8 lines
111 KiB
JavaScript
8 lines
111 KiB
JavaScript
import{b as j,A as dr}from"./Cu5ilWky.js";class ne extends Error{cause;isNetworkError;request;constructor(t,e=null){super("This looks like a network error, the endpoint might be blocked by an internet provider or a firewall."),this.cause=t,this.isNetworkError=!0,this.request=e}}class ur{#t;#e=!1;#r;#i;constructor(t,e){this.#i=t,this.#r=()=>e(t)}progress(){this.#e||this.#i>0&&(clearTimeout(this.#t),this.#t=setTimeout(this.#r,this.#i))}done(){this.#e||(clearTimeout(this.#t),this.#t=void 0,this.#e=!0)}}const vt=()=>{};function pr(r,t={}){const{body:e=null,headers:i={},method:s="GET",onBeforeRequest:a=vt,onUploadProgress:n=vt,shouldRetry:o=()=>!0,onAfterResponse:c=vt,onTimeout:l=vt,responseType:d,retries:h=3,signal:u=null,timeout:p=3e4,withCredentials:g=!1}=t,y=m=>.3*2**(m-1)*1e3,v=new ur(p,l);function b(m=0){return new Promise(async(E,R)=>{const w=new XMLHttpRequest,f=x=>{o(w)&&m<h?setTimeout(()=>{b(m+1).then(E,R)},y(m)):(v.done(),R(x))};w.open(s,r,!0),w.withCredentials=g,d&&(w.responseType=d),w.onload=async()=>{try{await c(w,m)}catch(x){x.request=w,f(x);return}w.status>=200&&w.status<300?(v.done(),E(w)):o(w)&&m<h?setTimeout(()=>{b(m+1).then(E,R)},y(m)):(v.done(),R(new ne(w.statusText,w)))},w.onerror=()=>f(new ne(w.statusText,w)),w.upload.onprogress=x=>{v.progress(),n(x)},i&&Object.keys(i).forEach(x=>{w.setRequestHeader(x,i[x])});function _(){w.abort(),R(new DOMException("Aborted","AbortError"))}if(u?.addEventListener("abort",_),u?.aborted){_();return}await a(w,m),w.send(e)})}return b()}const fr=r=>"error"in r&&!!r.error,gr=r=>r.progress.uploadComplete;function mr(r){return r.filter(t=>!fr(t)&&!gr(t))}function vr(r){return r.filter(t=>!t.progress?.uploadStarted||!t.isRestored)}function yr(r){return typeof r!="object"||r===null||!("nodeType"in r)?!1:r.nodeType===Node.ELEMENT_NODE}function br(r,t=document){return typeof r=="string"?t.querySelector(r):yr(r)?r:null}function Ti(r){const t=r.lastIndexOf(".");return t===-1||t===r.length-1?{name:r,extension:void 0}:{name:r.slice(0,t),extension:r.slice(t+1)}}const Pe={__proto__:null,md:"text/markdown",markdown:"text/markdown",mp4:"video/mp4",mp3:"audio/mp3",svg:"image/svg+xml",jpg:"image/jpeg",png:"image/png",webp:"image/webp",gif:"image/gif",heic:"image/heic",heif:"image/heif",yaml:"text/yaml",yml:"text/yaml",csv:"text/csv",tsv:"text/tab-separated-values",tab:"text/tab-separated-values",avi:"video/x-msvideo",mks:"video/x-matroska",mkv:"video/x-matroska",mov:"video/quicktime",dicom:"application/dicom",doc:"application/msword",msg:"application/vnd.ms-outlook",docm:"application/vnd.ms-word.document.macroenabled.12",docx:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",dot:"application/msword",dotm:"application/vnd.ms-word.template.macroenabled.12",dotx:"application/vnd.openxmlformats-officedocument.wordprocessingml.template",xla:"application/vnd.ms-excel",xlam:"application/vnd.ms-excel.addin.macroenabled.12",xlc:"application/vnd.ms-excel",xlf:"application/x-xliff+xml",xlm:"application/vnd.ms-excel",xls:"application/vnd.ms-excel",xlsb:"application/vnd.ms-excel.sheet.binary.macroenabled.12",xlsm:"application/vnd.ms-excel.sheet.macroenabled.12",xlsx:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",xlt:"application/vnd.ms-excel",xltm:"application/vnd.ms-excel.template.macroenabled.12",xltx:"application/vnd.openxmlformats-officedocument.spreadsheetml.template",xlw:"application/vnd.ms-excel",txt:"text/plain",text:"text/plain",conf:"text/plain",log:"text/plain",pdf:"application/pdf",zip:"application/zip","7z":"application/x-7z-compressed",rar:"application/x-rar-compressed",tar:"application/x-tar",gz:"application/gzip",dmg:"application/x-apple-diskimage"};function Mi(r){if(r.type)return r.type;const t=r.name?Ti(r.name).extension?.toLowerCase():null;return t&&t in Pe?Pe[t]:"application/octet-stream"}function wr(r){return r.charCodeAt(0).toString(32)}function Ue(r){let t="";return r.replace(/[^A-Z0-9]/gi,e=>(t+=`-${wr(e)}`,"/"))+t}function _r(r,t){let e=t||"uppy";return typeof r.name=="string"&&(e+=`-${Ue(r.name.toLowerCase())}`),r.type!==void 0&&(e+=`-${r.type}`),r.meta&&typeof r.meta.relativePath=="string"&&(e+=`-${Ue(r.meta.relativePath.toLowerCase())}`),r.data?.size!==void 0&&(e+=`-${r.data.size}`),r.data.lastModified!==void 0&&(e+=`-${r.data.lastModified}`),e}function Sr(r){return!r.isRemote||!r.remote?!1:new Set(["box","dropbox","drive","facebook","unsplash"]).has(r.remote.provider)}function xr(r,t){if(Sr(r))return r.id;const e=Mi(r);return _r({...r,type:e},t)}function ke(r,t){return r===!0?Object.keys(t):Array.isArray(r)?r:[]}function Er(r){for(;r&&!r.dir;)r=r.parentNode;return r?.dir}function zt(r){return r<10?`0${r}`:r.toString()}function Et(){const r=new Date,t=zt(r.getHours()),e=zt(r.getMinutes()),i=zt(r.getSeconds());return`${t}:${e}:${i}`}function Tr(r){return r?r.readyState===4&&r.status===0:!1}class Mr{#t=[];#e=0;#r;#i=!1;constructor(t){const e=t?.concurrency;this.#r=typeof e!="number"||e===0?1/0:e}add(t){const e=new AbortController;let i,s;const a=new Promise((o,c)=>{i=o,s=c}),n={run:()=>t(e.signal),resolve:i,reject:s,controller:e};return e.signal.addEventListener("abort",()=>{const o=this.#t.indexOf(n);o!==-1&&(this.#t.splice(o,1),s(e.signal.reason??new DOMException("Aborted","AbortError")))},{once:!0}),a.abort=o=>{e.abort(o??new DOMException("Aborted","AbortError"))},a.abortOn=o=>{if(o){const c=()=>a.abort(o.reason);o.addEventListener("abort",c,{once:!0}),a.then(()=>o.removeEventListener("abort",c),()=>o.removeEventListener("abort",c))}return a},!this.#i&&this.#e<this.#r?this.#a(n):this.#t.push(n),a}#a(t){if(this.#e++,t.controller.signal.aborted){this.#e--,t.reject(t.controller.signal.reason??new DOMException("Aborted","AbortError")),this.#s();return}let e;try{e=t.run()}catch(i){e=Promise.reject(i)}e.then(i=>{t.controller.signal.aborted?t.reject(t.controller.signal.reason??new DOMException("Aborted","AbortError")):t.resolve(i)},i=>{t.reject(i)}).finally(()=>{this.#e--,this.#s()})}#s(){queueMicrotask(()=>{if(!(this.#i||this.#e>=this.#r))for(;this.#t.length>0;){const t=this.#t.shift();if(!t.controller.signal.aborted){this.#a(t);return}}})}pause(){this.#i=!0}resume(){this.#i=!1;const t=this.#r-this.#e;for(let e=0;e<t;e++)this.#s()}clear(t){const e=this.#t.splice(0),i=t??new DOMException("Cleared","AbortError");for(const s of e)s.controller.abort(i),s.reject(i)}get concurrency(){return this.#r}set concurrency(t){if(this.#r=typeof t!="number"||t===0?1/0:t,!this.#i){const e=this.#r-this.#e;for(let i=0;i<e;i++)this.#s()}}get pending(){return this.#t.length}get running(){return this.#e}get isPaused(){return this.#i}wrapPromiseFunction(t){return(...e)=>this.add(i=>t(...e))}}function Rr(r,t,e){const i=[];return r.forEach(s=>typeof s!="string"?i.push(s):t[Symbol.split](s).forEach((a,n,o)=>{a!==""&&i.push(a),n<o.length-1&&i.push(e)})),i}function Ie(r,t){const e=/\$/g,i="$$$$";let s=[r];if(t==null)return s;for(const a of Object.keys(t))if(a!=="_"){let n=t[a];typeof n=="string"&&(n=e[Symbol.replace](n,i)),s=Rr(s,new RegExp(`%\\{${a}\\}`,"g"),n)}return s}const Or=r=>{throw new Error(`missing string: ${r}`)};class Ri{locale;constructor(t,{onMissingKey:e=Or}={}){this.locale={strings:{},pluralize(i){return i===1?0:1}},Array.isArray(t)?t.forEach(this.#e,this):this.#e(t),this.#t=e}#t;#e(t){if(!t?.strings)return;const e=this.locale;Object.assign(this.locale,{strings:{...e.strings,...t.strings},pluralize:t.pluralize||e.pluralize})}translate(t,e){return this.translateArray(t,e).join("")}translateArray(t,e){let i=this.locale.strings[t];if(i==null&&(this.#t(t),i=t),typeof i=="object"){if(e&&typeof e.smart_count<"u"){const a=this.locale.pluralize(e.smart_count);return Ie(i[a],e)}throw new Error("Attempted to use a string with plural forms, but no value was given for %{smart_count}")}if(typeof i!="string")throw new Error("string was not a string");return Ie(i,e)}}var At,F,Oi,Z,ze,Fi,Ci,Ai,we,oe,le,Mt={},Rt=[],Fr=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,Nt=Array.isArray;function V(r,t){for(var e in t)r[e]=t[e];return r}function _e(r){r&&r.parentNode&&r.parentNode.removeChild(r)}function Cr(r,t,e){var i,s,a,n={};for(a in t)a=="key"?i=t[a]:a=="ref"?s=t[a]:n[a]=t[a];if(arguments.length>2&&(n.children=arguments.length>3?At.call(arguments,2):e),typeof r=="function"&&r.defaultProps!=null)for(a in r.defaultProps)n[a]===void 0&&(n[a]=r.defaultProps[a]);return Tt(r,n,i,s,null)}function Tt(r,t,e,i,s){var a={type:r,props:t,key:e,ref:i,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:s??++Oi,__i:-1,__u:0};return s==null&&F.vnode!=null&&F.vnode(a),a}function Dt(r){return r.children}function ut(r,t){this.props=r,this.context=t}function ot(r,t){if(t==null)return r.__?ot(r.__,r.__i+1):null;for(var e;t<r.__k.length;t++)if((e=r.__k[t])!=null&&e.__e!=null)return e.__e;return typeof r.type=="function"?ot(r):null}function Ar(r){if(r.__P&&r.__d){var t=r.__v,e=t.__e,i=[],s=[],a=V({},t);a.__v=t.__v+1,F.vnode&&F.vnode(a),Se(r.__P,a,t,r.__n,r.__P.namespaceURI,32&t.__u?[e]:null,i,e??ot(t),!!(32&t.__u),s),a.__v=t.__v,a.__.__k[a.__i]=a,Ui(i,a,s),t.__e=t.__=null,a.__e!=e&&Ni(a)}}function Ni(r){if((r=r.__)!=null&&r.__c!=null)return r.__e=r.__c.base=null,r.__k.some(function(t){if(t!=null&&t.__e!=null)return r.__e=r.__c.base=t.__e}),Ni(r)}function Le(r){(!r.__d&&(r.__d=!0)&&Z.push(r)&&!Ot.__r++||ze!=F.debounceRendering)&&((ze=F.debounceRendering)||Fi)(Ot)}function Ot(){try{for(var r,t=1;Z.length;)Z.length>t&&Z.sort(Ci),r=Z.shift(),t=Z.length,Ar(r)}finally{Z.length=Ot.__r=0}}function Di(r,t,e,i,s,a,n,o,c,l,d){var h,u,p,g,y,v,b,m=i&&i.__k||Rt,E=t.length;for(c=Nr(e,t,m,c,E),h=0;h<E;h++)(p=e.__k[h])!=null&&(u=p.__i!=-1&&m[p.__i]||Mt,p.__i=h,v=Se(r,p,u,s,a,n,o,c,l,d),g=p.__e,p.ref&&u.ref!=p.ref&&(u.ref&&xe(u.ref,null,p),d.push(p.ref,p.__c||g,p)),y==null&&g!=null&&(y=g),(b=!!(4&p.__u))||u.__k===p.__k?c=Pi(p,c,r,b):typeof p.type=="function"&&v!==void 0?c=v:g&&(c=g.nextSibling),p.__u&=-7);return e.__e=y,c}function Nr(r,t,e,i,s){var a,n,o,c,l,d=e.length,h=d,u=0;for(r.__k=new Array(s),a=0;a<s;a++)(n=t[a])!=null&&typeof n!="boolean"&&typeof n!="function"?(typeof n=="string"||typeof n=="number"||typeof n=="bigint"||n.constructor==String?n=r.__k[a]=Tt(null,n,null,null,null):Nt(n)?n=r.__k[a]=Tt(Dt,{children:n},null,null,null):n.constructor===void 0&&n.__b>0?n=r.__k[a]=Tt(n.type,n.props,n.key,n.ref?n.ref:null,n.__v):r.__k[a]=n,c=a+u,n.__=r,n.__b=r.__b+1,o=null,(l=n.__i=Dr(n,e,c,h))!=-1&&(h--,(o=e[l])&&(o.__u|=2)),o==null||o.__v==null?(l==-1&&(s>d?u--:s<d&&u++),typeof n.type!="function"&&(n.__u|=4)):l!=c&&(l==c-1?u--:l==c+1?u++:(l>c?u--:u++,n.__u|=4))):r.__k[a]=null;if(h)for(a=0;a<d;a++)(o=e[a])!=null&&(2&o.__u)==0&&(o.__e==i&&(i=ot(o)),Ii(o,o));return i}function Pi(r,t,e,i){var s,a;if(typeof r.type=="function"){for(s=r.__k,a=0;s&&a<s.length;a++)s[a]&&(s[a].__=r,t=Pi(s[a],t,e,i));return t}r.__e!=t&&(i&&(t&&r.type&&!t.parentNode&&(t=ot(r)),e.insertBefore(r.__e,t||null)),t=r.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function Dr(r,t,e,i){var s,a,n,o=r.key,c=r.type,l=t[e],d=l!=null&&(2&l.__u)==0;if(l===null&&o==null||d&&o==l.key&&c==l.type)return e;if(i>(d?1:0)){for(s=e-1,a=e+1;s>=0||a<t.length;)if((l=t[n=s>=0?s--:a++])!=null&&(2&l.__u)==0&&o==l.key&&c==l.type)return n}return-1}function je(r,t,e){t[0]=="-"?r.setProperty(t,e??""):r[t]=e==null?"":typeof e!="number"||Fr.test(t)?e:e+"px"}function yt(r,t,e,i,s){var a,n;t:if(t=="style")if(typeof e=="string")r.style.cssText=e;else{if(typeof i=="string"&&(r.style.cssText=i=""),i)for(t in i)e&&t in e||je(r.style,t,"");if(e)for(t in e)i&&e[t]==i[t]||je(r.style,t,e[t])}else if(t[0]=="o"&&t[1]=="n")a=t!=(t=t.replace(Ai,"$1")),n=t.toLowerCase(),t=n in r||t=="onFocusOut"||t=="onFocusIn"?n.slice(2):t.slice(2),r.l||(r.l={}),r.l[t+a]=e,e?i?e.u=i.u:(e.u=we,r.addEventListener(t,a?le:oe,a)):r.removeEventListener(t,a?le:oe,a);else{if(s=="http://www.w3.org/2000/svg")t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(t!="width"&&t!="height"&&t!="href"&&t!="list"&&t!="form"&&t!="tabIndex"&&t!="download"&&t!="rowSpan"&&t!="colSpan"&&t!="role"&&t!="popover"&&t in r)try{r[t]=e??"";break t}catch{}typeof e=="function"||(e==null||e===!1&&t[4]!="-"?r.removeAttribute(t):r.setAttribute(t,t=="popover"&&e==1?"":e))}}function Be(r){return function(t){if(this.l){var e=this.l[t.type+r];if(t.t==null)t.t=we++;else if(t.t<e.u)return;return e(F.event?F.event(t):t)}}}function Se(r,t,e,i,s,a,n,o,c,l){var d,h,u,p,g,y,v,b,m,E,R,w,f,_,x,O=t.type;if(t.constructor!==void 0)return null;128&e.__u&&(c=!!(32&e.__u),a=[o=t.__e=e.__e]),(d=F.__b)&&d(t);t:if(typeof O=="function")try{if(b=t.props,m=O.prototype&&O.prototype.render,E=(d=O.contextType)&&i[d.__c],R=d?E?E.props.value:d.__:i,e.__c?v=(h=t.__c=e.__c).__=h.__E:(m?t.__c=h=new O(b,R):(t.__c=h=new ut(b,R),h.constructor=O,h.render=Ur),E&&E.sub(h),h.state||(h.state={}),h.__n=i,u=h.__d=!0,h.__h=[],h._sb=[]),m&&h.__s==null&&(h.__s=h.state),m&&O.getDerivedStateFromProps!=null&&(h.__s==h.state&&(h.__s=V({},h.__s)),V(h.__s,O.getDerivedStateFromProps(b,h.__s))),p=h.props,g=h.state,h.__v=t,u)m&&O.getDerivedStateFromProps==null&&h.componentWillMount!=null&&h.componentWillMount(),m&&h.componentDidMount!=null&&h.__h.push(h.componentDidMount);else{if(m&&O.getDerivedStateFromProps==null&&b!==p&&h.componentWillReceiveProps!=null&&h.componentWillReceiveProps(b,R),t.__v==e.__v||!h.__e&&h.shouldComponentUpdate!=null&&h.shouldComponentUpdate(b,h.__s,R)===!1){t.__v!=e.__v&&(h.props=b,h.state=h.__s,h.__d=!1),t.__e=e.__e,t.__k=e.__k,t.__k.some(function(U){U&&(U.__=t)}),Rt.push.apply(h.__h,h._sb),h._sb=[],h.__h.length&&n.push(h);break t}h.componentWillUpdate!=null&&h.componentWillUpdate(b,h.__s,R),m&&h.componentDidUpdate!=null&&h.__h.push(function(){h.componentDidUpdate(p,g,y)})}if(h.context=R,h.props=b,h.__P=r,h.__e=!1,w=F.__r,f=0,m)h.state=h.__s,h.__d=!1,w&&w(t),d=h.render(h.props,h.state,h.context),Rt.push.apply(h.__h,h._sb),h._sb=[];else do h.__d=!1,w&&w(t),d=h.render(h.props,h.state,h.context),h.state=h.__s;while(h.__d&&++f<25);h.state=h.__s,h.getChildContext!=null&&(i=V(V({},i),h.getChildContext())),m&&!u&&h.getSnapshotBeforeUpdate!=null&&(y=h.getSnapshotBeforeUpdate(p,g)),_=d!=null&&d.type===Dt&&d.key==null?ki(d.props.children):d,o=Di(r,Nt(_)?_:[_],t,e,i,s,a,n,o,c,l),h.base=t.__e,t.__u&=-161,h.__h.length&&n.push(h),v&&(h.__E=h.__=null)}catch(U){if(t.__v=null,c||a!=null)if(U.then){for(t.__u|=c?160:128;o&&o.nodeType==8&&o.nextSibling;)o=o.nextSibling;a[a.indexOf(o)]=null,t.__e=o}else{for(x=a.length;x--;)_e(a[x]);he(t)}else t.__e=e.__e,t.__k=e.__k,U.then||he(t);F.__e(U,t,e)}else a==null&&t.__v==e.__v?(t.__k=e.__k,t.__e=e.__e):o=t.__e=Pr(e.__e,t,e,i,s,a,n,c,l);return(d=F.diffed)&&d(t),128&t.__u?void 0:o}function he(r){r&&(r.__c&&(r.__c.__e=!0),r.__k&&r.__k.some(he))}function Ui(r,t,e){for(var i=0;i<e.length;i++)xe(e[i],e[++i],e[++i]);F.__c&&F.__c(t,r),r.some(function(s){try{r=s.__h,s.__h=[],r.some(function(a){a.call(s)})}catch(a){F.__e(a,s.__v)}})}function ki(r){return typeof r!="object"||r==null||r.__b>0?r:Nt(r)?r.map(ki):V({},r)}function Pr(r,t,e,i,s,a,n,o,c){var l,d,h,u,p,g,y,v=e.props||Mt,b=t.props,m=t.type;if(m=="svg"?s="http://www.w3.org/2000/svg":m=="math"?s="http://www.w3.org/1998/Math/MathML":s||(s="http://www.w3.org/1999/xhtml"),a!=null){for(l=0;l<a.length;l++)if((p=a[l])&&"setAttribute"in p==!!m&&(m?p.localName==m:p.nodeType==3)){r=p,a[l]=null;break}}if(r==null){if(m==null)return document.createTextNode(b);r=document.createElementNS(s,m,b.is&&b),o&&(F.__m&&F.__m(t,a),o=!1),a=null}if(m==null)v===b||o&&r.data==b||(r.data=b);else{if(a=a&&At.call(r.childNodes),!o&&a!=null)for(v={},l=0;l<r.attributes.length;l++)v[(p=r.attributes[l]).name]=p.value;for(l in v)p=v[l],l=="dangerouslySetInnerHTML"?h=p:l=="children"||l in b||l=="value"&&"defaultValue"in b||l=="checked"&&"defaultChecked"in b||yt(r,l,null,p,s);for(l in b)p=b[l],l=="children"?u=p:l=="dangerouslySetInnerHTML"?d=p:l=="value"?g=p:l=="checked"?y=p:o&&typeof p!="function"||v[l]===p||yt(r,l,p,v[l],s);if(d)o||h&&(d.__html==h.__html||d.__html==r.innerHTML)||(r.innerHTML=d.__html),t.__k=[];else if(h&&(r.innerHTML=""),Di(t.type=="template"?r.content:r,Nt(u)?u:[u],t,e,i,m=="foreignObject"?"http://www.w3.org/1999/xhtml":s,a,n,a?a[0]:e.__k&&ot(e,0),o,c),a!=null)for(l=a.length;l--;)_e(a[l]);o||(l="value",m=="progress"&&g==null?r.removeAttribute("value"):g!=null&&(g!==r[l]||m=="progress"&&!g||m=="option"&&g!=v[l])&&yt(r,l,g,v[l],s),l="checked",y!=null&&y!=r[l]&&yt(r,l,y,v[l],s))}return r}function xe(r,t,e){try{if(typeof r=="function"){var i=typeof r.__u=="function";i&&r.__u(),i&&t==null||(r.__u=r(t))}else r.current=t}catch(s){F.__e(s,e)}}function Ii(r,t,e){var i,s;if(F.unmount&&F.unmount(r),(i=r.ref)&&(i.current&&i.current!=r.__e||xe(i,null,t)),(i=r.__c)!=null){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(a){F.__e(a,t)}i.base=i.__P=null}if(i=r.__k)for(s=0;s<i.length;s++)i[s]&&Ii(i[s],t,e||typeof r.type!="function");e||_e(r.__e),r.__c=r.__=r.__e=void 0}function Ur(r,t,e){return this.constructor(r,e)}function He(r,t,e){var i,s,a,n;t==document&&(t=document.documentElement),F.__&&F.__(r,t),s=(i=!1)?null:t.__k,a=[],n=[],Se(t,r=t.__k=Cr(Dt,null,[r]),s||Mt,Mt,t.namespaceURI,s?null:t.firstChild?At.call(t.childNodes):null,a,s?s.__e:t.firstChild,i,n),Ui(a,r,n)}At=Rt.slice,F={__e:function(r,t,e,i){for(var s,a,n;t=t.__;)if((s=t.__c)&&!s.__)try{if((a=s.constructor)&&a.getDerivedStateFromError!=null&&(s.setState(a.getDerivedStateFromError(r)),n=s.__d),s.componentDidCatch!=null&&(s.componentDidCatch(r,i||{}),n=s.__d),n)return s.__E=s}catch(o){r=o}throw r}},Oi=0,ut.prototype.setState=function(r,t){var e;e=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=V({},this.state),typeof r=="function"&&(r=r(V({},e),this.props)),r&&V(e,r),r!=null&&this.__v&&(t&&this._sb.push(t),Le(this))},ut.prototype.forceUpdate=function(r){this.__v&&(this.__e=!0,r&&this.__h.push(r),Le(this))},ut.prototype.render=Dt,Z=[],Fi=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Ci=function(r,t){return r.__v.__b-t.__v.__b},Ot.__r=0,Ai=/(PointerCapture)$|Capture$/i,we=0,oe=Be(!1),le=Be(!0);var kr=0;function S(r,t,e,i,s,a){t||(t={});var n,o,c=t;if("ref"in c)for(o in c={},t)o=="ref"?n=t[o]:c[o]=t[o];var l={type:r,props:c,key:e,ref:n,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--kr,__i:-1,__u:0,__source:s,__self:a};if(typeof r=="function"&&(n=r.defaultProps))for(o in n)c[o]===void 0&&(c[o]=n[o]);return F.vnode&&F.vnode(l),l}class zi{uppy;opts;id;defaultLocale;i18n;i18nArray;type;VERSION;constructor(t,e){this.uppy=t,this.opts=e??{}}getPluginState(){const{plugins:t}=this.uppy.getState();return t?.[this.id]||{}}setPluginState(t){const{plugins:e}=this.uppy.getState();this.uppy.setState({plugins:{...e,[this.id]:{...e[this.id],...t}}})}setOptions(t){this.opts={...this.opts,...t},this.setPluginState(void 0),this.i18nInit()}i18nInit(){const t=new Ri([this.defaultLocale,this.uppy.locale,this.opts.locale]);this.i18n=t.translate.bind(t),this.i18nArray=t.translateArray.bind(t),this.setPluginState(void 0)}addTarget(t){throw new Error("Extend the addTarget method to add your plugin to another plugin's target")}install(){}uninstall(){}update(t){}afterUpdate(){}}class Ir{#t;#e=[];constructor(t){this.#t=t}on(t,e){return this.#e.push([t,e]),this.#t.on(t,e)}remove(){for(const[t,e]of this.#e.splice(0))this.#t.off(t,e)}onFilePause(t,e){this.on("upload-pause",(i,s)=>{t===i?.id&&e(s)})}onFileRemove(t,e){this.on("file-removed",i=>{t===i.id&&e(i.id)})}onPause(t,e){this.on("upload-pause",(i,s)=>{t===i?.id&&e(s)})}onRetry(t,e){this.on("upload-retry",i=>{t===i?.id&&e()})}onRetryAll(t,e){this.on("retry-all",()=>{this.#t.getFile(t)&&e()})}onPauseAll(t,e){this.on("pause-all",()=>{this.#t.getFile(t)&&e()})}onCancelAll(t,e){this.on("cancel-all",(...i)=>{this.#t.getFile(t)&&e(...i)})}onResumeAll(t,e){this.on("resume-all",()=>{this.#t.getFile(t)&&e()})}}const zr={debug:()=>{},warn:()=>{},error:(...r)=>console.error(`[Uppy] [${Et()}]`,...r)},Lr={debug:(...r)=>console.debug(`[Uppy] [${Et()}]`,...r),warn:(...r)=>console.warn(`[Uppy] [${Et()}]`,...r),error:(...r)=>console.error(`[Uppy] [${Et()}]`,...r)};var bt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Pt(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Lt,$e;function jr(){return $e||($e=1,Lt=function(t){if(typeof t!="number"||Number.isNaN(t))throw new TypeError(`Expected a number, got ${typeof t}`);const e=t<0;let i=Math.abs(t);if(e&&(i=-i),i===0)return"0 B";const s=["B","KB","MB","GB","TB","PB","EB","ZB","YB"],a=Math.min(Math.floor(Math.log(i)/Math.log(1024)),s.length-1),n=Number(i/1024**a),o=s[a];return`${n>=10||n%1===0?Math.round(n):n.toFixed(1)} ${o}`}),Lt}var Br=jr();const wt=Pt(Br);var jt,qe;function Hr(){if(qe)return jt;qe=1;function r(t,e){this.text=t=t||"",this.hasWild=~t.indexOf("*"),this.separator=e,this.parts=t.split(e)}return r.prototype.match=function(t){var e=!0,i=this.parts,s,a=i.length,n;if(typeof t=="string"||t instanceof String)if(!this.hasWild&&this.text!=t)e=!1;else{for(n=(t||"").split(this.separator),s=0;e&&s<a;s++)i[s]!=="*"&&(s<n.length?e=i[s]===n[s]:e=!1);e=e&&n}else if(typeof t.splice=="function")for(e=[],s=t.length;s--;)this.match(t[s])&&(e[e.length]=t[s]);else if(typeof t=="object"){e={};for(var o in t)this.match(o)&&(e[o]=t[o])}return e},jt=function(t,e,i){var s=new r(t,i||/[\/\.]/);return typeof e<"u"?s.match(e):s},jt}var Bt,We;function $r(){if(We)return Bt;We=1;var r=Hr(),t=/[\/\+\.]/;return Bt=function(e,i){function s(a){var n=r(a,e,t);return n&&n.length>=2}return i?s(i.split(";")[0]):s},Bt}var qr=$r();const Wr=Pt(qr),Xr={maxFileSize:null,minFileSize:null,maxTotalFileSize:null,maxNumberOfFiles:null,minNumberOfFiles:null,allowedFileTypes:null,requiredMetaFields:[]};class $ extends Error{isUserFacing;file;constructor(t,e){super(t),this.isUserFacing=e?.isUserFacing??!0,e?.file&&(this.file=e.file)}isRestriction=!0}class Yr{getI18n;getOpts;constructor(t,e){this.getI18n=e,this.getOpts=()=>{const i=t();if(i.restrictions?.allowedFileTypes!=null&&!Array.isArray(i.restrictions.allowedFileTypes))throw new TypeError("`restrictions.allowedFileTypes` must be an array");return i}}validateAggregateRestrictions(t,e){const{maxTotalFileSize:i,maxNumberOfFiles:s}=this.getOpts().restrictions;if(s&&t.filter(n=>!n.isGhost).length+e.length>s)throw new $(`${this.getI18n()("youCanOnlyUploadX",{smart_count:s})}`);if(i){const a=[...t,...e].reduce((n,o)=>n+(o.size??0),0);if(a>i)throw new $(this.getI18n()("aggregateExceedsSize",{sizeAllowed:wt(i),size:wt(a)}))}}validateSingleFile(t){const{maxFileSize:e,minFileSize:i,allowedFileTypes:s}=this.getOpts().restrictions;if(s&&!s.some(n=>n.includes("/")?t.type?Wr(t.type.replace(/;.*?$/,""),n):!1:n[0]==="."&&t.extension?t.extension.toLowerCase()===n.slice(1).toLowerCase():!1)){const n=s.join(", ");throw new $(this.getI18n()("youCanOnlyUploadFileTypes",{types:n}),{file:t})}if(e&&t.size!=null&&t.size>e)throw new $(this.getI18n()("exceedsSize",{size:wt(e),file:t.name??this.getI18n()("unnamed")}),{file:t});if(i&&t.size!=null&&t.size<i)throw new $(this.getI18n()("inferiorSize",{size:wt(i)}),{file:t})}validate(t,e){e.forEach(i=>{this.validateSingleFile(i)}),this.validateAggregateRestrictions(t,e)}validateMinNumberOfFiles(t){const{minNumberOfFiles:e}=this.getOpts().restrictions;if(e&&Object.keys(t).length<e)throw new $(this.getI18n()("youHaveToAtLeastSelectX",{smart_count:e}))}getMissingRequiredMetaFields(t){const e=new $(this.getI18n()("missingRequiredMetaFieldOnFile",{fileName:t.name??this.getI18n()("unnamed")})),{requiredMetaFields:i}=this.getOpts().restrictions,s=[];for(const a of i)(!Object.hasOwn(t.meta,a)||t.meta[a]==="")&&s.push(a);return{missingFields:s,error:e}}}function Vr(r){let t=null,e;return(...i)=>(e=i,t||(t=Promise.resolve().then(()=>(t=null,r(...e)))),t)}class Ft extends zi{#t;isTargetDOMEl;el;parent;title;getTargetPlugin(t){let e;if(typeof t?.addTarget=="function")e=t,e instanceof Ft||console.warn(new Error("The provided plugin is not an instance of UIPlugin. This is an indication of a bug with the way Uppy is bundled.",{cause:{targetPlugin:e,UIPlugin:Ft}}));else if(typeof t=="function"){const i=t;this.uppy.iteratePlugins(s=>{s instanceof i&&(e=s)})}return e}mount(t,e){const i=e.id,s=br(t);if(s){this.isTargetDOMEl=!0;const o=document.createElement("div");return o.classList.add("uppy-Root"),this.#t=Vr(c=>{this.uppy.getPlugin(this.id)&&(He(this.render(c,o),o),this.afterUpdate())}),this.uppy.log(`Installing ${i} to a DOM element '${t}'`),this.opts.replaceTargetContent&&(s.innerHTML=""),He(this.render(this.uppy.getState(),o),o),this.el=o,s.appendChild(o),o.dir=this.opts.direction||Er(o)||"ltr",this.onMount(),this.el}const a=this.getTargetPlugin(t);if(a)return this.uppy.log(`Installing ${i} to ${a.id}`),this.parent=a,this.el=a.addTarget(e),this.onMount(),this.el;this.uppy.log(`Not installing ${i}`);let n=`Invalid target option given to ${i}.`;throw typeof t=="function"?n+=" The given target is not a Plugin class. Please check that you're not specifying a React Component instead of a plugin. If you are using @uppy/* packages directly, make sure you have only 1 version of @uppy/core installed: run `npm ls @uppy/core` on the command line and verify that all the versions match and are deduped correctly.":n+="If you meant to target an HTML element, please make sure that the element exists. Check that the <script> tag initializing Uppy is right before the closing </body> tag at the end of the page. (see https://github.com/transloadit/uppy/issues/1042)\n\nIf you meant to target a plugin, please confirm that your `import` statements or `require` calls are correct.",new Error(n)}render(t,e){throw new Error("Extend the render method to add your plugin to a DOM element")}update(t){this.el!=null&&this.#t?.(t)}unmount(){this.isTargetDOMEl&&this.el?.remove(),this.onUnmount()}onMount(){}onUnmount(){}}const Gr="5.0.0",Zr={version:Gr};class Jr{static VERSION=Zr.version;state={};#t=new Set;getState(){return this.state}setState(t){const e={...this.state},i={...this.state,...t};this.state=i,this.#e(e,i,t)}subscribe(t){return this.#t.add(t),()=>{this.#t.delete(t)}}#e(...t){this.#t.forEach(e=>{e(...t)})}}var Ht,Xe;function Ee(){if(Xe)return Ht;Xe=1;function r(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}return Ht=r,Ht}var $t,Ye;function Kr(){if(Ye)return $t;Ye=1;var r=typeof bt=="object"&&bt&&bt.Object===Object&&bt;return $t=r,$t}var qt,Ve;function Li(){if(Ve)return qt;Ve=1;var r=Kr(),t=typeof self=="object"&&self&&self.Object===Object&&self,e=r||t||Function("return this")();return qt=e,qt}var Wt,Ge;function Qr(){if(Ge)return Wt;Ge=1;var r=Li(),t=function(){return r.Date.now()};return Wt=t,Wt}var Xt,Ze;function ts(){if(Ze)return Xt;Ze=1;var r=/\s/;function t(e){for(var i=e.length;i--&&r.test(e.charAt(i)););return i}return Xt=t,Xt}var Yt,Je;function es(){if(Je)return Yt;Je=1;var r=ts(),t=/^\s+/;function e(i){return i&&i.slice(0,r(i)+1).replace(t,"")}return Yt=e,Yt}var Vt,Ke;function ji(){if(Ke)return Vt;Ke=1;var r=Li(),t=r.Symbol;return Vt=t,Vt}var Gt,Qe;function is(){if(Qe)return Gt;Qe=1;var r=ji(),t=Object.prototype,e=t.hasOwnProperty,i=t.toString,s=r?r.toStringTag:void 0;function a(n){var o=e.call(n,s),c=n[s];try{n[s]=void 0;var l=!0}catch{}var d=i.call(n);return l&&(o?n[s]=c:delete n[s]),d}return Gt=a,Gt}var Zt,ti;function rs(){if(ti)return Zt;ti=1;var r=Object.prototype,t=r.toString;function e(i){return t.call(i)}return Zt=e,Zt}var Jt,ei;function ss(){if(ei)return Jt;ei=1;var r=ji(),t=is(),e=rs(),i="[object Null]",s="[object Undefined]",a=r?r.toStringTag:void 0;function n(o){return o==null?o===void 0?s:i:a&&a in Object(o)?t(o):e(o)}return Jt=n,Jt}var Kt,ii;function as(){if(ii)return Kt;ii=1;function r(t){return t!=null&&typeof t=="object"}return Kt=r,Kt}var Qt,ri;function ns(){if(ri)return Qt;ri=1;var r=ss(),t=as(),e="[object Symbol]";function i(s){return typeof s=="symbol"||t(s)&&r(s)==e}return Qt=i,Qt}var te,si;function os(){if(si)return te;si=1;var r=es(),t=Ee(),e=ns(),i=NaN,s=/^[-+]0x[0-9a-f]+$/i,a=/^0b[01]+$/i,n=/^0o[0-7]+$/i,o=parseInt;function c(l){if(typeof l=="number")return l;if(e(l))return i;if(t(l)){var d=typeof l.valueOf=="function"?l.valueOf():l;l=t(d)?d+"":d}if(typeof l!="string")return l===0?l:+l;l=r(l);var h=a.test(l);return h||n.test(l)?o(l.slice(2),h?2:8):s.test(l)?i:+l}return te=c,te}var ee,ai;function ls(){if(ai)return ee;ai=1;var r=Ee(),t=Qr(),e=os(),i="Expected a function",s=Math.max,a=Math.min;function n(o,c,l){var d,h,u,p,g,y,v=0,b=!1,m=!1,E=!0;if(typeof o!="function")throw new TypeError(i);c=e(c)||0,r(l)&&(b=!!l.leading,m="maxWait"in l,u=m?s(e(l.maxWait)||0,c):u,E="trailing"in l?!!l.trailing:E);function R(M){var P=d,N=h;return d=h=void 0,v=M,p=o.apply(N,P),p}function w(M){return v=M,g=setTimeout(x,c),b?R(M):p}function f(M){var P=M-y,N=M-v,q=c-P;return m?a(q,u-N):q}function _(M){var P=M-y,N=M-v;return y===void 0||P>=c||P<0||m&&N>=u}function x(){var M=t();if(_(M))return O(M);g=setTimeout(x,f(M))}function O(M){return g=void 0,E&&d?R(M):(d=h=void 0,p)}function U(){g!==void 0&&clearTimeout(g),v=0,d=y=h=g=void 0}function Y(){return g===void 0?p:O(t())}function B(){var M=t(),P=_(M);if(d=arguments,h=this,y=M,P){if(g===void 0)return w(y);if(m)return clearTimeout(g),g=setTimeout(x,c),R(y)}return g===void 0&&(g=setTimeout(x,c)),p}return B.cancel=U,B.flush=Y,B}return ee=n,ee}var ie,ni;function hs(){if(ni)return ie;ni=1;var r=ls(),t=Ee(),e="Expected a function";function i(s,a,n){var o=!0,c=!0;if(typeof s!="function")throw new TypeError(e);return t(n)&&(o="leading"in n?!!n.leading:o,c="trailing"in n?!!n.trailing:c),r(s,a,{leading:o,maxWait:a,trailing:c})}return ie=i,ie}var cs=hs();const ds=Pt(cs);var re,oi;function us(){return oi||(oi=1,re=function(){var t={},e=t._fns={};t.emit=function(n,o,c,l,d,h,u){var p=i(n);p.length&&s(n,p,[o,c,l,d,h,u])},t.on=function(n,o){e[n]||(e[n]=[]),e[n].push(o)},t.once=function(n,o){function c(){o.apply(this,arguments),t.off(n,c)}this.on(n,c)},t.off=function(n,o){var c=[];if(n&&o){var l=this._fns[n],d=0,h=l?l.length:0;for(d;d<h;d++)l[d]!==o&&c.push(l[d])}c.length?this._fns[n]=c:delete this._fns[n]};function i(a){var n=e[a]?e[a]:[],o=a.indexOf(":"),c=o===-1?[a]:[a.substring(0,o),a.substring(o+1)],l=Object.keys(e),d=0,h=l.length;for(d;d<h;d++){var u=l[d];if(u==="*"&&(n=n.concat(e[u])),c.length===2&&c[0]===u){n=n.concat(e[u]);break}}return n}function s(a,n,o){var c=0,l=n.length;for(c;c<l&&n[c];c++)n[c].event=a,n[c].apply(n[c],o)}return t}),re}var ps=us();const fs=Pt(ps);let gs="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict",ms=(r=21)=>{let t="",e=r|0;for(;e--;)t+=gs[Math.random()*64|0];return t};const vs="5.2.0",ys={version:vs};function bs(r,t){return t.name?t.name:r.split("/")[0]==="image"?`${r.split("/")[0]}.${r.split("/")[1]}`:"noname"}const ws={strings:{addBulkFilesFailed:{0:"Failed to add %{smart_count} file due to an internal error",1:"Failed to add %{smart_count} files due to internal errors"},youCanOnlyUploadX:{0:"You can only upload %{smart_count} file",1:"You can only upload %{smart_count} files"},youHaveToAtLeastSelectX:{0:"You have to select at least %{smart_count} file",1:"You have to select at least %{smart_count} files"},aggregateExceedsSize:"You selected %{size} of files, but maximum allowed size is %{sizeAllowed}",exceedsSize:"%{file} exceeds maximum allowed size of %{size}",missingRequiredMetaField:"Missing required meta fields",missingRequiredMetaFieldOnFile:"Missing required meta fields in %{fileName}",inferiorSize:"This file is smaller than the allowed size of %{size}",youCanOnlyUploadFileTypes:"You can only upload: %{types}",noMoreFilesAllowed:"Cannot add more files",noDuplicates:"Cannot add the duplicate file '%{fileName}', it already exists",companionError:"Connection with Companion failed",authAborted:"Authentication aborted",companionUnauthorizeHint:"To unauthorize to your %{provider} account, please go to %{url}",failedToUpload:"Failed to upload %{file}",noInternetConnection:"No Internet connection",connectedToInternet:"Connected to the Internet",noFilesFound:"You have no files or folders here",noSearchResults:"Unfortunately, there are no results for this search",selectX:{0:"Select %{smart_count}",1:"Select %{smart_count}"},allFilesFromFolderNamed:"All files from folder %{name}",openFolderNamed:"Open folder %{name}",cancel:"Cancel",logOut:"Log out",logIn:"Log in",pickFiles:"Pick files",pickPhotos:"Pick photos",filter:"Filter",resetFilter:"Reset filter",loading:"Loading...",loadedXFiles:"Loaded %{numFiles} files",authenticateWithTitle:"Please authenticate with %{pluginName} to select files",authenticateWith:"Connect to %{pluginName}",signInWithGoogle:"Sign in with Google",searchImages:"Search for images",enterTextToSearch:"Enter text to search for images",search:"Search",resetSearch:"Reset search",emptyFolderAdded:"No files were added from empty folder",addedNumFiles:"Added %{numFiles} file(s)",folderAlreadyAdded:'The folder "%{folder}" was already added',folderAdded:{0:"Added %{smart_count} file from %{folder}",1:"Added %{smart_count} files from %{folder}"},additionalRestrictionsFailed:"%{count} additional restrictions were not fulfilled",unnamed:"Unnamed",pleaseWait:"Please wait"}};function _s(r){if(r==null&&typeof navigator<"u"&&(r=navigator.userAgent),!r)return!0;const t=/Edge\/(\d+\.\d+)/.exec(r);if(!t)return!0;const i=t[1].split(".",2),s=parseInt(i[0],10),a=parseInt(i[1],10);return s<15||s===15&&a<15063||s>18||s===18&&a>=18218}const _t={totalProgress:0,allowNewUpload:!0,error:null,recoveredState:null};class Bi{static VERSION=ys.version;#t=Object.create(null);#e;#r;#i=fs();#a=new Set;#s=new Set;#n=new Set;defaultLocale;locale;opts;store;i18n;i18nArray;scheduledAutoProceed=null;wasOffline=!1;constructor(t){this.defaultLocale=ws;const e={id:"uppy",autoProceed:!1,allowMultipleUploadBatches:!0,debug:!1,restrictions:Xr,meta:{},onBeforeFileAdded:(s,a)=>!Object.hasOwn(a,s.id),onBeforeUpload:s=>s,store:new Jr,logger:zr,infoTimeout:5e3},i={...e,...t};this.opts={...i,restrictions:{...e.restrictions,...t?.restrictions}},t?.logger&&t.debug?this.log("You are using a custom `logger`, but also set `debug: true`, which uses built-in logger to output logs to console. Ignoring `debug: true` and using your custom `logger`.","warning"):t?.debug&&(this.opts.logger=Lr),this.log(`Using Core v${Bi.VERSION}`),this.i18nInit(),this.store=this.opts.store,this.setState({..._t,plugins:{},files:{},currentUploads:{},capabilities:{uploadProgress:_s(),individualCancellation:!0,resumableUploads:!1},meta:{...this.opts.meta},info:[]}),this.#e=new Yr(()=>this.opts,()=>this.i18n),this.#r=this.store.subscribe((s,a,n)=>{this.emit("state-update",s,a,n),this.updateAll(a)}),this.opts.debug&&typeof window<"u"&&(window[this.opts.id]=this),this.#T()}emit(t,...e){this.#i.emit(t,...e)}on(t,e){return this.#i.on(t,e),this}once(t,e){return this.#i.once(t,e),this}off(t,e){return this.#i.off(t,e),this}updateAll(t){this.iteratePlugins(e=>{e.update(t)})}setState(t){this.store.setState(t)}getState(){return this.store.getState()}patchFilesState(t){const e=this.getState().files;this.setState({files:{...e,...Object.fromEntries(Object.entries(t).map(([i,s])=>[i,{...e[i],...s}]))}})}setFileState(t,e){if(!this.getState().files[t])throw new Error(`Can’t set state for ${t} (the file could have been removed)`);this.patchFilesState({[t]:e})}i18nInit(){const t=i=>this.log(`Missing i18n string: ${i}`,"error"),e=new Ri([this.defaultLocale,this.opts.locale],{onMissingKey:t});this.i18n=e.translate.bind(e),this.i18nArray=e.translateArray.bind(e),this.locale=e.locale}setOptions(t){this.opts={...this.opts,...t,restrictions:{...this.opts.restrictions,...t?.restrictions}},t.meta&&this.setMeta(t.meta),this.i18nInit(),t.locale&&this.iteratePlugins(e=>{e.setOptions(t)}),this.setState(void 0)}resetProgress(){const t={percentage:0,bytesUploaded:!1,uploadComplete:!1,uploadStarted:null},e={...this.getState().files},i=Object.create(null);Object.keys(e).forEach(s=>{i[s]={...e[s],progress:{...e[s].progress,...t},tus:void 0,transloadit:void 0}}),this.setState({files:i,..._t})}clear(){const{capabilities:t,currentUploads:e}=this.getState();if(Object.keys(e).length>0&&!t.individualCancellation)throw new Error("The installed uploader plugin does not allow removing files during an upload.");this.setState({..._t,files:{}})}addPreProcessor(t){this.#a.add(t)}removePreProcessor(t){return this.#a.delete(t)}addPostProcessor(t){this.#n.add(t)}removePostProcessor(t){return this.#n.delete(t)}addUploader(t){this.#s.add(t)}removeUploader(t){return this.#s.delete(t)}setMeta(t){const e={...this.getState().meta,...t},i={...this.getState().files};Object.keys(i).forEach(s=>{i[s]={...i[s],meta:{...i[s].meta,...t}}}),this.log("Adding metadata:"),this.log(t),this.setState({meta:e,files:i})}setFileMeta(t,e){const i={...this.getState().files};if(!i[t]){this.log(`Was trying to set metadata for a file that has been removed: ${t}`);return}const s={...i[t].meta,...e};i[t]={...i[t],meta:s},this.setState({files:i})}getFile(t){return this.getState().files[t]}getFiles(){const{files:t}=this.getState();return Object.values(t)}getFilesByIds(t){return t.map(e=>this.getFile(e))}getObjectOfFilesPerState(){const{files:t,totalProgress:e,error:i}=this.getState(),s=Object.values(t),a=[],n=[],o=[],c=[],l=[],d=[],h=[],u=[],p=[];for(const g of s){const{progress:y}=g;!y.uploadComplete&&y.uploadStarted&&(a.push(g),g.isPaused||u.push(g)),y.uploadStarted||n.push(g),(y.uploadStarted||y.preprocess||y.postprocess)&&o.push(g),y.uploadStarted&&c.push(g),g.isPaused&&l.push(g),y.uploadComplete&&d.push(g),g.error&&h.push(g),(y.preprocess||y.postprocess)&&p.push(g)}return{newFiles:n,startedFiles:o,uploadStartedFiles:c,pausedFiles:l,completeFiles:d,erroredFiles:h,inProgressFiles:a,inProgressNotPausedFiles:u,processingFiles:p,isUploadStarted:c.length>0,isAllComplete:e===100&&d.length===s.length&&p.length===0,isAllErrored:!!i&&h.length===s.length,isAllPaused:a.length!==0&&l.length===a.length,isUploadInProgress:a.length>0,isSomeGhost:s.some(g=>g.isGhost)}}#o(t){for(const n of t)n.isRestriction?this.emit("restriction-failed",n.file,n):this.emit("error",n,n.file),this.log(n,"warning");const e=t.filter(n=>n.isUserFacing),i=4,s=e.slice(0,i),a=e.slice(i);s.forEach(({message:n,details:o=""})=>{this.info({message:n,details:o},"error",this.opts.infoTimeout)}),a.length>0&&this.info({message:this.i18n("additionalRestrictionsFailed",{count:a.length})})}validateRestrictions(t,e=this.getFiles()){try{this.#e.validate(e,[t])}catch(i){return i}return null}validateSingleFile(t){try{this.#e.validateSingleFile(t)}catch(e){return e.message}return null}validateAggregateRestrictions(t){const e=this.getFiles();try{this.#e.validateAggregateRestrictions(e,t)}catch(i){return i.message}return null}#u(t){const{missingFields:e,error:i}=this.#e.getMissingRequiredMetaFields(t);return e.length>0?(this.setFileState(t.id,{missingRequiredMetaFields:e,error:i.message}),this.log(i.message),this.emit("restriction-failed",t,i),!1):(e.length===0&&t.missingRequiredMetaFields&&this.setFileState(t.id,{missingRequiredMetaFields:[]}),!0)}#w(t){let e=!0;for(const i of Object.values(t))this.#u(i)||(e=!1);return e}#_(t){const{allowNewUpload:e}=this.getState();if(e===!1){const i=new $(this.i18n("noMoreFilesAllowed"),{file:t});throw this.#o([i]),i}}checkIfFileAlreadyExists(t){const{files:e}=this.getState();return!!(e[t]&&!e[t].isGhost)}#S(t){const e=t instanceof File?{name:t.name,type:t.type,size:t.size,data:t,meta:{},isRemote:!1,source:void 0,preview:void 0}:t,i=Mi(e),s=bs(i,e),a=Ti(s).extension,n=xr(e,this.getID()),o={...e.meta,name:s,type:i},c=Number.isFinite(e.data.size)?e.data.size:null;return{source:e.source||"",id:n,name:s,extension:a||"",meta:{...this.getState().meta,...o},type:i,progress:{percentage:0,bytesUploaded:!1,bytesTotal:c,uploadComplete:!1,uploadStarted:null},size:c,isGhost:!1,...e.isRemote?{isRemote:!0,remote:e.remote,data:e.data}:{isRemote:!1,data:e.data},preview:e.preview}}#p(){this.opts.autoProceed&&!this.scheduledAutoProceed&&(this.scheduledAutoProceed=setTimeout(()=>{this.scheduledAutoProceed=null,this.upload().catch(t=>{t.isRestriction||this.log(t.stack||t.message||t)})},4))}#f(t){let{files:e}=this.getState(),i={...e};const s=[],a=[];for(const n of t)try{let o=this.#S(n);this.#_(o);const c=e[o.id],l=c?.isGhost;if(l&&!o.isRemote){if(o.data==null)throw new Error("File data is missing");o={...c,isGhost:!1,data:o.data},this.log(`Replaced the blob in the restored ghost file: ${o.name}, ${o.id}`)}const d=this.opts.onBeforeFileAdded(o,i);if(e=this.getState().files,i={...e,...i},!d&&this.checkIfFileAlreadyExists(o.id))throw new $(this.i18n("noDuplicates",{fileName:o.name??this.i18n("unnamed")}),{file:o});if(d===!1&&!l)throw new $("Cannot add the file because onBeforeFileAdded returned false.",{isUserFacing:!1,file:o});typeof d=="object"&&d!==null&&(o=d),this.#e.validateSingleFile(o),i[o.id]=o,s.push(o)}catch(o){a.push(o)}try{this.#e.validateAggregateRestrictions(Object.values(e),s)}catch(n){return a.push(n),{nextFilesState:e,validFilesToAdd:[],errors:a}}return{nextFilesState:i,validFilesToAdd:s,errors:a}}addFile(t){const{nextFilesState:e,validFilesToAdd:i,errors:s}=this.#f([t]),a=s.filter(o=>o.isRestriction);if(this.#o(a),s.length>0)throw s[0];this.setState({files:e});const[n]=i;return this.emit("file-added",n),this.emit("files-added",i),this.log(`Added file: ${n.name}, ${n.id}, mime type: ${n.type}`),this.#p(),n.id}addFiles(t){const{nextFilesState:e,validFilesToAdd:i,errors:s}=this.#f(t),a=s.filter(o=>o.isRestriction);this.#o(a);const n=s.filter(o=>!o.isRestriction);if(n.length>0){let o=`Multiple errors occurred while adding files:
|
||
`;if(n.forEach(c=>{o+=`
|
||
* ${c.message}`}),this.info({message:this.i18n("addBulkFilesFailed",{smart_count:n.length}),details:o},"error",this.opts.infoTimeout),typeof AggregateError=="function")throw new AggregateError(n,o);{const c=new Error(o);throw c.errors=n,c}}this.setState({files:e}),i.forEach(o=>{this.emit("file-added",o)}),this.emit("files-added",i),i.length>5?this.log(`Added batch of ${i.length} files`):Object.values(i).forEach(o=>{this.log(`Added file: ${o.name}
|
||
id: ${o.id}
|
||
type: ${o.type}`)}),i.length>0&&this.#p()}removeFiles(t){const{files:e,currentUploads:i}=this.getState(),s={...e},a={...i},n=Object.create(null);t.forEach(d=>{e[d]&&(n[d]=e[d],delete s[d])});function o(d){return n[d]===void 0}Object.keys(a).forEach(d=>{const h=i[d].fileIDs.filter(o);if(h.length===0){delete a[d];return}const{capabilities:u}=this.getState();if(h.length!==i[d].fileIDs.length&&!u.individualCancellation)throw new Error("The installed uploader plugin does not allow removing files during an upload.");a[d]={...i[d],fileIDs:h}});const c={currentUploads:a,files:s};Object.keys(s).length===0&&(c.allowNewUpload=!0,c.error=null,c.recoveredState=null),this.setState(c),this.#h();const l=Object.keys(n);l.forEach(d=>{this.emit("file-removed",n[d])}),l.length>5?this.log(`Removed ${l.length} files`):this.log(`Removed files: ${l.join(", ")}`)}removeFile(t){this.removeFiles([t])}pauseResume(t){if(!this.getState().capabilities.resumableUploads||this.getFile(t).progress.uploadComplete)return;const e=this.getFile(t),s=!(e.isPaused||!1);return this.setFileState(t,{isPaused:s}),this.emit("upload-pause",e,s),s}pauseAll(){const t={...this.getState().files};Object.keys(t).filter(i=>!t[i].progress.uploadComplete&&t[i].progress.uploadStarted).forEach(i=>{const s={...t[i],isPaused:!0};t[i]=s}),this.setState({files:t}),this.emit("pause-all")}resumeAll(){const t={...this.getState().files};Object.keys(t).filter(i=>!t[i].progress.uploadComplete&&t[i].progress.uploadStarted).forEach(i=>{const s={...t[i],isPaused:!1,error:null};t[i]=s}),this.setState({files:t}),this.emit("resume-all")}#g(){const{files:t}=this.getState();return Object.keys(t).filter(e=>{const i=t[e];return i.error&&(!i.missingRequiredMetaFields||i.missingRequiredMetaFields.length===0)})}async#m(){const t=this.#g(),e={...this.getState().files};if(t.forEach(s=>{e[s]={...e[s],isPaused:!1,error:null}}),this.setState({files:e,error:null}),this.emit("retry-all",this.getFilesByIds(t)),t.length===0)return{successful:[],failed:[]};const i=this.#c(t,{forceAllowNewUpload:!0});return this.#d(i)}async retryAll(){const t=await this.#m();return this.emit("complete",t),t}cancelAll(){this.emit("cancel-all");const{files:t}=this.getState(),e=Object.keys(t);e.length&&this.removeFiles(e),this.setState(_t)}retryUpload(t){this.setFileState(t,{error:null,isPaused:!1}),this.emit("upload-retry",this.getFile(t));const e=this.#c([t],{forceAllowNewUpload:!0});return this.#d(e)}logout(){this.iteratePlugins(t=>{t.provider?.logout?.()})}#x=(t,e)=>{const i=t?this.getFile(t.id):void 0;if(t==null||!i){this.log(`Not setting progress for a file that has been removed: ${t?.id}`);return}if(i.progress.percentage===100){this.log(`Not setting progress for a file that has been already uploaded: ${t.id}`);return}const s={bytesTotal:e.bytesTotal,percentage:e.bytesTotal!=null&&Number.isFinite(e.bytesTotal)&&e.bytesTotal>0?Math.round(e.bytesUploaded/e.bytesTotal*100):void 0};i.progress.uploadStarted!=null?this.setFileState(t.id,{progress:{...i.progress,...s,bytesUploaded:e.bytesUploaded}}):this.setFileState(t.id,{progress:{...i.progress,...s}}),this.#h()};#v(){const t=this.#E();let e=null;t!=null&&(e=Math.round(t*100),e>100?e=100:e<0&&(e=0)),this.emit("progress",e??0),this.setState({totalProgress:e??0})}#h=ds(()=>this.#v(),500,{leading:!0,trailing:!0});[Symbol.for("uppy test: updateTotalProgress")](){return this.#v()}#E(){const e=this.getFiles().filter(c=>c.progress.uploadStarted||c.progress.preprocess||c.progress.postprocess);if(e.length===0)return 0;if(e.every(c=>c.progress.uploadComplete))return 1;const i=c=>c.progress.bytesTotal!=null&&c.progress.bytesTotal!==0,s=e.filter(i),a=e.filter(c=>!i(c));if(s.every(c=>c.progress.uploadComplete)&&a.length>0&&!a.every(c=>c.progress.uploadComplete))return null;const n=s.reduce((c,l)=>c+(l.progress.bytesTotal??0),0),o=s.reduce((c,l)=>c+(l.progress.bytesUploaded||0),0);return n===0?0:o/n}#T(){const t=(s,a,n)=>{let o=s.message||"Unknown error";s.details&&(o+=` ${s.details}`),this.setState({error:o}),a!=null&&a.id in this.getState().files&&this.setFileState(a.id,{error:o,response:n})};this.on("error",t),this.on("upload-error",(s,a,n)=>{if(t(a,s,n),typeof a=="object"&&a.message){this.log(a.message,"error");const o=new Error(this.i18n("failedToUpload",{file:s?.name??""}));o.isUserFacing=!0,o.details=a.message,a.details&&(o.details+=` ${a.details}`),this.#o([o])}else this.#o([a])});let e=null;this.on("upload-stalled",(s,a)=>{const{message:n}=s,o=a.map(c=>c.meta.name).join(", ");e||(this.info({message:n,details:o},"warning",this.opts.infoTimeout),e=setTimeout(()=>{e=null},this.opts.infoTimeout)),this.log(`${n} ${o}`.trim(),"warning")}),this.on("upload",()=>{this.setState({error:null})});const i=s=>{const a=s.filter(o=>{const c=o!=null&&this.getFile(o.id);return c||this.log(`Not setting progress for a file that has been removed: ${o?.id}`),c}),n=Object.fromEntries(a.map(o=>[o.id,{progress:{uploadStarted:Date.now(),uploadComplete:!1,bytesUploaded:0,bytesTotal:o.size}}]));this.patchFilesState(n)};this.on("upload-start",i),this.on("upload-progress",this.#x),this.on("upload-success",(s,a)=>{if(s==null||!this.getFile(s.id)){this.log(`Not setting progress for a file that has been removed: ${s?.id}`);return}const n=this.getFile(s.id).progress,o=this.#n.size>0;this.setFileState(s.id,{progress:{...n,postprocess:o?{mode:"indeterminate"}:void 0,uploadComplete:!0,...!o&&{complete:!0},percentage:100,bytesUploaded:n.bytesTotal},response:a,uploadURL:a.uploadURL,isPaused:!1}),s.size==null&&this.setFileState(s.id,{size:a.bytesUploaded||n.bytesTotal}),this.#h()}),this.on("preprocess-progress",(s,a)=>{if(s==null||!this.getFile(s.id)){this.log(`Not setting progress for a file that has been removed: ${s?.id}`);return}this.setFileState(s.id,{progress:{...this.getFile(s.id).progress,preprocess:a}})}),this.on("preprocess-complete",s=>{if(s==null||!this.getFile(s.id)){this.log(`Not setting progress for a file that has been removed: ${s?.id}`);return}const a={...this.getState().files};a[s.id]={...a[s.id],progress:{...a[s.id].progress}},delete a[s.id].progress.preprocess,this.setState({files:a})}),this.on("postprocess-progress",(s,a)=>{if(s==null||!this.getFile(s.id)){this.log(`Not setting progress for a file that has been removed: ${s?.id}`);return}this.setFileState(s.id,{progress:{...this.getState().files[s.id].progress,postprocess:a}})}),this.on("postprocess-complete",s=>{const a=s&&this.getFile(s.id);if(a==null){this.log(`Not setting progress for a file that has been removed: ${s?.id}`);return}const{postprocess:n,...o}=a.progress;this.patchFilesState({[a.id]:{progress:{...o,complete:!0}}})}),this.on("restored",()=>{this.#h()}),this.on("dashboard:file-edit-complete",s=>{s&&this.#u(s)}),typeof window<"u"&&window.addEventListener&&(window.addEventListener("online",this.#l),window.addEventListener("offline",this.#l),setTimeout(this.#l,3e3))}updateOnlineStatus(){window.navigator.onLine??!0?(this.emit("is-online"),this.wasOffline&&(this.emit("back-online"),this.info(this.i18n("connectedToInternet"),"success",3e3),this.wasOffline=!1)):(this.emit("is-offline"),this.info(this.i18n("noInternetConnection"),"error",0),this.wasOffline=!0)}#l=this.updateOnlineStatus.bind(this);getID(){return this.opts.id}use(t,...e){if(typeof t!="function"){const n=`Expected a plugin class, but got ${t===null?"null":typeof t}. Please verify that the plugin was imported and spelled correctly.`;throw new TypeError(n)}const i=new t(this,...e),s=i.id;if(!s)throw new Error("Your plugin must have an id");if(!i.type)throw new Error("Your plugin must have a type");const a=this.getPlugin(s);if(a){const n=`Already found a plugin named '${a.id}'. Tried to use: '${s}'.
|
||
Uppy plugins must have unique \`id\` options.`;throw new Error(n)}return t.VERSION&&this.log(`Using ${s} v${t.VERSION}`),i.type in this.#t?this.#t[i.type].push(i):this.#t[i.type]=[i],i.install(),this.emit("plugin-added",i),this}getPlugin(t){for(const e of Object.values(this.#t)){const i=e.find(s=>s.id===t);if(i!=null)return i}}[Symbol.for("uppy test: getPlugins")](t){return this.#t[t]}iteratePlugins(t){Object.values(this.#t).flat(1).forEach(t)}removePlugin(t){this.log(`Removing plugin ${t.id}`),this.emit("plugin-remove",t),t.uninstall&&t.uninstall();const e=this.#t[t.type],i=e.findIndex(n=>n.id===t.id);i!==-1&&e.splice(i,1);const a={plugins:{...this.getState().plugins,[t.id]:void 0}};this.setState(a)}destroy(){this.log(`Closing Uppy instance ${this.opts.id}: removing all files and uninstalling plugins`),this.cancelAll(),this.#r(),this.iteratePlugins(t=>{this.removePlugin(t)}),typeof window<"u"&&window.removeEventListener&&(window.removeEventListener("online",this.#l),window.removeEventListener("offline",this.#l))}hideInfo(){const{info:t}=this.getState();this.setState({info:t.slice(1)}),this.emit("info-hidden")}info(t,e="info",i=3e3){const s=typeof t=="object";this.setState({info:[...this.getState().info,{type:e,message:s?t.message:t,details:s?t.details:null}]}),setTimeout(()=>this.hideInfo(),i),this.emit("info-visible")}log(t,e){const{logger:i}=this.opts;switch(e){case"error":i.error(t);break;case"warning":i.warn(t);break;default:i.debug(t);break}}#y=new Map;registerRequestClient(t,e){this.#y.set(t,e)}getRequestClientForFile(t){if(!("remote"in t&&t.remote))throw new Error(`Tried to get RequestClient for a non-remote file ${t.id}`);const e=this.#y.get(t.remote.requestClientId);if(e==null)throw new Error(`requestClientId "${t.remote.requestClientId}" not registered for file "${t.id}"`);return e}async restore(t){this.log(`Core: Running restored upload "${t}"`);const e=await this.#d(t);return this.emit("complete",e),e}#c(t,e={}){const{forceAllowNewUpload:i=!1}=e,{allowNewUpload:s,currentUploads:a}=this.getState();if(!s&&!i)throw new Error("Cannot create a new upload: already uploading.");const n=ms();return this.emit("upload",n,this.getFilesByIds(t)),this.setState({allowNewUpload:this.opts.allowMultipleUploadBatches!==!1&&this.opts.allowMultipleUploads!==!1,currentUploads:{...a,[n]:{fileIDs:t,step:0,result:{}}}}),n}[Symbol.for("uppy test: createUpload")](...t){return this.#c(...t)}#M(t){const{currentUploads:e}=this.getState();return e[t]}addResultData(t,e){if(!this.#M(t)){this.log(`Not setting result for an upload that has been removed: ${t}`);return}const{currentUploads:i}=this.getState(),s={...i[t],result:{...i[t].result,...e}};this.setState({currentUploads:{...i,[t]:s}})}#b(t){const{[t]:e,...i}=this.getState().currentUploads;this.setState({currentUploads:i})}async#d(t){const e=()=>{const{currentUploads:n}=this.getState();return n[t]};let i=e();if(!i)throw new Error("Nonexistent upload");const s=[...this.#a,...this.#s,...this.#n];try{for(let n=i.step||0;n<s.length;n++){const o=s[n];this.setState({currentUploads:{...this.getState().currentUploads,[t]:{...i,step:n}}});const{fileIDs:c}=i;if(await o(c,t),i=e(),!i)break}}catch(n){throw this.#b(t),n}if(i){i.fileIDs.forEach(l=>{const d=this.getFile(l);d?.progress.postprocess&&this.emit("postprocess-complete",d)});const n=i.fileIDs.map(l=>this.getFile(l)),o=n.filter(l=>!l.error),c=n.filter(l=>l.error);this.addResultData(t,{successful:o,failed:c,uploadID:t}),i=e()}let a;return i&&(a=i.result,this.#b(t)),a==null&&(this.log(`Not setting result for an upload that has been removed: ${t}`),a={successful:[],failed:[],uploadID:t}),a}async upload(){this.#t.uploader?.length||this.log("No uploader type plugins are used","warning");let{files:t}=this.getState();if(this.#g().length>0){const s=await this.#m();if(!(this.getFiles().filter(n=>n.progress.uploadStarted==null).length>0))return this.emit("complete",s),s;({files:t}=this.getState())}const i=this.opts.onBeforeUpload(t);if(i===!1)throw new Error("Not starting the upload because onBeforeUpload returned false");i&&typeof i=="object"&&(t=i,this.setState({files:t}));try{if(this.#e.validateMinNumberOfFiles(t),!this.#w(t))throw new $(this.i18n("missingRequiredMetaField"));const{currentUploads:s}=this.getState(),a=Object.values(s).flatMap(l=>l.fileIDs),n=Object.keys(t).filter(l=>{const d=this.getFile(l);return d&&!d.progress.uploadStarted&&!a.includes(l)}),o=this.#c(n),c=await this.#d(o);return this.emit("complete",c),c}catch(s){throw this.#o([s]),s}}}const Ss="5.2.0",xs={version:Ss},Es={strings:{uploadStalled:"Upload has not made any progress for %{seconds} seconds. You may want to retry it."}};function Ts(r,t){let e=t;return e||(e=new Error("Upload error")),typeof e=="string"&&(e=new Error(e)),e instanceof Error||(e=Object.assign(new Error("Upload error"),{data:e})),Tr(r)?(e=new ne(e,r),e):(e.request=r,e)}function li(r){return r.data.slice(0,r.data.size,r.meta.type)}const Ms={formData:!0,fieldName:"file",method:"post",allowedMetaFields:!0,bundle:!1,headers:{},timeout:30*1e3,limit:5,withCredentials:!1,responseType:""};class Ba extends zi{static VERSION=xs.version;#t;#e;uploaderEvents;constructor(t,e){if(super(t,{...Ms,fieldName:e.bundle?"files[]":"file",...e}),this.type="uploader",this.id=this.opts.id||"XHRUpload",this.defaultLocale=Es,this.i18nInit(),this.#e=new Mr({concurrency:this.opts.limit}),this.opts.bundle&&!this.opts.formData)throw new Error("`opts.formData` must be true when `opts.bundle` is enabled.");if(this.opts.bundle&&typeof this.opts.headers=="function")throw new Error("`opts.headers` can not be a function when the `bundle: true` option is set.");if(e?.allowedMetaFields===void 0&&"metaFields"in this.opts)throw new Error("The `metaFields` option has been renamed to `allowedMetaFields`.");this.uploaderEvents=Object.create(null),this.#t=i=>async(s,a)=>{try{const n=await pr(s,{...a,onBeforeRequest:(l,d)=>this.opts.onBeforeRequest?.(l,d,i),shouldRetry:this.opts.shouldRetry,onAfterResponse:this.opts.onAfterResponse,onTimeout:l=>{const d=Math.ceil(l/1e3),h=new Error(this.i18n("uploadStalled",{seconds:d}));this.uppy.emit("upload-stalled",h,i)},onUploadProgress:l=>{if(l.lengthComputable)for(const{id:d}of i){const h=this.uppy.getFile(d);h!=null&&this.uppy.emit("upload-progress",h,{uploadStarted:h.progress.uploadStarted??0,bytesUploaded:l.loaded/l.total*h.size,bytesTotal:h.size})}}});let o=await this.opts.getResponseData?.(n);if(n.responseType==="json")o??=n.response;else try{o??=JSON.parse(n.responseText)}catch(l){throw new Error("@uppy/xhr-upload expects a JSON response (with a `url` property). To parse non-JSON responses, use `getResponseData` to turn your response into JSON.",{cause:l})}const c=typeof o?.url=="string"?o.url:void 0;for(const{id:l}of i)this.uppy.emit("upload-success",this.uppy.getFile(l),{status:n.status,body:o,uploadURL:c});return n}catch(n){if(n.name==="AbortError")return;const o=n.request;for(const c of i)this.uppy.emit("upload-error",this.uppy.getFile(c.id),Ts(o,n),o);throw n}}}getOptions(t){const e=this.uppy.getState().xhrUpload,{headers:i}=this.opts,s={...this.opts,...e||{},...t.xhrUpload||{},headers:{}};return typeof i=="function"?s.headers=i(t):Object.assign(s.headers,this.opts.headers),e&&Object.assign(s.headers,e.headers),t.xhrUpload&&Object.assign(s.headers,t.xhrUpload.headers),s}addMetadata(t,e,i){ke(i.allowedMetaFields,e).forEach(a=>{const n=e[a];Array.isArray(n)?n.forEach(o=>t.append(a,o)):t.append(a,n)})}createFormDataUpload(t,e){const i=new FormData;this.addMetadata(i,t.meta,e);const s=li(t);return t.name?i.append(e.fieldName,s,t.meta.name):i.append(e.fieldName,s),i}createBundledUpload(t,e){const i=new FormData,{meta:s}=this.uppy.getState();return this.addMetadata(i,s,e),t.forEach(a=>{const n=this.getOptions(a),o=li(a);a.name?i.append(n.fieldName,o,a.name):i.append(n.fieldName,o)}),i}async#r(t){const e=new Ir(this.uppy),i=new AbortController;e.onFileRemove(t.id,()=>i.abort()),e.onCancelAll(t.id,()=>i.abort());try{await this.#e.add(async s=>{const a=this.getOptions(t),n=this.#t([t]),o=a.formData?this.createFormDataUpload(t,a):t.data,c=typeof a.endpoint=="string"?a.endpoint:await a.endpoint(t);return n(c,{...a,body:o,signal:AbortSignal.any([s,i.signal])})})}catch(s){if(s.name==="AbortError")return;throw s}finally{e.remove()}}async#i(t){const e=new AbortController;function i(){e.abort()}this.uppy.once("cancel-all",i);try{await this.#e.add(async s=>{const a=this.uppy.getState().xhrUpload??{},n=this.#t(t),o=this.createBundledUpload(t,{...this.opts,...a}),c=typeof this.opts.endpoint=="string"?this.opts.endpoint:await this.opts.endpoint(t);return n(c,{...this.opts,body:o,signal:AbortSignal.any([s,e.signal])})})}catch(s){if(s.name==="AbortError")return;throw s}finally{this.uppy.off("cancel-all",i)}}#a(t){const e=this.getOptions(t),i=ke(e.allowedMetaFields,t.meta);return{...t.remote?.body,protocol:"multipart",endpoint:e.endpoint,size:t.data.size,fieldname:e.fieldName,metadata:Object.fromEntries(i.map(s=>[s,t.meta[s]])),httpMethod:e.method,useFormData:e.formData,headers:e.headers}}async#s(t){await Promise.allSettled(t.map(e=>{if(e.isRemote){const i=()=>this.#e,s=new AbortController,a=n=>{n.id===e.id&&s.abort()};return this.uppy.on("file-removed",a),this.uppy.getRequestClientForFile(e).uploadRemoteFile(e,this.#a(e),{signal:s.signal,getQueue:i}).finally(()=>{this.uppy.off("file-removed",a)})}return this.#r(e)}))}#n=async t=>{if(t.length===0){this.uppy.log("[XHRUpload] No files to upload!");return}this.opts.limit===0&&this.uppy.log("[XHRUpload] When uploading multiple files at once, consider setting the `limit` option (to `10` for example), to limit the number of concurrent uploads, which helps prevent memory and network issues: https://uppy.io/docs/xhr-upload/#limit-0","warning"),this.uppy.log("[XHRUpload] Uploading...");const e=this.uppy.getFilesByIds(t),i=mr(e),s=vr(i);if(this.uppy.emit("upload-start",s),this.opts.bundle){if(i.some(n=>n.isRemote))throw new Error("Can’t upload remote files when the `bundle: true` option is set");if(typeof this.opts.headers=="function")throw new TypeError("`headers` may not be a function when the `bundle: true` option is set");await this.#i(i)}else await this.#s(i)};install(){if(this.opts.bundle){const{capabilities:t}=this.uppy.getState();this.uppy.setState({capabilities:{...t,individualCancellation:!1}})}this.uppy.addUploader(this.#n)}uninstall(){if(this.opts.bundle){const{capabilities:t}=this.uppy.getState();this.uppy.setState({capabilities:{...t,individualCancellation:!0}})}this.uppy.removeUploader(this.#n)}}function hi(r,t){var e=Object.keys(r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(r);t&&(i=i.filter(function(s){return Object.getOwnPropertyDescriptor(r,s).enumerable})),e.push.apply(e,i)}return e}function Hi(r){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?hi(Object(e),!0).forEach(function(i){Cs(r,i,e[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(e)):hi(Object(e)).forEach(function(i){Object.defineProperty(r,i,Object.getOwnPropertyDescriptor(e,i))})}return r}function Rs(r,t){if(typeof r!="object"||!r)return r;var e=r[Symbol.toPrimitive];if(e!==void 0){var i=e.call(r,t);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(r)}function $i(r){var t=Rs(r,"string");return typeof t=="symbol"?t:t+""}function ce(r){"@babel/helpers - typeof";return ce=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ce(r)}function Os(r,t){if(!(r instanceof t))throw new TypeError("Cannot call a class as a function")}function ci(r,t){for(var e=0;e<t.length;e++){var i=t[e];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(r,$i(i.key),i)}}function Fs(r,t,e){return t&&ci(r.prototype,t),e&&ci(r,e),Object.defineProperty(r,"prototype",{writable:!1}),r}function Cs(r,t,e){return t=$i(t),t in r?Object.defineProperty(r,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):r[t]=e,r}function qi(r){return As(r)||Ns(r)||Ds(r)||Ps()}function As(r){if(Array.isArray(r))return de(r)}function Ns(r){if(typeof Symbol<"u"&&r[Symbol.iterator]!=null||r["@@iterator"]!=null)return Array.from(r)}function Ds(r,t){if(r){if(typeof r=="string")return de(r,t);var e=Object.prototype.toString.call(r).slice(8,-1);if(e==="Object"&&r.constructor&&(e=r.constructor.name),e==="Map"||e==="Set")return Array.from(r);if(e==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return de(r,t)}}function de(r,t){(t==null||t>r.length)&&(t=r.length);for(var e=0,i=new Array(t);e<t;e++)i[e]=r[e];return i}function Ps(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
||
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var Ut=typeof window<"u"&&typeof window.document<"u",X=Ut?window:{},Te=Ut&&X.document.documentElement?"ontouchstart"in X.document.documentElement:!1,Me=Ut?"PointerEvent"in X:!1,C="cropper",Re="all",Wi="crop",Xi="move",Yi="zoom",Q="e",tt="w",it="s",G="n",lt="ne",ht="nw",ct="se",dt="sw",ue="".concat(C,"-crop"),di="".concat(C,"-disabled"),z="".concat(C,"-hidden"),ui="".concat(C,"-hide"),Us="".concat(C,"-invisible"),Ct="".concat(C,"-modal"),pe="".concat(C,"-move"),ft="".concat(C,"Action"),St="".concat(C,"Preview"),Oe="crop",Vi="move",Gi="none",fe="crop",ge="cropend",me="cropmove",ve="cropstart",pi="dblclick",ks=Te?"touchstart":"mousedown",Is=Te?"touchmove":"mousemove",zs=Te?"touchend touchcancel":"mouseup",fi=Me?"pointerdown":ks,gi=Me?"pointermove":Is,mi=Me?"pointerup pointercancel":zs,vi="ready",yi="resize",bi="wheel",ye="zoom",wi="image/jpeg",Ls=/^e|w|s|n|se|sw|ne|nw|all|crop|move|zoom$/,js=/^data:/,Bs=/^data:image\/jpeg;base64,/,Hs=/^img|canvas$/i,Zi=200,Ji=100,_i={viewMode:0,dragMode:Oe,initialAspectRatio:NaN,aspectRatio:NaN,data:null,preview:"",responsive:!0,restore:!0,checkCrossOrigin:!0,checkOrientation:!0,modal:!0,guides:!0,center:!0,highlight:!0,background:!0,autoCrop:!0,autoCropArea:.8,movable:!0,rotatable:!0,scalable:!0,zoomable:!0,zoomOnTouch:!0,zoomOnWheel:!0,wheelZoomRatio:.1,cropBoxMovable:!0,cropBoxResizable:!0,toggleDragModeOnDblclick:!0,minCanvasWidth:0,minCanvasHeight:0,minCropBoxWidth:0,minCropBoxHeight:0,minContainerWidth:Zi,minContainerHeight:Ji,ready:null,cropstart:null,cropmove:null,cropend:null,crop:null,zoom:null},$s='<div class="cropper-container" touch-action="none"><div class="cropper-wrap-box"><div class="cropper-canvas"></div></div><div class="cropper-drag-box"></div><div class="cropper-crop-box"><span class="cropper-view-box"></span><span class="cropper-dashed dashed-h"></span><span class="cropper-dashed dashed-v"></span><span class="cropper-center"></span><span class="cropper-face"></span><span class="cropper-line line-e" data-cropper-action="e"></span><span class="cropper-line line-n" data-cropper-action="n"></span><span class="cropper-line line-w" data-cropper-action="w"></span><span class="cropper-line line-s" data-cropper-action="s"></span><span class="cropper-point point-e" data-cropper-action="e"></span><span class="cropper-point point-n" data-cropper-action="n"></span><span class="cropper-point point-w" data-cropper-action="w"></span><span class="cropper-point point-s" data-cropper-action="s"></span><span class="cropper-point point-ne" data-cropper-action="ne"></span><span class="cropper-point point-nw" data-cropper-action="nw"></span><span class="cropper-point point-sw" data-cropper-action="sw"></span><span class="cropper-point point-se" data-cropper-action="se"></span></div></div>',qs=Number.isNaN||X.isNaN;function T(r){return typeof r=="number"&&!qs(r)}var Si=function(t){return t>0&&t<1/0};function se(r){return typeof r>"u"}function et(r){return ce(r)==="object"&&r!==null}var Ws=Object.prototype.hasOwnProperty;function rt(r){if(!et(r))return!1;try{var t=r.constructor,e=t.prototype;return t&&e&&Ws.call(e,"isPrototypeOf")}catch{return!1}}function I(r){return typeof r=="function"}var Xs=Array.prototype.slice;function Ki(r){return Array.from?Array.from(r):Xs.call(r)}function D(r,t){return r&&I(t)&&(Array.isArray(r)||T(r.length)?Ki(r).forEach(function(e,i){t.call(r,e,i,r)}):et(r)&&Object.keys(r).forEach(function(e){t.call(r,r[e],e,r)})),r}var A=Object.assign||function(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),s=1;s<e;s++)i[s-1]=arguments[s];return et(t)&&i.length>0&&i.forEach(function(a){et(a)&&Object.keys(a).forEach(function(n){t[n]=a[n]})}),t},Ys=/\.\d*(?:0|9){12}\d*$/;function at(r){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1e11;return Ys.test(r)?Math.round(r*t)/t:r}var Vs=/^width|height|left|top|marginLeft|marginTop$/;function J(r,t){var e=r.style;D(t,function(i,s){Vs.test(s)&&T(i)&&(i="".concat(i,"px")),e[s]=i})}function Gs(r,t){return r.classList?r.classList.contains(t):r.className.indexOf(t)>-1}function k(r,t){if(t){if(T(r.length)){D(r,function(i){k(i,t)});return}if(r.classList){r.classList.add(t);return}var e=r.className.trim();e?e.indexOf(t)<0&&(r.className="".concat(e," ").concat(t)):r.className=t}}function W(r,t){if(t){if(T(r.length)){D(r,function(e){W(e,t)});return}if(r.classList){r.classList.remove(t);return}r.className.indexOf(t)>=0&&(r.className=r.className.replace(t,""))}}function st(r,t,e){if(t){if(T(r.length)){D(r,function(i){st(i,t,e)});return}e?k(r,t):W(r,t)}}var Zs=/([a-z\d])([A-Z])/g;function Fe(r){return r.replace(Zs,"$1-$2").toLowerCase()}function be(r,t){return et(r[t])?r[t]:r.dataset?r.dataset[t]:r.getAttribute("data-".concat(Fe(t)))}function gt(r,t,e){et(e)?r[t]=e:r.dataset?r.dataset[t]=e:r.setAttribute("data-".concat(Fe(t)),e)}function Js(r,t){if(et(r[t]))try{delete r[t]}catch{r[t]=void 0}else if(r.dataset)try{delete r.dataset[t]}catch{r.dataset[t]=void 0}else r.removeAttribute("data-".concat(Fe(t)))}var Qi=/\s\s*/,tr=(function(){var r=!1;if(Ut){var t=!1,e=function(){},i=Object.defineProperty({},"once",{get:function(){return r=!0,t},set:function(a){t=a}});X.addEventListener("test",e,i),X.removeEventListener("test",e,i)}return r})();function H(r,t,e){var i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{},s=e;t.trim().split(Qi).forEach(function(a){if(!tr){var n=r.listeners;n&&n[a]&&n[a][e]&&(s=n[a][e],delete n[a][e],Object.keys(n[a]).length===0&&delete n[a],Object.keys(n).length===0&&delete r.listeners)}r.removeEventListener(a,s,i)})}function L(r,t,e){var i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{},s=e;t.trim().split(Qi).forEach(function(a){if(i.once&&!tr){var n=r.listeners,o=n===void 0?{}:n;s=function(){delete o[a][e],r.removeEventListener(a,s,i);for(var l=arguments.length,d=new Array(l),h=0;h<l;h++)d[h]=arguments[h];e.apply(r,d)},o[a]||(o[a]={}),o[a][e]&&r.removeEventListener(a,o[a][e],i),o[a][e]=s,r.listeners=o}r.addEventListener(a,s,i)})}function nt(r,t,e){var i;return I(Event)&&I(CustomEvent)?i=new CustomEvent(t,{detail:e,bubbles:!0,cancelable:!0}):(i=document.createEvent("CustomEvent"),i.initCustomEvent(t,!0,!0,e)),r.dispatchEvent(i)}function er(r){var t=r.getBoundingClientRect();return{left:t.left+(window.pageXOffset-document.documentElement.clientLeft),top:t.top+(window.pageYOffset-document.documentElement.clientTop)}}var ae=X.location,Ks=/^(\w+:)\/\/([^:/?#]*):?(\d*)/i;function xi(r){var t=r.match(Ks);return t!==null&&(t[1]!==ae.protocol||t[2]!==ae.hostname||t[3]!==ae.port)}function Ei(r){var t="timestamp=".concat(new Date().getTime());return r+(r.indexOf("?")===-1?"?":"&")+t}function pt(r){var t=r.rotate,e=r.scaleX,i=r.scaleY,s=r.translateX,a=r.translateY,n=[];T(s)&&s!==0&&n.push("translateX(".concat(s,"px)")),T(a)&&a!==0&&n.push("translateY(".concat(a,"px)")),T(t)&&t!==0&&n.push("rotate(".concat(t,"deg)")),T(e)&&e!==1&&n.push("scaleX(".concat(e,")")),T(i)&&i!==1&&n.push("scaleY(".concat(i,")"));var o=n.length?n.join(" "):"none";return{WebkitTransform:o,msTransform:o,transform:o}}function Qs(r){var t=Hi({},r),e=0;return D(r,function(i,s){delete t[s],D(t,function(a){var n=Math.abs(i.startX-a.startX),o=Math.abs(i.startY-a.startY),c=Math.abs(i.endX-a.endX),l=Math.abs(i.endY-a.endY),d=Math.sqrt(n*n+o*o),h=Math.sqrt(c*c+l*l),u=(h-d)/d;Math.abs(u)>Math.abs(e)&&(e=u)})}),e}function xt(r,t){var e=r.pageX,i=r.pageY,s={endX:e,endY:i};return t?s:Hi({startX:e,startY:i},s)}function ta(r){var t=0,e=0,i=0;return D(r,function(s){var a=s.startX,n=s.startY;t+=a,e+=n,i+=1}),t/=i,e/=i,{pageX:t,pageY:e}}function K(r){var t=r.aspectRatio,e=r.height,i=r.width,s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"contain",a=Si(i),n=Si(e);if(a&&n){var o=e*t;s==="contain"&&o>i||s==="cover"&&o<i?e=i/t:i=e*t}else a?e=i/t:n&&(i=e*t);return{width:i,height:e}}function ea(r){var t=r.width,e=r.height,i=r.degree;if(i=Math.abs(i)%180,i===90)return{width:e,height:t};var s=i%90*Math.PI/180,a=Math.sin(s),n=Math.cos(s),o=t*n+e*a,c=t*a+e*n;return i>90?{width:c,height:o}:{width:o,height:c}}function ia(r,t,e,i){var s=t.aspectRatio,a=t.naturalWidth,n=t.naturalHeight,o=t.rotate,c=o===void 0?0:o,l=t.scaleX,d=l===void 0?1:l,h=t.scaleY,u=h===void 0?1:h,p=e.aspectRatio,g=e.naturalWidth,y=e.naturalHeight,v=i.fillColor,b=v===void 0?"transparent":v,m=i.imageSmoothingEnabled,E=m===void 0?!0:m,R=i.imageSmoothingQuality,w=R===void 0?"low":R,f=i.maxWidth,_=f===void 0?1/0:f,x=i.maxHeight,O=x===void 0?1/0:x,U=i.minWidth,Y=U===void 0?0:U,B=i.minHeight,M=B===void 0?0:B,P=document.createElement("canvas"),N=P.getContext("2d"),q=K({aspectRatio:p,width:_,height:O}),mt=K({aspectRatio:p,width:Y,height:M},"cover"),kt=Math.min(q.width,Math.max(mt.width,g)),It=Math.min(q.height,Math.max(mt.height,y)),Ce=K({aspectRatio:s,width:_,height:O}),Ae=K({aspectRatio:s,width:Y,height:M},"cover"),Ne=Math.min(Ce.width,Math.max(Ae.width,a)),De=Math.min(Ce.height,Math.max(Ae.height,n)),hr=[-Ne/2,-De/2,Ne,De];return P.width=at(kt),P.height=at(It),N.fillStyle=b,N.fillRect(0,0,kt,It),N.save(),N.translate(kt/2,It/2),N.rotate(c*Math.PI/180),N.scale(d,u),N.imageSmoothingEnabled=E,N.imageSmoothingQuality=w,N.drawImage.apply(N,[r].concat(qi(hr.map(function(cr){return Math.floor(at(cr))})))),N.restore(),P}var ir=String.fromCharCode;function ra(r,t,e){var i="";e+=t;for(var s=t;s<e;s+=1)i+=ir(r.getUint8(s));return i}var sa=/^data:.*,/;function aa(r){var t=r.replace(sa,""),e=atob(t),i=new ArrayBuffer(e.length),s=new Uint8Array(i);return D(s,function(a,n){s[n]=e.charCodeAt(n)}),i}function na(r,t){for(var e=[],i=8192,s=new Uint8Array(r);s.length>0;)e.push(ir.apply(null,Ki(s.subarray(0,i)))),s=s.subarray(i);return"data:".concat(t,";base64,").concat(btoa(e.join("")))}function oa(r){var t=new DataView(r),e;try{var i,s,a;if(t.getUint8(0)===255&&t.getUint8(1)===216)for(var n=t.byteLength,o=2;o+1<n;){if(t.getUint8(o)===255&&t.getUint8(o+1)===225){s=o;break}o+=1}if(s){var c=s+4,l=s+10;if(ra(t,c,4)==="Exif"){var d=t.getUint16(l);if(i=d===18761,(i||d===19789)&&t.getUint16(l+2,i)===42){var h=t.getUint32(l+4,i);h>=8&&(a=l+h)}}}if(a){var u=t.getUint16(a,i),p,g;for(g=0;g<u;g+=1)if(p=a+g*12+2,t.getUint16(p,i)===274){p+=8,e=t.getUint16(p,i),t.setUint16(p,1,i);break}}}catch{e=1}return e}function la(r){var t=0,e=1,i=1;switch(r){case 2:e=-1;break;case 3:t=-180;break;case 4:i=-1;break;case 5:t=90,i=-1;break;case 6:t=90;break;case 7:t=90,e=-1;break;case 8:t=-90;break}return{rotate:t,scaleX:e,scaleY:i}}var ha={render:function(){this.initContainer(),this.initCanvas(),this.initCropBox(),this.renderCanvas(),this.cropped&&this.renderCropBox()},initContainer:function(){var t=this.element,e=this.options,i=this.container,s=this.cropper,a=Number(e.minContainerWidth),n=Number(e.minContainerHeight);k(s,z),W(t,z);var o={width:Math.max(i.offsetWidth,a>=0?a:Zi),height:Math.max(i.offsetHeight,n>=0?n:Ji)};this.containerData=o,J(s,{width:o.width,height:o.height}),k(t,z),W(s,z)},initCanvas:function(){var t=this.containerData,e=this.imageData,i=this.options.viewMode,s=Math.abs(e.rotate)%180===90,a=s?e.naturalHeight:e.naturalWidth,n=s?e.naturalWidth:e.naturalHeight,o=a/n,c=t.width,l=t.height;t.height*o>t.width?i===3?c=t.height*o:l=t.width/o:i===3?l=t.width/o:c=t.height*o;var d={aspectRatio:o,naturalWidth:a,naturalHeight:n,width:c,height:l};this.canvasData=d,this.limited=i===1||i===2,this.limitCanvas(!0,!0),d.width=Math.min(Math.max(d.width,d.minWidth),d.maxWidth),d.height=Math.min(Math.max(d.height,d.minHeight),d.maxHeight),d.left=(t.width-d.width)/2,d.top=(t.height-d.height)/2,d.oldLeft=d.left,d.oldTop=d.top,this.initialCanvasData=A({},d)},limitCanvas:function(t,e){var i=this.options,s=this.containerData,a=this.canvasData,n=this.cropBoxData,o=i.viewMode,c=a.aspectRatio,l=this.cropped&&n;if(t){var d=Number(i.minCanvasWidth)||0,h=Number(i.minCanvasHeight)||0;o>1?(d=Math.max(d,s.width),h=Math.max(h,s.height),o===3&&(h*c>d?d=h*c:h=d/c)):o>0&&(d?d=Math.max(d,l?n.width:0):h?h=Math.max(h,l?n.height:0):l&&(d=n.width,h=n.height,h*c>d?d=h*c:h=d/c));var u=K({aspectRatio:c,width:d,height:h});d=u.width,h=u.height,a.minWidth=d,a.minHeight=h,a.maxWidth=1/0,a.maxHeight=1/0}if(e)if(o>(l?0:1)){var p=s.width-a.width,g=s.height-a.height;a.minLeft=Math.min(0,p),a.minTop=Math.min(0,g),a.maxLeft=Math.max(0,p),a.maxTop=Math.max(0,g),l&&this.limited&&(a.minLeft=Math.min(n.left,n.left+(n.width-a.width)),a.minTop=Math.min(n.top,n.top+(n.height-a.height)),a.maxLeft=n.left,a.maxTop=n.top,o===2&&(a.width>=s.width&&(a.minLeft=Math.min(0,p),a.maxLeft=Math.max(0,p)),a.height>=s.height&&(a.minTop=Math.min(0,g),a.maxTop=Math.max(0,g))))}else a.minLeft=-a.width,a.minTop=-a.height,a.maxLeft=s.width,a.maxTop=s.height},renderCanvas:function(t,e){var i=this.canvasData,s=this.imageData;if(e){var a=ea({width:s.naturalWidth*Math.abs(s.scaleX||1),height:s.naturalHeight*Math.abs(s.scaleY||1),degree:s.rotate||0}),n=a.width,o=a.height,c=i.width*(n/i.naturalWidth),l=i.height*(o/i.naturalHeight);i.left-=(c-i.width)/2,i.top-=(l-i.height)/2,i.width=c,i.height=l,i.aspectRatio=n/o,i.naturalWidth=n,i.naturalHeight=o,this.limitCanvas(!0,!1)}(i.width>i.maxWidth||i.width<i.minWidth)&&(i.left=i.oldLeft),(i.height>i.maxHeight||i.height<i.minHeight)&&(i.top=i.oldTop),i.width=Math.min(Math.max(i.width,i.minWidth),i.maxWidth),i.height=Math.min(Math.max(i.height,i.minHeight),i.maxHeight),this.limitCanvas(!1,!0),i.left=Math.min(Math.max(i.left,i.minLeft),i.maxLeft),i.top=Math.min(Math.max(i.top,i.minTop),i.maxTop),i.oldLeft=i.left,i.oldTop=i.top,J(this.canvas,A({width:i.width,height:i.height},pt({translateX:i.left,translateY:i.top}))),this.renderImage(t),this.cropped&&this.limited&&this.limitCropBox(!0,!0)},renderImage:function(t){var e=this.canvasData,i=this.imageData,s=i.naturalWidth*(e.width/e.naturalWidth),a=i.naturalHeight*(e.height/e.naturalHeight);A(i,{width:s,height:a,left:(e.width-s)/2,top:(e.height-a)/2}),J(this.image,A({width:i.width,height:i.height},pt(A({translateX:i.left,translateY:i.top},i)))),t&&this.output()},initCropBox:function(){var t=this.options,e=this.canvasData,i=t.aspectRatio||t.initialAspectRatio,s=Number(t.autoCropArea)||.8,a={width:e.width,height:e.height};i&&(e.height*i>e.width?a.height=a.width/i:a.width=a.height*i),this.cropBoxData=a,this.limitCropBox(!0,!0),a.width=Math.min(Math.max(a.width,a.minWidth),a.maxWidth),a.height=Math.min(Math.max(a.height,a.minHeight),a.maxHeight),a.width=Math.max(a.minWidth,a.width*s),a.height=Math.max(a.minHeight,a.height*s),a.left=e.left+(e.width-a.width)/2,a.top=e.top+(e.height-a.height)/2,a.oldLeft=a.left,a.oldTop=a.top,this.initialCropBoxData=A({},a)},limitCropBox:function(t,e){var i=this.options,s=this.containerData,a=this.canvasData,n=this.cropBoxData,o=this.limited,c=i.aspectRatio;if(t){var l=Number(i.minCropBoxWidth)||0,d=Number(i.minCropBoxHeight)||0,h=o?Math.min(s.width,a.width,a.width+a.left,s.width-a.left):s.width,u=o?Math.min(s.height,a.height,a.height+a.top,s.height-a.top):s.height;l=Math.min(l,s.width),d=Math.min(d,s.height),c&&(l&&d?d*c>l?d=l/c:l=d*c:l?d=l/c:d&&(l=d*c),u*c>h?u=h/c:h=u*c),n.minWidth=Math.min(l,h),n.minHeight=Math.min(d,u),n.maxWidth=h,n.maxHeight=u}e&&(o?(n.minLeft=Math.max(0,a.left),n.minTop=Math.max(0,a.top),n.maxLeft=Math.min(s.width,a.left+a.width)-n.width,n.maxTop=Math.min(s.height,a.top+a.height)-n.height):(n.minLeft=0,n.minTop=0,n.maxLeft=s.width-n.width,n.maxTop=s.height-n.height))},renderCropBox:function(){var t=this.options,e=this.containerData,i=this.cropBoxData;(i.width>i.maxWidth||i.width<i.minWidth)&&(i.left=i.oldLeft),(i.height>i.maxHeight||i.height<i.minHeight)&&(i.top=i.oldTop),i.width=Math.min(Math.max(i.width,i.minWidth),i.maxWidth),i.height=Math.min(Math.max(i.height,i.minHeight),i.maxHeight),this.limitCropBox(!1,!0),i.left=Math.min(Math.max(i.left,i.minLeft),i.maxLeft),i.top=Math.min(Math.max(i.top,i.minTop),i.maxTop),i.oldLeft=i.left,i.oldTop=i.top,t.movable&&t.cropBoxMovable&>(this.face,ft,i.width>=e.width&&i.height>=e.height?Xi:Re),J(this.cropBox,A({width:i.width,height:i.height},pt({translateX:i.left,translateY:i.top}))),this.cropped&&this.limited&&this.limitCanvas(!0,!0),this.disabled||this.output()},output:function(){this.preview(),nt(this.element,fe,this.getData())}},ca={initPreview:function(){var t=this.element,e=this.crossOrigin,i=this.options.preview,s=e?this.crossOriginUrl:this.url,a=t.alt||"The image to preview",n=document.createElement("img");if(e&&(n.crossOrigin=e),n.src=s,n.alt=a,this.viewBox.appendChild(n),this.viewBoxImage=n,!!i){var o=i;typeof i=="string"?o=t.ownerDocument.querySelectorAll(i):i.querySelector&&(o=[i]),this.previews=o,D(o,function(c){var l=document.createElement("img");gt(c,St,{width:c.offsetWidth,height:c.offsetHeight,html:c.innerHTML}),e&&(l.crossOrigin=e),l.src=s,l.alt=a,l.style.cssText='display:block;width:100%;height:auto;min-width:0!important;min-height:0!important;max-width:none!important;max-height:none!important;image-orientation:0deg!important;"',c.innerHTML="",c.appendChild(l)})}},resetPreview:function(){D(this.previews,function(t){var e=be(t,St);J(t,{width:e.width,height:e.height}),t.innerHTML=e.html,Js(t,St)})},preview:function(){var t=this.imageData,e=this.canvasData,i=this.cropBoxData,s=i.width,a=i.height,n=t.width,o=t.height,c=i.left-e.left-t.left,l=i.top-e.top-t.top;!this.cropped||this.disabled||(J(this.viewBoxImage,A({width:n,height:o},pt(A({translateX:-c,translateY:-l},t)))),D(this.previews,function(d){var h=be(d,St),u=h.width,p=h.height,g=u,y=p,v=1;s&&(v=u/s,y=a*v),a&&y>p&&(v=p/a,g=s*v,y=p),J(d,{width:g,height:y}),J(d.getElementsByTagName("img")[0],A({width:n*v,height:o*v},pt(A({translateX:-c*v,translateY:-l*v},t))))}))}},da={bind:function(){var t=this.element,e=this.options,i=this.cropper;I(e.cropstart)&&L(t,ve,e.cropstart),I(e.cropmove)&&L(t,me,e.cropmove),I(e.cropend)&&L(t,ge,e.cropend),I(e.crop)&&L(t,fe,e.crop),I(e.zoom)&&L(t,ye,e.zoom),L(i,fi,this.onCropStart=this.cropStart.bind(this)),e.zoomable&&e.zoomOnWheel&&L(i,bi,this.onWheel=this.wheel.bind(this),{passive:!1,capture:!0}),e.toggleDragModeOnDblclick&&L(i,pi,this.onDblclick=this.dblclick.bind(this)),L(t.ownerDocument,gi,this.onCropMove=this.cropMove.bind(this)),L(t.ownerDocument,mi,this.onCropEnd=this.cropEnd.bind(this)),e.responsive&&L(window,yi,this.onResize=this.resize.bind(this))},unbind:function(){var t=this.element,e=this.options,i=this.cropper;I(e.cropstart)&&H(t,ve,e.cropstart),I(e.cropmove)&&H(t,me,e.cropmove),I(e.cropend)&&H(t,ge,e.cropend),I(e.crop)&&H(t,fe,e.crop),I(e.zoom)&&H(t,ye,e.zoom),H(i,fi,this.onCropStart),e.zoomable&&e.zoomOnWheel&&H(i,bi,this.onWheel,{passive:!1,capture:!0}),e.toggleDragModeOnDblclick&&H(i,pi,this.onDblclick),H(t.ownerDocument,gi,this.onCropMove),H(t.ownerDocument,mi,this.onCropEnd),e.responsive&&H(window,yi,this.onResize)}},ua={resize:function(){if(!this.disabled){var t=this.options,e=this.container,i=this.containerData,s=e.offsetWidth/i.width,a=e.offsetHeight/i.height,n=Math.abs(s-1)>Math.abs(a-1)?s:a;if(n!==1){var o,c;t.restore&&(o=this.getCanvasData(),c=this.getCropBoxData()),this.render(),t.restore&&(this.setCanvasData(D(o,function(l,d){o[d]=l*n})),this.setCropBoxData(D(c,function(l,d){c[d]=l*n})))}}},dblclick:function(){this.disabled||this.options.dragMode===Gi||this.setDragMode(Gs(this.dragBox,ue)?Vi:Oe)},wheel:function(t){var e=this,i=Number(this.options.wheelZoomRatio)||.1,s=1;this.disabled||(t.preventDefault(),!this.wheeling&&(this.wheeling=!0,setTimeout(function(){e.wheeling=!1},50),t.deltaY?s=t.deltaY>0?1:-1:t.wheelDelta?s=-t.wheelDelta/120:t.detail&&(s=t.detail>0?1:-1),this.zoom(-s*i,t)))},cropStart:function(t){var e=t.buttons,i=t.button;if(!(this.disabled||(t.type==="mousedown"||t.type==="pointerdown"&&t.pointerType==="mouse")&&(T(e)&&e!==1||T(i)&&i!==0||t.ctrlKey))){var s=this.options,a=this.pointers,n;t.changedTouches?D(t.changedTouches,function(o){a[o.identifier]=xt(o)}):a[t.pointerId||0]=xt(t),Object.keys(a).length>1&&s.zoomable&&s.zoomOnTouch?n=Yi:n=be(t.target,ft),Ls.test(n)&&nt(this.element,ve,{originalEvent:t,action:n})!==!1&&(t.preventDefault(),this.action=n,this.cropping=!1,n===Wi&&(this.cropping=!0,k(this.dragBox,Ct)))}},cropMove:function(t){var e=this.action;if(!(this.disabled||!e)){var i=this.pointers;t.preventDefault(),nt(this.element,me,{originalEvent:t,action:e})!==!1&&(t.changedTouches?D(t.changedTouches,function(s){A(i[s.identifier]||{},xt(s,!0))}):A(i[t.pointerId||0]||{},xt(t,!0)),this.change(t))}},cropEnd:function(t){if(!this.disabled){var e=this.action,i=this.pointers;t.changedTouches?D(t.changedTouches,function(s){delete i[s.identifier]}):delete i[t.pointerId||0],e&&(t.preventDefault(),Object.keys(i).length||(this.action=""),this.cropping&&(this.cropping=!1,st(this.dragBox,Ct,this.cropped&&this.options.modal)),nt(this.element,ge,{originalEvent:t,action:e}))}}},pa={change:function(t){var e=this.options,i=this.canvasData,s=this.containerData,a=this.cropBoxData,n=this.pointers,o=this.action,c=e.aspectRatio,l=a.left,d=a.top,h=a.width,u=a.height,p=l+h,g=d+u,y=0,v=0,b=s.width,m=s.height,E=!0,R;!c&&t.shiftKey&&(c=h&&u?h/u:1),this.limited&&(y=a.minLeft,v=a.minTop,b=y+Math.min(s.width,i.width,i.left+i.width),m=v+Math.min(s.height,i.height,i.top+i.height));var w=n[Object.keys(n)[0]],f={x:w.endX-w.startX,y:w.endY-w.startY},_=function(O){switch(O){case Q:p+f.x>b&&(f.x=b-p);break;case tt:l+f.x<y&&(f.x=y-l);break;case G:d+f.y<v&&(f.y=v-d);break;case it:g+f.y>m&&(f.y=m-g);break}};switch(o){case Re:l+=f.x,d+=f.y;break;case Q:if(f.x>=0&&(p>=b||c&&(d<=v||g>=m))){E=!1;break}_(Q),h+=f.x,h<0&&(o=tt,h=-h,l-=h),c&&(u=h/c,d+=(a.height-u)/2);break;case G:if(f.y<=0&&(d<=v||c&&(l<=y||p>=b))){E=!1;break}_(G),u-=f.y,d+=f.y,u<0&&(o=it,u=-u,d-=u),c&&(h=u*c,l+=(a.width-h)/2);break;case tt:if(f.x<=0&&(l<=y||c&&(d<=v||g>=m))){E=!1;break}_(tt),h-=f.x,l+=f.x,h<0&&(o=Q,h=-h,l-=h),c&&(u=h/c,d+=(a.height-u)/2);break;case it:if(f.y>=0&&(g>=m||c&&(l<=y||p>=b))){E=!1;break}_(it),u+=f.y,u<0&&(o=G,u=-u,d-=u),c&&(h=u*c,l+=(a.width-h)/2);break;case lt:if(c){if(f.y<=0&&(d<=v||p>=b)){E=!1;break}_(G),u-=f.y,d+=f.y,h=u*c}else _(G),_(Q),f.x>=0?p<b?h+=f.x:f.y<=0&&d<=v&&(E=!1):h+=f.x,f.y<=0?d>v&&(u-=f.y,d+=f.y):(u-=f.y,d+=f.y);h<0&&u<0?(o=dt,u=-u,h=-h,d-=u,l-=h):h<0?(o=ht,h=-h,l-=h):u<0&&(o=ct,u=-u,d-=u);break;case ht:if(c){if(f.y<=0&&(d<=v||l<=y)){E=!1;break}_(G),u-=f.y,d+=f.y,h=u*c,l+=a.width-h}else _(G),_(tt),f.x<=0?l>y?(h-=f.x,l+=f.x):f.y<=0&&d<=v&&(E=!1):(h-=f.x,l+=f.x),f.y<=0?d>v&&(u-=f.y,d+=f.y):(u-=f.y,d+=f.y);h<0&&u<0?(o=ct,u=-u,h=-h,d-=u,l-=h):h<0?(o=lt,h=-h,l-=h):u<0&&(o=dt,u=-u,d-=u);break;case dt:if(c){if(f.x<=0&&(l<=y||g>=m)){E=!1;break}_(tt),h-=f.x,l+=f.x,u=h/c}else _(it),_(tt),f.x<=0?l>y?(h-=f.x,l+=f.x):f.y>=0&&g>=m&&(E=!1):(h-=f.x,l+=f.x),f.y>=0?g<m&&(u+=f.y):u+=f.y;h<0&&u<0?(o=lt,u=-u,h=-h,d-=u,l-=h):h<0?(o=ct,h=-h,l-=h):u<0&&(o=ht,u=-u,d-=u);break;case ct:if(c){if(f.x>=0&&(p>=b||g>=m)){E=!1;break}_(Q),h+=f.x,u=h/c}else _(it),_(Q),f.x>=0?p<b?h+=f.x:f.y>=0&&g>=m&&(E=!1):h+=f.x,f.y>=0?g<m&&(u+=f.y):u+=f.y;h<0&&u<0?(o=ht,u=-u,h=-h,d-=u,l-=h):h<0?(o=dt,h=-h,l-=h):u<0&&(o=lt,u=-u,d-=u);break;case Xi:this.move(f.x,f.y),E=!1;break;case Yi:this.zoom(Qs(n),t),E=!1;break;case Wi:if(!f.x||!f.y){E=!1;break}R=er(this.cropper),l=w.startX-R.left,d=w.startY-R.top,h=a.minWidth,u=a.minHeight,f.x>0?o=f.y>0?ct:lt:f.x<0&&(l-=h,o=f.y>0?dt:ht),f.y<0&&(d-=u),this.cropped||(W(this.cropBox,z),this.cropped=!0,this.limited&&this.limitCropBox(!0,!0));break}E&&(a.width=h,a.height=u,a.left=l,a.top=d,this.action=o,this.renderCropBox()),D(n,function(x){x.startX=x.endX,x.startY=x.endY})}},fa={crop:function(){return this.ready&&!this.cropped&&!this.disabled&&(this.cropped=!0,this.limitCropBox(!0,!0),this.options.modal&&k(this.dragBox,Ct),W(this.cropBox,z),this.setCropBoxData(this.initialCropBoxData)),this},reset:function(){return this.ready&&!this.disabled&&(this.imageData=A({},this.initialImageData),this.canvasData=A({},this.initialCanvasData),this.cropBoxData=A({},this.initialCropBoxData),this.renderCanvas(),this.cropped&&this.renderCropBox()),this},clear:function(){return this.cropped&&!this.disabled&&(A(this.cropBoxData,{left:0,top:0,width:0,height:0}),this.cropped=!1,this.renderCropBox(),this.limitCanvas(!0,!0),this.renderCanvas(),W(this.dragBox,Ct),k(this.cropBox,z)),this},replace:function(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return!this.disabled&&t&&(this.isImg&&(this.element.src=t),e?(this.url=t,this.image.src=t,this.ready&&(this.viewBoxImage.src=t,D(this.previews,function(i){i.getElementsByTagName("img")[0].src=t}))):(this.isImg&&(this.replaced=!0),this.options.data=null,this.uncreate(),this.load(t))),this},enable:function(){return this.ready&&this.disabled&&(this.disabled=!1,W(this.cropper,di)),this},disable:function(){return this.ready&&!this.disabled&&(this.disabled=!0,k(this.cropper,di)),this},destroy:function(){var t=this.element;return t[C]?(t[C]=void 0,this.isImg&&this.replaced&&(t.src=this.originalUrl),this.uncreate(),this):this},move:function(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:t,i=this.canvasData,s=i.left,a=i.top;return this.moveTo(se(t)?t:s+Number(t),se(e)?e:a+Number(e))},moveTo:function(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:t,i=this.canvasData,s=!1;return t=Number(t),e=Number(e),this.ready&&!this.disabled&&this.options.movable&&(T(t)&&(i.left=t,s=!0),T(e)&&(i.top=e,s=!0),s&&this.renderCanvas(!0)),this},zoom:function(t,e){var i=this.canvasData;return t=Number(t),t<0?t=1/(1-t):t=1+t,this.zoomTo(i.width*t/i.naturalWidth,null,e)},zoomTo:function(t,e,i){var s=this.options,a=this.canvasData,n=a.width,o=a.height,c=a.naturalWidth,l=a.naturalHeight;if(t=Number(t),t>=0&&this.ready&&!this.disabled&&s.zoomable){var d=c*t,h=l*t;if(nt(this.element,ye,{ratio:t,oldRatio:n/c,originalEvent:i})===!1)return this;if(i){var u=this.pointers,p=er(this.cropper),g=u&&Object.keys(u).length?ta(u):{pageX:i.pageX,pageY:i.pageY};a.left-=(d-n)*((g.pageX-p.left-a.left)/n),a.top-=(h-o)*((g.pageY-p.top-a.top)/o)}else rt(e)&&T(e.x)&&T(e.y)?(a.left-=(d-n)*((e.x-a.left)/n),a.top-=(h-o)*((e.y-a.top)/o)):(a.left-=(d-n)/2,a.top-=(h-o)/2);a.width=d,a.height=h,this.renderCanvas(!0)}return this},rotate:function(t){return this.rotateTo((this.imageData.rotate||0)+Number(t))},rotateTo:function(t){return t=Number(t),T(t)&&this.ready&&!this.disabled&&this.options.rotatable&&(this.imageData.rotate=t%360,this.renderCanvas(!0,!0)),this},scaleX:function(t){var e=this.imageData.scaleY;return this.scale(t,T(e)?e:1)},scaleY:function(t){var e=this.imageData.scaleX;return this.scale(T(e)?e:1,t)},scale:function(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:t,i=this.imageData,s=!1;return t=Number(t),e=Number(e),this.ready&&!this.disabled&&this.options.scalable&&(T(t)&&(i.scaleX=t,s=!0),T(e)&&(i.scaleY=e,s=!0),s&&this.renderCanvas(!0,!0)),this},getData:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,e=this.options,i=this.imageData,s=this.canvasData,a=this.cropBoxData,n;if(this.ready&&this.cropped){n={x:a.left-s.left,y:a.top-s.top,width:a.width,height:a.height};var o=i.width/i.naturalWidth;if(D(n,function(d,h){n[h]=d/o}),t){var c=Math.round(n.y+n.height),l=Math.round(n.x+n.width);n.x=Math.round(n.x),n.y=Math.round(n.y),n.width=l-n.x,n.height=c-n.y}}else n={x:0,y:0,width:0,height:0};return e.rotatable&&(n.rotate=i.rotate||0),e.scalable&&(n.scaleX=i.scaleX||1,n.scaleY=i.scaleY||1),n},setData:function(t){var e=this.options,i=this.imageData,s=this.canvasData,a={};if(this.ready&&!this.disabled&&rt(t)){var n=!1;e.rotatable&&T(t.rotate)&&t.rotate!==i.rotate&&(i.rotate=t.rotate,n=!0),e.scalable&&(T(t.scaleX)&&t.scaleX!==i.scaleX&&(i.scaleX=t.scaleX,n=!0),T(t.scaleY)&&t.scaleY!==i.scaleY&&(i.scaleY=t.scaleY,n=!0)),n&&this.renderCanvas(!0,!0);var o=i.width/i.naturalWidth;T(t.x)&&(a.left=t.x*o+s.left),T(t.y)&&(a.top=t.y*o+s.top),T(t.width)&&(a.width=t.width*o),T(t.height)&&(a.height=t.height*o),this.setCropBoxData(a)}return this},getContainerData:function(){return this.ready?A({},this.containerData):{}},getImageData:function(){return this.sized?A({},this.imageData):{}},getCanvasData:function(){var t=this.canvasData,e={};return this.ready&&D(["left","top","width","height","naturalWidth","naturalHeight"],function(i){e[i]=t[i]}),e},setCanvasData:function(t){var e=this.canvasData,i=e.aspectRatio;return this.ready&&!this.disabled&&rt(t)&&(T(t.left)&&(e.left=t.left),T(t.top)&&(e.top=t.top),T(t.width)?(e.width=t.width,e.height=t.width/i):T(t.height)&&(e.height=t.height,e.width=t.height*i),this.renderCanvas(!0)),this},getCropBoxData:function(){var t=this.cropBoxData,e;return this.ready&&this.cropped&&(e={left:t.left,top:t.top,width:t.width,height:t.height}),e||{}},setCropBoxData:function(t){var e=this.cropBoxData,i=this.options.aspectRatio,s,a;return this.ready&&this.cropped&&!this.disabled&&rt(t)&&(T(t.left)&&(e.left=t.left),T(t.top)&&(e.top=t.top),T(t.width)&&t.width!==e.width&&(s=!0,e.width=t.width),T(t.height)&&t.height!==e.height&&(a=!0,e.height=t.height),i&&(s?e.height=e.width/i:a&&(e.width=e.height*i)),this.renderCropBox()),this},getCroppedCanvas:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!this.ready||!window.HTMLCanvasElement)return null;var e=this.canvasData,i=ia(this.image,this.imageData,e,t);if(!this.cropped)return i;var s=this.getData(t.rounded),a=s.x,n=s.y,o=s.width,c=s.height,l=i.width/Math.floor(e.naturalWidth);l!==1&&(a*=l,n*=l,o*=l,c*=l);var d=o/c,h=K({aspectRatio:d,width:t.maxWidth||1/0,height:t.maxHeight||1/0}),u=K({aspectRatio:d,width:t.minWidth||0,height:t.minHeight||0},"cover"),p=K({aspectRatio:d,width:t.width||(l!==1?i.width:o),height:t.height||(l!==1?i.height:c)}),g=p.width,y=p.height;g=Math.min(h.width,Math.max(u.width,g)),y=Math.min(h.height,Math.max(u.height,y));var v=document.createElement("canvas"),b=v.getContext("2d");v.width=at(g),v.height=at(y),b.fillStyle=t.fillColor||"transparent",b.fillRect(0,0,g,y);var m=t.imageSmoothingEnabled,E=m===void 0?!0:m,R=t.imageSmoothingQuality;b.imageSmoothingEnabled=E,R&&(b.imageSmoothingQuality=R);var w=i.width,f=i.height,_=a,x=n,O,U,Y,B,M,P;_<=-o||_>w?(_=0,O=0,Y=0,M=0):_<=0?(Y=-_,_=0,O=Math.min(w,o+_),M=O):_<=w&&(Y=0,O=Math.min(o,w-_),M=O),O<=0||x<=-c||x>f?(x=0,U=0,B=0,P=0):x<=0?(B=-x,x=0,U=Math.min(f,c+x),P=U):x<=f&&(B=0,U=Math.min(c,f-x),P=U);var N=[_,x,O,U];if(M>0&&P>0){var q=g/o;N.push(Y*q,B*q,M*q,P*q)}return b.drawImage.apply(b,[i].concat(qi(N.map(function(mt){return Math.floor(at(mt))})))),v},setAspectRatio:function(t){var e=this.options;return!this.disabled&&!se(t)&&(e.aspectRatio=Math.max(0,t)||NaN,this.ready&&(this.initCropBox(),this.cropped&&this.renderCropBox())),this},setDragMode:function(t){var e=this.options,i=this.dragBox,s=this.face;if(this.ready&&!this.disabled){var a=t===Oe,n=e.movable&&t===Vi;t=a||n?t:Gi,e.dragMode=t,gt(i,ft,t),st(i,ue,a),st(i,pe,n),e.cropBoxMovable||(gt(s,ft,t),st(s,ue,a),st(s,pe,n))}return this}},ga=X.Cropper,rr=(function(){function r(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(Os(this,r),!t||!Hs.test(t.tagName))throw new Error("The first argument is required and must be an <img> or <canvas> element.");this.element=t,this.options=A({},_i,rt(e)&&e),this.cropped=!1,this.disabled=!1,this.pointers={},this.ready=!1,this.reloading=!1,this.replaced=!1,this.sized=!1,this.sizing=!1,this.init()}return Fs(r,[{key:"init",value:function(){var e=this.element,i=e.tagName.toLowerCase(),s;if(!e[C]){if(e[C]=this,i==="img"){if(this.isImg=!0,s=e.getAttribute("src")||"",this.originalUrl=s,!s)return;s=e.src}else i==="canvas"&&window.HTMLCanvasElement&&(s=e.toDataURL());this.load(s)}}},{key:"load",value:function(e){var i=this;if(e){this.url=e,this.imageData={};var s=this.element,a=this.options;if(!a.rotatable&&!a.scalable&&(a.checkOrientation=!1),!a.checkOrientation||!window.ArrayBuffer){this.clone();return}if(js.test(e)){Bs.test(e)?this.read(aa(e)):this.clone();return}var n=new XMLHttpRequest,o=this.clone.bind(this);this.reloading=!0,this.xhr=n,n.onabort=o,n.onerror=o,n.ontimeout=o,n.onprogress=function(){n.getResponseHeader("content-type")!==wi&&n.abort()},n.onload=function(){i.read(n.response)},n.onloadend=function(){i.reloading=!1,i.xhr=null},a.checkCrossOrigin&&xi(e)&&s.crossOrigin&&(e=Ei(e)),n.open("GET",e,!0),n.responseType="arraybuffer",n.withCredentials=s.crossOrigin==="use-credentials",n.send()}}},{key:"read",value:function(e){var i=this.options,s=this.imageData,a=oa(e),n=0,o=1,c=1;if(a>1){this.url=na(e,wi);var l=la(a);n=l.rotate,o=l.scaleX,c=l.scaleY}i.rotatable&&(s.rotate=n),i.scalable&&(s.scaleX=o,s.scaleY=c),this.clone()}},{key:"clone",value:function(){var e=this.element,i=this.url,s=e.crossOrigin,a=i;this.options.checkCrossOrigin&&xi(i)&&(s||(s="anonymous"),a=Ei(i)),this.crossOrigin=s,this.crossOriginUrl=a;var n=document.createElement("img");s&&(n.crossOrigin=s),n.src=a||i,n.alt=e.alt||"The image to crop",this.image=n,n.onload=this.start.bind(this),n.onerror=this.stop.bind(this),k(n,ui),e.parentNode.insertBefore(n,e.nextSibling)}},{key:"start",value:function(){var e=this,i=this.image;i.onload=null,i.onerror=null,this.sizing=!0;var s=X.navigator&&/(?:iPad|iPhone|iPod).*?AppleWebKit/i.test(X.navigator.userAgent),a=function(l,d){A(e.imageData,{naturalWidth:l,naturalHeight:d,aspectRatio:l/d}),e.initialImageData=A({},e.imageData),e.sizing=!1,e.sized=!0,e.build()};if(i.naturalWidth&&!s){a(i.naturalWidth,i.naturalHeight);return}var n=document.createElement("img"),o=document.body||document.documentElement;this.sizingImage=n,n.onload=function(){a(n.width,n.height),s||o.removeChild(n)},n.src=i.src,s||(n.style.cssText="left:0;max-height:none!important;max-width:none!important;min-height:0!important;min-width:0!important;opacity:0;position:absolute;top:0;z-index:-1;",o.appendChild(n))}},{key:"stop",value:function(){var e=this.image;e.onload=null,e.onerror=null,e.parentNode.removeChild(e),this.image=null}},{key:"build",value:function(){if(!(!this.sized||this.ready)){var e=this.element,i=this.options,s=this.image,a=e.parentNode,n=document.createElement("div");n.innerHTML=$s;var o=n.querySelector(".".concat(C,"-container")),c=o.querySelector(".".concat(C,"-canvas")),l=o.querySelector(".".concat(C,"-drag-box")),d=o.querySelector(".".concat(C,"-crop-box")),h=d.querySelector(".".concat(C,"-face"));this.container=a,this.cropper=o,this.canvas=c,this.dragBox=l,this.cropBox=d,this.viewBox=o.querySelector(".".concat(C,"-view-box")),this.face=h,c.appendChild(s),k(e,z),a.insertBefore(o,e.nextSibling),W(s,ui),this.initPreview(),this.bind(),i.initialAspectRatio=Math.max(0,i.initialAspectRatio)||NaN,i.aspectRatio=Math.max(0,i.aspectRatio)||NaN,i.viewMode=Math.max(0,Math.min(3,Math.round(i.viewMode)))||0,k(d,z),i.guides||k(d.getElementsByClassName("".concat(C,"-dashed")),z),i.center||k(d.getElementsByClassName("".concat(C,"-center")),z),i.background&&k(o,"".concat(C,"-bg")),i.highlight||k(h,Us),i.cropBoxMovable&&(k(h,pe),gt(h,ft,Re)),i.cropBoxResizable||(k(d.getElementsByClassName("".concat(C,"-line")),z),k(d.getElementsByClassName("".concat(C,"-point")),z)),this.render(),this.ready=!0,this.setDragMode(i.dragMode),i.autoCrop&&this.crop(),this.setData(i.data),I(i.ready)&&L(e,vi,i.ready,{once:!0}),nt(e,vi)}}},{key:"unbuild",value:function(){if(this.ready){this.ready=!1,this.unbind(),this.resetPreview();var e=this.cropper.parentNode;e&&e.removeChild(this.cropper),W(this.element,z)}}},{key:"uncreate",value:function(){this.ready?(this.unbuild(),this.ready=!1,this.cropped=!1):this.sizing?(this.sizingImage.onload=null,this.sizing=!1,this.sized=!1):this.reloading?(this.xhr.onabort=null,this.xhr.abort()):this.image&&this.stop()}}],[{key:"noConflict",value:function(){return window.Cropper=ga,r}},{key:"setDefaults",value:function(e){A(_i,rt(e)&&e)}}])})();A(rr.prototype,ha,ca,da,ua,pa,fa);const ma="4.2.0",va={version:ma};class ya extends ut{imgElement;componentDidMount(){const{initCropper:t}=this.props;this.imgElement&&t(this.imgElement)}onRotate90Deg=()=>{this.props.rotateBy(-90)};onRotateGranular=t=>{const e=Number(t.target.value);this.props.rotateGranular(e)};renderGranularRotate(){const{i18n:t}=this.props,{angleGranular:e}=this.props;return S("label",{role:"tooltip","aria-label":`${e}º`,"data-microtip-position":"top",className:"uppy-ImageCropper-rangeWrapper",children:S("input",{className:"uppy-ImageCropper-range uppy-u-reset",type:"range",onInput:this.onRotateGranular,onChange:this.onRotateGranular,value:e,min:"-45",max:"45","aria-label":t("rotate")})})}renderRevert(){const{i18n:t}=this.props;return S("button",{"data-microtip-position":"top",type:"button",className:"uppy-u-reset uppy-c-btn","aria-label":t("revert"),onClick:()=>{this.props.reset()},children:S("svg",{"aria-hidden":"true",className:"uppy-c-icon",width:"24",height:"24",viewBox:"0 0 24 24",children:[S("path",{d:"M0 0h24v24H0z",fill:"none"}),S("path",{d:"M13 3c-4.97 0-9 4.03-9 9H1l3.89 3.89.07.14L9 12H6c0-3.87 3.13-7 7-7s7 3.13 7 7-3.13 7-7 7c-1.93 0-3.68-.79-4.94-2.06l-1.42 1.42C8.27 19.99 10.51 21 13 21c4.97 0 9-4.03 9-9s-4.03-9-9-9zm-1 5v5l4.28 2.54.72-1.21-3.5-2.08V8H12z"})]})})}renderRotate(){const{i18n:t}=this.props;return S("button",{"data-microtip-position":"top",type:"button",className:"uppy-u-reset uppy-c-btn","aria-label":t("rotate"),onClick:this.onRotate90Deg,children:S("svg",{"aria-hidden":"true",className:"uppy-c-icon",width:"24",height:"24",viewBox:"0 0 24 24",children:[S("path",{d:"M0 0h24v24H0V0zm0 0h24v24H0V0z",fill:"none"}),S("path",{d:"M14 10a2 2 0 012 2v7a2 2 0 01-2 2H6a2 2 0 01-2-2v-7a2 2 0 012-2h8zm0 1.75H6a.25.25 0 00-.243.193L5.75 12v7a.25.25 0 00.193.243L6 19.25h8a.25.25 0 00.243-.193L14.25 19v-7a.25.25 0 00-.193-.243L14 11.75zM12 .76V4c2.3 0 4.61.88 6.36 2.64a8.95 8.95 0 012.634 6.025L21 13a1 1 0 01-1.993.117L19 13h-.003a6.979 6.979 0 00-2.047-4.95 6.97 6.97 0 00-4.652-2.044L12 6v3.24L7.76 5 12 .76z"})]})})}renderFlip(){const{i18n:t}=this.props;return S("button",{"data-microtip-position":"top",type:"button",className:"uppy-u-reset uppy-c-btn","aria-label":t("flipHorizontal"),onClick:()=>this.props.flipHorizontal(),children:S("svg",{"aria-hidden":"true",className:"uppy-c-icon",width:"24",height:"24",viewBox:"0 0 24 24",children:[S("path",{d:"M0 0h24v24H0z",fill:"none"}),S("path",{d:"M15 21h2v-2h-2v2zm4-12h2V7h-2v2zM3 5v14c0 1.1.9 2 2 2h4v-2H5V5h4V3H5c-1.1 0-2 .9-2 2zm16-2v2h2c0-1.1-.9-2-2-2zm-8 20h2V1h-2v22zm8-6h2v-2h-2v2zM15 5h2V3h-2v2zm4 8h2v-2h-2v2zm0 8c1.1 0 2-.9 2-2h-2v2z"})]})})}renderZoomIn(){const{i18n:t}=this.props;return S("button",{"data-microtip-position":"top",type:"button",className:"uppy-u-reset uppy-c-btn","aria-label":t("zoomIn"),onClick:()=>this.props.zoom(.1),children:S("svg",{"aria-hidden":"true",className:"uppy-c-icon",height:"24",viewBox:"0 0 24 24",width:"24",children:[S("path",{d:"M0 0h24v24H0V0z",fill:"none"}),S("path",{d:"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"}),S("path",{d:"M12 10h-2v2H9v-2H7V9h2V7h1v2h2v1z"})]})})}renderZoomOut(){const{i18n:t}=this.props;return S("button",{"data-microtip-position":"top",type:"button",className:"uppy-u-reset uppy-c-btn","aria-label":t("zoomOut"),onClick:()=>this.props.zoom(-.1),children:S("svg",{"aria-hidden":"true",className:"uppy-c-icon",width:"24",height:"24",viewBox:"0 0 24 24",children:[S("path",{d:"M0 0h24v24H0V0z",fill:"none"}),S("path",{d:"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14zM7 9h5v1H7z"})]})})}renderCropSquare(){const{i18n:t}=this.props;return S("button",{"data-microtip-position":"top",type:"button",className:"uppy-u-reset uppy-c-btn","aria-label":t("aspectRatioSquare"),onClick:()=>this.props.setAspectRatio("1:1"),children:S("svg",{"aria-hidden":"true",className:"uppy-c-icon",width:"24",height:"24",viewBox:"0 0 24 24",children:[S("path",{d:"M0 0h24v24H0z",fill:"none"}),S("path",{d:"M19 5v14H5V5h14m0-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2z"})]})})}renderCropWidescreen(){const{i18n:t}=this.props;return S("button",{"data-microtip-position":"top",type:"button",className:"uppy-u-reset uppy-c-btn","aria-label":t("aspectRatioLandscape"),onClick:()=>this.props.setAspectRatio("16:9"),children:S("svg",{"aria-hidden":"true",className:"uppy-c-icon",width:"24",height:"24",viewBox:"0 0 24 24",children:[S("path",{d:"M 19,4.9999992 V 17.000001 H 4.9999998 V 6.9999992 H 19 m 0,-2 H 4.9999998 c -1.0999999,0 -1.9999999,0.9000001 -1.9999999,2 V 17.000001 c 0,1.1 0.9,2 1.9999999,2 H 19 c 1.1,0 2,-0.9 2,-2 V 6.9999992 c 0,-1.0999999 -0.9,-2 -2,-2 z"}),S("path",{fill:"none",d:"M0 0h24v24H0z"})]})})}renderCropWidescreenVertical(){const{i18n:t}=this.props;return S("button",{"data-microtip-position":"top",type:"button","aria-label":t("aspectRatioPortrait"),className:"uppy-u-reset uppy-c-btn",onClick:()=>this.props.setAspectRatio("9:16"),children:S("svg",{"aria-hidden":"true",className:"uppy-c-icon",width:"24",height:"24",viewBox:"0 0 24 24",children:[S("path",{d:"M 19.000001,19 H 6.999999 V 5 h 10.000002 v 14 m 2,0 V 5 c 0,-1.0999999 -0.9,-1.9999999 -2,-1.9999999 H 6.999999 c -1.1,0 -2,0.9 -2,1.9999999 v 14 c 0,1.1 0.9,2 2,2 h 10.000002 c 1.1,0 2,-0.9 2,-2 z"}),S("path",{d:"M0 0h24v24H0z",fill:"none"})]})})}render(){const{currentImage:t,objectUrl:e,opts:i}=this.props,{actions:s}=i;return S("div",{className:"uppy-ImageCropper",children:[S("div",{className:"uppy-ImageCropper-container",children:S("img",{className:"uppy-ImageCropper-image",alt:t.name,src:e,ref:a=>{this.imgElement=a}})}),S("div",{className:"uppy-ImageCropper-controls",children:[s.revert&&this.renderRevert(),s.rotate&&this.renderRotate(),s.granularRotate&&this.renderGranularRotate(),s.flip&&this.renderFlip(),s.zoomIn&&this.renderZoomIn(),s.zoomOut&&this.renderZoomOut(),s.cropSquare&&this.renderCropSquare(),s.cropWidescreen&&this.renderCropWidescreen(),s.cropWidescreenVertical&&this.renderCropWidescreenVertical()]})]})}}const ba={strings:{revert:"Reset",rotate:"Rotate 90°",zoomIn:"Zoom in",zoomOut:"Zoom out",flipHorizontal:"Flip horizontally",aspectRatioSquare:"Crop square",aspectRatioLandscape:"Crop landscape (16:9)",aspectRatioPortrait:"Crop portrait (9:16)"}};function wa(r,t){const e=r.width/t.width,i=r.height/t.height,s=Math.min(e,i),a=t.width*s,n=t.height*s,o=(r.width-a)/2,c=(r.height-n)/2;return{width:a,height:n,left:o,top:c}}function _a(r){return r*(Math.PI/180)}function Sa(r,t,e){const i=Math.abs(_a(e));return Math.max((Math.sin(i)*r+Math.cos(i)*t)/t,(Math.sin(i)*t+Math.cos(i)*r)/r)}function xa(r,t,e){return t.left<r.left?{left:r.left,width:e.width}:t.top<r.top?{top:r.top,height:e.height}:t.left+t.width>r.left+r.width?{left:r.left+r.width-e.width,width:e.width}:t.top+t.height>r.top+r.height?{top:r.top+r.height-e.height,height:e.height}:null}function Ea(r,t,e){return t.left<r.left?{left:r.left,width:e.left+e.width-r.left}:t.top<r.top?{top:r.top,height:e.top+e.height-r.top}:t.left+t.width>r.left+r.width?{left:e.left,width:r.left+r.width-e.left}:t.top+t.height>r.top+r.height?{top:e.top,height:r.top+r.height-e.top}:null}const Ta={angle:0,angleGranular:0,isFlippedHorizontally:!1,aspectRatio:"free",cropperReady:!1},sr={viewMode:0,background:!1,autoCropArea:1,responsive:!0,minCropBoxWidth:70,minCropBoxHeight:70,croppedCanvasOptions:{},initialAspectRatio:0},ar={revert:!0,rotate:!0,granularRotate:!0,flip:!0,zoomIn:!0,zoomOut:!0,cropSquare:!0,cropWidescreen:!0,cropWidescreenVertical:!0},Ma={quality:.8,actions:ar,cropperOptions:sr};class Ha extends Ft{static VERSION=va.version;cropper=null;objectUrl=null;prevCropboxData=null;imgElement=null;cropstartHandler=null;cropendHandler=null;cropperReadyHandler=null;constructor(t,e){super(t,{...Ma,...e,actions:{...ar,...e?.actions},cropperOptions:{...sr,...e?.cropperOptions}}),this.id=this.opts.id||"ImageEditor",this.title="Image Editor",this.type="editor",this.defaultLocale=ba,this.i18nInit()}canEditFile(t){if(!t.type||t.isRemote)return!1;const e=t.type.split("/")[1];return!!/^(jpe?g|gif|png|bmp|webp)$/.test(e)}save=()=>{const{currentImage:t}=this.getPluginState();if(!t||!this.cropper)return;const e=s=>{if(!s)return;const a=t.id;if(!this.uppy.getFile(a))return;this.uppy.setFileState(a,{data:new File([s],t.name??this.i18n("unnamed"),{type:s.type}),size:s.size,preview:void 0});const n=this.uppy.getFile(a);n&&(this.uppy.emit("thumbnail:request",n),this.setPluginState({currentImage:n}),this.uppy.emit("file-editor:complete",n))},i=this.cropper.getCroppedCanvas({});i.width%2!==0&&this.cropper.setData({width:i.width-1}),i.height%2!==0&&this.cropper.setData({height:i.height-1}),this.cropper.getCroppedCanvas(this.opts.cropperOptions.croppedCanvasOptions).toBlob(e,t.type,this.opts.quality)};storeCropperInstance=t=>{this.cropper=t};selectFile=t=>{this.start(t)};resetEditorState=(t=this.getPluginState().currentImage)=>{this.setPluginState({currentImage:t,...Ta,cropperReady:!!this.cropper})};rotateBy=t=>{if(!this.cropper)return;const{angle:e,angleGranular:i,isFlippedHorizontally:s}=this.getPluginState(),n=e-i+t;this.cropper.scale(s?-1:1),this.cropper.rotateTo(n);const o=this.cropper.getCanvasData(),c=this.cropper.getContainerData(),l=wa(c,o);this.cropper.setCanvasData(l),this.cropper.setCropBoxData(l),this.setPluginState({angle:n,angleGranular:0})};rotateGranular=t=>{if(!this.cropper)return;const{angle:e,angleGranular:i,isFlippedHorizontally:s}=this.getPluginState(),n=e-i+t;this.cropper.rotateTo(n);const o=this.cropper.getImageData(),c=Sa(o.naturalWidth,o.naturalHeight,t),l=s?-c:c;this.cropper.scale(l,c),this.setPluginState({angle:n,angleGranular:t})};flipHorizontal=()=>{if(!this.cropper)return;const{isFlippedHorizontally:t}=this.getPluginState();this.cropper.scaleX(-this.cropper.getData().scaleX||-1),this.setPluginState({isFlippedHorizontally:!t})};zoom=t=>{this.cropper&&this.cropper.zoom(t)};setAspectRatio=t=>{if(!this.cropper)return;const e={free:0,"1:1":1,"16:9":16/9,"9:16":9/16};this.cropper.setAspectRatio(e[t]),this.setPluginState({aspectRatio:t})};reset=()=>{this.cropper&&(this.cropper.reset(),this.cropper.setAspectRatio(this.opts.cropperOptions.initialAspectRatio||0),this.resetEditorState())};start=t=>{this.objectUrl&&(URL.revokeObjectURL(this.objectUrl),this.objectUrl=null);let e=t.data;e instanceof Blob||(e=this.uppy.getFile(t.id)?.data),e instanceof Blob?this.objectUrl=URL.createObjectURL(e):console.warn("[Uppy ImageEditor] Cannot edit file: file.data is not a Blob.","File:",t,"file.data:",t.data,"typeof file.data:",typeof t.data),this.uppy.emit("file-editor:start",t),this.resetEditorState(t)};stop=()=>{this.destroyCropper(),this.objectUrl&&(URL.revokeObjectURL(this.objectUrl),this.objectUrl=null),this.resetEditorState(null)};initCropper=t=>{this.cropper||(this.imgElement=t,this.cropper=new rr(t,this.opts.cropperOptions),this.cropstartHandler=()=>{this.cropper&&(this.prevCropboxData=this.cropper.getCropBoxData())},this.cropendHandler=(e=>{if(!this.cropper||!this.prevCropboxData)return;const i=this.cropper.getCanvasData(),s=this.cropper.getCropBoxData();if(e.detail.action==="all"){const a=xa(i,s,this.prevCropboxData);a&&this.cropper.setCropBoxData(a)}else{const a=Ea(i,s,this.prevCropboxData);a&&this.cropper.setCropBoxData(a)}}),this.cropperReadyHandler=()=>{this.setPluginState({cropperReady:!0})},t.addEventListener("cropstart",this.cropstartHandler),t.addEventListener("cropend",this.cropendHandler),t.addEventListener("ready",this.cropperReadyHandler,{once:!0}))};destroyCropper=()=>{this.cropper&&(this.setPluginState({cropperReady:!1}),this.cropstartHandler&&this.imgElement&&this.imgElement.removeEventListener("cropstart",this.cropstartHandler),this.cropendHandler&&this.imgElement&&this.imgElement.removeEventListener("cropend",this.cropendHandler),this.cropperReadyHandler&&this.imgElement&&this.imgElement.removeEventListener("ready",this.cropperReadyHandler),this.cropper.destroy(),this.cropper=null,this.imgElement=null,this.cropstartHandler=null,this.cropendHandler=null,this.cropperReadyHandler=null,this.prevCropboxData=null)};getObjectUrl=()=>this.objectUrl;install(){this.resetEditorState(null);const{target:t}=this.opts;t&&this.mount(t,this)}uninstall(){const{currentImage:t}=this.getPluginState();if(t){const e=this.uppy.getFile(t.id);this.uppy.emit("file-editor:cancel",e)}this.stop(),this.unmount()}render(){const{currentImage:t,angleGranular:e}=this.getPluginState();return t===null||t.isRemote?null:S(ya,{currentImage:t,objectUrl:this.objectUrl??"",initCropper:this.initCropper,save:this.save,opts:this.opts,i18n:this.i18n,angleGranular:e,rotateBy:this.rotateBy,rotateGranular:this.rotateGranular,flipHorizontal:this.flipHorizontal,zoom:this.zoom,setAspectRatio:this.setAspectRatio,reset:this.reset})}}function nr(r){return r.split("/").map(encodeURIComponent).join("/")}function Ra(r){const t=r.match(/\?\d+$/),e=t?t[0]:"";return(e?r.slice(0,-e.length):r).replace(/#/g,"%23").replace(/\?/g,"%3F")+e}async function Oa(r={}){const t={};r.path&&(t.path=r.path),r.search&&(t.search=r.search),r.type&&(t.type=r.type),r.page&&(t.page=String(r.page)),r.per_page&&(t.per_page=String(r.per_page));const e=await j.getFullBody("/media",t);return{items:e.data,folders:e.meta.folders,path:e.meta.path,pagination:e.meta.pagination,search:e.meta.search}}async function Fa(r){return j.delete(`/media/${nr(r)}`)}async function Ca(r){return j.post("/media/folders",{path:r})}async function Aa(r){return j.delete(`/media/folders/${nr(r)}`)}async function Na(r,t){return j.post("/media/rename",{from:r,to:t})}async function Da(r,t){return j.post("/media/folders/rename",{from:r,to:t})}const or=Symbol("PAGE_MEDIA_ONLY");async function Pa(r){const t={folder:r.folder};r.scope&&(t.scope=r.scope),r.accept&&r.accept.length>0&&(t.accept=r.accept.join(",")),t.preview_images="1";try{const e=await j.getFullBody("/blueprint-files",t);return{items:e.data,folder:e.meta.folder,scope:e.meta.scope,exists:e.meta.exists}}catch(e){if(e instanceof dr&&e.status===422)return or;throw e}}async function Ua(r){return j.get(`/${r}/media`)}async function ka(r,t){return j.delete(`/${r}/media/${encodeURIComponent(t)}`)}function lr(r){const t=r.startsWith("/")?r.slice(1):r;return t===""?null:t}async function Ia(r){const t=lr(r);return t===null?[]:j.get(`/pages/${t}/media`)}async function za(r,t){const e=lr(r);if(e===null)throw new Error("Cannot delete page media: route is not resolved yet.");return j.delete(`/pages/${e}/media/${encodeURIComponent(t)}`)}async function La(r){await j.delete("/blueprint-upload",{path:r})}const $a=Object.freeze(Object.defineProperty({__proto__:null,BLUEPRINT_FILES_PAGE_MEDIA_ONLY:or,createFolder:Ca,deleteBlueprintFile:La,deleteFolder:Aa,deleteObjectMedia:ka,deletePageMedia:za,deleteSiteMedia:Fa,encodeMediaFileUrl:Ra,getBlueprintFiles:Pa,getObjectMedia:Ua,getPageMedia:Ia,getSiteMedia:Oa,renameFolder:Da,renameSiteMedia:Na},Symbol.toStringTag,{value:"Module"}));export{or as B,Ha as I,Bi as U,Ba as X,Na as a,Fa as b,Ca as c,Aa as d,Oa as e,Ra as f,Ua as g,Ia as h,ka as i,za as j,Pa as k,$a as m,Da as r};
|