import{E as k,a as L,c as V,g as z,o as $}from"./chunk-5Y6FVWZJ.js";import{G,H}from"./chunk-FUYX4JKG.js";import{a as W}from"./chunk-B54J7MIK.js";import{Da as l,Db as S,Dc as D,Ec as a,Hb as C,Jb as c,Na as E,Sg as U,Wc as I,Y as M,Yb as _,Zb as b,ba as y,cc as F,dc as O,ec as w,fd as A,ga as v,gb as m,ha as N,hb as u,kc as P,mb as g,nb as s,ob as r,pb as T,ra as R,zb as x}from"./chunk-7XPKW7E5.js";import{i as h}from"./chunk-SNJLK5AI.js";function X(n,o){if(n&1&&T(0,"my-global-icon",3),n&2){let d=c();g("iconName",d.icon());}}function j(n,o){if(n&1&&(s(0,"div",5),_(1),r()),n&2){let d=c();l(),b(d.filename);}}function B(n,o){if(n&1){let d=x();s(0,"button",7),C("click",function(){v(d);let t=c();return N(t.reset());}),S(1,0),r();}}var ae=(()=>{let o=class o{notifier=y(U);theme=a("secondary");inputLabel=a(void 0);inputName=a(void 0);extensions=a([]);maxFileSize=a(void 0);displayFilename=a(!1);displayReset=a(!1);icon=a(void 0);buttonTooltip=a(void 0);fileChanged=D();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[t]=i.target.files;if(t.size>this.maxFileSize()){this.notifier.error("Tiedoston koko on liian suuri.");return;}let e="."+t.name.split(".").pop();if(this.extensions().includes(e.toLowerCase())===!1){let f="This input cannot handle this kind of file. Accepted extensions are "+this.allowedExtensionsMessage+".";this.notifier.error(f);return;}this.file=t,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(){}};h(o,"\u0275fac",function(t){return new(t||o)();}),h(o,"\u0275cmp",E({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:[P([{provide:L,useExisting:M(()=>o),multi:!0}]),R],decls:8,vars:10,consts:()=>{let i;return i="Palauta",[i,[1,"root"],[1,"button-file",3,"ngClass","ngbTooltip"],[3,"iconName"],["type","file",3,"change","ngModelChange","name","id","accept","ngModel"],[1,"filename","ellipsis"],[1,"reset-button","reset-button-small","ms-2"],[1,"reset-button","reset-button-small","ms-2",3,"click"]];},template:function(t,e){t&1&&(s(0,"div",1)(1,"div",2),m(2,X,1,1,"my-global-icon",3),s(3,"span"),_(4),r(),s(5,"input",4),C("change",function(p){return e.fileChange(p);}),w("ngModelChange",function(p){return O(e.fileInputValue,p)||(e.fileInputValue=p),p;}),r()(),m(6,j,2,1,"div",5),m(7,B,2,0,"button",6),r()),t&2&&(l(),g("ngClass",e.classes)("ngbTooltip",e.buttonTooltip()),l(),u(e.icon()?2:-1),l(2),b(e.inputLabel()),l(),g("name",e.inputName())("id",e.inputName())("accept",e.extensions()),F("ngModel",e.fileInputValue),l(),u(e.displayFilename()===!0&&e.filename?6:-1),l(),u(e.displayReset()&&e.file?7:-1));},dependencies:[A,I,H,G,k,V,z,$,W],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-UQXWIUCR.css.map */`]}));let n=o;return n;})();export{ae as a};/**i18n:8bbaae6e8f892c770558263409b04864bea4163b0f68bbe3358622c96ded4382*///# sourceMappingURL=chunk-7UY25XPA.js.map