import{Ab as _,Ia as E,Ob as C,Qb as D,Sc as g,Tc as c,Zb as o,_b as a,cd as m,dd as x,gc as F,hc as y,hd as L,jb as r,jc as s,kc as I,sc as b,se as M,tc as T,uc as w,va as f,wa as h,wc as u,yc as l,zc as p}from"./chunk-UNHECMG2.js";var P=["fileInput"];function z(i,N){if(i&1&&(o(0,"div",3),l(1),a()),i&2){let e=I();r(),p(e.error())}}var j=(()=>{class i{constructor(){this.acceptedFileTypes=m.required(),this.error=m(null),this.value=L(null),this.dragging=E(!1),this.dragCount=0,this.fileInput=x.required("fileInput"),this.onDragEnter=()=>{this.dragCount+=1,this.dragCount===1&&this.dragging.set(!0)},this.onDragLeave=()=>{this.dragCount-=1,this.dragCount===0&&this.dragging.set(!1)}}ngAfterViewInit(){document.addEventListener("dragenter",this.onDragEnter),document.addEventListener("dragleave",this.onDragLeave)}ngOnDestroy(){document.removeEventListener("dragenter",this.onDragEnter),document.removeEventListener("dragleave",this.onDragLeave)}onFileInput(e){this.value.set(e?.item(0)??null)}onFileDrag(e){e.preventDefault()}onFileDrop(e){e.preventDefault(),this.dragCount=0,this.dragging.set(!1);let n=this.fileInput().nativeElement;n.files=e.dataTransfer?.files??null,n.dispatchEvent(new Event("change"))}static{this.\u0275fac=function(n){return new(n||i)}}static{this.\u0275cmp=_({type:i,selectors:[["bkd-file-input"]],viewQuery:function(n,t){n&1&&b(t.fileInput,P,5),n&2&&T()},inputs:{acceptedFileTypes:[1,"acceptedFileTypes"],error:[1,"error"],value:[1,"value"]},outputs:{value:"valueChange"},decls:13,vars:14,consts:[["fileInput",""],["for","formFile",1,"form-label"],["type","file","id","formFile",1,"form-control",3,"change","accept"],[1,"invalid-feedback"],["id","drop-zone",3,"drop","dragover"],[1,"material-icons"]],template:function(n,t){if(n&1){let S=F();o(0,"label",1),l(1),g(2,"translate"),a(),o(3,"input",2,0),s("change",function(){f(S);let d=w(4);return h(t.onFileInput(d.files))}),a(),C(5,z,2,1,"div",3),o(6,"div",4,0),s("drop",function(d){return t.onFileDrop(d)})("dragover",function(d){return t.onFileDrag(d)}),o(8,"i",5),l(9,"cloud_upload"),a(),o(10,"span"),l(11),g(12,"translate"),a()()}n&2&&(r(),p(c(2,10,"shared.file-input.input-label")),r(2),u("is-valid",t.value()&&!t.error())("is-invalid",t.error()),y("accept",t.acceptedFileTypes().join(",")),r(2),D(t.error()?5:-1),r(),u("dragging",t.dragging()),r(5),p(c(12,12,"shared.file-input.drop-zone-label")))},dependencies:[M],styles:["#drop-zone[_ngcontent-%COMP%]{border:2px dashed #adb5bd;display:none;flex-direction:column;justify-content:center;align-items:center;padding:5rem;position:fixed;top:0;left:0;width:100vw;height:100vh;z-index:1055;background:#dededee6}#drop-zone.dragging[_ngcontent-%COMP%]{display:flex}"],changeDetection:0})}}return i})();export{j as a};
