angular.module("app").controller("ListItemEditWindowController",["$windowScope","environment","itemParent","item","itemSettings","itemPath","useConditional","nameBinding","newItemName","modal","datasource","utils",function(t,n,i,e,a,l,o,r,m,s,g,u){t.itemParent=i,t.item=e,t.itemPath=l,t.itemSettings=a,t.useConditional=o,t.nameBinding=r,t.newItemName=m||"Neuer Eintrag";let nameBindingOptionsToString=t=>{let n=[].concat(t);return n.length-4>1&&(n=n.slice(0,4),n.push("...")),n.join(", ").trim()};t.showConditionalModal=function(){t.item&&t.item._internal&&s.show("ControlConditionalModal",(function(n){angular.isObject(n)&&(t.item._internal.condition=n.condition,t.item._internal.conditionalSettings=n.conditionalSettings)}),{conditionalSettings:t.item._internal.conditionalSettings||[]})},angular.isString(r)&&t.$watch("item."+r,(function(i){const e=t.newItemName||"Neuer Eintrag";let a=null;if(t.itemSettings&&t.itemSettings.length&&(a=t.itemSettings.find(t=>t.property===r)),t.item&&angular.isObject(t.item._internal)){if(i&&a&&a.options){if(angular.isString(a.options))return void g.resolve(a.options,"value",[].concat(i),n=>{n&&n.length?(n=n.map(t=>t.label),t.item._internal.name=u.stripTags(nameBindingOptionsToString(n))):t.item._internal.name=e,t.$apply()});if(angular.isArray(a.options)){let n=[];[].concat(i).forEach(t=>{n=n.concat(a.options.filter(n=>n.value&&n.value===t).map(t=>t.label))});let e=u.stripTags(nameBindingOptionsToString(n));if(e)return void(t.item._internal.name=e)}}else{if(i&&angular.isObject(i)&&i._multilanguage&&i[n.languageDefault.cISO])return void(t.item._internal.name=u.stripTags(""+i[n.languageDefault.cISO]));if(i&&(angular.isString(i)||angular.isNumber(i)))return void(t.item._internal.name=u.stripTags(""+i))}t.item._internal.name=e}}),!0)}]);