import{a as L}from"./chunk-MM6DQ2I6.js";import{a as M,f as x,k as O,z as y}from"./chunk-TFL3IALR.js";import{Da as g,Eb as h,Fb as C,Gb as _,Hb as f,Ib as b,Qf as S,Sa as u,X as s,Ye as v,ab as p,ba as c,bb as m,fg as P,ob as d}from"./chunk-CMXAM7KO.js";import{j as n}from"./chunk-OYEQFDD5.js";var r=class r{constructor(e){this.notifier=e;n(this,"availableItems",[]);n(this,"allGroupLabel");n(this,"placeholder");n(this,"maxItems");n(this,"selectedItems");n(this,"propagateChange",e=>{});}writeValue(e){this.selectedItems=e?e.map(t=>({id:t})):[{group:this.allGroupLabel}];}registerOnChange(e){this.propagateChange=e;}registerOnTouched(){}onModelChange(){this.isMaxConstraintValid()&&this.propagateChange(this.buildOutputItems());}onBlur(){Array.isArray(this.selectedItems)&&this.selectedItems.length===0&&(this.selectedItems=[{group:this.allGroupLabel}]);}isMaxConstraintValid(){if(!this.maxItems)return!0;let e=this.buildOutputItems();return e&&e.length>=this.maxItems?(this.notifier.error(v("You can't select more than {maxItems, plural, =1 {1 item} other {{maxItems} items}}",{maxItems:this.maxItems})),!1):!0;}buildOutputItems(){if(Array.isArray(this.selectedItems)){if(this.selectedItems.length===0||this.selectedItems.length===this.availableItems.length)return null;if(this.selectedItems.length===1){let e=this.selectedItems[0];if((typeof e=="string"||typeof e=="number"?e:e.group)===this.allGroupLabel)return null;}return this.selectedItems.map(e=>typeof e=="string"||typeof e=="number"?e:e.group?e.group:e.id+"");}}};n(r,"\u0275fac",function(t){return new(t||r)(g(P));}),n(r,"\u0275cmp",c({type:r,selectors:[["my-select-checkbox-all"]],inputs:{availableItems:"availableItems",allGroupLabel:"allGroupLabel",placeholder:"placeholder",maxItems:"maxItems"},standalone:!0,features:[f([{provide:M,useExisting:s(()=>r),multi:!0}]),b],decls:1,vars:5,consts:[[3,"ngModelChange","focusout","ngModel","availableItems","selectableGroup","selectableGroupAsModel","placeholder"]],template:function(t,o){t&1&&(p(0,"my-select-checkbox",0),_("ngModelChange",function(a){return C(o.selectedItems,a)||(o.selectedItems=a),a;}),d("ngModelChange",function(){return o.onModelChange();})("focusout",function(){return o.onBlur();}),m()),t&2&&(h("ngModel",o.selectedItems),u("availableItems",o.availableItems)("selectableGroup",!0)("selectableGroupAsModel",!0)("placeholder",o.placeholder));},dependencies:[L,y,x,O],styles:[".muted[_ngcontent-%COMP%]{font-size:90%}ng-select[_ngcontent-%COMP%]{width:auto}@media screen and (max-width: auto){ng-select[_ngcontent-%COMP%]{width:100%}}ng-select[_ngcontent-%COMP%]     .ng-value-container{max-height:100px;overflow-y:auto;overflow-x:hidden}ng-select[_ngcontent-%COMP%]     .ng-value-label img{position:relative;top:-1px}ng-select[_ngcontent-%COMP%]     img{border-radius:50%;height:20px;width:20px}.root[_ngcontent-%COMP%]{display:flex;align-items:center}.root[_ngcontent-%COMP%] > my-select-options[_ngcontent-%COMP%]{flex-grow:1}my-select-options[_ngcontent-%COMP%] + input[_ngcontent-%COMP%]{display:block;font-size:15px;padding:3px 15px;width:auto;max-width:auto;color:var(--inputForegroundColor);background-color:var(--inputBackgroundColor);border:1px solid var(--inputBorderColor);border-radius:3px;line-height:23px;margin-inline-start:.3125rem}my-select-options[_ngcontent-%COMP%] + input[_ngcontent-%COMP%]::placeholder{color:var(--inputPlaceholderColor)}my-select-options[_ngcontent-%COMP%] + input[readonly][_ngcontent-%COMP%]{opacity:.7}@media screen and (max-width: calc(auto + 40px)){my-select-options[_ngcontent-%COMP%] + input[_ngcontent-%COMP%]{width:100%}}.input-suffix[_ngcontent-%COMP%]{margin-inline-start:.3125rem}"]}));var I=r;var l=class l{constructor(e){this.server=e;n(this,"maxLanguages");n(this,"selectedLanguages");n(this,"availableLanguages",[]);n(this,"allLanguagesGroup","All languages");n(this,"toWrite");n(this,"loaded",!1);n(this,"propagateChange",e=>{});}ngOnInit(){this.server.getVideoLanguages().subscribe(e=>{this.availableLanguages=[{label:"Unknown language",id:"_unknown",group:this.allLanguagesGroup,groupOrder:1}],this.availableLanguages=this.availableLanguages.concat(e.map(t=>t.id==="zxx"?{label:t.label,id:t.id,group:"Other",groupOrder:0}:{label:t.label,id:t.id,group:this.allLanguagesGroup,groupOrder:1})),this.availableLanguages.sort((t,o)=>t.groupOrder-o.groupOrder),this.loaded=!0,this.writeValue(this.toWrite);});}writeValue(e){if(!this.loaded){this.toWrite=e;return;}this.selectedLanguages=e;}registerOnChange(e){this.propagateChange=e;}registerOnTouched(){}onModelChange(){this.propagateChange(this.selectedLanguages);}};n(l,"\u0275fac",function(t){return new(t||l)(g(S));}),n(l,"\u0275cmp",c({type:l,selectors:[["my-select-languages"]],inputs:{maxLanguages:"maxLanguages"},standalone:!0,features:[f([{provide:M,useExisting:s(()=>l),multi:!0}]),b],decls:1,vars:4,consts:()=>{let e;return e="Add a new language",[["placeholder",e,3,"ngModelChange","ngModel","availableItems","maxItems","allGroupLabel"]];},template:function(t,o){t&1&&(p(0,"my-select-checkbox-all",0),_("ngModelChange",function(a){return C(o.selectedLanguages,a)||(o.selectedLanguages=a),a;}),d("ngModelChange",function(){return o.onModelChange();}),m()),t&2&&(h("ngModel",o.selectedLanguages),u("availableItems",o.availableLanguages)("maxItems",o.maxLanguages)("allGroupLabel",o.allLanguagesGroup));},dependencies:[I,y,x,O],styles:[".muted[_ngcontent-%COMP%]{font-size:90%}ng-select[_ngcontent-%COMP%]{width:auto}@media screen and (max-width: auto){ng-select[_ngcontent-%COMP%]{width:100%}}ng-select[_ngcontent-%COMP%]     .ng-value-container{max-height:100px;overflow-y:auto;overflow-x:hidden}ng-select[_ngcontent-%COMP%]     .ng-value-label img{position:relative;top:-1px}ng-select[_ngcontent-%COMP%]     img{border-radius:50%;height:20px;width:20px}.root[_ngcontent-%COMP%]{display:flex;align-items:center}.root[_ngcontent-%COMP%] > my-select-options[_ngcontent-%COMP%]{flex-grow:1}my-select-options[_ngcontent-%COMP%] + input[_ngcontent-%COMP%]{display:block;font-size:15px;padding:3px 15px;width:auto;max-width:auto;color:var(--inputForegroundColor);background-color:var(--inputBackgroundColor);border:1px solid var(--inputBorderColor);border-radius:3px;line-height:23px;margin-inline-start:.3125rem}my-select-options[_ngcontent-%COMP%] + input[_ngcontent-%COMP%]::placeholder{color:var(--inputPlaceholderColor)}my-select-options[_ngcontent-%COMP%] + input[readonly][_ngcontent-%COMP%]{opacity:.7}@media screen and (max-width: calc(auto + 40px)){my-select-options[_ngcontent-%COMP%] + input[_ngcontent-%COMP%]{width:100%}}.input-suffix[_ngcontent-%COMP%]{margin-inline-start:.3125rem}"]}));var w=l;export{I as a,w as b};/**i18n:2321df1a7d0424ae0b2c3b82420e9e89fc52f7caf578a34327a0567eb5289370*/