import{D as $}from"./chunk-OFG4OGZP.js";import{A as k,a as V,c as L,g as z,l as D}from"./chunk-RB6U2MY6.js";import{a as H}from"./chunk-6OQTGYWE.js";import{Db as h,Dc as P,Eb as f,Fc as A,Ha as a,Rb as _,Sa as T,Sb as C,Uf as G,Wb as I,Xb as N,Y as y,Yb as O,Za as d,Zb as w,ba as b,ga as M,gb as s,ha as E,ia as R,pb as r,qb as p,rb as v,sa as S,ta as l,vb as x,zb as F}from"./chunk-ZXQQIUTT.js";import{i as g}from"./chunk-RE7RSUSQ.js";function B(i,o){if(i&1&&v(0,"my-global-icon",7),i&2){let m=f();s("iconName",m.icon());}}function U(i,o){if(i&1&&(r(0,"div",8),_(1),p()),i&2){let m=f();a(),C(m.filename);}}function W(i,o){if(i&1){let m=x();r(0,"button",9),h("click",function(){E(m);let n=f();return R(n.reset());}),F(1,0),p();}}var te=(()=>{let o=class o{notifier=b(G);theme=l("secondary");inputLabel=l(void 0);inputName=l(void 0);extensions=l([]);maxFileSize=l(void 0);displayFilename=l(!1);displayReset=l(!1);icon=l(void 0);buttonTooltip=l(void 0);fileChanged=S();classes={};allowedExtensionsMessage="";fileInputValue;file;get filename(){return this.file?this.file.name:"";}ngOnInit(){this.allowedExtensionsMessage=this.extensions().join(", "),this.buildClasses();}ngOnChanges(){this.buildClasses();}buildClasses(){this.classes={"with-icon":!!this.icon(),"primary-button":this.theme()==="primary","secondary-button":this.theme()==="secondary"};}fileChange(t){if(t.target.files?.length){let[n]=t.target.files;if(n.size>this.maxFileSize()){this.notifier.error("Aquest fitxer \xE9s massa gran.");return;}let e="."+n.name.split(".").pop();if(this.extensions().includes(e.toLowerCase())===!1){let u="PeerTube no pot gestionar aquest tipus de fitxers. Les extensions acceptades s\xF3n "+this.allowedExtensionsMessage+".";this.notifier.error(u);return;}this.file=n,this.propagateChange(this.file);}this.fileChanged.emit(this.file);}reset(){this.writeValue(void 0),this.propagateChange(void 0),this.fileChanged.emit(void 0);}propagateChange=t=>{};writeValue(t){this.file=t,this.file||(this.fileInputValue=null);}registerOnChange(t){this.propagateChange=t;}registerOnTouched(){}};g(o,"\u0275fac",function(n){return new(n||o)();}),g(o,"\u0275cmp",T({type:o,selectors:[["my-reactive-file"]],inputs:{theme:[1,"theme"],inputLabel:[1,"inputLabel"],inputName:[1,"inputName"],extensions:[1,"extensions"],maxFileSize:[1,"maxFileSize"],displayFilename:[1,"displayFilename"],displayReset:[1,"displayReset"],icon:[1,"icon"],buttonTooltip:[1,"buttonTooltip"]},outputs:{fileChanged:"fileChanged"},features:[w([{provide:V,useExisting:y(()=>o),multi:!0}]),M],decls:8,vars:10,consts:()=>{let t;return t="Restablir",[t,[1,"root"],[1,"button-file",3,"ngClass","ngbTooltip"],[3,"iconName",4,"ngIf"],["type","file",3,"change","ngModelChange","name","id","accept","ngModel"],["class","filename",4,"ngIf"],["class","reset-button reset-button-small ms-2",3,"click",4,"ngIf"],[3,"iconName"],[1,"filename"],[1,"reset-button","reset-button-small","ms-2",3,"click"]];},template:function(n,e){n&1&&(r(0,"div",1)(1,"div",2),d(2,B,1,1,"my-global-icon",3),r(3,"span"),_(4),p(),r(5,"input",4),h("change",function(c){return e.fileChange(c);}),O("ngModelChange",function(c){return N(e.fileInputValue,c)||(e.fileInputValue=c),c;}),p()(),d(6,U,2,1,"div",5)(7,W,2,0,"button",6),p()),n&2&&(a(),s("ngClass",e.classes)("ngbTooltip",e.buttonTooltip()),a(),s("ngIf",e.icon()),a(2),C(e.inputLabel()),a(),s("name",e.inputName())("id",e.inputName())("accept",e.extensions()),I("ngModel",e.fileInputValue),a(),s("ngIf",e.displayFilename()===!0&&e.filename),a(),s("ngIf",e.displayReset()&&e.filename));},dependencies:[P,$,A,H,k,L,z,D],styles:[`.root[_ngcontent-%COMP%]{height:auto;display:flex;align-items:center}.root[_ngcontent-%COMP%]   .button-file.with-icon[_ngcontent-%COMP%]   my-global-icon[_ngcontent-%COMP%]{position:relative;top:-1px;right:0;display:inline-block;width:20px;height:20px;line-height:20px}.root[_ngcontent-%COMP%]   .button-file.with-icon[_ngcontent-%COMP%]:not(.icon-only)   my-global-icon[_ngcontent-%COMP%]{margin-inline-end:.1875rem}.root[_ngcontent-%COMP%]   .filename[_ngcontent-%COMP%]{font-weight:600;margin-inline-start:.3125rem}
/*# sourceMappingURL=reactive-file.component-4GUBBEP3.css.map */`]}));let i=o;return i;})();export{te as a};/**i18n:4ea3d52b0fe89d1d8e6fff59c182aeadbd7786f17ffe9a1efa1c7ed627997eaf*///# sourceMappingURL=chunk-5IHW63P6.js.map