UNPKG

uploadcare-widget

Version:
18 lines (17 loc) 305 kB
/** * @license uploadcare-widget v3.21.8 * * Copyright (c) 2024 Uploadcare, Inc. * * This source code is licensed under the BSD 2-Clause License * found in the LICENSE file in the root directory of this source tree. */ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("jquery")):"function"==typeof define&&define.amd?define(["jquery"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).uploadcare=t(e.$)}(this,(function(e){"use strict";function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=t(e);function n(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),a.push.apply(a,i)}return a}function r(e){for(var t=1;t<arguments.length;t++){var a=null!=arguments[t]?arguments[t]:{};t%2?n(Object(a),!0).forEach((function(t){p(e,t,a[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):n(Object(a)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))}))}return e}function o(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var a=e[Symbol.toPrimitive];if(void 0!==a){var i=a.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}function s(e){return(s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function c(e,t){for(var a=0;a<t.length;a++){var i=t[a];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,o(i.key),i)}}function d(e,t,a){return t&&c(e.prototype,t),a&&c(e,a),Object.defineProperty(e,"prototype",{writable:!1}),e}function p(e,t,a){return(t=o(t))in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}function f(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&m(e,t)}function h(e){return(h=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function m(e,t){return(m=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function g(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return g(e)}function v(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var a,i=h(e);if(t){var n=h(this).constructor;a=Reflect.construct(i,arguments,n)}else a=i.apply(this,arguments);return _(this,a)}}function b(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=h(e)););return e}function y(){return(y="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,a){var i=b(e,t);if(i){var n=Object.getOwnPropertyDescriptor(i,t);return n.get?n.get.call(arguments.length<3?e:a):n.value}}).apply(this,arguments)}function w(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var a=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var i,n,r,o,l=[],s=!0,u=!1;try{if(r=(a=a.call(e)).next,0===t){if(Object(a)!==a)return;s=!1}else for(;!(s=(i=r.call(a)).done)&&(l.push(i.value),l.length!==t);s=!0);}catch(e){u=!0,n=e}finally{try{if(!s&&null!=a.return&&(o=a.return(),Object(o)!==o))return}finally{if(u)throw n}}return l}}(e,t)||k(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function x(e){return function(e){if(Array.isArray(e))return z(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||k(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function k(e,t){if(e){if("string"==typeof e)return z(e,t);var a=Object.prototype.toString.call(e).slice(8,-1);return"Object"===a&&e.constructor&&(a=e.constructor.name),"Map"===a||"Set"===a?Array.from(e):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?z(e,t):void 0}}function z(e,t){(null==t||t>e.length)&&(t=e.length);for(var a=0,i=new Array(t);a<t;a++)i[a]=e[a];return i}var A=function(){var e;try{var t;return null!=(e=window.console)&&"function"==typeof e.log?(t=e).log.apply(t,arguments):void 0}catch(e){}},C=function(){var e;if(!(null!=(e=window.console)?e.debug:void 0))return A.apply(void 0,["Debug:"].concat(Array.prototype.slice.call(arguments)));try{var t;return(t=window.console).debug.apply(t,arguments)}catch(e){}},S=function(){var e;if(!(null!=(e=window.console)?e.warn:void 0))return A.apply(void 0,["Warning:"].concat(Array.prototype.slice.call(arguments)));try{var t;return(t=window.console).warn.apply(t,arguments)}catch(e){}},F={},T=function(e){if(null==F[e])return F[e]=!0,S(e)},j=function(){return"object"===("undefined"==typeof window?"undefined":s(window))},D=Object.freeze({__proto__:null,isWindowDefined:j});function I(e,t,a){var i;if("RequestThrottledError"===(null==e||null===(i=e.responseJSON)||void 0===i||null===(i=i.error)||void 0===i?void 0:i.error_code)&&a.attempt<t.throttledAttempts){var n=Number.parseFloat(e.getResponseHeader("retry-after"));return{shouldRetry:!0,retryTimeout:Number.isFinite(n)?Math.ceil(1e3*n):15e3}}return-1!==["error","timeout"].indexOf(e.statusText)&&a.attempt<t.attempts?{shouldRetry:!0,retryTimeout:Math.round(t.baseTimeout*Math.pow(t.factor,a.attempt))}:{shouldRetry:!1}}function P(e,t,i,n){var o=["baseTimeout","attempts","factor"].find((function(e){return void 0===i[e]}));if(o)return S('Option key "'.concat(o,'" is missed in the retry config.')),e;n={attempt:n.attempt||0,timeoutId:null,jqXHR:null},i=r({baseTimeout:null,attempts:null,factor:null,onAttemptFail:null,debugUploads:!1},i);var l=function(e,t,i,n){return function(){var o=a.default.Deferred();function l(){n.jqXHR=a.default.ajax(t).retry(i,r(r({},n),{},{attempt:n.attempt+1})).done(o.resolve).fail(o.reject)}for(var s,u=I(e,i,n),c=u.shouldRetry,d=u.retryTimeout,p=arguments.length,f=new Array(p),h=0;h<p;h++)f[h]=arguments[h];c?(null===(s=i.onAttemptFail)||void 0===s||s.call(i,{attempt:n.attempt}),i.debugUploads&&A("Attempt failed. Retry #".concat(n.attempt+1," in ").concat(d,"ms"),e),n.timeoutId=setTimeout(l,d)):"resolved"===e.state()?o.resolveWith(e,f):o.rejectWith(e,f);return o}}(e,t,i,n),s=e.then(l,l);return s.abort=function(){var t;clearTimeout(n.timeoutId);for(var a=arguments.length,i=new Array(a),r=0;r<a;r++)i[r]=arguments[r];e.abort.apply(e,i),null===(t=n.jqXHR)||void 0===t||t.abort.apply(t,i)},s}j()&&a.default.ajaxPrefilter((function(e,t,a){a.retry=function(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return P(a,e,t,i)}})),j()&&window.XDomainRequest&&a.default.ajaxTransport((function(e){var t;if(e.crossDomain&&e.async)return e.timeout&&(e.xdrTimeout=e.timeout,delete e.timeout),{send:function(a,i){function n(e,a,n,r){t.onload=t.onerror=t.ontimeout=function(){},t=void 0,i(e,a,n,r)}(t=new XDomainRequest).onload=function(){n(200,"OK",{text:t.responseText},"Content-Type: "+t.contentType)},t.onerror=function(){n(404,"Not Found")},t.onprogress=function(){},t.ontimeout=function(){n(0,"timeout")},t.timeout=e.xdrTimeout||Number.MAX_VALUE,t.open(e.type,e.url.replace(/^https?:/,"")),t.send(e.hasContent&&e.data||null)},abort:function(){t&&(t.onerror=function(){},t.abort())}}}));var M=j()&&!!(window.File&&window.FileList&&window.FileReader),E=j()&&!(!window.FormData||!M),O=j()&&function(){var e;return"draggable"in(e=document.createElement("div"))||"ondragstart"in e&&"ondrop"in e}(),U=j()&&function(){var e;return!(!(e=document.createElement("canvas")).getContext||!e.getContext("2d"))}(),B=M&&O,R=null,V=j()&&/^[^(]+\(iP(?:hone|od|ad);\s*(.+?)\)/.exec(navigator.userAgent);if(V){var L=/OS (\d*)_(\d*)/.exec(V[1]);L&&(R=+L[1]+L[2]/10)}var N=j()&&navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&/MacIntel/.test(navigator.platform),q=!1;try{j()&&new window.Blob&&(q=window.Blob)}catch(e){}var H=j()&&(window.URL||window.webkitURL||!1),K=H&&H.createObjectURL&&H,W=j()&&(null!=window.FileReader?window.FileReader.prototype.readAsArrayBuffer:void 0)&&window.FileReader,G=[].indexOf,Z=function(e){var t,a,i,n;for(n=[],a=0,i=e.length;a<i;a++)t=e[a],G.call(n,t)<0&&n.push(t);return n},X=function(e){return setTimeout(e,0)},Y=function(e,t){for(var a;t;)a=e%t,e=t,t=a;return e},J=function(e){var t,a;return t=!1,a=null,function(){return t||(a=e.apply(this,arguments),t=!0),a}},Q=function(e){return a.default.Deferred().resolve(e).promise()},$=function(e,t,i,n){var r,o;return o=a.default.Deferred(),r=function(e,t){return e&&t?function(){return t.call(this,e.apply(this,arguments))}:e||t},e.then(r(t,o.resolve),r(i,o.reject),r(n,o.notify)),o.promise()},ee=function(e,t){var i;return i={},a.default.each(t,(function(t,n){var r=e[n];a.default.isFunction(r)?i[n]=function(){for(var t=arguments.length,a=new Array(t),n=0;n<t;n++)a[n]=arguments[n];var o=r.apply(e,a);return o===e?i:o}:i[n]=r})),i},te=function(e){return e.replace(/([A-Z])/g,"_$1").toUpperCase()},ae=function(e){var t;return(t=e.add).add=e.add,t.remove=e.remove,t},ie=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}))},ne=/^(?:([^:/?#]+):)?(?:\/\/([^/?#]*))?([^?#]*)\??([^#]*)#?(.*)$/,re=/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/i,oe=new RegExp("".concat(re.source,"~[0-9]+"),"i"),le=new RegExp("^/?(".concat(re.source,")(?:/(-/(?:[^/]+/)+)?([^/]*))?$"),"i"),se=function(e){return le.exec(ne.exec(e)[3])},ue=function(e){return e.replace(/[\\-\\[]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},ce=function(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"i";return t=a.default.map(e.split("*"),ue),new RegExp("^"+t.join(".+")+"$",i)},de=function(e){var t;return"http:"!==(t=document.location.protocol)&&(t="https:"),e.replace(/^\/\//,t+"//").replace(/\/+$/,"")},pe=function(e,t){if(e.length>t){var a=Math.ceil((t-3)/2),i=Math.floor((t-3)/2);return e.slice(0,a)+"..."+e.slice(-i)}return e},fe=function(e,t,a){var i,n;return e[0]>t[0]||e[1]>t[1]||a?(n=t[0]/e[0],i=t[1]/e[1],!t[0]||t[1]&&n>i?[Math.round(i*e[0]),t[1]]:[t[0],Math.round(n*e[1])]):e.slice()},he=function(e,t,i,n){var r,o,l,s,u,c,d;if(c=n.width,o=n.height,s=t.preferedSize,l="",(d=c===i[0]&&o===i[1])||(l+="-/crop/".concat(c,"x").concat(o,"/").concat(n.left,",").concat(n.top,"/")),r=t.downscale&&(c>s[0]||o>s[1]),u=t.upscale&&(c<s[0]||o<s[1]),r||u){var p=w(s,2);n.sw=p[0],n.sh=p[1],l+="-/resize/".concat(s.join("x"),"/")}else d||(l+="-/preview/");return(e=a.default.extend({},e)).cdnUrlModifiers=l,e.cdnUrl="".concat(e.originalUrl).concat(l||""),e.crop=n,e},me=["image/*","image/heif","image/heif-sequence","image/heic","image/heic-sequence","image/avif","image/avif-sequence",".heif",".heifs",".heic",".heics",".avif",".avifs"].join(","),ge=function(e,t,i){var n,r,o;return r=null,""===(n=t.inputAcceptTypes)&&(n=t.imagesOnly?me:null),(o=function(){return r=(t.multiple?a.default('<input type="file" multiple>'):a.default('<input type="file">')).attr("accept",n).css({position:"absolute",top:0,opacity:0,margin:0,padding:0,width:"auto",height:"auto",cursor:e.css("cursor")}).on("change",(function(){return i(this),a.default(this).hide(),o()})),e.append(r)})(),e.css({position:"relative",overflow:"hidden"}).mousemove((function(e){var t,i,n,o=a.default(this).offset();return t=o.left,i=o.top,n=r.width(),r.css({left:e.pageX-t-n+10,top:e.pageY-i-10})}))},_e=function(e,t,i){var n,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return""===(n=t.inputAcceptTypes)&&(n=t.imagesOnly?me:null),a.default(t.multiple?'<input type="file" multiple>':'<input type="file">').attr("accept",n).attr(r).css({position:"fixed",bottom:0,opacity:0}).on("change",(function(){return i(this),a.default(this).remove()})).appendTo(e).focus().click().hide()},ve="B KB MB GB TB PB EB ZB YB".split(" "),be=function(e){var t,a,i,n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",l=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"";if(e=parseInt(e,10),isNaN(e))return r;for(t=2,i=0,n=1e3-5*Math.pow(10,2-Math.max(t,3));e>n&&i<ve.length-1;)i++,e/=1024;return e+=1e-15,a=Math.max(0,t-Math.floor(e).toFixed(0).length),e=Number(e.toFixed(a)),"".concat(o).concat(e," ").concat(ve[i]).concat(l)},ye={dataType:"json",crossDomain:!0,cache:!1},we=function(e,t,i){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},r=a.default.ajax(a.default.extend({url:e,type:t,data:i},n,ye)).retry(n.retryConfig).fail((function(t,a,i){var n="".concat(a," (").concat(i,")");S("JSONP unexpected error: ".concat(n," while loading ").concat(e))})),o=r.then((function(e){var t,i;return e.error?("string"==typeof e.error?(t=e.error,i=e.error_code):(t=e.error.content,i=e.error.error_code),a.default.Deferred().reject({message:t,code:i})):e}));return o.abort=r.abort.bind(r),o},xe=function(e,t,a,i){var n,r,o,l,s,u;if(window.HTMLCanvasElement.prototype.toBlob)return e.toBlob(i,t,a);for(o=(o=e.toDataURL(t,a)).split(","),r=window.atob(o[1]),n=new Uint8Array(r.length),l=s=0,u=r.length;s<u;l=s+=1)n[l]=r.charCodeAt(l);return i(new window.Blob([n],{type:/:(.+\/.+);/.exec(o[0])[1]}))},ke=function(e){var t,a,i;return i=0,t=[],a=function(){var e;return t.length?(e=t.shift(),X((function(){return e(a)}))):i-=1},function(n){return!e||i<e?(i+=1,X((function(){return n(a)}))):t.push(n)}},ze=[["notify","progress",2],["resolve","done",0],["reject","fail",1]],Ae=function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),n=1;n<t;n++)i[n-1]=arguments[n];return a.default.Deferred((function(t){return a.default.each(ze,(function(n,r){var o;return o=a.default.isFunction(i[r[2]])&&i[r[2]],e[r[1]]((function(){var i;return(i=o&&o.apply(this,arguments))&&a.default.isFunction(i.promise)?i.promise().progress(t.notify).done(t.resolve).fail(t.reject):t[r[0]+"With"](this===e?t.promise():this,o?[i]:arguments)}))}))})).promise()},Ce=function(e){var t;return t=r({},t=e.metadataCallback?e.metadataCallback()||{}:e.metadata||{}),a.default.each(t,(function(e,a){t[e]=String(a)})),t},Se=55,Fe=110,Te=165,je=255,De="rgba(".concat(Se,", ").concat(Fe,", ").concat(Te,", ").concat(je/255,")");function Ie(e,t){try{var a=[e-1,t-1,1,1],i=document.createElement("canvas");i.width=1,i.height=1;var n=document.createElement("canvas");n.width=e,n.height=t;var r=i.getContext("2d"),o=n.getContext("2d");o&&(o.fillStyle=De,o.fillRect.apply(o,a),r.drawImage(n,e-1,t-1,1,1,0,0,1,1));var l=r&&r.getImageData(0,0,1,1).data,s=!1;return l&&(s=l[0]===Se&&l[1]===Fe&&l[2]===Te&&l[3]===je),n.width=n.height=1,s}catch(a){return A("Failed to test for max canvas size of ".concat(e,"x").concat(t,"."),a),!1}}function Pe(e,t){var a={};return function(){for(var i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];var o=t(n,a);return o in a?a[o]:a[o]=e.apply(void 0,n)}}var Me={squareSide:[Math.floor(Math.sqrt(5e6)),4096,8192,11180,10836,11402,14188,16384],dimension:[4096,8192,16384,32767,65535]},Ee=Me.squareSide[Me.squareSide.length-1];function Oe(e){return function(){for(var t=arguments.length,i=new Array(t),n=0;n<t;n++)i[n]=arguments[n];var r=a.default.Deferred();return X((function(){var t=e.apply(void 0,i);r.resolve(t)})),r.promise()}}function Ue(e,t){for(var a=w(e,1)[0],i=Object.keys(t).map((function(e){return parseInt(e,10)})).sort((function(e,t){return e-t})),n=0;n<i.length;n++){var r=i[n],o=!!t[r];if(r>a&&o)return r;if(r<a&&!o)return r}return a}var Be=Oe(Pe(Ie,Ue)),Re=Oe(Pe(Ie,Ue));function Ve(e,t){var i=a.default.Deferred(),n=Me.squareSide.find((function(a){return a*a>=e*t})),r=Me.dimension.find((function(a){return a>=e&&a>=t}));if(!n||!r)return i.reject();var o=[Be(n,n),Re(r,1)];return a.default.when.apply(a.default,o).done((function(e,t){e&&t?i.resolve():i.reject()})),i.promise()}var Le,Ne,qe,He,Ke,We,Ge,Ze,Xe,Ye,Je,Qe,$e,et,tt,at,it,nt,rt,ot,lt,st,ut,ct=[].indexOf;Ke={live:!0,manualStart:!1,locale:null,localePluralize:null,localeTranslations:null,systemDialog:!1,crop:!1,previewStep:!1,imagesOnly:!1,clearable:!1,multiple:!1,multipleMax:1e3,multipleMin:1,multipleMaxStrict:!1,imageShrink:!1,pathValue:!0,tabs:"file camera url facebook gdrive gphotos dropbox instagram evernote flickr onedrive",preferredTypes:"",inputAcceptTypes:"",doNotStore:!1,publicKey:null,secureSignature:"",secureExpire:"",pusherKey:"79ae88bd931ea68464d9",cdnBase:"https://ucarecdn.com",urlBase:"https://upload.uploadcare.com",socialBase:"https://social.uploadcare.com",previewProxy:null,previewUrlCallback:null,remoteTabSessionKey:null,metadata:null,metadataCallback:null,imagePreviewMaxSize:26214400,multipartMinSize:10485760,multipartPartSize:5242880,multipartMinLastPartSize:1048576,multipartConcurrency:4,multipartMaxAttempts:null,retryAttempts:3,retryThrottledAttempts:10,retryBaseTimeout:1e3,retryFactor:2,parallelDirectUploads:10,passWindowOpen:!1,cameraMirrorDefault:!0,enableAudioRecording:!0,enableVideoRecording:!0,videoPreferredMimeTypes:null,audioBitsPerSecond:null,videoBitsPerSecond:null,scriptBase:"//ucarecdn.com/widget/".concat("3.21.8","/uploadcare/"),debugUploads:!1,integration:""},We=r({},Ke),rt={multipleMax:{from:0,to:1e3}},qe={multipleMax:{min:1,max:1e3}},tt={tabs:{all:"file camera url facebook gdrive gphotos dropbox instagram evernote flickr onedrive box vk huddle",default:Ke.tabs}},at=j()&&(document.currentScript||(ut=document.getElementsByTagName("script"))[ut.length-1]),(Xe=j()&&a.default(at).data("integration"))&&null!=Xe&&(Ke=a.default.extend(Ke,{integration:Xe})),it=function(e){return a.default.isArray(e)||(e=(e=a.default.trim(e))?e.split(" "):[]),e},Le=function(e,t){var a,i,n,r,o,l,s,u,c=Object.prototype.hasOwnProperty;for(a=0,o=t.length;a<o;a++){if(r=t[a],u=s=it(e[r]),c.apply(tt,[r]))for(u=[],n=0,l=s.length;n<l;n++)i=s[n],c.apply(tt[r],[i])?u=u.concat(it(tt[r][i])):u.push(i);e[r]=Z(u)}return e},ot=function(e,t){var a,i,n;for(a=0,n=t.length;a<n;a++)null!=e[i=t[a]]&&(e[i]=de(e[i]));return e},Ge=function(e,t){var i,n,r,o;for(i=0,r=t.length;i<r;i++)null!=e[n=t[i]]&&("string"==typeof(o=e[n])?(o=a.default.trim(o).toLowerCase(),e[n]=!("false"===o||"disabled"===o)):e[n]=!!o);return e},Ze=function(e,t){var a,i,n;for(a=0,n=t.length;a<n;a++)null!=e[i=t[a]]&&(e[i]=parseInt(e[i]));return e},Ye=function(e){return e._userAgent="UploadcareWidget/".concat("3.21.8","/").concat(e.publicKey," (JavaScript").concat(e.integration?"; ".concat(e.integration):"",")"),e},Je=function(e){e.retryAttempts===We.retryAttempts&&null!==e.multipartMaxAttempts&&(e.retryAttempts=e.multipartMaxAttempts),e.retryConfig={baseTimeout:e.retryBaseTimeout,factor:e.retryFactor,attempts:e.retryAttempts,debugUploads:e.debugUploads,throttledAttempts:e.retryThrottledAttempts}},nt=function(e,t){var a,i;for(a in t)i=t[a],null!=e[a]&&e[a]===i.from&&(e[a]=i.to);return e},Ne=function(e,t){var a,i,n;for(a in t){var r=t[a];n=r.min,i=r.max,null!=e[a]&&(e[a]=Math.min(Math.max(e[a],n),i))}return e},lt=function(e,t){for(var a=0,i=t.length;a<i;a++){var n=t[a];e[n]&&"function"!=typeof e[n]&&T('Option "'.concat(n,'" is expected to be a function. Instead got: ').concat(s(e[n])))}},st=function(e,t){for(var a=0,i=t.length;a<i;a++){var n=t[a];e[n]&&(r=e[n],"[object Object]"!==Object.prototype.toString.call(r))&&T('Option "'.concat(n,'" is expected to be an object. Instead got: ').concat(s(e[n])))}var r},$e=function(e){var t;return{downscale:"x"===(t=/^([0-9]+)([x:])([0-9]+)\s*(|upscale|minimum)$/i.exec(a.default.trim(e.toLowerCase()))||[])[2],upscale:!!t[4],notLess:"minimum"===t[4],preferedSize:t.length?[+t[1],+t[3]]:void 0}},et=function(e){var t=/^([0-9]+)x([0-9]+)(?:\s+(\d{1,2}|100)%)?$/i.exec(a.default.trim(e.toLowerCase()))||[];if(!t.length)return!1;var i=t[1]*t[2],n=Ee*Ee;return i>n?(T("Shrinked size can not be larger than ".concat(Math.floor(n/1e3/1e3),"MP. ")+"You have set ".concat(t[1],"x").concat(t[2]," (")+"".concat(Math.ceil(i/1e3/100)/10,"MP).")),!1):{quality:t[3]?t[3]/100:void 0,size:i}},He=function(e,t){var a,i,n,r;return this.previewProxy?(i=(n=!/\?/.test(this.previewProxy))||!/=$/.test(this.previewProxy),a=!n&&!/[&?=]$/.test(this.previewProxy),r=encodeURIComponent(e),i&&(r="url="+r),a&&(r="&"+r),n&&(r="?"+r),this.previewProxy+r):e},Qe=function(e){Le(e,["tabs","preferredTypes","videoPreferredMimeTypes"]),ot(e,["cdnBase","socialBase","urlBase","scriptBase"]),Ge(e,["doNotStore","imagesOnly","multiple","clearable","pathValue","previewStep","systemDialog","debugUploads","multipleMaxStrict","cameraMirrorDefault"]),Ze(e,["multipleMax","multipleMin","multipartMinSize","multipartPartSize","multipartMinLastPartSize","multipartConcurrency","multipartMaxAttempts","retryAttempts","retryThrottledAttempts","retryBaseTimeout","retryFactor","parallelDirectUploads"]),lt(e,["previewUrlCallback","metadataCallback"]),st(e,["metadata"]),nt(e,rt),Ne(e,qe),Ye(e),Je(e),!1===e.crop||a.default.isArray(e.crop)||(/^(disabled?|false|null)$/i.test(e.crop)?e.crop=!1:a.default.isPlainObject(e.crop)?e.crop=[e.crop]:e.crop=a.default.map((""+e.crop).split(","),$e)),e.imageShrink&&!a.default.isPlainObject(e.imageShrink)&&(e.imageShrink=et(e.imageShrink)),(e.crop||e.multiple)&&(e.previewStep=!0),E||(e.systemDialog=!1),e.validators&&(e.validators=e.validators.slice()),e.previewProxy&&!e.previewUrlCallback&&(e.previewUrlCallback=He);var t=e.tabs.indexOf("skydrive");return-1!==t&&(e.tabs[t]="onedrive"),e};var dt,pt=function(){var e,t,a;for(e in t={},Ke)null!=(a=window["UPLOADCARE_".concat(te(e))])&&(t[e]=a);return t},ft=J((function(e,t){var i;return t||(Ke=a.default.extend(Ke,pt())),i=Qe(a.default.extend(Ke,e||{})),mt.fire(i),i})),ht=function(e){var t;return t=a.default.extend({},ft()),a.default.isEmptyObject(e)||(t=Qe(a.default.extend(t,e))),t},mt=j()&&a.default.Callbacks("once memory"),gt=function(){function e(){u(this,e),this.urls=[],this.styles=[]}return d(e,[{key:"addUrl",value:function(e){if(!/^https?:\/\//i.test(e))throw new Error("Embedded urls should be absolute. "+e);if(!(ct.call(this.urls,e)>=0))return this.urls.push(e)}},{key:"addStyle",value:function(e){return this.styles.push(e)}}]),e}(),_t=function(e,t){var i;return i=a.default.Deferred(),t&&(e.src=t),e.complete?i.resolve(e):(a.default(e).one("load",(function(){return i.resolve(e)})),a.default(e).one("error",(function(){return i.reject(e)}))),i.promise()},vt=function e(t){return a.default.isArray(t)?a.default.when.apply(null,a.default.map(t,e)):t.src?_t(t):_t(new window.Image,t)},bt=function(e){var t=a.default.Deferred();return a.default("<video></video>").on("loadeddata",t.resolve).on("error",t.reject).attr("src",e).get(0).load(),t.promise()},yt=function(){var e=a.default.Deferred();if(void 0!==dt)e.resolve(dt);else{var t=new window.Image;t.onload=function(){dt=t.naturalWidth<t.naturalHeight,t.src="//:0",e.resolve(dt)},t.src="data:image/jpg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/4QA6RXhpZgAATU0AKgAAAAgAAwESAAMAAAABAAYAAAEoAAMAAAABAAIAAAITAAMAAAABAAEAAAAAAAD/2wBDAP//////////////////////////////////////////////////////////////////////////////////////wAALCAABAAIBASIA/8QAJgABAAAAAAAAAAAAAAAAAAAAAxABAAAAAAAAAAAAAAAAAAAAAP/aAAgBAQAAPwBH/9k="}return e.promise()},wt=function(e,t,i){var n=a.default.Deferred();return X((function(){try{var a=document.createElement("canvas"),r=a.getContext("2d");a.width=t,a.height=i,r.imageSmoothingQuality="high",r.drawImage(e,0,0,t,i),e.src="//:0",e.width=e.height=1,n.resolve(a)}catch(e){A("Failed to shrink image to size ".concat(t,"x").concat(i,"."),e),n.reject(e)}})),n.promise()},xt=function(e,t,i,n,r){var o=function(e,t,a,i){var n=[],r=t,o=a;do{n.push([r,o]),r=Math.round(r/i),o=Math.round(o/i)}while(r<e*i);return n.reverse()}(t,i,n,r),l=a.default.Deferred(),s=a.default.Deferred();s.resolve(e);var u,c=function(e,t){var a="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!a){if(Array.isArray(e)||(a=k(e))||t&&e&&"number"==typeof e.length){a&&(e=a);var i=0,n=function(){};return{s:n,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var r,o=!0,l=!1;return{s:function(){a=a.call(e)},n:function(){var e=a.next();return o=e.done,e},e:function(e){l=!0,r=e},f:function(){try{o||null==a.return||a.return()}finally{if(l)throw r}}}}(o);try{var d=function(){var e=w(u.value,2),n=e[0],r=e[1];s=s.then((function(e){var t=a.default.Deferred();return Ve(n,r).then((function(){return t.resolve(e,!1)})).fail((function(){return t.resolve(e,!0)})),t.promise()})).then((function(e,t){return t?e:wt(e,n,r)})).then((function(e){return l.notify((t-n)/(t-i)),e}))};for(c.s();!(u=c.n()).done;)d()}catch(e){c.e(e)}finally{c.f()}return s.done((function(e){l.resolve(e)})),s.fail((function(e){l.reject(e)})),l.promise()},kt=function(e,t){var i=a.default.Deferred();if(.71*e.width*e.height*.71<t.size)return i.reject("not required");var n=e.width,r=e.height,o=n/r,l=Math.floor(Math.sqrt(t.size*o)),s=Math.floor(t.size/Math.sqrt(t.size*o));return Ve(l,s).fail((function(){i.reject("not supported")})).then((function(){("imageSmoothingQuality"in document.createElement("canvas").getContext("2d")&&!R&&!N?function(e,t,a){return wt(e,t,a)}(e,l,s):xt(e,n,l,s,.71)).done((function(e){return i.resolve(e)})).progress((function(e){return i.notify(e)})).fail((function(){return i.reject("not supported")}))})),i.promise()},zt=j()&&window.DataView,At=ke(1),Ct=function(e,t){var i=a.default.Deferred();return K&&zt&&q?(At((function(n){i.always(n),Et(e).then((function(e){if(e)return i.reject("skipped"),a.default.Deferred().reject()})).then((function(){return Mt(e).fail((function(){i.reject("not image")}))})).done((function(n){i.notify(.1);var r=a.default.when(jt(e),yt(),Dt(e)).always((function(e,o,l){i.notify(.2);var s="resolved"===r.state(),u=kt(n,t);u.progress((function(e){return i.notify(.2+.6*e)})),u.fail(i.reject),u.done((function(n){var r="image/jpeg",u=t.quality||.8;!s&&Rt(n)&&(r="image/png",u=void 0),xe(n,r,u,(function(t){n.width=n.height=1,i.notify(.9);var r=a.default.Deferred().resolve(t);e&&(r=r.then((function(t){return It(t,e,o)})).catch((function(){return t}))),(null==l?void 0:l.length)>0&&(r=r.then((function(e){return Pt(e,l)})).catch((function(){return t}))),r.done(i.resolve),r.fail((function(){return i.resolve(t)}))}))}))}))}))})),i.promise()):i.reject("support")},St=function(e,t,i,n,r){var o,l;return o=a.default.Deferred(),K?((l=vt(K.createObjectURL(e))).always((function(e){return K.revokeObjectURL(e.src)})),l.fail((function(){return o.reject("not image")})),l.done((function(l){return o.always((function(){l.src="//:0"})),r&&l.width*l.height>r?o.reject("max source"):a.default.when(jt(e),yt()).always((function(e,a){var r=a?1:Ut(e)||1,s=r>4,u=s?[l.height,l.width]:[l.width,l.height],c=w(fe(u,[t,i]),2),d=c[0],p=c[1],f=[[1,0,0,1,0,0],[-1,0,0,1,d,0],[-1,0,0,-1,d,p],[1,0,0,-1,0,p],[0,1,1,0,0,0],[0,1,-1,0,d,0],[0,-1,-1,0,d,p],[0,-1,1,0,0,p]][r-1];if(!f)return o.reject("bad image");var h=document.createElement("canvas");h.width=d,h.height=p;var m=h.getContext("2d");if(m.transform.apply(m,f),s){var g=[p,d];d=g[0],p=g[1]}return n&&(m.fillStyle=n,m.fillRect(0,0,d,p)),m.drawImage(l,0,0,d,p),o.resolve(h,u)}))})),o.promise()):o.reject("support")},Ft=function(e){var t,i,n,r,o;return o=function(e,a){var i;return(i=new W).onload=function(){return a(new zt(i.result))},i.onerror=function(e){return t.reject("reader",e)},i.readAsArrayBuffer(e)},n=function(){return o(e.slice(i,i+128),(function(e){var t,a,n;for(t=a=0,n=e.byteLength;n>=0?a<n:a>n;t=n>=0?++a:--a)if(255===e.getUint8(t)){i+=t;break}return r()}))},r=function(){var a;return a=i,o(e.slice(i,i+=4),(function(r){var l,s;return 4!==r.byteLength||255!==r.getUint8(0)?t.reject("corrupted"):218===(s=r.getUint8(1))?t.resolve():(l=r.getUint16(2)-2,o(e.slice(i,i+=l),(function(e){return e.byteLength!==l?t.reject("corrupted"):(t.notify(a,l,s,e),n())})))}))},t=a.default.Deferred(),W&&zt?(i=2,o(e.slice(0,2),(function(e){return 65496!==e.getUint16(0)?t.reject("not jpeg"):n()})),t.promise()):t.reject("support")},Tt=function(e,t,i){var n,r,o,l;return n=a.default.Deferred(),o=[],r=[],(l=Ft(e)).fail(n.reject),l.progress((function(e,a,i){if(i===t)return o.push(e),r.push(a)})),l.done((function(){var a,l,s,u,c,d,p,f,h;for(p=[e.slice(0,2)],u=0,d=i.length;u<d;u++)a=i[u],(s=new zt(new ArrayBuffer(4))).setUint16(0,65280+t),s.setUint16(2,a.byteLength+2),p.push(s.buffer),p.push(a);for(f=2,l=c=0,h=o.length;h>=0?c<h:c>h;l=h>=0?++c:--c)o[l]>f&&p.push(e.slice(f,o[l])),f=o[l]+r[l]+4;return p.push(e.slice(f,e.size)),n.resolve(new q(p,{type:e.type}))})),n.promise()},jt=function(e){var t=null,i=Ft(e);return i.progress((function(e,a,i,n){if(!t&&225===i&&n.byteLength>=14&&1165519206===n.getUint32(0)&&0===n.getUint16(4))return t=n})),i.then((function(){return t}),(function(){return a.default.Deferred().reject(t)}))},Dt=function(e){var t=[],i=Ft(e);return i.progress((function(e,a,i,n){226===i&&1229144927===n.getUint32(0)&&1347571526===n.getUint32(4)&&1229735168===n.getUint32(8)&&t.push(n)})),i.then((function(){return t}),(function(){return a.default.Deferred().reject(t)}))},It=function(e,t,a){return a&&Ot(t,1),Tt(e,225,[t.buffer])},Pt=function(e,t){return Tt(e,226,t.map((function(e){return e.buffer})))},Mt=function(e){var t=a.default.Deferred();return Pt(e,[]).catch((function(){return e})).then((function(e){var a=vt(K.createObjectURL(e));a.always((function(e){K.revokeObjectURL(e.src)})),a.fail((function(){t.reject()})),a.done((function(e){t.resolve(e)}))})).fail((function(){t.reject()})),t.promise()},Et=function(e){var t=[1,3],a=[192,193,194,195,197,198,199,201,202,203,205,206,207],i=!1,n=Ft(e);return n.progress((function(e,n,r,o){if(!i&&a.indexOf(r)>=0){var l=o.getUint8(5);t.indexOf(l)<0&&(i=!0)}})),n.then((function(){return i})).catch((function(){return i}))},Ot=function(e,t){Bt(e,(function(a,i){return e.setUint16(a,t,i)}))},Ut=function(e){return Bt(e,(function(t,a){return e.getUint16(t,a)}))},Bt=function(e,t){var a,i,n,r;if(!e||e.byteLength<14||1165519206!==e.getUint32(0)||0!==e.getUint16(4))return null;if(18761===e.getUint16(6))i=!0;else{if(19789!==e.getUint16(6))return null;i=!1}if(42!==e.getUint16(8,i))return null;for(n=8+e.getUint32(10,i),a=0,r=e.getUint16(n-2,i);r>=0?a<r:a>r;r>=0?++a:--a){if(e.byteLength<n+10)return null;if(274===e.getUint16(n,i))return t(n+8,i);n+=12}return null},Rt=function(e){var t,a,i,n,r,o;for(50,(t=document.createElement("canvas")).width=t.height=50,(a=t.getContext("2d")).drawImage(e,0,0,50,50),i=a.getImageData(0,0,50,50).data,t.width=t.height=1,n=r=3,o=i.length;r<o;n=r+=4)if(i[n]<254)return!0;return!1},Vt=function(){function e(t,a){var i,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};u(this,e),this.settings=a,this.sourceInfo=n,this.fileId=null,this.fileName=null,this.sanitizedName=null,this.fileSize=null,this.isStored=null,this.cdnUrlModifiers=null,this.isImage=null,this.imageInfo=null,this.videoInfo=null,this.contentInfo=null,this.mimeType=null,this.s3Bucket=null,this.metadata=null,(i=this.sourceInfo).source||(i.source=this.sourceName),this.__setupValidation(),this.__initApi()}return d(e,[{key:"__startUpload",value:function(){return a.default.Deferred().resolve()}},{key:"__completeUpload",value:function(){var e,t,a,i,n=this;return a=0,this.settings.debugUploads&&(C("Load file info.",this.fileId,this.settings.publicKey),t=setInterval((function(){return C("Still waiting for file ready.",a,n.fileId,n.settings.publicKey)}),5e3),this.apiDeferred.done((function(){return C("File uploaded.",a,n.fileId,n.settings.publicKey)})).always((function(){return clearInterval(t)}))),i=100,(e=function(){if("pending"===n.apiDeferred.state())return a+=1,n.__updateInfo().done((function(){return setTimeout(e,i),i+=50}))})()}},{key:"__updateInfo",value:function(){var e=this;return we("".concat(this.settings.urlBase,"/info/"),"GET",{jsonerrors:1,file_id:this.fileId,pub_key:this.settings.publicKey,wait_is_ready:+(null===this.isImage)},{headers:{"X-UC-User-Agent":this.settings._userAgent},retryConfig:this.settings.retryConfig}).fail((function(t){return e.settings.debugUploads&&A("Can't load file info. Probably removed.",e.fileId,e.settings.publicKey,t.message),e.__rejectApi("info",t)})).done(this.__handleFileData.bind(this))}},{key:"__handleFileData",value:function(e){if(this.fileName=e.original_filename,this.sanitizedName=e.filename,this.fileSize=e.size,this.isImage=e.is_image,this.imageInfo=e.image_info,this.videoInfo=e.video_info,this.contentInfo=e.content_info,this.mimeType=e.mime_type,this.isStored=e.is_stored,this.s3Bucket=e.s3_bucket,this.metadata=e.metadata,e.default_effects&&(this.cdnUrlModifiers="-/"+e.default_effects),this.s3Bucket&&this.cdnUrlModifiers&&this.__rejectApi("baddata"),this.__runValidators(),e.is_ready)return this.__resolveApi()}},{key:"__progressInfo",value:function(){var e;return{state:this.__progressState,uploadProgress:this.__progress,progress:"ready"===(e=this.__progressState)||"error"===e?1:.9*this.__progress,incompleteFileInfo:this.__fileInfo()}}},{key:"__fileInfo",value:function(){var e;return e=this.s3Bucket?"https://".concat(this.s3Bucket,".s3.amazonaws.com/").concat(this.fileId,"/").concat(this.sanitizedName):"".concat(this.settings.cdnBase,"/").concat(this.fileId,"/"),{uuid:this.fileId,name:this.fileName,size:this.fileSize,isStored:this.isStored,isImage:this.isImage,originalImageInfo:this.imageInfo,originalVideoInfo:this.videoInfo,originalContentInfo:this.contentInfo,mimeType:this.mimeType,originalUrl:this.fileId?e:null,cdnUrl:this.fileId?"".concat(e).concat(this.cdnUrlModifiers||""):null,cdnUrlModifiers:this.cdnUrlModifiers,sourceInfo:this.sourceInfo,metadata:this.metadata}}},{key:"__setupValidation",value:function(){if(this.validators=this.settings.validators||this.settings.__validators||[],this.settings.imagesOnly)return this.validators.push((function(e){if(!1===e.isImage)throw new Error("image")}))}},{key:"__runValidators",value:function(){var e,t,a,i,n,r,o;a=this.__fileInfo();try{for(n=this.validators,r=[],t=0,i=n.length;t<i;t++)o=n[t],r.push(o(a));return r}catch(t){return e=t,this.__rejectApi(e.message)}}},{key:"__initApi",value:function(){return this.apiDeferred=a.default.Deferred(),this.__progressState="uploading",this.__progress=0,this.__notifyApi()}},{key:"__notifyApi",value:function(){return this.apiDeferred.notify(this.__progressInfo())}},{key:"__rejectApi",value:function(e,t){return this.__progressState="error",this.__notifyApi(),this.apiDeferred.reject(e,this.__fileInfo(),t)}},{key:"__resolveApi",value:function(){return this.__progressState="ready",this.__notifyApi(),this.apiDeferred.resolve(this.__fileInfo())}},{key:"__cancel",value:function(){return this.__rejectApi("user")}},{key:"__extendApi",value:function(e){var t=this;return e.cancel=this.__cancel.bind(this),e.pipe=e.then=function(){for(var a=arguments.length,i=new Array(a),n=0;n<a;n++)i[n]=arguments[n];return t.__extendApi(Ae.apply(void 0,[e].concat(i)))},e}},{key:"promise",value:function(){var e,t=this;return this.__apiPromise||(this.__apiPromise=this.__extendApi(this.apiDeferred.promise()),this.__runValidators(),"pending"===this.apiDeferred.state()&&((e=this.__startUpload()).done((function(){return t.__progressState="uploaded",t.__progress=1,t.__notifyApi(),t.__completeUpload()})),e.progress((function(e){if(e>t.__progress)return t.__progress=e,t.__notifyApi()})),e.fail((function(e){return t.__rejectApi("upload",e)})),this.apiDeferred.always(e.reject))),this.__apiPromise}}]),e}(),Lt=null,Nt=function(e){f(i,e);var t=v(i);function i(e){var a;return u(this,i),(a=t.apply(this,arguments)).__file=e,a.fileName=a.__file.name||"original",a.__notifyApi(),a}return d(i,[{key:"setFile",value:function(e){if(e&&(this.__file=e),this.sourceInfo.file=this.__file,this.__file)return this.fileSize=this.__file.size,this.fileType=this.__file.type||"application/octet-stream",this.settings.debugUploads&&C("Use local file.",this.fileName,this.fileType,this.fileSize),this.__runValidators(),this.__notifyApi()}},{key:"__startUpload",value:function(){var e,t,i,n=this;return this.apiDeferred.always((function(){return n.__file=null,n.__file})),this.__file.size>=this.settings.multipartMinSize&&q?(this.setFile(),this.multipartUpload()):(t=R,!this.settings.imageShrink||t&&t<8?(this.setFile(),this.directUpload()):(e=a.default.Deferred(),i=.4,Ct(this.__file,this.settings.imageShrink).progress((function(t){return e.notify(t*i)})).done(this.setFile.bind(this)).fail((function(){return n.setFile(),i*=.1})).always((function(){return e.notify(i),n.directUpload().done(e.resolve).fail(e.reject).progress((function(t){return e.notify(i+t*(1-i))}))})),e))}},{key:"__autoAbort",value:function(e){return this.apiDeferred.fail((function(){return e.abort()})),e}},{key:"directRunner",value:function(e){return Lt||(Lt=ke(this.settings.parallelDirectUploads)),Lt(e)}},{key:"directUpload",value:function(){var e,t=this;return e=a.default.Deferred(),this.__file?this.fileSize>104857600?(this.__rejectApi("size"),e):(this.directRunner((function(i){if(e.always(i),"pending"===t.apiDeferred.state()){var n=new window.FormData;return n.append("UPLOADCARE_PUB_KEY",t.settings.publicKey),n.append("signature",t.settings.secureSignature),n.append("expire",t.settings.secureExpire),n.append("UPLOADCARE_STORE",t.settings.doNotStore?"":"auto"),n.append("file",t.__file,t.fileName),n.append("file_name",t.fileName),n.append("source",t.sourceInfo.source),a.default.each(Ce(t.settings),(function(e,t){n.append("metadata[".concat(e,"]"),t)})),t.__autoAbort(a.default.ajax({xhr:function(){var t;return t=a.default.ajaxSettings.xhr(),t.upload&&t.upload.addEventListener("progress",(function(t){return e.notify(t.loaded/t.total)}),!1),t},crossDomain:!0,type:"POST",url:"".concat(t.settings.urlBase,"/base/?jsonerrors=1"),headers:{"X-UC-User-Agent":t.settings._userAgent},contentType:!1,processData:!1,data:n,dataType:"json"}).retry(t.settings.retryConfig).done((function(a){if(null!=a?a.file:void 0)return t.fileId=a.file,e.resolve();if(a.error){var i=a.error,n=i.content,r=i.error_code;return e.reject({message:n,code:r})}return e.reject()})).fail(e.reject))}})),e):(this.__rejectApi("baddata"),e)}},{key:"multipartUpload",value:function(){var e,t=this;return e=a.default.Deferred(),this.__file?(this.multipartStart().done((function(a){return t.uploadParts(a.parts,a.uuid).done((function(){return t.multipartComplete(a.uuid).done((function(a){return t.fileId=a.uuid,t.__handleFileData(a),e.resolve()})).fail(e.reject)})).progress(e.notify).fail(e.reject)})).fail(e.reject),e):e}},{key:"multipartStart",value:function(){var e=this,t={UPLOADCARE_PUB_KEY:this.settings.publicKey,signature:this.settings.secureSignature,expire:this.settings.secureExpire,filename:this.fileName,source:this.sourceInfo.source,size:this.fileSize,content_type:this.fileType,part_size:this.settings.multipartPartSize,UPLOADCARE_STORE:this.settings.doNotStore?"":"auto"};return a.default.each(Ce(this.settings),(function(e,a){t["metadata[".concat(e,"]")]=a})),this.__autoAbort(we("".concat(this.settings.urlBase,"/multipart/start/?jsonerrors=1"),"POST",t,{headers:{"X-UC-User-Agent":this.settings._userAgent},retryConfig:this.settings.retryConfig})).fail((function(a){if(e.settings.debugUploads)return A("Can't start multipart upload.",a.message,t)}))}},{key:"uploadParts",value:function(e,t){var i,n,o,l,s,u,c,d,p,f,h=this;for(s=[],l=Date.now(),f=function(e,t){var a,n,r;if(s[e]=t,!(Date.now()-l<250)){for(l=Date.now(),r=0,a=0,n=s.length;a<n;a++)r+=t=s[a];return i.notify(r/h.fileSize)}},i=a.default.Deferred(),n=0,p=0,d=0,c=function(){if(!(d>=h.fileSize)){var o=d+h.settings.multipartPartSize;h.fileSize<o+h.settings.multipartMinLastPartSize&&(o=h.fileSize);var l=h.__file.slice(d,o);d=o;var u=p;return n+=1,p+=1,function(){if("pending"===h.apiDeferred.state())return s[u]=0,h.__autoAbort(a.default.ajax({xhr:function(){var e;return e=a.default.ajaxSettings.xhr(),e.responseType="text",e.upload&&e.upload.addEventListener("progress",(function(e){return f(u,e.loaded)}),!1),e},url:e[u],crossDomain:!0,type:"PUT",processData:!1,contentType:h.fileType,data:l}).retry(r(r({},h.settings.retryConfig),{},{onAttemptFail:function(e){var a=e.attempt;h.settings.debugUploads&&C("Part #".concat(u,"(").concat(a,") upload is failed."),t)}})).done((function(){if(n-=1,c(),!n)return i.resolve()})).fail((function(){return h.settings.debugUploads&&A("Part #".concat(u," and file upload is failed."),t),i.reject()})))}()}},o=0,u=this.settings.multipartConcurrency;u>=0?o<u:o>u;u>=0?++o:--o)c();return i}},{key:"multipartComplete",value:function(e){var t,a=this;return t={UPLOADCARE_PUB_KEY:this.settings.publicKey,uuid:e},this.__autoAbort(we("".concat(this.settings.urlBase,"/multipart/complete/?jsonerrors=1"),"POST",t,{headers:{"X-UC-User-Agent":this.settings._userAgent},retryConfig:this.settings.retryConfig})).fail((function(t){if(a.settings.debugUploads)return A("Can't complete multipart upload.",e,a.settings.publicKey,t.message)}))}}]),i}(Vt);Nt.prototype.sourceName="local";var qt=function(e){f(i,e);var t=v(i);function i(e){var n;return u(this,i),(n=t.apply(this,arguments)).__input=e,n.fileId=ie(),n.fileName=a.default(n.__input).val().split("\\").pop(),n.__notifyApi(),n}return d(i,[{key:"__startUpload",value:function(){var e,t,i,n;return e=a.default.Deferred(),n="".concat(this.settings.urlBase,"/iframe/"),i="uploadcare--iframe-".concat(this.fileId),this.__iframe=a.default("<iframe>").attr({id:i,name:i}).css("display","none").appendTo("body").on("load",e.resolve).on("error",e.reject),t=function(e,t){return a.default("<input/>",{type:"hidden",name:e,value:t})},a.default(this.__input).attr("name","file"),this.__iframeForm=a.default("<form>").attr({method:"POST",action:n,enctype:"multipart/form-data",target:i}).append(t("UPLOADCARE_PUB_KEY",this.settings.publicKey)).append(t("UPLOADCARE_SIGNATURE",this.settings.secureSignature)).append(t("UPLOADCARE_EXPIRE",this.settings.secureExpire)).append(t("UPLOADCARE_FILE_ID",this.fileId)).append(t("UPLOADCARE_STORE",this.settings.doNotStore?"":"auto")).append(t("UPLOADCARE_SOURCE",this.sourceInfo.source)).append(this.__input).css("display","none").appendTo("body").submit(),e.always(this.__cleanUp.bind(this))}},{key:"__cleanUp",value:function(){var e,t;return null!=(e=this.__iframe)&&e.off("load error").remove(),null!=(t=this.__iframeForm)&&t.remove(),this.__iframe=null,this.__iframeForm=null,this.__iframeForm}}]),i}(Vt);qt.prototype.sourceName="local-compat";var Ht=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(e,t){ /*! * Pusher JavaScript Library v1.12.2 * http://pusherapp.com/ * * Copyright 2011, Pusher * Released under the MIT licence. */ var a=D.isWindowDefined;(function(){var e,t;(e=function(t,a){this.options=a||{},this.key=t,this.channels=new e.Channels,this.global_emitter=new e.EventsDispatcher;var i=this;this.checkAppKey(),this.connection=new e.Connection(this.key,this.options),this.connection.bind("connected",(function(){i.subscribeAll()})).bind("message",(function(e){var t,a=0===e.event.indexOf("pusher_internal:");e.channel&&(t=i.channel(e.channel))&&t.emit(e.event,e.data),a||i.global_emitter.emit(e.event,e.data)})).bind("disconnected",(function(){i.channels.disconnect()})).bind("error",(function(t){e.warn("Error",t)})),e.instances.push(this),e.isReady&&i.connect()}).instances=[],e.prototype={channel:function(e){return this.channels.find(e)},connect:function(){this.connection.connect()},disconnect:function(){this.connection.disconnect()},bind:function(e,t){return this.global_emitter.bind(e,t),this},bind_all:function(e){return this.global_emitter.bind_all(e),this},subscribeAll:function(){var e;for(e in this.channels.channels)this.channels.channels.hasOwnProperty(e)&&this.subscribe(e)},subscribe:function(e){var t=this,a=this.channels.add(e,this);return"connected"===this.connection.state&&a.authorize(this.connection.socket_id,this.options,(function(i,n){i?a.emit("pusher:subscription_error",n):t.send_event("pusher:subscribe",{channel:e,auth:n.auth,channel_data:n.channel_data})})),a},unsubscribe:function(e){this.channels.remove(e),"connected"===this.connection.state&&this.send_event("pusher:unsubscribe",{channel:e})},send_event:function(e,t,a){return this.connection.send_event(e,t,a)},checkAppKey:function(){null!==this.key&&void 0!==this.key||e.warn("Warning","You must pass your app key when you instantiate Pusher.")}},e.Util={extend:function e(t,a){for(var i in a)a[i]&&a[i].constructor&&a[i].constructor===Object?t[i]=e(t[i]||{},a[i]):t[i]=a[i];return t},stringify:function(){for(var e=["Pusher"],t=0;t<arguments.length;t++)"string"==typeof arguments[t]?e.push(arguments[t]):null==window.JSON?e.push(arguments[t].toString()):e.push(JSON.stringify(arguments[t]));return e.join(" : ")},arrayIndexOf:function(e,t){var a=Array.prototype.indexOf;if(null==e)return-1;if(a&&e.indexOf===a)return e.indexOf(t);for(i=0,l=e.length;i<l;i++)if(e[i]===t)return i;return-1}},e.debug=function(){e.log&&e.log(e.Util.stringify.apply(this,arguments))},e.warn=function(){if(window.console&&window.console.warn)window.console.warn(e.Util.stringify.apply(this,arguments));else{if(!e.log)return;e.log(e.Util.stringify.apply(this,arguments))}},e.VERSION="1.12.2",e.host="ws.pusherapp.com",e.ws_port=80,e.wss_port=443,e.channel_auth_endpoint="/pusher/auth",e.cdn_http="http://js.pusher.com/",e.cdn_https="https://d3dy5gmtp8yhk7.cloudfront.net/",e.dependency_suffix=".min",e.channel_auth_transport="ajax",e.activity_timeout=12e4,e.pong_timeout=3e4,e.isReady=!1,e.ready=function(){e.isReady=!0;for(var t=0,a=e.instances.length;t<a;t++)e.instances[t].connect()},function(){function t(){this._callbacks={}}function a(e){this.callbacks=new t,this.global_callbacks=[],this.failThrough=e}t.prototype.get=function(e){return this._callbacks[this._prefix(e)]},t.prototype.add=function(e,t){var a=this._prefix(e);this._callbacks[a]=this._callbacks[a]||[],this._callbacks[a].push(t)},t.prototype.remove=function(t,a){if(this.get(t)){var i=e.Util.arrayIndexOf(this.get(t),a);this._callbacks[this._prefix(t)].splice(i,1)}},t.prototype._prefix=function(e){return"_"+e},a.prototype.bind=function(e,t){return this.callbacks.add(e,t),this},a.prototype.unbind=function(e,t){return this.callbacks.remove(e,t),this},a.prototype.emit=function(e,t){for(var a=0;a<this.global_callbacks.length;a++)this.global_callbacks[a](e,t);var i=this.callbacks.get(e);if(i)for(a=0;a<i.length;a++)i[a](t);else this.failThrough&&this.failThrough(e,t);return this},a.prototype.bind_all=function(e){return this.global_callbacks.push(e),this},e.EventsDispatcher=a}(),function(){function t(e,t,a){void 0!==t[e]&&t[e](a)}function a(t,a,i){e.EventsDispatcher.call(this),this.state=void 0,this.errors=[],this.stateActions=i,this.transitions=a,this.transition(t)}a.prototype.transition=function(a,i){var n,r=this.state,o=this.stateActions;if(r&&-1==e.Util.arrayIndexOf(this.transitions[r],a))throw this.emit("invalid_transition_attempt",{oldState:r,newState:a}),new Error("Invalid transition ["+r+" to "+a+"]");t(r+"Exit",o,i),t(r+"To"+((n=a).substr(0,1).toUpperCase()+n.substr(1)),o,i),t(a+"Pre",o,i),this.state=a,this.emit("state_change",{oldState:r,newState:a}),t(a+"Post",o,i)},a.prototype.is=function(e){return this.state===e},a.prototype.isNot=function(e){return this.state!==e},e.Util.extend(a.prototype,e.EventsDispatcher.prototype),e.Machine=a}(),(t=function(){var t=this;e.EventsDispatcher.call(this),void 0!==window.addEventListener&&(window.addEventListener("online",(function(){t.emit("online",null)}),!1),window.addEventListener("offline",(function(){t.emit("offline",null)}),!1))}).prototype.isOnLine=function(){return void 0===window.navigator.onLine||window.navigator.onLine},e.Util.extend(t.prototype,e.EventsDispatcher.prototype),e.NetInfo=t,function(){var t={initialized:["waiting","failed"],waiting:["connecting","permanentlyClosed"],connecting:["open","permanentlyClosing","impermanentlyClosing","waiting"],open:["connected","permanentlyClosing","impermanentlyClosing","waiting"],connected:["permanentlyClosing","waiting"],impermanentlyClosing:["waiting","permanentlyClosing"],permanentlyClosing:["permanentlyClosed"],permanentlyClosed:["waiting","failed"],failed:["permanentlyClosed"]};function a(t){t.connectionWait=0,"flash"===e.TransportType?t.openTimeout=5e3:t.openTimeout=2e3,t.connectedTimeout=2e3,t.connectionSecure=t.compulsorySecure,t.connectionAttempts=0}function i(i,n){var r=this;function o(){r.connectionWait<1e4&&(r.connectionWait+=2e3),r.openTimeout<1e4&&(r.openTimeout+=2e3),r.connectedTimeout<1e4&&(r.connectedTimeout+=2e3),!0!==r.compulsorySecure&&(r.connectionSecure=!r.connectionSecure),r.connectionAttempts++}function l(){r._machine.transition("impermanentlyClosing")}function s(){r._activityTimer&&clearTimeout(r._activityTimer),r._activityTimer=setTimeout((function(){r.send_event("pusher:ping",{}),r._activityTimer=setTimeout((function(){r.socket.close()}),r.options.pong_timeout||e.pong_timeout)}),r.options.