filepond
Version:
FilePond, Where files go to stretch their bits.
9 lines (7 loc) • 96.6 kB
JavaScript
/*!
* FilePond 4.3.7
* Licensed under MIT, https://opensource.org/licenses/MIT/
* Please visit https://pqina.nl/filepond/ for details.
*/
/* eslint-disable */
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).FilePond={})}(this,function(e){"use strict";var t,n,r=function(e,t){for(var n in e)e.hasOwnProperty(n)&&t(n,e[n])},o=function(e){var t={};return r(e,function(n){!function(e,t,n){"function"!=typeof n?Object.defineProperty(e,t,Object.assign({},n)):e[t]=n}(t,n,e[n])}),t},i=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;if(null===n)return e.getAttribute(t)||e.hasAttribute(t);e.setAttribute(t,n)},a=["svg","path"],s=function(e){return a.includes(e)},u=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};"object"==typeof t&&(n=t,t=null);var o=s(e)?document.createElementNS("http://www.w3.org/2000/svg",e):document.createElement(e);return t&&(s(e)?i(o,"class",t):o.className=t),r(n,function(e,t){i(o,e,t)}),o},l=function(e,t){return function(e,n){return void 0!==n?t.splice(n,0,e):t.push(e),e}},c=function(e,t){return function(n){return t.splice(t.indexOf(n),1),n.element.parentNode&&e.removeChild(n.element),n}},f=function(e,t,n,r){var o=n[0]||e.left,i=n[1]||e.top,a=o+e.width,s=i+e.height*(r[1]||1),u={element:Object.assign({},e),inner:{left:e.left,top:e.top,right:e.right,bottom:e.bottom},outer:{left:o,top:i,right:a,bottom:s}};return t.filter(function(e){return!e.isRectIgnored()}).map(function(e){return e.rect}).forEach(function(e){p(u.inner,Object.assign({},e.inner)),p(u.outer,Object.assign({},e.outer))}),d(u.inner),u.outer.bottom+=u.element.marginBottom,u.outer.right+=u.element.marginRight,d(u.outer),u},p=function(e,t){t.top+=e.top,t.right+=e.left,t.bottom+=e.top,t.left+=e.left,t.bottom>e.bottom&&(e.bottom=t.bottom),t.right>e.right&&(e.right=t.right)},d=function(e){e.width=e.right-e.left,e.height=e.bottom-e.top},E=function(e){return"number"==typeof e},_=function(e){return e<.5?2*e*e:(4-2*e)*e-1},T={spring:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.stiffness,n=void 0===t?.5:t,r=e.damping,i=void 0===r?.75:r,a=e.mass,s=void 0===a?10:a,u=null,l=null,c=0,f=!1,p=o({interpolate:function(){if(!f){if(!E(u)||!E(l))return f=!0,void(c=0);!function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:.001;return Math.abs(e-t)<r&&Math.abs(n)<r}(l+=c+=-(l-u)*n/s,u,c*=i)?p.onupdate(l):(l=u,c=0,f=!0,p.onupdate(l),p.oncomplete(l))}},target:{set:function(e){if(E(e)&&!E(l)&&(l=e),null===u&&(u=e,l=e),l===(u=e)||void 0===u)return f=!0,c=0,p.onupdate(l),void p.oncomplete(l);f=!1},get:function(){return u}},resting:{get:function(){return f}},onupdate:function(e){},oncomplete:function(e){}});return p},tween:function(){var e,t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=n.duration,i=void 0===r?500:r,a=n.easing,s=void 0===a?_:a,u=n.delay,l=void 0===u?0:u,c=null,f=!0,p=!1,d=null,E=o({interpolate:function(n){f||null===d||(null===c&&(c=n),n-c<l||((e=n-c-l)<i?(t=e/i,E.onupdate((e>=0?s(p?1-t:t):0)*d)):(e=1,t=p?0:1,E.onupdate(t*d),E.oncomplete(t*d),f=!0)))},target:{get:function(){return p?0:d},set:function(e){if(null===d)return d=e,E.onupdate(e),void E.oncomplete(e);e<d?(d=1,p=!0):(p=!1,d=e),f=!1,c=null}},resting:{get:function(){return f}},onupdate:function(e){},oncomplete:function(e){}});return E}},I=function(e,t,n){var r=e[t]&&"object"==typeof e[t][n]?e[t][n]:e[t]||e,o="string"==typeof r?r:r.type,i="object"==typeof r?Object.assign({},r):{};return T[o]?T[o](i):null},m=function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]&&arguments[3];(t=Array.isArray(t)?t:[t]).forEach(function(t){e.forEach(function(e){var o=e,i=function(){return n[e]},a=function(t){return n[e]=t};"object"==typeof e&&(o=e.key,i=e.getter||i,a=e.setter||a),t[o]&&!r||(t[o]={get:i,set:a})})})},v=function(e){return null!=e},g={opacity:1,scaleX:1,scaleY:1,translateX:0,translateY:0,rotateX:0,rotateY:0,rotateZ:0,originX:0,originY:0},R=function(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!0;for(var n in t)if(t[n]!==e[n])return!0;return!1},h=function(e,t){var n=t.opacity,r=t.perspective,o=t.translateX,i=t.translateY,a=t.scaleX,s=t.scaleY,u=t.rotateX,l=t.rotateY,c=t.rotateZ,f=t.originX,p=t.originY,d=t.width,E=t.height,_="",T="";(v(f)||v(p))&&(T+="transform-origin: "+(f||0)+"px "+(p||0)+"px;"),v(r)&&(_+="perspective("+r+"px) "),(v(o)||v(i))&&(_+="translate3d("+(o||0)+"px, "+(i||0)+"px, 0) "),(v(a)||v(s))&&(_+="scale3d("+(v(a)?a:1)+", "+(v(s)?s:1)+", 1) "),v(c)&&(_+="rotateZ("+c+"rad) "),v(u)&&(_+="rotateX("+u+"rad) "),v(l)&&(_+="rotateY("+l+"rad) "),_.length&&(T+="transform:"+_+";"),v(n)&&(T+="opacity:"+n+";",0===n&&(T+="visibility:hidden;"),n<1&&(T+="pointer-events:none;")),v(E)&&(T+="height:"+E+"px;"),v(d)&&(T+="width:"+d+"px;");var I=e.elementCurrentStyle||"";T.length===I.length&&T===I||(e.setAttribute("style",T),e.elementCurrentStyle=T)},O={styles:function(e){var t=e.mixinConfig,n=e.viewProps,r=e.viewInternalAPI,o=e.viewExternalAPI,i=e.view,a=Object.assign({},n),s={};m(t,[r,o],n);var u=function(){return i.rect?f(i.rect,i.childViews,[n.translateX||0,n.translateY||0],[n.scaleX||0,n.scaleY||0]):null};return r.rect={get:u},o.rect={get:u},t.forEach(function(e){n[e]=void 0===a[e]?g[e]:a[e]}),{write:function(){if(R(s,n))return h(i.element,n),Object.assign(s,Object.assign({},n)),!0},destroy:function(){}}},listeners:function(e){e.mixinConfig,e.viewProps,e.viewInternalAPI;var t,n=e.viewExternalAPI,r=(e.viewState,e.view),o=[],i=(t=r.element,function(e,n){t.addEventListener(e,n)}),a=function(e){return function(t,n){e.removeEventListener(t,n)}}(r.element);return n.on=function(e,t){o.push({type:e,fn:t}),i(e,t)},n.off=function(e,t){o.splice(o.findIndex(function(n){return n.type===e&&n.fn===t}),1),a(e,t)},{write:function(){return!0},destroy:function(){o.forEach(function(e){a(e.type,e.fn)})}}},animations:function(e){var t=e.mixinConfig,n=e.viewProps,o=e.viewInternalAPI,i=e.viewExternalAPI,a=(e.viewState,Object.assign({},n)),s=[];return r(t,function(e,t){var r=I(t);r&&(r.onupdate=function(t){n[e]=t},r.target=a[e],m([{key:e,setter:function(e){r.target!==e&&(r.target=e)},getter:function(){return n[e]}}],[o,i],n,!0),s.push(r))}),{write:function(e){var t=!0;return s.forEach(function(n){n.resting||(t=!1),n.interpolate(e)}),t},destroy:function(){}}},apis:function(e){var t=e.mixinConfig,n=e.viewProps,r=e.viewExternalAPI;m(t,r,n)}},D=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return t.layoutCalculated||(e.paddingTop=parseInt(n.paddingTop,10)||0,e.marginTop=parseInt(n.marginTop,10)||0,e.marginRight=parseInt(n.marginRight,10)||0,e.marginBottom=parseInt(n.marginBottom,10)||0,e.marginLeft=parseInt(n.marginLeft,10)||0,t.layoutCalculated=!0),e.left=t.offsetLeft||0,e.top=t.offsetTop||0,e.width=t.offsetWidth||0,e.height=t.offsetHeight||0,e.right=e.left+e.width,e.bottom=e.top+e.height,e.scrollTop=t.scrollTop,e.hidden=null===t.offsetParent,e},S=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.tag,n=void 0===t?"div":t,r=e.name,i=void 0===r?null:r,a=e.attributes,s=void 0===a?{}:a,p=e.read,d=void 0===p?function(){}:p,E=e.write,_=void 0===E?function(){}:E,T=e.create,I=void 0===T?function(){}:T,m=e.destroy,v=void 0===m?function(){}:m,g=e.filterFrameActionsForChild,R=void 0===g?function(e,t){return t}:g,h=e.didCreateView,S=void 0===h?function(){}:h,y=e.didWriteView,A=void 0===y?function(){}:y,b=e.ignoreRect,P=void 0!==b&&b,L=e.ignoreRectUpdate,M=void 0!==L&&L,C=e.mixins,N=void 0===C?[]:C;return function(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=u(n,"filepond--"+i,s),p=window.getComputedStyle(a,null),E=D(),T=null,m=!1,g=[],h=[],y={},b={},L=[_],C=[d],w=[v],G=function(){return a},U=function(){return g.concat()},B=function(){return T||(T=f(E,g,[0,0],[1,1]))},V={element:{get:G},style:{get:function(){return p}},childViews:{get:U}},F=Object.assign({},V,{rect:{get:B},ref:{get:function(){return y}},is:function(e){return i===e},appendChild:(t=a,function(e,n){void 0!==n&&t.children[n]?t.insertBefore(e,t.children[n]):t.appendChild(e)}),createChildView:function(e){return function(t,n){return t(e,n)}}(e),linkView:function(e){return g.push(e),e},unlinkView:function(e){g.splice(g.indexOf(e),1)},appendChildView:l(0,g),removeChildView:c(a,g),registerWriter:function(e){return L.push(e)},registerReader:function(e){return C.push(e)},registerDestroyer:function(e){return w.push(e)},invalidateLayout:function(){return a.layoutCalculated=!1},dispatch:e.dispatch,query:e.query}),q={element:{get:G},childViews:{get:U},rect:{get:B},resting:{get:function(){return m}},isRectIgnored:function(){return P},_read:function(){T=null,g.forEach(function(e){return e._read()}),!(M&&E.width&&E.height)&&D(E,a,p);var e={root:Y,props:r,rect:E};C.forEach(function(t){return t(e)})},_write:function(e,t,n){var o=0===t.length;return L.forEach(function(i){!1===i({props:r,root:Y,actions:t,timestamp:e,shouldOptimize:n})&&(o=!1)}),h.forEach(function(t){!1===t.write(e)&&(o=!1)}),g.filter(function(e){return!!e.element.parentNode}).forEach(function(r){r._write(e,R(r,t),n)||(o=!1)}),g.forEach(function(r,i){r.element.parentNode||(Y.appendChild(r.element,i),r._read(),r._write(e,R(r,t),n),o=!1)}),m=o,A({props:r,root:Y,actions:t,timestamp:e}),o},_destroy:function(){h.forEach(function(e){return e.destroy()}),w.forEach(function(e){e({root:Y,props:r})}),g.forEach(function(e){return e._destroy()})}},x=Object.assign({},V,{rect:{get:function(){return E}}});Object.keys(N).sort(function(e,t){return"styles"===e?1:"styles"===t?-1:0}).forEach(function(e){var t=O[e]({mixinConfig:N[e],viewProps:r,viewState:b,viewInternalAPI:F,viewExternalAPI:q,view:o(x)});t&&h.push(t)});var Y=o(F);I({root:Y,props:r});var j=a.children.length;return g.forEach(function(e,t){Y.appendChild(e.element,j+t)}),S(Y),o(q)}},y=function(e,t){return function(n){var r=n.root,o=n.props,i=n.actions,a=void 0===i?[]:i,s=n.timestamp,u=n.shouldOptimize;a.filter(function(t){return e[t.type]}).forEach(function(t){return e[t.type]({root:r,props:o,action:t.data,timestamp:s,shouldOptimize:u})}),t&&t({root:r,props:o,actions:a,timestamp:s,shouldOptimize:u})}},A=function(e,t){return t.parentNode.insertBefore(e,t)},b=function(e,t){return t.parentNode.insertBefore(e,t.nextSibling)},P=function(e){return Array.isArray(e)},L=function(e){return null==e},M=function(e){return e.trim()},C=function(e){return""+e},N=function(e){return"boolean"==typeof e},w=function(e){return N(e)?e:"true"===e},G=function(e){return"string"==typeof e},U=function(e){return E(e)?e:G(e)?C(e).replace(/[a-z]+/gi,""):0},B=function(e){return parseInt(U(e),10)},V=function(e){return E(e)&&isFinite(e)&&Math.floor(e)===e},F=function(e){if(V(e))return e;var t=C(e).trim();return/MB$/i.test(t)?(t=t.replace(/MB$i/,"").trim(),1e3*B(t)*1e3):/KB/i.test(t)?(t=t.replace(/KB$i/,"").trim(),1e3*B(t)):B(t)},q=function(e){return"function"==typeof e},x={process:"POST",revert:"DELETE",fetch:"GET",restore:"GET",load:"GET"},Y=function(e,t,n,r){if(null===t)return null;if("function"==typeof t)return t;var o={url:"GET"===n?"?"+e+"=":"",method:n,headers:{},withCredentials:!1,timeout:r,onload:null,ondata:null,onerror:null};if(G(t))return o.url=t,o;if(Object.assign(o,t),G(o.headers)){var i=o.headers.split(/:(.+)/);o.headers={header:i[0],value:i[1]}}return o.withCredentials=w(o.withCredentials),o},j=function(e){return"object"==typeof e&&null!==e},H=function(e){return P(e)?"array":function(e){return null===e}(e)?"null":V(e)?"int":/^[0-9]+ ?(?:GB|MB|KB)$/gi.test(e)?"bytes":function(e){return j(e)&&G(e.url)&&j(e.process)&&j(e.revert)&&j(e.restore)&&j(e.fetch)}(e)?"api":typeof e},X={array:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:",";return L(e)?[]:P(e)?e:C(e).split(t).map(M).filter(function(e){return e.length})},boolean:w,int:function(e){return"bytes"===H(e)?F(e):B(e)},float:function(e){return parseFloat(U(e))},bytes:F,string:function(e){return q(e)?e:C(e)},serverapi:function(e){return(n={}).url=G(t=e)?t:t.url||"",n.timeout=t.timeout?parseInt(t.timeout,10):0,r(x,function(e){n[e]=Y(e,t[e],x[e],n.timeout)}),n.remove=t.remove||null,n;var t,n},object:function(e){try{return JSON.parse(e.replace(/{\s*'/g,'{"').replace(/'\s*}/g,'"}').replace(/'\s*:/g,'":').replace(/:\s*'/g,':"').replace(/,\s*'/g,',"').replace(/'\s*,/g,'",'))}catch(e){return null}},function:function(e){return function(e){for(var t=self,n=e.split("."),r=null;r=n.shift();)if(!(t=t[r]))return null;return t}(e)}},W=function(e,t,n){if(e===t)return e;var r,o=H(e);if(o!==n){var i=(r=e,X[n](r));if(o=H(i),null===i)throw'Trying to assign value with incorrect type to "'+option+'", allowed type: "'+n+'"';e=i}return e},z=function(e){var t={};return r(e,function(n){var r,o,i,a=e[n];t[n]=(r=a[0],o=a[1],i=r,{enumerable:!0,get:function(){return i},set:function(e){i=W(e,r,o)}})}),o(t)},k=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"-";return e.split(/(?=[A-Z])/).map(function(e){return e.toLowerCase()}).join(t)},Q=function(e){return function(t,n,o){var i={};return r(e,function(e){var n=k(e,"_").toUpperCase();i["SET_"+n]=function(r){try{o.options[e]=r.value}catch(e){}t("DID_SET_"+n,{value:o.options[e]})}}),i}},Z=function(e){return function(t){var n={};return r(e,function(e){n["GET_"+k(e,"_").toUpperCase()]=function(n){return t.options[e]}}),n}},$=1,K=2,J=3,ee=4,te=5,ne=function(){return Math.random().toString(36).substr(2,9)},re=function(e,t){return e.splice(t,1)},oe=function(){var e=[],t=function(t,n){re(e,e.findIndex(function(e){return e.event===t&&(e.cb===n||!n)}))};return{fire:function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];e.filter(function(e){return e.event===t}).map(function(e){return e.cb}).forEach(function(e){setTimeout(function(){e.apply(void 0,r)},0)})},on:function(t,n){e.push({event:t,cb:n})},onOnce:function(n,r){e.push({event:n,cb:function(){t(n,r),r.apply(void 0,arguments)}})},off:t}},ie=function(e,t,n){Object.getOwnPropertyNames(e).filter(function(e){return!n.includes(e)}).forEach(function(n){return Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(e,n))})},ae=["fire","process","revert","load","on","off","onOnce","retryLoad","extend","archive","archived","release","released","requestProcessing","freeze"],se=function(e){var t={};return ie(e,t,ae),t},ue={INIT:1,IDLE:2,PROCESSING_QUEUED:9,PROCESSING:3,PROCESSING_COMPLETE:5,PROCESSING_ERROR:6,PROCESSING_REVERT_ERROR:10,LOADING:7,LOAD_ERROR:8},le=function(e){return/[^0-9]+/.exec(e)},ce=function(){return le(1.1.toLocaleString())[0]},fe={BOOLEAN:"boolean",INT:"int",STRING:"string",ARRAY:"array",OBJECT:"object",FUNCTION:"function",ACTION:"action",SERVER_API:"serverapi",REGEX:"regex"},pe=[],de=function(e,t,n){return new Promise(function(r,o){var i=pe.filter(function(t){return t.key===e}).map(function(e){return e.cb});if(0!==i.length){var a=i.shift();i.reduce(function(e,t){return e.then(function(e){return t(e,n)})},a(t,n)).then(function(e){return r(e)}).catch(function(e){return o(e)})}else r(t)})},Ee=function(e,t,n){return pe.filter(function(t){return t.key===e}).map(function(e){return e.cb(t,n)})},_e=function(e,t){return pe.push({key:e,cb:t})},Te=function(){return Object.assign({},Ie)},Ie={id:[null,fe.STRING],name:["filepond",fe.STRING],disabled:[!1,fe.BOOLEAN],className:[null,fe.STRING],required:[!1,fe.BOOLEAN],captureMethod:[null,fe.STRING],allowDrop:[!0,fe.BOOLEAN],allowBrowse:[!0,fe.BOOLEAN],allowPaste:[!0,fe.BOOLEAN],allowMultiple:[!1,fe.BOOLEAN],allowReplace:[!0,fe.BOOLEAN],allowRevert:[!0,fe.BOOLEAN],forceRevert:[!1,fe.BOOLEAN],maxFiles:[null,fe.INT],checkValidity:[!1,fe.BOOLEAN],itemInsertLocationFreedom:[!0,fe.BOOLEAN],itemInsertLocation:["before",fe.STRING],itemInsertInterval:[75,fe.INT],dropOnPage:[!1,fe.BOOLEAN],dropOnElement:[!0,fe.BOOLEAN],dropValidation:[!1,fe.BOOLEAN],ignoredFiles:[[".ds_store","thumbs.db","desktop.ini"],fe.ARRAY],instantUpload:[!0,fe.BOOLEAN],maxParallelUploads:[2,fe.INT],server:[null,fe.SERVER_API],labelDecimalSeparator:[ce(),fe.STRING],labelThousandsSeparator:[(t=ce(),n=1e3.toLocaleString(),n!==1e3.toString()?le(n)[0]:"."===t?",":"."),fe.STRING],labelIdle:['Drag & Drop your files or <span class="filepond--label-action">Browse</span>',fe.STRING],labelInvalidField:["Field contains invalid files",fe.STRING],labelFileWaitingForSize:["Waiting for size",fe.STRING],labelFileSizeNotAvailable:["Size not available",fe.STRING],labelFileCountSingular:["file in list",fe.STRING],labelFileCountPlural:["files in list",fe.STRING],labelFileLoading:["Loading",fe.STRING],labelFileAdded:["Added",fe.STRING],labelFileLoadError:["Error during load",fe.STRING],labelFileRemoved:["Removed",fe.STRING],labelFileRemoveError:["Error during remove",fe.STRING],labelFileProcessing:["Uploading",fe.STRING],labelFileProcessingComplete:["Upload complete",fe.STRING],labelFileProcessingAborted:["Upload cancelled",fe.STRING],labelFileProcessingError:["Error during upload",fe.STRING],labelFileProcessingRevertError:["Error during revert",fe.STRING],labelTapToCancel:["tap to cancel",fe.STRING],labelTapToRetry:["tap to retry",fe.STRING],labelTapToUndo:["tap to undo",fe.STRING],labelButtonRemoveItem:["Remove",fe.STRING],labelButtonAbortItemLoad:["Abort",fe.STRING],labelButtonRetryItemLoad:["Retry",fe.STRING],labelButtonAbortItemProcessing:["Cancel",fe.STRING],labelButtonUndoItemProcessing:["Undo",fe.STRING],labelButtonRetryItemProcessing:["Retry",fe.STRING],labelButtonProcessItem:["Upload",fe.STRING],iconRemove:['<svg width="26" height="26" viewBox="0 0 26 26" xmlns="http://www.w3.org/2000/svg"><path d="M11.586 13l-2.293 2.293a1 1 0 0 0 1.414 1.414L13 14.414l2.293 2.293a1 1 0 0 0 1.414-1.414L14.414 13l2.293-2.293a1 1 0 0 0-1.414-1.414L13 11.586l-2.293-2.293a1 1 0 0 0-1.414 1.414L11.586 13z" fill="currentColor" fill-rule="nonzero"/></svg>',fe.STRING],iconProcess:['<svg width="26" height="26" viewBox="0 0 26 26" xmlns="http://www.w3.org/2000/svg"><path d="M14 10.414v3.585a1 1 0 0 1-2 0v-3.585l-1.293 1.293a1 1 0 0 1-1.414-1.415l3-3a1 1 0 0 1 1.414 0l3 3a1 1 0 0 1-1.414 1.415L14 10.414zM9 18a1 1 0 0 1 0-2h8a1 1 0 0 1 0 2H9z" fill="currentColor" fill-rule="evenodd"/></svg>',fe.STRING],iconRetry:['<svg width="26" height="26" viewBox="0 0 26 26" xmlns="http://www.w3.org/2000/svg"><path d="M10.81 9.185l-.038.02A4.997 4.997 0 0 0 8 13.683a5 5 0 0 0 5 5 5 5 0 0 0 5-5 1 1 0 0 1 2 0A7 7 0 1 1 9.722 7.496l-.842-.21a.999.999 0 1 1 .484-1.94l3.23.806c.535.133.86.675.73 1.21l-.804 3.233a.997.997 0 0 1-1.21.73.997.997 0 0 1-.73-1.21l.23-.928v-.002z" fill="currentColor" fill-rule="nonzero"/></svg>',fe.STRING],iconUndo:['<svg width="26" height="26" viewBox="0 0 26 26" xmlns="http://www.w3.org/2000/svg"><path d="M9.185 10.81l.02-.038A4.997 4.997 0 0 1 13.683 8a5 5 0 0 1 5 5 5 5 0 0 1-5 5 1 1 0 0 0 0 2A7 7 0 1 0 7.496 9.722l-.21-.842a.999.999 0 1 0-1.94.484l.806 3.23c.133.535.675.86 1.21.73l3.233-.803a.997.997 0 0 0 .73-1.21.997.997 0 0 0-1.21-.73l-.928.23-.002-.001z" fill="currentColor" fill-rule="nonzero"/></svg>',fe.STRING],iconDone:['<svg width="26" height="26" viewBox="0 0 26 26" xmlns="http://www.w3.org/2000/svg"><path d="M18.293 9.293a1 1 0 0 1 1.414 1.414l-7.002 7a1 1 0 0 1-1.414 0l-3.998-4a1 1 0 1 1 1.414-1.414L12 15.586l6.294-6.293z" fill="currentColor" fill-rule="nonzero"/></svg>',fe.STRING],oninit:[null,fe.FUNCTION],onwarning:[null,fe.FUNCTION],onerror:[null,fe.FUNCTION],onactivatefile:[null,fe.FUNCTION],onaddfilestart:[null,fe.FUNCTION],onaddfileprogress:[null,fe.FUNCTION],onaddfile:[null,fe.FUNCTION],onprocessfilestart:[null,fe.FUNCTION],onprocessfileprogress:[null,fe.FUNCTION],onprocessfileabort:[null,fe.FUNCTION],onprocessfilerevert:[null,fe.FUNCTION],onprocessfile:[null,fe.FUNCTION],onprocessfiles:[null,fe.FUNCTION],onremovefile:[null,fe.FUNCTION],onpreparefile:[null,fe.FUNCTION],onupdatefiles:[null,fe.FUNCTION],beforeAddFile:[null,fe.FUNCTION],beforeRemoveFile:[null,fe.FUNCTION],stylePanelLayout:[null,fe.STRING],stylePanelAspectRatio:[null,fe.STRING],styleItemPanelAspectRatio:[null,fe.STRING],styleButtonRemoveItemPosition:["left",fe.STRING],styleButtonProcessItemPosition:["right",fe.STRING],styleLoadIndicatorPosition:["right",fe.STRING],styleProgressIndicatorPosition:["right",fe.STRING],files:[[],fe.ARRAY]},me=function(e,t){return L(t)?e[0]||null:V(t)?e[t]||null:("object"==typeof t&&(t=t.id),e.find(function(e){return e.id===t})||null)},ve=function(e){if(L(e))return e;if(/:/.test(e)){var t=e.split(":");return t[1]/t[0]}return parseFloat(e)},ge=function(e){return e.filter(function(e){return!e.archived})},Re={EMPTY:0,IDLE:1,ERROR:2,BUSY:3,READY:4},he=[ue.LOAD_ERROR,ue.PROCESSING_ERROR,ue.PROCESSING_REVERT_ERROR],Oe=[ue.LOADING,ue.PROCESSING,ue.PROCESSING_QUEUED,ue.INIT],De=[ue.PROCESSING_COMPLETE],Se=function(e){return he.includes(e.status)},ye=function(e){return Oe.includes(e.status)},Ae=function(e){return De.includes(e.status)},be=function(e){return{GET_STATUS:function(){var t=ge(e.items),n=Re.EMPTY,r=Re.ERROR,o=Re.BUSY,i=Re.IDLE,a=Re.READY;return 0===t.length?n:t.some(Se)?r:t.some(ye)?o:t.some(Ae)?a:i},GET_ITEM:function(t){return me(e.items,t)},GET_ACTIVE_ITEM:function(t){return me(ge(e.items),t)},GET_ACTIVE_ITEMS:function(t){return ge(e.items)},GET_ITEMS:function(t){return e.items},GET_ITEM_NAME:function(t){var n=me(e.items,t);return n?n.filename:null},GET_ITEM_SIZE:function(t){var n=me(e.items,t);return n?n.fileSize:null},GET_STYLES:function(){return Object.keys(e.options).filter(function(e){return/^style/.test(e)}).map(function(t){return{name:t,value:e.options[t]}})},GET_PANEL_ASPECT_RATIO:function(){return/circle/.test(e.options.stylePanelLayout)?1:ve(e.options.stylePanelAspectRatio)},GET_ITEM_PANEL_ASPECT_RATIO:function(){return e.options.styleItemPanelAspectRatio},GET_ITEMS_BY_STATUS:function(t){return ge(e.items).filter(function(e){return e.status===t})},GET_TOTAL_ITEMS:function(){return ge(e.items).length},IS_ASYNC:function(){return j(e.options.server)&&(j(e.options.server.process)||q(e.options.server.process))}}},Pe=function(e,t,n){return L(t)?null:void 0===n?(e.push(t),t):(r=n,o=0,i=e.length,function(e,t,n){e.splice(t,0,n)}(e,n=Math.max(Math.min(i,r),o),t),t);var r,o,i},Le=function(e){return/^\s*data:([a-z]+\/[a-z0-9-+.]+(;[a-z-]+=[a-z0-9-]+)?)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s]*)\s*$/i.test(e)},Me=function(e){return e.split("/").pop().split("?").shift()},Ce=function(e){return e.split(".").pop()},Ne=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return(t+e).slice(-t.length)},we=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Date;return e.getFullYear()+"-"+Ne(e.getMonth()+1,"00")+"-"+Ne(e.getDate(),"00")+"_"+Ne(e.getHours(),"00")+"-"+Ne(e.getMinutes(),"00")+"-"+Ne(e.getSeconds(),"00")},Ge=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,o="string"==typeof n?e.slice(0,e.size,n):e.slice(0,e.size,e.type);return o.lastModifiedDate=new Date,G(t)||(t=we()),t&&null===r&&Ce(t)?o.name=t:(r=r||function(e){if("string"!=typeof e)return"";var t=e.split("/").pop();return/svg/.test(t)?"svg":/zip|compressed/.test(t)?"zip":/plain/.test(t)?"txt":/msword/.test(t)?"doc":/[a-z]+/.test(t)?"jpeg"===t?"jpg":t:""}(o.type),o.name=t+(r?"."+r:"")),o},Ue=function(e,t){var n=window.BlobBuilder=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder||window.MSBlobBuilder;if(n){var r=new n;return r.append(e),r.getBlob(t)}return new Blob([e],{type:t})},Be=function(e){return(/^data:(.+);/.exec(e)||[])[1]||null},Ve=function(e){var t=Be(e);return function(e,t){for(var n=new ArrayBuffer(e.length),r=new Uint8Array(n),o=0;o<e.length;o++)r[o]=e.charCodeAt(o);return Ue(n,t)}(function(e){return atob(function(e){return e.split(",")[1].replace(/\s/g,"")}(e))}(e),t)},Fe=function(e){var t=e.match(/(?:filename="(.+)")|(?:filename=(.+))/)||[];return t[1]||t[2]},qe=function(e){if(/content-length:/i.test(e)){var t=e.match(/[0-9]+/)[0];return t?parseInt(t,10):null}return null},xe=function(e){return/x-content-transfer-id:/i.test(e)&&(e.split(":")[1]||"").trim()||null},Ye=function(e){var t={source:null,name:null,size:null},n=e.split("\n"),r=!0,o=!1,i=void 0;try{for(var a,s=n[Symbol.iterator]();!(r=(a=s.next()).done);r=!0){var u=a.value,l=Fe(u);if(l)t.name=l;else{var c=qe(u);if(c)t.size=c;else{var f=xe(u);f&&(t.source=f)}}}}catch(e){o=!0,i=e}finally{try{r||null==s.return||s.return()}finally{if(o)throw i}}return t},je=function(e){var t={source:null,complete:!1,progress:0,size:null,timestamp:null,duration:0,request:null},n=function(n){e?(t.timestamp=Date.now(),t.request=e(n,function(e){t.duration=Date.now()-t.timestamp,t.complete=!0,e instanceof Blob&&(e=Ge(e,Me(n))),r.fire("load",e instanceof Blob?e:e.body)},function(e){r.fire("error","string"==typeof e?{type:"error",code:0,body:e}:e)},function(e,n,o){o&&(t.size=o),t.duration=Date.now()-t.timestamp,e?(t.progress=n/o,r.fire("progress",t.progress)):t.progress=null},function(){r.fire("abort")},function(e){var n=Ye("string"==typeof e?e:e.headers);r.fire("meta",{size:t.size||n.size,filename:n.name,source:n.source})})):r.fire("error",{type:"error",body:"Can't load URL",code:400})},r=Object.assign({},oe(),{setSource:function(e){return t.source=e},getProgress:function(){return t.progress},abort:function(){t.request&&t.request.abort()},load:function(){var e,o,i=t.source;r.fire("init",i),i instanceof File?r.fire("load",i):i instanceof Blob?r.fire("load",Ge(i,i.name)):Le(i)?r.fire("load",Ge(Ve(i),e,null,o)):n(i)}});return r},He=function(e){return/GET|HEAD/.test(e)},Xe=function(e,t,n){var r={onheaders:function(){},onprogress:function(){},onload:function(){},ontimeout:function(){},onerror:function(){},onabort:function(){},abort:function(){o=!0,a.abort()}},o=!1,i=!1;n=Object.assign({method:"POST",headers:{},withCredentials:!1},n),t=encodeURI(t),He(n.method)&&e&&(t=""+t+encodeURIComponent("string"==typeof e?e:JSON.stringify(e)));var a=new XMLHttpRequest;return(He(n.method)?a:a.upload).onprogress=function(e){o||r.onprogress(e.lengthComputable,e.loaded,e.total)},a.onreadystatechange=function(){a.readyState<2||4===a.readyState&&0===a.status||i||(i=!0,r.onheaders(a))},a.onload=function(){a.status>=200&&a.status<300?r.onload(a):r.onerror(a)},a.onerror=function(){return r.onerror(a)},a.onabort=function(){o=!0,r.onabort()},a.ontimeout=function(){return r.ontimeout(a)},a.open(n.method,t,!0),V(n.timeout)&&(a.timeout=n.timeout),Object.keys(n.headers).forEach(function(e){a.setRequestHeader(e,n.headers[e])}),n.responseType&&(a.responseType=n.responseType),n.withCredentials&&(a.withCredentials=!0),a.send(e),r},We=function(e,t,n,r){return{type:e,code:t,body:n,headers:r}},ze=function(e){return function(t){e(We("error",0,"Timeout",t.getAllResponseHeaders()))}},ke=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1?arguments[1]:void 0;if("function"==typeof t)return t;if(!t||!G(t.url))return null;var n=t.onload||function(e){return e},r=t.onerror||function(e){return null};return function(o,i,a,s,u,l){var c=Xe(o,e+t.url,Object.assign({},t,{responseType:"blob"}));return c.onload=function(e){var t=e.getAllResponseHeaders(),r=Ye(t).name||Me(o);i(We("load",e.status,Ge(n(e.response),r),t))},c.onerror=function(e){a(We("error",e.status,r(e.response)||e.statusText,e.getAllResponseHeaders()))},c.onheaders=function(e){l(We("headers",e.status,null,e.getAllResponseHeaders()))},c.ontimeout=ze(a),c.onprogress=s,c.onabort=u,c}},Qe=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1?arguments[1]:void 0;if("function"==typeof t)return t;if(!t||!G(t.url))return function(e,t){return t()};var n=t.onload||function(e){return e},r=t.onerror||function(e){return null};return function(o,i,a){var s=Xe(o,e+t.url,t);return s.onload=function(e){i(We("load",e.status,n(e.response),e.getAllResponseHeaders()))},s.onerror=function(e){a(We("error",e.status,r(e.response)||e.statusText,e.getAllResponseHeaders()))},s.ontimeout=ze(a),s}},Ze=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return e+Math.random()*(t-e)},$e=function(e){var t={complete:!1,perceivedProgress:0,perceivedPerformanceUpdater:null,progress:null,timestamp:null,perceivedDuration:0,duration:0,request:null,response:null},n=function(){t.request&&(t.perceivedPerformanceUpdater.clear(),t.request.abort(),t.complete=!0)},r=Object.assign({},oe(),{process:function(n,o){var i=function(){0!==t.duration&&null!==t.progress&&r.fire("progress",r.getProgress())},a=function(){t.complete=!0,r.fire("load-perceived",t.response.body)};r.fire("start"),t.timestamp=Date.now(),t.perceivedPerformanceUpdater=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e3,n=(arguments.length>2&&void 0!==arguments[2]&&arguments[2],arguments.length>3&&void 0!==arguments[3]?arguments[3]:25),r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:250,o=null,i=Date.now();return function a(){var s=Date.now()-i,u=Ze(n,r);s+u>t&&(u=s+u-t);var l=s/t;l>=1?e(1):(e(l),o=setTimeout(a,u))}(),{clear:function(){clearTimeout(o)}}}(function(e){t.perceivedProgress=e,t.perceivedDuration=Date.now()-t.timestamp,i(),t.response&&1===t.perceivedProgress&&!t.complete&&a()},Ze(750,1500)),t.request=e(n,o,function(e){t.response=j(e)?e:{type:"load",code:200,body:""+e,headers:{}},t.duration=Date.now()-t.timestamp,t.progress=1,r.fire("load",t.response.body),1===t.perceivedProgress&&a()},function(e){t.perceivedPerformanceUpdater.clear(),r.fire("error",j(e)?e:{type:"error",code:0,body:""+e})},function(e,n,r){t.duration=Date.now()-t.timestamp,t.progress=e?n/r:null,i()},function(){t.perceivedPerformanceUpdater.clear(),r.fire("abort",t.response?t.response.body:null)})},abort:n,getProgress:function(){return t.progress?Math.min(t.progress,t.perceivedProgress):null},getDuration:function(){return Math.min(t.duration,t.perceivedDuration)},reset:function(){n(),t.complete=!1,t.perceivedProgress=0,t.progress=0,t.timestamp=null,t.perceivedDuration=0,t.duration=0,t.request=null,t.response=null}});return r},Ke=function(e){return e.substr(0,e.lastIndexOf("."))||e},Je={INPUT:1,LIMBO:2,LOCAL:3},et=function(e){return e instanceof File||e instanceof Blob&&e.name},tt=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,r=ne(),i={archived:!1,frozen:!1,released:!1,source:null,file:n,serverFileReference:t,status:t?ue.PROCESSING_COMPLETE:ue.INIT,activeLoader:null,activeProcessor:null},a=null,s={},u=function(e){return i.status=e},l=function(e){if(!i.released&&!i.frozen){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];f.fire.apply(f,[e].concat(n))}},c=function(e,t,n){var r=e.split("."),o=r[0],i=r.pop(),a=s;r.forEach(function(e){return a=a[e]}),JSON.stringify(a[i])!==JSON.stringify(t)&&(a[i]=t,n||l("metadata-update",{key:o,value:s[o]}))},f=Object.assign({id:{get:function(){return r}},origin:{get:function(){return e}},serverId:{get:function(){return i.serverFileReference}},status:{get:function(){return i.status}},filename:{get:function(){return i.file.name}},filenameWithoutExtension:{get:function(){return Ke(i.file.name)}},fileExtension:{get:function(){return Ce(i.file.name)}},fileType:{get:function(){return i.file.type}},fileSize:{get:function(){return i.file.size}},file:{get:function(){return i.file}},source:{get:function(){return i.source}},getMetadata:function(e){return function e(t){if(!j(t))return t;var n=P(t)?[]:{};for(var r in t)if(t.hasOwnProperty(r)){var o=t[r];n[r]=o&&j(o)?e(o):o}return n}(e?s[e]:s)},setMetadata:function(e,t,n){if(j(e)){var r=e;return Object.keys(r).forEach(function(e){c(e,r[e],t)}),e}return c(e,t,n),t},extend:function(e,t){return p[e]=t},abortLoad:function(){i.activeLoader?i.activeLoader.abort():(u(ue.INIT),l("load-abort"))},retryLoad:function(){i.activeLoader&&i.activeLoader.load()},requestProcessing:function(){u(ue.PROCESSING_QUEUED)},abortProcessing:function(){return new Promise(function(e){if(!i.activeProcessor)return u(ue.IDLE),l("process-abort"),void e();a=function(){e()},i.activeProcessor.abort()})},load:function(t,n,r){i.source=t,i.file?l("load-skip"):(i.file=function(e){var t=[e.name,e.size,e.type];return e instanceof Blob||Le(e)?t[0]=e.name||we():Le(e)?(t[1]=e.length,t[2]=Be(e)):G(e)&&(t[0]=Me(e),t[1]=0,t[2]="application/octet-stream"),{name:t[0],size:t[1],type:t[2]}}(t),n.on("init",function(){l("load-init")}),n.on("meta",function(t){i.file.size=t.size,i.file.filename=t.filename,t.source&&(e=Je.LIMBO,i.serverFileReference=t.source,i.status=ue.PROCESSING_COMPLETE),l("load-meta")}),n.on("progress",function(e){u(ue.LOADING),l("load-progress",e)}),n.on("error",function(e){u(ue.LOAD_ERROR),l("load-request-error",e)}),n.on("abort",function(){u(ue.INIT),l("load-abort")}),n.on("load",function(t){i.activeLoader=null;var n=function(t){i.file=et(t)?t:i.file,e===Je.LIMBO&&i.serverFileReference?u(ue.PROCESSING_COMPLETE):u(ue.IDLE),l("load")};i.serverFileReference?n(t):r(t,n,function(e){i.file=t,l("load-meta"),u(ue.LOAD_ERROR),l("load-file-error",e)})}),n.setSource(t),i.activeLoader=n,n.load())},process:function e(t,n){u(ue.PROCESSING),a=null,i.file instanceof Blob?(t.on("load",function(e){i.serverFileReference=e}),t.on("load-perceived",function(e){i.activeProcessor=null,i.serverFileReference=e,u(ue.PROCESSING_COMPLETE),l("process-complete",e)}),t.on("start",function(){l("process-start")}),t.on("error",function(e){i.activeProcessor=null,u(ue.PROCESSING_ERROR),l("process-error",e)}),t.on("abort",function(e){i.activeProcessor=null,i.serverFileReference=e,u(ue.IDLE),l("process-abort"),a&&a()}),t.on("progress",function(e){l("process-progress",e)}),n(i.file,function(e){i.archived||t.process(e,Object.assign({},s))},function(e){}),i.activeProcessor=t):f.on("load",function(){e(t,n)})},revert:function(e,t){return new Promise(function(n,r){null!==i.serverFileReference?(e(i.serverFileReference,function(){i.serverFileReference=null,n()},function(e){t?(u(ue.PROCESSING_REVERT_ERROR),l("process-revert-error"),r(e)):n()}),u(ue.IDLE),l("process-revert")):n()})}},oe(),{freeze:function(){return i.frozen=!0},release:function(){return i.released=!0},released:{get:function(){return i.released}},archive:function(){return i.archived=!0},archived:{get:function(){return i.archived}}}),p=o(f);return p},nt=function(e,t){var n=function(e,t){return L(t)?0:G(t)?e.findIndex(function(e){return e.id===t}):-1}(e,t);if(!(n<0))return e[n]||null},rt=function(e,t,n,r,o,i){var a=Xe(null,e,{method:"GET",responseType:"blob"});return a.onload=function(n){var r=n.getAllResponseHeaders(),o=Ye(r).name||Me(e);t(We("load",n.status,Ge(n.response,o),r))},a.onerror=function(e){n(We("error",e.status,e.statusText,e.getAllResponseHeaders()))},a.onheaders=function(e){i(We("headers",e.status,null,e.getAllResponseHeaders()))},a.ontimeout=ze(n),a.onprogress=r,a.onabort=o,a},ot=function(e){return 0===e.indexOf("//")&&(e=location.protocol+e),e.toLowerCase().replace("blob:","").replace(/([a-z])?:\/\//,"$1").split("/")[0]},it=function(e){return function(){return q(e)?e.apply(void 0,arguments):e}},at=function(e,t){clearTimeout(t.listUpdateTimeout),t.listUpdateTimeout=setTimeout(function(){e("DID_UPDATE_ITEMS",{items:ge(t.items)})},0)},st=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return new Promise(function(t){if(!e)return t(!0);var r=e.apply(void 0,n);return null==r?t(!0):"boolean"==typeof r?t(r):void("function"==typeof r.then&&r.then(t))})},ut=function(e,t){e.items.sort(function(e,n){return t(se(e),se(n))})},lt=function(e,t){return function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=n.query,o=n.success,i=void 0===o?function(){}:o,a=n.failure,s=void 0===a?function(){}:a,u=me(e.items,r);u?t(u,i,s):s({error:We("error",0,"Item not found"),file:null})}},ct=function(e,t,n){return{ABORT_ALL:function(){ge(n.items).forEach(function(e){e.freeze(),e.abortLoad(),e.abortProcessing()})},DID_SET_FILES:function(t){var r=t.value,o=(void 0===r?[]:r).map(function(e){return{source:e.source?e.source:e,options:e.options}}),i=ge(n.items);i.forEach(function(t){o.find(function(e){return e.source===t.source||e.source===t.file})||e("REMOVE_ITEM",{query:t})}),i=ge(n.items),o.forEach(function(t,n){i.find(function(e){return e.source===t.source||e.file===t.source})||e("ADD_ITEM",Object.assign({},t,{interactionMethod:te,index:n}))})},DID_UPDATE_ITEM_METADATA:function(r){var o=r.id,i=(r.change,nt(n.items,o));if(t("IS_ASYNC")){var a,s=function(){setTimeout(function(){e("REQUEST_ITEM_PROCESSING",{query:o})},32)};return i.status===ue.PROCESSING_COMPLETE?(a=n.options.instantUpload,void i.revert(Qe(n.options.server.url,n.options.server.revert),t("GET_FORCE_REVERT")).then(a?s:function(){}).catch(function(){})):i.status===ue.PROCESSING?function(e){i.abortProcessing().then(e?s:function(){})}(n.options.instantUpload):void(n.options.instantUpload&&s())}de("SHOULD_PREPARE_OUTPUT",!1,{item:i,query:t}).then(function(t){t&&e("REQUEST_PREPARE_OUTPUT",{query:o,item:i,ready:function(t){e("DID_PREPARE_OUTPUT",{id:o,file:t})}},!0)})},SORT:function(e){var t=e.compare;ut(n,t)},ADD_ITEMS:function(n){var r=n.items,o=n.index,i=n.interactionMethod,a=n.success,s=void 0===a?function(){}:a,u=n.failure,l=void 0===u?function(){}:u,c=o;if(-1===o||void 0===o){var f=t("GET_ITEM_INSERT_LOCATION"),p=t("GET_TOTAL_ITEMS");c="before"===f?0:p}var d=t("GET_IGNORED_FILES"),E=r.filter(function(e){return et(e)?!d.includes(e.name.toLowerCase()):!L(e)}).map(function(t){return new Promise(function(n,r){e("ADD_ITEM",{interactionMethod:i,source:t.source||t,success:n,failure:r,index:c++,options:t.options||{}})})});Promise.all(E).then(s).catch(l)},ADD_ITEM:function(r){var o=r.source,i=r.index,a=void 0===i?-1:i,s=r.interactionMethod,u=r.success,l=void 0===u?function(){}:u,c=r.failure,f=void 0===c?function(){}:c,p=r.options,d=void 0===p?{}:p;if(L(o))f({error:We("error",0,"No source"),file:null});else if(!et(o)||!n.options.ignoredFiles.includes(o.name.toLowerCase())){if(!function(e){var t=ge(e.items).length;if(!e.options.allowMultiple)return 0===t;var n=e.options.maxFiles;return null===n||t<n}(n)){if(n.options.allowMultiple||!n.options.allowMultiple&&!n.options.allowReplace){var E=We("warning",0,"Max files");return e("DID_THROW_MAX_FILES",{source:o,error:E}),void f({error:E,file:null})}var _=ge(n.items)[0];if(_.status===ue.PROCESSING_COMPLETE||_.status===ue.PROCESSING_REVERT_ERROR){var T=t("GET_FORCE_REVERT");if(_.revert(Qe(n.options.server.url,n.options.server.revert),T).then(function(){T&&e("ADD_ITEM",{source:o,index:a,interactionMethod:s,success:l,failure:f,options:d})}).catch(function(){}),T)return}e("REMOVE_ITEM",{query:_.id})}var I="local"===d.type?Je.LOCAL:"limbo"===d.type?Je.LIMBO:Je.INPUT,m=tt(I,I===Je.INPUT?null:o,d.file);Object.keys(d.metadata||{}).forEach(function(e){m.setMetadata(e,d.metadata[e])}),Ee("DID_CREATE_ITEM",m,{query:t,dispatch:e});var v=t("GET_ITEM_INSERT_LOCATION");n.options.itemInsertLocationFreedom||(a="before"===v?-1:n.items.length),Pe(n.items,m,a),q(v)&&o&&ut(n,v);var g=m.id;m.on("load-init",function(){e("DID_START_ITEM_LOAD",{id:g})}),m.on("load-meta",function(){e("DID_UPDATE_ITEM_META",{id:g})}),m.on("load-progress",function(t){e("DID_UPDATE_ITEM_LOAD_PROGRESS",{id:g,progress:t})}),m.on("load-request-error",function(t){var r=it(n.options.labelFileLoadError)(t);if(t.code>=400&&t.code<500)return e("DID_THROW_ITEM_INVALID",{id:g,error:t,status:{main:r,sub:t.code+" ("+t.body+")"}}),void f({error:t,file:se(m)});e("DID_THROW_ITEM_LOAD_ERROR",{id:g,error:t,status:{main:r,sub:n.options.labelTapToRetry}})}),m.on("load-file-error",function(t){e("DID_THROW_ITEM_INVALID",{id:g,error:t.status,status:t.status})}),m.on("load-abort",function(){e("REMOVE_ITEM",{query:g})}),m.on("load-skip",function(){e("COMPLETE_LOAD_ITEM",{query:g,item:m,data:{source:o,success:l}})}),m.on("load",function(){var r=function(r){r?(m.on("metadata-update",function(t){e("DID_UPDATE_ITEM_METADATA",{id:g,change:t})}),de("SHOULD_PREPARE_OUTPUT",!1,{item:m,query:t}).then(function(t){var r=function(){e("COMPLETE_LOAD_ITEM",{query:g,item:m,data:{source:o,success:l}}),at(e,n)};t?e("REQUEST_PREPARE_OUTPUT",{query:g,item:m,ready:function(t){e("DID_PREPARE_OUTPUT",{id:g,file:t}),r()}},!0):r()})):e("REMOVE_ITEM",{query:g})};de("DID_LOAD_ITEM",m,{query:t,dispatch:e}).then(function(){st(t("GET_BEFORE_ADD_FILE"),se(m)).then(r)}).catch(function(){r(!1)})}),m.on("process-start",function(){e("DID_START_ITEM_PROCESSING",{id:g})}),m.on("process-progress",function(t){e("DID_UPDATE_ITEM_PROCESS_PROGRESS",{id:g,progress:t})}),m.on("process-error",function(t){e("DID_THROW_ITEM_PROCESSING_ERROR",{id:g,error:t,status:{main:it(n.options.labelFileProcessingError)(t),sub:n.options.labelTapToRetry}})}),m.on("process-revert-error",function(t){e("DID_THROW_ITEM_PROCESSING_REVERT_ERROR",{id:g,error:t,status:{main:it(n.options.labelFileProcessingRevertError)(t),sub:n.options.labelTapToRetry}})}),m.on("process-complete",function(t){e("DID_COMPLETE_ITEM_PROCESSING",{id:g,error:null,serverFileReference:t})}),m.on("process-abort",function(){e("DID_ABORT_ITEM_PROCESSING",{id:g})}),m.on("process-revert",function(){e("DID_REVERT_ITEM_PROCESSING",{id:g})}),e("DID_ADD_ITEM",{id:g,index:a,interactionMethod:s}),at(e,n);var R=n.options.server||{},h=R.url,O=R.load,D=R.restore,S=R.fetch;m.load(o,je(I===Je.INPUT?G(o)&&function(e){return(e.indexOf(":")>-1||e.indexOf("//")>-1)&&ot(location.href)!==ot(e)}(o)?ke(h,S):rt:ke(h,I===Je.LIMBO?D:O)),function(e,n,r){de("LOAD_FILE",e,{query:t}).then(n).catch(r)})}},REQUEST_PREPARE_OUTPUT:function(e){var n=e.item,r=e.ready;n.archived||de("PREPARE_OUTPUT",n.file,{query:t,item:n}).then(function(e){de("COMPLETE_PREPARE_OUTPUT",e,{query:t,item:n}).then(function(e){n.archived||r(e)})})},COMPLETE_LOAD_ITEM:function(r){var o=r.item,i=r.data,a=i.success,s=i.source,u=t("GET_ITEM_INSERT_LOCATION");q(u)&&s&&ut(n,u),e("DID_LOAD_ITEM",{id:o.id,error:null,serverFileReference:o.origin===Je.INPUT?null:s}),a(se(o)),o.origin!==Je.LOCAL?o.origin!==Je.LIMBO?t("IS_ASYNC")&&n.options.instantUpload&&e("REQUEST_ITEM_PROCESSING",{query:o.id}):e("DID_COMPLETE_ITEM_PROCESSING",{id:o.id,error:null,serverFileReference:s}):e("DID_LOAD_LOCAL_ITEM",{id:o.id})},RETRY_ITEM_LOAD:lt(n,function(e){e.retryLoad()}),REQUEST_ITEM_PROCESSING:lt(n,function(r,o,i){if(r.status===ue.IDLE||r.status===ue.PROCESSING_ERROR)r.status!==ue.PROCESSING_QUEUED&&(r.requestProcessing(),e("DID_REQUEST_ITEM_PROCESSING",{id:r.id}),e("PROCESS_ITEM",{query:r,success:o,failure:i},!0));else{var a=function(){setTimeout(function(){e("REQUEST_ITEM_PROCESSING",{query:r,success:o,failure:i})},32)};r.status===ue.PROCESSING_COMPLETE||r.status===ue.PROCESSING_REVERT_ERROR?r.revert(Qe(n.options.server.url,n.options.server.revert),t("GET_FORCE_REVERT")).then(a).catch(function(){}):r.status===ue.PROCESSING&&r.abortProcessing().then(a)}}),PROCESS_ITEM:lt(n,function(r,o,i){var a=t("GET_MAX_PARALLEL_UPLOADS");if(t("GET_ITEMS_BY_STATUS",ue.PROCESSING).length!==a){if(r.status!==ue.PROCESSING){var s=function(){var t=n.processingQueue.shift();t&&e("PROCESS_ITEM",{query:t.item,success:t.success,failure:t.failure},!0)};r.onOnce("process-complete",function(){o(se(r)),s(),t("GET_ITEMS_BY_STATUS",ue.PROCESSING_COMPLETE).length===n.items.length&&e("DID_COMPLETE_ITEM_PROCESSING_ALL")}),r.onOnce("process-error",function(e){i({error:e,file:se(r)}),s()}),r.process($e(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1?arguments[1]:void 0,n=arguments.length>2?arguments[2]:void 0;return"function"==typeof t?function(){for(var e=arguments.length,r=new Array(e),o=0;o<e;o++)r[o]=arguments[o];return t.apply(void 0,[n].concat(r))}:t&&G(t.url)?function(r,o,i,a,s,u){var l=t.ondata||function(e){return e},c=t.onload||function(e){return e},f=t.onerror||function(e){return null};if(r){var p=new FormData;j(o)&&p.append(n,JSON.stringify(o)),(r instanceof Blob?[{name:null,file:r}]:r).forEach(function(e){p.append(n,e.file,null===e.name?e.file.name:""+e.name+e.file.name)});var d=Xe(l(p),e+t.url,t);return d.onload=function(e){i(We("load",e.status,c(e.response),e.getAllResponseHeaders()))},d.onerror=function(e){a(We("error",e.status,f(e.response)||e.statusText,e.getAllResponseHeaders()))},d.ontimeout=ze(a),d.onprogress=s,d.onabort=u,d}}:null}(n.options.server.url,n.options.server.process,n.options.name)),function(n,o,i){de("PREPARE_OUTPUT",n,{query:t,item:r}).then(function(t){e("DID_PREPARE_OUTPUT",{id:r.id,file:t}),o(t)}).catch(i)})}}else n.processingQueue.push({item:r,success:o,failure:i})}),RETRY_ITEM_PROCESSING:lt(n,function(t){e("REQUEST_ITEM_PROCESSING",{query:t})}),REQUEST_REMOVE_ITEM:lt(n,function(n){st(t("GET_BEFORE_REMOVE_FILE"),se(n)).then(function(t){t&&e("REMOVE_ITEM",{query:n})})}),RELEASE_ITEM:lt(n,function(e){e.release()}),REMOVE_ITEM:lt(n,function(t,r){var o=function(){var o=t.id;nt(n.items,o).archive(),e("DID_REMOVE_ITEM",{error:null,id:o,item:t}),at(e,n),r(se(t))},i=n.options.server;t.origin===Je.LOCAL&&i&&q(i.remove)?(e("DID_START_ITEM_REMOVE",{id:t.id}),i.remove(t.source,function(){return o()},function(r){e("DID_THROW_ITEM_REMOVE_ERROR",{id:t.id,error:We("error",0,r,null),status:{main:it(n.options.labelFileRemoveError)(r),sub:n.options.labelTapToRetry}})})):o()}),ABORT_ITEM_LOAD:lt(n,function(e){e.abortLoad()}),ABORT_ITEM_PROCESSING:lt(n,function(t){t.serverId?e("REVERT_ITEM_PROCESSING",{id:t.id}):t.abortProcessing().then(function(){n.options.instantUpload&&e("REMOVE_ITEM",{query:t.id})})}),REQUEST_REVERT_ITEM_PROCESSING:lt(n,function(r){if(n.options.instantUpload){var o=function(t){t&&e("REVERT_ITEM_PROCESSING",{query:r})},i=t("GET_BEFORE_REMOVE_FILE");if(!i)return o(!0);var a=i(se(r));return null==a?o(!0):"boolean"==typeof a?o(a):void("function"==typeof a.then&&a.then(o))}e("REVERT_ITEM_PROCESSING",{query:r})}),REVERT_ITEM_PROCESSING:lt(n,function(r){r.revert(Qe(n.options.server.url,n.options.server.revert),t("GET_FORCE_REVERT")).then(function(){(n.options.instantUpload||function(e){return!et(e.file)}(r))&&e("REMOVE_ITEM",{query:r.id})}).catch(function(){})}),SET_OPTIONS:function(t){var n=t.options;r(n,function(t,n){e("SET_"+k(t,"_").toUpperCase(),{value:n})})}}},ft=function(e){return e},pt=function(e){return document.createElement(e)},dt=function(e,t){var n=e.childNodes[0];n?t!==n.nodeValue&&(n.nodeValue=t):(n=document.createTextNode(t),e.appendChild(n))},Et=function(e,t,n,r){var o=(r%360-90)*Math.PI/180;return{x:e+n*Math.cos(o),y:t+n*Math.sin(o)}},_t=function(e,t,n,r,o){var i=1;return o>r&&o-r<=.5&&(i=0),r>o&&r-o>=.5&&(i=0),function(e,t,n,r,o,i){var a=Et(e,t,n,o),s=Et(e,t,n,r);return["M",a.x,a.y,"A",n,n,0,i,0,s.x,s.y].join(" ")}(e,t,n,360*Math.min(.9999,r),360*Math.min(.9999,o),i)},Tt=S({tag:"div",name:"progress-indicator",ignoreRectUpdate:!0,ignoreRect:!0,create:function(e){var t=e.root,n=e.props;n.spin=!1,n.progress=0,n.opacity=0;var r=u("svg");t.ref.path=u("path",{"stroke-width":2,"stroke-linecap":"round"}),r.appendChild(t.ref.path),t.ref.svg=r,t.appendChild(r)},write:function(e){var t=e.root,n=e.props;if(0!==n.opacity){n.align&&(t.element.dataset.align=n.align);var r=parseInt(i(t.ref.path,"stroke-width"),10),o=.5*t.rect.element.width,a=0,s=0;n.spin?(a=0,s=.5):(a=0,s=n.progress);var u=_t(o,o,o-r,a,s);i(t.ref.path,"d",u),i(t.ref.path,"stroke-opacity",n.spin||n.progress>0?1:0)}},mixins:{apis:["progress","spin","align"],styles:["opacity"],animations:{opacity:{type:"tween",duration:500},progress:{type:"spring",stiffness:.95,damping:.65,mass:10}}}}),It=S({tag:"button",attributes:{type:"button"},ignoreRect:!0,ignoreRectUpdate:!0,name:"file-action-button",mixins:{apis:["label"],styles:["translateX","translateY","scaleX","scaleY","opacity"],animations:{scaleX:"spring",scaleY:"spring",translateX:"spring",translateY:"spring",opacity:{type:"tween",duration:250}},listeners:!0},create:function(e){var t=e.root,n=e.props;t.element.title=n.label,t.element.innerHTML=n.icon||"",n.isDisabled=!1},write:function(e){var t=e.root,n=e.props,r=n.isDisabled,o=t.query("GET_DISABLED")||0===n.opacity;o&&!r?(n.isDisabled=!0,i(t.element,"disabled","disabled")):!o&&r&&(n.isDisabled=!1,t.element.removeAttribute("disabled"))}}),mt=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:".";return(e=Math.round(Math.abs(e)))<1e3?e+" bytes":e<gt?Math.floor(e/vt)+" KB":e<Rt?ht(e/gt,1,t)+" MB":ht(e/Rt,2,t)+" GB"},vt=1e3,gt=1e6,Rt=1e9,ht=function(e,t,n){return e.toFixed(t).split(".").filter(function(e){return"0"!==e}).join(n)},Ot=function(e){var t=e.root,n=e.props;dt(t.ref.fileSize,mt(t.query("GET_ITEM_SIZE",n.id))),dt(t.ref.fileName,ft(t.query("GET_ITEM_NAME",n.id)))},Dt=function(e){var t=e.root,n=e.props;V(t.query("GET_ITEM_SIZE",n.id))||dt(t.ref.fileSize,t.query("GET_LABEL_FILE_SIZE_NOT_AVAILABLE"))},St=S({name:"file-info",ignoreRect:!0,ignoreRectUpdate:!0,write:y({DID_LOAD_ITEM:Ot,DID_UPDATE_ITEM_META:Ot,DID_THROW_ITEM_LOAD_ERROR:Dt,DID_THROW_ITEM_INVALID:Dt}),didCreateView:function(e){Ee("CREATE_VIEW",Object.assign({},e,{view:e}))},create:function(e){var t=e.root,n=e.props,r=pt("span");r.className="filepond--file-info-main",i(r,"aria-hidden","true"),t.appendChild(r),t.ref.fileName=r;var o=pt("span");o.className="filepond--file-info-sub",t.appendChild(o),t.ref.fileSize=o,dt(o,t.query("GET_LABEL_FILE_WAITING_FOR_SIZE")),dt(r,ft(t.query("GET_ITEM_NAME",n.id)))},mixins:{styles:["translateX","translateY"],animations:{translateX:"spring",translateY:"spring"}}}),yt=function(e){return Math.round(100*e)},At=function(e){var t=e.root,n=e.action,r=null===n.progress?t.query("GET_LABEL_FILE_LOADING"):t.query("GET_LABEL_FILE_LOADING")+" "+yt(n.progress)+"%";dt(t.ref.main,r)