PageSourceSearch

https://restore-photos.vercel.app/_next/static/chunks/d89bb442-9dc1aa1090ac1acc.js

js restore-photos.vercel.app collected 2026-10-03 07:37:38 UTC 81,428 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[719],{9364:function(e,t,r){r.d(t,{$O:function(){return H}});var n,o,i,a,c,u,l,s,f,p,d,y,h,v,m,b,_,g={};g.d=function(e,t){for(var r in t)g.o(t,r)&&!g.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},g.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)};var P={};function _await(e,t,r){return r?t?t(e):e:(e&&e.then||(e=Promise.resolve(e)),t?e.then(t):e)}function _empty(){}function _typeof(e){return(_typeof="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 _defineProperties(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,function(e){var t=function(e,t){if("object"!=_typeof(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=_typeof(n))return n;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==_typeof(t)?t:t+""}(n.key),n)}}g.d(P,{AuthManager:function(){return Q},BaseAPI:function(){return U},BinaryResult:function(){return T},BytescaleApiClientConfigUtils:function(){return S},BytescaleApiError:function(){return O},BytescaleGenericError:function(){return j},CacheApi:function(){return M},CancelledError:function(){return B},CommonTypesNoOp:function(){return q},FileApi:function(){return E},FolderApi:function(){return F},JSONApiResponse:function(){return C},JobApi:function(){return W},UploadApi:function(){return R},UploadManager:function(){return K},UrlBuilder:function(){return N},UrlBuilderTypesNoOp:function(){return x},VoidApiResponse:function(){return I},encodeBytescaleQuerystringKVP:function(){return encodeBytescaleQuerystringKVP},querystring:function(){return querystring}});var w=(n=function FairMutex(){(function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")})(this,FairMutex),this.locked=!1,this.queue=[]},o=[{key:"safe",value:function(e){try{var t=this;return _await(t.lock(),function(){return function(e,t){try{var r=e()}catch(e){return t(!0,e)}return r&&r.then?r.then(t.bind(null,!1),t.bind(null,!0)):t(!1,r)}(e,function(e,r){return t.unlock(),function(e,t){if(e)throw t;return t}(e,r)})})}catch(e){return Promise.reject(e)}}},{key:"lock",value:function(){try{var e,t,r=this;return _await((e=function(e){r.locked=!0},(t=function(){if(r.locked){var e,t=new Promise(function(t){e=t});if(void 0===e)throw Error("unlockNext was undefined");return r.queue.push({resolve:e}),t&&t.then?t.then(_empty):Promise.resolve()}}())&&t.then?t.then(e):e(t)))}catch(e){return Promise.reject(e)}}},{key:"unlock",value:function(){if(!this.locked)throw Error("Mutex is not locked.");var e=this.queue.shift();void 0!==e?e.resolve():this.locked=!1}}],_defineProperties(n.prototype,o),i&&_defineProperties(n,i),Object.defineProperty(n,"prototype",{writable:!1}),n);function AuthSessionState_typeof(e){return(AuthSessionState_typeof="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)}var A=function(){var e;function AuthSessionState(){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,AuthSessionState)}return e=[{key:"getMutex",value:function(){var e=AuthSessionState.mutexKey,t=window[e];return void 0===t&&(t=new w,window[e]=t),t}},{key:"setSession",value:function(e){window[AuthSessionState.stateKey]=e}},{key:"getSession",value:function(){if("undefined"!=typeof window)return window[AuthSessionState.stateKey]}}],function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,function(e){var t=function(e,t){if("object"!=AuthSessionState_typeof(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=AuthSessionState_typeof(n))return n;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==AuthSessionState_typeof(t)?t:t+""}(n.key),n)}}(AuthSessionState,e),Object.defineProperty(AuthSessionState,"prototype",{writable:!1}),AuthSessionState}();function ConsoleUtils_typeof(e){return(ConsoleUtils_typeof="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)}A.stateKey="BytescaleSessionState",A.mutexKey="BytescaleSessionStateMutex";var k=function(){var e;function ConsoleUtils(){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}
1(this,ConsoleUtils)}return e=[{key:"debug",value:function(e){console.log(ConsoleUtils.prefix(e))}},{key:"warn",value:function(e){console.warn(ConsoleUtils.prefix(e))}},{key:"error",value:function(e){console.error(ConsoleUtils.prefix(e))}},{key:"prefix",value:function(e){return"[bytescale-sdk] ".concat(e)}}],function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,function(e){var t=function(e,t){if("object"!=ConsoleUtils_typeof(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=ConsoleUtils_typeof(n))return n;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==ConsoleUtils_typeof(t)?t:t+""}(n.key),n)}}(ConsoleUtils,e),Object.defineProperty(ConsoleUtils,"prototype",{writable:!1}),ConsoleUtils}();function runtime_await(e,t,r){return r?t?t(e):e:(e&&e.then||(e=Promise.resolve(e)),t?e.then(t):e)}function _catch(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}function runtime_empty(){}function _continue(e,t){return e&&e.then?e.then(t):t(e)}function runtime_typeof(e){return(runtime_typeof="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 _toConsumableArray(e){return function(e){if(Array.isArray(e))return _arrayLikeToArray(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return _arrayLikeToArray(e,t)}}(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function _callSuper(e,t,r){return t=_getPrototypeOf(t),function(e,t){if(t&&("object"===runtime_typeof(t)||"function"==typeof t))return t;if(void 0!==t)throw TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,_isNativeReflectConstruct()?Reflect.construct(t,r||[],_getPrototypeOf(e).constructor):t.apply(e,r))}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw 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&&_setPrototypeOf(e,t)}function _wrapNativeSuper(e){var t="function"==typeof Map?new Map:void 0;return(_wrapNativeSuper=function(e){if(null===e||!function(e){try{return -1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,Wrapper)}function Wrapper(){return function(e,t,r){if(_isNativeReflectConstruct())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,t);var o=new(e.bind.apply(e,n));return r&&_setPrototypeOf(o,r.prototype),o}(e,arguments,_getPrototypeOf(this).constructor)}return Wrapper.prototype=Object.create(e.prototype,{constructor:{value:Wrapper,enumerable:!1,writable:!0,configurable:!0}}),_setPrototypeOf(Wrapper,e)})(e)}function _isNativeReflectConstruct(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(_isNativeReflectConstruct=function(){return!!e})()}function _setPrototypeOf(e,t){return(_setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function _getPrototypeOf(e){return(_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function runtime_classCallCheck(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}function runtime_defineProperties(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,runtime_toPropertyKey(n.key),n)}}function runtime_createClass(e,t,r){return t&&runtime_defineProperties(e.prototype,t),r&&runtime_defineProperties(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function runtime_toPropertyKey(e){var t=function(e,t){if("object"!=runtime_typeof(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=runtime_typeof(n))return n;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==runtime_typeof(t)?t:t+""}var S=function(){function BytescaleApiClientConfigUtils(){runtime_classCallCheck(this,BytescaleApiClientConfigUtils)}return runtime_createClass(BytescaleApiClientConfigUtils,null,[{key:"getApiUrl",value:function(e){var t;return null!==(t=e.apiUrl)&&void 0!==t?t:BytescaleApiClientConfigUtils.defaultApiUrl}},{key:"getCdnUrl",value:function(e){var t;return null!==(t=e.cdnUrl)&&void 0!==t?t:BytescaleApiClientConfigUtils.defaultCdnUrl}},{key:"getFetchApi",value:function(e){var t;return null!==(t=e.fetchApi)&&void 0!==t?t:fetch}},{key:"getAccountId",value:function(e){var t,r,n;if(BytescaleApiClientConfigUtils.specialApiKeys.includes(e.apiKey))n=BytescaleApiClientConfigUtils.specialApiKeyAccountId;else if((n=null!==(r=null===(t=e.apiKey.split("_")[1])||void 0===t?void 0:t.substr(0,BytescaleApiClientConfigUtils.accountIdLength))&&void 0!==r?r:"").length!==BytescaleApiClientConfigUtils.accountIdLength)throw Error("Invalid Bytescale API key.");return n}},{key:"validate",value:function(e){var t;if((null!=e?e:void 0)===void 0)throw Error("Config parameter required.");
1if((null!==(t=e.apiKey)&&void 0!==t?t:void 0)===void 0)throw Error("Please provide an API key via the 'apiKey' config parameter.");if(e.apiKey.trim()!==e.apiKey)throw Error("API key needs trimming (whitespace detected).");BytescaleApiClientConfigUtils.getAccountId(e)}}])}();S.defaultApiUrl="https://api.bytescale.com",S.defaultCdnUrl="https://upcdn.io",S.specialApiKeys=["free","demo"],S.specialApiKeyAccountId="W142hJk",S.accountIdLength=7;var U=function(){function BaseAPI(e){runtime_classCallCheck(this,BaseAPI),this.config=e,S.validate(e)}return runtime_createClass(BaseAPI,[{key:"request",value:function(e,t,r){try{var n,o,i,a,c=this,u=c.config.apiKey;e.headers.Authorization="Bearer ".concat(u);var l=A.getSession();(null==l?void 0:l.accessToken)!==void 0&&(e.headers["Authorization-Token"]=l.accessToken);var s=(n={},o=S.defaultCdnUrl,i=S.getCdnUrl(c.config),(o=runtime_toPropertyKey(o))in n?Object.defineProperty(n,o,{value:i,enumerable:!0,configurable:!0,writable:!0}):n[o]=i,n);return runtime_await(c.createFetchParams(e,t,void 0===r?void 0:null!==(a=s[r])&&void 0!==a?a:r),function(e){var t=e.url,r=e.init;return BaseAPI.fetch(t,r,Object.assign(Object.assign({},c.config),{isBytescaleApi:!0}))})}catch(e){return Promise.reject(e)}}},{key:"encodeParam",value:function(e,t){if("filePath"===e){if(!t.startsWith("/"))throw Error("The 'filePath' parameter must begin with a '/' character.");return t}return encodeURIComponent(t)}},{key:"createFetchParams",value:function(e,t,r){try{var n=(null!=r?r:S.getApiUrl(this.config))+e.path;void 0!==e.query&&0!==Object.keys(e.query).length&&(n+="?"+querystring(e.query));var o=this.config.headers,i=Object.assign({},e.headers);return runtime_await(runtime_await(void 0===o?{}:"function"==typeof o?o():o,function(r){var o=Object.assign(i,r);Object.keys(o).forEach(function(e){return void 0===o[e]?delete o[e]:{}});var a="function"==typeof t?t:function(){return runtime_await(t)},c={method:e.method,headers:o,body:e.body},u=Object.assign({},c);return runtime_await(a({init:c,context:e}),function(e){var t=Object.assign(u,e),r=Object.assign(Object.assign({},t),{body:JSON.stringify(t.body)});return{url:n,init:r}})},void 0===o||"function"!=typeof o))}catch(e){return Promise.reject(e)}}}],[{key:"fetch",value:function(e,t,r){try{var n,o,i;return runtime_await(_continue(_catch(function(){return runtime_await(S.getFetchApi(r)(e,Object.assign(Object.assign({},t),{cache:"no-store",duplex:"half"})),function(e){i=e})},function(t){throw Error(r.isBytescaleApi?"Unable to resolve the Bytescale API: ".concat(t.message," If the problem persists, and your network connection is OK, then please contact [email protected] and provide: (a) time of failed request in UTC (b) screenshot of failed network response header + body (c) screenshot of failed network request header + body (d) browser and OS version."):"Unable to resolve URL (".concat(e,"): ").concat(t.message))}),function(a){var c,u;return i.status>=200&&i.status<300?i:(c=function(r){throw Error("Failure status code (".concat(i.status,") received for request: ").concat(null!==(o=t.method)&&void 0!==o?o:"GET"," ").concat(e))},(u=function(){if(r.isBytescaleApi){var e=void 0,t=void 0;return _continue(_catch(function(){return runtime_await(i.text(),function(r){e=r,t=JSON.parse(e)})},runtime_empty),function(){if("string"==typeof(null===(n=null==t?void 0:t.error)||void 0===n?void 0:n.code))throw new O(t);throw!0===r.debug&&(k.debug("Error response header:"),i.headers.forEach(function(e,t){return k.debug("".concat(t,": ").concat(e))}),k.debug("Error response body:"),k.debug(null!=e?e:"<empty>")),new j(i,e,t)})}}())&&u.then?u.then(c):c(u))}))}catch(e){return Promise.reject(e)}}}])}(),B=function(e){function CancelledError(){var e;return runtime_classCallCheck(this,CancelledError),(e=_callSuper(this,CancelledError,["Operation cancelled by caller."])).name="CancelledError",e}return _inherits(CancelledError,e),runtime_createClass(CancelledError)}(_wrapNativeSuper(Error)),j=function(e){function BytescaleGenericError(e,t,r){var n;return runtime_classCallCheck(this,BytescaleGenericError),(n=_callSuper(this,BytescaleGenericError,["Unable to connect to the Bytescale API (".concat(e.status,"): please try again.")])).response=e,n.responseText=t,n.responseJson=r,n.name="BytescaleGenericError",n}return _inherits(BytescaleGenericError,e),runtime_createClass(BytescaleGenericError)}(_wrapNativeSuper(Error)),O=function(e){function BytescaleApiError(e){var t;return runtime_classCallCheck(this,BytescaleApiError),(t=_callSuper(this,BytescaleApiError,[e.error.message])).name="BytescaleApiError",t.errorCode=e.error.code,t.details=e.error.details,t}return _inherits(BytescaleApiError,e),runtime_createClass(BytescaleApiError)}(_wrapNativeSuper(Error));function querystring(e){var t,r;return(t=Object.keys(e),r="artifact",[].concat(_toConsumableArray(t.filter(function(e){return e!==r})),_toConsumableArray(t.filter(function(e){return e===r})))).map(function(t){var r;return(r=e[t])instanceof Object?querystring(r):encodeBytescaleQuerystringKVP(t,String(r))}).filter(function(e){return e.length>0}).join("&")}function encodeBytescaleQuerystringKVP(e,t){return"a"===e||"artifact"===e?"".concat(e,"=").concat(encodeURIComponent(t).replace(/%2F/g,"/")):"".concat(encodeURIComponent(e),"=").concat(encodeURIComponent(t))}var C=runtime_createClass(function JSONApiResponse(e){runtime_classCallCheck(this,JSONApiResponse),this.raw=e},[{key:"value",value:function(){try{return runtime_await(this.raw.json())}catch(e){return Promise.reject(e)}}}]),I=runtime_createClass(function VoidApiResponse(e){runtime_classCallCheck(this,VoidApiResponse),this.raw=e},[{key:"value",value:function(){return runtime_await(void 0)}}]),T=runtime_createClass(function BinaryResult(e){runtime_classCallCheck(this,BinaryResult),this.raw=e},[{key:"stream",value:function(){if(this.raw.bodyUsed)throw Error("Response body has already been consumed.");
1if(null===this.raw.body)throw Error("Response body does not exist.");return this.raw.body}},{key:"text",value:function(){try{return runtime_await(this.raw.text())}catch(e){return Promise.reject(e)}}},{key:"blob",value:function(){try{return runtime_await(this.raw.blob())}catch(e){return Promise.reject(e)}}},{key:"json",value:function(){try{return runtime_await(this.raw.json())}catch(e){return Promise.reject(e)}}}]);function CacheApi_typeof(e){return(CacheApi_typeof="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 CacheApi_await(e,t,r){return r?t?t(e):e:(e&&e.then||(e=Promise.resolve(e)),t?e.then(t):e)}function CacheApi_defineProperties(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,function(e){var t=function(e,t){if("object"!=CacheApi_typeof(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=CacheApi_typeof(n))return n;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==CacheApi_typeof(t)?t:t+""}(n.key),n)}}function CacheApi_isNativeReflectConstruct(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(CacheApi_isNativeReflectConstruct=function(){return!!e})()}function CacheApi_getPrototypeOf(e){return(CacheApi_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function CacheApi_setPrototypeOf(e,t){return(CacheApi_setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}var M=function(e){var t,r;function CacheApi(){var e,t;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,CacheApi),e=CacheApi,t=arguments,e=CacheApi_getPrototypeOf(e),function(e,t){if(t&&("object"===CacheApi_typeof(t)||"function"==typeof t))return t;if(void 0!==t)throw TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(this,CacheApi_isNativeReflectConstruct()?Reflect.construct(e,t||[],CacheApi_getPrototypeOf(this).constructor):e.apply(this,t))}return!function(e,t){if("function"!=typeof t&&null!==t)throw 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&&CacheApi_setPrototypeOf(e,t)}(CacheApi,e),t=[{key:"resetCache",value:function(e){try{var t={};return t["Content-Type"]="application/json",CacheApi_await(this.request({path:"/v2/accounts/{accountId}/cache/reset".replace("{".concat("accountId","}"),this.encodeParam("accountId",e.accountId)),method:"POST",headers:t,query:{},body:e.resetCacheRequest},void 0,[][0]),function(e){return CacheApi_await(new C(e).value())})}catch(e){return Promise.reject(e)}}}],CacheApi_defineProperties(CacheApi.prototype,t),r&&CacheApi_defineProperties(CacheApi,r),Object.defineProperty(CacheApi,"prototype",{writable:!1}),CacheApi}(U);function FileApi_typeof(e){return(FileApi_typeof="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 FileApi_await(e,t,r){return r?t?t(e):e:(e&&e.then||(e=Promise.resolve(e)),t?e.then(t):e)}function FileApi_defineProperties(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,function(e){var t=function(e,t){if("object"!=FileApi_typeof(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=FileApi_typeof(n))return n;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==FileApi_typeof(t)?t:t+""}(n.key),n)}}function FileApi_isNativeReflectConstruct(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(FileApi_isNativeReflectConstruct=function(){return!!e})()}function FileApi_getPrototypeOf(e){return(FileApi_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function FileApi_setPrototypeOf(e,t){return(FileApi_setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}var E=function(e){var t,r;function FileApi(){var e,t;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,FileApi),e=FileApi,t=arguments,e=FileApi_getPrototypeOf(e),function(e,t){if(t&&("object"===FileApi_typeof(t)||"function"==typeof t))return t;if(void 0!==t)throw TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(this,FileApi_isNativeReflectConstruct()?Reflect.construct(e,t||[],FileApi_getPrototypeOf(this).constructor):e.apply(this,t))}return!function(e,t){if("function"!=typeof t&&null!==t)throw 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&&FileApi_setPrototypeOf(e,t)}(FileApi,e),t=[{key:"copyFile",value:function(e){try{var t={};return t["Content-Type"]="application/json",FileApi_await(this.request({path:"/v2/accounts/{accountId}/files/copy".replace("{".concat("accountId","}"),this.encodeParam("accountId",e.accountId)),method:"POST",headers:t,query:{},body:e.copyFileRequest},void 0,[][0]),function(e){return FileApi_await(new C(e).value())})}catch(e){return Promise.reject(e)}}},{key:"copyFileBatch",value:function(e){try{var t={};return t["Content-Type"]="application/json",FileApi_await(this.request({path:"/v2/accounts/{accountId}/files/copy/batch".replace("{".concat("accountId","}"),this.encodeParam("accountId",e.accountId)),method:"POST",headers:t,query:{},body:e.copyFileBatchRequest},void 0,[][0]),function(e){return FileApi_await(new C(e).value())})}catch(e){return Promise.reject(e)}}},{key:"deleteFile",value:function(e){try{var t={};return void 0!==e.filePath&&(t.filePath=e.filePath),FileApi_await(this.request({path:"/v2/accounts/{accountId}/files".replace("{".concat("accountId","}"),this.encodeParam("accountId",e.accountId)),method:"DELETE",headers:{},query:t},void 0,[][0]),function(e){return FileApi_await(new I(e).value())})}catch(e){return Promise.reject(e)}}},{key:"deleteFileBatch",value:function(e){try{var t={};return t["Content-Type"]="application/json",FileApi_await(this.request({path:"/v2/accounts/{accountId}/files/batch".replace("{".concat("accountId","}"),this.encodeParam("accountId",e.accountId)),method:"DELETE",headers:t,query:{},body:e.deleteFileBatchRequest},void 0,[][0]),function(e){return FileApi_await(new C(e).value())})}catch(e){return Promise.reject(e)}}},{key:"downloadFile",value:function(e){try{var t={};return void 0!==e.cache&&(t.cache=e.cache),void 0!==e.cacheTtl&&(t.cache_ttl=e.cacheTtl),void 0!==e.cacheTtl404&&(t.cache_ttl_404=e.cacheTtl404),void 0!==e.version&&(t.version=e.version),FileApi_await(this.request({path:"/{accountId}
1/raw{filePath}".replace("{".concat("accountId","}"),this.encodeParam("accountId",e.accountId)).replace("{".concat("filePath","}"),this.encodeParam("filePath",e.filePath)),method:"GET",headers:{},query:t},void 0,"https://upcdn.io"),function(e){return new T(e)})}catch(e){return Promise.reject(e)}}},{key:"getFileDetails",value:function(e){try{var t={};return void 0!==e.filePath&&(t.filePath=e.filePath),FileApi_await(this.request({path:"/v2/accounts/{accountId}/files/details".replace("{".concat("accountId","}"),this.encodeParam("accountId",e.accountId)),method:"GET",headers:{},query:t},void 0,[][0]),function(e){return FileApi_await(new C(e).value())})}catch(e){return Promise.reject(e)}}},{key:"processFile",value:function(e){try{var t={};return void 0!==e.artifact&&(t.artifact=e.artifact),void 0!==e.cache&&(t.cache=e.cache),void 0!==e.cacheOnly&&(t.cache_only=e.cacheOnly),void 0!==e.cachePerm&&(t.cache_perm=e.cachePerm),void 0!==e.cacheTtl&&(t.cache_ttl=e.cacheTtl),void 0!==e.cacheTtl404&&(t.cache_ttl_404=e.cacheTtl404),void 0!==e.transformationParams&&(t.transformationParams=e.transformationParams),void 0!==e.version&&(t.version=e.version),FileApi_await(this.request({path:"/{accountId}/{transformation}{filePath}".replace("{".concat("accountId","}"),this.encodeParam("accountId",e.accountId)).replace("{".concat("filePath","}"),this.encodeParam("filePath",e.filePath)).replace("{".concat("transformation","}"),this.encodeParam("transformation",e.transformation)),method:"GET",headers:{},query:t},void 0,"https://upcdn.io"),function(e){return new T(e)})}catch(e){return Promise.reject(e)}}},{key:"processFileAndSave",value:function(e){try{var t={};void 0!==e.transformationParams&&(t.transformationParams=e.transformationParams);var r={};return r["Content-Type"]="application/json",FileApi_await(this.request({path:"/{accountId}/save/{transformation}{filePath}".replace("{".concat("accountId","}"),this.encodeParam("accountId",e.accountId)).replace("{".concat("filePath","}"),this.encodeParam("filePath",e.filePath)).replace("{".concat("transformation","}"),this.encodeParam("transformation",e.transformation)),method:"POST",headers:r,query:t,body:e.processFileAndSaveRequest},void 0,"https://upcdn.io"),function(e){return FileApi_await(new C(e).value())})}catch(e){return Promise.reject(e)}}}],FileApi_defineProperties(FileApi.prototype,t),r&&FileApi_defineProperties(FileApi,r),Object.defineProperty(FileApi,"prototype",{writable:!1}),FileApi}(U);function FolderApi_typeof(e){return(FolderApi_typeof="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 FolderApi_await(e,t,r){return r?t?t(e):e:(e&&e.then||(e=Promise.resolve(e)),t?e.then(t):e)}function FolderApi_defineProperties(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,function(e){var t=function(e,t){if("object"!=FolderApi_typeof(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=FolderApi_typeof(n))return n;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==FolderApi_typeof(t)?t:t+""}(n.key),n)}}function FolderApi_isNativeReflectConstruct(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(FolderApi_isNativeReflectConstruct=function(){return!!e})()}function FolderApi_getPrototypeOf(e){return(FolderApi_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function FolderApi_setPrototypeOf(e,t){return(FolderApi_setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}var F=function(e){var t,r;function FolderApi(){var e,t;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,FolderApi),e=FolderApi,t=arguments,e=FolderApi_getPrototypeOf(e),function(e,t){if(t&&("object"===FolderApi_typeof(t)||"function"==typeof t))return t;if(void 0!==t)throw TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(this,FolderApi_isNativeReflectConstruct()?Reflect.construct(e,t||[],FolderApi_getPrototypeOf(this).constructor):e.apply(this,t))}return!function(e,t){if("function"!=typeof t&&null!==t)throw 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&&FolderApi_setPrototypeOf(e,t)}(FolderApi,e),t=[{key:"copyFolder",value:function(e){try{var t={};return t["Content-Type"]="application/json",FolderApi_await(this.request({path:"/v2/accounts/{accountId}/folders/copy".replace("{".concat("accountId","}"),this.encodeParam("accountId",e.accountId)),method:"POST",headers:t,query:{},body:e.copyFolderRequest},void 0,[][0]),function(e){return FolderApi_await(new C(e).value())})}catch(e){return Promise.reject(e)}}},{key:"copyFolderBatch",value:function(e){try{var t={};return t["Content-Type"]="application/json",FolderApi_await(this.request({path:"/v2/accounts/{accountId}/folders/copy/batch".replace("{".concat("accountId","}"),this.encodeParam("accountId",e.accountId)),method:"POST",headers:t,query:{},body:e.copyFolderBatchRequest},void 0,[][0]),function(e){return FolderApi_await(new C(e).value())})}catch(e){return Promise.reject(e)}}},{key:"deleteFolder",value:function(e){try{var t={};return t["Content-Type"]="application/json",FolderApi_await(this.request({path:"/v2/accounts/{accountId}/folders".replace("{".concat("accountId","}"),this.encodeParam("accountId",e.accountId)),method:"DELETE",headers:t,query:{},body:e.deleteFolderRequest},void 0,[][0]),function(e){return FolderApi_await(new C(e).value())})}catch(e){return Promise.reject(e)}}},{key:"deleteFolderBatch",value:function(e){try{var t={};return t["Content-Type"]="application/json",FolderApi_await(this.request({path:"/v2/accounts/{accountId}/folders/batch".replace("{".concat("accountId","}"),this.encodeParam("accountId",e.accountId)),method:"DELETE",headers:t,query:{},body:e.deleteFolderBatchRequest},void 0,[][0]),function(e){return FolderApi_await(new C(e).value())})}catch(e){return Promise.reject(e)}}},{key:"getFolderDetails",value:function(e){try{var t={};return void 0!==e.folderPath&&(t.folderPath=e.folderPath),FolderApi_await(this.request({path:"/v2/accounts/{accountId}/folders".replace("{".concat("accountId","}"),this.encodeParam("accountId",e.accountId)),method:"GET",headers:{},query:t},void 0,[][0]),function(e){return FolderApi_await(new C(e).value())})}catch(e){return Promise.reject(e)}}},{key:"listFolder",value:function(e){try{var t={};
1return void 0!==e.cursor&&(t.cursor=e.cursor),void 0!==e.dryRun&&(t.dryRun=e.dryRun),void 0!==e.folderPath&&(t.folderPath=e.folderPath),void 0!==e.includeFiles&&(t.includeFiles=e.includeFiles),void 0!==e.includeOverriddenStorage&&(t.includeOverriddenStorage=e.includeOverriddenStorage),void 0!==e.includePhysicalFolders&&(t.includePhysicalFolders=e.includePhysicalFolders),void 0!==e.includeVirtualFolders&&(t.includeVirtualFolders=e.includeVirtualFolders),void 0!==e.limit&&(t.limit=e.limit),void 0!==e.recursive&&(t.recursive=e.recursive),FolderApi_await(this.request({path:"/v2/accounts/{accountId}/folders/list".replace("{".concat("accountId","}"),this.encodeParam("accountId",e.accountId)),method:"GET",headers:{},query:t},void 0,[][0]),function(e){return FolderApi_await(new C(e).value())})}catch(e){return Promise.reject(e)}}},{key:"putFolder",value:function(e){try{var t={};return t["Content-Type"]="application/json",FolderApi_await(this.request({path:"/v2/accounts/{accountId}/folders".replace("{".concat("accountId","}"),this.encodeParam("accountId",e.accountId)),method:"PUT",headers:t,query:{},body:e.putFolderRequest},void 0,[][0]),function(e){return FolderApi_await(new C(e).value())})}catch(e){return Promise.reject(e)}}}],FolderApi_defineProperties(FolderApi.prototype,t),r&&FolderApi_defineProperties(FolderApi,r),Object.defineProperty(FolderApi,"prototype",{writable:!1}),FolderApi}(U);function JobApi_typeof(e){return(JobApi_typeof="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 JobApi_await(e,t,r){return r?t?t(e):e:(e&&e.then||(e=Promise.resolve(e)),t?e.then(t):e)}function JobApi_defineProperties(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,function(e){var t=function(e,t){if("object"!=JobApi_typeof(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=JobApi_typeof(n))return n;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==JobApi_typeof(t)?t:t+""}(n.key),n)}}function JobApi_isNativeReflectConstruct(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(JobApi_isNativeReflectConstruct=function(){return!!e})()}function JobApi_getPrototypeOf(e){return(JobApi_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function JobApi_setPrototypeOf(e,t){return(JobApi_setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}var W=function(e){var t,r;function JobApi(){var e,t;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,JobApi),e=JobApi,t=arguments,e=JobApi_getPrototypeOf(e),function(e,t){if(t&&("object"===JobApi_typeof(t)||"function"==typeof t))return t;if(void 0!==t)throw TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(this,JobApi_isNativeReflectConstruct()?Reflect.construct(e,t||[],JobApi_getPrototypeOf(this).constructor):e.apply(this,t))}return!function(e,t){if("function"!=typeof t&&null!==t)throw 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&&JobApi_setPrototypeOf(e,t)}(JobApi,e),t=[{key:"cancelJob",value:function(e){try{return JobApi_await(this.request({path:"/v2/accounts/{accountId}/jobs/{jobType}/{jobId}".replace("{".concat("accountId","}"),this.encodeParam("accountId",e.accountId)).replace("{".concat("jobId","}"),this.encodeParam("jobId",e.jobId)).replace("{".concat("jobType","}"),this.encodeParam("jobType",e.jobType)),method:"DELETE",headers:{},query:{}},void 0,[][0]),function(e){return JobApi_await(new I(e).value())})}catch(e){return Promise.reject(e)}}},{key:"getJob",value:function(e){try{return JobApi_await(this.request({path:"/v2/accounts/{accountId}/jobs/{jobType}/{jobId}".replace("{".concat("accountId","}"),this.encodeParam("accountId",e.accountId)).replace("{".concat("jobId","}"),this.encodeParam("jobId",e.jobId)).replace("{".concat("jobType","}"),this.encodeParam("jobType",e.jobType)),method:"GET",headers:{},query:{}},void 0,[][0]),function(e){return JobApi_await(new C(e).value())})}catch(e){return Promise.reject(e)}}},{key:"listRecentJobs",value:function(e){try{var t={};return e.jobType&&(t.jobType=e.jobType),JobApi_await(this.request({path:"/v2/accounts/{accountId}/jobs".replace("{".concat("accountId","}"),this.encodeParam("accountId",e.accountId)),method:"GET",headers:{},query:t},void 0,[][0]),function(e){return JobApi_await(new C(e).value())})}catch(e){return Promise.reject(e)}}}],JobApi_defineProperties(JobApi.prototype,t),r&&JobApi_defineProperties(JobApi,r),Object.defineProperty(JobApi,"prototype",{writable:!1}),JobApi}(U);function UploadApi_typeof(e){return(UploadApi_typeof="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 UploadApi_await(e,t,r){return r?t?t(e):e:(e&&e.then||(e=Promise.resolve(e)),t?e.then(t):e)}function UploadApi_defineProperties(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,function(e){var t=function(e,t){if("object"!=UploadApi_typeof(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=UploadApi_typeof(n))return n;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==UploadApi_typeof(t)?t:t+""}(n.key),n)}}function UploadApi_isNativeReflectConstruct(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(UploadApi_isNativeReflectConstruct=function(){return!!e})()}function UploadApi_getPrototypeOf(e){return(UploadApi_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function UploadApi_setPrototypeOf(e,t){return(UploadApi_setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}var R=function(e){var t,r;function UploadApi(){var e,t;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,UploadApi),e=UploadApi,t=arguments,e=UploadApi_getPrototypeOf(e),function(e,t){if(t&&("object"===UploadApi_typeof(t)||"function"==typeof t))return t;if(void 0!==t)throw TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(this,UploadApi_isNativeReflectConstruct()?Reflect.construct(e,t||[],UploadApi_getPrototypeOf(this).constructor):e.apply(this,t))}return!function(e,t){if("function"!=typeof t&&null!==t)throw 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&&UploadApi_setPrototypeOf(e,t)}(UploadApi,e),t=[{key:"beginMultipartUpload",value:function(e){try{var t={};return t["Content-Type"]="application/json",UploadApi_await(this.request({path:"/v2/accounts/{accountId}/uploads".replace("{".concat("accountId","}"),this.encodeParam("accountId",e.accountId)),method:"POST",headers:t,query:{},body:e.beginMultipartUploadRequest},void 0,[][0]),function(e){return UploadApi_await(new C(e).value())})}catch(e){return Promise.reject(e)}}},{key:"completeUploadPart",value:function(e){try{var t={};return t["Content-Type"]="application/json",UploadApi_await(this.request({path:"/v2/accounts/{accountId}/uploads/{uploadId}/parts/{uploadPartIndex}".replace("{".concat("accountId","}"),this.encodeParam("accountId",e.accountId)).replace("{".concat("uploadId","}"),this.encodeParam("uploadId",e.uploadId)).replace("{".concat("uploadPartIndex","}"),this.encodeParam("uploadPartIndex",e.uploadPartIndex)),method:"PUT",headers:t,query:{},body:e.completeUploadPartRequest},void 0,[][0]),function(e){return UploadApi_await(new C(e).value())})}catch(e){return Promise.reject(e)}}},{key:"getUploadPart",value:function(e){try{return UploadApi_await(this.request({path:"/v2/accounts/{accountId}/uploads/{uploadId}/parts/{uploadPartIndex}".replace("{".concat("accountId","}"),this.encodeParam("accountId",e.accountId)).replace("{".concat("uploadId","}"),this.encodeParam("uploadId",e.uploadId)).replace("{".concat("uploadPartIndex","}"),this.encodeParam("uploadPartIndex",e.uploadPartIndex)),method:"GET",headers:{},query:{}},void 0,[][0]),function(e){return UploadApi_await(new C(e).value())})}catch(e){return Promise.reject(e)}}},{key:"listUploadParts",value:function(e){try{return UploadApi_await(this.request({path:"/v2/accounts/{accountId}/uploads/{uploadId}/parts".replace("{".concat("accountId","}"),this.encodeParam("accountId",e.accountId)).replace("{".concat("uploadId","}"),this.encodeParam("uploadId",e.uploadId)),method:"GET",headers:{},query:{}},void 0,[][0]),function(e){return UploadApi_await(new C(e).value())})}catch(e){return Promise.reject(e)}}},{key:"uploadFromUrl",value:function(e){try{var t={};return t["Content-Type"]="application/json",UploadApi_await(this.request({path:"/v2/accounts/{accountId}/uploads/url".replace("{".concat("accountId","}"),this.encodeParam("accountId",e.accountId)),method:"POST",headers:t,query:{},body:e.uploadFromUrlRequest},void 0,[][0]),function(e){return UploadApi_await(new C(e).value())})}catch(e){return Promise.reject(e)}}}],UploadApi_defineProperties(UploadApi.prototype,t),r&&UploadApi_defineProperties(UploadApi,r),Object.defineProperty(UploadApi,"prototype",{writable:!1}),UploadApi}(U),q=!1;function assertUnreachable(e){throw Error("Didn't expect to get here: ".concat(JSON.stringify(e)))}function isDefinedEntry(e){return void 0!==e[1]&&null!==e[1]}function UrlBuilder_typeof(e){return(UrlBuilder_typeof="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 _slicedToArray(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,l=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;
1!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==t);u=!0);}catch(e){l=!0,o=e}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(l)throw o}}return c}}(e,t)||UrlBuilder_unsupportedIterableToArray(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function UrlBuilder_toConsumableArray(e){return function(e){if(Array.isArray(e))return UrlBuilder_arrayLikeToArray(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||UrlBuilder_unsupportedIterableToArray(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function UrlBuilder_unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return UrlBuilder_arrayLikeToArray(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return UrlBuilder_arrayLikeToArray(e,t)}}function UrlBuilder_arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var N=(a=function UrlBuilder(){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,UrlBuilder)},c=[{key:"url",value:function(e){var t;return(null===(t=e.options)||void 0===t?void 0:t.transformation)===void 0?this.raw(e):this.transformation(e,e.options)}},{key:"raw",value:function(e){var t,r=this.getBaseUrl(e,"raw"),n=this.getCommonQueryParams(null!==(t=e.options)&&void 0!==t?t:{});return this.addQueryParams(r,n)}},{key:"transformation",value:function(e,t){var r,n=this.getBaseUrl(e,"preset"===t.transformation?t.transformationPreset:t.transformation),o="preset"===t.transformation?[]:this.getTransformationParams(t),i=this.getCommonQueryParams(null!==(r=e.options)&&void 0!==r?r:{}),a=this.getCommonTransformationQueryParams(t);return this.addQueryParams(n,[].concat(UrlBuilder_toConsumableArray(o),UrlBuilder_toConsumableArray(i),UrlBuilder_toConsumableArray(a)))}},{key:"getBaseUrl",value:function(e,t){var r,n,o=null!==(n=null===(r=e.options)||void 0===r?void 0:r.cdnUrl)&&void 0!==n?n:S.defaultCdnUrl,i=encodeURIComponent(e.filePath).replace(/%2F/g,"/");return"".concat(o,"/").concat(e.accountId,"/").concat(t).concat(i)}},{key:"getCommonTransformationQueryParams",value:function(e){return this.makeQueryParams({cacheOnly:null,cachePermanently:null,artifact:null},{cacheOnly:"cache_only",cachePermanently:"cache_perm"})(e)}},{key:"getCommonQueryParams",value:function(e){return this.makeQueryParams({cache:null,cacheTtl:null,cacheTtl404:null,version:null,forceDownloadPrompt:null},{cacheTtl:"cache_ttl",cacheTtl404:"cache_ttl_404",forceDownloadPrompt:"download"})(e)}},{key:"makeQueryParams",value:function(e,t){return function(r){var n=[];return Object.keys(e).forEach(function(e){var o,i=r[e];void 0!==i&&n.push([null!==(o=t[e])&&void 0!==o?o:e,i.toString()])}),n}}},{key:"getTransformationParams",value:function(e){var t=e.transformationParams;if(void 0===t)return[];var serializeObj=function(e){return Object.entries(e).filter(isDefinedEntry).map(function(e){var t=_slicedToArray(e,2);return[t[0],t[1].toString()]})};return Array.isArray(t)?t.flatMap(serializeObj):serializeObj(t)}},{key:"addQueryParams",value:function(e,t){return 0===t.length?e:"".concat(e,"?").concat(t.map(function(e){var t=_slicedToArray(e,2);return encodeBytescaleQuerystringKVP(t[0],t[1])}).join("&"))}}],function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,function(e){var t=function(e,t){if("object"!=UrlBuilder_typeof(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=UrlBuilder_typeof(n))return n;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==UrlBuilder_typeof(t)?t:t+""}(n.key),n)}}(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a),x=!1;function UploadManagerBase_empty(){}function UploadManagerBase_await(e,t,r){return r?t?t(e):e:(e&&e.then||(e=Promise.resolve(e)),t?e.then(t):e)}function _async(e){return function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];try{return Promise.resolve(e.apply(this,t))}catch(e){return Promise.reject(e)}}}function _settle(e,t,r){if(!e.s){if(r instanceof J){if(r.s)1&t&&(t=r.s),r=r.v;else{r.o=_settle.bind(null,e,t);return}}if(r&&r.then){r.then(_settle.bind(null,e,t),_settle.bind(null,e,2));return}e.s=t,e.v=r;var n=e.o;n&&n(e)}}var J=function(){function _Pact(){}return _Pact.prototype.then=function(e,t){var r=new _Pact,n=this.s;if(n){var o=1&n?e:t;if(!o)return this;try{_settle(r,1,o(this.v))}catch(e){_settle(r,2,e)}return r}return this.o=function(n){try{var o=n.v;1&n.s?_settle(r,1,e?e(o):o):t?_settle(r,1,t(o)):_settle(r,2,o)}catch(e){_settle(r,2,e)}},r},_Pact}();function _isSettledPact(e){return e instanceof J&&1&e.s}function UploadManagerBase_typeof(e){return(UploadManagerBase_typeof="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 UploadManagerBase_toConsumableArray(e){return function(e){if(Array.isArray(e))return UploadManagerBase_arrayLikeToArray(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return UploadManagerBase_arrayLikeToArray(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return UploadManagerBase_arrayLikeToArray(e,t)}}(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function UploadManagerBase_arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function UploadManagerBase_defineProperties(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,function(e){var t=function(e,t){if("object"!=UploadManagerBase_typeof(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=UploadManagerBase_typeof(n))return n;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==UploadManagerBase_typeof(t)?t:t+""}(n.key),n)}}function UploadManagerBrowserWorkerBase_typeof(e){return(UploadManagerBrowserWorkerBase_typeof="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 UploadManagerBrowserWorkerBase_defineProperties(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,function(e){var t=function(e,t){if("object"!=UploadManagerBrowserWorkerBase_typeof(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=UploadManagerBrowserWorkerBase_typeof(n))return n;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==UploadManagerBrowserWorkerBase_typeof(t)?t:t+""}(n.key),n)}}function UploadManagerBrowserWorkerBase_isNativeReflectConstruct(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(UploadManagerBrowserWorkerBase_isNativeReflectConstruct=function(){return!!e})()}function UploadManagerBrowserWorkerBase_getPrototypeOf(e){return(UploadManagerBrowserWorkerBase_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function UploadManagerBrowserWorkerBase_setPrototypeOf(e,t){return(UploadManagerBrowserWorkerBase_setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function UploadManagerBrowser_typeof(e){return(UploadManagerBrowser_typeof="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 UploadManagerBrowser_await(e,t,r){return r?t?t(e):e:(e&&e.then||(e=Promise.resolve(e)),t?e.then(t):e)}function UploadManagerBrowser_defineProperties(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,function(e){var t=function(e,t){if("object"!=UploadManagerBrowser_typeof(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=UploadManagerBrowser_typeof(n))return n;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==UploadManagerBrowser_typeof(t)?t:t+""}(n.key),n)}}function UploadManagerBrowser_isNativeReflectConstruct(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(UploadManagerBrowser_isNativeReflectConstruct=function(){return!!e})()}function UploadManagerBrowser_getPrototypeOf(e){return(UploadManagerBrowser_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function UploadManagerBrowser_setPrototypeOf(e,t){return(UploadManagerBrowser_setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}var K=function(e){var t,r;function UploadManager(){var e,t;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,UploadManager),e=UploadManager,t=arguments,e=UploadManagerBrowser_getPrototypeOf(e),function(e,t){if(t&&("object"===UploadManagerBrowser_typeof(t)||"function"==typeof t))return t;if(void 0!==t)throw TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(this,UploadManagerBrowser_isNativeReflectConstruct()?Reflect.construct(e,t||[],UploadManagerBrowser_getPrototypeOf(this).constructor):e.apply(this,t))}return!function(e,t){if("function"!=typeof t&&null!==t)throw 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&&UploadManagerBrowser_setPrototypeOf(e,t)}(UploadManager,e),t=[{key:"doPutUploadPart",value:function(e,t,r,n,o){try{var i=this,a=new XMLHttpRequest,c=!0;return o(function(){c&&a.abort()}),UploadManagerBrowser_await(function(e,t){try{var r=e()}catch(e){return t(!0,e)}return r&&r.then?r.then(t.bind(null,!1),t.bind(null,!0)):t(!1,r)}(function(){return UploadManagerBrowser_await(new Promise(function(t,o){a.upload.addEventListener("progress",function(e){e.lengthComputable&&n(e.loaded)},!1),a.addEventListener("load",function(){var e,r=null!==(e=a.getResponseHeader("etag"))&&void 0!==e?e:void 0;t({etag:r,status:a.status})}),a.onabort=function(){return o(new B)},a.onerror=function(){return o(Error("File upload error."))},a.ontimeout=function(){return o(Error("File upload timeout."))},a.open("PUT",e.uploadUrl),a.send(i.getRequestBody(e,r))}))},function(e,t){return c=!1,function(e,t){if(e)throw t;return t}(e,t)}))}catch(e){return Promise.reject(e)}}}],UploadManagerBrowser_defineProperties(UploadManager.prototype,t),r&&UploadManagerBrowser_defineProperties(UploadManager,r),Object.defineProperty(UploadManager,"prototype",{writable:!1}),UploadManager}(function(e){var t,r;function UploadManagerBrowserWorkerBase(){var e,t;return!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,UploadManagerBrowserWorkerBase),e=UploadManagerBrowserWorkerBase,t=arguments,e=UploadManagerBrowserWorkerBase_getPrototypeOf(e),function(e,t){if(t&&("object"===UploadManagerBrowserWorkerBase_typeof(t)||"function"==typeof t))return t;if(void 0!==t)throw TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(this,UploadManagerBrowserWorkerBase_isNativeReflectConstruct()?Reflect.construct(e,t||[],UploadManagerBrowserWorkerBase_getPrototypeOf(this).constructor):e.apply(this,t))}return!function(e,t){if("function"!=typeof t&&null!==t)throw 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&&UploadManagerBrowserWorkerBase_setPrototypeOf(e,t)}(UploadManagerBrowserWorkerBase,e),t=[{key:"processUploadSource",value:function(e){if("string"==typeof e)return{type:"Blob",value:new Blob([e],{type:this.stringMimeType})};if(void 0!==e.byteLength)return{type:"ArrayBuffer",value:e};if(void 0!==e.size)return{type:"Blob",value:e};throw Error("Unsupported type for 'data' parameter. Please provide a String, Blob, ArrayBuffer, or File object (from a file input element).")}},{key:"getPreUploadInfoPartial",value:function(e,t){switch(t.type){case"Blob":return this.getBlobInfo(t);case"ArrayBuffer":return{mime:void 0,size:t.value.byteLength,originalFileName:void 0,maxConcurrentUploadParts:void 0};default:assertUnreachable(t)}
1}},{key:"preUpload",value:function(e){}},{key:"postUpload",value:function(e){var t,r;return t&&t.then||(t=Promise.resolve(t)),r?t.then(r):t}},{key:"getRequestBody",value:function(e,t){return -1===e.range.inclusiveEnd?new Blob:t.value.slice(e.range.inclusiveStart,e.range.inclusiveEnd+1)}}],UploadManagerBrowserWorkerBase_defineProperties(UploadManagerBrowserWorkerBase.prototype,t),r&&UploadManagerBrowserWorkerBase_defineProperties(UploadManagerBrowserWorkerBase,r),Object.defineProperty(UploadManagerBrowserWorkerBase,"prototype",{writable:!1}),UploadManagerBrowserWorkerBase}((u=function UploadManagerBase(e){(function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")})(this,UploadManagerBase),this.config=e,this.stringMimeType="text/plain",this.defaultMaxConcurrentUploadParts=4,this.intervalMs=500,this.uploadApi=new R(e),this.accountId=S.getAccountId(e)},l=[{key:"upload",value:function(e){try{var t=this;t.assertNotCancelled(e);var r=t.processUploadSource(e.data),n=t.getPreUploadInfo(e,r),o=n.size,i=t.makeOnProgressForPartFactory(e,o),a=t.preUpload(r);return void 0!==e.onProgress&&e.onProgress(t.makeProgressEvent(0,o)),UploadManagerBase_await(t.beginUpload(e,n),function(o){var c,u,l,s=o.uploadParts.count,f=UploadManagerBase_toConsumableArray(Array(s).keys()),p=t.makeCancellationMethods(),d=p.cancel,y=p.addCancellationHandler,h=setInterval(t.onIntervalTick(e,d),t.intervalMs);return c=function(e,t){try{var r=e()}catch(e){return t(!0,e)}return r&&r.then?r.then(t.bind(null,!1),t.bind(null,!0)):t(!1,r)}(function(){return UploadManagerBase_await(t.mapAsync(f,n.maxConcurrentUploadParts,_async(function(n){return t.uploadPart(e,r,n,o,i(),y)})),function(e){var r;return l=e,(r=t.postUpload(a))&&r.then?r.then(UploadManagerBase_empty):Promise.resolve()})},function(e,t){return clearInterval(h),function(e,t){if(e)throw t;return t}(e,t)}),u=function(){var e=l.flatMap(function(e){return"Completed"===e.status?[e.etag]:[]})[0];return Object.assign(Object.assign({},o.file),{etag:e})},c&&c.then?c.then(u):u(c)})}catch(e){return Promise.reject(e)}}},{key:"getBlobInfo",value:function(e){var t=e.value,r=t.name,n=t.size,o=t.type;return{mime:""===o?void 0:o,size:n,originalFileName:r,maxConcurrentUploadParts:void 0}}},{key:"onIntervalTick",value:function(e,t){var r=this;return function(){r.isCancelled(e)&&t()}}},{key:"makeCancellationMethods",value:function(){var e=[];return{cancel:function(){return e.forEach(function(e){return e()})},addCancellationHandler:function(t){e.push(t)}}}},{key:"makeOnProgressForPartFactory",value:function(e,t){var r=this,n=e.onProgress;if(void 0===n)return function(){return function(){}};var o=0;return function(){var e=0;return function(i){var a=i-e;e+=a,o+=a,n(r.makeProgressEvent(o,t))}}}},{key:"makeProgressEvent",value:function(e,t){return{bytesTotal:t,bytesSent:e,progress:Math.round(e/t*100)}}},{key:"assertNotCancelled",value:function(e){if(this.isCancelled(e))throw new B}},{key:"isCancelled",value:function(e){var t;return(null===(t=e.cancellationToken)||void 0===t?void 0:t.isCancelled)===!0}},{key:"beginUpload",value:function(e,t){var r=t.size,n=t.mime,o=t.originalFileName;try{return UploadManagerBase_await(this.uploadApi.beginMultipartUpload({accountId:this.accountId,beginMultipartUploadRequest:{metadata:e.metadata,mime:n,originalFileName:o,path:e.path,protocol:"1.1",size:r,tags:e.tags}}))}catch(e){return Promise.reject(e)}}},{key:"uploadPart",value:function(e,t,r,n,o,i){try{var a=this;return a.assertNotCancelled(e),UploadManagerBase_await(a.getUploadPart(r,n),function(c){return a.assertNotCancelled(e),UploadManagerBase_await(a.putUploadPart(c,t,o,i),function(t){return a.assertNotCancelled(e),UploadManagerBase_await(a.uploadApi.completeUploadPart({accountId:a.accountId,uploadId:n.uploadId,uploadPartIndex:r,completeUploadPartRequest:{etag:t}}))})})}catch(e){return Promise.reject(e)}}},{key:"putUploadPart",value:function(e,t,r,n){try{var o=e.range.inclusiveEnd+1-e.range.inclusiveStart;return UploadManagerBase_await(this.doPutUploadPart(e,o,t,r,n),function(e){var t=e.status,n=e.etag;if(2!==Math.floor(t/100))throw Error("Failed to upload part (".concat(t,")."));if(void 0===n)throw Error("No 'etag' response header found in upload part response.");return r(o),n})}catch(e){return Promise.reject(e)}}},{key:"getUploadPart",value:function(e,t){try{if(0===e)return UploadManagerBase_await(t.uploadParts.first);return UploadManagerBase_await(this.uploadApi.getUploadPart({uploadId:t.uploadId,accountId:this.accountId,uploadPartIndex:e}))}catch(e){return Promise.reject(e)}}},{key:"getPreUploadInfo",value:function(e,t){var r,n,o,i=this.getPreUploadInfoPartial(e,t);return{maxConcurrentUploadParts:null!==(r=i.maxConcurrentUploadParts)&&void 0!==r?r:this.defaultMaxConcurrentUploadParts,originalFileName:null!==(n=e.originalFileName)&&void 0!==n?n:i.originalFileName,mime:null!==(o=e.mime)&&void 0!==o?o:i.mime,size:i.size}}},{key:"mapAsync",value:function(e,t,r){try{var n=[],o=UploadManagerBase_toConsumableArray(e);return UploadManagerBase_await(Promise.all(UploadManagerBase_toConsumableArray(Array(t).keys()).map(_async(function(){return function(e){if(e&&e.then)return e.then(UploadManagerBase_empty)}(function(e,t,r){for(;;){var n,o=e();
1if(_isSettledPact(o)&&(o=o.v),!o)return i;if(o.then){n=0;break}var i=r();if(i&&i.then){if(_isSettledPact(i))i=i.s;else{n=1;break}}if(t){var a=t();if(a&&a.then&&!_isSettledPact(a)){n=2;break}}}var c=new J,u=_settle.bind(null,c,2);return(0===n?o.then(_resumeAfterTest):1===n?i.then(_resumeAfterBody):a.then(_resumeAfterUpdate)).then(void 0,u),c;function _resumeAfterBody(n){i=n;do{if(t&&(a=t())&&a.then&&!_isSettledPact(a)){a.then(_resumeAfterUpdate).then(void 0,u);return}if(!(o=e())||_isSettledPact(o)&&!o.v){_settle(c,1,i);return}if(o.then){o.then(_resumeAfterTest).then(void 0,u);return}_isSettledPact(i=r())&&(i=i.v)}while(!i||!i.then);i.then(_resumeAfterBody).then(void 0,u)}function _resumeAfterTest(e){e?(i=r())&&i.then?i.then(_resumeAfterBody).then(void 0,u):_resumeAfterBody(i):_settle(c,1,i)}function _resumeAfterUpdate(){(o=e())?o.then?o.then(_resumeAfterTest).then(void 0,u):_resumeAfterTest(o):_settle(c,1,i)}}(function(){return o.length>0},void 0,function(){var e=o.shift();return function(e){var t=e();if(t&&t.then)return t.then(UploadManagerBase_empty)}(function(){if(void 0!==e){var t=n.push;return UploadManagerBase_await(r(e),function(e){t.call(n,e)})}})}))}))),function(){return n})}catch(e){return Promise.reject(e)}}}],UploadManagerBase_defineProperties(u.prototype,l),s&&UploadManagerBase_defineProperties(u,s),Object.defineProperty(u,"prototype",{writable:!1}),u)));function ServiceWorkerUtils_await(e,t,r){return r?t?t(e):e:(e&&e.then||(e=Promise.resolve(e)),t?e.then(t):e)}function ServiceWorkerUtils_empty(){}function ServiceWorkerUtils_settle(e,t,r){if(!e.s){if(r instanceof L){if(r.s)1&t&&(t=r.s),r=r.v;else{r.o=ServiceWorkerUtils_settle.bind(null,e,t);return}}if(r&&r.then){r.then(ServiceWorkerUtils_settle.bind(null,e,t),ServiceWorkerUtils_settle.bind(null,e,2));return}e.s=t,e.v=r;var n=e.o;n&&n(e)}}var L=function(){function _Pact(){}return _Pact.prototype.then=function(e,t){var r=new _Pact,n=this.s;if(n){var o=1&n?e:t;if(!o)return this;try{ServiceWorkerUtils_settle(r,1,o(this.v))}catch(e){ServiceWorkerUtils_settle(r,2,e)}return r}return this.o=function(n){try{var o=n.v;1&n.s?ServiceWorkerUtils_settle(r,1,e?e(o):o):t?ServiceWorkerUtils_settle(r,1,t(o)):ServiceWorkerUtils_settle(r,2,o)}catch(e){ServiceWorkerUtils_settle(r,2,e)}},r},_Pact}(),D="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function ServiceWorkerUtils_isSettledPact(e){return e instanceof L&&1&e.s}function ServiceWorkerUtils_typeof(e){return(ServiceWorkerUtils_typeof="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 ServiceWorkerUtils_defineProperties(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,function(e){var t=function(e,t){if("object"!=ServiceWorkerUtils_typeof(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=ServiceWorkerUtils_typeof(n))return n;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==ServiceWorkerUtils_typeof(t)?t:t+""}(n.key),n)}}var G=(f=function ServiceWorkerUtils(){!function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")}(this,ServiceWorkerUtils)},p=[{key:"canUseServiceWorkers",value:function(){return"serviceWorker"in navigator}},{key:"sendMessage",value:function(e,t,r){try{return ServiceWorkerUtils_await(this.ensureActiveServiceWorkerExists(e,t,r),function(t){return t.serviceWorker.postMessage(e),t.config})}catch(e){return Promise.reject(e)}}},{key:"ensureActiveServiceWorkerExists",value:function(e,t,r){try{var n,o,i=!1,a=this;return ServiceWorkerUtils_await((n=function(e,t){var r,n=-1;e:{for(var o=0;o<t.length;o++){var i=t[o][0];if(i){var a=i();if(a&&a.then)break e;if(a===e){n=o;break}}else n=o}if(-1!==n){do{for(var c=t[n][1];!c;)c=t[++n][1];var u=c();if(u&&u.then){r=!0;break e}var l=t[n][2];n++}while(l&&!l());return u}}var s=new L,f=ServiceWorkerUtils_settle.bind(null,s,2);return(r?u.then(_resumeAfterBody):a.then(function _resumeAfterTest(r){for(;;){if(r===e){n=o;break}if(++o===t.length){if(-1!==n)break;ServiceWorkerUtils_settle(s,1,c);return}
1if(i=t[o][0]){if((r=i())&&r.then){r.then(_resumeAfterTest).then(void 0,f);return}}else n=o}do{for(var a=t[n][1];!a;)a=t[++n][1];var c=a();if(c&&c.then){c.then(_resumeAfterBody).then(void 0,f);return}var u=t[n][2];n++}while(u&&!u());ServiceWorkerUtils_settle(s,1,c)})).then(void 0,f),s;function _resumeAfterBody(e){for(;;){var r=t[n][2];if(!r||r())break;for(var o=t[++n][1];!o;)o=t[++n][1];if((e=o())&&e.then){e.then(_resumeAfterBody).then(void 0,f);return}}ServiceWorkerUtils_settle(s,1,e)}}(t.type,[[function(){return"Uninitialized"},function(){return ServiceWorkerUtils_await(a.unregisterOnHardReload(),function(){})}],[function(){return"Initialized"},function(){return ServiceWorkerUtils_await(a.getActiveServiceWorker(t.serviceWorkerScope),function(e){if(void 0!==e)return i=!0,{serviceWorker:e,config:t}})}],[void 0,function(){assertUnreachable(t)},ServiceWorkerUtils_empty]]),o=function(n){return i?n:ServiceWorkerUtils_await(a.registerServiceWorker(t.serviceWorkerScript,e,r))},n&&n.then?n.then(o):o(n)))}catch(e){return Promise.reject(e)}}},{key:"registerServiceWorker",value:function(e,t,r){try{var n=this;if(!e.startsWith("/"))throw Error("The '".concat(r,"' field must start with a '/' and reference a script at the root of your website."));return e.split("/").length-1>1&&k.warn("The '".concat(r,"' field should be a root script (e.g. '/script.js'). The Bytescale SDK can only authorize requests originating from webpages that are at the same level as the script or below.")),ServiceWorkerUtils_await(function(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}(function(){return ServiceWorkerUtils_await(navigator.serviceWorker.register(e),function(r){return ServiceWorkerUtils_await(n.waitForActiveServiceWorker(r,t),function(t){return{serviceWorker:t,config:{serviceWorkerScript:e,serviceWorkerScope:r.scope,type:"Initialized"}}})})},function(e){throw Error("Failed to install Bytescale Service Worker (SW). ".concat(e.name,": ").concat(e.message))}))}catch(e){return Promise.reject(e)}}},{key:"waitForActiveServiceWorker",value:function(e,t){try{var r,n,o=!1,i=e.installing;return ServiceWorkerUtils_await((r=function(t){if(o)return t;if(null!==e.active)return e.active;throw Error("Service worker was neither 'installing' or 'active'.")},(n=function(){if(null!==i){var e=new Promise(function(e){i.addEventListener("statechange",function stateChangeHandler(t){var r=t.target;"activated"===r.state&&(i.removeEventListener("statechange",stateChangeHandler),e(r))})});return i.postMessage(t),ServiceWorkerUtils_await(e,function(e){return o=!0,e})}}())&&n.then?n.then(r):r(n)))}catch(e){return Promise.reject(e)}}},{key:"getActiveServiceWorker",value:function(e){try{var t,r;return ServiceWorkerUtils_await(this.getActiveRegistrations(),function(n){var o=n.filter(function(t){return t.scope===e});return null!==(r=null===(t=o[0])||void 0===t?void 0:t.active)&&void 0!==r?r:void 0})}catch(e){return Promise.reject(e)}}},{key:"unregisterOnHardReload",value:function(){try{if(null!==navigator.serviceWorker.controller)return ServiceWorkerUtils_await();return ServiceWorkerUtils_await(this.getActiveRegistrations(),function(e){return function(e){if(e&&e.then)return e.then(ServiceWorkerUtils_empty)}(function(e,t,r){if("function"==typeof e[D]){var n,o,i,a,c,u,l=e[D]();if(function _cycle(e){try{for(;!(a=l.next()).done&&(!r||!r());)if((e=t(a.value))&&e.then){if(ServiceWorkerUtils_isSettledPact(e))e=e.v;else{e.then(_cycle,u||(u=ServiceWorkerUtils_settle.bind(null,c=new L,2)));return}}c?ServiceWorkerUtils_settle(c,1,e):c=e}catch(e){ServiceWorkerUtils_settle(c||(c=new L),2,e)}}(),l.return){var _fixup=function(e){try{a.done||l.return()}catch(e){}return e};if(c&&c.then)return c.then(_fixup,function(e){throw _fixup(e)});_fixup()}return c}if(!("length"in e))throw TypeError("Object is not iterable");for(var s=[],f=0;f<e.length;f++)s.push(e[f]);return i=-1,function _cycle(e){try{for(;++i<s.length&&(!r||!r());){var a;if(a=i,(e=t(s[a]))&&e.then){if(ServiceWorkerUtils_isSettledPact(e))e=e.v;else{e.then(_cycle,o||(o=ServiceWorkerUtils_settle.bind(null,n=new L,2)));return}}}n?ServiceWorkerUtils_settle(n,1,e):n=e}catch(e){ServiceWorkerUtils_settle(n||(n=new L),2,e)}}(),n}(e,function(e){var t;return(t=e.unregister())&&t.then?t.then(ServiceWorkerUtils_empty):Promise.resolve()}))})}catch(e){return Promise.reject(e)}}},{key:"getActiveRegistrations",value:function(){try{return ServiceWorkerUtils_await(navigator.serviceWorker.getRegistrations(),function(e){return e.filter(function(e){return null!==e.active})})}catch(e){return Promise.reject(e)}}}],ServiceWorkerUtils_defineProperties(f.prototype,p),d&&ServiceWorkerUtils_defineProperties(f,d),Ob
1ject.defineProperty(f,"prototype",{writable:!1}),f);function Scheduler_typeof(e){return(Scheduler_typeof="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 Scheduler_defineProperties(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,function(e){var t=function(e,t){if("object"!=Scheduler_typeof(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=Scheduler_typeof(n))return n;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==Scheduler_typeof(t)?t:t+""}(n.key),n)}}var z=(y=function Scheduler(){(function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")})(this,Scheduler),this.callbacks={},this.nextId=0,this.intervalId=void 0},h=[{key:"schedule",value:function(e,t){var r=this.nextId++;return this.callbacks[r]={epoch:e,callback:t},this.startInterval(),r}},{key:"unschedule",value:function(e){delete this.callbacks[e],0===Object.keys(this.callbacks).length&&this.stopInterval()}},{key:"startInterval",value:function(){var e=this;void 0===this.intervalId&&(this.intervalId=setInterval(function(){return e.checkCallbacks()},1e3))}},{key:"stopInterval",value:function(){void 0!==this.intervalId&&(clearInterval(this.intervalId),this.intervalId=void 0)}},{key:"checkCallbacks",value:function(){var e=Date.now();for(var t in this.callbacks){var r=parseInt(t);if(this.callbacks[r].epoch<=e){try{this.callbacks[r].callback()}catch(e){k.error("Unhandled error from scheduled callback: ".concat(e))}this.unschedule(r)}}}}],Scheduler_defineProperties(y.prototype,h),v&&Scheduler_defineProperties(y,v),Object.defineProperty(y,"prototype",{writable:!1}),y);function AuthManagerBrowser_empty(){}function AuthManagerBrowser_awaitIgnored(e,t){if(!t)return e&&e.then?e.then(AuthManagerBrowser_empty):Promise.resolve()}function AuthManagerBrowser_await(e,t,r){return r?t?t(e):e:(e&&e.then||(e=Promise.resolve(e)),t?e.then(t):e)}function AuthManagerBrowser_async(e){return function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];try{return Promise.resolve(e.apply(this,t))}catch(e){return Promise.reject(e)}}}function AuthManagerBrowser_typeof(e){return(AuthManagerBrowser_typeof="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 AuthManagerBrowser_defineProperties(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,AuthManagerBrowser_toPropertyKey(n.key),n)}}function AuthManagerBrowser_toPropertyKey(e){var t=function(e,t){if("object"!=AuthManagerBrowser_typeof(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=AuthManagerBrowser_typeof(n))return n;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==AuthManagerBrowser_typeof(t)?t:t+""}var Q=new(m=function AuthManagerImpl(e){(function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")})(this,AuthManagerImpl),this.serviceWorkerUtils=e,this.serviceWorkerScriptFieldName="serviceWorkerScript",this.contentType="content-type",this.contentTypeJson="application/json",this.contentTypeText="text/plain",this.minJwtTtlSeconds=10,this.retryAuthAfterErrorSeconds=5,this.refreshBeforeExpirySeconds=20,this.scheduler=new z,this.authSessionMutex=A.getMutex()},b=[{key:"isAuthSessionActive",value:function(){return void 0!==A.getSession()}},{key:"isAuthSessionReady",value:function(){var e;return(null===(e=A.getSession())||void 0===e?void 0:e.accessToken)!==void 0}},{key:"beginAuthSession",value:function(e){try{var t=this;return AuthManagerBrowser_await(t.authSessionMutex.safe(AuthManagerBrowser_async(function(){if(t.isAuthSessionActive())throw Error("Auth session already active. Please call 'await endAuthSe
1ssion()' and then call 'await beginAuthSession(...)' to start a new auth session.");var r={accessToken:void 0,accessTokenRefreshHandle:void 0,params:e,isActive:!0,authServiceWorker:void 0!==e.serviceWorkerScript&&t.serviceWorkerUtils.canUseServiceWorkers()?{serviceWorkerScript:e.serviceWorkerScript,type:"Uninitialized"}:void 0};return A.setSession(r),r})),function(e){return AuthManagerBrowser_awaitIgnored(t.refreshAccessToken(e))})}catch(e){return Promise.reject(e)}}},{key:"endAuthSession",value:function(){try{var e=this;return AuthManagerBrowser_await(AuthManagerBrowser_awaitIgnored(e.authSessionMutex.safe(AuthManagerBrowser_async(function(){var t=A.getSession();if(void 0!==t)return A.setSession(void 0),t.isActive=!1,void 0!==t.accessTokenRefreshHandle&&e.scheduler.unschedule(t.accessTokenRefreshHandle),AuthManagerBrowser_await(e.deleteAccessToken(t.params),function(){return function(e){var t=e();if(t&&t.then)return t.then(AuthManagerBrowser_empty)}(function(){if(void 0!==t.authServiceWorker)return AuthManagerBrowser_awaitIgnored(e.serviceWorkerUtils.sendMessage({type:"SET_BYTESCALE_AUTH_CONFIG",config:[]},t.authServiceWorker,e.serviceWorkerScriptFieldName))})})}))))}catch(e){return Promise.reject(e)}}},{key:"refreshAccessToken",value:function(e){try{var t=this;return AuthManagerBrowser_await(AuthManagerBrowser_awaitIgnored(t.authSessionMutex.safe(AuthManagerBrowser_async(function(){if(e.isActive){var secondsFromNow=function(e){return Date.now()+1e3*e},r=secondsFromNow(t.retryAuthAfterErrorSeconds);return function(e){if(e&&e.then)return e.then(AuthManagerBrowser_empty)}(function(e,t){try{var r=e()}catch(e){return t(!0,e)}return r&&r.then?r.then(t.bind(null,!1),t.bind(null,!0)):t(!1,r)}(function(){return function(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}(function(){var n=t.getAccessToken,o=e.params;return AuthManagerBrowser_await(e.params.authHeaders(),function(i){return AuthManagerBrowser_await(n.call(t,o,i),function(n){var o=void 0===e.authServiceWorker;return AuthManagerBrowser_await(t.setAccessToken(e.params,n,o),function(o){var i,a;return i=function(){var n=o.ttlSeconds-t.refreshBeforeExpirySeconds,i=Math.max(n,t.minJwtTtlSeconds);n!==i&&k.warn("JWT expiration is too short: waiting for ".concat(i," seconds before refreshing.")),r=secondsFromNow(i),e.accessToken=o.accessToken},(a=function(){if(void 0!==e.authServiceWorker)return AuthManagerBrowser_await(t.serviceWorkerUtils.sendMessage({type:"SET_BYTESCALE_AUTH_CONFIG",config:[{headers:[{key:"Authorization",value:"Bearer ".concat(n)}],expires:secondsFromNow(o.ttlSeconds),urlPrefix:"".concat(t.getCdnUrl(e.params),"/").concat(e.params.accountId,"/")}]},e.authServiceWorker,t.serviceWorkerScriptFieldName),function(){return AuthManagerBrowser_awaitIgnored(new Promise(function(e){return setTimeout(e,100)}))})}())&&a.then?a.then(i):i(a)})})})},function(e){k.warn("Unable to refresh JWT access token: ".concat(e))})},function(n,o){return e.accessTokenRefreshHandle=t.scheduler.schedule(r,function(){t.refreshAccessToken(e).then(function(){},function(e){return k.error("Unexpected error when refreshing JWT access token: ".concat(e))})}),function(e,t){if(e)throw t;return t}(n,o)}))}}))))}catch(e){return Promise.reject(e)}}},{key:"getAccessTokenUrl",value:function(e,t){return"".concat(this.getCdnUrl(e),"/api/v1/access_tokens/").concat(e.accountId,"?set-cookie=").concat(t?"true":"false")}},{key:"getCdnUrl",value:function(e){var t;return S.getCdnUrl(null!==(t=e.options)&&void 0!==t?t:{})}},{key:"deleteAccessToken",value:function(e){try{var t;return AuthManagerBrowser_await(AuthManagerBrowser_awaitIgnored(U.fetch(this.getAccessTokenUrl(e,!0),{method:"DELETE",credentials:"include",headers:{}},{isBytescaleApi:!0,fetchApi:null===(t=e.options)||void 0===t?void 0:t.fetchApi})))}catch(e){return Promise.reject(e)}}},{key:"setAccessToken",value:function(e,t,r){try{var n,o,i,a;return AuthManagerBrowser_await(U.fetch(this.getAccessTokenUrl(e,r),{method:"PUT",credentials:"include",headers:(o={},i=this.contentType,a=this.contentTypeJson,(i=AuthManagerBrowser_toPropertyKey(i))in o?Object.defineProperty(o,i,{value:a,enumerable:!0,configurable:!0,writable:!0}):o[i]=a,o),body:JSON.stringify({accessToken:t})},{isBytescaleApi:!0,fetchApi:null===(n=e.options)||void 0===n?void 0:n.fetchApi}),function(e){return AuthManagerBrowser_await(e.json())})}catch(e){return Promise.reject(e)}}},{key:"getAccessToken",value:function(e,t){try{var r,n,o=this,i="Your auth API endpoint",a=o.contentTypeText;return AuthManagerBrowser_await(U.fetch(e.authUrl,{method:"GET",headers:t},{isBytescaleApi:!1,fetchApi:null===(r=e.options)||void 0===r?void 0:r.fetchApi}),function(e){var t=null!==(n=e.headers.get(o.contentType))&&void 0!==n?n:"";if(t.split(";")[0]!==a)throw Error("".concat(i,' returned "').concat(t,'" for the ').concat(o.contentType,' response header, but the Bytescale SDK requires "').concat(a,'".'));return AuthManagerBrowser_await(e.text(),function(e){if(0===e.length)throw Error("".concat(i," returned an empty string. Please return a valid JWT instead."));if(e.trim().length!==e.length)throw Error("".concat(i," returned whitespace around the JWT, please remove it."));return e})})}catch(e){return Promise.reject(e)}}}],AuthManagerBrowser_defineProperties(m.prototype,b),_&&AuthManagerBrowser_defineProperties(m,_),Object.defineProperty(m,"prototype",{writable:!1}),m)(new G);P.AuthManager,P.BaseAPI,P.BinaryResult,P.BytescaleApiClientConfigUtils,P.BytescaleApiError,P.BytescaleGenericError,P.CacheApi,P.CancelledError,P.CommonTypesNoOp,P.FileApi,P.FolderApi,P.JSONApiResponse,P.JobApi,P.UploadApi,P.UploadManager;var H=P.UrlBuilder;P.UrlBuilderTypesNoOp,P.VoidApiResponse,P.encodeBytescaleQuerystringKVP,P.querystring}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.