UNPKG

@arcana/auth

Version:

Arcana Auth

9 lines 240 kB
function t(t,e){return e.forEach((function(e){e&&"string"!=typeof e&&!Array.isArray(e)&&Object.keys(e).forEach((function(r){if("default"!==r&&!(r in t)){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}}))})),Object.freeze(t)}function e(t,e,r,n){return new(r||(r=Promise))((function(i,o){function s(t){try{u(n.next(t))}catch(t){o(t)}}function a(t){try{u(n.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;var r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function n(t){return t&&Object.prototype.hasOwnProperty.call(t,"default")&&1===Object.keys(t).length?t.default:t}var i={},o={},s=l;l.default=l,l.stable=g,l.stableStringify=g;var a="[...]",u="[Circular]",c=[],h=[];function f(){return{depthLimit:Number.MAX_SAFE_INTEGER,edgesLimit:Number.MAX_SAFE_INTEGER}}function l(t,e,r,n){var i;void 0===n&&(n=f()),p(t,"",0,[],void 0,0,n);try{i=0===h.length?JSON.stringify(t,e,r):JSON.stringify(t,w(e),r)}catch(t){return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;0!==c.length;){var o=c.pop();4===o.length?Object.defineProperty(o[0],o[1],o[3]):o[0][o[1]]=o[2]}}return i}function d(t,e,r,n){var i=Object.getOwnPropertyDescriptor(n,r);void 0!==i.get?i.configurable?(Object.defineProperty(n,r,{value:t}),c.push([n,r,e,i])):h.push([e,r,t]):(n[r]=t,c.push([n,r,e]))}function p(t,e,r,n,i,o,s){var c;if(o+=1,"object"==typeof t&&null!==t){for(c=0;c<n.length;c++)if(n[c]===t)return void d(u,t,e,i);if(void 0!==s.depthLimit&&o>s.depthLimit)return void d(a,t,e,i);if(void 0!==s.edgesLimit&&r+1>s.edgesLimit)return void d(a,t,e,i);if(n.push(t),Array.isArray(t))for(c=0;c<t.length;c++)p(t[c],c,c,n,t,o,s);else{var h=Object.keys(t);for(c=0;c<h.length;c++){var f=h[c];p(t[f],f,c,n,t,o,s)}}n.pop()}}function m(t,e){return t<e?-1:t>e?1:0}function g(t,e,r,n){void 0===n&&(n=f());var i,o=y(t,"",0,[],void 0,0,n)||t;try{i=0===h.length?JSON.stringify(o,e,r):JSON.stringify(o,w(e),r)}catch(t){return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;0!==c.length;){var s=c.pop();4===s.length?Object.defineProperty(s[0],s[1],s[3]):s[0][s[1]]=s[2]}}return i}function y(t,e,r,n,i,o,s){var h;if(o+=1,"object"==typeof t&&null!==t){for(h=0;h<n.length;h++)if(n[h]===t)return void d(u,t,e,i);try{if("function"==typeof t.toJSON)return}catch(t){return}if(void 0!==s.depthLimit&&o>s.depthLimit)return void d(a,t,e,i);if(void 0!==s.edgesLimit&&r+1>s.edgesLimit)return void d(a,t,e,i);if(n.push(t),Array.isArray(t))for(h=0;h<t.length;h++)y(t[h],h,h,n,t,o,s);else{var f={},l=Object.keys(t).sort(m);for(h=0;h<l.length;h++){var p=l[h];y(t[p],p,h,n,t,o,s),f[p]=t[p]}if(void 0===i)return f;c.push([i,e,t]),i[e]=f}n.pop()}}function w(t){return t=void 0!==t?t:function(t,e){return e},function(e,r){if(h.length>0)for(var n=0;n<h.length;n++){var i=h[n];if(i[1]===e&&i[0]===r){r=i[2],h.splice(n,1);break}}return t.call(this,e,r)}}Object.defineProperty(o,"__esModule",{value:!0}),o.EthereumProviderError=o.EthereumRpcError=void 0;const v=s;class b extends Error{constructor(t,e,r){if(!Number.isInteger(t))throw new Error('"code" must be an integer.');if(!e||"string"!=typeof e)throw new Error('"message" must be a nonempty string.');super(e),this.code=t,void 0!==r&&(this.data=r)}serialize(){const t={code:this.code,message:this.message};return void 0!==this.data&&(t.data=this.data),this.stack&&(t.stack=this.stack),t}toString(){return v.default(this.serialize(),_,2)}}o.EthereumRpcError=b;function _(t,e){if("[Circular]"!==e)return e}o.EthereumProviderError=class extends b{constructor(t,e,r){if(!function(t){return Number.isInteger(t)&&t>=1e3&&t<=4999}(t))throw new Error('"code" must be an integer such that: 1000 <= code <= 4999');super(t,e,r)}};var E={},x={};Object.defineProperty(x,"__esModule",{value:!0}),x.errorValues=x.errorCodes=void 0,x.errorCodes={rpc:{invalidInput:-32e3,resourceNotFound:-32001,resourceUnavailable:-32002,transactionRejected:-32003,methodNotSupported:-32004,limitExceeded:-32005,parse:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internal:-32603},provider:{userRejectedRequest:4001,unauthorized:4100,unsupportedMethod:4200,disconnected:4900,chainDisconnected:4901}},x.errorValues={"-32700":{standard:"JSON RPC 2.0",message:"Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."},"-32600":{standard:"JSON RPC 2.0",message:"The JSON sent is not a valid Request object."},"-32601":{standard:"JSON RPC 2.0",message:"The method does not exist / is not available."},"-32602":{standard:"JSON RPC 2.0",message:"Invalid method parameter(s)."},"-32603":{standard:"JSON RPC 2.0",message:"Internal JSON-RPC error."},"-32000":{standard:"EIP-1474",message:"Invalid input."},"-32001":{standard:"EIP-1474",message:"Resource not found."},"-32002":{standard:"EIP-1474",message:"Resource unavailable."},"-32003":{standard:"EIP-1474",message:"Transaction rejected."},"-32004":{standard:"EIP-1474",message:"Method not supported."},"-32005":{standard:"EIP-1474",message:"Request limit exceeded."},4001:{standard:"EIP-1193",message:"User rejected the request."},4100:{standard:"EIP-1193",message:"The requested account and/or method has not been authorized by the user."},4200:{standard:"EIP-1193",message:"The requested method is not supported by this Ethereum provider."},4900:{standard:"EIP-1193",message:"The provider is disconnected from all chains."},4901:{standard:"EIP-1193",message:"The provider is disconnected from the specified chain."}},function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.serializeError=t.isValidCode=t.getMessageFromCode=t.JSON_RPC_SERVER_ERROR_MESSAGE=void 0;const e=x,r=o,n=e.errorCodes.rpc.internal,i="Unspecified error message. This is a bug, please report it.",s={code:n,message:a(n)};function a(r,n=i){if(Number.isInteger(r)){const n=r.toString();if(f(e.errorValues,n))return e.errorValues[n].message;if(c(r))return t.JSON_RPC_SERVER_ERROR_MESSAGE}return n}function u(t){if(!Number.isInteger(t))return!1;const r=t.toString();return!!e.errorValues[r]||!!c(t)}function c(t){return t>=-32099&&t<=-32e3}function h(t){return t&&"object"==typeof t&&!Array.isArray(t)?Object.assign({},t):t}function f(t,e){return Object.prototype.hasOwnProperty.call(t,e)}t.JSON_RPC_SERVER_ERROR_MESSAGE="Unspecified server error.",t.getMessageFromCode=a,t.isValidCode=u,t.serializeError=function(t,{fallbackError:e=s,shouldIncludeStack:n=!1}={}){var i,o;if(!e||!Number.isInteger(e.code)||"string"!=typeof e.message)throw new Error("Must provide fallback error with integer number code and string message.");if(t instanceof r.EthereumRpcError)return t.serialize();const c={};if(t&&"object"==typeof t&&!Array.isArray(t)&&f(t,"code")&&u(t.code)){const e=t;c.code=e.code,e.message&&"string"==typeof e.message?(c.message=e.message,f(e,"data")&&(c.data=e.data)):(c.message=a(c.code),c.data={originalError:h(t)})}else{c.code=e.code;const r=null===(i=t)||void 0===i?void 0:i.message;c.message=r&&"string"==typeof r?r:e.message,c.data={originalError:h(t)}}const l=null===(o=t)||void 0===o?void 0:o.stack;return n&&t&&l&&"string"==typeof l&&(c.stack=l),c}}(E);var M={};Object.defineProperty(M,"__esModule",{value:!0}),M.ethErrors=void 0;const A=o,B=E,S=x;function I(t,e){const[r,n]=O(e);return new A.EthereumRpcError(t,r||B.getMessageFromCode(t),n)}function k(t,e){const[r,n]=O(e);return new A.EthereumProviderError(t,r||B.getMessageFromCode(t),n)}function O(t){if(t){if("string"==typeof t)return[t];if("object"==typeof t&&!Array.isArray(t)){const{message:e,data:r}=t;if(e&&"string"!=typeof e)throw new Error("Must specify string message.");return[e||void 0,r]}}return[]}M.ethErrors={rpc:{parse:t=>I(S.errorCodes.rpc.parse,t),invalidRequest:t=>I(S.errorCodes.rpc.invalidRequest,t),invalidParams:t=>I(S.errorCodes.rpc.invalidParams,t),methodNotFound:t=>I(S.errorCodes.rpc.methodNotFound,t),internal:t=>I(S.errorCodes.rpc.internal,t),server:t=>{if(!t||"object"!=typeof t||Array.isArray(t))throw new Error("Ethereum RPC Server errors must provide single object argument.");const{code:e}=t;if(!Number.isInteger(e)||e>-32005||e<-32099)throw new Error('"code" must be an integer such that: -32099 <= code <= -32005');return I(e,t)},invalidInput:t=>I(S.errorCodes.rpc.invalidInput,t),resourceNotFound:t=>I(S.errorCodes.rpc.resourceNotFound,t),resourceUnavailable:t=>I(S.errorCodes.rpc.resourceUnavailable,t),transactionRejected:t=>I(S.errorCodes.rpc.transactionRejected,t),methodNotSupported:t=>I(S.errorCodes.rpc.methodNotSupported,t),limitExceeded:t=>I(S.errorCodes.rpc.limitExceeded,t)},provider:{userRejectedRequest:t=>k(S.errorCodes.provider.userRejectedRequest,t),unauthorized:t=>k(S.errorCodes.provider.unauthorized,t),unsupportedMethod:t=>k(S.errorCodes.provider.unsupportedMethod,t),disconnected:t=>k(S.errorCodes.provider.disconnected,t),chainDisconnected:t=>k(S.errorCodes.provider.chainDisconnected,t),custom:t=>{if(!t||"object"!=typeof t||Array.isArray(t))throw new Error("Ethereum Provider custom errors must provide single object argument.");const{code:e,message:r,data:n}=t;if(!r||"string"!=typeof r)throw new Error('"message" must be a nonempty string');return new A.EthereumProviderError(e,r,n)}}},function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.getMessageFromCode=t.serializeError=t.EthereumProviderError=t.EthereumRpcError=t.ethErrors=t.errorCodes=void 0;const e=o;Object.defineProperty(t,"EthereumRpcError",{enumerable:!0,get:function(){return e.EthereumRpcError}}),Object.defineProperty(t,"EthereumProviderError",{enumerable:!0,get:function(){return e.EthereumProviderError}});const r=E;Object.defineProperty(t,"serializeError",{enumerable:!0,get:function(){return r.serializeError}}),Object.defineProperty(t,"getMessageFromCode",{enumerable:!0,get:function(){return r.getMessageFromCode}});const n=M;Object.defineProperty(t,"ethErrors",{enumerable:!0,get:function(){return n.ethErrors}});const i=x;Object.defineProperty(t,"errorCodes",{enumerable:!0,get:function(){return i.errorCodes}})}(i);var U,R={},T={exports:{}},L="object"==typeof Reflect?Reflect:null,C=L&&"function"==typeof L.apply?L.apply:function(t,e,r){return Function.prototype.apply.call(t,e,r)};U=L&&"function"==typeof L.ownKeys?L.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var N=Number.isNaN||function(t){return t!=t};function $(){$.init.call(this)}T.exports=$,T.exports.once=function(t,e){return new Promise((function(r,n){function i(r){t.removeListener(e,o),n(r)}function o(){"function"==typeof t.removeListener&&t.removeListener("error",i),r([].slice.call(arguments))}G(t,e,o,{once:!0}),"error"!==e&&function(t,e,r){"function"==typeof t.on&&G(t,"error",e,r)}(t,i,{once:!0})}))},$.EventEmitter=$,$.prototype._events=void 0,$.prototype._eventsCount=0,$.prototype._maxListeners=void 0;var P=10;function F(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function z(t){return void 0===t._maxListeners?$.defaultMaxListeners:t._maxListeners}function j(t,e,r,n){var i,o,s,a;if(F(r),void 0===(o=t._events)?(o=t._events=Object.create(null),t._eventsCount=0):(void 0!==o.newListener&&(t.emit("newListener",e,r.listener?r.listener:r),o=t._events),s=o[e]),void 0===s)s=o[e]=r,++t._eventsCount;else if("function"==typeof s?s=o[e]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),(i=z(t))>0&&s.length>i&&!s.warned){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=t,u.type=e,u.count=s.length,a=u,console&&console.warn&&console.warn(a)}return t}function D(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function q(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=D.bind(n);return i.listener=r,n.wrapFn=i,i}function H(t,e,r){var n=t._events;if(void 0===n)return[];var i=n[e];return void 0===i?[]:"function"==typeof i?r?[i.listener||i]:[i]:r?function(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}(i):Z(i,i.length)}function V(t){var e=this._events;if(void 0!==e){var r=e[t];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function Z(t,e){for(var r=new Array(e),n=0;n<e;++n)r[n]=t[n];return r}function G(t,e,r,n){if("function"==typeof t.on)n.once?t.once(e,r):t.on(e,r);else{if("function"!=typeof t.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t);t.addEventListener(e,(function i(o){n.once&&t.removeEventListener(e,i),r(o)}))}}Object.defineProperty($,"defaultMaxListeners",{enumerable:!0,get:function(){return P},set:function(t){if("number"!=typeof t||t<0||N(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");P=t}}),$.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},$.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||N(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this},$.prototype.getMaxListeners=function(){return z(this)},$.prototype.emit=function(t){for(var e=[],r=1;r<arguments.length;r++)e.push(arguments[r]);var n="error"===t,i=this._events;if(void 0!==i)n=n&&void 0===i.error;else if(!n)return!1;if(n){var o;if(e.length>0&&(o=e[0]),o instanceof Error)throw o;var s=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw s.context=o,s}var a=i[t];if(void 0===a)return!1;if("function"==typeof a)C(a,this,e);else{var u=a.length,c=Z(a,u);for(r=0;r<u;++r)C(c[r],this,e)}return!0},$.prototype.addListener=function(t,e){return j(this,t,e,!1)},$.prototype.on=$.prototype.addListener,$.prototype.prependListener=function(t,e){return j(this,t,e,!0)},$.prototype.once=function(t,e){return F(e),this.on(t,q(this,t,e)),this},$.prototype.prependOnceListener=function(t,e){return F(e),this.prependListener(t,q(this,t,e)),this},$.prototype.removeListener=function(t,e){var r,n,i,o,s;if(F(e),void 0===(n=this._events))return this;if(void 0===(r=n[t]))return this;if(r===e||r.listener===e)0==--this._eventsCount?this._events=Object.create(null):(delete n[t],n.removeListener&&this.emit("removeListener",t,r.listener||e));else if("function"!=typeof r){for(i=-1,o=r.length-1;o>=0;o--)if(r[o]===e||r[o].listener===e){s=r[o].listener,i=o;break}if(i<0)return this;0===i?r.shift():function(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}(r,i),1===r.length&&(n[t]=r[0]),void 0!==n.removeListener&&this.emit("removeListener",t,s||e)}return this},$.prototype.off=$.prototype.removeListener,$.prototype.removeAllListeners=function(t){var e,r,n;if(void 0===(r=this._events))return this;if(void 0===r.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[t]&&(0==--this._eventsCount?this._events=Object.create(null):delete r[t]),this;if(0===arguments.length){var i,o=Object.keys(r);for(n=0;n<o.length;++n)"removeListener"!==(i=o[n])&&this.removeAllListeners(i);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(e=r[t]))this.removeListener(t,e);else if(void 0!==e)for(n=e.length-1;n>=0;n--)this.removeListener(t,e[n]);return this},$.prototype.listeners=function(t){return H(this,t,!0)},$.prototype.rawListeners=function(t){return H(this,t,!1)},$.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):V.call(t,e)},$.prototype.listenerCount=V,$.prototype.eventNames=function(){return this._eventsCount>0?U(this._events):[]},Object.defineProperty(R,"__esModule",{value:!0});const W=T.exports;function J(t,e,r){try{Reflect.apply(t,e,r)}catch(t){setTimeout((()=>{throw t}))}}class K extends W.EventEmitter{emit(t,...e){let r="error"===t;const n=this._events;if(void 0!==n)r=r&&void 0===n.error;else if(!r)return!1;if(r){let t;if(e.length>0&&([t]=e),t instanceof Error)throw t;const r=new Error("Unhandled error."+(t?` (${t.message})`:""));throw r.context=t,r}const i=n[t];if(void 0===i)return!1;if("function"==typeof i)J(i,this,e);else{const t=i.length,r=function(t){const e=t.length,r=new Array(e);for(let n=0;n<e;n+=1)r[n]=t[n];return r}(i);for(let n=0;n<t;n+=1)J(r[n],this,e)}return!0}}var Y,X,Q,tt,et,rt=R.default=K;!function(t){t.Call="call",t.Reply="reply",t.Syn="syn",t.SynAck="synAck",t.Ack="ack"}(Y||(Y={})),function(t){t.Fulfilled="fulfilled",t.Rejected="rejected"}(X||(X={})),function(t){t.ConnectionDestroyed="ConnectionDestroyed",t.ConnectionTimeout="ConnectionTimeout",t.NoIframeSrc="NoIframeSrc"}(Q||(Q={})),function(t){t.DataCloneError="DataCloneError"}(tt||(tt={})),function(t){t.Message="message"}(et||(et={}));const nt={"http:":"80","https:":"443"},it=/^(https?:)?\/\/([^/:]+)?(:(\d+))?/,ot=["file:","data:"];const st=({name:t,message:e,stack:r})=>({name:t,message:e,stack:r});let at=0;var ut=()=>++at;const ct=t=>t?t.split("."):[],ht=(t,e,r)=>{const n=ct(e);return n.reduce(((t,e,i)=>(void 0===t[e]&&(t[e]={}),i===n.length-1&&(t[e]=r),t[e])),t),t},ft=(t,e)=>{const r={};return Object.keys(t).forEach((n=>{const i=t[n],o=((t,e)=>{const r=ct(e||"");return r.push(t),(t=>t.join("."))(r)})(n,e);"object"==typeof i&&Object.assign(r,ft(i,o)),"function"==typeof i&&(r[o]=i)})),r};var lt=(t,e,r,n,i)=>{const{localName:o,local:s,remote:a,originForSending:u,originForReceiving:c}=e;let h=!1;i(`${o}: Connecting call sender`);const f=t=>(...e)=>{let r;i(`${o}: Sending ${t}() call`);try{a.closed&&(r=!0)}catch(t){r=!0}if(r&&n(),h){const e=new Error(`Unable to send ${t}() call due to destroyed connection`);throw e.code=Q.ConnectionDestroyed,e}return new Promise(((r,n)=>{const h=ut(),f=e=>{if(e.source!==a||e.data.penpal!==Y.Reply||e.data.id!==h)return;if("*"!==c&&e.origin!==c)return void i(`${o} received message from origin ${e.origin} which did not match expected origin ${c}`);const u=e.data;i(`${o}: Received ${t}() reply`),s.removeEventListener(et.Message,f);let l=u.returnValue;u.returnValueIsError&&(l=(t=>{const e=new Error;return Object.keys(t).forEach((r=>e[r]=t[r])),e})(l)),(u.resolution===X.Fulfilled?r:n)(l)};s.addEventListener(et.Message,f);const l={penpal:Y.Call,id:h,methodName:t,args:e};a.postMessage(l,u)}))},l=r.reduce(((t,e)=>(t[e]=f(e),t)),{});return Object.assign(t,(t=>{const e={};for(const r in t)ht(e,r,t[r]);return e})(l)),()=>{h=!0}},dt=(t,e,r,n,i)=>{const{destroy:o,onDestroy:s}=n;let a,u;const c={};return n=>{if("*"!==e&&n.origin!==e)return void i(`Parent: Handshake - Received ACK message from origin ${n.origin} which did not match expected origin ${e}`);i("Parent: Handshake - Received ACK");const h={localName:"Parent",local:window,remote:n.source,originForSending:r,originForReceiving:e};a&&a(),a=((t,e,r)=>{const{localName:n,local:i,remote:o,originForSending:s,originForReceiving:a}=t;let u=!1;const c=t=>{if(t.source!==o||t.data.penpal!==Y.Call)return;if("*"!==a&&t.origin!==a)return void r(`${n} received message from origin ${t.origin} which did not match expected origin ${a}`);const i=t.data,{methodName:c,args:h,id:f}=i;r(`${n}: Received ${c}() call`);const l=t=>e=>{if(r(`${n}: Sending ${c}() reply`),u)return void r(`${n}: Unable to send ${c}() reply due to destroyed connection`);const i={penpal:Y.Reply,id:f,resolution:t,returnValue:e};t===X.Rejected&&e instanceof Error&&(i.returnValue=st(e),i.returnValueIsError=!0);try{o.postMessage(i,s)}catch(t){if(t.name===tt.DataCloneError){const e={penpal:Y.Reply,id:f,resolution:X.Rejected,returnValue:st(t),returnValueIsError:!0};o.postMessage(e,s)}throw t}};new Promise((t=>t(e[c].apply(e,h)))).then(l(X.Fulfilled),l(X.Rejected))};return i.addEventListener(et.Message,c),()=>{u=!0,i.removeEventListener(et.Message,c)}})(h,t,i),s(a),u&&u.forEach((t=>{delete c[t]})),u=n.data.methodNames;const f=lt(c,h,u,o,i);return s(f),c}};var pt,mt,gt,yt,wt,vt,bt,_t,Et,xt,Mt=t=>{let{iframe:e,methods:r={},childOrigin:n,timeout:i,debug:o=!1}=t;const s=(t=>(...e)=>{t&&console.log("[Penpal]",...e)})(o),a=((t,e)=>{const r=[];let n=!1;return{destroy(i){n||(n=!0,e(`${t}: Destroying connection`),r.forEach((t=>{t(i)})))},onDestroy(t){n?t():r.push(t)}}})("Parent",s),{onDestroy:u,destroy:c}=a;n||((t=>{if(!t.src&&!t.srcdoc){const t=new Error("Iframe must have src or srcdoc property defined.");throw t.code=Q.NoIframeSrc,t}})(e),n=(t=>{if(t&&ot.find((e=>t.startsWith(e))))return"null";const e=document.location,r=it.exec(t);let n,i,o;return r?(n=r[1]?r[1]:e.protocol,i=r[2],o=r[4]):(n=e.protocol,i=e.hostname,o=e.port),`${n}//${i}${o&&o!==nt[n]?`:${o}`:""}`})(e.src));const h="null"===n?"*":n,f=ft(r),l=((t,e,r,n)=>i=>{if(!i.source)return;if("*"!==r&&i.origin!==r)return void t(`Parent: Handshake - Received SYN message from origin ${i.origin} which did not match expected origin ${r}`);t("Parent: Handshake - Received SYN, responding with SYN-ACK");const o={penpal:Y.SynAck,methodNames:Object.keys(e)};i.source.postMessage(o,n)})(s,f,n,h),d=dt(f,n,h,a,s),p=new Promise(((t,r)=>{const n=((t,e)=>{let r;return void 0!==t&&(r=window.setTimeout((()=>{const r=new Error(`Connection timed out after ${t}ms`);r.code=Q.ConnectionTimeout,e(r)}),t)),()=>{clearTimeout(r)}})(i,c),o=r=>{if(r.source===e.contentWindow&&r.data)if(r.data.penpal!==Y.Syn)if(r.data.penpal!==Y.Ack);else{const e=d(r);e&&(n(),t(e))}else l(r)};window.addEventListener(et.Message,o),s("Parent: Awaiting handshake"),((t,e)=>{const{destroy:r,onDestroy:n}=e,i=setInterval((()=>{t.isConnected||(clearInterval(i),r())}),6e4);n((()=>{clearInterval(i)}))})(e,a),u((t=>{window.removeEventListener(et.Message,o),t&&r(t)}))}));return{promise:p,destroy(){c()}}},At={},Bt=[],St=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,It=Array.isArray;function kt(t,e){for(var r in e)t[r]=e[r];return t}function Ot(t){var e=t.parentNode;e&&e.removeChild(t)}function Ut(t,e,r,n,i){var o={type:t,props:e,key:r,ref:n,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:null==i?++gt:i,__i:-1,__u:0};return null==i&&null!=mt.vnode&&mt.vnode(o),o}function Rt(t){return t.children}function Tt(t,e){this.props=t,this.context=e}function Lt(t,e){if(null==e)return t.__?Lt(t.__,t.__i+1):null;for(var r;e<t.__k.length;e++)if(null!=(r=t.__k[e])&&null!=r.__e)return r.__e;return"function"==typeof t.type?Lt(t):null}function Ct(t){var e,r;if(null!=(t=t.__)&&null!=t.__c){for(t.__e=t.__c.base=null,e=0;e<t.__k.length;e++)if(null!=(r=t.__k[e])&&null!=r.__e){t.__e=t.__c.base=r.__e;break}return Ct(t)}}function Nt(t){(!t.__d&&(t.__d=!0)&&yt.push(t)&&!$t.__r++||wt!==mt.debounceRendering)&&((wt=mt.debounceRendering)||vt)($t)}function $t(){var t,e,r,n,i,o,s,a;for(yt.sort(bt);t=yt.shift();)t.__d&&(e=yt.length,n=void 0,o=(i=(r=t).__v).__e,s=[],a=[],r.__P&&((n=kt({},i)).__v=i.__v+1,mt.vnode&&mt.vnode(n),Vt(r.__P,n,i,r.__n,r.__P.namespaceURI,32&i.__u?[o]:null,s,null==o?Lt(i):o,!!(32&i.__u),a),n.__v=i.__v,n.__.__k[n.__i]=n,Zt(s,n,a),n.__e!=o&&Ct(n)),yt.length>e&&yt.sort(bt));$t.__r=0}function Pt(t,e,r,n,i,o,s,a,u,c,h){var f,l,d,p,m,g=n&&n.__k||Bt,y=e.length;for(r.__d=u,Ft(r,e,g),u=r.__d,f=0;f<y;f++)null!=(d=r.__k[f])&&"boolean"!=typeof d&&"function"!=typeof d&&(l=-1===d.__i?At:g[d.__i]||At,d.__i=f,Vt(t,d,l,i,o,s,a,u,c,h),p=d.__e,d.ref&&l.ref!=d.ref&&(l.ref&&Wt(l.ref,null,d),h.push(d.ref,d.__c||p,d)),null==m&&null!=p&&(m=p),65536&d.__u||l.__k===d.__k?(u&&"string"==typeof d.type&&!t.contains(u)&&(u=Lt(l)),u=zt(d,u,t)):"function"==typeof d.type&&void 0!==d.__d?u=d.__d:p&&(u=p.nextSibling),d.__d=void 0,d.__u&=-196609);r.__d=u,r.__e=m}function Ft(t,e,r){var n,i,o,s,a,u=e.length,c=r.length,h=c,f=0;for(t.__k=[],n=0;n<u;n++)s=n+f,null!=(i=t.__k[n]=null==(i=e[n])||"boolean"==typeof i||"function"==typeof i?null:"string"==typeof i||"number"==typeof i||"bigint"==typeof i||i.constructor==String?Ut(null,i,null,null,null):It(i)?Ut(Rt,{children:i},null,null,null):void 0===i.constructor&&i.__b>0?Ut(i.type,i.props,i.key,i.ref?i.ref:null,i.__v):i)?(i.__=t,i.__b=t.__b+1,a=jt(i,r,s,h),i.__i=a,o=null,-1!==a&&(h--,(o=r[a])&&(o.__u|=131072)),null==o||null===o.__v?(-1==a&&f--,"function"!=typeof i.type&&(i.__u|=65536)):a!==s&&(a==s-1?f=a-s:a==s+1?f++:a>s?h>u-s?f+=a-s:f--:a<s&&f++,a!==n+f&&(i.__u|=65536))):(o=r[s])&&null==o.key&&o.__e&&!(131072&o.__u)&&(o.__e==t.__d&&(t.__d=Lt(o)),Jt(o,o,!1),r[s]=null,h--);if(h)for(n=0;n<c;n++)null!=(o=r[n])&&!(131072&o.__u)&&(o.__e==t.__d&&(t.__d=Lt(o)),Jt(o,o))}function zt(t,e,r){var n,i;if("function"==typeof t.type){for(n=t.__k,i=0;n&&i<n.length;i++)n[i]&&(n[i].__=t,e=zt(n[i],e,r));return e}t.__e!=e&&(r.insertBefore(t.__e,e||null),e=t.__e);do{e=e&&e.nextSibling}while(null!=e&&8===e.nodeType);return e}function jt(t,e,r,n){var i=t.key,o=t.type,s=r-1,a=r+1,u=e[r];if(null===u||u&&i==u.key&&o===u.type&&!(131072&u.__u))return r;if(n>(null==u||131072&u.__u?0:1))for(;s>=0||a<e.length;){if(s>=0){if((u=e[s])&&!(131072&u.__u)&&i==u.key&&o===u.type)return s;s--}if(a<e.length){if((u=e[a])&&!(131072&u.__u)&&i==u.key&&o===u.type)return a;a++}}return-1}function Dt(t,e,r){"-"===e[0]?t.setProperty(e,null==r?"":r):t[e]=null==r?"":"number"!=typeof r||St.test(e)?r:r+"px"}function qt(t,e,r,n,i){var o;t:if("style"===e)if("string"==typeof r)t.style.cssText=r;else{if("string"==typeof n&&(t.style.cssText=n=""),n)for(e in n)r&&e in r||Dt(t.style,e,"");if(r)for(e in r)n&&r[e]===n[e]||Dt(t.style,e,r[e])}else if("o"===e[0]&&"n"===e[1])o=e!==(e=e.replace(/(PointerCapture)$|Capture$/i,"$1")),e=e.toLowerCase()in t||"onFocusOut"===e||"onFocusIn"===e?e.toLowerCase().slice(2):e.slice(2),t.l||(t.l={}),t.l[e+o]=r,r?n?r.u=n.u:(r.u=_t,t.addEventListener(e,o?xt:Et,o)):t.removeEventListener(e,o?xt:Et,o);else{if("http://www.w3.org/2000/svg"==i)e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("width"!=e&&"height"!=e&&"href"!=e&&"list"!=e&&"form"!=e&&"tabIndex"!=e&&"download"!=e&&"rowSpan"!=e&&"colSpan"!=e&&"role"!=e&&"popover"!=e&&e in t)try{t[e]=null==r?"":r;break t}catch(t){}"function"==typeof r||(null==r||!1===r&&"-"!==e[4]?t.removeAttribute(e):t.setAttribute(e,"popover"==e&&1==r?"":r))}}function Ht(t){return function(e){if(this.l){var r=this.l[e.type+t];if(null==e.t)e.t=_t++;else if(e.t<r.u)return;return r(mt.event?mt.event(e):e)}}}function Vt(t,e,r,n,i,o,s,a,u,c){var h,f,l,d,p,m,g,y,w,v,b,_,E,x,M,A,B=e.type;if(void 0!==e.constructor)return null;128&r.__u&&(u=!!(32&r.__u),o=[a=e.__e=r.__e]),(h=mt.__b)&&h(e);t:if("function"==typeof B)try{if(y=e.props,w="prototype"in B&&B.prototype.render,v=(h=B.contextType)&&n[h.__c],b=h?v?v.props.value:h.__:n,r.__c?g=(f=e.__c=r.__c).__=f.__E:(w?e.__c=f=new B(y,b):(e.__c=f=new Tt(y,b),f.constructor=B,f.render=Kt),v&&v.sub(f),f.props=y,f.state||(f.state={}),f.context=b,f.__n=n,l=f.__d=!0,f.__h=[],f._sb=[]),w&&null==f.__s&&(f.__s=f.state),w&&null!=B.getDerivedStateFromProps&&(f.__s==f.state&&(f.__s=kt({},f.__s)),kt(f.__s,B.getDerivedStateFromProps(y,f.__s))),d=f.props,p=f.state,f.__v=e,l)w&&null==B.getDerivedStateFromProps&&null!=f.componentWillMount&&f.componentWillMount(),w&&null!=f.componentDidMount&&f.__h.push(f.componentDidMount);else{if(w&&null==B.getDerivedStateFromProps&&y!==d&&null!=f.componentWillReceiveProps&&f.componentWillReceiveProps(y,b),!f.__e&&(null!=f.shouldComponentUpdate&&!1===f.shouldComponentUpdate(y,f.__s,b)||e.__v===r.__v)){for(e.__v!==r.__v&&(f.props=y,f.state=f.__s,f.__d=!1),e.__e=r.__e,e.__k=r.__k,e.__k.forEach((function(t){t&&(t.__=e)})),_=0;_<f._sb.length;_++)f.__h.push(f._sb[_]);f._sb=[],f.__h.length&&s.push(f);break t}null!=f.componentWillUpdate&&f.componentWillUpdate(y,f.__s,b),w&&null!=f.componentDidUpdate&&f.__h.push((function(){f.componentDidUpdate(d,p,m)}))}if(f.context=b,f.props=y,f.__P=t,f.__e=!1,E=mt.__r,x=0,w){for(f.state=f.__s,f.__d=!1,E&&E(e),h=f.render(f.props,f.state,f.context),M=0;M<f._sb.length;M++)f.__h.push(f._sb[M]);f._sb=[]}else do{f.__d=!1,E&&E(e),h=f.render(f.props,f.state,f.context),f.state=f.__s}while(f.__d&&++x<25);f.state=f.__s,null!=f.getChildContext&&(n=kt(kt({},n),f.getChildContext())),w&&!l&&null!=f.getSnapshotBeforeUpdate&&(m=f.getSnapshotBeforeUpdate(d,p)),Pt(t,It(A=null!=h&&h.type===Rt&&null==h.key?h.props.children:h)?A:[A],e,r,n,i,o,s,a,u,c),f.base=e.__e,e.__u&=-161,f.__h.length&&s.push(f),g&&(f.__E=f.__=null)}catch(t){e.__v=null,u||null!=o?(e.__e=a,e.__u|=u?160:32,o[o.indexOf(a)]=null):(e.__e=r.__e,e.__k=r.__k),mt.__e(t,e,r)}else null==o&&e.__v===r.__v?(e.__k=r.__k,e.__e=r.__e):e.__e=Gt(r.__e,e,r,n,i,o,s,u,c);(h=mt.diffed)&&h(e)}function Zt(t,e,r){e.__d=void 0;for(var n=0;n<r.length;n++)Wt(r[n],r[++n],r[++n]);mt.__c&&mt.__c(e,t),t.some((function(e){try{t=e.__h,e.__h=[],t.some((function(t){t.call(e)}))}catch(t){mt.__e(t,e.__v)}}))}function Gt(t,e,r,n,i,o,s,a,u){var c,h,f,l,d,p,m,g=r.props,y=e.props,w=e.type;if("svg"===w?i="http://www.w3.org/2000/svg":"math"===w?i="http://www.w3.org/1998/Math/MathML":i||(i="http://www.w3.org/1999/xhtml"),null!=o)for(c=0;c<o.length;c++)if((d=o[c])&&"setAttribute"in d==!!w&&(w?d.localName===w:3===d.nodeType)){t=d,o[c]=null;break}if(null==t){if(null===w)return document.createTextNode(y);t=document.createElementNS(i,w,y.is&&y),o=null,a=!1}if(null===w)g===y||a&&t.data===y||(t.data=y);else{if(o=o&&pt.call(t.childNodes),g=r.props||At,!a&&null!=o)for(g={},c=0;c<t.attributes.length;c++)g[(d=t.attributes[c]).name]=d.value;for(c in g)if(d=g[c],"children"==c);else if("dangerouslySetInnerHTML"==c)f=d;else if("key"!==c&&!(c in y)){if("value"==c&&"defaultValue"in y||"checked"==c&&"defaultChecked"in y)continue;qt(t,c,null,d,i)}for(c in y)d=y[c],"children"==c?l=d:"dangerouslySetInnerHTML"==c?h=d:"value"==c?p=d:"checked"==c?m=d:"key"===c||a&&"function"!=typeof d||g[c]===d||qt(t,c,d,g[c],i);if(h)a||f&&(h.__html===f.__html||h.__html===t.innerHTML)||(t.innerHTML=h.__html),e.__k=[];else if(f&&(t.innerHTML=""),Pt(t,It(l)?l:[l],e,r,n,"foreignObject"===w?"http://www.w3.org/1999/xhtml":i,o,s,o?o[0]:r.__k&&Lt(r,0),a,u),null!=o)for(c=o.length;c--;)null!=o[c]&&Ot(o[c]);a||(c="value",void 0!==p&&(p!==t[c]||"progress"===w&&!p||"option"===w&&p!==g[c])&&qt(t,c,p,g[c],i),c="checked",void 0!==m&&m!==t[c]&&qt(t,c,m,g[c],i))}return t}function Wt(t,e,r){try{"function"==typeof t?t(e):t.current=e}catch(t){mt.__e(t,r)}}function Jt(t,e,r){var n,i;if(mt.unmount&&mt.unmount(t),(n=t.ref)&&(n.current&&n.current!==t.__e||Wt(n,null,e)),null!=(n=t.__c)){if(n.componentWillUnmount)try{n.componentWillUnmount()}catch(t){mt.__e(t,e)}n.base=n.__P=null}if(n=t.__k)for(i=0;i<n.length;i++)n[i]&&Jt(n[i],e,r||"function"!=typeof t.type);r||null==t.__e||Ot(t.__e),t.__c=t.__=t.__e=t.__d=void 0}function Kt(t,e,r){return this.constructor(t,r)}function Yt(t,e,r){var n,i,o,s;mt.__&&mt.__(t,e),i=(n="function"==typeof r)?null:r&&r.__k||e.__k,o=[],s=[],Vt(e,t=(!n&&r||e).__k=function(t,e,r){var n,i,o,s={};for(o in e)"key"==o?n=e[o]:"ref"==o?i=e[o]:s[o]=e[o];if(arguments.length>2&&(s.children=arguments.length>3?pt.call(arguments,2):r),"function"==typeof t&&null!=t.defaultProps)for(o in t.defaultProps)void 0===s[o]&&(s[o]=t.defaultProps[o]);return Ut(t,s,n,i,null)}(Rt,null,[t]),i||At,At,e.namespaceURI,!n&&r?[r]:i?null:e.firstChild?pt.call(e.childNodes):null,o,!n&&r?r:i?i.__e:e.firstChild,n,s),Zt(o,t,s)}pt=Bt.slice,mt={__e:function(t,e,r,n){for(var i,o,s;e=e.__;)if((i=e.__c)&&!i.__)try{if((o=i.constructor)&&null!=o.getDerivedStateFromError&&(i.setState(o.getDerivedStateFromError(t)),s=i.__d),null!=i.componentDidCatch&&(i.componentDidCatch(t,n||{}),s=i.__d),s)return i.__E=i}catch(e){t=e}throw t}},gt=0,Tt.prototype.setState=function(t,e){var r;r=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=kt({},this.state),"function"==typeof t&&(t=t(kt({},r),this.props)),t&&kt(r,t),null!=t&&this.__v&&(e&&this._sb.push(e),Nt(this))},Tt.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),Nt(this))},Tt.prototype.render=Rt,yt=[],vt="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,bt=function(t,e){return t.__v.__b-e.__v.__b},$t.__r=0,_t=0,Et=Ht(!1),xt=Ht(!0);var Xt=0;function Qt(t,e,r,n,i,o){e||(e={});var s,a,u=e;if("ref"in u)for(a in u={},e)"ref"==a?s=e[a]:u[a]=e[a];var c={type:t,props:u,key:r,ref:s,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:--Xt,__i:-1,__u:0,__source:i,__self:o};if("function"==typeof t&&(s=t.defaultProps))for(a in s)void 0===u[a]&&(u[a]=s[a]);return mt.vnode&&mt.vnode(c),c}var te,ee,re,ne,ie=0,oe=[],se=mt,ae=se.__b,ue=se.__r,ce=se.diffed,he=se.__c,fe=se.unmount,le=se.__;function de(t,e){se.__h&&se.__h(ee,t,ie||e),ie=0;var r=ee.__H||(ee.__H={__:[],__h:[]});return t>=r.__.length&&r.__.push({}),r.__[t]}function pe(t){return ie=1,me(Me,t)}function me(t,e,r){var n=de(te++,2);if(n.t=t,!n.__c&&(n.__=[r?r(e):Me(void 0,e),function(t){var e=n.__N?n.__N[0]:n.__[0],r=n.t(e,t);e!==r&&(n.__N=[r,n.__[1]],n.__c.setState({}))}],n.__c=ee,!ee.u)){var i=function(t,e,r){if(!n.__c.__H)return!0;var i=n.__c.__H.__.filter((function(t){return!!t.__c}));if(i.every((function(t){return!t.__N})))return!o||o.call(this,t,e,r);var s=!1;return i.forEach((function(t){if(t.__N){var e=t.__[0];t.__=t.__N,t.__N=void 0,e!==t.__[0]&&(s=!0)}})),!(!s&&n.__c.props===t)&&(!o||o.call(this,t,e,r))};ee.u=!0;var o=ee.shouldComponentUpdate,s=ee.componentWillUpdate;ee.componentWillUpdate=function(t,e,r){if(this.__e){var n=o;o=void 0,i(t,e,r),o=n}s&&s.call(this,t,e,r)},ee.shouldComponentUpdate=i}return n.__N||n.__}function ge(t,e){var r=de(te++,3);!se.__s&&xe(r.__H,e)&&(r.__=t,r.i=e,ee.__H.__h.push(r))}function ye(t){return ie=5,function(t,e){var r=de(te++,7);return xe(r.__H,e)&&(r.__=t(),r.__H=e,r.__h=t),r.__}((function(){return{current:t}}),[])}function we(){for(var t;t=oe.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(_e),t.__H.__h.forEach(Ee),t.__H.__h=[]}catch(e){t.__H.__h=[],se.__e(e,t.__v)}}se.__b=function(t){ee=null,ae&&ae(t)},se.__=function(t,e){t&&e.__k&&e.__k.__m&&(t.__m=e.__k.__m),le&&le(t,e)},se.__r=function(t){ue&&ue(t),te=0;var e=(ee=t.__c).__H;e&&(re===ee?(e.__h=[],ee.__h=[],e.__.forEach((function(t){t.__N&&(t.__=t.__N),t.i=t.__N=void 0}))):(e.__h.forEach(_e),e.__h.forEach(Ee),e.__h=[],te=0)),re=ee},se.diffed=function(t){ce&&ce(t);var e=t.__c;e&&e.__H&&(e.__H.__h.length&&(1!==oe.push(e)&&ne===se.requestAnimationFrame||((ne=se.requestAnimationFrame)||be)(we)),e.__H.__.forEach((function(t){t.i&&(t.__H=t.i),t.i=void 0}))),re=ee=null},se.__c=function(t,e){e.some((function(t){try{t.__h.forEach(_e),t.__h=t.__h.filter((function(t){return!t.__||Ee(t)}))}catch(r){e.some((function(t){t.__h&&(t.__h=[])})),e=[],se.__e(r,t.__v)}})),he&&he(t,e)},se.unmount=function(t){fe&&fe(t);var e,r=t.__c;r&&r.__H&&(r.__H.__.forEach((function(t){try{_e(t)}catch(t){e=t}})),r.__H=void 0,e&&se.__e(e,r.__v))};var ve="function"==typeof requestAnimationFrame;function be(t){var e,r=function(){clearTimeout(n),ve&&cancelAnimationFrame(e),setTimeout(t)},n=setTimeout(r,100);ve&&(e=requestAnimationFrame(r))}function _e(t){var e=ee,r=t.__c;"function"==typeof r&&(t.__c=void 0,r()),ee=e}function Ee(t){var e=ee;t.__c=t.__(),ee=e}function xe(t,e){return!t||t.length!==e.length||e.some((function(e,r){return e!==t[r]}))}function Me(t,e){return"function"==typeof e?e(t):e}function Ae(t){return Ae="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ae(t)}function Be(t){if(!("string"==typeof t||t instanceof String)){var e=Ae(t);throw null===t?e="null":"object"===e&&(e=t.constructor.name),new TypeError("Expected a string but received a ".concat(e))}}function Se(t){return Se="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Se(t)}function Ie(t,e){var r,n;Be(t),"object"===Se(e)?(r=e.min||0,n=e.max):(r=arguments[1],n=arguments[2]);var i=encodeURI(t).split(/%..|./).length-1;return i>=r&&(void 0===n||i<=n)}function ke(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length>1?arguments[1]:void 0;for(var r in e)void 0===t[r]&&(t[r]=e[r]);return t}var Oe={require_tld:!0,allow_underscores:!1,allow_trailing_dot:!1,allow_numeric_tld:!1,allow_wildcard:!1,ignore_max_length:!1};var Ue="(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])",Re="(".concat(Ue,"[.]){3}").concat(Ue),Te=new RegExp("^".concat(Re,"$")),Le="(?:[0-9a-fA-F]{1,4})",Ce=new RegExp("^("+"(?:".concat(Le,":){7}(?:").concat(Le,"|:)|")+"(?:".concat(Le,":){6}(?:").concat(Re,"|:").concat(Le,"|:)|")+"(?:".concat(Le,":){5}(?::").concat(Re,"|(:").concat(Le,"){1,2}|:)|")+"(?:".concat(Le,":){4}(?:(:").concat(Le,"){0,1}:").concat(Re,"|(:").concat(Le,"){1,3}|:)|")+"(?:".concat(Le,":){3}(?:(:").concat(Le,"){0,2}:").concat(Re,"|(:").concat(Le,"){1,4}|:)|")+"(?:".concat(Le,":){2}(?:(:").concat(Le,"){0,3}:").concat(Re,"|(:").concat(Le,"){1,5}|:)|")+"(?:".concat(Le,":){1}(?:(:").concat(Le,"){0,4}:").concat(Re,"|(:").concat(Le,"){1,6}|:)|")+"(?::((?::".concat(Le,"){0,5}:").concat(Re,"|(?::").concat(Le,"){1,7}|:))")+")(%[0-9a-zA-Z-.:]{1,})?$");function Ne(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return Be(t),(e=String(e))?"4"===e?Te.test(t):"6"===e&&Ce.test(t):Ne(t,4)||Ne(t,6)}var $e={allow_display_name:!1,allow_underscores:!1,require_display_name:!1,allow_utf8_local_part:!0,require_tld:!0,blacklisted_chars:"",ignore_max_length:!1,host_blacklist:[],host_whitelist:[]},Pe=/^([^\x00-\x1F\x7F-\x9F\cX]+)</i,Fe=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~]+$/i,ze=/^[a-z\d]+$/,je=/^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f]))*$/i,De=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\u00A1-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+$/i,qe=/^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))*$/i;function He(t,e){if(Be(t),(e=ke(e,$e)).require_display_name||e.allow_display_name){var r=t.match(Pe);if(r){var n=r[1];if(t=t.replace(n,"").replace(/(^<|>$)/g,""),n.endsWith(" ")&&(n=n.slice(0,-1)),!function(t){var e=t.replace(/^"(.+)"$/,"$1");if(!e.trim())return!1;if(/[\.";<>]/.test(e)){if(e===t)return!1;if(e.split('"').length!==e.split('\\"').length)return!1}return!0}(n))return!1}else if(e.require_display_name)return!1}if(!e.ignore_max_length&&t.length>254)return!1;var i=t.split("@"),o=i.pop(),s=o.toLowerCase();if(e.host_blacklist.includes(s))return!1;if(e.host_whitelist.length>0&&!e.host_whitelist.includes(s))return!1;var a=i.join("@");if(e.domain_specific_validation&&("gmail.com"===s||"googlemail.com"===s)){var u=(a=a.toLowerCase()).split("+")[0];if(!Ie(u.replace(/\./g,""),{min:6,max:30}))return!1;for(var c=u.split("."),h=0;h<c.length;h++)if(!ze.test(c[h]))return!1}if(!(!1!==e.ignore_max_length||Ie(a,{max:64})&&Ie(o,{max:254})))return!1;if(!function(t,e){Be(t),(e=ke(e,Oe)).allow_trailing_dot&&"."===t[t.length-1]&&(t=t.substring(0,t.length-1)),!0===e.allow_wildcard&&0===t.indexOf("*.")&&(t=t.substring(2));var r=t.split("."),n=r[r.length-1];if(e.require_tld){if(r.length<2)return!1;if(!e.allow_numeric_tld&&!/^([a-z\u00A1-\u00A8\u00AA-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,}|xn[a-z0-9-]{2,})$/i.test(n))return!1;if(/\s/.test(n))return!1}return!(!e.allow_numeric_tld&&/^\d+$/.test(n))&&r.every((function(t){return!(t.length>63&&!e.ignore_max_length||!/^[a-z_\u00a1-\uffff0-9-]+$/i.test(t)||/[\uff01-\uff5e]/.test(t)||/^-|-$/.test(t)||!e.allow_underscores&&/_/.test(t))}))}(o,{require_tld:e.require_tld,ignore_max_length:e.ignore_max_length,allow_underscores:e.allow_underscores})){if(!e.allow_ip_domain)return!1;if(!Ne(o)){if(!o.startsWith("[")||!o.endsWith("]"))return!1;var f=o.slice(1,-1);if(0===f.length||!Ne(f))return!1}}if('"'===a[0])return a=a.slice(1,a.length-1),e.allow_utf8_local_part?qe.test(a):je.test(a);for(var l=e.allow_utf8_local_part?De:Fe,d=a.split("."),p=0;p<d.length;p++)if(!l.test(d[p]))return!1;return!e.blacklisted_chars||-1===a.search(new RegExp("[".concat(e.blacklisted_chars,"]+"),"g"))}function Ve(t,e){void 0===e&&(e={});var r=e.insertAt;if(t&&"undefined"!=typeof document){var n=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");i.type="text/css","top"===r&&n.firstChild?n.insertBefore(i,n.firstChild):n.appendChild(i),i.styleSheet?i.styleSheet.cssText=t:i.appendChild(document.createTextNode(t))}}for(var Ze={},Ge={byteLength:function(t){var e=Qe(t),r=e[0],n=e[1];return 3*(r+n)/4-n},toByteArray:function(t){var e,r,n=Qe(t),i=n[0],o=n[1],s=new Ke(function(t,e,r){return 3*(e+r)/4-r}(0,i,o)),a=0,u=o>0?i-4:i;for(r=0;r<u;r+=4)e=Je[t.charCodeAt(r)]<<18|Je[t.charCodeAt(r+1)]<<12|Je[t.charCodeAt(r+2)]<<6|Je[t.charCodeAt(r+3)],s[a++]=e>>16&255,s[a++]=e>>8&255,s[a++]=255&e;2===o&&(e=Je[t.charCodeAt(r)]<<2|Je[t.charCodeAt(r+1)]>>4,s[a++]=255&e);1===o&&(e=Je[t.charCodeAt(r)]<<10|Je[t.charCodeAt(r+1)]<<4|Je[t.charCodeAt(r+2)]>>2,s[a++]=e>>8&255,s[a++]=255&e);return s},fromByteArray:function(t){for(var e,r=t.length,n=r%3,i=[],o=16383,s=0,a=r-n;s<a;s+=o)i.push(tr(t,s,s+o>a?a:s+o));1===n?(e=t[r-1],i.push(We[e>>2]+We[e<<4&63]+"==")):2===n&&(e=(t[r-2]<<8)+t[r-1],i.push(We[e>>10]+We[e>>4&63]+We[e<<2&63]+"="));return i.join("")}},We=[],Je=[],Ke="undefined"!=typeof Uint8Array?Uint8Array:Array,Ye="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Xe=0;Xe<64;++Xe)We[Xe]=Ye[Xe],Je[Ye.charCodeAt(Xe)]=Xe;function Qe(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function tr(t,e,r){for(var n,i,o=[],s=e;s<r;s+=3)n=(t[s]<<16&16711680)+(t[s+1]<<8&65280)+(255&t[s+2]),o.push(We[(i=n)>>18&63]+We[i>>12&63]+We[i>>6&63]+We[63&i]);return o.join("")}Je["-".charCodeAt(0)]=62,Je["_".charCodeAt(0)]=63;var er={/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */ read:function(t,e,r,n,i){var o,s,a=8*i-n-1,u=(1<<a)-1,c=u>>1,h=-7,f=r?i-1:0,l=r?-1:1,d=t[e+f];for(f+=l,o=d&(1<<-h)-1,d>>=-h,h+=a;h>0;o=256*o+t[e+f],f+=l,h-=8);for(s=o&(1<<-h)-1,o>>=-h,h+=n;h>0;s=256*s+t[e+f],f+=l,h-=8);if(0===o)o=1-c;else{if(o===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=c}return(d?-1:1)*s*Math.pow(2,o-n)},write:function(t,e,r,n,i,o){var s,a,u,c=8*o-i-1,h=(1<<c)-1,f=h>>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,m=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=h):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),(e+=s+f>=1?l/u:l*Math.pow(2,1-f))*u>=2&&(s++,u/=2),s+f>=h?(a=0,s=h):s+f>=1?(a=(e*u-1)*Math.pow(2,i),s+=f):(a=e*Math.pow(2,f-1)*Math.pow(2,i),s=0));i>=8;t[r+d]=255&a,d+=p,a/=256,i-=8);for(s=s<<i|a,c+=i;c>0;t[r+d]=255&s,d+=p,s/=256,c-=8);t[r+d-p]|=128*m}}; /*! * The buffer module from node.js, for the browser. * * @author Feross Aboukhadijeh <https://feross.org> * @license MIT */ !function(t){const e=Ge,r=er,n="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=s,t.SlowBuffer=function(t){+t!=t&&(t=0);return s.alloc(+t)},t.INSPECT_MAX_BYTES=50;const i=2147483647;function o(t){if(t>i)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,s.prototype),e}function s(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return c(t)}return a(t,e,r)}function a(t,e,r){if("string"==typeof t)return function(t,e){"string"==typeof e&&""!==e||(e="utf8");if(!s.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|d(t,e);let n=o(r);const i=n.write(t,e);i!==r&&(n=n.slice(0,i));return n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(G(t,Uint8Array)){const e=new Uint8Array(t);return f(e.buffer,e.byteOffset,e.byteLength)}return h(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(G(t,ArrayBuffer)||t&&G(t.buffer,ArrayBuffer))return f(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(G(t,SharedArrayBuffer)||t&&G(t.buffer,SharedArrayBuffer)))return f(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return s.from(n,e,r);const i=function(t){if(s.isBuffer(t)){const e=0|l(t.length),r=o(e);return 0===r.length||t.copy(r,0,0,e),r}if(void 0!==t.length)return"number"!=typeof t.length||W(t.length)?o(0):h(t);if("Buffer"===t.type&&Array.isArray(t.data))return h(t.data)}(t);if(i)return i;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return s.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function u(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function c(t){return u(t),o(t<0?0:0|l(t))}function h(t){const e=t.length<0?0:0|l(t.length),r=o(e);for(let n=0;n<e;n+=1)r[n]=255&t[n];return r}function f(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return n=void 0===e&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,e):new Uint8Array(t,e,r),Object.setPrototypeOf(n,s.prototype),n}function l(t){if(t>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return 0|t}function d(t,e){if(s.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||G(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return H(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return V(t).length;default:if(i)return n?-1:H(t).length;e=(""+e).toLowerCase(),i=!0}}function p(t,e,r){let n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return I(this,e,r);case"utf8":case"utf-8":return M(this,e,r);case"ascii":return B(this,e,r);case"latin1":case"binary":return S(this,e,r);case"base64":return x(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function m(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function g(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),W(r=+r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=s.from(e,n)),s.isBuffer(e))return 0===e.length?-1:y(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):y(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function y(t,e,r,n,i){let o,s=1,a=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;s=2,a/=2,u/=2,r/=2}function c(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(i){let n=-1;for(o=r;o<a;o++)if(c(t,o)===c(e,-1===n?0:o-n)){if(-1===n&&(n=o),o-n+1===u)return n*s}else-1!==n&&(o-=o-n),n=-1}else for(r+u>a&&(r=a-u),o=r;o>=0;o--){let r=!0;for(let n=0;n<u;n++)if(c(t,o+n)!==c(e,n)){r=!1;break}if(r)return o}return-1}function w(t,e,r,n){r=Number(r)||0;const i=t.length-r;n?(n=Number(n))>i&&(n=i):n=i;const o=e.length;let s;for(n>o/2&&(n=o/2),s=0;s<n;++s){const n=parseInt(e.substr(2*s,2),16);if(W(n))return s;t[r+s]=n}return s}function v(t,e,r,n){return Z(H(e,t.length-r),t,r,n)}function b(t,e,r,n){return Z(function(t){const e=[];for(let r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function _(t,e,r,n){return Z(V(e),t,r,n)}function E(t,e,r,n){return Z(function(t,e){let r,n,i;const o=[];for(let s=0;s<t.length&&!((e-=2)<0);++s)r=t.charCodeAt(s),n=r>>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function x(t,r,n){return 0===r&&n===t.length?e.fromByteArray(t):e.fromByteArray(t.slice(r,n))}function M(t,e,r){r=Math.min(t.length,r);const n=[];let i=e;for(;i<r;){const e=t[i];let o=null,s=e>239?4:e>223?3:e>191?2:1;if(i+s<=r){let r,n,a,u;switch(s){case 1:e<128&&(o=e);break;case 2:r=t[i+1],128==(192&r)&&(u=(31&e)<<6|63&r,u>127&&(o=u));break;case 3:r=t[i+1],n=t[i+2],128==(192&r)&&128==(192&n)&&(u=(15&e)<<12|(63&r)<<6|63&n,u>2047&&(u<55296||u>57343)&&(o=u));break;case 4:r=t[i+1],n=t[i+2],a=t[i+3],128==(192&r)&&128==(192&n)&&128==(192&a)&&(u=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&a,u>65535&&u<1114112&&(o=u))}}null===o?(o=65533,s=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|1023&o),n.push(o),i+=s}return functio