import{a as W}from"./chunk-NABIRIYG.js";import{a as H}from"./chunk-JIKLIHHQ.js";import{a as k}from"./chunk-K3S7L2EH.js";import{C as U,a as L,g as V,n as F}from"./chunk-2UGJU7DR.js";import{$b as A,Bb as w,Cb as _,Ea as y,Fc as z,Ha as m,Hh as B,Lc as D,Ob as x,Sa as E,Tc as I,Vb as O,Wb as R,X as M,Xb as T,Ya as v,aa as b,bc as N,eb as l,ha as p,hh as $,ia as d,jb as C,nb as g,ob as c,pb as f,sc as P,ta as a,tb as S}from"./chunk-EWB56PWF.js";import{i as u}from"./chunk-2T7OYDCL.js";var X=t=>({"buttons-aside":t});function j(t,n){if(t&1&&f(0,"img",2),t&2){let r=_();l("ngStyle",r.previewSize())("src",r.imageSrc,y);}}function q(t,n){if(t&1&&f(0,"div",3),t&2){let r=_();l("ngStyle",r.previewSize());}}function J(t,n){if(t&1){let r=S();g(0,"my-delete-button",7),w("click",function(){p(r),_();let o=x(5);return d(o.reset());}),c();}}var le=(()=>{let n=class n{serverService=b(B);inputName=a.required();inputLabel=a(void 0);displayDelete=a(!1,{transform:P});buttonsAside=a(!1,{transform:P});previewSize=a(void 0);imageSrc;allowedExtensionsMessage="";maxSizeText;file;serverConfig;bytesPipe;constructor(){this.bytesPipe=new H(),this.maxSizeText="\u043C\u0430\u043A\u0441\u0438\u043C\u0430\u043B\u044C\u043D\u044B\u0439 \u0440\u0430\u0437\u043C\u0435\u0440";}get videoImageExtensions(){return this.serverConfig.video.image.extensions;}get maxVideoImageSize(){return this.serverConfig.video.image.size.max;}get maxVideoImageSizeInBytes(){return this.bytesPipe.transform(this.maxVideoImageSize);}getReactiveFileButtonTooltip(){return"(\u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043D\u0438\u044F: "+this.videoImageExtensions+", "+this.maxSizeText+": "+this.maxVideoImageSizeInBytes+")";}ngOnInit(){this.serverConfig=this.serverService.getHTMLConfig(),this.allowedExtensionsMessage=this.videoImageExtensions.join(", ");}onFileChanged(i){this.file=i,this.propagateChange(this.file),this.updatePreview();}propagateChange=i=>{};writeValue(i){this.file=i,this.updatePreview();}registerOnChange(i){this.propagateChange=i;}registerOnTouched(){}updatePreview(){this.file?$(this.file).then(i=>this.imageSrc=i):this.imageSrc=void 0;}};u(n,"\u0275fac",function(o){return new(o||n)();}),u(n,"\u0275cmp",E({type:n,selectors:[["my-preview-upload"]],inputs:{inputName:[1,"inputName"],inputLabel:[1,"inputLabel"],displayDelete:[1,"displayDelete"],buttonsAside:[1,"buttonsAside"],previewSize:[1,"previewSize"]},features:[A([{provide:L,useExisting:M(()=>n),multi:!0}])],decls:7,vars:11,consts:()=>{let i;i="\u041F\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043B\u044C\u043D\u044B\u0439 \u043F\u0440\u043E\u0441\u043C\u043E\u0442\u0440";let o;return o="Delete the image",[["reactiveFile",""],[1,"preview-container",3,"ngClass"],["alt",i,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",o,"theme","danger"],["title",o,"theme","danger",3,"click"]];},template:function(o,e){if(o&1){let h=S();g(0,"div",1),v(1,j,1,2,"img",2)(2,q,1,1,"div",3),g(3,"div",4)(4,"my-reactive-file",5,0),T("ngModelChange",function(s){return p(h),R(e.file,s)||(e.file=s),d(s);}),w("fileChanged",function(s){return p(h),d(e.onFileChanged(s));}),c(),v(6,J,1,0,"my-delete-button",6),c()();}o&2&&(l("ngClass",N(9,X,e.buttonsAside())),m(),C(e.imageSrc?1:2),m(3),O("ngModel",e.file),l("inputName",e.inputName())("inputLabel",e.inputLabel())("extensions",e.videoImageExtensions)("maxFileSize",e.maxVideoImageSize)("buttonTooltip",e.getReactiveFileButtonTooltip()),m(2),C(e.displayDelete()&&e.file?6:-1));},dependencies:[I,z,D,U,V,F,W,k],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);padding-inline-end:calc(1.275rem + .3vw);padding-top:1rem;padding-bottom:1rem}@media (min-width: 1200px){.preview-container.buttons-aside[_ngcontent-%COMP%]{padding-inline-start:1.5rem}}@media (min-width: 1200px){.preview-container.buttons-aside[_ngcontent-%COMP%]{padding-inline-end:1.5rem}}.preview-container.buttons-aside[_ngcontent-%COMP%]   .buttons[_ngcontent-%COMP%]{margin-top:1rem}
/*# sourceMappingURL=preview-upload.component-SJOFIBAB.css.map */`]}));let t=n;return t;})();export{le as a};/**i18n:85d030b7fdd36d163c6d41dcef9178681a6baa573eb199e8b12fe27dbb057a98*///# sourceMappingURL=chunk-FJNHGQO5.js.map