UNPKG

uploadcare-widget

Version:
18 lines (17 loc) 81.2 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 n=t(e);function r(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function o(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?r(Object(n),!0).forEach((function(t){d(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):r(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function a(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;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 n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,a(r.key),r)}}function f(e,t,n){return t&&c(e.prototype,t),n&&c(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function d(e,t,n){return(t=a(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function p(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 v(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 y(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 n,r=h(e);if(t){var i=h(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return v(this,n)}}function _(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=h(e)););return e}function b(){return(b="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,n){var r=_(e,t);if(r){var i=Object.getOwnPropertyDescriptor(r,t);return i.get?i.get.call(arguments.length<3?e:n):i.value}}).apply(this,arguments)}function w(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,o,a,s=[],u=!0,l=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=o.call(n)).done)&&(s.push(r.value),s.length!==t);u=!0);}catch(e){l=!0,i=e}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(l)throw i}}return s}}(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 A(e){return function(e){if(Array.isArray(e))return x(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 x(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?x(e,t):void 0}}function x(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var S=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 S.apply(void 0,["Debug:"].concat(Array.prototype.slice.call(arguments)));try{var t;return(t=window.console).debug.apply(t,arguments)}catch(e){}},T=function(){var e;if(!(null!=(e=window.console)?e.warn:void 0))return S.apply(void 0,["Warning:"].concat(Array.prototype.slice.call(arguments)));try{var t;return(t=window.console).warn.apply(t,arguments)}catch(e){}},j={},U=function(e){if(null==j[e])return j[e]=!0,T(e)},I=function(){return"object"===("undefined"==typeof window?"undefined":s(window))},O=Object.freeze({__proto__:null,isWindowDefined:I});function D(e,t,n){var r;if("RequestThrottledError"===(null==e||null===(r=e.responseJSON)||void 0===r||null===(r=r.error)||void 0===r?void 0:r.error_code)&&n.attempt<t.throttledAttempts){var i=Number.parseFloat(e.getResponseHeader("retry-after"));return{shouldRetry:!0,retryTimeout:Number.isFinite(i)?Math.ceil(1e3*i):15e3}}return-1!==["error","timeout"].indexOf(e.statusText)&&n.attempt<t.attempts?{shouldRetry:!0,retryTimeout:Math.round(t.baseTimeout*Math.pow(t.factor,n.attempt))}:{shouldRetry:!1}}function P(e,t,r,i){var a=["baseTimeout","attempts","factor"].find((function(e){return void 0===r[e]}));if(a)return T('Option key "'.concat(a,'" is missed in the retry config.')),e;i={attempt:i.attempt||0,timeoutId:null,jqXHR:null},r=o({baseTimeout:null,attempts:null,factor:null,onAttemptFail:null,debugUploads:!1},r);var s=function(e,t,r,i){return function(){var a=n.default.Deferred();function s(){i.jqXHR=n.default.ajax(t).retry(r,o(o({},i),{},{attempt:i.attempt+1})).done(a.resolve).fail(a.reject)}for(var u,l=D(e,r,i),c=l.shouldRetry,f=l.retryTimeout,d=arguments.length,p=new Array(d),h=0;h<d;h++)p[h]=arguments[h];c?(null===(u=r.onAttemptFail)||void 0===u||u.call(r,{attempt:i.attempt}),r.debugUploads&&S("Attempt failed. Retry #".concat(i.attempt+1," in ").concat(f,"ms"),e),i.timeoutId=setTimeout(s,f)):"resolved"===e.state()?a.resolveWith(e,p):a.rejectWith(e,p);return a}}(e,t,r,i),u=e.then(s,s);return u.abort=function(){var t;clearTimeout(i.timeoutId);for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];e.abort.apply(e,r),null===(t=i.jqXHR)||void 0===t||t.abort.apply(t,r)},u}I()&&n.default.ajaxPrefilter((function(e,t,n){n.retry=function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return P(n,e,t,r)}})),I()&&window.XDomainRequest&&n.default.ajaxTransport((function(e){var t;if(e.crossDomain&&e.async)return e.timeout&&(e.xdrTimeout=e.timeout,delete e.timeout),{send:function(n,r){function i(e,n,i,o){t.onload=t.onerror=t.ontimeout=function(){},t=void 0,r(e,n,i,o)}(t=new XDomainRequest).onload=function(){i(200,"OK",{text:t.responseText},"Content-Type: "+t.contentType)},t.onerror=function(){i(404,"Not Found")},t.onprogress=function(){},t.ontimeout=function(){i(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 E,R=I()&&!!(window.File&&window.FileList&&window.FileReader),F=I()&&!(!window.FormData||!R),z=I()&&("draggable"in(E=document.createElement("div"))||"ondragstart"in E&&"ondrop"in E),L=I()&&function(){var e;return!(!(e=document.createElement("canvas")).getContext||!e.getContext("2d"))}(),M=R&&z,B=null,N=I()&&/^[^(]+\(iP(?:hone|od|ad);\s*(.+?)\)/.exec(navigator.userAgent);if(N){var W=/OS (\d*)_(\d*)/.exec(N[1]);W&&(B=+W[1]+W[2]/10)}var q=I()&&navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&/MacIntel/.test(navigator.platform),K=!1;try{I()&&new window.Blob&&(K=window.Blob)}catch(e){}var G=I()&&(window.URL||window.webkitURL||!1),X=G&&G.createObjectURL&&G,J=I()&&(null!=window.FileReader?window.FileReader.prototype.readAsArrayBuffer:void 0)&&window.FileReader,V=[].indexOf,H=function(e){var t,n,r,i;for(i=[],n=0,r=e.length;n<r;n++)t=e[n],V.call(i,t)<0&&i.push(t);return i},Y=function(e){return setTimeout(e,0)},$=function(e){var t,n;return t=!1,n=null,function(){return t||(n=e.apply(this,arguments),t=!0),n}},Q=function(e){return n.default.Deferred().resolve(e).promise()},Z=function(e,t){var r;return r={},n.default.each(t,(function(t,i){var o=e[i];n.default.isFunction(o)?r[i]=function(){for(var t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];var a=o.apply(e,n);return a===e?r:a}:r[i]=o})),r},ee=function(e){return e.replace(/([A-Z])/g,"_$1").toUpperCase()},te=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,ie=new RegExp("".concat(re.source,"~[0-9]+"),"i"),oe=new RegExp("^/?(".concat(re.source,")(?:/(-/(?:[^/]+/)+)?([^/]*))?$"),"i"),ae=function(e){return oe.exec(ne.exec(e)[3])},se=function(e){return e.replace(/[\\-\\[]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},ue=function(e){var t;return"http:"!==(t=document.location.protocol)&&(t="https:"),e.replace(/^\/\//,t+"//").replace(/\/+$/,"")},le=function(e,t,n){var r,i;return e[0]>t[0]||e[1]>t[1]||n?(i=t[0]/e[0],r=t[1]/e[1],!t[0]||t[1]&&i>r?[Math.round(r*e[0]),t[1]]:[t[0],Math.round(i*e[1])]):e.slice()},ce=["image/*","image/heif","image/heif-sequence","image/heic","image/heic-sequence","image/avif","image/avif-sequence",".heif",".heifs",".heic",".heics",".avif",".avifs"].join(","),fe="B KB MB GB TB PB EB ZB YB".split(" "),de={dataType:"json",crossDomain:!0,cache:!1},pe=function(e,t,r){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o=n.default.ajax(n.default.extend({url:e,type:t,data:r},i,de)).retry(i.retryConfig).fail((function(t,n,r){var i="".concat(n," (").concat(r,")");T("JSONP unexpected error: ".concat(i," while loading ").concat(e))})),a=o.then((function(e){var t,r;return e.error?("string"==typeof e.error?(t=e.error,r=e.error_code):(t=e.error.content,r=e.error.error_code),n.default.Deferred().reject({message:t,code:r})):e}));return a.abort=o.abort.bind(o),a},he=function(e,t,n,r){var i,o,a,s,u,l;if(window.HTMLCanvasElement.prototype.toBlob)return e.toBlob(r,t,n);for(a=(a=e.toDataURL(t,n)).split(","),o=window.atob(a[1]),i=new Uint8Array(o.length),s=u=0,l=o.length;u<l;s=u+=1)i[s]=o.charCodeAt(s);return r(new window.Blob([i],{type:/:(.+\/.+);/.exec(a[0])[1]}))},me=function(e){var t,n,r;return r=0,t=[],n=function(){var e;return t.length?(e=t.shift(),Y((function(){return e(n)}))):r-=1},function(i){return!e||r<e?(r+=1,Y((function(){return i(n)}))):t.push(i)}},ge=[["notify","progress",2],["resolve","done",0],["reject","fail",1]],ve=function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];return n.default.Deferred((function(t){return n.default.each(ge,(function(i,o){var a;return a=n.default.isFunction(r[o[2]])&&r[o[2]],e[o[1]]((function(){var r;return(r=a&&a.apply(this,arguments))&&n.default.isFunction(r.promise)?r.promise().progress(t.notify).done(t.resolve).fail(t.reject):t[o[0]+"With"](this===e?t.promise():this,a?[r]:arguments)}))}))})).promise()},ye=function(e){var t;return t=o({},t=e.metadataCallback?e.metadataCallback()||{}:e.metadata||{}),n.default.each(t,(function(e,n){t[e]=String(n)})),t},_e=55,be=110,we=165,Ae=255,ke="rgba(".concat(_e,", ").concat(be,", ").concat(we,", ").concat(Ae/255,")");function xe(e,t){try{var n=[e-1,t-1,1,1],r=document.createElement("canvas");r.width=1,r.height=1;var i=document.createElement("canvas");i.width=e,i.height=t;var o=r.getContext("2d"),a=i.getContext("2d");a&&(a.fillStyle=ke,a.fillRect.apply(a,n),o.drawImage(i,e-1,t-1,1,1,0,0,1,1));var s=o&&o.getImageData(0,0,1,1).data,u=!1;return s&&(u=s[0]===_e&&s[1]===be&&s[2]===we&&s[3]===Ae),i.width=i.height=1,u}catch(n){return S("Failed to test for max canvas size of ".concat(e,"x").concat(t,"."),n),!1}}function Se(e,t){var n={};return function(){for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];var a=t(i,n);return a in n?n[a]:n[a]=e.apply(void 0,i)}}var Ce={squareSide:[Math.floor(Math.sqrt(5e6)),4096,8192,11180,10836,11402,14188,16384],dimension:[4096,8192,16384,32767,65535]},Te=Ce.squareSide[Ce.squareSide.length-1];function je(e){return function(){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];var o=n.default.Deferred();return Y((function(){var t=e.apply(void 0,r);o.resolve(t)})),o.promise()}}function Ue(e,t){for(var n=w(e,1)[0],r=Object.keys(t).map((function(e){return parseInt(e,10)})).sort((function(e,t){return e-t})),i=0;i<r.length;i++){var o=r[i],a=!!t[o];if(o>n&&a)return o;if(o<n&&!a)return o}return n}var Ie=je(Se(xe,Ue)),Oe=je(Se(xe,Ue));function De(e,t){var r=n.default.Deferred(),i=Ce.squareSide.find((function(n){return n*n>=e*t})),o=Ce.dimension.find((function(n){return n>=e&&n>=t}));if(!i||!o)return r.reject();var a=[Ie(i,i),Oe(o,1)];return n.default.when.apply(n.default,a).done((function(e,t){e&&t?r.resolve():r.reject()})),r.promise()}var Pe,Ee,Re,Fe,ze,Le,Me,Be,Ne,We,qe,Ke,Ge,Xe,Je,Ve,He,Ye,$e,Qe,Ze,et,tt,nt=[].indexOf;ze={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:""},Le=o({},ze),$e={multipleMax:{from:0,to:1e3}},Re={multipleMax:{min:1,max:1e3}},Je={tabs:{all:"file camera url facebook gdrive gphotos dropbox instagram evernote flickr onedrive box vk huddle",default:ze.tabs}},Ve=I()&&(document.currentScript||(tt=document.getElementsByTagName("script"))[tt.length-1]),(Ne=I()&&n.default(Ve).data("integration"))&&null!=Ne&&(ze=n.default.extend(ze,{integration:Ne})),He=function(e){return n.default.isArray(e)||(e=(e=n.default.trim(e))?e.split(" "):[]),e},Pe=function(e,t){var n,r,i,o,a,s,u,l,c=Object.prototype.hasOwnProperty;for(n=0,a=t.length;n<a;n++){if(o=t[n],l=u=He(e[o]),c.apply(Je,[o]))for(l=[],i=0,s=u.length;i<s;i++)r=u[i],c.apply(Je[o],[r])?l=l.concat(He(Je[o][r])):l.push(r);e[o]=H(l)}return e},Qe=function(e,t){var n,r,i;for(n=0,i=t.length;n<i;n++)null!=e[r=t[n]]&&(e[r]=ue(e[r]));return e},Me=function(e,t){var r,i,o,a;for(r=0,o=t.length;r<o;r++)null!=e[i=t[r]]&&("string"==typeof(a=e[i])?(a=n.default.trim(a).toLowerCase(),e[i]=!("false"===a||"disabled"===a)):e[i]=!!a);return e},Be=function(e,t){var n,r,i;for(n=0,i=t.length;n<i;n++)null!=e[r=t[n]]&&(e[r]=parseInt(e[r]));return e},We=function(e){return e._userAgent="UploadcareWidget/".concat("3.21.8","/").concat(e.publicKey," (JavaScript").concat(e.integration?"; ".concat(e.integration):"",")"),e},qe=function(e){e.retryAttempts===Le.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}},Ye=function(e,t){var n,r;for(n in t)r=t[n],null!=e[n]&&e[n]===r.from&&(e[n]=r.to);return e},Ee=function(e,t){var n,r,i;for(n in t){var o=t[n];i=o.min,r=o.max,null!=e[n]&&(e[n]=Math.min(Math.max(e[n],i),r))}return e},Ze=function(e,t){for(var n=0,r=t.length;n<r;n++){var i=t[n];e[i]&&"function"!=typeof e[i]&&U('Option "'.concat(i,'" is expected to be a function. Instead got: ').concat(s(e[i])))}},et=function(e,t){for(var n=0,r=t.length;n<r;n++){var i=t[n];e[i]&&(o=e[i],"[object Object]"!==Object.prototype.toString.call(o))&&U('Option "'.concat(i,'" is expected to be an object. Instead got: ').concat(s(e[i])))}var o},Ge=function(e){var t;return{downscale:"x"===(t=/^([0-9]+)([x:])([0-9]+)\s*(|upscale|minimum)$/i.exec(n.default.trim(e.toLowerCase()))||[])[2],upscale:!!t[4],notLess:"minimum"===t[4],preferedSize:t.length?[+t[1],+t[3]]:void 0}},Xe=function(e){var t=/^([0-9]+)x([0-9]+)(?:\s+(\d{1,2}|100)%)?$/i.exec(n.default.trim(e.toLowerCase()))||[];if(!t.length)return!1;var r=t[1]*t[2],i=Te*Te;return r>i?(U("Shrinked size can not be larger than ".concat(Math.floor(i/1e3/1e3),"MP. ")+"You have set ".concat(t[1],"x").concat(t[2]," (")+"".concat(Math.ceil(r/1e3/100)/10,"MP).")),!1):{quality:t[3]?t[3]/100:void 0,size:r}},Fe=function(e,t){var n,r,i,o;return this.previewProxy?(r=(i=!/\?/.test(this.previewProxy))||!/=$/.test(this.previewProxy),n=!i&&!/[&?=]$/.test(this.previewProxy),o=encodeURIComponent(e),r&&(o="url="+o),n&&(o="&"+o),i&&(o="?"+o),this.previewProxy+o):e},Ke=function(e){Pe(e,["tabs","preferredTypes","videoPreferredMimeTypes"]),Qe(e,["cdnBase","socialBase","urlBase","scriptBase"]),Me(e,["doNotStore","imagesOnly","multiple","clearable","pathValue","previewStep","systemDialog","debugUploads","multipleMaxStrict","cameraMirrorDefault"]),Be(e,["multipleMax","multipleMin","multipartMinSize","multipartPartSize","multipartMinLastPartSize","multipartConcurrency","multipartMaxAttempts","retryAttempts","retryThrottledAttempts","retryBaseTimeout","retryFactor","parallelDirectUploads"]),Ze(e,["previewUrlCallback","metadataCallback"]),et(e,["metadata"]),Ye(e,$e),Ee(e,Re),We(e),qe(e),!1===e.crop||n.default.isArray(e.crop)||(/^(disabled?|false|null)$/i.test(e.crop)?e.crop=!1:n.default.isPlainObject(e.crop)?e.crop=[e.crop]:e.crop=n.default.map((""+e.crop).split(","),Ge)),e.imageShrink&&!n.default.isPlainObject(e.imageShrink)&&(e.imageShrink=Xe(e.imageShrink)),(e.crop||e.multiple)&&(e.previewStep=!0),F||(e.systemDialog=!1),e.validators&&(e.validators=e.validators.slice()),e.previewProxy&&!e.previewUrlCallback&&(e.previewUrlCallback=Fe);var t=e.tabs.indexOf("skydrive");return-1!==t&&(e.tabs[t]="onedrive"),e};var rt,it=function(){var e,t,n;for(e in t={},ze)null!=(n=window["UPLOADCARE_".concat(ee(e))])&&(t[e]=n);return t},ot=$((function(e,t){var r;return t||(ze=n.default.extend(ze,it())),r=Ke(n.default.extend(ze,e||{})),st.fire(r),r})),at=function(e){var t;return t=n.default.extend({},ot()),n.default.isEmptyObject(e)||(t=Ke(n.default.extend(t,e))),t},st=I()&&n.default.Callbacks("once memory"),ut=function(){function e(){u(this,e),this.urls=[],this.styles=[]}return f(e,[{key:"addUrl",value:function(e){if(!/^https?:\/\//i.test(e))throw new Error("Embedded urls should be absolute. "+e);if(!(nt.call(this.urls,e)>=0))return this.urls.push(e)}},{key:"addStyle",value:function(e){return this.styles.push(e)}}]),e}(),lt=function(e,t){var r;return r=n.default.Deferred(),t&&(e.src=t),e.complete?r.resolve(e):(n.default(e).one("load",(function(){return r.resolve(e)})),n.default(e).one("error",(function(){return r.reject(e)}))),r.promise()},ct=function e(t){return n.default.isArray(t)?n.default.when.apply(null,n.default.map(t,e)):t.src?lt(t):lt(new window.Image,t)},ft=function(){var e=n.default.Deferred();if(void 0!==rt)e.resolve(rt);else{var t=new window.Image;t.onload=function(){rt=t.naturalWidth<t.naturalHeight,t.src="//:0",e.resolve(rt)},t.src="data:image/jpg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/4QA6RXhpZgAATU0AKgAAAAgAAwESAAMAAAABAAYAAAEoAAMAAAABAAIAAAITAAMAAAABAAEAAAAAAAD/2wBDAP//////////////////////////////////////////////////////////////////////////////////////wAALCAABAAIBASIA/8QAJgABAAAAAAAAAAAAAAAAAAAAAxABAAAAAAAAAAAAAAAAAAAAAP/aAAgBAQAAPwBH/9k="}return e.promise()},dt=function(e,t,r){var i=n.default.Deferred();return Y((function(){try{var n=document.createElement("canvas"),o=n.getContext("2d");n.width=t,n.height=r,o.imageSmoothingQuality="high",o.drawImage(e,0,0,t,r),e.src="//:0",e.width=e.height=1,i.resolve(n)}catch(e){S("Failed to shrink image to size ".concat(t,"x").concat(r,"."),e),i.reject(e)}})),i.promise()},pt=function(e,t,r,i,o){var a=function(e,t,n,r){var i=[],o=t,a=n;do{i.push([o,a]),o=Math.round(o/r),a=Math.round(a/r)}while(o<e*r);return i.reverse()}(t,r,i,o),s=n.default.Deferred(),u=n.default.Deferred();u.resolve(e);var l,c=function(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=k(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}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 o,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}(a);try{var f=function(){var e=w(l.value,2),i=e[0],o=e[1];u=u.then((function(e){var t=n.default.Deferred();return De(i,o).then((function(){return t.resolve(e,!1)})).fail((function(){return t.resolve(e,!0)})),t.promise()})).then((function(e,t){return t?e:dt(e,i,o)})).then((function(e){return s.notify((t-i)/(t-r)),e}))};for(c.s();!(l=c.n()).done;)f()}catch(e){c.e(e)}finally{c.f()}return u.done((function(e){s.resolve(e)})),u.fail((function(e){s.reject(e)})),s.promise()},ht=function(e,t){var r=n.default.Deferred();if(.71*e.width*e.height*.71<t.size)return r.reject("not required");var i=e.width,o=e.height,a=i/o,s=Math.floor(Math.sqrt(t.size*a)),u=Math.floor(t.size/Math.sqrt(t.size*a));return De(s,u).fail((function(){r.reject("not supported")})).then((function(){("imageSmoothingQuality"in document.createElement("canvas").getContext("2d")&&!B&&!q?function(e,t,n){return dt(e,t,n)}(e,s,u):pt(e,i,s,u,.71)).done((function(e){return r.resolve(e)})).progress((function(e){return r.notify(e)})).fail((function(){return r.reject("not supported")}))})),r.promise()},mt=I()&&window.DataView,gt=me(1),vt=function(e,t){var r=n.default.Deferred();return X&&mt&&K?(gt((function(i){r.always(i),St(e).then((function(e){if(e)return r.reject("skipped"),n.default.Deferred().reject()})).then((function(){return xt(e).fail((function(){r.reject("not image")}))})).done((function(i){r.notify(.1);var o=n.default.when(bt(e),ft(),wt(e)).always((function(e,a,s){r.notify(.2);var u="resolved"===o.state(),l=ht(i,t);l.progress((function(e){return r.notify(.2+.6*e)})),l.fail(r.reject),l.done((function(i){var o="image/jpeg",l=t.quality||.8;!u&&Ut(i)&&(o="image/png",l=void 0),he(i,o,l,(function(t){i.width=i.height=1,r.notify(.9);var o=n.default.Deferred().resolve(t);e&&(o=o.then((function(t){return At(t,e,a)})).catch((function(){return t}))),(null==s?void 0:s.length)>0&&(o=o.then((function(e){return kt(e,s)})).catch((function(){return t}))),o.done(r.resolve),o.fail((function(){return r.resolve(t)}))}))}))}))}))})),r.promise()):r.reject("support")},yt=function(e){var t,r,i,o,a;return a=function(e,n){var r;return(r=new J).onload=function(){return n(new mt(r.result))},r.onerror=function(e){return t.reject("reader",e)},r.readAsArrayBuffer(e)},i=function(){return a(e.slice(r,r+128),(function(e){var t,n,i;for(t=n=0,i=e.byteLength;i>=0?n<i:n>i;t=i>=0?++n:--n)if(255===e.getUint8(t)){r+=t;break}return o()}))},o=function(){var n;return n=r,a(e.slice(r,r+=4),(function(o){var s,u;return 4!==o.byteLength||255!==o.getUint8(0)?t.reject("corrupted"):218===(u=o.getUint8(1))?t.resolve():(s=o.getUint16(2)-2,a(e.slice(r,r+=s),(function(e){return e.byteLength!==s?t.reject("corrupted"):(t.notify(n,s,u,e),i())})))}))},t=n.default.Deferred(),J&&mt?(r=2,a(e.slice(0,2),(function(e){return 65496!==e.getUint16(0)?t.reject("not jpeg"):i()})),t.promise()):t.reject("support")},_t=function(e,t,r){var i,o,a,s;return i=n.default.Deferred(),a=[],o=[],(s=yt(e)).fail(i.reject),s.progress((function(e,n,r){if(r===t)return a.push(e),o.push(n)})),s.done((function(){var n,s,u,l,c,f,d,p,h;for(d=[e.slice(0,2)],l=0,f=r.length;l<f;l++)n=r[l],(u=new mt(new ArrayBuffer(4))).setUint16(0,65280+t),u.setUint16(2,n.byteLength+2),d.push(u.buffer),d.push(n);for(p=2,s=c=0,h=a.length;h>=0?c<h:c>h;s=h>=0?++c:--c)a[s]>p&&d.push(e.slice(p,a[s])),p=a[s]+o[s]+4;return d.push(e.slice(p,e.size)),i.resolve(new K(d,{type:e.type}))})),i.promise()},bt=function(e){var t=null,r=yt(e);return r.progress((function(e,n,r,i){if(!t&&225===r&&i.byteLength>=14&&1165519206===i.getUint32(0)&&0===i.getUint16(4))return t=i})),r.then((function(){return t}),(function(){return n.default.Deferred().reject(t)}))},wt=function(e){var t=[],r=yt(e);return r.progress((function(e,n,r,i){226===r&&1229144927===i.getUint32(0)&&1347571526===i.getUint32(4)&&1229735168===i.getUint32(8)&&t.push(i)})),r.then((function(){return t}),(function(){return n.default.Deferred().reject(t)}))},At=function(e,t,n){return n&&Ct(t,1),_t(e,225,[t.buffer])},kt=function(e,t){return _t(e,226,t.map((function(e){return e.buffer})))},xt=function(e){var t=n.default.Deferred();return kt(e,[]).catch((function(){return e})).then((function(e){var n=ct(X.createObjectURL(e));n.always((function(e){X.revokeObjectURL(e.src)})),n.fail((function(){t.reject()})),n.done((function(e){t.resolve(e)}))})).fail((function(){t.reject()})),t.promise()},St=function(e){var t=[1,3],n=[192,193,194,195,197,198,199,201,202,203,205,206,207],r=!1,i=yt(e);return i.progress((function(e,i,o,a){if(!r&&n.indexOf(o)>=0){var s=a.getUint8(5);t.indexOf(s)<0&&(r=!0)}})),i.then((function(){return r})).catch((function(){return r}))},Ct=function(e,t){jt(e,(function(n,r){return e.setUint16(n,t,r)}))},Tt=function(e){return jt(e,(function(t,n){return e.getUint16(t,n)}))},jt=function(e,t){var n,r,i,o;if(!e||e.byteLength<14||1165519206!==e.getUint32(0)||0!==e.getUint16(4))return null;if(18761===e.getUint16(6))r=!0;else{if(19789!==e.getUint16(6))return null;r=!1}if(42!==e.getUint16(8,r))return null;for(i=8+e.getUint32(10,r),n=0,o=e.getUint16(i-2,r);o>=0?n<o:n>o;o>=0?++n:--n){if(e.byteLength<i+10)return null;if(274===e.getUint16(i,r))return t(i+8,r);i+=12}return null},Ut=function(e){var t,n,r,i,o,a;for(50,(t=document.createElement("canvas")).width=t.height=50,(n=t.getContext("2d")).drawImage(e,0,0,50,50),r=n.getImageData(0,0,50,50).data,t.width=t.height=1,i=o=3,a=r.length;o<a;i=o+=4)if(r[i]<254)return!0;return!1},It=function(){function e(t,n){var r,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};u(this,e),this.settings=n,this.sourceInfo=i,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,(r=this.sourceInfo).source||(r.source=this.sourceName),this.__setupValidation(),this.__initApi()}return f(e,[{key:"__startUpload",value:function(){return n.default.Deferred().resolve()}},{key:"__completeUpload",value:function(){var e,t,n,r,i=this;return n=0,this.settings.debugUploads&&(C("Load file info.",this.fileId,this.settings.publicKey),t=setInterval((function(){return C("Still waiting for file ready.",n,i.fileId,i.settings.publicKey)}),5e3),this.apiDeferred.done((function(){return C("File uploaded.",n,i.fileId,i.settings.publicKey)})).always((function(){return clearInterval(t)}))),r=100,(e=function(){if("pending"===i.apiDeferred.state())return n+=1,i.__updateInfo().done((function(){return setTimeout(e,r),r+=50}))})()}},{key:"__updateInfo",value:function(){var e=this;return pe("".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&&S("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,n,r,i,o,a;n=this.__fileInfo();try{for(i=this.validators,o=[],t=0,r=i.length;t<r;t++)a=i[t],o.push(a(n));return o}catch(t){return e=t,this.__rejectApi(e.message)}}},{key:"__initApi",value:function(){return this.apiDeferred=n.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 n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return t.__extendApi(ve.apply(void 0,[e].concat(r)))},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}(),Ot=null,Dt=function(e){p(r,e);var t=y(r);function r(e){var n;return u(this,r),(n=t.apply(this,arguments)).__file=e,n.fileName=n.__file.name||"original",n.__notifyApi(),n}return f(r,[{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,r,i=this;return this.apiDeferred.always((function(){return i.__file=null,i.__file})),this.__file.size>=this.settings.multipartMinSize&&K?(this.setFile(),this.multipartUpload()):(t=B,!this.settings.imageShrink||t&&t<8?(this.setFile(),this.directUpload()):(e=n.default.Deferred(),r=.4,vt(this.__file,this.settings.imageShrink).progress((function(t){return e.notify(t*r)})).done(this.setFile.bind(this)).fail((function(){return i.setFile(),r*=.1})).always((function(){return e.notify(r),i.directUpload().done(e.resolve).fail(e.reject).progress((function(t){return e.notify(r+t*(1-r))}))})),e))}},{key:"__autoAbort",value:function(e){return this.apiDeferred.fail((function(){return e.abort()})),e}},{key:"directRunner",value:function(e){return Ot||(Ot=me(this.settings.parallelDirectUploads)),Ot(e)}},{key:"directUpload",value:function(){var e,t=this;return e=n.default.Deferred(),this.__file?this.fileSize>104857600?(this.__rejectApi("size"),e):(this.directRunner((function(r){if(e.always(r),"pending"===t.apiDeferred.state()){var i=new window.FormData;return i.append("UPLOADCARE_PUB_KEY",t.settings.publicKey),i.append("signature",t.settings.secureSignature),i.append("expire",t.settings.secureExpire),i.append("UPLOADCARE_STORE",t.settings.doNotStore?"":"auto"),i.append("file",t.__file,t.fileName),i.append("file_name",t.fileName),i.append("source",t.sourceInfo.source),n.default.each(ye(t.settings),(function(e,t){i.append("metadata[".concat(e,"]"),t)})),t.__autoAbort(n.default.ajax({xhr:function(){var t;return t=n.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:i,dataType:"json"}).retry(t.settings.retryConfig).done((function(n){if(null!=n?n.file:void 0)return t.fileId=n.file,e.resolve();if(n.error){var r=n.error,i=r.content,o=r.error_code;return e.reject({message:i,code:o})}return e.reject()})).fail(e.reject))}})),e):(this.__rejectApi("baddata"),e)}},{key:"multipartUpload",value:function(){var e,t=this;return e=n.default.Deferred(),this.__file?(this.multipartStart().done((function(n){return t.uploadParts(n.parts,n.uuid).done((function(){return t.multipartComplete(n.uuid).done((function(n){return t.fileId=n.uuid,t.__handleFileData(n),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 n.default.each(ye(this.settings),(function(e,n){t["metadata[".concat(e,"]")]=n})),this.__autoAbort(pe("".concat(this.settings.urlBase,"/multipart/start/?jsonerrors=1"),"POST",t,{headers:{"X-UC-User-Agent":this.settings._userAgent},retryConfig:this.settings.retryConfig})).fail((function(n){if(e.settings.debugUploads)return S("Can't start multipart upload.",n.message,t)}))}},{key:"uploadParts",value:function(e,t){var r,i,a,s,u,l,c,f,d,p,h=this;for(u=[],s=Date.now(),p=function(e,t){var n,i,o;if(u[e]=t,!(Date.now()-s<250)){for(s=Date.now(),o=0,n=0,i=u.length;n<i;n++)o+=t=u[n];return r.notify(o/h.fileSize)}},r=n.default.Deferred(),i=0,d=0,f=0,c=function(){if(!(f>=h.fileSize)){var a=f+h.settings.multipartPartSize;h.fileSize<a+h.settings.multipartMinLastPartSize&&(a=h.fileSize);var s=h.__file.slice(f,a);f=a;var l=d;return i+=1,d+=1,function(){if("pending"===h.apiDeferred.state())return u[l]=0,h.__autoAbort(n.default.ajax({xhr:function(){var e;return e=n.default.ajaxSettings.xhr(),e.responseType="text",e.upload&&e.upload.addEventListener("progress",(function(e){return p(l,e.loaded)}),!1),e},url:e[l],crossDomain:!0,type:"PUT",processData:!1,contentType:h.fileType,data:s}).retry(o(o({},h.settings.retryConfig),{},{onAttemptFail:function(e){var n=e.attempt;h.settings.debugUploads&&C("Part #".concat(l,"(").concat(n,") upload is failed."),t)}})).done((function(){if(i-=1,c(),!i)return r.resolve()})).fail((function(){return h.settings.debugUploads&&S("Part #".concat(l," and file upload is failed."),t),r.reject()})))}()}},a=0,l=this.settings.multipartConcurrency;l>=0?a<l:a>l;l>=0?++a:--a)c();return r}},{key:"multipartComplete",value:function(e){var t,n=this;return t={UPLOADCARE_PUB_KEY:this.settings.publicKey,uuid:e},this.__autoAbort(pe("".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(n.settings.debugUploads)return S("Can't complete multipart upload.",e,n.settings.publicKey,t.message)}))}}]),r}(It);Dt.prototype.sourceName="local";var Pt=function(e){p(r,e);var t=y(r);function r(e){var i;return u(this,r),(i=t.apply(this,arguments)).__input=e,i.fileId=te(),i.fileName=n.default(i.__input).val().split("\\").pop(),i.__notifyApi(),i}return f(r,[{key:"__startUpload",value:function(){var e,t,r,i;return e=n.default.Deferred(),i="".concat(this.settings.urlBase,"/iframe/"),r="uploadcare--iframe-".concat(this.fileId),this.__iframe=n.default("<iframe>").attr({id:r,name:r}).css("display","none").appendTo("body").on("load",e.resolve).on("error",e.reject),t=function(e,t){return n.default("<input/>",{type:"hidden",name:e,value:t})},n.default(this.__input).attr("name","file"),this.__iframeForm=n.default("<form>").attr({method:"POST",action:i,enctype:"multipart/form-data",target:r}).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}}]),r}(It);Pt.prototype.sourceName="local-compat";var Et=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 n=O.isWindowDefined;(function(){var e,t;(e=function(t,n){this.options=n||{},this.key=t,this.channels=new e.Channels,this.global_emitter=new e.EventsDispatcher;var r=this;this.checkAppKey(),this.connection=new e.Connection(this.key,this.options),this.connection.bind("connected",(function(){r.subscribeAll()})).bind("message",(function(e){var t,n=0===e.event.indexOf("pusher_internal:");e.channel&&(t=r.channel(e.channel))&&t.emit(e.event,e.data),n||r.global_emitter.emit(e.event,e.data)})).bind("disconnected",(function(){r.channels.disconnect()})).bind("error",(function(t){e.warn("Error",t)})),e.instances.push(this),e.isReady&&r.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,n=this.channels.add(e,this);return"connected"===this.connection.state&&n.authorize(this.connection.socket_id,this.options,(function(r,i){r?n.emit("pusher:subscription_error",i):t.send_event("pusher:subscribe",{channel:e,auth:i.auth,channel_data:i.channel_data})})),n},unsubscribe:function(e){this.channels.remove(e),"connected"===this.connection.state&&this.send_event("pusher:unsubscribe",{channel:e})},send_event:function(e,t,n){return this.connection.send_event(e,t,n)},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,n){for(var r in n)n[r]&&n[r].constructor&&n[r].constructor===Object?t[r]=e(t[r]||{},n[r]):t[r]=n[r];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 n=Array.prototype.indexOf;if(null==e)return-1;if(n&&e.indexOf===n)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,n=e.instances.length;t<n;t++)e.instances[t].connect()},function(){function t(){this._callbacks={}}function n(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 n=this._prefix(e);this._callbacks[n]=this._callbacks[n]||[],this._callbacks[n].push(t)},t.prototype.remove=function(t,n){if(this.get(t)){var r=e.Util.arrayIndexOf(this.get(t),n);this._callbacks[this._prefix(t)].splice(r,1)}},t.prototype._prefix=function(e){return"_"+e},n.prototype.bind=function(e,t){return this.callbacks.add(e,t),this},n.prototype.unbind=function(e,t){return this.callbacks.remove(e,t),this},n.prototype.emit=function(e,t){for(var n=0;n<this.global_callbacks.length;n++)this.global_callbacks[n](e,t);var r=this.callbacks.get(e);if(r)for(n=0;n<r.length;n++)r[n](t);else this.failThrough&&this.failThrough(e,t);return this},n.prototype.bind_all=function(e){return this.global_callbacks.push(e),this},e.EventsDispatcher=n}(),function(){function t(e,t,n){void 0!==t[e]&&t[e](n)}function n(t,n,r){e.EventsDispatcher.call(this),this.state=void 0,this.errors=[],this.stateActions=r,this.transitions=n,this.transition(t)}n.prototype.transition=function(n,r){var i,o=this.state,a=this.stateActions;if(o&&-1==e.Util.arrayIndexOf(this.transitions[o],n))throw this.emit("invalid_transition_attempt",{oldState:o,newState:n}),new Error("Invalid transition ["+o+" to "+n+"]");t(o+"Exit",a,r),t(o+"To"+((i=n).substr(0,1).toUpperCase()+i.substr(1)),a,r),t(n+"Pre",a,r),this.state=n,this.emit("state_change",{oldState:o,newState:n}),t(n+"Post",a,r)},n.prototype.is=function(e){return this.state===e},n.prototype.isNot=function(e){return this.state!==e},e.Util.extend(n.prototype,e.EventsDispatcher.prototype),e.Machine=n}(),(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 n(t){t.connectionWait=0,"flash"===e.TransportType?t.openTimeout=5e3:t.openTimeout=2e3,t.connectedTimeout=2e3,t.connectionSecure=t.compulsorySecure,t.connectionAttempts=0}function r(r,i){var o=this;function a(){o.connectionWait<1e4&&(o.connectionWait+=2e3),o.openTimeout<1e4&&(o.openTimeout+=2e3),o.connectedTimeout<1e4&&(o.connectedTimeout+=2e3),!0!==o.compulsorySecure&&(o.connectionSecure=!o.connectionSecure),o.connectionAttempts++}function s(){o._machine.transition("impermanentlyClosing")}function u(){o._activityTimer&&clearTimeout(o._activityTimer),o._activityTimer=setTimeout((function(){o.send_event("pusher:ping",{}),o._activityTimer=setTimeout((function(){o.socket.close()}),o.options.pong_timeout||e.pong_timeout)}),o.options.activity_timeout||e.activity_timeout)}function l(){o._machine.transition("open")}function c(e){var t,n,r=d(e);void 0!==r&&("pusher:connection_established"===r.event?o._machine.transition("connected",r.data.socket_id):"pusher:error"===r.event&&(t=r.data.code,n=r.data.message,o.emit("error",{type:"PusherError",data:{code:t,message:n}}),4e3===t?(o.compulsorySecure=!0,o.connectionSecure=!0,o.options.encrypted=!0,s()):t<4100?o._machine.transition("permanentlyClosing"):t<4200?(o.connectionWait=1e3,o._machine.transition("waiting")):t<4300?s():o._machine.transition("permanentlyClosing")))}function f(t){u();var n=d(t);if(void 0!==n){switch(e.debug("Event recd",n),n.event){case"pusher:error":o.emit("error",{type:"PusherError",data:n.data});break;case"pusher:ping":o.send_event("pusher:pong",{})}o.emit("message",n)}}function d(e){try{var t=JSON.parse(e.data);if("string"==typeof t.data)try{t.data=JSON.parse(t.data)}catch(e){if(!(e instanceof SyntaxError))throw e}return t}catch(t){o.emit("error",{type:"MessageParseError",error:t,data:e.data})}}function p(){o._machine.transition("waiting")}function h(e){o.emit("error",{type:"WebSocketError",error:e})}function m(t,n){var r=o.state;o.state=t,r!==t&&(e.debug("State changed",r+" -> "+t),o.emit("state_change",{previous:r,current:t}),o.emit(t,n))}e.EventsDispatcher.call(this),this.options=e.Util.extend({encrypted:!1},i),this.netInfo=new e.NetInfo,this.netInfo.bind("online",(function(){o._machine.is("waiting")&&(o._machine.transition("connecting"),m("connecting"))})),this.netInfo.bind("offline",(function(){o._machine.is("connected")&&(o.socket.onclose=void 0,o.socket.onmessage=void 0,o.socket.onerror=void 0,o.socket.onopen=void 0,o.socket.close(),o.socket=void 0,o._machine.transition("waiting"))})),this._machine=new e.Machine("initialized",t,{initializedPre:function(){o.compulsorySecure=o.options.encrypted,o.key=r,o.socket=null,o.socket_id=null,o.state="initialized"},waitingPre:function(){o.connectionWait>0&&o.emit("connecting_in",o.connectionWait),o.netInfo.isOnLine()&&o.connectionAttempts<=4?m("connecting"):m("unavailable"),o.netInfo.isOnLine()&&(o._waitingTimer=setTimeout((function(){o._machine.transition("connecting")}),function(){var e=o.connectionWait;if(0===e&&o.connectedAt){var t=(new Date).getTime()-o.connectedAt;t<1e3&&(e=1e3-t)}return e}()))},waitingExit:function(){clearTimeout(o._waitingTimer)},connectingPre:function(){if(!1===o.netInfo.isOnLine())return o._machine.transition("waiting"),void m("unavailable");var t=function(t,n){var r=e.ws_port,i="ws://";(n||"https:"===document.location.protocol)&&(r=e.wss_port,i="wss://");var o="flash"===e.TransportType?"true":"false";return i+e.host+":"+r+"/app/"+t+"?protocol=5&client=js&version="+e.VERSION+"&flash="+o}(o.key,o.connectionSecure);e.debug("Connecting",t),o.socket=new e.Transport(t),o.socket.onopen=l,o.socket.onclose=p,o.socket.onerror=h,o._connectingTimer=setTimeout(s,o.openTimeout)},connectingExit:function(){clearTimeout(o._connectingTimer),o.socket.onopen=void 0},connectingToWaiting:function(){a()},connectingToImpermanentlyClosing:function(){a()},openPre:function(){o.socket.onmessage=c,o.socket.onerror=h,o.socket.onclose=p,o._openTimer=setTimeout(s,o.connectedTimeout)},openExit:function(){clearTimeout(o._openTimer),o.socket.onmessage=void 0},openToWaiting:function(){a()},openToImpermanentlyClosing:function(){a()},connectedPre:function(e){o.socket_id=e,o.socket.onmessage=f,o.socket.onerror=h,o.socket.onclose=p,n(o),o.connectedAt=(new Date).getTime(),u()},connectedPost:function(){m("connected")},connectedExit:function(){o._activityTimer&&clearTimeout(o._activityTimer),m("dis