import{Ca as dA,Fn as MV,Gn as NV,Hi as Zt,Ja as g,Kr as Tu,Ns as rh,Ra as f5,Rr as Si,So as jV,V as CI,X as D$,_s as ph,ai as Vj,et as DI,gt as Ex,jt as Gj,k as Bb,s as $a,ss as o5,vc as wf,ya as ci,yc as wp,yi as XRe,za as fA}from"./chunk-b0nJCs5_.js";import{A as qn,O as ln,r as D,s as Jn}from"./chunk-Cmet2Nw-.js";import{t as Vt}from"./chunk-aIvt-K7L.js";var v=class i{notifier=g(Si);inputId=ph.required();availableItems=ph([]);placeholder=ph(void 0);maxIndividualItems=ph(void 0);allSelectedLabel=ph(void 0);selectedLabel=ph(void 0);virtualScroll=ph(!1,{transform:Tu});selectedItemsLabel;selectedItems;propagateChange=e=>{};writeValue(e){if(e){this.selectedItems=e,this.updateLabel();return}this.selectAll()}registerOnChange(e){this.propagateChange=e}registerOnTouched(){}ngOnChanges(){this.updateLabel()}onModelChange(){this.updateLabel(),this.isMaxItemsValid()&&this.propagateChange(this.buildOutputItems())}onPanelHide(){Array.isArray(this.selectedItems)&&this.selectedItems.length===0&&this.selectAll(),this.checkMaxItemsOrSelectAll()}isMaxItemsValid(){let e=this.maxIndividualItems();if(!e)return!0;let t=this.buildOutputItems();return t?!(t.length>=e):!0}checkMaxItemsOrSelectAll(){this.isMaxItemsValid()||(this.notifier.error(XRe("Você não pode selecionar mais de {maxItems, plural, =1 {1 item} other {{maxItems} itens}}",{maxItems:this.maxIndividualItems()})),this.selectAll())}selectAll(){this.selectedItems=this.availableItems().map(e=>e.id+``),this.updateLabel()}updateLabel(){let e=this.availableItems();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}static ɵfac=function(t){return new(t||i)};static ɵcmp=$a({type:i,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:[f5([{provide:D,useExisting:wf(()=>i),multi:!0}]),ci],decls:1,vars:6,consts:[[`showClear`,`false`,`showToggleAll`,`true`,3,`ngModelChange`,`panelHide`,`ngModel`,`availableItems`,`placeholder`,`inputId`,`selectedItemsLabel`,`virtualScroll`]],template:function(t,l){t&1&&(wp(0,`my-select-checkbox`,0),fA(`ngModelChange`,function(s){return o5(l.selectedItems,s)||(l.selectedItems=s),s}),rh(`ngModelChange`,function(){return l.onModelChange()})(`panelHide`,function(){return l.onPanelHide()}),Bb(),Vj()),t&2&&(dA(`ngModel`,l.selectedItems),Ex(`availableItems`,l.availableItems())(`placeholder`,l.placeholder())(`inputId`,l.inputId())(`selectedItemsLabel`,l.selectedItemsLabel)(`virtualScroll`,l.virtualScroll()),Gj())},dependencies:[Vt,Jn,qn,ln],encapsulation:2,changeDetection:1})};function $(i,e){if(i&1){let t=jV();wp(0,`my-select-checkbox-default-all`,1),fA(`ngModelChange`,function(a){CI(t);let s=D$();return o5(s.selectedLanguages,a)||(s.selectedLanguages=a),DI(a)}),rh(`ngModelChange`,function(){CI(t);return DI(D$().onModelChange())}),Bb(),Vj()}if(i&2){let t=D$();Ex(`availableItems`,t.availableLanguages),dA(`ngModel`,t.selectedLanguages),Ex(`inputId`,t.inputId())(`maxIndividualItems`,t.maxLanguages()),Gj()}}var G=class i{server=g(Zt);inputId=ph.required();maxLanguages=ph(void 0);selectedLanguages;availableLanguages;ngOnInit(){this.server.getVideoLanguages().subscribe(e=>{let t=e.find(l=>l.id===`zxx`);this.availableLanguages=[{label:"Língua desconhecida",id:`_unknown`},t,...e.filter(l=>l.id!==`zxx`).map(l=>({label:l.label,id:l.id}))]})}propagateChange=e=>{};writeValue(e){this.selectedLanguages=e}registerOnChange(e){this.propagateChange=e}registerOnTouched(){}onModelChange(){this.propagateChange(this.selectedLanguages)}static ɵfac=function(t){return new(t||i)};static ɵcmp=$a({type:i,selectors:[[`my-select-languages`]],inputs:{inputId:[1,`inputId`],maxLanguages:[1,`maxLanguages`]},features:[f5([{provide:D,useExisting:wf(()=>i),multi:!0}])],decls:1,vars:1,consts:()=>{let e;e="Todos os idiomas";let t;t="";let l;return l="Adicionar um novo idioma",[[`virtualScroll`,`true`,`virtualScrollItemSize`,`37`,`allSelectedLabel`,e,`selectedLabel`,t,`placeholder`,l,3,`availableItems`,`ngModel`,`inputId`,`maxIndividualItems`],[`virtualScroll`,`true`,`virtualScrollItemSize`,`37`,`allSelectedLabel`,e,`selectedLabel`,t,`placeholder`,l,3,`ngModelChange`,`availableItems`,`ngModel`,`inputId`,`maxIndividualItems`]]},template:function(t,l){t&1&&NV(0,$,1,4,`my-select-checkbox-default-all`,0),t&2&&MV(l.availableLanguages?0:-1)},dependencies:[v,Jn,qn,ln],encapsulation:2,changeDetection:1})};export{v as n,G as t};
//# debugId=cec0762a-f5c0-5c99-ad52-b681f2dcd5af
//# sourceMappingURL=chunk-kAUBfzSL.js.map