"use strict";var P=Object.create;var l=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var E=Object.getPrototypeOf;var w=Object.prototype.hasOwnProperty;var h=(s,e)=>l(s,"name",{value:e,configurable:true});var R=(s,e)=>{for(var a in e)l(s,a,{get:e[a],enumerable:true})};var x=(s,e,a,i)=>{if(e&&typeof e==="object"||typeof e==="function"){for(let r of y(e))if(!w.call(s,r)&&r!==a)l(s,r,{get:()=>e[r],enumerable:!(i=f(e,r))||i.enumerable})}return s};var c=(s,e,a)=>(a=s!=null?P(E(s)):{},x(e||!s||!s.__esModule?l(a,"default",{value:s,enumerable:true}):a,s));var A=s=>x(l({},"__esModule",{value:true}),s);var b=(s,e,a,i)=>{var r=i>1?void 0:i?f(e,a):e;for(var o=s.length-1,p;o>=0;o--)if(p=s[o])r=(i?p(e,a,r):p(r))||r;if(i&&r)l(e,a,r);return r};var k={};R(k,{default:()=>T});module.exports=A(k);var t=require("react/jsx-runtime");var d=require("@mdi/js");var S=c(require("classnames"));var v=require("mobx-react");var N=c(require("pretty-bytes"));var _=require("react");var z=c(require("react-dropzone"));var I=require("../../../environment");var u=c(require("../icon"));let n=class extends _.Component{constructor(e){super(e);this.state={path:null,errorState:false,errorMessage:{message:""}}}onDropAccepted(e){const{field:a}=this.props;this.setState({errorState:false});for(const i of e){const r=I.isWindows?i.path.replaceAll("\\","/"):i.path;this.setState({path:r});this.props.field.onDrop(i)}a.set("")}onDropRejected(e){for(const a of e){for(const i of a.errors){if(i.code==="file-too-large"){this.setState({errorState:true,errorMessage:{message:this.props.textMaxFileSizeError}})}}}}render(){const{field:e,textDelete:a,textUpload:i,textMaxFileSize:r,className:o="",multiple:p=false,maxSize:m=Number.POSITIVE_INFINITY,maxFiles:D=0}=this.props;const F=(0,S.default)({"image-upload__dropzone":true,[`${o}`]:o});const g=m===void 0||m===Number.POSITIVE_INFINITY?0:m;return(0,t.jsxs)("div",{className:"image-upload-wrapper",children:[(0,t.jsx)("label",{className:"franz-form__label",htmlFor:"iconUpload",children:e.label}),(0,t.jsx)("div",{className:"image-upload",children:e.value&&e.value!=="delete"||this.state.path?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:"image-upload__preview",style:{backgroundImage:`url("${this.state.path||e.value}")`}}),(0,t.jsxs)("div",{className:"image-upload__action",children:[(0,t.jsxs)("button",{type:"button",onClick:()=>{if(e.value){e.set("delete")}else{this.setState({path:null})}},children:[(0,t.jsx)(u.default,{icon:d.mdiDelete}),(0,t.jsx)("p",{children:a})]}),(0,t.jsx)("div",{className:"image-upload__action-background"})]})]}):(0,t.jsx)(z.default,{onDropAccepted:this.onDropAccepted.bind(this),onDropRejected:this.onDropRejected.bind(this),multiple:p,accept:{"image/jpeg":[".jpeg",".jpg"],"image/png":[".png"],"image/svg+xml":[".svg"]},minSize:0,maxSize:m,maxFiles:D,children:({getRootProps:M,getInputProps:j})=>(0,t.jsxs)("div",{...M(),className:F,children:[(0,t.jsx)(u.default,{icon:d.mdiFileImage}),(0,t.jsx)("p",{children:i}),(0,t.jsx)("input",{...j()})]})})}),g!==0&&(0,t.jsxs)("span",{className:"image-upload-wrapper__file-size",children:[r," ",(0,N.default)(g,{maximumFractionDigits:1})]}),this.state.errorState&&(0,t.jsx)("span",{className:"image-upload-wrapper__file-size-error",children:this.state.errorMessage.message})]})}};h(n,"ImageUpload");n=b([v.observer],n);var T=n;
