@cloudbase/utilities
Version:
cloudbase javascript sdk utilities
1 lines • 25.6 kB
JavaScript
!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:()=>_t,adapters:()=>o,cache:()=>a,constants:()=>r,events:()=>i,helpers:()=>s,jwt:()=>Rt,langEvent:()=>c,utils:()=>n});var r={};t.r(r),t.d(r,{COMMUNITY_SITE_URL:()=>b,ERRORS:()=>m,IS_DEBUG_MODE:()=>v,OATUH_LOGINTYPE:()=>g,getProtocol:()=>h,getSdkName:()=>f,setProtocol:()=>d,setSdkName:()=>l});var n={};t.r(n),t.d(n,{createPromiseCallback:()=>M,execCallback:()=>D,formatUrl:()=>R,genSeqId:()=>N,generateRequestId:()=>P,getHash:()=>T,getQuery:()=>C,isArray:()=>E,isFormData:()=>A,isInstanceOf:()=>j,isNull:()=>_,isPalinObject:()=>I,isString:()=>x,isUndefined:()=>S,parseCaptcha:()=>H,parseQueryString:()=>G,printError:()=>q,printGroupLog:()=>$,printInfo:()=>V,printWarn:()=>U,removeParam:()=>L,sleep:()=>F,throwError:()=>J,toQueryString:()=>k,transformPhone:()=>W});var o={};t.r(o),t.d(o,{RUNTIME:()=>Z,useAdapters:()=>et,useDefaultAdapter:()=>rt});var a={};t.r(a),t.d(a,{CloudbaseCache:()=>ct});var i={};t.r(i),t.d(i,{CloudbaseEvent:()=>lt,CloudbaseEventEmitter:()=>pt,IErrorEvent:()=>ft,activateEvent:()=>yt,addEventListener:()=>ht,removeEventListener:()=>vt});var c={};t.r(c),t.d(c,{LANG_CHANGE_EVENT:()=>mt,bus:()=>bt});var s={};t.r(s),t.d(s,{catchErrorsDecorator:()=>St});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",m={INVALID_PARAMS:"INVALID_PARAMS",INVALID_SYNTAX:"INVALID_SYNTAX",INVALID_OPERATION:"INVALID_OPERATION",OPERATION_FAIL:"OPERATION_FAIL",NETWORK_ERROR:"NETWORK_ERROR",UNKOWN_ERROR:"UNKOWN_ERROR"},g="constants";!function(t){t.local="local",t.none="none",t.session="session"}(y||(y={}));var w=function(){},O=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]])}return r};function E(t){return"[object Array]"===Object.prototype.toString.call(t)}function x(t){return"string"==typeof t}function S(t){return void 0===t}function I(t){return"[object Object]"===Object.prototype.toString.call(t)}function _(t){return"[object Null]"===Object.prototype.toString.call(t)}function j(t,e){return t instanceof e}function A(t){return"[object FormData]"===Object.prototype.toString.call(t)}function N(){return Math.random().toString(16).slice(2)}function P(){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 R(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 k(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 C(t,e){if("undefined"==typeof window)return!1;var r=e||decodeURIComponent(window.location.search),n=new RegExp("(^|&)".concat(t,"=([^&]*)(&|$)")),o=r.substr(r.indexOf("?")+1).match(n);return null!=o?o[2]:""}var T=function(t){if("undefined"==typeof window)return"";var e=window.location.hash.match(new RegExp("[#?&/]".concat(t,"=([^&#]*)")));return e?e[1]:""};function L(t,e){var r=e.split("?")[0],n=[],o=-1!==e.indexOf("?")?e.split("?")[1]:"";if(""!==o){for(var a=(n=o.split("&")).length-1;a>=0;a-=1)n[a].split("=")[0]===t&&n.splice(a,1);r="".concat(r,"?").concat(n.join("&"))}return r}function M(){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 D(t,e,r){if(void 0===r&&(r=null),t&&"function"==typeof t)return t(e,r);if(e)throw e;return r}function U(t,e){console.warn("[".concat(f(),"][").concat(t,"]:").concat(e))}function q(t,e){console.error({code:t,msg:"[".concat(f(),"][").concat(t,"]:").concat(e)})}function V(t,e){console.log("[".concat(f(),"][").concat(t,"]:").concat(e))}function J(t,e){throw new Error(JSON.stringify({code:t,msg:"[".concat(f(),"][").concat(t,"]:").concat(e)}))}function $(t){var e,r=t.title,n=t.subtitle,o=void 0===n?"":n,a=t.content,i=void 0===a?[]:a,c=t.printTrace,s=void 0!==c&&c,u=t.collapsed;void 0!==u&&u?(console.groupCollapsed||console.error)(r,o):(console.group||console.error)(r,o);for(var l=0,f=i;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};function H(t){var e={},r=t.match(/^(data:.*?)(\?[^#\s]*)?$/);if(r){t=r[1];var n=r[2];n&&(e=G(n))}var o=e.token,a=O(e,["token"]);return/^data:/.test(t)&&!o?{error:"invalid_argument",error_description:"invalid captcha data: ".concat(t)}:o?{state:a.state,token:o,captchaData:t}:{error:"unimplemented",error_description:"need to impl captcha data"}}var Y,B=(Y=function(t,e){return(Y=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}Y(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),K=function(){return(K=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)},X=function(t,e,r,n){return new(r||(r=Promise))((function(o,a){function i(t){try{s(n.next(t))}catch(t){a(t)}}function c(t){try{s(n.throw(t))}catch(t){a(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(i,c)}s((n=n.apply(t,e||[])).next())}))},Q=function(t,e){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(c){return function(s){return function(c){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(i=0)),i;)try{if(r=1,n&&(o=2&c[0]?n.return:c[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,c[1])).done)return o;switch(n=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,n=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=e.call(t,i)}catch(t){c=[6,t],n=0}finally{r=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,s])}}},z=function(t){function e(e){var r=t.call(this)||this,n=e.timeout,o=e.timeoutMsg,a=e.restrictedMethods;return r.timeout=n||0,r.timeoutMsg=o||"请求超时",r.restrictedMethods=a||["get","post","upload","download"],r}return B(e,t),e.prototype.get=function(t){return this.request(K(K({},t),{method:"get"}),this.restrictedMethods.includes("get"))},e.prototype.post=function(t){return this.request(K(K({},t),{method:"post"}),this.restrictedMethods.includes("post"))},e.prototype.put=function(t){return this.request(K(K({},t),{method:"put"}))},e.prototype.upload=function(t){var e=t.data,r=t.file,n=t.name,o=t.method,a=t.headers,i=void 0===a?{}:a,c={post:"post",put:"put"}[null==o?void 0:o.toLowerCase()]||"put",s=new FormData;return"post"===c?(Object.keys(e).forEach((function(t){s.append(t,e[t])})),s.append("key",n),s.append("file",r),this.request(K(K({},t),{data:s,method:c}),this.restrictedMethods.includes("upload"))):this.request(K(K({},t),{method:"put",headers:i,body:r}),this.restrictedMethods.includes("upload"))},e.prototype.download=function(t){return X(this,void 0,void 0,(function(){var e,r,n,o;return Q(this,(function(a){switch(a.label){case 0:return a.trys.push([0,2,,3]),[4,this.get(K(K({},t),{headers:{},responseType:"blob"}))];case 1:return e=a.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 a.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 X(this,void 0,void 0,(function(){var r,n,o,a,i,c,s,u,l,f,p,d,h,y=this;return Q(this,(function(v){switch(v.label){case 0:return r=new AbortController,n=t.url,o=t.enableAbort,a=void 0!==o&&o,i=t.stream,c=void 0!==i&&i,s=t.signal,u=t.timeout,l=t.shouldThrowOnError,f=void 0===l||l,p=null!=u?u:this.timeout,s&&(s.aborted&&r.abort(),s.addEventListener("abort",(function(){return r.abort()}))),d=null,a&&p&&(d=setTimeout((function(){console.warn(y.timeoutMsg),r.abort(new Error(y.timeoutMsg))}),p)),[4,fetch(n,K(K({},t),{signal:r.signal})).then((function(t){return X(y,void 0,void 0,(function(){var e,r,n;return Q(this,(function(o){switch(o.label){case 0:return clearTimeout(d),f?t.ok?(e=t,[3,3]):[3,1]:[3,4];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];case 4:return[2,t]}}))}))})).catch((function(t){if(clearTimeout(d),f)return Promise.reject(t)}))];case 1:return h=v.sent(),[2,{data:c?h.body:(null===(e=h.headers.get("content-type"))||void 0===e?void 0:e.includes("application/json"))?h.json():h.text(),statusCode:h.status,header:h.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 a,i,c=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=R(h(),c,"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(a),o(t)}},e&&r.timeout&&(a=setTimeout((function(){console.warn(r.timeoutMsg),b.abort()}),r.timeout)),i=A(l)?l:"application/x-www-form-urlencoded"===u["content-type"]?k(l):d||(l?JSON.stringify(l):void 0),p&&(b.withCredentials=!0),b.send(i)}))},e}((function(){}));var Z,tt=function(){return(tt=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 et(t,e){for(var r=0,n=E(t)?t:[t];r<n.length;r++){var o=n[r],a=o.isMatch,i=o.genAdapter,c=o.runtime;if(a())return{adapter:tt({isMatch:a},i(e)),runtime:c}}}function rt(){return{adapter:tt({},{type:"default",root:window,reqClass:z,wsClass:WebSocket,localStorage:localStorage}),runtime:Z.WEB}}!function(t){t.WEB="web",t.WX_MP="wx_mp"}(Z||(Z={}));var nt=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)}}(),ot=function(t,e,r,n){return new(r||(r=Promise))((function(o,a){function i(t){try{s(n.next(t))}catch(t){a(t)}}function c(t){try{s(n.throw(t))}catch(t){a(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(i,c)}s((n=n.apply(t,e||[])).next())}))},at=function(t,e){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(c){return function(s){return function(c){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(i=0)),i;)try{if(r=1,n&&(o=2&c[0]?n.return:c[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,c[1])).done)return o;switch(n=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,n=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=e.call(t,i)}catch(t){c=[6,t],n=0}finally{r=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,s])}}},it=function(t){function e(e){var r=t.call(this)||this;return r.root=e,e.tcbCacheObject||(e.tcbCacheObject={}),r}return nt(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 ct=function(){function t(t){this.keys={};var e=t.persistence,r=t.platformInfo,n=void 0===r?{}:r,o=t.keys,a=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:(U(m.INVALID_PARAMS,"localStorage is not supported on current platform"),new it(e.root));case"none":return new it(e.root);default:return e.localStorage?e.localStorage:(U(m.INVALID_PARAMS,"localStorage is not supported on current platform"),new it(e.root))}}(this.persistenceTag,this.platformInfo.adapter),this.keys=a)}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:m.OPERATION_FAIL,msg:"[".concat(f(),"][").concat(m.OPERATION_FAIL,"]setStore failed"),info:t}))}}else U(m.INVALID_OPERATION,"current platform's storage is asynchronous, please use setStoreAsync insteed")},t.prototype.setStoreAsync=function(t,e,r){return ot(this,void 0,void 0,(function(){var n;return at(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:""}U(m.INVALID_OPERATION,"current platform's storage is asynchronous, please use getStoreAsync insteed")},t.prototype.getStoreAsync=function(t,e){var r;return ot(this,void 0,void 0,(function(){var n;return at(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):U(m.INVALID_OPERATION,"current platform's storage is asynchronous, please use removeStoreAsync insteed")},t.prototype.removeStoreAsync=function(t){return ot(this,void 0,void 0,(function(){return at(this,(function(e){switch(e.label){case 0:return[4,this.storage.removeItem(t)];case 1:return e.sent(),[2]}}))}))},t}(),st=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)}}(),ut=function(t,e,r){if(r||2===arguments.length)for(var n,o=0,a=e.length;o<a;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 lt=function(t,e){this.data=e||null,this.name=t},ft=function(t){function e(e,r){var n=t.call(this,"error",{error:e,data:r})||this;return n.error=e,n}return st(e,t),e}(lt),pt=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(j(t,ft))return console.error(t.error),this;var r=x(t)?new lt(t,e||{}):t,n=r.name;if(this.listens(n)){r.target=this;for(var o=0,a=this.listeners[n]?ut([],this.listeners[n],!0):[];o<a.length;o++){a[o].call(this,r)}}return this},t.prototype.listens=function(t){return this.listeners[t]&&this.listeners[t].length>0},t}(),dt=new pt;function ht(t,e){dt.on(t,e)}function yt(t,e){void 0===e&&(e={}),dt.fire(t,e)}function vt(t,e){dt.off(t,e)}var bt=new pt,mt="lang_change",gt=function(t,e,r,n){return new(r||(r=Promise))((function(o,a){function i(t){try{s(n.next(t))}catch(t){a(t)}}function c(t){try{s(n.throw(t))}catch(t){a(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(i,c)}s((n=n.apply(t,e||[])).next())}))},wt=function(t,e){var r,n,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(c){return function(s){return function(c){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(i=0)),i;)try{if(r=1,n&&(o=2&c[0]?n.return:c[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,c[1])).done)return o;switch(n=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,n=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=e.call(t,i)}catch(t){c=[6,t],n=0}finally{r=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,s])}}},Ot=!1;"undefined"!=typeof navigator&&navigator.userAgent&&(Ot=-1!==navigator.userAgent.indexOf("Firefox"));var Et=Ot?/(\.js\/)?__decorate(\$\d+)?<@.*\d$/:/(\/\w+\.js\.)?__decorate(\$\d+)?\s*\(.*\)$/,xt=/https?:\/\/.+:\d*\/.*\.js:\d+:\d+/;function St(t){var e=t.mode,r=void 0===e?"async":e,n=t.customInfo,o=void 0===n?{}:n,a=t.title,i=t.messages,c=void 0===i?[]:i;return function(t,e,n){if(v){var i=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 Et.test(t)}));if(-1!==n){var o=xt.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=It({err:new Error,className:i,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:a||"".concat(i,".").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=c.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=c.map((function(t){return{type:"info",body:t}}))),$(d),n}}:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return gt(this,void 0,void 0,(function(){var e,r,n,o,f,p,d,h;return wt(this,(function(y){switch(y.label){case 0:e=It({err:new Error,className:i,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:a||"".concat(i,".").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=c.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=c.map((function(t){return{type:"info",body:t}}))),$(d),n;case 4:return[2]}}))}))}}}}function It(t){var e=t.err,r=t.className,n=t.methodName,o=t.sourceLink;if(!o)return null;var a,i=e.stack.split("\n"),c=Ot?/^catchErrorsDecorator\/<\/descriptor.value@.*\d$/:new RegExp("".concat(r,"\\.descriptor.value\\s*\\[as\\s").concat(n,"\\]\\s*\\(.*\\)$")),s=Ot?/^catchErrorsDecorator\/<\/descriptor.value/:new RegExp("".concat(r,"\\.descriptor.value\\s*\\[as\\s").concat(n,"\\]")),u=i.findIndex((function(t){return c.test(t)}));if(-1!==u){var l=i.filter((function(t,e){return e>u}));l.unshift(i[u].replace(s,"".concat(r,".").concat(n)).replace(xt,o)),(a=new Error).stack="".concat(Ot?"@debugger":"Error","\n").concat(l.join("\n"))}return a}const _t=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 jt(t){this.message=t}jt.prototype=new Error,jt.prototype.name="InvalidCharacterError";var At="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new jt("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,n,o=0,a=0,i="";n=e.charAt(a++);~n&&(r=o%4?64*r+n:n,o++%4)?i+=String.fromCharCode(255&r>>(-2*o&6)):0)n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);return i};function Nt(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(At(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 At(e)}}function Pt(t){this.message=t}Pt.prototype=new Error,Pt.prototype.name="InvalidTokenError";var Rt={decode:function(t,e){if("string"!=typeof t)throw new Pt("Invalid token specified");var r=!0===(e=e||{}).header?0:1;try{return JSON.parse(Nt(t.split(".")[r]))}catch(t){throw new Pt("Invalid token specified: "+t.message)}}};return e})());