import{a as O}from"./chunk-C6CC5JGF.js";import{a as I}from"./chunk-QQAZFEPL.js";import{a as y}from"./chunk-7VHQBARM.js";import{Aa as u,Da as p,Ea as f,Kb as C,Lb as w,Mf as M,Oa as h,Ob as c,Wa as a,X as v,ba as d,db as _,eb as g,fb as l,ng as E,rb as S,sb as m,uc as x,yc as P}from"./chunk-QXV2GR6R.js";import{i}from"./chunk-JJ4RDTEF.js";var T=(t,n)=>({width:t,height:n});function b(t,n){if(t&1&&l(0,"img",5),t&2){let r=m();a("ngStyle",c(2,T,r.previewWidth,r.previewHeight))("src",r.imageSrc,u);}}function z(t,n){if(t&1&&l(0,"div",6),t&2){let r=m();a("ngStyle",c(1,T,r.previewWidth,r.previewHeight));}}var j=(()=>{let n=class n{constructor(e){i(this,"serverService");i(this,"inputLabel");i(this,"inputName");i(this,"previewWidth");i(this,"previewHeight");i(this,"imageSrc");i(this,"allowedExtensionsMessage","");i(this,"maxSizeText");i(this,"serverConfig");i(this,"bytesPipe");i(this,"file");i(this,"propagateChange",e=>{});this.serverService=e,this.bytesPipe=new I(),this.maxSizeText="suli ken";}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"(nasin ken: "+this.videoImageExtensions+", "+this.maxSizeText+": "+this.maxVideoImageSizeInBytes+")";}ngOnInit(){this.serverConfig=this.serverService.getHTMLConfig(),this.allowedExtensionsMessage=this.videoImageExtensions.join(", ");}onFileChanged(e){this.file=e,this.propagateChange(this.file),this.updatePreview();}writeValue(e){this.file=e,this.updatePreview();}registerOnChange(e){this.propagateChange=e;}registerOnTouched(){}updatePreview(){this.file&&M(this.file).then(e=>this.imageSrc=e);}};i(n,"\u0275fac",function(s){return new(s||n)(f(E));}),i(n,"\u0275cmp",d({type:n,selectors:[["my-preview-upload"]],inputs:{inputLabel:"inputLabel",inputName:"inputName",previewWidth:"previewWidth",previewHeight:"previewHeight"},standalone:!0,features:[C([{provide:y,useExisting:v(()=>n),multi:!0}]),w],decls:5,vars:7,consts:()=>{let e;return e="Preview",[[1,"root"],[1,"preview-container"],["placement","right","icon","edit","theme","primary",3,"fileChanged","inputName","inputLabel","extensions","maxFileSize","buttonTooltip"],["class","preview","alt",e,3,"ngStyle","src",4,"ngIf"],["class","preview no-image",3,"ngStyle",4,"ngIf"],["alt",e,1,"preview",3,"ngStyle","src"],[1,"preview","no-image",3,"ngStyle"]];},template:function(s,o){s&1&&(_(0,"div",0)(1,"div",1)(2,"my-reactive-file",2),S("fileChanged",function(R){return o.onFileChanged(R);}),g(),h(3,b,1,5,"img",3)(4,z,1,4,"div",4),g()()),s&2&&(p(2),a("inputName",o.inputName)("inputLabel",o.inputLabel)("extensions",o.videoImageExtensions)("maxFileSize",o.maxVideoImageSize)("buttonTooltip",o.getReactiveFileButtonTooltip()),p(),a("ngIf",o.imageSrc),p(),a("ngIf",!o.imageSrc));},dependencies:[O,x,P],styles:[`.root[_ngcontent-%COMP%]{height:auto;display:flex;flex-direction:column}.root[_ngcontent-%COMP%]   .preview-container[_ngcontent-%COMP%]{position:relative}.root[_ngcontent-%COMP%]   .preview-container[_ngcontent-%COMP%]   my-reactive-file[_ngcontent-%COMP%]{position:absolute;bottom:10px;left:10px}.root[_ngcontent-%COMP%]   .preview-container[_ngcontent-%COMP%]   .preview[_ngcontent-%COMP%]{object-fit:cover;border-radius:4px;max-width:100%}.root[_ngcontent-%COMP%]   .preview-container[_ngcontent-%COMP%]   .preview.no-image[_ngcontent-%COMP%]{border:2px solid #808080;background-color:var(--bg)}
/*# sourceMappingURL=preview-upload.component-6FJI6WDK.css.map */`]}));let t=n;return t;})();export{j as a};/**i18n:224bcada6943fe8b17ea60808c2d370cec9507c3bd670ebe71692d099a3befa1*///# sourceMappingURL=chunk-LUTW4ABU.js.map