import{D as k}from"./chunk-YLQIMX27.js";import{A as D,a as A,c as V,g as L,l as z}from"./chunk-I267ADJP.js";import{a as G}from"./chunk-NIY7P74G.js";import{$a as a,Fa as l,Ga as R,Hb as h,Ib as _,La as v,Mb as I,Nb as F,Ob as N,Pb as O,Qf as $,Sa as g,Y as C,ha as y,ia as b,ib as s,ja as M,jb as r,kb as S,ob as T,qa as E,sb as x,tc as w,vc as P,wb as d,xb as c}from"./chunk-4JM6MIZ5.js";import{i as u}from"./chunk-QJQRWPYR.js";function H(i,o){if(i&1&&S(0,"my-global-icon",7),i&2){let p=c();a("iconName",p.icon);}}function B(i,o){if(i&1&&(s(0,"div",8),h(1),r()),i&2){let p=c();l(),_(p.filename);}}function U(i,o){if(i&1){let p=T();s(0,"button",9),d("click",function(){b(p);let n=c();return M(n.reset());}),x(1,0),r();}}var ie=(()=>{let o=class o{notifier;theme="secondary";inputLabel;inputName;extensions=[];maxFileSize;displayFilename=!1;displayReset=!1;icon;buttonTooltip;fileChanged=new E();classes={};allowedExtensionsMessage="";fileInputValue;file;constructor(t){this.notifier=t;}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("\u0627\u06CC\u0646 \u0641\u0627\u06CC\u0644 \u062E\u06CC\u0644\u06CC \u0628\u0632\u0631\u06AF \u0627\u0633\u062A.");return;}let e="."+n.name.split(".").pop();if(this.extensions.includes(e.toLowerCase())===!1){let f="\u067E\u06CC\u0631\u062A\u06CC\u0648\u0628 \u0627\u0645\u06A9\u0627\u0646 \u06A9\u0627\u0631\u06A9\u0631\u062F\u0646 \u0628\u0627 \u0627\u06CC\u0646 \u0646\u0648\u0639 \u0641\u0627\u06CC\u0644 \u0631\u0627 \u0646\u062F\u0627\u0631\u062F. \u067E\u0633\u0648\u0646\u062F\u0647\u0627\u06CC \u0645\u0648\u0631\u062F \u067E\u0630\u06CC\u0631\u0634 "+this.allowedExtensionsMessage+" \u0647\u0633\u062A\u0646\u062F.";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=t=>{};writeValue(t){this.file=t,this.file||(this.fileInputValue=null);}registerOnChange(t){this.propagateChange=t;}registerOnTouched(){}};u(o,"\u0275fac",function(n){return new(n||o)(R($));}),u(o,"\u0275cmp",v({type:o,selectors:[["my-reactive-file"]],inputs:{theme:"theme",inputLabel:"inputLabel",inputName:"inputName",extensions:"extensions",maxFileSize:"maxFileSize",displayFilename:"displayFilename",displayReset:"displayReset",icon:"icon",buttonTooltip:"buttonTooltip"},outputs:{fileChanged:"fileChanged"},features:[O([{provide:A,useExisting:C(()=>o),multi:!0}]),y],decls:8,vars:10,consts:()=>{let t;return t="\u0628\u0627\u0632\u0646\u0634\u0627\u0646\u06CC \u06A9\u0631\u062F\u0646",[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&&(s(0,"div",1)(1,"div",2),g(2,H,1,1,"my-global-icon",3),s(3,"span"),h(4),r(),s(5,"input",4),d("change",function(m){return e.fileChange(m);}),N("ngModelChange",function(m){return F(e.fileInputValue,m)||(e.fileInputValue=m),m;}),r()(),g(6,B,2,1,"div",5)(7,U,2,0,"button",6),r()),n&2&&(l(),a("ngClass",e.classes)("ngbTooltip",e.buttonTooltip),l(),a("ngIf",e.icon),l(2),_(e.inputLabel),l(),a("name",e.inputName)("id",e.inputName)("accept",e.extensions),I("ngModel",e.fileInputValue),l(),a("ngIf",e.displayFilename===!0&&e.filename),l(),a("ngIf",e.displayReset&&e.filename));},dependencies:[w,k,P,G,D,V,L,z],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{ie as a};/**i18n:68865f44f2a527c44cf5136a17c76a0ff8308c2bae5c7c8d50070a5fb9847c44*///# sourceMappingURL=chunk-DVDDNBHR.js.map