import{E as G,F as H}from"./chunk-SIHEBH6V.js";import{C as $,a as V,c as D,g as z,n as k}from"./chunk-2UGJU7DR.js";import{a as j}from"./chunk-IM5O2N5E.js";import{$b as w,Bb as h,Cb as c,Fc as P,Ha as a,Hc as L,Pb as _,Qb as C,Sa as S,Tc as A,Vb as F,Wb as I,X as y,Xb as O,Ya as d,aa as b,eb as s,fh as W,ga as M,ha as E,ia as R,nb as r,ob as p,pb as v,sa as T,ta as l,tb as x,xb as N}from"./chunk-EWB56PWF.js";import{i as g}from"./chunk-2T7OYDCL.js";function U(t,o){if(t&1&&v(0,"my-global-icon",7),t&2){let m=c();s("iconName",m.icon());}}function X(t,o){if(t&1&&(r(0,"div",8),_(1),p()),t&2){let m=c();a(),C(m.filename);}}function B(t,o){if(t&1){let m=x();r(0,"button",9),h("click",function(){E(m);let n=c();return R(n.reset());}),N(1,0),p();}}var le=(()=>{let o=class o{notifier=b(W);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=T();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","icon-only":!this.inputLabel()};}fileChange(i){if(i.target.files?.length){let[n]=i.target.files;if(n.size>this.maxFileSize()){this.notifier.error("Tha am faidhle seo ro mh\xF2r.");return;}let e="."+n.name.split(".").pop();if(this.extensions().includes(e.toLowerCase())===!1){let f="Chan urrainn dha PeerTube faidhle dhen t-se\xF2rsa seo a l\xE0imhseachadh. Seo na leudachain ris a bheil taic: "+this.allowedExtensionsMessage+".";this.notifier.error(f);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=i=>{};writeValue(i){this.file=i,this.file||(this.fileInputValue=null);}registerOnChange(i){this.propagateChange=i;}registerOnTouched(){}};g(o,"\u0275fac",function(n){return new(n||o)();}),g(o,"\u0275cmp",S({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 i;return i="Ath-shuidhich",[i,[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,U,1,1,"my-global-icon",3),r(3,"span"),_(4),p(),r(5,"input",4),h("change",function(u){return e.fileChange(u);}),O("ngModelChange",function(u){return I(e.fileInputValue,u)||(e.fileInputValue=u),u;}),p()(),d(6,X,2,1,"div",5)(7,B,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()),F("ngModel",e.fileInputValue),a(),s("ngIf",e.displayFilename()===!0&&e.filename),a(),s("ngIf",e.displayReset()&&e.file));},dependencies:[A,P,L,H,G,j,$,D,z,k],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:24px;height:24px;line-height:24px}.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-LZJDT4DL.css.map */`]}));let t=o;return t;})();export{le as a};/**i18n:85d030b7fdd36d163c6d41dcef9178681a6baa573eb199e8b12fe27dbb057a98*///# sourceMappingURL=chunk-NABIRIYG.js.map