import{c as k}from"./chunk-XJHJSTYT.js";import{C as M,a as E,g as L,n as b}from"./chunk-VJWG2YMW.js";import{$b as C,Bb as p,Cb as h,Hc as N,Hh as w,Sa as m,Vb as S,Wb as f,X as c,Xb as I,Ya as T,aa as u,eb as r,fh as P,ha as v,ia as x,nb as g,ob as _,sc as R,ta as n,tb as y,zg as O}from"./chunk-QIQJDAPQ.js";import{i as o}from"./chunk-3HGMGVFC.js";var D=(()=>{let a=class a{notifier=u(P);inputId=n.required();availableItems=n([]);placeholder=n(void 0);maxIndividualItems=n(void 0);allSelectedLabel=n(void 0);selectedLabel=n(void 0);virtualScroll=n(!1,{transform:R});selectedItemsLabel;selectedItems;propagateChange=e=>{};writeValue(e){e?this.selectedItems=e:this.selectAll();}registerOnChange(e){this.propagateChange=e;}registerOnTouched(){}onModelChange(){this.updateLabel(),this.isMaxItemsValid()&&this.propagateChange(this.buildOutputItems());}onPanelHide(){Array.isArray(this.selectedItems)&&this.selectedItems.length===0&&this.selectAll(),this.checkMaxItems();}isMaxItemsValid(){let e=this.maxIndividualItems();if(!e)return!0;let l=this.buildOutputItems();return l?!(l.length>=e):!0;}checkMaxItems(){this.isMaxItemsValid()||(this.notifier.error(O("\xDE\xFA getur ekki vali\xF0 meira en {maxItems, plural, =1 {1 atri\xF0i} other {{maxItems} atri\xF0i}}",{maxItems:this.maxIndividualItems()})),this.selectAll());}selectAll(){this.selectedItems=this.availableItems().map(e=>e.id+""),this.updateLabel();}updateLabel(){let e=this.availableItems();this.selectedItems&&e&&this.selectedItems.length===e.length?this.selectedItemsLabel=this.allSelectedLabel():this.selectedItemsLabel=this.selectedLabel();}buildOutputItems(){if(Array.isArray(this.selectedItems))return this.selectedItems.length===0||this.selectedItems.length===this.availableItems().length?null:this.selectedItems;}};o(a,"\u0275fac",function(l){return new(l||a)();}),o(a,"\u0275cmp",m({type:a,selectors:[["my-select-checkbox-default-all"]],inputs:{inputId:[1,"inputId"],availableItems:[1,"availableItems"],placeholder:[1,"placeholder"],maxIndividualItems:[1,"maxIndividualItems"],allSelectedLabel:[1,"allSelectedLabel"],selectedLabel:[1,"selectedLabel"],virtualScroll:[1,"virtualScroll"]},features:[C([{provide:E,useExisting:c(()=>a),multi:!0}])],decls:1,vars:6,consts:[["showClear","false","showToggleAll","true",3,"ngModelChange","panelHide","ngModel","availableItems","placeholder","inputId","selectedItemsLabel","virtualScroll"]],template:function(l,t){l&1&&(g(0,"my-select-checkbox",0),I("ngModelChange",function(A){return f(t.selectedItems,A)||(t.selectedItems=A),A;}),p("ngModelChange",function(){return t.onModelChange();})("panelHide",function(){return t.onPanelHide();}),_()),l&2&&(S("ngModel",t.selectedItems),r("availableItems",t.availableItems())("placeholder",t.placeholder())("inputId",t.inputId())("selectedItemsLabel",t.selectedItemsLabel)("virtualScroll",t.virtualScroll()));},dependencies:[k,M,L,b],encapsulation:2}));let i=a;return i;})();function V(i,a){if(i&1){let s=y();g(0,"my-select-checkbox-default-all",1),I("ngModelChange",function(l){v(s);let t=h();return f(t.selectedLanguages,l)||(t.selectedLanguages=l),x(l);}),p("ngModelChange",function(){v(s);let l=h();return x(l.onModelChange());}),_();}if(i&2){let s=h();r("availableItems",s.availableLanguages),S("ngModel",s.selectedLanguages),r("inputId",s.inputId())("maxIndividualItems",s.maxLanguages());}}var ee=(()=>{let a=class a{server=u(w);inputId=n.required();maxLanguages=n(void 0);selectedLanguages;availableLanguages;ngOnInit(){this.server.getVideoLanguages().subscribe(e=>{let l=e.find(t=>t.id==="zxx");this.availableLanguages=[{label:"\xD3\xFEekkt tungum\xE1l",id:"_unknown"},l,...e.filter(t=>t.id!=="zxx").map(t=>({label:t.label,id:t.id}))];});}propagateChange=e=>{};writeValue(e){this.selectedLanguages=e;}registerOnChange(e){this.propagateChange=e;}registerOnTouched(){}onModelChange(){this.propagateChange(this.selectedLanguages);}};o(a,"\u0275fac",function(l){return new(l||a)();}),o(a,"\u0275cmp",m({type:a,selectors:[["my-select-languages"]],inputs:{inputId:[1,"inputId"],maxLanguages:[1,"maxLanguages"]},features:[C([{provide:E,useExisting:c(()=>a),multi:!0}])],decls:1,vars:1,consts:()=>{let e;e="\xD6ll tungum\xE1l";let l;l="";let t;return t="B\xE6ta vi\xF0 n\xFDju tungum\xE1li",[["virtualScroll","true","virtualScrollItemSize","37","allSelectedLabel",e,"selectedLabel",l,"placeholder",t,3,"availableItems","ngModel","inputId","maxIndividualItems","ngModelChange",4,"ngIf"],["virtualScroll","true","virtualScrollItemSize","37","allSelectedLabel",e,"selectedLabel",l,"placeholder",t,3,"ngModelChange","availableItems","ngModel","inputId","maxIndividualItems"]];},template:function(l,t){l&1&&T(0,V,1,4,"my-select-checkbox-default-all",0),l&2&&r("ngIf",t.availableLanguages);},dependencies:[D,M,L,b,N],encapsulation:2}));let i=a;return i;})();export{D as a,ee as b};/**i18n:d946b30bd8b2b104e368c275b91cb34bb911fa22291c946a5e8c8a6facd9306d*///# sourceMappingURL=chunk-KVG4XH3A.js.map