@wangeditor-next/editor 5.6.56 → 5.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +48 -0
- package/dist/basic-modules/src/modules/color/render-style.d.ts +3 -1
- package/dist/basic-modules/src/modules/color/style-to-html.d.ts +3 -1
- package/dist/basic-modules/src/modules/font-size-family/render-style.d.ts +3 -1
- package/dist/basic-modules/src/modules/font-size-family/style-to-html.d.ts +3 -1
- package/dist/basic-modules/src/modules/image/elem-to-html.d.ts +2 -1
- package/dist/basic-modules/src/modules/indent/render-style.d.ts +3 -1
- package/dist/basic-modules/src/modules/indent/style-to-html.d.ts +2 -1
- package/dist/basic-modules/src/modules/justify/render-style.d.ts +3 -1
- package/dist/basic-modules/src/modules/justify/style-to-html.d.ts +2 -1
- package/dist/basic-modules/src/modules/line-height/render-style.d.ts +3 -1
- package/dist/basic-modules/src/modules/line-height/style-to-html.d.ts +2 -1
- package/dist/basic-modules/src/utils/style-class.d.ts +14 -0
- package/dist/basic-modules/src/utils/vdom.d.ts +14 -0
- package/dist/core/src/config/interface.d.ts +33 -1
- package/dist/core/src/config/style-mode.d.ts +8 -0
- package/dist/core/src/editor/dom-editor.d.ts +9 -0
- package/dist/core/src/index.d.ts +13 -2
- package/dist/core/src/render/element/renderStyle.d.ts +3 -1
- package/dist/core/src/render/index.d.ts +2 -2
- package/dist/core/src/render/text/renderStyle.d.ts +3 -1
- package/dist/core/src/to-html/index.d.ts +2 -2
- package/dist/core/src/upload/createUploader.d.ts +7 -3
- package/dist/core/src/upload/createUppyUploader.d.ts +7 -0
- package/dist/core/src/upload/index.d.ts +4 -3
- package/dist/core/src/upload/interface.d.ts +37 -9
- package/dist/core/src/upload.d.ts +5 -0
- package/dist/core.js +13 -0
- package/dist/core.js.map +1 -0
- package/dist/core.mjs +13 -0
- package/dist/core.mjs.map +1 -0
- package/dist/css/style.css +4 -4
- package/dist/editor/src/core.d.ts +54 -0
- package/dist/editor/src/index.d.ts +3 -2
- package/dist/editor/src/upload.d.ts +6 -0
- package/dist/index.js +18 -18
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3 -3
- package/dist/index.mjs.map +1 -1
- package/dist/list-module/src/module/elem-to-html.d.ts +2 -1
- package/dist/list-module/src/module/style-class.d.ts +6 -0
- package/dist/table-module/src/module/elem-to-html.d.ts +3 -2
- package/dist/table-module/src/module/style-to-html.d.ts +2 -1
- package/dist/upload.js +13 -0
- package/dist/upload.js.map +1 -0
- package/dist/upload.mjs +13 -0
- package/dist/upload.mjs.map +1 -0
- package/dist/video-module/src/module/elem-to-html.d.ts +2 -1
- package/dist/video-module/src/utils/dom.d.ts +1 -1
- package/package.json +18 -8
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
* @description to html
|
|
3
3
|
* @author wangfupeng
|
|
4
4
|
*/
|
|
5
|
+
import { IDomEditor } from '@wangeditor-next/core';
|
|
5
6
|
import { Element } from 'slate';
|
|
6
|
-
declare function elemToHtml(elem: Element, childrenHtml: string): {
|
|
7
|
+
declare function elemToHtml(elem: Element, childrenHtml: string, editor?: IDomEditor): {
|
|
7
8
|
html: string;
|
|
8
9
|
prefix?: string;
|
|
9
10
|
suffix?: string;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description list style class utils
|
|
3
|
+
*/
|
|
4
|
+
import { IDomEditor } from '@wangeditor-next/core';
|
|
5
|
+
export declare function genListColorClassName(color: string): string;
|
|
6
|
+
export declare function resolveListColorAction(editor: IDomEditor | undefined, color: string): 'class' | 'preserve-data' | 'inline';
|
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
* @description to html
|
|
3
3
|
* @author wangfupeng
|
|
4
4
|
*/
|
|
5
|
+
import { IDomEditor } from '@wangeditor-next/core';
|
|
5
6
|
import { Element } from 'slate';
|
|
6
|
-
declare function tableToHtml(elemNode: Element, childrenHtml: string): string;
|
|
7
|
-
declare function tableRowToHtml(elem: Element, childrenHtml: string): string;
|
|
7
|
+
declare function tableToHtml(elemNode: Element, childrenHtml: string, editor?: IDomEditor): string;
|
|
8
|
+
declare function tableRowToHtml(elem: Element, childrenHtml: string, editor?: IDomEditor): string;
|
|
8
9
|
declare function tableCellToHtml(cellNode: Element, childrenHtml: string): string;
|
|
9
10
|
export declare const tableToHtmlConf: {
|
|
10
11
|
type: string;
|
package/dist/upload.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).wangEditorUpload={})}(this,function(e){"use strict";var t=function(){return t=Object.assign||function(e){for(var t,r=1,i=arguments.length;r<i;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},t.apply(this,arguments)};"function"==typeof SuppressedError&&SuppressedError;var r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function i(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function n(e){if(Object.prototype.hasOwnProperty.call(e,"__esModule"))return e;var t=e.default;if("function"==typeof t){var r=function e(){var r=!1;try{r=this instanceof e}catch{}return r?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach(function(t){var i=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,i.get?i:{enumerable:!0,get:function(){return e[t]}})}),r}var o,s,a,l,u,p={exports:{}},d={};function c(){if(a)return d;a=1,Object.defineProperty(d,"__esModule",{value:!0}),d.justErrorsLogger=d.debugLogger=void 0;const e=function(){if(s)return o;function e(e){return e<10?`0${e}`:e.toString()}return s=1,o=function(){const t=new Date;return`${e(t.getHours())}:${e(t.getMinutes())}:${e(t.getSeconds())}`}}(),t={debug:()=>{},warn:()=>{},error:function(){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];return console.error(`[Uppy] [${e()}]`,...r)}};d.justErrorsLogger=t;const r={debug:function(){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];return console.debug(`[Uppy] [${e()}]`,...r)},warn:function(){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];return console.warn(`[Uppy] [${e()}]`,...r)},error:function(){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];return console.error(`[Uppy] [${e()}]`,...r)}};return d.debugLogger=r,d}function h(){if(u)return l;u=1;return l={nanoid:(e=21)=>{let t="",r=0|e;for(;r--;)t+="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[64*Math.random()|0];return t},customAlphabet:(e,t=21)=>(r=t)=>{let i="",n=0|r;for(;n--;)i+=e[Math.random()*e.length|0];return i}},l}var f,g,m,y,v,_,b,w,P,S,O,E,x,U,j,F,T,k,$,A,R,C,N,I,M,L,z,D,q,H,B,W,X,G={};function K(){return g?f:(g=1,f=function(e){if("number"!=typeof e||isNaN(e))throw new TypeError("Expected a number, got "+typeof e);var t=e<0,r=["B","KB","MB","GB","TB","PB","EB","ZB","YB"];if(t&&(e=-e),e<1)return(t?"-":"")+e+" B";var i=Math.min(Math.floor(Math.log(e)/Math.log(1024)),r.length-1);e=Number(e/Math.pow(1024,i));var n=r[i];return e>=10||e%1==0?(t?"-":"")+e.toFixed(0)+" "+n:(t?"-":"")+e.toFixed(1)+" "+n})}function V(){if(y)return m;function e(e,t){this.text=e=e||"",this.hasWild=~e.indexOf("*"),this.separator=t,this.parts=e.split(t)}return y=1,e.prototype.match=function(e){var t,r,i=!0,n=this.parts,o=n.length;if("string"==typeof e||e instanceof String)if(this.hasWild||this.text==e){for(r=(e||"").split(this.separator),t=0;i&&t<o;t++)"*"!==n[t]&&(i=t<r.length&&n[t]===r[t]);i=i&&r}else i=!1;else if("function"==typeof e.splice)for(i=[],t=e.length;t--;)this.match(e[t])&&(i[i.length]=e[t]);else if("object"==typeof e)for(var s in i={},e)this.match(s)&&(i[s]=e[s]);return i},m=function(t,r,i){var n=new e(t,i||/[\/\.]/);return void 0!==r?n.match(r):n}}function Y(){if(b)return G;b=1,Object.defineProperty(G,"__esModule",{value:!0}),G.defaultOptions=G.RestrictionError=G.Restricter=void 0;const e=K(),t=function(){if(_)return v;_=1;var e=V(),t=/[\/\+\.]/;return v=function(r,i){function n(i){var n=e(i,r,t);return n&&n.length>=2}return i?n(i.split(";")[0]):n}}();G.defaultOptions={maxFileSize:null,minFileSize:null,maxTotalFileSize:null,maxNumberOfFiles:null,minNumberOfFiles:null,allowedFileTypes:null,requiredMetaFields:[]};class r extends Error{constructor(){super(...arguments),this.isRestriction=!0}}G.RestrictionError=r,"undefined"==typeof AggregateError&&(globalThis.AggregateError=class extends Error{constructor(e,t){super(t),this.errors=e}});return G.Restricter=class{constructor(e,t){this.i18n=t,this.getOpts=()=>{const t=e();if(null!=t.restrictions.allowedFileTypes&&!Array.isArray(t.restrictions.allowedFileTypes))throw new TypeError("`restrictions.allowedFileTypes` must be an array");return t}}validate(i,n){const{maxFileSize:o,minFileSize:s,maxTotalFileSize:a,maxNumberOfFiles:l,allowedFileTypes:u}=this.getOpts().restrictions;if(l){const e=n.filter(e=>!e.isGhost);if(e.length+1>l)throw new r(`${this.i18n("youCanOnlyUploadX",{smart_count:l})}`)}if(u){if(!u.some(e=>e.includes("/")?!!i.type&&t(i.type.replace(/;.*?$/,""),e):!("."!==e[0]||!i.extension)&&i.extension.toLowerCase()===e.slice(1).toLowerCase())){const e=u.join(", ");throw new r(this.i18n("youCanOnlyUploadFileTypes",{types:e}))}}if(a&&null!=i.size){const t=n.reduce((e,t)=>e+t.size,i.size);if(t>a)throw new r(this.i18n("exceedsSize",{size:e(a),file:i.name}))}if(o&&null!=i.size&&i.size>o)throw new r(this.i18n("exceedsSize",{size:e(o),file:i.name}));if(s&&null!=i.size&&i.size<s)throw new r(this.i18n("inferiorSize",{size:e(s)}))}validateMinNumberOfFiles(e){const{minNumberOfFiles:t}=this.getOpts().restrictions;if(Object.keys(e).length<t)throw new r(this.i18n("youHaveToAtLeastSelectX",{smart_count:t}))}getMissingRequiredMetaFields(e){const t=new r(this.i18n("missingRequiredMetaFieldOnFile",{fileName:e.name})),{requiredMetaFields:i}=this.getOpts().restrictions,n=Object.prototype.hasOwnProperty,o=[];for(const t of i)n.call(e.meta,t)&&""!==e.meta[t]||o.push(t);return{missingFields:o,error:t}}},G}function Q(){if(P)return w;return P=1,w=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}}function J(){if(O)return S;function e(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw new TypeError("attempted to use private field on non-instance");return e}O=1;var t=0;function r(e){return"__private_"+t+++"_"+e}const i=Q();function n(e,t,r){const i=[];return e.forEach(e=>"string"!=typeof e?i.push(e):t[Symbol.split](e).forEach((e,t,n)=>{""!==e&&i.push(e),t<n.length-1&&i.push(r)})),i}
|
|
2
|
+
/**
|
|
3
|
+
* Takes a string with placeholder variables like `%{smart_count} file selected`
|
|
4
|
+
* and replaces it with values from options `{smart_count: 5}`
|
|
5
|
+
*
|
|
6
|
+
* @license https://github.com/airbnb/polyglot.js/blob/master/LICENSE
|
|
7
|
+
* taken from https://github.com/airbnb/polyglot.js/blob/master/lib/polyglot.js#L299
|
|
8
|
+
*
|
|
9
|
+
* @param {string} phrase that needs interpolation, with placeholders
|
|
10
|
+
* @param {object} options with values that will be used to replace placeholders
|
|
11
|
+
* @returns {any[]} interpolated
|
|
12
|
+
*/function o(e,t){const r=/\$/g;let i=[e];if(null==t)return i;for(const e of Object.keys(t))if("_"!==e){let o=t[e];"string"==typeof o&&(o=r[Symbol.replace](o,"$$$$")),i=n(i,new RegExp(`%\\{${e}\\}`,"g"),o)}return i}var s=r("apply");function a(e){if(null==e||!e.strings)return;const t=this.locale;this.locale={...t,strings:{...t.strings,...e.strings}},this.locale.pluralize=e.pluralize||t.pluralize}return S=class{constructor(t){Object.defineProperty(this,s,{value:a}),this.locale={strings:{},pluralize:e=>1===e?0:1},Array.isArray(t)?t.forEach(e(this,s)[s],this):e(this,s)[s](t)}translate(e,t){return this.translateArray(e,t).join("")}translateArray(e,t){if(!i(this.locale.strings,e))throw new Error(`missing string: ${e}`);const r=this.locale.strings[e];if("object"==typeof r){if(t&&void 0!==t.smart_count){return o(r[this.locale.pluralize(t.smart_count)],t)}throw new Error("Attempted to use a string with plural forms, but no value was given for %{smart_count}")}return o(r,t)}},S}function Z(){return x||(x=1,E=function(){var e={},t=e._fns={};return e.emit=function(e,r,i,n,o,s,a){var l=function(e){var r=t[e]?t[e]:[],i=e.indexOf(":"),n=-1===i?[e]:[e.substring(0,i),e.substring(i+1)],o=Object.keys(t),s=0,a=o.length;for(;s<a;s++){var l=o[s];if("*"===l&&(r=r.concat(t[l])),2===n.length&&n[0]===l){r=r.concat(t[l]);break}}return r}(e);l.length&&function(e,t,r){var i=0,n=t.length;for(;i<n&&t[i];i++)t[i].event=e,t[i].apply(t[i],r)}(e,l,[r,i,n,o,s,a])},e.on=function(e,r){t[e]||(t[e]=[]),t[e].push(r)},e.once=function(t,r){this.on(t,function i(){r.apply(this,arguments),e.off(t,i)})},e.off=function(e,t){var r=[];if(e&&t)for(var i=this._fns[e],n=0,o=i?i.length:0;n<o;n++)i[n]!==t&&r.push(i[n]);r.length?this._fns[e]=r:delete this._fns[e]},e}),E}function ee(){if(j)return U;j=1;var e="Expected a function",t=/^\s+|\s+$/g,i=/^[-+]0x[0-9a-f]+$/i,n=/^0b[01]+$/i,o=/^0o[0-7]+$/i,s=parseInt,a="object"==typeof r&&r&&r.Object===Object&&r,l="object"==typeof self&&self&&self.Object===Object&&self,u=a||l||Function("return this")(),p=Object.prototype.toString,d=Math.max,c=Math.min,h=function(){return u.Date.now()};function f(t,r,i){var n,o,s,a,l,u,p=0,f=!1,y=!1,v=!0;if("function"!=typeof t)throw new TypeError(e);function _(e){var r=n,i=o;return n=o=void 0,p=e,a=t.apply(i,r)}function b(e){var t=e-u;return void 0===u||t>=r||t<0||y&&e-p>=s}function w(){var e=h();if(b(e))return P(e);l=setTimeout(w,function(e){var t=r-(e-u);return y?c(t,s-(e-p)):t}(e))}function P(e){return l=void 0,v&&n?_(e):(n=o=void 0,a)}function S(){var e=h(),t=b(e);if(n=arguments,o=this,u=e,t){if(void 0===l)return function(e){return p=e,l=setTimeout(w,r),f?_(e):a}(u);if(y)return l=setTimeout(w,r),_(u)}return void 0===l&&(l=setTimeout(w,r)),a}return r=m(r)||0,g(i)&&(f=!!i.leading,s=(y="maxWait"in i)?d(m(i.maxWait)||0,r):s,v="trailing"in i?!!i.trailing:v),S.cancel=function(){void 0!==l&&clearTimeout(l),p=0,n=u=o=l=void 0},S.flush=function(){return void 0===l?a:P(h())},S}function g(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function m(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Symbol]"==p.call(e)}(e))return NaN;if(g(e)){var r="function"==typeof e.valueOf?e.valueOf():e;e=g(r)?r+"":r}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(t,"");var a=n.test(e);return a||o.test(e)?s(e.slice(2),a?2:8):i.test(e)?NaN:+e}return U=function(t,r,i){var n=!0,o=!0;if("function"!=typeof t)throw new TypeError(e);return g(i)&&(n="leading"in i?!!i.leading:n,o="trailing"in i?!!i.trailing:o),f(t,r,{leading:n,maxWait:r,trailing:o})}}function te(){if(T)return F;T=1;var e=0;function t(t){return"__private_"+e+++"_"+t}var r=t("publish");class i{constructor(){Object.defineProperty(this,r,{value:n}),this.state={},this.callbacks=[]}getState(){return this.state}setState(e){const t={...this.state},i={...this.state,...e};this.state=i,function(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw new TypeError("attempted to use private field on non-instance");return e}(this,r)[r](t,i,e)}subscribe(e){return this.callbacks.push(e),()=>{this.callbacks.splice(this.callbacks.indexOf(e),1)}}}function n(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];this.callbacks.forEach(e=>{e(...t)})}return i.VERSION="2.1.1",F=function(){return new i}}function re(){if($)return k;return $=1,k=function(e){const t=e.lastIndexOf(".");return-1===t||t===e.length-1?{name:e,extension:void 0}:{name:e.slice(0,t),extension:e.slice(t+1)}}}function ie(){return R?A:(R=1,A={md:"text/markdown",markdown:"text/markdown",mp4:"video/mp4",mp3:"audio/mp3",svg:"image/svg+xml",jpg:"image/jpeg",png:"image/png",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",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 ne(){if(X)return W;X=1;var e=h(),t=c(),r=Y();let i,n;function o(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw new TypeError("attempted to use private field on non-instance");return e}var s=0;function a(e){return"__private_"+s+++"_"+e}const l=J(),u=Z(),p=ee(),d=te(),f=function(){if(N)return C;N=1;const e=re(),t=ie();return C=function(r){var i;if(r.type)return r.type;const n=r.name?null==(i=e(r.name).extension)?void 0:i.toLowerCase():null;return n&&n in t?t[n]:"application/octet-stream"}}(),g=re(),m=function(){if(M)return I;function e(e){let t="";return e.replace(/[^A-Z0-9]/gi,e=>(t+=`-${function(e){return e.charCodeAt(0).toString(32)}(e)}`,"/"))+t}return M=1,I=function(t){let r="uppy";return"string"==typeof t.name&&(r+=`-${e(t.name.toLowerCase())}`),void 0!==t.type&&(r+=`-${t.type}`),t.meta&&"string"==typeof t.meta.relativePath&&(r+=`-${e(t.meta.relativePath.toLowerCase())}`),void 0!==t.data.size&&(r+=`-${t.data.size}`),void 0!==t.data.lastModified&&(r+=`-${t.data.lastModified}`),r}}(),y=(z||(z=1,L=function(e){if(null==e&&"undefined"!=typeof navigator&&(e=navigator.userAgent),!e)return!0;const t=/Edge\/(\d+\.\d+)/.exec(e);if(!t)return!0;const r=t[1];let[i,n]=r.split(".");return i=parseInt(i,10),n=parseInt(n,10),i<15||15===i&&n<15063||i>18||18===i&&n>=18218}),L),v=q?D:(q=1,D=function(e,t){return t.name?t.name:"image"===e.split("/")[0]?`${e.split("/")[0]}.${e.split("/")[1]}`:"noname"}),_=B?H:(B=1,H={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"},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",selectX:{0:"Select %{smart_count}",1:"Select %{smart_count}"},allFilesFromFolderNamed:"All files from folder %{name}",openFolderNamed:"Open folder %{name}",cancel:"Cancel",logOut:"Log out",filter:"Filter",resetFilter:"Reset filter",loading:"Loading...",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",emptyFolderAdded:"No files were added from empty folder",folderAlreadyAdded:'The folder "%{folder}" was already added',folderAdded:{0:"Added %{smart_count} file from %{folder}",1:"Added %{smart_count} files from %{folder}"}}});var b=a("plugins"),w=a("restricter"),P=a("storeUnsubscribe"),S=a("emitter"),O=a("preProcessors"),E=a("uploaders"),x=a("postProcessors"),U=a("informAndEmit"),j=a("checkRequiredMetaFieldsOnFile"),F=a("checkRequiredMetaFields"),T=a("assertNewUploadAllowed"),k=a("checkAndCreateFileStateObject"),$=a("startIfAutoProceed"),A=a("addListeners"),R=a("updateOnlineStatus"),G=a("createUpload"),K=a("getUpload"),V=a("removeUpload"),Q=a("runUpload");i=Symbol.for("uppy test: getPlugins"),n=Symbol.for("uppy test: createUpload");class ne{constructor(e){Object.defineProperty(this,Q,{value:ge}),Object.defineProperty(this,V,{value:fe}),Object.defineProperty(this,K,{value:he}),Object.defineProperty(this,G,{value:ce}),Object.defineProperty(this,A,{value:de}),Object.defineProperty(this,$,{value:pe}),Object.defineProperty(this,k,{value:ue}),Object.defineProperty(this,T,{value:le}),Object.defineProperty(this,F,{value:ae}),Object.defineProperty(this,j,{value:se}),Object.defineProperty(this,U,{value:oe}),Object.defineProperty(this,b,{writable:!0,value:Object.create(null)}),Object.defineProperty(this,w,{writable:!0,value:void 0}),Object.defineProperty(this,P,{writable:!0,value:void 0}),Object.defineProperty(this,S,{writable:!0,value:u()}),Object.defineProperty(this,O,{writable:!0,value:new Set}),Object.defineProperty(this,E,{writable:!0,value:new Set}),Object.defineProperty(this,x,{writable:!0,value:new Set}),Object.defineProperty(this,R,{writable:!0,value:this.updateOnlineStatus.bind(this)}),this.defaultLocale=_;const i={id:"uppy",autoProceed:!1,allowMultipleUploads:!0,allowMultipleUploadBatches:!0,debug:!1,restrictions:r.defaultOptions,meta:{},onBeforeFileAdded:e=>e,onBeforeUpload:e=>e,store:d(),logger:t.justErrorsLogger,infoTimeout:5e3};this.opts={...i,...e,restrictions:{...i.restrictions,...e&&e.restrictions}},e&&e.logger&&e.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"):e&&e.debug&&(this.opts.logger=t.debugLogger),this.log(`Using Core v${this.constructor.VERSION}`),this.i18nInit(),this.calculateProgress=p(this.calculateProgress.bind(this),500,{leading:!0,trailing:!0}),this.store=this.opts.store,this.setState({plugins:{},files:{},currentUploads:{},allowNewUpload:!0,capabilities:{uploadProgress:y(),individualCancellation:!0,resumableUploads:!1},totalProgress:0,meta:{...this.opts.meta},info:[],recoveredState:null}),o(this,w)[w]=new r.Restricter(()=>this.opts,this.i18n),o(this,P)[P]=this.store.subscribe((e,t,r)=>{this.emit("state-update",e,t,r),this.updateAll(t)}),this.opts.debug&&"undefined"!=typeof window&&(window[this.opts.id]=this),o(this,A)[A]()}emit(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];o(this,S)[S].emit(e,...r)}on(e,t){return o(this,S)[S].on(e,t),this}once(e,t){return o(this,S)[S].once(e,t),this}off(e,t){return o(this,S)[S].off(e,t),this}updateAll(e){this.iteratePlugins(t=>{t.update(e)})}setState(e){this.store.setState(e)}getState(){return this.store.getState()}get state(){return this.getState()}setFileState(e,t){if(!this.getState().files[e])throw new Error(`Can’t set state for ${e} (the file could have been removed)`);this.setState({files:{...this.getState().files,[e]:{...this.getState().files[e],...t}}})}i18nInit(){const e=new l([this.defaultLocale,this.opts.locale]);this.i18n=e.translate.bind(e),this.i18nArray=e.translateArray.bind(e),this.locale=e.locale}setOptions(e){this.opts={...this.opts,...e,restrictions:{...this.opts.restrictions,...e&&e.restrictions}},e.meta&&this.setMeta(e.meta),this.i18nInit(),e.locale&&this.iteratePlugins(e=>{e.setOptions()}),this.setState()}resetProgress(){const e={percentage:0,bytesUploaded:0,uploadComplete:!1,uploadStarted:null},t={...this.getState().files},r={};Object.keys(t).forEach(i=>{const n={...t[i]};n.progress={...n.progress,...e},r[i]=n}),this.setState({files:r,totalProgress:0}),this.emit("reset-progress")}addPreProcessor(e){o(this,O)[O].add(e)}removePreProcessor(e){return o(this,O)[O].delete(e)}addPostProcessor(e){o(this,x)[x].add(e)}removePostProcessor(e){return o(this,x)[x].delete(e)}addUploader(e){o(this,E)[E].add(e)}removeUploader(e){return o(this,E)[E].delete(e)}setMeta(e){const t={...this.getState().meta,...e},r={...this.getState().files};Object.keys(r).forEach(t=>{r[t]={...r[t],meta:{...r[t].meta,...e}}}),this.log("Adding metadata:"),this.log(e),this.setState({meta:t,files:r})}setFileMeta(e,t){const r={...this.getState().files};if(!r[e])return void this.log("Was trying to set metadata for a file that has been removed: ",e);const i={...r[e].meta,...t};r[e]={...r[e],meta:i},this.setState({files:r})}getFile(e){return this.getState().files[e]}getFiles(){const{files:e}=this.getState();return Object.values(e)}getObjectOfFilesPerState(){const{files:e,totalProgress:t,error:r}=this.getState(),i=Object.values(e),n=i.filter(e=>{let{progress:t}=e;return!t.uploadComplete&&t.uploadStarted}),o=i.filter(e=>!e.progress.uploadStarted),s=i.filter(e=>e.progress.uploadStarted||e.progress.preprocess||e.progress.postprocess),a=i.filter(e=>e.progress.uploadStarted),l=i.filter(e=>e.isPaused),u=i.filter(e=>e.progress.uploadComplete),p=i.filter(e=>e.error),d=n.filter(e=>!e.isPaused),c=i.filter(e=>e.progress.preprocess||e.progress.postprocess);return{newFiles:o,startedFiles:s,uploadStartedFiles:a,pausedFiles:l,completeFiles:u,erroredFiles:p,inProgressFiles:n,inProgressNotPausedFiles:d,processingFiles:c,isUploadStarted:a.length>0,isAllComplete:100===t&&u.length===i.length&&0===c.length,isAllErrored:!!r&&p.length===i.length,isAllPaused:0!==n.length&&l.length===n.length,isUploadInProgress:n.length>0,isSomeGhost:i.some(e=>e.isGhost)}}validateRestrictions(e,t){void 0===t&&(t=this.getFiles());try{return o(this,w)[w].validate(e,t),{result:!0}}catch(e){return{result:!1,reason:e.message}}}checkIfFileAlreadyExists(e){const{files:t}=this.getState();return!(!t[e]||t[e].isGhost)}addFile(e){o(this,T)[T](e);const{files:t}=this.getState();let r=o(this,k)[k](t,e);return t[r.id]&&t[r.id].isGhost&&(r={...t[r.id],data:e.data,isGhost:!1},this.log(`Replaced the blob in the restored ghost file: ${r.name}, ${r.id}`)),this.setState({files:{...t,[r.id]:r}}),this.emit("file-added",r),this.emit("files-added",[r]),this.log(`Added file: ${r.name}, ${r.id}, mime type: ${r.type}`),o(this,$)[$](),r.id}addFiles(e){o(this,T)[T]();const t={...this.getState().files},r=[],i=[];for(let n=0;n<e.length;n++)try{let i=o(this,k)[k](t,e[n]);t[i.id]&&t[i.id].isGhost&&(i={...t[i.id],data:e[n].data,isGhost:!1},this.log(`Replaced blob in a ghost file: ${i.name}, ${i.id}`)),t[i.id]=i,r.push(i)}catch(e){e.isRestriction||i.push(e)}if(this.setState({files:t}),r.forEach(e=>{this.emit("file-added",e)}),this.emit("files-added",r),r.length>5?this.log(`Added batch of ${r.length} files`):Object.keys(r).forEach(e=>{this.log(`Added file: ${r[e].name}\n id: ${r[e].id}\n type: ${r[e].type}`)}),r.length>0&&o(this,$)[$](),i.length>0){let e="Multiple errors occurred while adding files:\n";if(i.forEach(t=>{e+=`\n * ${t.message}`}),this.info({message:this.i18n("addBulkFilesFailed",{smart_count:i.length}),details:e},"error",this.opts.infoTimeout),"function"==typeof AggregateError)throw new AggregateError(i,e);{const t=new Error(e);throw t.errors=i,t}}}removeFiles(e,t){const{files:r,currentUploads:i}=this.getState(),n={...r},o={...i},s=Object.create(null);function a(e){return void 0===s[e]}e.forEach(e=>{r[e]&&(s[e]=r[e],delete n[e])}),Object.keys(o).forEach(e=>{const t=i[e].fileIDs.filter(a);if(0===t.length)return void delete o[e];const{capabilities:r}=this.getState();if(t.length!==i[e].fileIDs.length&&!r.individualCancellation)throw new Error("individualCancellation is disabled");o[e]={...i[e],fileIDs:t}});const l={currentUploads:o,files:n};0===Object.keys(n).length&&(l.allowNewUpload=!0,l.error=null,l.recoveredState=null),this.setState(l),this.calculateTotalProgress();const u=Object.keys(s);u.forEach(e=>{this.emit("file-removed",s[e],t)}),u.length>5?this.log(`Removed ${u.length} files`):this.log(`Removed files: ${u.join(", ")}`)}removeFile(e,t){void 0===t&&(t=null),this.removeFiles([e],t)}pauseResume(e){if(!this.getState().capabilities.resumableUploads||this.getFile(e).uploadComplete)return;const t=!(this.getFile(e).isPaused||!1);return this.setFileState(e,{isPaused:t}),this.emit("upload-pause",e,t),t}pauseAll(){const e={...this.getState().files};Object.keys(e).filter(t=>!e[t].progress.uploadComplete&&e[t].progress.uploadStarted).forEach(t=>{const r={...e[t],isPaused:!0};e[t]=r}),this.setState({files:e}),this.emit("pause-all")}resumeAll(){const e={...this.getState().files};Object.keys(e).filter(t=>!e[t].progress.uploadComplete&&e[t].progress.uploadStarted).forEach(t=>{const r={...e[t],isPaused:!1,error:null};e[t]=r}),this.setState({files:e}),this.emit("resume-all")}retryAll(){const e={...this.getState().files},t=Object.keys(e).filter(t=>e[t].error);if(t.forEach(t=>{const r={...e[t],isPaused:!1,error:null};e[t]=r}),this.setState({files:e,error:null}),this.emit("retry-all",t),0===t.length)return Promise.resolve({successful:[],failed:[]});const r=o(this,G)[G](t,{forceAllowNewUpload:!0});return o(this,Q)[Q](r)}cancelAll(e){let{reason:t="user"}=void 0===e?{}:e;if(this.emit("cancel-all",{reason:t}),"user"===t){const{files:e}=this.getState(),t=Object.keys(e);t.length&&this.removeFiles(t,"cancel-all"),this.setState({totalProgress:0,error:null,recoveredState:null})}}retryUpload(e){this.setFileState(e,{error:null,isPaused:!1}),this.emit("upload-retry",e);const t=o(this,G)[G]([e],{forceAllowNewUpload:!0});return o(this,Q)[Q](t)}reset(){this.cancelAll(...arguments)}logout(){this.iteratePlugins(e=>{e.provider&&e.provider.logout&&e.provider.logout()})}calculateProgress(e,t){if(null==e||!this.getFile(e.id))return void this.log(`Not setting progress for a file that has been removed: ${null==e?void 0:e.id}`);const r=Number.isFinite(t.bytesTotal)&&t.bytesTotal>0;this.setFileState(e.id,{progress:{...this.getFile(e.id).progress,bytesUploaded:t.bytesUploaded,bytesTotal:t.bytesTotal,percentage:r?Math.round(t.bytesUploaded/t.bytesTotal*100):0}}),this.calculateTotalProgress()}calculateTotalProgress(){const e=this.getFiles().filter(e=>e.progress.uploadStarted||e.progress.preprocess||e.progress.postprocess);if(0===e.length)return this.emit("progress",0),void this.setState({totalProgress:0});const t=e.filter(e=>null!=e.progress.bytesTotal),r=e.filter(e=>null==e.progress.bytesTotal);if(0===t.length){const t=100*e.length,i=r.reduce((e,t)=>e+t.progress.percentage,0),n=Math.round(i/t*100);return void this.setState({totalProgress:n})}let i=t.reduce((e,t)=>e+t.progress.bytesTotal,0);const n=i/t.length;i+=n*r.length;let o=0;t.forEach(e=>{o+=e.progress.bytesUploaded}),r.forEach(e=>{o+=n*(e.progress.percentage||0)/100});let s=0===i?0:Math.round(o/i*100);s>100&&(s=100),this.setState({totalProgress:s}),this.emit("progress",s)}updateOnlineStatus(){void 0===window.navigator.onLine||window.navigator.onLine?(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)}getID(){return this.opts.id}use(e,t){if("function"!=typeof e){throw new TypeError(`Expected a plugin class, but got ${null===e?"null":typeof e}. Please verify that the plugin was imported and spelled correctly.`)}const r=new e(this,t),i=r.id;if(!i)throw new Error("Your plugin must have an id");if(!r.type)throw new Error("Your plugin must have a type");const n=this.getPlugin(i);if(n){const e=`Already found a plugin named '${n.id}'. Tried to use: '${i}'.\nUppy plugins must have unique \`id\` options. See https://uppy.io/docs/plugins/#id.`;throw new Error(e)}return e.VERSION&&this.log(`Using ${i} v${e.VERSION}`),r.type in o(this,b)[b]?o(this,b)[b][r.type].push(r):o(this,b)[b][r.type]=[r],r.install(),this}getPlugin(e){for(const t of Object.values(o(this,b)[b])){const r=t.find(t=>t.id===e);if(null!=r)return r}}[i](e){return o(this,b)[b][e]}iteratePlugins(e){Object.values(o(this,b)[b]).flat(1).forEach(e)}removePlugin(e){this.log(`Removing plugin ${e.id}`),this.emit("plugin-remove",e),e.uninstall&&e.uninstall();const t=o(this,b)[b][e.type],r=t.findIndex(t=>t.id===e.id);-1!==r&&t.splice(r,1);const i={plugins:{...this.getState().plugins,[e.id]:void 0}};this.setState(i)}close(e){let{reason:t}=void 0===e?{}:e;this.log(`Closing Uppy instance ${this.opts.id}: removing all files and uninstalling plugins`),this.cancelAll({reason:t}),o(this,P)[P](),this.iteratePlugins(e=>{this.removePlugin(e)}),"undefined"!=typeof window&&window.removeEventListener&&(window.removeEventListener("online",o(this,R)[R]),window.removeEventListener("offline",o(this,R)[R]))}hideInfo(){const{info:e}=this.getState();this.setState({info:e.slice(1)}),this.emit("info-hidden")}info(e,t,r){void 0===t&&(t="info"),void 0===r&&(r=3e3);const i="object"==typeof e;this.setState({info:[...this.getState().info,{type:t,message:i?e.message:e,details:i?e.details:null}]}),setTimeout(()=>this.hideInfo(),r),this.emit("info-visible")}log(e,t){const{logger:r}=this.opts;switch(t){case"error":r.error(e);break;case"warning":r.warn(e);break;default:r.debug(e)}}restore(e){return this.log(`Core: attempting to restore upload "${e}"`),this.getState().currentUploads[e]?o(this,Q)[Q](e):(o(this,V)[V](e),Promise.reject(new Error("Nonexistent upload")))}[n](){return o(this,G)[G](...arguments)}addResultData(e,t){if(!o(this,K)[K](e))return void this.log(`Not setting result for an upload that has been removed: ${e}`);const{currentUploads:r}=this.getState(),i={...r[e],result:{...r[e].result,...t}};this.setState({currentUploads:{...r,[e]:i}})}upload(){var e;null!=(e=o(this,b)[b].uploader)&&e.length||this.log("No uploader type plugins are used","warning");let{files:t}=this.getState();const i=this.opts.onBeforeUpload(t);return!1===i?Promise.reject(new Error("Not starting the upload because onBeforeUpload returned false")):(i&&"object"==typeof i&&(t=i,this.setState({files:t})),Promise.resolve().then(()=>o(this,w)[w].validateMinNumberOfFiles(t)).catch(e=>{throw o(this,U)[U](e),e}).then(()=>{if(!o(this,F)[F](t))throw new r.RestrictionError(this.i18n("missingRequiredMetaField"))}).catch(e=>{throw e}).then(()=>{const{currentUploads:e}=this.getState(),r=Object.values(e).flatMap(e=>e.fileIDs),i=[];Object.keys(t).forEach(e=>{const t=this.getFile(e);t.progress.uploadStarted||-1!==r.indexOf(e)||i.push(t.id)});const n=o(this,G)[G](i);return o(this,Q)[Q](n)}).catch(e=>{throw this.emit("error",e),this.log(e,"error"),e}))}}function oe(e,t){const{message:r,details:i=""}=e;e.isRestriction?this.emit("restriction-failed",t,e):this.emit("error",e),this.info({message:r,details:i},"error",this.opts.infoTimeout),this.log(`${r} ${i}`.trim(),"error")}function se(e){const{missingFields:t,error:r}=o(this,w)[w].getMissingRequiredMetaFields(e);return!(t.length>0)||(this.setFileState(e.id,{missingRequiredMetaFields:t}),this.log(r.message),this.emit("restriction-failed",e,r),!1)}function ae(e){let t=!0;for(const r of Object.values(e))o(this,j)[j](r)||(t=!1);return t}function le(e){const{allowNewUpload:t}=this.getState();if(!1===t){const t=new r.RestrictionError(this.i18n("noMoreFilesAllowed"));throw o(this,U)[U](t,e),t}}function ue(e,t){const i=f(t),n=v(i,t),s=g(n).extension,a=Boolean(t.isRemote),l=m({...t,type:i});if(this.checkIfFileAlreadyExists(l)){const e=new r.RestrictionError(this.i18n("noDuplicates",{fileName:n}));throw o(this,U)[U](e,t),e}const u=t.meta||{};u.name=n,u.type=i;const p=Number.isFinite(t.data.size)?t.data.size:null;let d={source:t.source||"",id:l,name:n,extension:s||"",meta:{...this.getState().meta,...u},type:i,data:t.data,progress:{percentage:0,bytesUploaded:0,bytesTotal:p,uploadComplete:!1,uploadStarted:null},size:p,isRemote:a,remote:t.remote||"",preview:t.preview};const c=this.opts.onBeforeFileAdded(d,e);if(!1===c){const e=new r.RestrictionError("Cannot add the file because onBeforeFileAdded returned false.");throw this.emit("restriction-failed",t,e),e}"object"==typeof c&&null!==c&&(d=c);try{const t=Object.keys(e).map(t=>e[t]);o(this,w)[w].validate(d,t)}catch(e){throw o(this,U)[U](e,d),e}return d}function pe(){this.opts.autoProceed&&!this.scheduledAutoProceed&&(this.scheduledAutoProceed=setTimeout(()=>{this.scheduledAutoProceed=null,this.upload().catch(e=>{e.isRestriction||this.log(e.stack||e.message||e)})},4))}function de(){const e=(e,t,r)=>{let i=e.message||"Unknown error";e.details&&(i+=` ${e.details}`),this.setState({error:i}),null!=t&&t.id in this.getState().files&&this.setFileState(t.id,{error:i,response:r})};this.on("error",e),this.on("upload-error",(t,r,i)=>{if(e(r,t,i),"object"==typeof r&&r.message){const e=new Error(r.message);e.details=r.message,r.details&&(e.details+=` ${r.details}`),e.message=this.i18n("failedToUpload",{file:null==t?void 0:t.name}),o(this,U)[U](e)}else o(this,U)[U](r)}),this.on("upload",()=>{this.setState({error:null})}),this.on("upload-started",e=>{null!=e&&this.getFile(e.id)?this.setFileState(e.id,{progress:{uploadStarted:Date.now(),uploadComplete:!1,percentage:0,bytesUploaded:0,bytesTotal:e.size}}):this.log(`Not setting progress for a file that has been removed: ${null==e?void 0:e.id}`)}),this.on("upload-progress",this.calculateProgress),this.on("upload-success",(e,t)=>{if(null==e||!this.getFile(e.id))return void this.log(`Not setting progress for a file that has been removed: ${null==e?void 0:e.id}`);const r=this.getFile(e.id).progress;this.setFileState(e.id,{progress:{...r,postprocess:o(this,x)[x].size>0?{mode:"indeterminate"}:null,uploadComplete:!0,percentage:100,bytesUploaded:r.bytesTotal},response:t,uploadURL:t.uploadURL,isPaused:!1}),null==e.size&&this.setFileState(e.id,{size:t.bytesUploaded||r.bytesTotal}),this.calculateTotalProgress()}),this.on("preprocess-progress",(e,t)=>{null!=e&&this.getFile(e.id)?this.setFileState(e.id,{progress:{...this.getFile(e.id).progress,preprocess:t}}):this.log(`Not setting progress for a file that has been removed: ${null==e?void 0:e.id}`)}),this.on("preprocess-complete",e=>{if(null==e||!this.getFile(e.id))return void this.log(`Not setting progress for a file that has been removed: ${null==e?void 0:e.id}`);const t={...this.getState().files};t[e.id]={...t[e.id],progress:{...t[e.id].progress}},delete t[e.id].progress.preprocess,this.setState({files:t})}),this.on("postprocess-progress",(e,t)=>{null!=e&&this.getFile(e.id)?this.setFileState(e.id,{progress:{...this.getState().files[e.id].progress,postprocess:t}}):this.log(`Not setting progress for a file that has been removed: ${null==e?void 0:e.id}`)}),this.on("postprocess-complete",e=>{if(null==e||!this.getFile(e.id))return void this.log(`Not setting progress for a file that has been removed: ${null==e?void 0:e.id}`);const t={...this.getState().files};t[e.id]={...t[e.id],progress:{...t[e.id].progress}},delete t[e.id].progress.postprocess,this.setState({files:t})}),this.on("restored",()=>{this.calculateTotalProgress()}),this.on("dashboard:file-edit-complete",e=>{e&&o(this,j)[j](e)}),"undefined"!=typeof window&&window.addEventListener&&(window.addEventListener("online",o(this,R)[R]),window.addEventListener("offline",o(this,R)[R]),setTimeout(o(this,R)[R],3e3))}function ce(t,r){void 0===r&&(r={});const{forceAllowNewUpload:i=!1}=r,{allowNewUpload:n,currentUploads:o}=this.getState();if(!n&&!i)throw new Error("Cannot create a new upload: already uploading.");const s=(0,e.nanoid)();return this.emit("upload",{id:s,fileIDs:t}),this.setState({allowNewUpload:!1!==this.opts.allowMultipleUploadBatches&&!1!==this.opts.allowMultipleUploads,currentUploads:{...o,[s]:{fileIDs:t,step:0,result:{}}}}),s}function he(e){const{currentUploads:t}=this.getState();return t[e]}function fe(e){const t={...this.getState().currentUploads};delete t[e],this.setState({currentUploads:t})}async function ge(e){let{currentUploads:t}=this.getState(),r=t[e];const i=r.step||0,n=[...o(this,O)[O],...o(this,E)[E],...o(this,x)[x]];try{for(let o=i;o<n.length&&r;o++){const i=n[o],s={...r,step:o};this.setState({currentUploads:{...t,[e]:s}}),await i(s.fileIDs,e),t=this.getState().currentUploads,r=t[e]}}catch(t){throw o(this,V)[V](e),t}if(r){r.fileIDs.forEach(e=>{const t=this.getFile(e);t&&t.progress.postprocess&&this.emit("postprocess-complete",t)});const i=r.fileIDs.map(e=>this.getFile(e)),n=i.filter(e=>!e.error),o=i.filter(e=>e.error);await this.addResultData(e,{successful:n,failed:o,uploadID:e}),t=this.getState().currentUploads,r=t[e]}let s;return r&&(s=r.result,this.emit("complete",s),o(this,V)[V](e)),null==s&&this.log(`Not setting result for an upload that has been removed: ${e}`),s}return ne.VERSION="2.3.4",W=ne}var oe,se,ae,le,ue,pe,de,ce,he,fe,ge,me,ye,ve={},_e=[],be=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,we=Array.isArray;function Pe(e,t){for(var r in t)e[r]=t[r];return e}function Se(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function Oe(e,t,r){var i,n,o,s={};for(o in t)"key"==o?i=t[o]:"ref"==o?n=t[o]:s[o]=t[o];if(arguments.length>2&&(s.children=arguments.length>3?oe.call(arguments,2):r),"function"==typeof e&&null!=e.defaultProps)for(o in e.defaultProps)void 0===s[o]&&(s[o]=e.defaultProps[o]);return Ee(e,s,i,n,null)}function Ee(e,t,r,i,n){var o={type:e,props:t,key:r,ref:i,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:null==n?++ae:n,__i:-1,__u:0};return null==n&&null!=se.vnode&&se.vnode(o),o}function xe(e){return e.children}function Ue(e,t){this.props=e,this.context=t}function je(e,t){if(null==t)return e.__?je(e.__,e.__i+1):null;for(var r;t<e.__k.length;t++)if(null!=(r=e.__k[t])&&null!=r.__e)return r.__e;return"function"==typeof e.type?je(e):null}function Fe(e){var t,r;if(null!=(e=e.__)&&null!=e.__c){for(e.__e=e.__c.base=null,t=0;t<e.__k.length;t++)if(null!=(r=e.__k[t])&&null!=r.__e){e.__e=e.__c.base=r.__e;break}return Fe(e)}}function Te(e){(!e.__d&&(e.__d=!0)&&ue.push(e)&&!ke.__r++||pe!=se.debounceRendering)&&((pe=se.debounceRendering)||de)(ke)}function ke(){for(var e,t,r,i,n,o,s,a=1;ue.length;)ue.length>a&&ue.sort(ce),e=ue.shift(),a=ue.length,e.__d&&(r=void 0,i=void 0,n=(i=(t=e).__v).__e,o=[],s=[],t.__P&&((r=Pe({},i)).__v=i.__v+1,se.vnode&&se.vnode(r),Le(t.__P,r,i,t.__n,t.__P.namespaceURI,32&i.__u?[n]:null,o,null==n?je(i):n,!!(32&i.__u),s),r.__v=i.__v,r.__.__k[r.__i]=r,De(o,r,s),i.__e=i.__=null,r.__e!=n&&Fe(r)));ke.__r=0}function $e(e,t,r,i,n,o,s,a,l,u,p){var d,c,h,f,g,m,y,v=i&&i.__k||_e,_=t.length;for(l=Ae(r,t,v,l,_),d=0;d<_;d++)null!=(h=r.__k[d])&&(c=-1==h.__i?ve:v[h.__i]||ve,h.__i=d,m=Le(e,h,c,n,o,s,a,l,u,p),f=h.__e,h.ref&&c.ref!=h.ref&&(c.ref&&Be(c.ref,null,h),p.push(h.ref,h.__c||f,h)),null==g&&null!=f&&(g=f),(y=!!(4&h.__u))||c.__k===h.__k?l=Re(h,l,e,y):"function"==typeof h.type&&void 0!==m?l=m:f&&(l=f.nextSibling),h.__u&=-7);return r.__e=g,l}function Ae(e,t,r,i,n){var o,s,a,l,u,p=r.length,d=p,c=0;for(e.__k=new Array(n),o=0;o<n;o++)null!=(s=t[o])&&"boolean"!=typeof s&&"function"!=typeof s?(l=o+c,(s=e.__k[o]="string"==typeof s||"number"==typeof s||"bigint"==typeof s||s.constructor==String?Ee(null,s,null,null,null):we(s)?Ee(xe,{children:s},null,null,null):null==s.constructor&&s.__b>0?Ee(s.type,s.props,s.key,s.ref?s.ref:null,s.__v):s).__=e,s.__b=e.__b+1,a=null,-1!=(u=s.__i=Ce(s,r,l,d))&&(d--,(a=r[u])&&(a.__u|=2)),null==a||null==a.__v?(-1==u&&(n>p?c--:n<p&&c++),"function"!=typeof s.type&&(s.__u|=4)):u!=l&&(u==l-1?c--:u==l+1?c++:(u>l?c--:c++,s.__u|=4))):e.__k[o]=null;if(d)for(o=0;o<p;o++)null!=(a=r[o])&&!(2&a.__u)&&(a.__e==i&&(i=je(a)),We(a,a));return i}function Re(e,t,r,i){var n,o;if("function"==typeof e.type){for(n=e.__k,o=0;n&&o<n.length;o++)n[o]&&(n[o].__=e,t=Re(n[o],t,r,i));return t}e.__e!=t&&(i&&(t&&e.type&&!t.parentNode&&(t=je(e)),r.insertBefore(e.__e,t||null)),t=e.__e);do{t=t&&t.nextSibling}while(null!=t&&8==t.nodeType);return t}function Ce(e,t,r,i){var n,o,s,a=e.key,l=e.type,u=t[r],p=null!=u&&!(2&u.__u);if(null===u&&null==e.key||p&&a==u.key&&l==u.type)return r;if(i>(p?1:0))for(n=r-1,o=r+1;n>=0||o<t.length;)if(null!=(u=t[s=n>=0?n--:o++])&&!(2&u.__u)&&a==u.key&&l==u.type)return s;return-1}function Ne(e,t,r){"-"==t[0]?e.setProperty(t,null==r?"":r):e[t]=null==r?"":"number"!=typeof r||be.test(t)?r:r+"px"}function Ie(e,t,r,i,n){var o,s;e:if("style"==t)if("string"==typeof r)e.style.cssText=r;else{if("string"==typeof i&&(e.style.cssText=i=""),i)for(t in i)r&&t in r||Ne(e.style,t,"");if(r)for(t in r)i&&r[t]==i[t]||Ne(e.style,t,r[t])}else if("o"==t[0]&&"n"==t[1])o=t!=(t=t.replace(he,"$1")),s=t.toLowerCase(),t=s in e||"onFocusOut"==t||"onFocusIn"==t?s.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+o]=r,r?i?r.u=i.u:(r.u=fe,e.addEventListener(t,o?me:ge,o)):e.removeEventListener(t,o?me:ge,o);else{if("http://www.w3.org/2000/svg"==n)t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("width"!=t&&"height"!=t&&"href"!=t&&"list"!=t&&"form"!=t&&"tabIndex"!=t&&"download"!=t&&"rowSpan"!=t&&"colSpan"!=t&&"role"!=t&&"popover"!=t&&t in e)try{e[t]=null==r?"":r;break e}catch(e){}"function"==typeof r||(null==r||!1===r&&"-"!=t[4]?e.removeAttribute(t):e.setAttribute(t,"popover"==t&&1==r?"":r))}}function Me(e){return function(t){if(this.l){var r=this.l[t.type+e];if(null==t.t)t.t=fe++;else if(t.t<r.u)return;return r(se.event?se.event(t):t)}}}function Le(e,t,r,i,n,o,s,a,l,u){var p,d,c,h,f,g,m,y,v,_,b,w,P,S,O,E,x,U=t.type;if(null!=t.constructor)return null;128&r.__u&&(l=!!(32&r.__u),o=[a=t.__e=r.__e]),(p=se.__b)&&p(t);e:if("function"==typeof U)try{if(y=t.props,v="prototype"in U&&U.prototype.render,_=(p=U.contextType)&&i[p.__c],b=p?_?_.props.value:p.__:i,r.__c?m=(d=t.__c=r.__c).__=d.__E:(v?t.__c=d=new U(y,b):(t.__c=d=new Ue(y,b),d.constructor=U,d.render=Xe),_&&_.sub(d),d.props=y,d.state||(d.state={}),d.context=b,d.__n=i,c=d.__d=!0,d.__h=[],d._sb=[]),v&&null==d.__s&&(d.__s=d.state),v&&null!=U.getDerivedStateFromProps&&(d.__s==d.state&&(d.__s=Pe({},d.__s)),Pe(d.__s,U.getDerivedStateFromProps(y,d.__s))),h=d.props,f=d.state,d.__v=t,c)v&&null==U.getDerivedStateFromProps&&null!=d.componentWillMount&&d.componentWillMount(),v&&null!=d.componentDidMount&&d.__h.push(d.componentDidMount);else{if(v&&null==U.getDerivedStateFromProps&&y!==h&&null!=d.componentWillReceiveProps&&d.componentWillReceiveProps(y,b),!d.__e&&null!=d.shouldComponentUpdate&&!1===d.shouldComponentUpdate(y,d.__s,b)||t.__v==r.__v){for(t.__v!=r.__v&&(d.props=y,d.state=d.__s,d.__d=!1),t.__e=r.__e,t.__k=r.__k,t.__k.some(function(e){e&&(e.__=t)}),w=0;w<d._sb.length;w++)d.__h.push(d._sb[w]);d._sb=[],d.__h.length&&s.push(d);break e}null!=d.componentWillUpdate&&d.componentWillUpdate(y,d.__s,b),v&&null!=d.componentDidUpdate&&d.__h.push(function(){d.componentDidUpdate(h,f,g)})}if(d.context=b,d.props=y,d.__P=e,d.__e=!1,P=se.__r,S=0,v){for(d.state=d.__s,d.__d=!1,P&&P(t),p=d.render(d.props,d.state,d.context),O=0;O<d._sb.length;O++)d.__h.push(d._sb[O]);d._sb=[]}else do{d.__d=!1,P&&P(t),p=d.render(d.props,d.state,d.context),d.state=d.__s}while(d.__d&&++S<25);d.state=d.__s,null!=d.getChildContext&&(i=Pe(Pe({},i),d.getChildContext())),v&&!c&&null!=d.getSnapshotBeforeUpdate&&(g=d.getSnapshotBeforeUpdate(h,f)),E=p,null!=p&&p.type===xe&&null==p.key&&(E=qe(p.props.children)),a=$e(e,we(E)?E:[E],t,r,i,n,o,s,a,l,u),d.base=t.__e,t.__u&=-161,d.__h.length&&s.push(d),m&&(d.__E=d.__=null)}catch(e){if(t.__v=null,l||null!=o)if(e.then){for(t.__u|=l?160:128;a&&8==a.nodeType&&a.nextSibling;)a=a.nextSibling;o[o.indexOf(a)]=null,t.__e=a}else{for(x=o.length;x--;)Se(o[x]);ze(t)}else t.__e=r.__e,t.__k=r.__k,e.then||ze(t);se.__e(e,t,r)}else null==o&&t.__v==r.__v?(t.__k=r.__k,t.__e=r.__e):a=t.__e=He(r.__e,t,r,i,n,o,s,l,u);return(p=se.diffed)&&p(t),128&t.__u?void 0:a}function ze(e){e&&e.__c&&(e.__c.__e=!0),e&&e.__k&&e.__k.forEach(ze)}function De(e,t,r){for(var i=0;i<r.length;i++)Be(r[i],r[++i],r[++i]);se.__c&&se.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){se.__e(e,t.__v)}})}function qe(e){return"object"!=typeof e||null==e||e.__b&&e.__b>0?e:we(e)?e.map(qe):Pe({},e)}function He(e,t,r,i,n,o,s,a,l){var u,p,d,c,h,f,g,m=r.props,y=t.props,v=t.type;if("svg"==v?n="http://www.w3.org/2000/svg":"math"==v?n="http://www.w3.org/1998/Math/MathML":n||(n="http://www.w3.org/1999/xhtml"),null!=o)for(u=0;u<o.length;u++)if((h=o[u])&&"setAttribute"in h==!!v&&(v?h.localName==v:3==h.nodeType)){e=h,o[u]=null;break}if(null==e){if(null==v)return document.createTextNode(y);e=document.createElementNS(n,v,y.is&&y),a&&(se.__m&&se.__m(t,o),a=!1),o=null}if(null==v)m===y||a&&e.data==y||(e.data=y);else{if(o=o&&oe.call(e.childNodes),m=r.props||ve,!a&&null!=o)for(m={},u=0;u<e.attributes.length;u++)m[(h=e.attributes[u]).name]=h.value;for(u in m)if(h=m[u],"children"==u);else if("dangerouslySetInnerHTML"==u)d=h;else if(!(u in y)){if("value"==u&&"defaultValue"in y||"checked"==u&&"defaultChecked"in y)continue;Ie(e,u,null,h,n)}for(u in y)h=y[u],"children"==u?c=h:"dangerouslySetInnerHTML"==u?p=h:"value"==u?f=h:"checked"==u?g=h:a&&"function"!=typeof h||m[u]===h||Ie(e,u,h,m[u],n);if(p)a||d&&(p.__html==d.__html||p.__html==e.innerHTML)||(e.innerHTML=p.__html),t.__k=[];else if(d&&(e.innerHTML=""),$e("template"==t.type?e.content:e,we(c)?c:[c],t,r,i,"foreignObject"==v?"http://www.w3.org/1999/xhtml":n,o,s,o?o[0]:r.__k&&je(r,0),a,l),null!=o)for(u=o.length;u--;)Se(o[u]);a||(u="value","progress"==v&&null==f?e.removeAttribute("value"):null!=f&&(f!==e[u]||"progress"==v&&!f||"option"==v&&f!=m[u])&&Ie(e,u,f,m[u],n),u="checked",null!=g&&g!=e[u]&&Ie(e,u,g,m[u],n))}return e}function Be(e,t,r){try{if("function"==typeof e){var i="function"==typeof e.__u;i&&e.__u(),i&&null==t||(e.__u=e(t))}else e.current=t}catch(e){se.__e(e,r)}}function We(e,t,r){var i,n;if(se.unmount&&se.unmount(e),(i=e.ref)&&(i.current&&i.current!=e.__e||Be(i,null,t)),null!=(i=e.__c)){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(e){se.__e(e,t)}i.base=i.__P=null}if(i=e.__k)for(n=0;n<i.length;n++)i[n]&&We(i[n],t,r||"function"!=typeof e.type);r||Se(e.__e),e.__c=e.__=e.__e=void 0}function Xe(e,t,r){return this.constructor(e,r)}function Ge(e,t,r){var i,n,o,s;t==document&&(t=document.documentElement),se.__&&se.__(e,t),n=(i="function"==typeof r)?null:r&&r.__k||t.__k,o=[],s=[],Le(t,e=(!i&&r||t).__k=Oe(xe,null,[e]),n||ve,ve,t.namespaceURI,!i&&r?[r]:n?null:t.firstChild?oe.call(t.childNodes):null,o,!i&&r?r:n?n.__e:t.firstChild,i,s),De(o,e,s)}oe=_e.slice,se={__e:function(e,t,r,i){for(var n,o,s;t=t.__;)if((n=t.__c)&&!n.__)try{if((o=n.constructor)&&null!=o.getDerivedStateFromError&&(n.setState(o.getDerivedStateFromError(e)),s=n.__d),null!=n.componentDidCatch&&(n.componentDidCatch(e,i||{}),s=n.__d),s)return n.__E=n}catch(t){e=t}throw e}},ae=0,le=function(e){return null!=e&&null==e.constructor},Ue.prototype.setState=function(e,t){var r;r=null!=this.__s&&this.__s!=this.state?this.__s:this.__s=Pe({},this.state),"function"==typeof e&&(e=e(Pe({},r),this.props)),e&&Pe(r,e),null!=e&&this.__v&&(t&&this._sb.push(t),Te(this))},Ue.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),Te(this))},Ue.prototype.render=xe,ue=[],de="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,ce=function(e,t){return e.__v.__b-t.__v.__b},ke.__r=0,he=/(PointerCapture)$|Capture$/i,fe=0,ge=Me(!1),me=Me(!0),ye=0;var Ke,Ve,Ye,Qe,Je,Ze,et,tt,rt,it,nt,ot=Object.freeze({__proto__:null,Component:Ue,Fragment:xe,cloneElement:function(e,t,r){var i,n,o,s,a=Pe({},e.props);for(o in e.type&&e.type.defaultProps&&(s=e.type.defaultProps),t)"key"==o?i=t[o]:"ref"==o?n=t[o]:a[o]=void 0===t[o]&&null!=s?s[o]:t[o];return arguments.length>2&&(a.children=arguments.length>3?oe.call(arguments,2):r),Ee(e.type,a,i||e.key,n||e.ref,null)},createContext:function(e){function t(e){var r,i;return this.getChildContext||(r=new Set,(i={})[t.__c]=this,this.getChildContext=function(){return i},this.componentWillUnmount=function(){r=null},this.shouldComponentUpdate=function(e){this.props.value!=e.value&&r.forEach(function(e){e.__e=!0,Te(e)})},this.sub=function(e){r.add(e);var t=e.componentWillUnmount;e.componentWillUnmount=function(){r&&r.delete(e),t&&t.call(e)}}),e.children}return t.__c="__cC"+ye++,t.__=e,t.Provider=t.__l=(t.Consumer=function(e,t){return e.children(t)}).contextType=t,t},createElement:Oe,createRef:function(){return{current:null}},h:Oe,hydrate:function e(t,r){Ge(t,r,e)},get isValidElement(){return le},get options(){return se},render:Ge,toChildArray:function e(t,r){return r=r||[],null==t||"boolean"==typeof t||(we(t)?t.some(function(t){e(t,r)}):r.push(t)),r}}),st=n(ot);function at(){if(Qe)return Ye;Qe=1;const e=Ve?Ke:(Ve=1,Ke=function(e){return(null==e?void 0:e.nodeType)===Node.ELEMENT_NODE});return Ye=function(t,r){return void 0===r&&(r=document),"string"==typeof t?r.querySelector(t):e(t)?t:null}}function lt(){if(tt)return et;tt=1;const e=J();return et=class{constructor(e,t){void 0===t&&(t={}),this.uppy=e,this.opts=t}getPluginState(){const{plugins:e}=this.uppy.getState();return e[this.id]||{}}setPluginState(e){const{plugins:t}=this.uppy.getState();this.uppy.setState({plugins:{...t,[this.id]:{...t[this.id],...e}}})}setOptions(e){this.opts={...this.opts,...e},this.setPluginState(),this.i18nInit()}i18nInit(){const t=new e([this.defaultLocale,this.uppy.locale,this.opts.locale]);this.i18n=t.translate.bind(t),this.i18nArray=t.translateArray.bind(t),this.setPluginState()}addTarget(){throw new Error("Extend the addTarget method to add your plugin to another plugin's target")}install(){}uninstall(){}render(){throw new Error("Extend the render method to add your plugin to a DOM element")}update(){}afterUpdate(){}}}function ut(){if(it)return rt;it=1;var e=st;function t(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw new TypeError("attempted to use private field on non-instance");return e}var r=0;function i(e){return"__private_"+r+++"_"+e}const n=at(),o=Ze?Je:(Ze=1,Je=function(e){for(var t;e&&!e.dir;)e=e.parentNode;return null==(t=e)?void 0:t.dir}),s=lt();var a=i("updateUI");class l extends s{constructor(){super(...arguments),Object.defineProperty(this,a,{writable:!0,value:void 0})}mount(r,i){const s=i.id,u=n(r);if(u){this.isTargetDOMEl=!0;const i=document.createElement("div");return i.classList.add("uppy-Root"),t(this,a)[a]=function(e){let t=null,r=null;return function(){for(var i=arguments.length,n=new Array(i),o=0;o<i;o++)n[o]=arguments[o];return r=n,t||(t=Promise.resolve().then(()=>(t=null,e(...r)))),t}}(t=>{this.uppy.getPlugin(this.id)&&((0,e.render)(this.render(t),i),this.afterUpdate())}),this.uppy.log(`Installing ${s} to a DOM element '${r}'`),this.opts.replaceTargetContent&&(u.innerHTML=""),(0,e.render)(this.render(this.uppy.getState()),i),this.el=i,u.appendChild(i),i.dir=this.opts.direction||o(i)||"ltr",this.onMount(),this.el}let p;if("object"==typeof r&&r instanceof l)p=r;else if("function"==typeof r){const e=r;this.uppy.iteratePlugins(t=>{t instanceof e&&(p=t)})}if(p)return this.uppy.log(`Installing ${s} to ${p.id}`),this.parent=p,this.el=p.addTarget(i),this.onMount(),this.el;this.uppy.log(`Not installing ${s}`);let d=`Invalid target option given to ${s}.`;throw d+="function"==typeof r?" 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.":"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(d)}update(e){var r,i;null!=this.el&&(null==(r=(i=t(this,a))[a])||r.call(i,e))}unmount(){var e;this.isTargetDOMEl&&(null==(e=this.el)||e.remove());this.onUnmount()}onMount(){}onUnmount(){}}return rt=l}var pt,dt,ct,ht,ft,gt,mt,yt,vt,_t,bt=(nt||(nt=1,function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.Uppy=t.UIPlugin=t.BasePlugin=void 0,Object.defineProperty(t,"debugLogger",{enumerable:!0,get:function(){return r.debugLogger}});var r=c();e.exports=ne();const i=ut();t.UIPlugin=i;const n=lt();t.BasePlugin=n;const o=ne();t.Uppy=o;const s=ut(),a=lt();o.Uppy=o,o.UIPlugin=s,o.BasePlugin=a,o.debugLogger=r.debugLogger}(p,p.exports)),p.exports),wt=i(bt),Pt={};function St(){if(dt)return pt;dt=1;class e extends Error{constructor(e,t){void 0===t&&(t=null),super("This looks like a network error, the endpoint might be blocked by an internet provider or a firewall."),this.cause=e,this.isNetworkError=!0,this.request=t}}return pt=e}function Ot(){if(_t)return vt;let e;function t(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw new TypeError("attempted to use private field on non-instance");return e}_t=1;var r=0;function i(e){return"__private_"+r+++"_"+e}const n=function(){if(ht)return ct;ht=1;const e=St();return ct=function(){return fetch(...arguments).catch(t=>{throw"AbortError"===t.name?t:new e(t)})},ct}(),o=function(){if(gt)return ft;gt=1;const e=Q();class t extends Error{constructor(t,r){void 0===r&&(r={}),super(t),this.cause=r.cause,this.cause&&e(this.cause,"isNetworkError")&&(this.isNetworkError=this.cause.isNetworkError)}}return ft=t}(),s=function(){if(yt)return mt;yt=1;class e extends Error{constructor(){super("Authorization required"),this.name="AuthError",this.isAuthError=!0}}return mt=e}();async function a(e){if(401===e.status)throw new s;const t=e.json();if(e.status<200||e.status>300){let r=`Failed request with status: ${e.status}. ${e.statusText}`;try{const e=await t;r=e.message?`${r} message: ${e.message}`:r,r=e.requestId?`${r} request-Id: ${e.requestId}`:r}finally{throw new Error(r)}}return t}var l=i("companionHeaders"),u=i("getPostResponseFunc"),p=i("getUrl"),d=i("errorHandler");e=Symbol.for("uppy test: getCompanionHeaders");class c{constructor(e,r){Object.defineProperty(this,d,{value:f}),Object.defineProperty(this,p,{value:h}),Object.defineProperty(this,l,{writable:!0,value:void 0}),Object.defineProperty(this,u,{writable:!0,value:e=>t=>e?t:this.onReceiveResponse(t)}),this.uppy=e,this.opts=r,this.onReceiveResponse=this.onReceiveResponse.bind(this),this.allowedHeaders=["accept","content-type","uppy-auth-token"],this.preflightDone=!1,t(this,l)[l]=null==r?void 0:r.companionHeaders}setCompanionHeaders(e){t(this,l)[l]=e}[e](){return t(this,l)[l]}get hostname(){const{companion:e}=this.uppy.getState(),t=this.opts.companionUrl;return(e&&e[t]?e[t]:t).replace(/\/$/,"")}headers(){return Promise.resolve({...c.defaultHeaders,...t(this,l)[l]})}onReceiveResponse(e){const t=this.uppy.getState().companion||{},r=this.opts.companionUrl,{headers:i}=e;return i.has("i-am")&&i.get("i-am")!==t[r]&&this.uppy.setState({companion:{...t,[r]:i.get("i-am")}}),e}preflight(e){return this.preflightDone?Promise.resolve(this.allowedHeaders.slice()):fetch(t(this,p)[p](e),{method:"OPTIONS"}).then(e=>(e.headers.has("access-control-allow-headers")&&(this.allowedHeaders=e.headers.get("access-control-allow-headers").split(",").map(e=>e.trim().toLowerCase())),this.preflightDone=!0,this.allowedHeaders.slice())).catch(e=>(this.uppy.log(`[CompanionClient] unable to make preflight request ${e}`,"warning"),this.preflightDone=!0,this.allowedHeaders.slice()))}preflightAndHeaders(e){return Promise.all([this.preflight(e),this.headers()]).then(e=>{let[t,r]=e;return Object.keys(r).forEach(e=>{t.includes(e.toLowerCase())||(this.uppy.log(`[CompanionClient] excluding disallowed header ${e}`),delete r[e])}),r})}get(e,r){return this.preflightAndHeaders(e).then(r=>n(t(this,p)[p](e),{method:"get",headers:r,credentials:this.opts.companionCookiesRule||"same-origin"})).then(t(this,u)[u](r)).then(a).catch(t(this,d)[d]("get",e))}post(e,r,i){const o="post";return this.preflightAndHeaders(e).then(i=>n(t(this,p)[p](e),{method:o,headers:i,credentials:this.opts.companionCookiesRule||"same-origin",body:JSON.stringify(r)})).then(t(this,u)[u](i)).then(a).catch(t(this,d)[d](o,e))}delete(e,r,i){const o="delete";return this.preflightAndHeaders(e).then(t=>n(`${this.hostname}/${e}`,{method:o,headers:t,credentials:this.opts.companionCookiesRule||"same-origin",body:r?JSON.stringify(r):null})).then(t(this,u)[u](i)).then(a).catch(t(this,d)[d](o,e))}}function h(e){return/^(https?:|)\/\//.test(e)?e:`${this.hostname}/${e}`}function f(e,r){return i=>{var n;return null!=(n=i)&&n.isAuthError||(i=new o(`Could not ${e} ${t(this,p)[p](r)}`,{cause:i})),Promise.reject(i)}}return c.VERSION="2.2.2",c.defaultHeaders={Accept:"application/json","Content-Type":"application/json","Uppy-Versions":`@uppy/companion-client=${c.VERSION}`},vt=c}var Et,xt,Ut,jt,Ft,Tt,kt,$t,At={};function Rt(){if(Et)return At;return Et=1,Object.defineProperty(At,"__esModule",{value:!0}),At.getItem=function(e){return Promise.resolve(localStorage.getItem(e))},At.removeItem=function(e){return new Promise(t=>{localStorage.removeItem(e),t()})},At.setItem=function(e,t){return new Promise(r=>{localStorage.setItem(e,t),r()})},At}function Ct(){if($t)return Pt;$t=1,Object.defineProperty(Pt,"__esModule",{value:!0}),Pt.Socket=Pt.SearchProvider=Pt.RequestClient=Pt.Provider=void 0;const e=Ot();Pt.RequestClient=e;const t=function(){if(Ut)return xt;Ut=1;var e=Rt();const t=Ot();return xt=class extends t{constructor(e,t){super(e,t),this.provider=t.provider,this.id=this.provider,this.name=this.opts.name||this.id.split("-").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" "),this.pluginId=this.opts.pluginId,this.tokenKey=`companion-${this.pluginId}-auth-token`,this.companionKeysParams=this.opts.companionKeysParams,this.preAuthToken=null}headers(){return Promise.all([super.headers(),this.getAuthToken()]).then(e=>{let[t,r]=e;const i={};return r&&(i["uppy-auth-token"]=r),this.companionKeysParams&&(i["uppy-credentials-params"]=btoa(JSON.stringify({params:this.companionKeysParams}))),{...t,...i}})}onReceiveResponse(e){e=super.onReceiveResponse(e);const t=this.uppy.getPlugin(this.pluginId),r=t.getPluginState().authenticated?401!==e.status:e.status<400;return t.setPluginState({authenticated:r}),e}setAuthToken(e){return this.uppy.getPlugin(this.pluginId).storage.setItem(this.tokenKey,e)}getAuthToken(){return this.uppy.getPlugin(this.pluginId).storage.getItem(this.tokenKey)}async ensurePreAuth(){if(this.companionKeysParams&&!this.preAuthToken&&(await this.fetchPreAuthToken(),!this.preAuthToken))throw new Error("Could not load authentication data required for third-party login. Please try again later.")}authUrl(e){void 0===e&&(e={});const t=new URLSearchParams(e);return this.preAuthToken&&t.set("uppyPreAuthToken",this.preAuthToken),`${this.hostname}/${this.id}/connect?${t}`}fileUrl(e){return`${this.hostname}/${this.id}/get/${e}`}async fetchPreAuthToken(){if(this.companionKeysParams)try{const e=await this.post(`${this.id}/preauth/`,{params:this.companionKeysParams});this.preAuthToken=e.token}catch(e){this.uppy.log(`[CompanionClient] unable to fetch preAuthToken ${e}`,"warning")}}list(e){return this.get(`${this.id}/list/${e||""}`)}logout(){return this.get(`${this.id}/logout`).then(e=>Promise.all([e,this.uppy.getPlugin(this.pluginId).storage.removeItem(this.tokenKey)])).then(e=>{let[t]=e;return t})}static initPlugin(t,r,i){if(t.type="acquirer",t.files=[],i&&(t.opts={...i,...r}),r.serverUrl||r.serverPattern)throw new Error("`serverUrl` and `serverPattern` have been renamed to `companionUrl` and `companionAllowedHosts` respectively in the 0.30.5 release. Please consult the docs (for example, https://uppy.io/docs/instagram/ for the Instagram plugin) and use the updated options.`");if(r.companionAllowedHosts){const e=r.companionAllowedHosts;if(!("string"==typeof e||Array.isArray(e)||e instanceof RegExp))throw new TypeError(`${t.id}: the option "companionAllowedHosts" must be one of string, Array, RegExp`);t.opts.companionAllowedHosts=e}else/^(?!https?:\/\/).*$/i.test(r.companionUrl)?t.opts.companionAllowedHosts=`https://${r.companionUrl.replace(/^\/\//,"")}`:t.opts.companionAllowedHosts=new URL(r.companionUrl).origin;t.storage=t.opts.storage||e}},xt}();Pt.Provider=t;const r=function(){if(Ft)return jt;Ft=1;const e=Ot();return jt=class extends e{constructor(e,t){super(e,t),this.provider=t.provider,this.id=this.provider,this.name=this.opts.name||this.id.split("-").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" "),this.pluginId=this.opts.pluginId}fileUrl(e){return`${this.hostname}/search/${this.id}/get/${e}`}search(e,t){return this.get(`search/${this.id}/list?q=${encodeURIComponent(e)}${t?`&${t}`:""}`)}},jt}();Pt.SearchProvider=r;const i=function(){if(kt)return Tt;let e,t;function r(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw new TypeError("attempted to use private field on non-instance");return e}kt=1;var i=0;function n(e){return"__private_"+i+++"_"+e}const o=Z();var s=n("queued"),a=n("emitter"),l=n("isOpen"),u=n("socket"),p=n("handleMessage");return e=Symbol.for("uppy test: getSocket"),t=Symbol.for("uppy test: getQueued"),Tt=class{constructor(e){Object.defineProperty(this,s,{writable:!0,value:[]}),Object.defineProperty(this,a,{writable:!0,value:o()}),Object.defineProperty(this,l,{writable:!0,value:!1}),Object.defineProperty(this,u,{writable:!0,value:void 0}),Object.defineProperty(this,p,{writable:!0,value:e=>{try{const t=JSON.parse(e.data);this.emit(t.action,t.payload)}catch(e){console.log(e)}}}),this.opts=e,e&&!1===e.autoOpen||this.open()}get isOpen(){return r(this,l)[l]}[e](){return r(this,u)[u]}[t](){return r(this,s)[s]}open(){r(this,u)[u]=new WebSocket(this.opts.target),r(this,u)[u].onopen=()=>{for(r(this,l)[l]=!0;r(this,s)[s].length>0&&r(this,l)[l];){const e=r(this,s)[s].shift();this.send(e.action,e.payload)}},r(this,u)[u].onclose=()=>{r(this,l)[l]=!1},r(this,u)[u].onmessage=r(this,p)[p]}close(){var e;null==(e=r(this,u)[u])||e.close()}send(e,t){r(this,l)[l]?r(this,u)[u].send(JSON.stringify({action:e,payload:t})):r(this,s)[s].push({action:e,payload:t})}on(e,t){r(this,a)[a].on(e,t)}emit(e,t){r(this,a)[a].emit(e,t)}once(e,t){r(this,a)[a].once(e,t)}},Tt}();return Pt.Socket=i,Pt}var Nt,It,Mt,Lt,zt,Dt,qt,Ht,Bt,Wt,Xt,Gt,Kt,Vt,Yt,Qt,Jt,Zt={};function er(){if(Nt)return Zt;function e(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw new TypeError("attempted to use private field on non-instance");return e}Nt=1,Object.defineProperty(Zt,"__esModule",{value:!0}),Zt.internalRateLimitedQueue=Zt.RateLimitedQueue=void 0;var t=0;function r(e){return"__private_"+t+++"_"+e}var i=r("activeRequests"),n=r("queuedHandlers"),o=r("paused"),s=r("pauseTimer"),a=r("downLimit"),l=r("upperLimit"),u=r("rateLimitingTimer"),p=r("call"),d=r("queueNext"),c=r("next"),h=r("queue"),f=r("dequeue"),g=r("resume"),m=r("increaseLimit");function y(t){e(this,i)[i]+=1;let r,n=!1;try{r=t()}catch(t){throw e(this,i)[i]-=1,t}return{abort:()=>{n||(n=!0,e(this,i)[i]-=1,r(),e(this,d)[d]())},done:()=>{n||(n=!0,e(this,i)[i]-=1,e(this,d)[d]())}}}function v(){queueMicrotask(()=>e(this,c)[c]())}function _(){if(e(this,o)[o]||e(this,i)[i]>=this.limit)return;if(0===e(this,n)[n].length)return;const t=e(this,n)[n].shift(),r=e(this,p)[p](t.fn);t.abort=r.abort,t.done=r.done}function b(t,r){void 0===r&&(r={});const i={fn:t,priority:r.priority||0,abort:()=>{e(this,f)[f](i)},done:()=>{throw new Error("Cannot mark a queued request as done: this indicates a bug")}},o=e(this,n)[n].findIndex(e=>i.priority>e.priority);return-1===o?e(this,n)[n].push(i):e(this,n)[n].splice(o,0,i),i}function w(t){const r=e(this,n)[n].indexOf(t);-1!==r&&e(this,n)[n].splice(r,1)}Zt.RateLimitedQueue=class{constructor(t){Object.defineProperty(this,f,{value:w}),Object.defineProperty(this,h,{value:b}),Object.defineProperty(this,c,{value:_}),Object.defineProperty(this,d,{value:v}),Object.defineProperty(this,p,{value:y}),Object.defineProperty(this,i,{writable:!0,value:0}),Object.defineProperty(this,n,{writable:!0,value:[]}),Object.defineProperty(this,o,{writable:!0,value:!1}),Object.defineProperty(this,s,{writable:!0,value:void 0}),Object.defineProperty(this,a,{writable:!0,value:1}),Object.defineProperty(this,l,{writable:!0,value:void 0}),Object.defineProperty(this,u,{writable:!0,value:void 0}),Object.defineProperty(this,g,{writable:!0,value:()=>this.resume()}),Object.defineProperty(this,m,{writable:!0,value:()=>{if(e(this,o)[o])e(this,u)[u]=setTimeout(e(this,m)[m],0);else{e(this,a)[a]=this.limit,this.limit=Math.ceil((e(this,l)[l]+e(this,a)[a])/2);for(let t=e(this,a)[a];t<=this.limit;t++)e(this,d)[d]();e(this,l)[l]-e(this,a)[a]>3?e(this,u)[u]=setTimeout(e(this,m)[m],2e3):e(this,a)[a]=Math.floor(e(this,a)[a]/2)}}}),this.limit="number"!=typeof t||0===t?1/0:t}run(t,r){return!e(this,o)[o]&&e(this,i)[i]<this.limit?e(this,p)[p](t):e(this,h)[h](t,r)}wrapPromiseFunction(e,t){var r=this;return function(){for(var i=arguments.length,n=new Array(i),o=0;o<i;o++)n[o]=arguments[o];let s;const a=new Promise((i,o)=>{s=r.run(()=>{let t,r;try{r=Promise.resolve(e(...n))}catch(e){r=Promise.reject(e)}return r.then(e=>{t?o(t):(s.done(),i(e))},e=>{t?o(t):(s.done(),o(e))}),()=>{t=new Error("Cancelled")}},t)});return a.abort=()=>{s.abort()},a}}resume(){e(this,o)[o]=!1,clearTimeout(e(this,s)[s]);for(let t=0;t<this.limit;t++)e(this,d)[d]()}pause(t){void 0===t&&(t=null),e(this,o)[o]=!0,clearTimeout(e(this,s)[s]),null!=t&&(e(this,s)[s]=setTimeout(e(this,g)[g],t))}rateLimit(t){clearTimeout(e(this,u)[u]),this.pause(t),this.limit>1&&Number.isFinite(this.limit)&&(e(this,l)[l]=this.limit-1,this.limit=e(this,a)[a],e(this,u)[u]=setTimeout(e(this,m)[m],t))}get isPaused(){return e(this,o)[o]}};const P=Symbol("__queue");return Zt.internalRateLimitedQueue=P,Zt}function tr(){return Yt?Vt:(Yt=1,Vt={strings:{timedOut:"Upload stalled for %{seconds} seconds, aborting."}})}var rr,ir,nr=function(){if(Jt)return Qt;Jt=1;var e=h(),t=Ct(),r=er();const i=lt(),n=function(){if(Mt)return It;Mt=1;const e=ee();return It=e(function(e,t,r){const{progress:i,bytesUploaded:n,bytesTotal:o}=t;i&&(e.uppy.log(`Upload progress: ${i}`),e.uppy.emit("upload-progress",r,{uploader:e,bytesUploaded:n,bytesTotal:o}))},300,{leading:!0,trailing:!0})}(),o=zt?Lt:(zt=1,Lt=function(e){const t=/^(?:https?:\/\/|\/\/)?(?:[^@\n]+@)?(?:www\.)?([^\n]+)/i.exec(e)[1];return`${/^http:\/\//i.test(e)?"ws":"wss"}://${t}`}),s=qt?Dt:(qt=1,Dt=function(e){const t=[],r=[];function i(e){t.push(e)}function n(e){r.push(e)}return Promise.all(e.map(e=>e.then(i,n))).then(()=>({successful:t,failed:r}))}),a=function(){if(Bt)return Ht;function e(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw new TypeError("attempted to use private field on non-instance");return e}Bt=1;var t=0;function r(e){return"__private_"+t+++"_"+e}var i=r("emitter"),n=r("events");return Ht=class{constructor(t){Object.defineProperty(this,i,{writable:!0,value:void 0}),Object.defineProperty(this,n,{writable:!0,value:[]}),e(this,i)[i]=t}on(t,r){return e(this,n)[n].push([t,r]),e(this,i)[i].on(t,r)}remove(){for(const[t,r]of e(this,n)[n].splice(0))e(this,i)[i].off(t,r)}}}(),l=function(){if(Xt)return Wt;function e(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw new TypeError("attempted to use private field on non-instance");return e}Xt=1;var t=0;function r(e){return"__private_"+t+++"_"+e}var i=r("aliveTimer"),n=r("isDone"),o=r("onTimedOut"),s=r("timeout");return Wt=class{constructor(t,r){Object.defineProperty(this,i,{writable:!0,value:void 0}),Object.defineProperty(this,n,{writable:!0,value:!1}),Object.defineProperty(this,o,{writable:!0,value:void 0}),Object.defineProperty(this,s,{writable:!0,value:void 0}),e(this,s)[s]=t,e(this,o)[o]=r}progress(){e(this,n)[n]||e(this,s)[s]>0&&(clearTimeout(e(this,i)[i]),e(this,i)[i]=setTimeout(e(this,o)[o],e(this,s)[s]))}done(){e(this,n)[n]||(clearTimeout(e(this,i)[i]),e(this,i)[i]=null,e(this,n)[n]=!0)}}}(),u=St(),p=Kt?Gt:(Kt=1,Gt=function(e){return!!e&&(0!==e.readyState&&4!==e.readyState||0===e.status)}),d=tr();function c(e,t){let r=t;return r||(r=new Error("Upload error")),"string"==typeof r&&(r=new Error(r)),r instanceof Error||(r=Object.assign(new Error("Upload error"),{data:r})),p(e)?(r=new u(r,e),r):(r.request=e,r)}function f(e){return e.data.slice(0,e.data.size,e.meta.type)}class g extends i{constructor(e,t){super(e,t),this.type="uploader",this.id=this.opts.id||"XHRUpload",this.title="XHRUpload",this.defaultLocale=d;const i={formData:!0,fieldName:t.bundle?"files[]":"file",method:"post",metaFields:null,responseUrlFieldName:"url",bundle:!1,headers:{},timeout:3e4,limit:5,withCredentials:!1,responseType:"",getResponseData(t){let r={};try{r=JSON.parse(t)}catch(t){e.log(t)}return r},getResponseError(e,t){let r=new Error("Upload error");return p(t)&&(r=new u(r,t)),r},validateStatus:e=>e>=200&&e<300};if(this.opts={...i,...t},this.i18nInit(),this.handleUpload=this.handleUpload.bind(this),r.internalRateLimitedQueue in this.opts?this.requests=this.opts[r.internalRateLimitedQueue]:this.requests=new r.RateLimitedQueue(this.opts.limit),this.opts.bundle&&!this.opts.formData)throw new Error("`opts.formData` must be true when `opts.bundle` is enabled.");this.uploaderEvents=Object.create(null)}getOptions(e){const t=this.uppy.getState().xhrUpload,{headers:r}=this.opts,i={...this.opts,...t||{},...e.xhrUpload||{},headers:{}};return"function"==typeof r?i.headers=r(e):Object.assign(i.headers,this.opts.headers),t&&Object.assign(i.headers,t.headers),e.xhrUpload&&Object.assign(i.headers,e.xhrUpload.headers),i}addMetadata(e,t,r){(Array.isArray(r.metaFields)?r.metaFields:Object.keys(t)).forEach(r=>{e.append(r,t[r])})}createFormDataUpload(e,t){const r=new FormData;this.addMetadata(r,e.meta,t);const i=f(e);return e.name?r.append(t.fieldName,i,e.meta.name):r.append(t.fieldName,i),r}createBundledUpload(e,t){const r=new FormData,{meta:i}=this.uppy.getState();return this.addMetadata(r,i,t),e.forEach(e=>{const t=this.getOptions(e),i=f(e);e.name?r.append(t.fieldName,i,e.name):r.append(t.fieldName,i)}),r}upload(t,r,i){const n=this.getOptions(t);return this.uppy.log(`uploading ${r} of ${i}`),new Promise((r,i)=>{this.uppy.emit("upload-started",t);const o=n.formData?this.createFormDataUpload(t,n):t.data,s=new XMLHttpRequest;let u;this.uploaderEvents[t.id]=new a(this.uppy);const p=new l(n.timeout,()=>{s.abort(),u.done();const e=new Error(this.i18n("timedOut",{seconds:Math.ceil(n.timeout/1e3)}));this.uppy.emit("upload-error",t,e),i(e)}),d=(0,e.nanoid)();s.upload.addEventListener("loadstart",()=>{this.uppy.log(`[XHRUpload] ${d} started`)}),s.upload.addEventListener("progress",e=>{this.uppy.log(`[XHRUpload] ${d} progress: ${e.loaded} / ${e.total}`),p.progress(),e.lengthComputable&&this.uppy.emit("upload-progress",t,{uploader:this,bytesUploaded:e.loaded,bytesTotal:e.total})}),s.addEventListener("load",()=>{if(this.uppy.log(`[XHRUpload] ${d} finished`),p.done(),u.done(),this.uploaderEvents[t.id]&&(this.uploaderEvents[t.id].remove(),this.uploaderEvents[t.id]=null),n.validateStatus(s.status,s.responseText,s)){const e=n.getResponseData(s.responseText,s),i=e[n.responseUrlFieldName],o={status:s.status,body:e,uploadURL:i};return this.uppy.emit("upload-success",t,o),i&&this.uppy.log(`Download ${t.name} from ${i}`),r(t)}const e=n.getResponseData(s.responseText,s),o=c(s,n.getResponseError(s.responseText,s)),a={status:s.status,body:e};return this.uppy.emit("upload-error",t,o,a),i(o)}),s.addEventListener("error",()=>{this.uppy.log(`[XHRUpload] ${d} errored`),p.done(),u.done(),this.uploaderEvents[t.id]&&(this.uploaderEvents[t.id].remove(),this.uploaderEvents[t.id]=null);const e=c(s,n.getResponseError(s.responseText,s));return this.uppy.emit("upload-error",t,e),i(e)}),s.open(n.method.toUpperCase(),n.endpoint,!0),s.withCredentials=n.withCredentials,""!==n.responseType&&(s.responseType=n.responseType),u=this.requests.run(()=>{this.uppy.emit("upload-started",t);const e=this.getOptions(t);return Object.keys(e.headers).forEach(t=>{s.setRequestHeader(t,e.headers[t])}),s.send(o),()=>{p.done(),s.abort()}}),this.onFileRemove(t.id,()=>{u.abort(),i(new Error("File removed"))}),this.onCancelAll(t.id,e=>{let{reason:t}=e;"user"===t&&u.abort(),i(new Error("Upload cancelled"))})})}uploadRemote(e){const r=this.getOptions(e);return new Promise((i,s)=>{this.uppy.emit("upload-started",e);const l={};(Array.isArray(r.metaFields)?r.metaFields:Object.keys(e.meta)).forEach(t=>{l[t]=e.meta[t]});new(e.remote.providerOptions.provider?t.Provider:t.RequestClient)(this.uppy,e.remote.providerOptions).post(e.remote.url,{...e.remote.body,endpoint:r.endpoint,size:e.data.size,fieldname:r.fieldName,metadata:l,httpMethod:r.method,useFormData:r.formData,headers:r.headers}).then(l=>{const{token:u}=l,p=o(e.remote.companionUrl),d=new t.Socket({target:`${p}/api/${u}`,autoOpen:!1});let c;this.uploaderEvents[e.id]=new a(this.uppy),this.onFileRemove(e.id,()=>{d.send("cancel",{}),c.abort(),i(`upload ${e.id} was removed`)}),this.onCancelAll(e.id,function(t){let{reason:r}=void 0===t?{}:t;"user"===r&&(d.send("cancel",{}),c.abort()),i(`upload ${e.id} was canceled`)}),this.onRetry(e.id,()=>{d.send("pause",{}),d.send("resume",{})}),this.onRetryAll(e.id,()=>{d.send("pause",{}),d.send("resume",{})}),d.on("progress",t=>n(this,t,e)),d.on("success",t=>{const n=r.getResponseData(t.response.responseText,t.response),o=n[r.responseUrlFieldName],s={status:t.response.status,body:n,uploadURL:o};return this.uppy.emit("upload-success",e,s),c.done(),this.uploaderEvents[e.id]&&(this.uploaderEvents[e.id].remove(),this.uploaderEvents[e.id]=null),i()}),d.on("error",t=>{const i=t.response,n=i?r.getResponseError(i.responseText,i):Object.assign(new Error(t.error.message),{cause:t.error});this.uppy.emit("upload-error",e,n),c.done(),this.uploaderEvents[e.id]&&(this.uploaderEvents[e.id].remove(),this.uploaderEvents[e.id]=null),s(n)}),c=this.requests.run(()=>(d.open(),e.isPaused&&d.send("pause",{}),()=>d.close()))}).catch(t=>{this.uppy.emit("upload-error",e,t),s(t)})})}uploadBundle(e){return new Promise((t,r)=>{const{endpoint:i}=this.opts,{method:n}=this.opts,o=this.uppy.getState().xhrUpload,s=this.createBundledUpload(e,{...this.opts,...o||{}}),a=new XMLHttpRequest,u=t=>{e.forEach(e=>{this.uppy.emit("upload-error",e,t)})},p=new l(this.opts.timeout,()=>{a.abort();const e=new Error(this.i18n("timedOut",{seconds:Math.ceil(this.opts.timeout/1e3)}));u(e),r(e)});a.upload.addEventListener("loadstart",()=>{this.uppy.log("[XHRUpload] started uploading bundle"),p.progress()}),a.upload.addEventListener("progress",t=>{p.progress(),t.lengthComputable&&e.forEach(e=>{this.uppy.emit("upload-progress",e,{uploader:this,bytesUploaded:t.loaded/t.total*e.size,bytesTotal:e.size})})}),a.addEventListener("load",i=>{if(p.done(),this.opts.validateStatus(i.target.status,a.responseText,a)){const r=this.opts.getResponseData(a.responseText,a),n={status:i.target.status,body:r};return e.forEach(e=>{this.uppy.emit("upload-success",e,n)}),t()}const n=this.opts.getResponseError(a.responseText,a)||new Error("Upload error");return n.request=a,u(n),r(n)}),a.addEventListener("error",()=>{p.done();const e=this.opts.getResponseError(a.responseText,a)||new Error("Upload error");return u(e),r(e)}),this.uppy.on("cancel-all",function(e){let{reason:t}=void 0===e?{}:e;"user"===t&&(p.done(),a.abort())}),a.open(n.toUpperCase(),i,!0),a.withCredentials=this.opts.withCredentials,""!==this.opts.responseType&&(a.responseType=this.opts.responseType),Object.keys(this.opts.headers).forEach(e=>{a.setRequestHeader(e,this.opts.headers[e])}),a.send(s),e.forEach(e=>{this.uppy.emit("upload-started",e)})})}uploadFiles(e){const t=e.map((t,r)=>{const i=parseInt(r,10)+1,n=e.length;return t.error?Promise.reject(new Error(t.error)):t.isRemote?this.uploadRemote(t,i,n):this.upload(t,i,n)});return s(t)}onFileRemove(e,t){this.uploaderEvents[e].on("file-removed",r=>{e===r.id&&t(r.id)})}onRetry(e,t){this.uploaderEvents[e].on("upload-retry",r=>{e===r&&t()})}onRetryAll(e,t){this.uploaderEvents[e].on("retry-all",()=>{this.uppy.getFile(e)&&t()})}onCancelAll(e,t){var r=this;this.uploaderEvents[e].on("cancel-all",function(){r.uppy.getFile(e)&&t(...arguments)})}handleUpload(e){if(0===e.length)return this.uppy.log("[XHRUpload] No files to upload!"),Promise.resolve();0!==this.opts.limit||this.opts[r.internalRateLimitedQueue]||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 t=e.map(e=>this.uppy.getFile(e));if(this.opts.bundle){if(t.some(e=>e.isRemote))throw new Error("Can’t upload remote files when the `bundle: true` option is set");if("function"==typeof this.opts.headers)throw new TypeError("`headers` may not be a function when the `bundle: true` option is set");return this.uploadBundle(t)}return this.uploadFiles(t).then(()=>null)}install(){if(this.opts.bundle){const{capabilities:e}=this.uppy.getState();this.uppy.setState({capabilities:{...e,individualCancellation:!1}})}this.uppy.addUploader(this.handleUpload)}uninstall(){if(this.opts.bundle){const{capabilities:e}=this.uppy.getState();this.uppy.setState({capabilities:{...e,individualCancellation:!0}})}this.uppy.removeUploader(this.handleUpload)}}return g.VERSION="2.1.3",Qt=g}(),or=i(nr);var sr=function(){if(ir)return rr;ir=1;var e=9007199254740991,t="[object Arguments]",r="[object Function]",i="[object GeneratorFunction]",n=/^(?:0|[1-9]\d*)$/;function o(e,t){for(var r=-1,i=e?e.length:0;++r<i&&!1!==t(e[r],r,e););return e}var s,a,l=Object.prototype,u=l.hasOwnProperty,p=l.toString,d=l.propertyIsEnumerable,c=(s=Object.keys,a=Object,function(e){return s(a(e))});function h(e,r){var i=_(e)||function(e){return function(e){return function(e){return!!e&&"object"==typeof e}(e)&&b(e)}(e)&&u.call(e,"callee")&&(!d.call(e,"callee")||p.call(e)==t)}(e)?function(e,t){for(var r=-1,i=Array(e);++r<e;)i[r]=t(r);return i}(e.length,String):[],n=i.length,o=!!n;for(var s in e)!u.call(e,s)||o&&("length"==s||v(s,n))||i.push(s);return i}var f,g=(f=function(e,t){return e&&m(e,t,w)},function(e,t){if(null==e)return e;if(!b(e))return f(e,t);for(var r=e.length,i=-1,n=Object(e);++i<r&&!1!==t(n[i],i,n););return e}),m=function(e,t,r){for(var i=-1,n=Object(e),o=r(e),s=o.length;s--;){var a=o[++i];if(!1===t(n[a],a,n))break}return e};function y(e){if(r=(t=e)&&t.constructor,i="function"==typeof r&&r.prototype||l,t!==i)return c(e);var t,r,i,n=[];for(var o in Object(e))u.call(e,o)&&"constructor"!=o&&n.push(o);return n}function v(t,r){return!!(r=null==r?e:r)&&("number"==typeof t||n.test(t))&&t>-1&&t%1==0&&t<r}var _=Array.isArray;function b(t){return null!=t&&function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=e}(t.length)&&!function(e){var t=function(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}(e)?p.call(e):"";return t==r||t==i}(t)}function w(e){return b(e)?h(e):y(e)}function P(e){return e}return rr=function(e,t){return(_(e)?o:g)(e,"function"==typeof t?t:P)}}(),ar=i(sr);function lr(e,t){var r=function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var i,n,o=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(i=o.next()).done;)s.push(i.value)}catch(e){n={error:e}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return s}(e.split("#"),2),i=r[0],n=r[1],o=[];ar(t,function(e,t){o.push("".concat(t,"=").concat(e))});var s=o.join("&");return i=i.indexOf("?")>0?"".concat(i,"&").concat(s):"".concat(i,"?").concat(s),n?"".concat(i,"#").concat(n):i}function ur(e){return e||{name:""}}e.createUploader=function(e,r){return e.uploadAdapter?e.uploadAdapter({config:e,editor:r}):function(e){var r=e.server,i=void 0===r?"":r,n=e.fieldName,o=void 0===n?"":n,s=e.maxFileSize,a=void 0===s?10485760:s,l=e.maxNumberOfFiles,u=void 0===l?100:l,p=e.meta,d=void 0===p?{}:p,c=e.metaWithUrl,h=void 0!==c&&c,f=e.headers,g=void 0===f?{}:f,m=e.withCredentials,y=void 0!==m&&m,v=e.timeout,_=void 0===v?1e4:v,b=e.onBeforeUpload,w=void 0===b?function(e){return e}:b,P=e.onSuccess,S=void 0===P?function(e,t){}:P,O=e.onError,E=void 0===O?function(e,t,r){console.error("".concat(e.name," upload error"),t,r)}:O,x=e.onProgress,U=void 0===x?function(e){}:x;if(!i)throw new Error("Cannot get upload server address\n没有配置上传地址");if(!o)throw new Error("Cannot get fieldName\n没有配置 fieldName");var j=i;h&&(j=lr(j,d));var F=new wt(t({onBeforeUpload:function(e){return w(e)},restrictions:{maxFileSize:a,maxNumberOfFiles:u},meta:d},e.uppyConfig)).use(or,t({endpoint:j,headers:g,formData:!0,fieldName:o,bundle:!1,withCredentials:y,timeout:_},e.xhrConfig));return F.on("upload-success",function(e,t){var r=(null!=t?t:{}).body,i=void 0===r?{}:r,n=ur(e);try{S(n,i)}catch(e){console.error("wangEditor upload file - onSuccess error",e)}}),F.on("progress",function(e){e<1||U(e)}),F.on("upload-error",function(e,t,r){var i=ur(e);try{E(i,t,r)}catch(e){console.error("wangEditor upload file - onError error",e)}}),F.on("restriction-failed",function(e,t){var r=ur(e);try{E(r,t,void 0)}catch(e){console.error("wangEditor upload file - onError error",e)}}),F}(e)}});
|
|
13
|
+
//# sourceMappingURL=upload.js.map
|