UNPKG

@cloudbase/utilities

Version:
1 lines 24.8 kB
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("tcbauth",[],e):"object"==typeof exports?exports.tcbauth=e():t.tcbauth=e()}("undefined"!=typeof window?window:this,()=>(()=>{"use strict";var t={d:(e,r)=>{for(var n in r)t.o(r,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{AbortController:()=>St,adapters:()=>o,cache:()=>i,constants:()=>r,events:()=>c,helpers:()=>s,jwt:()=>Nt,langEvent:()=>a,utils:()=>n});var r={};t.r(r),t.d(r,{COMMUNITY_SITE_URL:()=>b,ERRORS:()=>g,IS_DEBUG_MODE:()=>v,OATUH_LOGINTYPE:()=>m,getProtocol:()=>h,getSdkName:()=>f,setProtocol:()=>d,setSdkName:()=>l});var n={};t.r(n),t.d(n,{createPromiseCallback:()=>L,execCallback:()=>M,formatUrl:()=>P,genSeqId:()=>j,generateRequestId:()=>N,getHash:()=>C,getQuery:()=>k,isArray:()=>O,isFormData:()=>A,isInstanceOf:()=>_,isNull:()=>I,isPalinObject:()=>S,isString:()=>E,isUndefined:()=>x,parseQueryString:()=>G,printError:()=>U,printGroupLog:()=>J,printInfo:()=>q,printWarn:()=>D,removeParam:()=>T,sleep:()=>F,throwError:()=>V,toQueryString:()=>R,transformPhone:()=>W});var o={};t.r(o),t.d(o,{RUNTIME:()=>Q,useAdapters:()=>Z,useDefaultAdapter:()=>tt});var i={};t.r(i),t.d(i,{CloudbaseCache:()=>it});var c={};t.r(c),t.d(c,{CloudbaseEvent:()=>st,CloudbaseEventEmitter:()=>lt,IErrorEvent:()=>ut,activateEvent:()=>dt,addEventListener:()=>pt,removeEventListener:()=>ht});var a={};t.r(a),t.d(a,{LANG_CHANGE_EVENT:()=>vt,bus:()=>yt});var s={};t.r(s),t.d(s,{catchErrorsDecorator:()=>Et});var u="@cloudbase/js-sdk";function l(t){u=t}function f(){return u}var p="https:";function d(t){p=t}function h(){return p}var y,v=!1,b="https://support.qq.com/products/148793",g={INVALID_PARAMS:"INVALID_PARAMS",INVALID_SYNTAX:"INVALID_SYNTAX",INVALID_OPERATION:"INVALID_OPERATION",OPERATION_FAIL:"OPERATION_FAIL",NETWORK_ERROR:"NETWORK_ERROR",UNKOWN_ERROR:"UNKOWN_ERROR"},m="constants";!function(t){t.local="local",t.none="none",t.session="session"}(y||(y={}));var w=function(){};function O(t){return"[object Array]"===Object.prototype.toString.call(t)}function E(t){return"string"==typeof t}function x(t){return void 0===t}function S(t){return"[object Object]"===Object.prototype.toString.call(t)}function I(t){return"[object Null]"===Object.prototype.toString.call(t)}function _(t,e){return t instanceof e}function A(t){return"[object FormData]"===Object.prototype.toString.call(t)}function j(){return Math.random().toString(16).slice(2)}function N(){var t=(new Date).getTime(),e=(null===Date||void 0===Date?void 0:Date.now)&&1e3*Date.now()||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(r){var n=16*Math.random();return t>0?(n=(t+n)%16|0,t=Math.floor(t/16)):(n=(e+n)%16|0,e=Math.floor(e/16)),("x"===r?n:7&n|8).toString(16)}))}function P(t,e,r){void 0===r&&(r={});var n=/\?/.test(e),o="";return Object.keys(r).forEach((function(t){""===o?!n&&(e+="?"):o+="&",o+="".concat(t,"=").concat(encodeURIComponent(r[t]))})),/^http(s)?:\/\//.test(e+=o)?e:"".concat(t).concat(e)}function R(t){void 0===t&&(t={});var e=[];return Object.keys(t).forEach((function(r){e.push("".concat(r,"=").concat(encodeURIComponent(t[r])))})),e.join("&")}function k(t,e){if("undefined"==typeof window)return!1;var r=e||window.location.search,n=new RegExp("(^|&)".concat(t,"=([^&]*)(&|$)")),o=r.substr(r.indexOf("?")+1).match(n);return null!=o?o[2]:""}var C=function(t){if("undefined"==typeof window)return"";var e=window.location.hash.match(new RegExp("[#?&/]".concat(t,"=([^&#]*)")));return e?e[1]:""};function T(t,e){var r=e.split("?")[0],n=[],o=-1!==e.indexOf("?")?e.split("?")[1]:"";if(""!==o){for(var i=(n=o.split("&")).length-1;i>=0;i-=1)n[i].split("=")[0]===t&&n.splice(i,1);r="".concat(r,"?").concat(n.join("&"))}return r}function L(){var t;if(!Promise){(t=function(){}).promise={};var e=function(){throw new Error('Your Node runtime does support ES6 Promises. Set "global.Promise" to your preferred implementation of promises.')};return Object.defineProperty(t.promise,"then",{get:e}),Object.defineProperty(t.promise,"catch",{get:e}),t}var r=new Promise((function(e,r){t=function(t,n){return t?r(t):e(n)}}));return t.promise=r,t}function M(t,e,r){if(void 0===r&&(r=null),t&&"function"==typeof t)return t(e,r);if(e)throw e;return r}function D(t,e){console.warn("[".concat(f(),"][").concat(t,"]:").concat(e))}function U(t,e){console.error({code:t,msg:"[".concat(f(),"][").concat(t,"]:").concat(e)})}function q(t,e){console.log("[".concat(f(),"][").concat(t,"]:").concat(e))}function V(t,e){throw new Error(JSON.stringify({code:t,msg:"[".concat(f(),"][").concat(t,"]:").concat(e)}))}function J(t){var e,r=t.title,n=t.subtitle,o=void 0===n?"":n,i=t.content,c=void 0===i?[]:i,a=t.printTrace,s=void 0!==a&&a,u=t.collapsed;void 0!==u&&u?(console.groupCollapsed||console.error)(r,o):(console.group||console.error)(r,o);for(var l=0,f=c;l<f.length;l++){var p=f[l],d=p.type,h=p.body;switch(d){case"info":console.log(h);break;case"warn":console.warn(h);break;case"error":console.error(h)}}s&&(console.trace||console.log)("stack trace:"),null===(e=console.groupEnd)||void 0===e||e.call(console)}var F=function(t){return void 0===t&&(t=0),new Promise((function(e){return setTimeout(e,t)}))};function W(t){return"+86".concat(t)}var $,G=function(t){t=t.replace(/^\?/,"");var e={};return t.split("&").forEach((function(t){var r=t.split("="),n=r[0],o=r[1];n=decodeURIComponent(n),o=decodeURIComponent(o),n&&(e[n]?Array.isArray(e[n])?e[n].push(o):e[n]=[e[n],o]:e[n]=o)})),e},H=($=function(t,e){return($=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}$(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),Y=function(){return(Y=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)},B=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function c(t){try{s(n.next(t))}catch(t){i(t)}}function a(t){try{s(n.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(c,a)}s((n=n.apply(t,e||[])).next())}))},K=function(t,e){var r,n,o,i,c={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(s){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(c=0)),c;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return c.label++,{value:a[1],done:!1};case 5:c.label++,n=a[1],a=[0];continue;case 7:a=c.ops.pop(),c.trys.pop();continue;default:if(!(o=c.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){c=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){c.label=a[1];break}if(6===a[0]&&c.label<o[1]){c.label=o[1],o=a;break}if(o&&c.label<o[2]){c.label=o[2],c.ops.push(a);break}o[2]&&c.ops.pop(),c.trys.pop();continue}a=e.call(t,c)}catch(t){a=[6,t],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,s])}}},X=function(t){function e(e){var r=t.call(this)||this,n=e.timeout,o=e.timeoutMsg,i=e.restrictedMethods;return r.timeout=n||0,r.timeoutMsg=o||"请求超时",r.restrictedMethods=i||["get","post","upload","download"],r}return H(e,t),e.prototype.get=function(t){return this.request(Y(Y({},t),{method:"get"}),this.restrictedMethods.includes("get"))},e.prototype.post=function(t){return this.request(Y(Y({},t),{method:"post"}),this.restrictedMethods.includes("post"))},e.prototype.put=function(t){return this.request(Y(Y({},t),{method:"put"}))},e.prototype.upload=function(t){var e=t.data,r=t.file,n=t.name,o=t.method,i=t.headers,c=void 0===i?{}:i,a={post:"post",put:"put"}[null==o?void 0:o.toLowerCase()]||"put",s=new FormData;return"post"===a?(Object.keys(e).forEach((function(t){s.append(t,e[t])})),s.append("key",n),s.append("file",r),this.request(Y(Y({},t),{data:s,method:a}),this.restrictedMethods.includes("upload"))):this.request(Y(Y({},t),{method:"put",headers:c,body:r}),this.restrictedMethods.includes("upload"))},e.prototype.download=function(t){return B(this,void 0,void 0,(function(){var e,r,n,o;return K(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this.get(Y(Y({},t),{headers:{},responseType:"blob"}))];case 1:return e=i.sent().data,r=window.URL.createObjectURL(new Blob([e])),n=decodeURIComponent(new URL(t.url).pathname.split("/").pop()||""),(o=document.createElement("a")).href=r,o.setAttribute("download",n),o.style.display="none",document.body.appendChild(o),o.click(),window.URL.revokeObjectURL(r),document.body.removeChild(o),[3,3];case 2:return i.sent(),[3,3];case 3:return[2,new Promise((function(e){e({statusCode:200,tempFilePath:t.url})}))]}}))}))},e.prototype.fetch=function(t){var e;return B(this,void 0,void 0,(function(){var r,n,o,i,c,a,s,u,l,f,p,d=this;return K(this,(function(h){switch(h.label){case 0:return r=new AbortController,n=t.url,o=t.enableAbort,i=void 0!==o&&o,c=t.stream,a=void 0!==c&&c,s=t.signal,u=t.timeout,l=null!=u?u:this.timeout,s&&(s.aborted&&r.abort(),s.addEventListener("abort",(function(){return r.abort()}))),f=null,i&&l&&(f=setTimeout((function(){console.warn(d.timeoutMsg),r.abort(new Error(d.timeoutMsg))}),l)),[4,fetch(n,Y(Y({},t),{signal:r.signal})).then((function(t){return B(d,void 0,void 0,(function(){var e,r,n;return K(this,(function(o){switch(o.label){case 0:return clearTimeout(f),t.ok?(e=t,[3,3]):[3,1];case 1:return n=(r=Promise).reject,[4,t.json()];case 2:e=n.apply(r,[o.sent()]),o.label=3;case 3:return[2,e]}}))}))})).catch((function(t){return clearTimeout(f),Promise.reject(t)}))];case 1:return p=h.sent(),[2,{data:a?p.body:(null===(e=p.headers.get("content-type"))||void 0===e?void 0:e.includes("application/json"))?p.json():p.text(),statusCode:p.status,header:p.headers}]}}))}))},e.prototype.request=function(t,e){var r=this;void 0===e&&(e=!1);var n=String(t.method).toLowerCase()||"get";return new Promise((function(o){var i,c,a=t.url,s=t.headers,u=void 0===s?{}:s,l=t.data,f=t.responseType,p=t.withCredentials,d=t.body,y=t.onUploadProgress,v=P(h(),a,"get"===n?l:{}),b=new XMLHttpRequest;b.open(n,v),f&&(b.responseType=f),Object.keys(u).forEach((function(t){b.setRequestHeader(t,u[t])})),y&&b.upload.addEventListener("progress",y),b.onreadystatechange=function(){var t={};if(4===b.readyState){var e=b.getAllResponseHeaders().trim().split(/[\r\n]+/),r={};e.forEach((function(t){var e=t.split(": "),n=e.shift().toLowerCase(),o=e.join(": ");r[n]=o})),t.header=r,t.statusCode=b.status;try{t.data="blob"===f?b.response:JSON.parse(b.responseText)}catch(e){t.data="blob"===f?b.response:b.responseText}clearTimeout(i),o(t)}},e&&r.timeout&&(i=setTimeout((function(){console.warn(r.timeoutMsg),b.abort()}),r.timeout)),c=A(l)?l:"application/x-www-form-urlencoded"===u["content-type"]?R(l):d||(l?JSON.stringify(l):void 0),p&&(b.withCredentials=!0),b.send(c)}))},e}((function(){}));var Q,z=function(){return(z=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};function Z(t,e){for(var r=0,n=O(t)?t:[t];r<n.length;r++){var o=n[r],i=o.isMatch,c=o.genAdapter,a=o.runtime;if(i())return{adapter:z({isMatch:i},c(e)),runtime:a}}}function tt(){return{adapter:{type:"default",root:window,reqClass:X,wsClass:WebSocket,localStorage:localStorage},runtime:Q.WEB}}!function(t){t.WEB="web",t.WX_MP="wx_mp"}(Q||(Q={}));var et=function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),rt=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function c(t){try{s(n.next(t))}catch(t){i(t)}}function a(t){try{s(n.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(c,a)}s((n=n.apply(t,e||[])).next())}))},nt=function(t,e){var r,n,o,i,c={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(s){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(c=0)),c;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return c.label++,{value:a[1],done:!1};case 5:c.label++,n=a[1],a=[0];continue;case 7:a=c.ops.pop(),c.trys.pop();continue;default:if(!(o=c.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){c=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){c.label=a[1];break}if(6===a[0]&&c.label<o[1]){c.label=o[1],o=a;break}if(o&&c.label<o[2]){c.label=o[2],c.ops.push(a);break}o[2]&&c.ops.pop(),c.trys.pop();continue}a=e.call(t,c)}catch(t){a=[6,t],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,s])}}},ot=function(t){function e(e){var r=t.call(this)||this;return r.root=e,e.tcbCacheObject||(e.tcbCacheObject={}),r}return et(e,t),e.prototype.setItem=function(t,e){this.root.tcbCacheObject[t]=e},e.prototype.getItem=function(t){return this.root.tcbCacheObject[t]},e.prototype.removeItem=function(t){delete this.root.tcbCacheObject[t]},e.prototype.clear=function(){delete this.root.tcbCacheObject},e}(w);var it=function(){function t(t){this.keys={};var e=t.persistence,r=t.platformInfo,n=void 0===r?{}:r,o=t.keys,i=void 0===o?{}:o;this.platformInfo=n,this.storage||(this.persistenceTag=this.platformInfo.adapter.primaryStorage||e,this.storage=function(t,e){switch(t){case"local":return e.localStorage?e.localStorage:(D(g.INVALID_PARAMS,"localStorage is not supported on current platform"),new ot(e.root));case"none":return new ot(e.root);default:return e.localStorage?e.localStorage:(D(g.INVALID_PARAMS,"localStorage is not supported on current platform"),new ot(e.root))}}(this.persistenceTag,this.platformInfo.adapter),this.keys=i)}return Object.defineProperty(t.prototype,"mode",{get:function(){return this.storage.mode||"sync"},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"persistence",{get:function(){return this.persistenceTag},enumerable:!1,configurable:!0}),t.prototype.setStore=function(t,e,r){if("async"!==this.mode){if(this.storage)try{var n={version:r||"localCachev1",content:e};this.storage.setItem(t,JSON.stringify(n))}catch(t){throw new Error(JSON.stringify({code:g.OPERATION_FAIL,msg:"[".concat(f(),"][").concat(g.OPERATION_FAIL,"]setStore failed"),info:t}))}}else D(g.INVALID_OPERATION,"current platform's storage is asynchronous, please use setStoreAsync insteed")},t.prototype.setStoreAsync=function(t,e,r){return rt(this,void 0,void 0,(function(){var n;return nt(this,(function(o){switch(o.label){case 0:if(!this.storage)return[2];o.label=1;case 1:return o.trys.push([1,3,,4]),n={version:r||"localCachev1",content:e},[4,this.storage.setItem(t,JSON.stringify(n))];case 2:return o.sent(),[3,4];case 3:return o.sent(),[2];case 4:return[2]}}))}))},t.prototype.getStore=function(t,e){var r;if("async"!==this.mode){try{if("undefined"!=typeof process&&(null===(r=process.env)||void 0===r?void 0:r.tcb_token))return process.env.tcb_token;if(!this.storage)return""}catch(t){return""}e=e||"localCachev1";var n=this.storage.getItem(t);return n&&n.indexOf(e)>=0?JSON.parse(n).content:""}D(g.INVALID_OPERATION,"current platform's storage is asynchronous, please use getStoreAsync insteed")},t.prototype.getStoreAsync=function(t,e){var r;return rt(this,void 0,void 0,(function(){var n;return nt(this,(function(o){switch(o.label){case 0:try{if("undefined"!=typeof process&&(null===(r=process.env)||void 0===r?void 0:r.tcb_token))return[2,process.env.tcb_token];if(!this.storage)return[2,""]}catch(t){return[2,""]}return e=e||"localCachev1",[4,this.storage.getItem(t)];case 1:return(n=o.sent())&&n.indexOf(e)>=0?[2,JSON.parse(n).content]:[2,""]}}))}))},t.prototype.removeStore=function(t){"async"!==this.mode?this.storage.removeItem(t):D(g.INVALID_OPERATION,"current platform's storage is asynchronous, please use removeStoreAsync insteed")},t.prototype.removeStoreAsync=function(t){return rt(this,void 0,void 0,(function(){return nt(this,(function(e){switch(e.label){case 0:return[4,this.storage.removeItem(t)];case 1:return e.sent(),[2]}}))}))},t}(),ct=function(){var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(e,r)};return function(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),at=function(t,e,r){if(r||2===arguments.length)for(var n,o=0,i=e.length;o<i;o++)!n&&o in e||(n||(n=Array.prototype.slice.call(e,0,o)),n[o]=e[o]);return t.concat(n||Array.prototype.slice.call(e))};var st=function(t,e){this.data=e||null,this.name=t},ut=function(t){function e(e,r){var n=t.call(this,"error",{error:e,data:r})||this;return n.error=e,n}return ct(e,t),e}(st),lt=function(){function t(){this.listeners={}}return t.prototype.on=function(t,e){return function(t,e,r){r[t]=r[t]||[],r[t].push(e)}(t,e,this.listeners),this},t.prototype.off=function(t,e){return function(t,e,r){if(null==r?void 0:r[t]){var n=r[t].indexOf(e);-1!==n&&r[t].splice(n,1)}}(t,e,this.listeners),this},t.prototype.fire=function(t,e){if(_(t,ut))return console.error(t.error),this;var r=E(t)?new st(t,e||{}):t,n=r.name;if(this.listens(n)){r.target=this;for(var o=0,i=this.listeners[n]?at([],this.listeners[n],!0):[];o<i.length;o++){i[o].call(this,r)}}return this},t.prototype.listens=function(t){return this.listeners[t]&&this.listeners[t].length>0},t}(),ft=new lt;function pt(t,e){ft.on(t,e)}function dt(t,e){void 0===e&&(e={}),ft.fire(t,e)}function ht(t,e){ft.off(t,e)}var yt=new lt,vt="lang_change",bt=function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function c(t){try{s(n.next(t))}catch(t){i(t)}}function a(t){try{s(n.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(c,a)}s((n=n.apply(t,e||[])).next())}))},gt=function(t,e){var r,n,o,i,c={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(s){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(c=0)),c;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return c.label++,{value:a[1],done:!1};case 5:c.label++,n=a[1],a=[0];continue;case 7:a=c.ops.pop(),c.trys.pop();continue;default:if(!(o=c.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){c=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){c.label=a[1];break}if(6===a[0]&&c.label<o[1]){c.label=o[1],o=a;break}if(o&&c.label<o[2]){c.label=o[2],c.ops.push(a);break}o[2]&&c.ops.pop(),c.trys.pop();continue}a=e.call(t,c)}catch(t){a=[6,t],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,s])}}},mt=!1;"undefined"!=typeof navigator&&navigator.userAgent&&(mt=-1!==navigator.userAgent.indexOf("Firefox"));var wt=mt?/(\.js\/)?__decorate(\$\d+)?<@.*\d$/:/(\/\w+\.js\.)?__decorate(\$\d+)?\s*\(.*\)$/,Ot=/https?:\/\/.+:\d*\/.*\.js:\d+:\d+/;function Et(t){var e=t.mode,r=void 0===e?"async":e,n=t.customInfo,o=void 0===n?{}:n,i=t.title,c=t.messages,a=void 0===c?[]:c;return function(t,e,n){if(v){var c=o.className||t.constructor.name,s=o.methodName||e,u=n.value,l=function(t){var e="",r=t.stack.split("\n"),n=r.findIndex((function(t){return wt.test(t)}));if(-1!==n){var o=Ot.exec(r[n+1]||"");e=o?o[0]:""}return e}(new Error);n.value="sync"===r?function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=xt({err:new Error,className:c,methodName:s,sourceLink:l});try{return u.apply(this,t)}catch(t){var n=t,o=t.message,f=t.error,p=t.error_description,d={title:i||"".concat(c,".").concat(s," failed"),content:[{type:"error",body:t}]};if(o&&/^\{.*\}$/.test(o)){var h=JSON.parse(o);d.subtitle=o,h.code&&(r?(r.code=h.code,r.msg=h.msg):(t.code=h.code,t.message=h.msg),n=r||t,d.content=a.map((function(t){return{type:"info",body:t}})))}throw f&&p&&(d.subtitle=p,r?(r.code=f,r.msg=p):(t.code=f,t.message=p),n=r||t,d.content=a.map((function(t){return{type:"info",body:t}}))),J(d),n}}:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return bt(this,void 0,void 0,(function(){var e,r,n,o,f,p,d,h;return gt(this,(function(y){switch(y.label){case 0:e=xt({err:new Error,className:c,methodName:s,sourceLink:l}),y.label=1;case 1:return y.trys.push([1,3,,4]),[4,u.apply(this,t)];case 2:return[2,y.sent()];case 3:throw r=y.sent(),n=r,o=r.message,f=r.error,p=r.error_description,d={title:i||"".concat(c,".").concat(s," failed"),content:[{type:"error",body:r}]},o&&/^\{.*\}$/.test(o)&&(h=JSON.parse(o),d.subtitle=h,h.code&&(e?(e.code=h.code,e.message=h.msg):(r.code=h.code,r.message=h.msg),n=e||r,d.content=a.map((function(t){return{type:"info",body:t}})))),f&&p&&(d.subtitle=p,e?(e.code=f,e.msg=p):(r.code=f,r.message=p),n=e||r,d.content=a.map((function(t){return{type:"info",body:t}}))),J(d),n;case 4:return[2]}}))}))}}}}function xt(t){var e=t.err,r=t.className,n=t.methodName,o=t.sourceLink;if(!o)return null;var i,c=e.stack.split("\n"),a=mt?/^catchErrorsDecorator\/<\/descriptor.value@.*\d$/:new RegExp("".concat(r,"\\.descriptor.value\\s*\\[as\\s").concat(n,"\\]\\s*\\(.*\\)$")),s=mt?/^catchErrorsDecorator\/<\/descriptor.value/:new RegExp("".concat(r,"\\.descriptor.value\\s*\\[as\\s").concat(n,"\\]")),u=c.findIndex((function(t){return a.test(t)}));if(-1!==u){var l=c.filter((function(t,e){return e>u}));l.unshift(c[u].replace(s,"".concat(r,".").concat(n)).replace(Ot,o)),(i=new Error).stack="".concat(mt?"@debugger":"Error","\n").concat(l.join("\n"))}return i}const St=function(){function t(){var t=this;this.listeners=[],this.signal={aborted:!1,addEventListener:function(e,r){"abort"===e&&t.listeners.push(r)}}}return t.prototype.abort=function(){this.signal.aborted||(this.signal.aborted=!0,this.listeners.forEach((function(t){return t()})))},t}();function It(t){this.message=t}It.prototype=new Error,It.prototype.name="InvalidCharacterError";var _t="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new It("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,n,o=0,i=0,c="";n=e.charAt(i++);~n&&(r=o%4?64*r+n:n,o++%4)?c+=String.fromCharCode(255&r>>(-2*o&6)):0)n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);return c};function At(t){var e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(t){return decodeURIComponent(_t(t).replace(/(.)/g,(function(t,e){var r=e.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r})))}(e)}catch(t){return _t(e)}}function jt(t){this.message=t}jt.prototype=new Error,jt.prototype.name="InvalidTokenError";var Nt={decode:function(t,e){if("string"!=typeof t)throw new jt("Invalid token specified");var r=!0===(e=e||{}).header?0:1;try{return JSON.parse(At(t.split(".")[r]))}catch(t){throw new jt("Invalid token specified: "+t.message)}}};return e})());