import{l as le,h}from'./chunk-Bms7X8vH.js';import{s}from'./chunk-ChTAcsy3.js';import{g,$ as $t,L as qp,R as tl,fd as rxe,b as Pa,ah as c$,bP as D,bQ as af,U as cl,V as w3,fe as A3,J as Jn,q as qn,l as ln,k as k2,s as sp,m as _2,n as Mx,F as Fp,u as ub,t as GH,a3 as B0,a4 as l$,z as zB,A as w2,N as Nx,W as WH,e as Pp,o as bV,cF as sw,d as $I,aj as IV,G as GI,p as e$}from'./main-BiUBeaMj.js';var X=i=>({"buttons-aside":i});function W(i,S){if(i&1&&Pp(0,"img",2),i&2){let e=bV();B0("ngStyle",e.previewSize())("src",e.imageSrc,sw);}}function q(i,S){if(i&1&&Pp(0,"div",3),i&2){let e=bV();B0("ngStyle",e.previewSize());}}function J(i,S){if(i&1){let e=k2();sp(0,"my-delete-button",7),Fp("click",function(){$I(e),bV();let t=IV(5);return GI(t.reset());}),ub();}}var me=(()=>{class i{serverService=g($t);inputName=qp.required();inputLabel=qp();displayDelete=qp(false,{transform:tl});buttonsAside=qp(false,{transform:tl});previewSize=qp();fileConstraints=qp();imageSrc;maxSizeText;file;imageExtensions=[];maxImageSize;maxImageSizeInBytes;allowedExtensionsMessage="";serverConfig;bytesPipe;constructor(){this.bytesPipe=new s(),this.maxSizeText="mida m\xE0xima";}getReactiveFileButtonTooltip(){return"(extensions: "+this.imageExtensions.join(", ")+", mida m\xE0xima: "+this.maxImageSizeInBytes+")";}ngOnInit(){this.serverConfig=this.serverService.getHTMLConfig();let e=this.fileConstraints()??this.serverConfig.video.image;this.imageExtensions=e.extensions,this.maxImageSize=e.size.max,this.maxImageSizeInBytes=this.bytesPipe.transform(this.maxImageSize),this.allowedExtensionsMessage=this.imageExtensions.join(", ");}onFileChanged(e){this.file=e,this.propagateChange(this.file),this.updatePreview();}propagateChange=e=>{};writeValue(e){this.file=e,this.updatePreview();}registerOnChange(e){this.propagateChange=e;}registerOnTouched(){}updatePreview(){this.file?rxe(this.file).then(e=>this.imageSrc=e):this.imageSrc=void 0;}static ɵfac=function(n){return new(n||i)();};static ɵcmp=Pa({type:i,selectors:[["my-image-input"]],inputs:{inputName:[1,"inputName"],inputLabel:[1,"inputLabel"],displayDelete:[1,"displayDelete"],buttonsAside:[1,"buttonsAside"],previewSize:[1,"previewSize"],fileConstraints:[1,"fileConstraints"]},features:[c$([{provide:D,useExisting:af(()=>i),multi:true}])],decls:7,vars:11,consts:()=>{let e;e="Vista pr\xE8via";let n;return n="Suprimir la imatge",[["reactiveFile",""],[1,"preview-container",3,"ngClass"],["alt",e,1,"preview",3,"ngStyle","src"],[1,"preview","no-image",3,"ngStyle"],[1,"buttons"],["placement","right","icon","upload","theme","primary",3,"ngModelChange","fileChanged","ngModel","inputName","inputLabel","extensions","maxFileSize","buttonTooltip"],["title",n,"theme","danger"],["title",n,"theme","danger",3,"click"]];},template:function(n,t){if(n&1){let k=k2();sp(0,"div",1),_2(1,W,1,2,"img",2)(2,q,1,1,"div",3),sp(3,"div",4)(4,"my-reactive-file",5,0),Mx("ngModelChange",function(a){return $I(k),e$(t.file,a)||(t.file=a),GI(a);}),Fp("fileChanged",function(a){return t.onFileChanged(a);}),ub(),GH(),_2(6,J,1,0,"my-delete-button",6),ub()();}n&2&&(B0("ngClass",l$(9,X,t.buttonsAside())),zB(),w2(t.imageSrc?1:2),zB(3),Nx("ngModel",t.file),B0("inputName",t.inputName())("inputLabel",t.inputLabel())("extensions",t.imageExtensions)("maxFileSize",t.maxImageSize)("buttonTooltip",t.getReactiveFileButtonTooltip()),WH(),zB(2),w2(t.displayDelete()&&t.file?6:-1));},dependencies:[cl,w3,A3,Jn,qn,ln,le,h],styles:["[_nghost-%COMP%]{display:block}.preview-container[_ngcontent-%COMP%], .preview[_ngcontent-%COMP%]{height:100%;width:100%}.preview-container[_ngcontent-%COMP%]{position:relative}.preview-container[_ngcontent-%COMP%]   .buttons[_ngcontent-%COMP%]{display:flex;gap:10px}.preview-container[_ngcontent-%COMP%]   .preview[_ngcontent-%COMP%]{object-fit:cover;border-radius:4px;max-width:100%}.preview-container[_ngcontent-%COMP%]:not(.buttons-aside)   .buttons[_ngcontent-%COMP%]{position:absolute;bottom:10px;left:10px;flex-wrap:wrap}.preview-container[_ngcontent-%COMP%]:not(.buttons-aside)   .preview.no-image[_ngcontent-%COMP%]{border:2px solid var(--secondary-icon-color);background-color:var(--bg)}.preview-container.buttons-aside[_ngcontent-%COMP%]{text-align:center;border:1px solid var(--secondary-icon-color);border-radius:4px;width:min-content;padding-inline-start:calc(1.275rem + .3vw)}@media(min-width:1200px){.preview-container.buttons-aside[_ngcontent-%COMP%]{padding-inline-start:1.5rem}}.preview-container.buttons-aside[_ngcontent-%COMP%]{padding-inline-end:calc(1.275rem + .3vw)}@media(min-width:1200px){.preview-container.buttons-aside[_ngcontent-%COMP%]{padding-inline-end:1.5rem}}.preview-container.buttons-aside[_ngcontent-%COMP%]{padding-top:1rem;padding-bottom:1rem}.preview-container.buttons-aside[_ngcontent-%COMP%]   .buttons[_ngcontent-%COMP%]{margin-top:1rem}"],changeDetection:1});}return i;})();/**i18n:fad79908930cbb4c308e7550a5fe49bb3841dbb330066a6429aebaa006173605*/export{me as m};//# sourceMappingURL=chunk-D6G00JKq.js.map