@wormhole-foundation/wormhole-connect 2.1.0-beta.1-development → 2.1.0-beta.2-development
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{ccip-j5QHovIT.js → ccip-DfI9A4kL.js} +1 -1
- package/dist/assets/{evm-B5I5ieRn.js → evm-CYICYl2d.js} +3 -3
- package/dist/assets/index-26ve8f2n.js +531 -0
- package/dist/assets/index-NqsKKz5-.js +14 -0
- package/dist/assets/index.es-CephYdxr.js +47 -0
- package/dist/assets/{solana-c_vE3Ye5.js → solana-DXbD7wpn.js} +2 -2
- package/dist/assets/{solanaEmbed.esm-Bx0ME0S1.js → solanaEmbed.esm-CcwIvLto.js} +10 -10
- package/dist/main.js +3 -3
- package/lib/{aptos-CzT6f7Ba.js → aptos-7G9wZkGW.js} +2 -2
- package/lib/{aptos-wFa1-xae.mjs → aptos-BlOWGpyT.mjs} +2 -2
- package/lib/{aptos-CqfHXKy7.js → aptos-CYxRBLR_.js} +1 -1
- package/lib/{aptos-DxhN-FI3.mjs → aptos-Ckopfy7I.mjs} +5 -5
- package/lib/{base64-C_XWimVd.js → base64-CFR5QWTY.js} +1 -1
- package/lib/{base64-L1vzz0KI.mjs → base64-HSuzVIKw.mjs} +1 -1
- package/lib/{ccip-z81HbzxN.mjs → ccip-Bntg_vPp.mjs} +1 -1
- package/lib/{ccip-D6aPw5Ue.js → ccip-CVUhxB0q.js} +1 -1
- package/lib/{chunk-IMTC3J2M-CazR2ogu.mjs → chunk-IMTC3J2M-BADDWO3l.mjs} +3 -3
- package/lib/{chunk-IMTC3J2M-WMj1Jt5m.js → chunk-IMTC3J2M-ByR5Yjf4.js} +1 -1
- package/lib/{events-D4Mv_WYU.js → events-jATx_JnD.js} +1 -1
- package/lib/{events-BrdIAbQL.mjs → events-lD3LhLH0.mjs} +1 -1
- package/lib/{evm-CB6zu7io.mjs → evm-BW0CHBCG.mjs} +5 -5
- package/lib/{evm-Fk4wBAda.js → evm-Bh1Y4eUx.js} +1 -1
- package/lib/{evm-CULALpUt.mjs → evm-ColKfWEz.mjs} +10 -6
- package/lib/{evm-BJL8RjTB.js → evm-z5yFHxM9.js} +3 -3
- package/lib/{index-D2y7My6x.mjs → index-2fBRXVP8.mjs} +2 -2
- package/lib/{index-Cuov-W4s.js → index-8-70GvMi.js} +1 -1
- package/lib/{index-Xy8XaqU-.js → index-8JCep4IW.js} +1 -1
- package/lib/{index-BTmEJpYG.mjs → index-B9GU1bLs.mjs} +1 -1
- package/lib/{index-CS3t6bxx.mjs → index-BXkdaYu_.mjs} +1 -1
- package/lib/{index-DEpSdwA-.mjs → index-BZ0W_BZS.mjs} +2 -2
- package/lib/{index-CtpCK8QC.js → index-BcdbCktu.js} +1 -1
- package/lib/{index-BnVRRJvv.js → index-BhexWYVn.js} +1 -1
- package/lib/{index-BT_eiQVC.js → index-C-OIv0gT.js} +1 -1
- package/lib/{index-CAqS4koK.js → index-C6WDEDwO.js} +1 -1
- package/lib/{index-BqaYMlOq.mjs → index-CAUvtNGE.mjs} +3 -3
- package/lib/{index-DpfI-2hT.mjs → index-CBxgME-2.mjs} +2 -2
- package/lib/{index-Dtg6idl8.js → index-CCUy1jes.js} +1 -1
- package/lib/{index-DGcrnWdu.mjs → index-CYBM2IeY.mjs} +13 -12
- package/lib/{index-DJJ3umH8.mjs → index-CcFpkXPM.mjs} +2 -2
- package/lib/{index-BqCducVx.mjs → index-CfnNi3Zd.mjs} +3 -3
- package/lib/{index-DdRe9fUB.mjs → index-Cl6LSKsg.mjs} +1 -1
- package/lib/{index-DtqIOAjg.mjs → index-CxQ-swIQ.mjs} +1 -1
- package/lib/index-Cxw9PIcl.js +531 -0
- package/lib/{index-CGdGYg5B.mjs → index-D0XcjaUl.mjs} +2 -2
- package/lib/{index-B9FwYN90.js → index-D7IcLxQc.js} +1 -1
- package/lib/index-DAzDpd7U.js +14 -0
- package/lib/{index-jC1hUxPJ.mjs → index-DB_r424l.mjs} +1 -1
- package/lib/{index-C_2eG0Va.mjs → index-DECw2aR6.mjs} +1 -1
- package/lib/{index-CuPOodtE.js → index-DGgQSMuG.js} +1 -1
- package/lib/{index-BsmdxKnE.mjs → index-DIAuhm70.mjs} +3008 -3525
- package/lib/{index-CuWt4RaJ.js → index-DOXMkFA4.js} +1 -1
- package/lib/{index-BGZONAdj.js → index-DQVQrflZ.js} +1 -1
- package/lib/{index-GM4m48QO.js → index-DUXnbpVg.js} +1 -1
- package/lib/{index-DUGwXho3.js → index-DZvLy2Dr.js} +3 -3
- package/lib/{index-BsYhqVq_.js → index-DjkMeATf.js} +1 -1
- package/lib/{index-C0MgLwy8.js → index-DleO04Ea.js} +1 -1
- package/lib/{index-HeldZ3mJ.mjs → index-InC6In6o.mjs} +2 -2
- package/lib/{index-CkUMgihl.js → index-V7kxzAZX.js} +1 -1
- package/lib/{index-B5TOuhBB.js → index-WLqZ1uO7.js} +1 -1
- package/lib/{index-Cf2BEUjb.mjs → index-gd_dleYk.mjs} +1 -1
- package/lib/{index-CayMgbM_.js → index-l0NqjNj9.js} +1 -1
- package/lib/{index-wAClTIQn.mjs → index-lEBTHIqm.mjs} +2 -2
- package/lib/{index-DsYAlD9Y.mjs → index-lHA40g0z.mjs} +2 -2
- package/lib/index-oPxOJfPK.mjs +3236 -0
- package/lib/{index-ChzkRsG0.js → index-rFhS51F6.js} +1 -1
- package/lib/{index-DXIpHh2N.mjs → index-y_DeeCWD.mjs} +4 -4
- package/lib/index.es-Doowrf9a.js +46 -0
- package/lib/index.es-YqKQxHG6.mjs +7725 -0
- package/lib/index.js +1 -1
- package/lib/index.mjs +1 -1
- package/lib/{signer-BBJR-S7u.mjs → signer-CfU9wW3f.mjs} +1 -1
- package/lib/{signer-D8m72nd4.js → signer-eoVHaZz7.js} +1 -1
- package/lib/{solana-DB5vwgKO.mjs → solana-CHUnEnef.mjs} +4 -4
- package/lib/{solana-tZZpsxE8.js → solana-C_d_AKET.js} +1 -1
- package/lib/solana-SFHXHGL2.js +1 -0
- package/lib/{solana-DdLCPKF2.mjs → solana-y-l38J4U.mjs} +5 -5
- package/lib/{solanaEmbed.esm-TpsYEDsw.js → solanaEmbed.esm-B4tNQ7S7.js} +10 -10
- package/lib/{solanaEmbed.esm-ANGjgiaN.mjs → solanaEmbed.esm-DVOHg5WI.mjs} +1559 -1560
- package/lib/{sui-BFNsLy1t.mjs → sui-1fbLRIUL.mjs} +5 -5
- package/lib/{sui-UELhAZj0.js → sui-BN1m6APK.js} +1 -1
- package/lib/{sui-DKw9LmTC.mjs → sui-D9frS9ki.mjs} +1 -1
- package/lib/{sui-D9F11hKw.js → sui-K20aVxqE.js} +2 -2
- package/package.json +5 -1
- package/dist/assets/index-BUd_4Lqz.js +0 -14
- package/dist/assets/index-Db_i6Hbk.js +0 -531
- package/dist/assets/index.es-BYwyqXqm.js +0 -47
- package/lib/index-5EBn2EJL.mjs +0 -2709
- package/lib/index-CYpOkqEl.js +0 -14
- package/lib/index-Cst2493l.js +0 -531
- package/lib/index.es-DG7BWZ8R.js +0 -46
- package/lib/index.es-IbuqEs8_.mjs +0 -8242
- package/lib/solana-521ACL4P.js +0 -1
package/lib/index.es-DG7BWZ8R.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Ve=require("./events-D4Mv_WYU.js"),K=require("./index-DUGwXho3.js"),Ke=require("./evm-BJL8RjTB.js"),q=require("./index-BGZONAdj.js"),S=require("./index-CYpOkqEl.js");var ne={};Object.defineProperty(ne,"__esModule",{value:!0});ne.getLocalStorage=ne.getLocalStorageOrThrow=ne.getCrypto=ne.getCryptoOrThrow=ne.getLocation=ne.getLocationOrThrow=ne.getNavigator=ne.getNavigatorOrThrow=ne.getDocument=ne.getDocumentOrThrow=ne.getFromWindowOrThrow=ne.getFromWindow=void 0;function ar(o){let t;return typeof window<"u"&&typeof window[o]<"u"&&(t=window[o]),t}ne.getFromWindow=ar;function Ar(o){const t=ar(o);if(!t)throw new Error(`${o} is not defined in Window`);return t}ne.getFromWindowOrThrow=Ar;function pw(){return Ar("document")}ne.getDocumentOrThrow=pw;function fw(){return ar("document")}ne.getDocument=fw;function dw(){return Ar("navigator")}ne.getNavigatorOrThrow=dw;function gw(){return ar("navigator")}ne.getNavigator=gw;function mw(){return Ar("location")}ne.getLocationOrThrow=mw;function yw(){return ar("location")}ne.getLocation=yw;function vw(){return Ar("crypto")}ne.getCryptoOrThrow=vw;function ww(){return ar("crypto")}ne.getCrypto=ww;function _w(){return Ar("localStorage")}ne.getLocalStorageOrThrow=_w;function bw(){return ar("localStorage")}ne.getLocalStorage=bw;var To={};Object.defineProperty(To,"__esModule",{value:!0});To.getWindowMetadata=void 0;const bu=ne;function Ew(){let o,t;try{o=bu.getDocumentOrThrow(),t=bu.getLocationOrThrow()}catch{return null}function r(){const _=o.getElementsByTagName("link"),I=[];for(let T=0;T<_.length;T++){const C=_[T],U=C.getAttribute("rel");if(U&&U.toLowerCase().indexOf("icon")>-1){const D=C.getAttribute("href");if(D)if(D.toLowerCase().indexOf("https:")===-1&&D.toLowerCase().indexOf("http:")===-1&&D.indexOf("//")!==0){let B=t.protocol+"//"+t.host;if(D.indexOf("/")===0)B+=D;else{const ae=t.pathname.split("/");ae.pop();const Z=ae.join("/");B+=Z+"/"+D}I.push(B)}else if(D.indexOf("//")===0){const B=t.protocol+D;I.push(B)}else I.push(D)}}return I}function s(..._){const I=o.getElementsByTagName("meta");for(let T=0;T<I.length;T++){const C=I[T],U=["itemprop","property","name"].map(D=>C.getAttribute(D)).filter(D=>D?_.includes(D):!1);if(U.length&&U){const D=C.getAttribute("content");if(D)return D}}return""}function a(){let _=s("name","og:site_name","og:title","twitter:title");return _||(_=o.title),_}function u(){return s("description","og:description","twitter:description","keywords")}const l=a(),g=u(),v=t.origin,d=r();return{description:g,url:v,icons:d,name:l}}To.getWindowMetadata=Ew;function Iw(o,t=[]){const r=[];return Object.keys(o).forEach(s=>{if(t.length&&!t.includes(s))return;const a=o[s];r.push(...a.accounts)}),r}const Pw={INVALID_METHOD:{message:"Invalid method.",code:1001},INVALID_EVENT:{message:"Invalid event.",code:1002},INVALID_UPDATE_REQUEST:{message:"Invalid update request.",code:1003},INVALID_EXTEND_REQUEST:{message:"Invalid extend request.",code:1004},INVALID_SESSION_SETTLE_REQUEST:{message:"Invalid session settle request.",code:1005},UNAUTHORIZED_METHOD:{message:"Unauthorized method.",code:3001},UNAUTHORIZED_EVENT:{message:"Unauthorized event.",code:3002},UNAUTHORIZED_UPDATE_REQUEST:{message:"Unauthorized update request.",code:3003},UNAUTHORIZED_EXTEND_REQUEST:{message:"Unauthorized extend request.",code:3004},USER_REJECTED:{message:"User rejected.",code:5e3},USER_REJECTED_CHAINS:{message:"User rejected chains.",code:5001},USER_REJECTED_METHODS:{message:"User rejected methods.",code:5002},USER_REJECTED_EVENTS:{message:"User rejected events.",code:5003},UNSUPPORTED_CHAINS:{message:"Unsupported chains.",code:5100},UNSUPPORTED_METHODS:{message:"Unsupported methods.",code:5101},UNSUPPORTED_EVENTS:{message:"Unsupported events.",code:5102},UNSUPPORTED_ACCOUNTS:{message:"Unsupported accounts.",code:5103},UNSUPPORTED_NAMESPACE_KEY:{message:"Unsupported namespace key.",code:5104},USER_DISCONNECTED:{message:"User disconnected.",code:6e3},SESSION_SETTLEMENT_FAILED:{message:"Session settlement failed.",code:7e3},WC_METHOD_UNSUPPORTED:{message:"Unsupported wc_ method.",code:10001}};function Sw(o,t){const{message:r,code:s}=Pw[o];return{message:r,code:s}}function vo(o,t){return!!Array.isArray(o)}function Ow(o){return!o||typeof o.then!="function"?Promise.resolve(o):o}function Ee(o,...t){try{return Ow(o(...t))}catch(r){return Promise.reject(r)}}function Rw(o){const t=typeof o;return o===null||t!=="object"&&t!=="function"}function $w(o){const t=Object.getPrototypeOf(o);return!t||t.isPrototypeOf(Object)}function _s(o){if(Rw(o))return String(o);if($w(o)||Array.isArray(o))return JSON.stringify(o);if(typeof o.toJSON=="function")return _s(o.toJSON());throw new Error("[unstorage] Cannot stringify value!")}const wo="base64:";function Nw(o){return typeof o=="string"?o:wo+Aw(o)}function Cw(o){return typeof o!="string"||!o.startsWith(wo)?o:Tw(o.slice(wo.length))}function Tw(o){return globalThis.Buffer?K.dist.Buffer.from(o,"base64"):Uint8Array.from(globalThis.atob(o),t=>t.codePointAt(0))}function Aw(o){return globalThis.Buffer?K.dist.Buffer.from(o).toString("base64"):globalThis.btoa(String.fromCodePoint(...o))}function ze(o){var t;return o&&((t=o.split("?")[0])==null?void 0:t.replace(/[/\\]/g,":").replace(/:+/g,":").replace(/^:|:$/g,""))||""}function xw(...o){return ze(o.join(":"))}function gs(o){return o=ze(o),o?o+":":""}const Dw="memory",jw=()=>{const o=new Map;return{name:Dw,getInstance:()=>o,hasItem(t){return o.has(t)},getItem(t){return o.get(t)??null},getItemRaw(t){return o.get(t)??null},setItem(t,r){o.set(t,r)},setItemRaw(t,r){o.set(t,r)},removeItem(t){o.delete(t)},getKeys(){return[...o.keys()]},clear(){o.clear()},dispose(){o.clear()}}};function Fw(o={}){const t={mounts:{"":o.driver||jw()},mountpoints:[""],watching:!1,watchListeners:[],unwatch:{}},r=d=>{for(const E of t.mountpoints)if(d.startsWith(E))return{base:E,relativeKey:d.slice(E.length),driver:t.mounts[E]};return{base:"",relativeKey:d,driver:t.mounts[""]}},s=(d,E)=>t.mountpoints.filter(_=>_.startsWith(d)||E&&d.startsWith(_)).map(_=>({relativeBase:d.length>_.length?d.slice(_.length):void 0,mountpoint:_,driver:t.mounts[_]})),a=(d,E)=>{if(t.watching){E=ze(E);for(const _ of t.watchListeners)_(d,E)}},u=async()=>{if(!t.watching){t.watching=!0;for(const d in t.mounts)t.unwatch[d]=await Eu(t.mounts[d],a,d)}},l=async()=>{if(t.watching){for(const d in t.unwatch)await t.unwatch[d]();t.unwatch={},t.watching=!1}},g=(d,E,_)=>{const I=new Map,T=C=>{let U=I.get(C.base);return U||(U={driver:C.driver,base:C.base,items:[]},I.set(C.base,U)),U};for(const C of d){const U=typeof C=="string",D=ze(U?C:C.key),B=U?void 0:C.value,ae=U||!C.options?E:{...E,...C.options},Z=r(D);T(Z).items.push({key:D,value:B,relativeKey:Z.relativeKey,options:ae})}return Promise.all([...I.values()].map(C=>_(C))).then(C=>C.flat())},v={hasItem(d,E={}){d=ze(d);const{relativeKey:_,driver:I}=r(d);return Ee(I.hasItem,_,E)},getItem(d,E={}){d=ze(d);const{relativeKey:_,driver:I}=r(d);return Ee(I.getItem,_,E).then(T=>S.destr(T))},getItems(d,E={}){return g(d,E,_=>_.driver.getItems?Ee(_.driver.getItems,_.items.map(I=>({key:I.relativeKey,options:I.options})),E).then(I=>I.map(T=>({key:xw(_.base,T.key),value:S.destr(T.value)}))):Promise.all(_.items.map(I=>Ee(_.driver.getItem,I.relativeKey,I.options).then(T=>({key:I.key,value:S.destr(T)})))))},getItemRaw(d,E={}){d=ze(d);const{relativeKey:_,driver:I}=r(d);return I.getItemRaw?Ee(I.getItemRaw,_,E):Ee(I.getItem,_,E).then(T=>Cw(T))},async setItem(d,E,_={}){if(E===void 0)return v.removeItem(d);d=ze(d);const{relativeKey:I,driver:T}=r(d);T.setItem&&(await Ee(T.setItem,I,_s(E),_),T.watch||a("update",d))},async setItems(d,E){await g(d,E,async _=>{if(_.driver.setItems)return Ee(_.driver.setItems,_.items.map(I=>({key:I.relativeKey,value:_s(I.value),options:I.options})),E);_.driver.setItem&&await Promise.all(_.items.map(I=>Ee(_.driver.setItem,I.relativeKey,_s(I.value),I.options)))})},async setItemRaw(d,E,_={}){if(E===void 0)return v.removeItem(d,_);d=ze(d);const{relativeKey:I,driver:T}=r(d);if(T.setItemRaw)await Ee(T.setItemRaw,I,E,_);else if(T.setItem)await Ee(T.setItem,I,Nw(E),_);else return;T.watch||a("update",d)},async removeItem(d,E={}){typeof E=="boolean"&&(E={removeMeta:E}),d=ze(d);const{relativeKey:_,driver:I}=r(d);I.removeItem&&(await Ee(I.removeItem,_,E),(E.removeMeta||E.removeMata)&&await Ee(I.removeItem,_+"$",E),I.watch||a("remove",d))},async getMeta(d,E={}){typeof E=="boolean"&&(E={nativeOnly:E}),d=ze(d);const{relativeKey:_,driver:I}=r(d),T=Object.create(null);if(I.getMeta&&Object.assign(T,await Ee(I.getMeta,_,E)),!E.nativeOnly){const C=await Ee(I.getItem,_+"$",E).then(U=>S.destr(U));C&&typeof C=="object"&&(typeof C.atime=="string"&&(C.atime=new Date(C.atime)),typeof C.mtime=="string"&&(C.mtime=new Date(C.mtime)),Object.assign(T,C))}return T},setMeta(d,E,_={}){return this.setItem(d+"$",E,_)},removeMeta(d,E={}){return this.removeItem(d+"$",E)},async getKeys(d,E={}){d=gs(d);const _=s(d,!0);let I=[];const T=[];for(const C of _){const U=await Ee(C.driver.getKeys,C.relativeBase,E);for(const D of U){const B=C.mountpoint+ze(D);I.some(ae=>B.startsWith(ae))||T.push(B)}I=[C.mountpoint,...I.filter(D=>!D.startsWith(C.mountpoint))]}return d?T.filter(C=>C.startsWith(d)&&C[C.length-1]!=="$"):T.filter(C=>C[C.length-1]!=="$")},async clear(d,E={}){d=gs(d),await Promise.all(s(d,!1).map(async _=>{if(_.driver.clear)return Ee(_.driver.clear,_.relativeBase,E);if(_.driver.removeItem){const I=await _.driver.getKeys(_.relativeBase||"",E);return Promise.all(I.map(T=>_.driver.removeItem(T,E)))}}))},async dispose(){await Promise.all(Object.values(t.mounts).map(d=>Iu(d)))},async watch(d){return await u(),t.watchListeners.push(d),async()=>{t.watchListeners=t.watchListeners.filter(E=>E!==d),t.watchListeners.length===0&&await l()}},async unwatch(){t.watchListeners=[],await l()},mount(d,E){if(d=gs(d),d&&t.mounts[d])throw new Error(`already mounted at ${d}`);return d&&(t.mountpoints.push(d),t.mountpoints.sort((_,I)=>I.length-_.length)),t.mounts[d]=E,t.watching&&Promise.resolve(Eu(E,a,d)).then(_=>{t.unwatch[d]=_}).catch(console.error),v},async unmount(d,E=!0){var _,I;d=gs(d),!(!d||!t.mounts[d])&&(t.watching&&d in t.unwatch&&((I=(_=t.unwatch)[d])==null||I.call(_),delete t.unwatch[d]),E&&await Iu(t.mounts[d]),t.mountpoints=t.mountpoints.filter(T=>T!==d),delete t.mounts[d])},getMount(d=""){d=ze(d)+":";const E=r(d);return{driver:E.driver,base:E.base}},getMounts(d="",E={}){return d=ze(d),s(d,E.parents).map(I=>({driver:I.driver,base:I.mountpoint}))},keys:(d,E={})=>v.getKeys(d,E),get:(d,E={})=>v.getItem(d,E),set:(d,E,_={})=>v.setItem(d,E,_),has:(d,E={})=>v.hasItem(d,E),del:(d,E={})=>v.removeItem(d,E),remove:(d,E={})=>v.removeItem(d,E)};return v}function Eu(o,t,r){return o.watch?o.watch((s,a)=>t(s,r+a)):()=>{}}async function Iu(o){typeof o.dispose=="function"&&await Ee(o.dispose)}const qw=o=>JSON.stringify(o,(t,r)=>typeof r=="bigint"?r.toString()+"n":r),Uw=o=>{const t=/([\[:])?(\d{17,}|(?:[9](?:[1-9]07199254740991|0[1-9]7199254740991|00[8-9]199254740991|007[2-9]99254740991|007199[3-9]54740991|0071992[6-9]4740991|00719925[5-9]740991|007199254[8-9]40991|0071992547[5-9]0991|00719925474[1-9]991|00719925474099[2-9])))([,\}\]])/g,r=o.replace(t,'$1"$2n"$3');return JSON.parse(r,(s,a)=>typeof a=="string"&&a.match(/^\d+n$/)?BigInt(a.substring(0,a.length-1)):a)};function Ns(o){if(typeof o!="string")throw new Error(`Cannot safe json parse value of type ${typeof o}`);try{return Uw(o)}catch{return o}}function Cs(o){return typeof o=="string"?o:qw(o)||""}const Mw="idb-keyval";var Lw=(o={})=>{const t=o.base&&o.base.length>0?`${o.base}:`:"",r=a=>t+a;let s;return o.dbName&&o.storeName&&(s=S.createStore(o.dbName,o.storeName)),{name:Mw,options:o,async hasItem(a){return!(typeof await S.get(r(a),s)>"u")},async getItem(a){return await S.get(r(a),s)??null},setItem(a,u){return S.set(r(a),u,s)},removeItem(a){return S.del(r(a),s)},getKeys(){return S.keys(s)},clear(){return S.clear(s)}}};const kw="WALLET_CONNECT_V2_INDEXED_DB",zw="keyvaluestorage";let Hw=class{constructor(){this.indexedDb=Fw({driver:Lw({dbName:kw,storeName:zw})})}async getKeys(){return this.indexedDb.getKeys()}async getEntries(){return(await this.indexedDb.getItems(await this.indexedDb.getKeys())).map(t=>[t.key,t.value])}async getItem(t){const r=await this.indexedDb.getItem(t);if(r!==null)return r}async setItem(t,r){await this.indexedDb.setItem(t,Cs(r))}async removeItem(t){await this.indexedDb.removeItem(t)}};var io=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof K.dist.global<"u"?K.dist.global:typeof self<"u"?self:{},bs={exports:{}};(function(){let o;function t(){}o=t,o.prototype.getItem=function(r){return this.hasOwnProperty(r)?String(this[r]):null},o.prototype.setItem=function(r,s){this[r]=String(s)},o.prototype.removeItem=function(r){delete this[r]},o.prototype.clear=function(){const r=this;Object.keys(r).forEach(function(s){r[s]=void 0,delete r[s]})},o.prototype.key=function(r){return r=r||0,Object.keys(this)[r]},o.prototype.__defineGetter__("length",function(){return Object.keys(this).length}),typeof io<"u"&&io.localStorage?bs.exports=io.localStorage:typeof window<"u"&&window.localStorage?bs.exports=window.localStorage:bs.exports=new t})();function Kw(o){var t;return[o[0],Ns((t=o[1])!=null?t:"")]}let Vw=class{constructor(){this.localStorage=bs.exports}async getKeys(){return Object.keys(this.localStorage)}async getEntries(){return Object.entries(this.localStorage).map(Kw)}async getItem(t){const r=this.localStorage.getItem(t);if(r!==null)return Ns(r)}async setItem(t,r){this.localStorage.setItem(t,Cs(r))}async removeItem(t){this.localStorage.removeItem(t)}};const Bw="wc_storage_version",Pu=1,Ww=async(o,t,r)=>{const s=Bw,a=await t.getItem(s);if(a&&a>=Pu){r(t);return}const u=await o.getKeys();if(!u.length){r(t);return}const l=[];for(;u.length;){const g=u.shift();if(!g)continue;const v=g.toLowerCase();if(v.includes("wc@")||v.includes("walletconnect")||v.includes("wc_")||v.includes("wallet_connect")){const d=await o.getItem(g);await t.setItem(g,d),l.push(g)}}await t.setItem(s,Pu),r(t),Jw(o,l)},Jw=async(o,t)=>{t.length&&t.forEach(async r=>{await o.removeItem(r)})};let Gw=class{constructor(){this.initialized=!1,this.setInitialized=r=>{this.storage=r,this.initialized=!0};const t=new Vw;this.storage=t;try{const r=new Hw;Ww(t,r,this.setInitialized)}catch{this.initialized=!0}}async getKeys(){return await this.initialize(),this.storage.getKeys()}async getEntries(){return await this.initialize(),this.storage.getEntries()}async getItem(t){return await this.initialize(),this.storage.getItem(t)}async setItem(t,r){return await this.initialize(),this.storage.setItem(t,r)}async removeItem(t){return await this.initialize(),this.storage.removeItem(t)}async initialize(){this.initialized||await new Promise(t=>{const r=setInterval(()=>{this.initialized&&(clearInterval(r),t())},20)})}};var xr={};/*! *****************************************************************************
|
|
2
|
-
Copyright (c) Microsoft Corporation.
|
|
3
|
-
|
|
4
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
5
|
-
purpose with or without fee is hereby granted.
|
|
6
|
-
|
|
7
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
8
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
9
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
10
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
11
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
12
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
13
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
14
|
-
***************************************************************************** */var _o=function(o,t){return _o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,s){r.__proto__=s}||function(r,s){for(var a in s)s.hasOwnProperty(a)&&(r[a]=s[a])},_o(o,t)};function Qw(o,t){_o(o,t);function r(){this.constructor=o}o.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}var bo=function(){return bo=Object.assign||function(t){for(var r,s=1,a=arguments.length;s<a;s++){r=arguments[s];for(var u in r)Object.prototype.hasOwnProperty.call(r,u)&&(t[u]=r[u])}return t},bo.apply(this,arguments)};function Yw(o,t){var r={};for(var s in o)Object.prototype.hasOwnProperty.call(o,s)&&t.indexOf(s)<0&&(r[s]=o[s]);if(o!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,s=Object.getOwnPropertySymbols(o);a<s.length;a++)t.indexOf(s[a])<0&&Object.prototype.propertyIsEnumerable.call(o,s[a])&&(r[s[a]]=o[s[a]]);return r}function Zw(o,t,r,s){var a=arguments.length,u=a<3?t:s===null?s=Object.getOwnPropertyDescriptor(t,r):s,l;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")u=Reflect.decorate(o,t,r,s);else for(var g=o.length-1;g>=0;g--)(l=o[g])&&(u=(a<3?l(u):a>3?l(t,r,u):l(t,r))||u);return a>3&&u&&Object.defineProperty(t,r,u),u}function Xw(o,t){return function(r,s){t(r,s,o)}}function e_(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)}function t_(o,t,r,s){function a(u){return u instanceof r?u:new r(function(l){l(u)})}return new(r||(r=Promise))(function(u,l){function g(E){try{d(s.next(E))}catch(_){l(_)}}function v(E){try{d(s.throw(E))}catch(_){l(_)}}function d(E){E.done?u(E.value):a(E.value).then(g,v)}d((s=s.apply(o,t||[])).next())})}function r_(o,t){var r={label:0,sent:function(){if(u[0]&1)throw u[1];return u[1]},trys:[],ops:[]},s,a,u,l;return l={next:g(0),throw:g(1),return:g(2)},typeof Symbol=="function"&&(l[Symbol.iterator]=function(){return this}),l;function g(d){return function(E){return v([d,E])}}function v(d){if(s)throw new TypeError("Generator is already executing.");for(;r;)try{if(s=1,a&&(u=d[0]&2?a.return:d[0]?a.throw||((u=a.return)&&u.call(a),0):a.next)&&!(u=u.call(a,d[1])).done)return u;switch(a=0,u&&(d=[d[0]&2,u.value]),d[0]){case 0:case 1:u=d;break;case 4:return r.label++,{value:d[1],done:!1};case 5:r.label++,a=d[1],d=[0];continue;case 7:d=r.ops.pop(),r.trys.pop();continue;default:if(u=r.trys,!(u=u.length>0&&u[u.length-1])&&(d[0]===6||d[0]===2)){r=0;continue}if(d[0]===3&&(!u||d[1]>u[0]&&d[1]<u[3])){r.label=d[1];break}if(d[0]===6&&r.label<u[1]){r.label=u[1],u=d;break}if(u&&r.label<u[2]){r.label=u[2],r.ops.push(d);break}u[2]&&r.ops.pop(),r.trys.pop();continue}d=t.call(o,r)}catch(E){d=[6,E],a=0}finally{s=u=0}if(d[0]&5)throw d[1];return{value:d[0]?d[1]:void 0,done:!0}}}function i_(o,t,r,s){s===void 0&&(s=r),o[s]=t[r]}function s_(o,t){for(var r in o)r!=="default"&&!t.hasOwnProperty(r)&&(t[r]=o[r])}function Eo(o){var t=typeof Symbol=="function"&&Symbol.iterator,r=t&&o[t],s=0;if(r)return r.call(o);if(o&&typeof o.length=="number")return{next:function(){return o&&s>=o.length&&(o=void 0),{value:o&&o[s++],done:!o}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Th(o,t){var r=typeof Symbol=="function"&&o[Symbol.iterator];if(!r)return o;var s=r.call(o),a,u=[],l;try{for(;(t===void 0||t-- >0)&&!(a=s.next()).done;)u.push(a.value)}catch(g){l={error:g}}finally{try{a&&!a.done&&(r=s.return)&&r.call(s)}finally{if(l)throw l.error}}return u}function n_(){for(var o=[],t=0;t<arguments.length;t++)o=o.concat(Th(arguments[t]));return o}function o_(){for(var o=0,t=0,r=arguments.length;t<r;t++)o+=arguments[t].length;for(var s=Array(o),a=0,t=0;t<r;t++)for(var u=arguments[t],l=0,g=u.length;l<g;l++,a++)s[a]=u[l];return s}function mi(o){return this instanceof mi?(this.v=o,this):new mi(o)}function a_(o,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var s=r.apply(o,t||[]),a,u=[];return a={},l("next"),l("throw"),l("return"),a[Symbol.asyncIterator]=function(){return this},a;function l(I){s[I]&&(a[I]=function(T){return new Promise(function(C,U){u.push([I,T,C,U])>1||g(I,T)})})}function g(I,T){try{v(s[I](T))}catch(C){_(u[0][3],C)}}function v(I){I.value instanceof mi?Promise.resolve(I.value.v).then(d,E):_(u[0][2],I)}function d(I){g("next",I)}function E(I){g("throw",I)}function _(I,T){I(T),u.shift(),u.length&&g(u[0][0],u[0][1])}}function c_(o){var t,r;return t={},s("next"),s("throw",function(a){throw a}),s("return"),t[Symbol.iterator]=function(){return this},t;function s(a,u){t[a]=o[a]?function(l){return(r=!r)?{value:mi(o[a](l)),done:a==="return"}:u?u(l):l}:u}}function u_(o){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=o[Symbol.asyncIterator],r;return t?t.call(o):(o=typeof Eo=="function"?Eo(o):o[Symbol.iterator](),r={},s("next"),s("throw"),s("return"),r[Symbol.asyncIterator]=function(){return this},r);function s(u){r[u]=o[u]&&function(l){return new Promise(function(g,v){l=o[u](l),a(g,v,l.done,l.value)})}}function a(u,l,g,v){Promise.resolve(v).then(function(d){u({value:d,done:g})},l)}}function h_(o,t){return Object.defineProperty?Object.defineProperty(o,"raw",{value:t}):o.raw=t,o}function l_(o){if(o&&o.__esModule)return o;var t={};if(o!=null)for(var r in o)Object.hasOwnProperty.call(o,r)&&(t[r]=o[r]);return t.default=o,t}function p_(o){return o&&o.__esModule?o:{default:o}}function f_(o,t){if(!t.has(o))throw new TypeError("attempted to get private field on non-instance");return t.get(o)}function d_(o,t,r){if(!t.has(o))throw new TypeError("attempted to set private field on non-instance");return t.set(o,r),r}const g_=Object.freeze(Object.defineProperty({__proto__:null,get __assign(){return bo},__asyncDelegator:c_,__asyncGenerator:a_,__asyncValues:u_,__await:mi,__awaiter:t_,__classPrivateFieldGet:f_,__classPrivateFieldSet:d_,__createBinding:i_,__decorate:Zw,__exportStar:s_,__extends:Qw,__generator:r_,__importDefault:p_,__importStar:l_,__makeTemplateObject:h_,__metadata:e_,__param:Xw,__read:Th,__rest:Yw,__spread:n_,__spreadArrays:o_,__values:Eo},Symbol.toStringTag,{value:"Module"})),Ts=K.getAugmentedNamespace(g_);var oi={},so={},ai={};const m_=Object.freeze(Object.defineProperty({__proto__:null,IEvents:S.IEvents},Symbol.toStringTag,{value:"Module"})),y_=K.getAugmentedNamespace(m_);var Su;function v_(){if(Su)return ai;Su=1,Object.defineProperty(ai,"__esModule",{value:!0}),ai.IHeartBeat=void 0;const o=y_;class t extends o.IEvents{constructor(s){super()}}return ai.IHeartBeat=t,ai}var Ou;function Ah(){return Ou||(Ou=1,function(o){Object.defineProperty(o,"__esModule",{value:!0}),Ts.__exportStar(v_(),o)}(so)),so}var no={},sr={},Ru;function w_(){if(Ru)return sr;Ru=1,Object.defineProperty(sr,"__esModule",{value:!0}),sr.HEARTBEAT_EVENTS=sr.HEARTBEAT_INTERVAL=void 0;const o=q.cjs;return sr.HEARTBEAT_INTERVAL=o.FIVE_SECONDS,sr.HEARTBEAT_EVENTS={pulse:"heartbeat_pulse"},sr}var $u;function xh(){return $u||($u=1,function(o){Object.defineProperty(o,"__esModule",{value:!0}),Ts.__exportStar(w_(),o)}(no)),no}var Nu;function __(){if(Nu)return oi;Nu=1,Object.defineProperty(oi,"__esModule",{value:!0}),oi.HeartBeat=void 0;const o=Ts,t=K.requireEvents(),r=q.cjs,s=Ah(),a=xh();class u extends s.IHeartBeat{constructor(g){super(g),this.events=new t.EventEmitter,this.interval=a.HEARTBEAT_INTERVAL,this.interval=(g==null?void 0:g.interval)||a.HEARTBEAT_INTERVAL}static init(g){return o.__awaiter(this,void 0,void 0,function*(){const v=new u(g);return yield v.init(),v})}init(){return o.__awaiter(this,void 0,void 0,function*(){yield this.initialize()})}stop(){clearInterval(this.intervalRef)}on(g,v){this.events.on(g,v)}once(g,v){this.events.once(g,v)}off(g,v){this.events.off(g,v)}removeListener(g,v){this.events.removeListener(g,v)}initialize(){return o.__awaiter(this,void 0,void 0,function*(){this.intervalRef=setInterval(()=>this.pulse(),r.toMiliseconds(this.interval))})}pulse(){this.events.emit(a.HEARTBEAT_EVENTS.pulse)}}return oi.HeartBeat=u,oi}(function(o){Object.defineProperty(o,"__esModule",{value:!0});const t=Ts;t.__exportStar(__(),o),t.__exportStar(Ah(),o),t.__exportStar(xh(),o)})(xr);class b_ extends S.IEvents{constructor(t){super(),this.opts=t,this.protocol="wc",this.version=2}}let E_=class extends S.IEvents{constructor(t,r){super(),this.core=t,this.logger=r,this.records=new Map}},I_=class{constructor(t,r){this.logger=t,this.core=r}},P_=class extends S.IEvents{constructor(t,r){super(),this.relayer=t,this.logger=r}},S_=class extends S.IEvents{constructor(t){super()}},O_=class{constructor(t,r,s,a){this.core=t,this.logger=r,this.name=s}},R_=class extends S.IEvents{constructor(t,r){super(),this.relayer=t,this.logger=r}},$_=class extends S.IEvents{constructor(t,r){super(),this.core=t,this.logger=r}},N_=class{constructor(t,r){this.projectId=t,this.logger=r}},C_=class{constructor(t,r){this.projectId=t,this.logger=r}},T_=class{constructor(t){this.opts=t,this.protocol="wc",this.version=2}},A_=class{constructor(t){this.client=t}};var oe={};Object.defineProperty(oe,"__esModule",{value:!0});oe.getLocalStorage=oe.getLocalStorageOrThrow=oe.getCrypto=oe.getCryptoOrThrow=Dh=oe.getLocation=oe.getLocationOrThrow=xo=oe.getNavigator=oe.getNavigatorOrThrow=Ao=oe.getDocument=oe.getDocumentOrThrow=oe.getFromWindowOrThrow=oe.getFromWindow=void 0;function cr(o){let t;return typeof window<"u"&&typeof window[o]<"u"&&(t=window[o]),t}oe.getFromWindow=cr;function Dr(o){const t=cr(o);if(!t)throw new Error(`${o} is not defined in Window`);return t}oe.getFromWindowOrThrow=Dr;function x_(){return Dr("document")}oe.getDocumentOrThrow=x_;function D_(){return cr("document")}var Ao=oe.getDocument=D_;function j_(){return Dr("navigator")}oe.getNavigatorOrThrow=j_;function F_(){return cr("navigator")}var xo=oe.getNavigator=F_;function q_(){return Dr("location")}oe.getLocationOrThrow=q_;function U_(){return cr("location")}var Dh=oe.getLocation=U_;function M_(){return Dr("crypto")}oe.getCryptoOrThrow=M_;function L_(){return cr("crypto")}oe.getCrypto=L_;function k_(){return Dr("localStorage")}oe.getLocalStorageOrThrow=k_;function z_(){return cr("localStorage")}oe.getLocalStorage=z_;var Do={};Object.defineProperty(Do,"__esModule",{value:!0});var jh=Do.getWindowMetadata=void 0;const Cu=oe;function H_(){let o,t;try{o=Cu.getDocumentOrThrow(),t=Cu.getLocationOrThrow()}catch{return null}function r(){const _=o.getElementsByTagName("link"),I=[];for(let T=0;T<_.length;T++){const C=_[T],U=C.getAttribute("rel");if(U&&U.toLowerCase().indexOf("icon")>-1){const D=C.getAttribute("href");if(D)if(D.toLowerCase().indexOf("https:")===-1&&D.toLowerCase().indexOf("http:")===-1&&D.indexOf("//")!==0){let B=t.protocol+"//"+t.host;if(D.indexOf("/")===0)B+=D;else{const ae=t.pathname.split("/");ae.pop();const Z=ae.join("/");B+=Z+"/"+D}I.push(B)}else if(D.indexOf("//")===0){const B=t.protocol+D;I.push(B)}else I.push(D)}}return I}function s(..._){const I=o.getElementsByTagName("meta");for(let T=0;T<I.length;T++){const C=I[T],U=["itemprop","property","name"].map(D=>C.getAttribute(D)).filter(D=>D?_.includes(D):!1);if(U.length&&U){const D=C.getAttribute("content");if(D)return D}}return""}function a(){let _=s("name","og:site_name","og:title","twitter:title");return _||(_=o.title),_}function u(){return s("description","og:description","twitter:description","keywords")}const l=a(),g=u(),v=t.origin,d=r();return{description:g,url:v,icons:d,name:l}}jh=Do.getWindowMetadata=H_;const K_=":";function V_(o){const[t,r]=o.split(K_);return{namespace:t,reference:r}}function Fh(o,t){return o.includes(":")?[o]:t.chains||[]}const qh="base10",je="base16",Io="base64pad",jo="utf8",Uh=0,ur=1,B_=0,Tu=1,Po=12,Fo=32;function W_(){const o=Ke.x25519.generateKeyPair();return{privateKey:S.toString(o.secretKey,je),publicKey:S.toString(o.publicKey,je)}}function So(){const o=Ke.random.randomBytes(Fo);return S.toString(o,je)}function J_(o,t){const r=Ke.x25519.sharedKey(S.fromString(o,je),S.fromString(t,je),!0),s=new Ke.HKDF_1(Ke.sha256.SHA256,r).expand(Fo);return S.toString(s,je)}function G_(o){const t=Ke.sha256.hash(S.fromString(o,je));return S.toString(t,je)}function Cr(o){const t=Ke.sha256.hash(S.fromString(o,jo));return S.toString(t,je)}function Q_(o){return S.fromString(`${o}`,qh)}function vi(o){return Number(S.toString(o,qh))}function Y_(o){const t=Q_(typeof o.type<"u"?o.type:Uh);if(vi(t)===ur&&typeof o.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const r=typeof o.senderPublicKey<"u"?S.fromString(o.senderPublicKey,je):void 0,s=typeof o.iv<"u"?S.fromString(o.iv,je):Ke.random.randomBytes(Po),a=new Ke.chacha20poly1305.ChaCha20Poly1305(S.fromString(o.symKey,je)).seal(s,S.fromString(o.message,jo));return X_({type:t,sealed:a,iv:s,senderPublicKey:r})}function Z_(o){const t=new Ke.chacha20poly1305.ChaCha20Poly1305(S.fromString(o.symKey,je)),{sealed:r,iv:s}=Ps(o.encoded),a=t.open(s,r);if(a===null)throw new Error("Failed to decrypt");return S.toString(a,jo)}function X_(o){if(vi(o.type)===ur){if(typeof o.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return S.toString(S.concat([o.type,o.senderPublicKey,o.iv,o.sealed]),Io)}return S.toString(S.concat([o.type,o.iv,o.sealed]),Io)}function Ps(o){const t=S.fromString(o,Io),r=t.slice(B_,Tu),s=Tu;if(vi(r)===ur){const g=s+Fo,v=g+Po,d=t.slice(s,g),E=t.slice(g,v),_=t.slice(v);return{type:r,sealed:_,iv:E,senderPublicKey:d}}const a=s+Po,u=t.slice(s,a),l=t.slice(a);return{type:r,sealed:l,iv:u}}function e1(o,t){const r=Ps(o);return Mh({type:vi(r.type),senderPublicKey:typeof r.senderPublicKey<"u"?S.toString(r.senderPublicKey,je):void 0,receiverPublicKey:t==null?void 0:t.receiverPublicKey})}function Mh(o){const t=(o==null?void 0:o.type)||Uh;if(t===ur){if(typeof(o==null?void 0:o.senderPublicKey)>"u")throw new Error("missing sender public key");if(typeof(o==null?void 0:o.receiverPublicKey)>"u")throw new Error("missing receiver public key")}return{type:t,senderPublicKey:o==null?void 0:o.senderPublicKey,receiverPublicKey:o==null?void 0:o.receiverPublicKey}}function Au(o){return o.type===ur&&typeof o.senderPublicKey=="string"&&typeof o.receiverPublicKey=="string"}var t1=Object.defineProperty,xu=Object.getOwnPropertySymbols,r1=Object.prototype.hasOwnProperty,i1=Object.prototype.propertyIsEnumerable,Du=(o,t,r)=>t in o?t1(o,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[t]=r,ju=(o,t)=>{for(var r in t||(t={}))r1.call(t,r)&&Du(o,r,t[r]);if(xu)for(var r of xu(t))i1.call(t,r)&&Du(o,r,t[r]);return o};const s1="ReactNative",Ze={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},n1="js";function qo(){return typeof K.dist.process<"u"&&typeof K.dist.process.versions<"u"&&typeof K.dist.process.versions.node<"u"}function jr(){return!Ao()&&!!xo()&&navigator.product===s1}function Fr(){return!qo()&&!!xo()&&!!Ao()}function wi(){return jr()?Ze.reactNative:qo()?Ze.node:Fr()?Ze.browser:Ze.unknown}function o1(){var o;try{return jr()&&typeof K.dist.global<"u"&&typeof(K.dist.global==null?void 0:K.dist.global.Application)<"u"?(o=K.dist.global.Application)==null?void 0:o.applicationId:void 0}catch{return}}function a1(o,t){let r=Ke.queryString.parse(o);return r=ju(ju({},r),t),o=Ke.queryString.stringify(r),o}function c1(){return jh()||{name:"",description:"",url:"",icons:[""]}}function u1(){if(wi()===Ze.reactNative&&typeof K.dist.global<"u"&&typeof(K.dist.global==null?void 0:K.dist.global.Platform)<"u"){const{OS:r,Version:s}=K.dist.global.Platform;return[r,s].join("-")}const o=S.detect();if(o===null)return"unknown";const t=o.os?o.os.replace(" ","").toLowerCase():"unknown";return o.type==="browser"?[t,o.name,o.version].join("-"):[t,o.version].join("-")}function h1(){var o;const t=wi();return t===Ze.browser?[t,((o=Dh())==null?void 0:o.host)||"unknown"].join(":"):t}function l1(o,t,r){const s=u1(),a=h1();return[[o,t].join("-"),[n1,r].join("-"),s,a].join("/")}function p1({protocol:o,version:t,relayUrl:r,sdkVersion:s,auth:a,projectId:u,useOnCloseEvent:l,bundleId:g}){const v=r.split("?"),d=l1(o,t,s),E={auth:a,ua:d,projectId:u,useOnCloseEvent:l,origin:g||void 0},_=a1(v[1]||"",E);return v[0]+"?"+_}function nr(o,t){return o.filter(r=>t.includes(r)).length===o.length}function Lh(o){return Object.fromEntries(o.entries())}function kh(o){return new Map(Object.entries(o))}function $r(o=q.cjs.FIVE_MINUTES,t){const r=q.cjs.toMiliseconds(o||q.cjs.FIVE_MINUTES);let s,a,u;return{resolve:l=>{u&&s&&(clearTimeout(u),s(l))},reject:l=>{u&&a&&(clearTimeout(u),a(l))},done:()=>new Promise((l,g)=>{u=setTimeout(()=>{g(new Error(t))},r),s=l,a=g})}}function yi(o,t,r){return new Promise(async(s,a)=>{const u=setTimeout(()=>a(new Error(r)),t);try{const l=await o;s(l)}catch(l){a(l)}clearTimeout(u)})}function zh(o,t){if(typeof t=="string"&&t.startsWith(`${o}:`))return t;if(o.toLowerCase()==="topic"){if(typeof t!="string")throw new Error('Value must be "string" for expirer target type: topic');return`topic:${t}`}else if(o.toLowerCase()==="id"){if(typeof t!="number")throw new Error('Value must be "number" for expirer target type: id');return`id:${t}`}throw new Error(`Unknown expirer target type: ${o}`)}function f1(o){return zh("topic",o)}function d1(o){return zh("id",o)}function Hh(o){const[t,r]=o.split(":"),s={id:void 0,topic:void 0};if(t==="topic"&&typeof r=="string")s.topic=r;else if(t==="id"&&Number.isInteger(Number(r)))s.id=Number(r);else throw new Error(`Invalid target, expected id:number or topic:string, got ${t}:${r}`);return s}function gt(o,t){return q.cjs.fromMiliseconds(Date.now()+q.cjs.toMiliseconds(o))}function Vt(o){return Date.now()>=q.cjs.toMiliseconds(o)}function ve(o,t){return`${o}${t?`:${t}`:""}`}function oo(o=[],t=[]){return[...new Set([...o,...t])]}async function g1({id:o,topic:t,wcDeepLink:r}){try{if(!r)return;const s=typeof r=="string"?JSON.parse(r):r;let a=s==null?void 0:s.href;if(typeof a!="string")return;a.endsWith("/")&&(a=a.slice(0,-1));const u=`${a}/wc?requestId=${o}&sessionTopic=${t}`,l=wi();l===Ze.browser?u.startsWith("https://")?window.open(u,"_blank","noreferrer noopener"):window.open(u,"_self","noreferrer noopener"):l===Ze.reactNative&&typeof(K.dist.global==null?void 0:K.dist.global.Linking)<"u"&&await K.dist.global.Linking.openURL(u)}catch(s){console.error(s)}}async function m1(o,t){try{return await o.getItem(t)||(Fr()?localStorage.getItem(t):void 0)}catch(r){console.error(r)}}const y1="irn";function Oo(o){return(o==null?void 0:o.relay)||{protocol:y1}}function Es(o){const t=S.C[o];if(typeof t>"u")throw new Error(`Relay Protocol not supported: ${o}`);return t}var v1=Object.defineProperty,Fu=Object.getOwnPropertySymbols,w1=Object.prototype.hasOwnProperty,_1=Object.prototype.propertyIsEnumerable,qu=(o,t,r)=>t in o?v1(o,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[t]=r,b1=(o,t)=>{for(var r in t||(t={}))w1.call(t,r)&&qu(o,r,t[r]);if(Fu)for(var r of Fu(t))_1.call(t,r)&&qu(o,r,t[r]);return o};function E1(o,t="-"){const r={},s="relay"+t;return Object.keys(o).forEach(a=>{if(a.startsWith(s)){const u=a.replace(s,""),l=o[a];r[u]=l}}),r}function Uu(o){o=o.includes("wc://")?o.replace("wc://",""):o,o=o.includes("wc:")?o.replace("wc:",""):o;const t=o.indexOf(":"),r=o.indexOf("?")!==-1?o.indexOf("?"):void 0,s=o.substring(0,t),a=o.substring(t+1,r).split("@"),u=typeof r<"u"?o.substring(r):"",l=Ke.queryString.parse(u);return{protocol:s,topic:I1(a[0]),version:parseInt(a[1],10),symKey:l.symKey,relay:E1(l)}}function I1(o){return o.startsWith("//")?o.substring(2):o}function P1(o,t="-"){const r="relay",s={};return Object.keys(o).forEach(a=>{const u=r+t+a;o[a]&&(s[u]=o[a])}),s}function S1(o){return`${o.protocol}:${o.topic}@${o.version}?`+Ke.queryString.stringify(b1({symKey:o.symKey},P1(o.relay)))}function qr(o){const t=[];return o.forEach(r=>{const[s,a]=r.split(":");t.push(`${s}:${a}`)}),t}function O1(o){const t=[];return Object.values(o).forEach(r=>{t.push(...qr(r.accounts))}),t}function R1(o,t){const r=[];return Object.values(o).forEach(s=>{qr(s.accounts).includes(t)&&r.push(...s.methods)}),r}function $1(o,t){const r=[];return Object.values(o).forEach(s=>{qr(s.accounts).includes(t)&&r.push(...s.events)}),r}function N1(o,t){const r=Is(o,t);if(r)throw new Error(r.message);const s={};for(const[a,u]of Object.entries(o))s[a]={methods:u.methods,events:u.events,chains:u.accounts.map(l=>`${l.split(":")[0]}:${l.split(":")[1]}`)};return s}function Uo(o){return o.includes(":")}function fi(o){return Uo(o)?o.split(":")[0]:o}const C1={INVALID_METHOD:{message:"Invalid method.",code:1001},INVALID_EVENT:{message:"Invalid event.",code:1002},INVALID_UPDATE_REQUEST:{message:"Invalid update request.",code:1003},INVALID_EXTEND_REQUEST:{message:"Invalid extend request.",code:1004},INVALID_SESSION_SETTLE_REQUEST:{message:"Invalid session settle request.",code:1005},UNAUTHORIZED_METHOD:{message:"Unauthorized method.",code:3001},UNAUTHORIZED_EVENT:{message:"Unauthorized event.",code:3002},UNAUTHORIZED_UPDATE_REQUEST:{message:"Unauthorized update request.",code:3003},UNAUTHORIZED_EXTEND_REQUEST:{message:"Unauthorized extend request.",code:3004},USER_REJECTED:{message:"User rejected.",code:5e3},USER_REJECTED_CHAINS:{message:"User rejected chains.",code:5001},USER_REJECTED_METHODS:{message:"User rejected methods.",code:5002},USER_REJECTED_EVENTS:{message:"User rejected events.",code:5003},UNSUPPORTED_CHAINS:{message:"Unsupported chains.",code:5100},UNSUPPORTED_METHODS:{message:"Unsupported methods.",code:5101},UNSUPPORTED_EVENTS:{message:"Unsupported events.",code:5102},UNSUPPORTED_ACCOUNTS:{message:"Unsupported accounts.",code:5103},UNSUPPORTED_NAMESPACE_KEY:{message:"Unsupported namespace key.",code:5104},USER_DISCONNECTED:{message:"User disconnected.",code:6e3},SESSION_SETTLEMENT_FAILED:{message:"Session settlement failed.",code:7e3},WC_METHOD_UNSUPPORTED:{message:"Unsupported wc_ method.",code:10001}},T1={NOT_INITIALIZED:{message:"Not initialized.",code:1},NO_MATCHING_KEY:{message:"No matching key.",code:2},RESTORE_WILL_OVERRIDE:{message:"Restore will override.",code:3},RESUBSCRIBED:{message:"Resubscribed.",code:4},MISSING_OR_INVALID:{message:"Missing or invalid.",code:5},EXPIRED:{message:"Expired.",code:6},UNKNOWN_TYPE:{message:"Unknown type.",code:7},MISMATCHED_TOPIC:{message:"Mismatched topic.",code:8},NON_CONFORMING_NAMESPACES:{message:"Non conforming namespaces.",code:9}};function A(o,t){const{message:r,code:s}=T1[o];return{message:t?`${r} ${t}`:r,code:s}}function ye(o,t){const{message:r,code:s}=C1[o];return{message:t?`${r} ${t}`:r,code:s}}function or(o,t){return!!Array.isArray(o)}function Tr(o){return Object.getPrototypeOf(o)===Object.prototype&&Object.keys(o).length}function De(o){return typeof o>"u"}function Ie(o,t){return t&&De(o)?!0:typeof o=="string"&&!!o.trim().length}function Mo(o,t){return t&&De(o)?!0:typeof o=="number"&&!isNaN(o)}function A1(o,t){const{requiredNamespaces:r}=t,s=Object.keys(o.namespaces),a=Object.keys(r);let u=!0;return nr(a,s)?(s.forEach(l=>{const{accounts:g,methods:v,events:d}=o.namespaces[l],E=qr(g),_=r[l];(!nr(Fh(l,_),E)||!nr(_.methods,v)||!nr(_.events,d))&&(u=!1)}),u):!1}function Ss(o){return Ie(o,!1)&&o.includes(":")?o.split(":").length===2:!1}function x1(o){if(Ie(o,!1)&&o.includes(":")){const t=o.split(":");if(t.length===3){const r=t[0]+":"+t[1];return!!t[2]&&Ss(r)}}return!1}function D1(o){if(Ie(o,!1))try{return typeof new URL(o)<"u"}catch{return!1}return!1}function j1(o){var t;return(t=o==null?void 0:o.proposer)==null?void 0:t.publicKey}function F1(o){return o==null?void 0:o.topic}function q1(o,t){let r=null;return Ie(o==null?void 0:o.publicKey,!1)||(r=A("MISSING_OR_INVALID",`${t} controller public key should be a string`)),r}function Mu(o){let t=!0;return or(o)?o.length&&(t=o.every(r=>Ie(r,!1))):t=!1,t}function U1(o,t,r){let s=null;return or(t)&&t.length?t.forEach(a=>{s||Ss(a)||(s=ye("UNSUPPORTED_CHAINS",`${r}, chain ${a} should be a string and conform to "namespace:chainId" format`))}):Ss(o)||(s=ye("UNSUPPORTED_CHAINS",`${r}, chains must be defined as "namespace:chainId" e.g. "eip155:1": {...} in the namespace key OR as an array of CAIP-2 chainIds e.g. eip155: { chains: ["eip155:1", "eip155:5"] }`)),s}function M1(o,t,r){let s=null;return Object.entries(o).forEach(([a,u])=>{if(s)return;const l=U1(a,Fh(a,u),`${t} ${r}`);l&&(s=l)}),s}function L1(o,t){let r=null;return or(o)?o.forEach(s=>{r||x1(s)||(r=ye("UNSUPPORTED_ACCOUNTS",`${t}, account ${s} should be a string and conform to "namespace:chainId:address" format`))}):r=ye("UNSUPPORTED_ACCOUNTS",`${t}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),r}function k1(o,t){let r=null;return Object.values(o).forEach(s=>{if(r)return;const a=L1(s==null?void 0:s.accounts,`${t} namespace`);a&&(r=a)}),r}function z1(o,t){let r=null;return Mu(o==null?void 0:o.methods)?Mu(o==null?void 0:o.events)||(r=ye("UNSUPPORTED_EVENTS",`${t}, events should be an array of strings or empty array for no events`)):r=ye("UNSUPPORTED_METHODS",`${t}, methods should be an array of strings or empty array for no methods`),r}function Kh(o,t){let r=null;return Object.values(o).forEach(s=>{if(r)return;const a=z1(s,`${t}, namespace`);a&&(r=a)}),r}function H1(o,t,r){let s=null;if(o&&Tr(o)){const a=Kh(o,t);a&&(s=a);const u=M1(o,t,r);u&&(s=u)}else s=A("MISSING_OR_INVALID",`${t}, ${r} should be an object with data`);return s}function Is(o,t){let r=null;if(o&&Tr(o)){const s=Kh(o,t);s&&(r=s);const a=k1(o,t);a&&(r=a)}else r=A("MISSING_OR_INVALID",`${t}, namespaces should be an object with data`);return r}function Vh(o){return Ie(o.protocol,!0)}function K1(o,t){let r=!1;return o?o&&or(o)&&o.length&&o.forEach(s=>{r=Vh(s)}):r=!0,r}function V1(o){return typeof o=="number"}function He(o){return typeof o<"u"&&typeof o!==null}function B1(o){return!(!o||typeof o!="object"||!o.code||!Mo(o.code,!1)||!o.message||!Ie(o.message,!1))}function W1(o){return!(De(o)||!Ie(o.method,!1))}function J1(o){return!(De(o)||De(o.result)&&De(o.error)||!Mo(o.id,!1)||!Ie(o.jsonrpc,!1))}function G1(o){return!(De(o)||!Ie(o.name,!1))}function Lu(o,t){return!(!Ss(t)||!O1(o).includes(t))}function Q1(o,t,r){return Ie(r,!1)?R1(o,t).includes(r):!1}function Y1(o,t,r){return Ie(r,!1)?$1(o,t).includes(r):!1}function ku(o,t,r){let s=null;const a=Z1(o),u=X1(t),l=Object.keys(a),g=Object.keys(u),v=zu(Object.keys(o)),d=zu(Object.keys(t)),E=v.filter(_=>!d.includes(_));return E.length&&(s=A("NON_CONFORMING_NAMESPACES",`${r} namespaces keys don't satisfy requiredNamespaces.
|
|
15
|
-
Required: ${E.toString()}
|
|
16
|
-
Received: ${Object.keys(t).toString()}`)),nr(l,g)||(s=A("NON_CONFORMING_NAMESPACES",`${r} namespaces chains don't satisfy required namespaces.
|
|
17
|
-
Required: ${l.toString()}
|
|
18
|
-
Approved: ${g.toString()}`)),Object.keys(t).forEach(_=>{if(!_.includes(":")||s)return;const I=qr(t[_].accounts);I.includes(_)||(s=A("NON_CONFORMING_NAMESPACES",`${r} namespaces accounts don't satisfy namespace accounts for ${_}
|
|
19
|
-
Required: ${_}
|
|
20
|
-
Approved: ${I.toString()}`))}),l.forEach(_=>{s||(nr(a[_].methods,u[_].methods)?nr(a[_].events,u[_].events)||(s=A("NON_CONFORMING_NAMESPACES",`${r} namespaces events don't satisfy namespace events for ${_}`)):s=A("NON_CONFORMING_NAMESPACES",`${r} namespaces methods don't satisfy namespace methods for ${_}`))}),s}function Z1(o){const t={};return Object.keys(o).forEach(r=>{var s;r.includes(":")?t[r]=o[r]:(s=o[r].chains)==null||s.forEach(a=>{t[a]={methods:o[r].methods,events:o[r].events}})}),t}function zu(o){return[...new Set(o.map(t=>t.includes(":")?t.split(":")[0]:t))]}function X1(o){const t={};return Object.keys(o).forEach(r=>{if(r.includes(":"))t[r]=o[r];else{const s=qr(o[r].accounts);s==null||s.forEach(a=>{t[a]={accounts:o[r].accounts.filter(u=>u.includes(`${a}:`)),methods:o[r].methods,events:o[r].events}})}}),t}function e0(o,t){return Mo(o,!1)&&o<=t.max&&o>=t.min}function Hu(){const o=wi();return new Promise(t=>{switch(o){case Ze.browser:t(t0());break;case Ze.reactNative:t(r0());break;case Ze.node:t(i0());break;default:t(!0)}})}function t0(){return Fr()&&(navigator==null?void 0:navigator.onLine)}async function r0(){if(jr()&&typeof K.dist.global<"u"&&K.dist.global!=null&&K.dist.global.NetInfo){const o=await(K.dist.global==null?void 0:K.dist.global.NetInfo.fetch());return o==null?void 0:o.isConnected}return!0}function i0(){return!0}function s0(o){switch(wi()){case Ze.browser:n0(o);break;case Ze.reactNative:o0(o);break}}function n0(o){!jr()&&Fr()&&(window.addEventListener("online",()=>o(!0)),window.addEventListener("offline",()=>o(!1)))}function o0(o){var t;jr()&&typeof K.dist.global<"u"&&K.dist.global!=null&&K.dist.global.NetInfo&&((t=K.dist.global)==null||t.NetInfo.addEventListener(r=>o(r==null?void 0:r.isConnected)))}const ao={};let ms=class{static get(t){return ao[t]}static set(t,r){ao[t]=r}static delete(t){delete ao[t]}};class xt extends S.r{constructor(t){super(t),this.events=new Ve.eventsExports.EventEmitter,this.hasRegisteredEventListeners=!1,this.connection=this.setConnection(t),this.connection.connected&&this.registerEventListeners()}async connect(t=this.connection){await this.open(t)}async disconnect(){await this.close()}on(t,r){this.events.on(t,r)}once(t,r){this.events.once(t,r)}off(t,r){this.events.off(t,r)}removeListener(t,r){this.events.removeListener(t,r)}async request(t,r){return this.requestStrict(S.formatJsonRpcRequest(t.method,t.params||[],t.id||S.getBigIntRpcId().toString()),r)}async requestStrict(t,r){return new Promise(async(s,a)=>{if(!this.connection.connected)try{await this.open()}catch(u){a(u)}this.events.on(`${t.id}`,u=>{S.isJsonRpcError(u)?a(u.error):s(u.result)});try{await this.connection.send(t,r)}catch(u){a(u)}})}setConnection(t=this.connection){return t}onPayload(t){this.events.emit("payload",t),S.isJsonRpcResponse(t)?this.events.emit(`${t.id}`,t):this.events.emit("message",{type:t.method,data:t.params})}onClose(t){t&&t.code===3e3&&this.events.emit("error",new Error(`WebSocket connection closed abnormally with code: ${t.code} ${t.reason?`(${t.reason})`:""}`)),this.events.emit("disconnect")}async open(t=this.connection){this.connection===t&&this.connection.connected||(this.connection.connected&&this.close(),typeof t=="string"&&(await this.connection.open(t),t=this.connection),this.connection=this.setConnection(t),await this.connection.open(),this.registerEventListeners(),this.events.emit("connect"))}async close(){await this.connection.close()}registerEventListeners(){this.hasRegisteredEventListeners||(this.connection.on("payload",t=>this.onPayload(t)),this.connection.on("close",t=>this.onClose(t)),this.connection.on("error",t=>this.events.emit("error",t)),this.connection.on("register_error",t=>this.onClose()),this.hasRegisteredEventListeners=!0)}}const a0=()=>typeof WebSocket<"u"?WebSocket:typeof K.dist.global<"u"&&typeof K.dist.global.WebSocket<"u"?K.dist.global.WebSocket:typeof window<"u"&&typeof window.WebSocket<"u"?window.WebSocket:typeof self<"u"&&typeof self.WebSocket<"u"?self.WebSocket:require("ws"),c0=()=>typeof WebSocket<"u"||typeof K.dist.global<"u"&&typeof K.dist.global.WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"||typeof self<"u"&&typeof self.WebSocket<"u",Ku=o=>o.split("?")[0],Vu=10,u0=a0();let h0=class{constructor(t){if(this.url=t,this.events=new Ve.eventsExports.EventEmitter,this.registering=!1,!S.isWsUrl(t))throw new Error(`Provided URL is not compatible with WebSocket connection: ${t}`);this.url=t}get connected(){return typeof this.socket<"u"}get connecting(){return this.registering}on(t,r){this.events.on(t,r)}once(t,r){this.events.once(t,r)}off(t,r){this.events.off(t,r)}removeListener(t,r){this.events.removeListener(t,r)}async open(t=this.url){await this.register(t)}async close(){return new Promise((t,r)=>{if(typeof this.socket>"u"){r(new Error("Connection already closed"));return}this.socket.onclose=s=>{this.onClose(s),t()},this.socket.close()})}async send(t){typeof this.socket>"u"&&(this.socket=await this.register());try{this.socket.send(Cs(t))}catch(r){this.onError(t.id,r)}}register(t=this.url){if(!S.isWsUrl(t))throw new Error(`Provided URL is not compatible with WebSocket connection: ${t}`);if(this.registering){const r=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=r||this.events.listenerCount("open")>=r)&&this.events.setMaxListeners(r+1),new Promise((s,a)=>{this.events.once("register_error",u=>{this.resetMaxListeners(),a(u)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.socket>"u")return a(new Error("WebSocket connection is missing or invalid"));s(this.socket)})})}return this.url=t,this.registering=!0,new Promise((r,s)=>{const a=new URLSearchParams(t).get("origin"),u=S.cjs.isReactNative()?{headers:{origin:a}}:{rejectUnauthorized:!S.isLocalhostUrl(t)},l=new u0(t,[],u);c0()?l.onerror=g=>{const v=g;s(this.emitError(v.error))}:l.on("error",g=>{s(this.emitError(g))}),l.onopen=()=>{this.onOpen(l),r(l)}})}onOpen(t){t.onmessage=r=>this.onPayload(r),t.onclose=r=>this.onClose(r),this.socket=t,this.registering=!1,this.events.emit("open")}onClose(t){this.socket=void 0,this.registering=!1,this.events.emit("close",t)}onPayload(t){if(typeof t.data>"u")return;const r=typeof t.data=="string"?Ns(t.data):t.data;this.events.emit("payload",r)}onError(t,r){const s=this.parseError(r),a=s.message||s.toString(),u=S.formatJsonRpcError(t,a);this.events.emit("payload",u)}parseError(t,r=this.url){return S.parseConnectionError(t,Ku(r),"WS")}resetMaxListeners(){this.events.getMaxListeners()>Vu&&this.events.setMaxListeners(Vu)}emitError(t){const r=this.parseError(new Error((t==null?void 0:t.message)||`WebSocket connection failed for host: ${Ku(this.url)}`));return this.events.emit("register_error",r),r}};function l0(o,t){return t=t||{},new Promise(function(r,s){var a=new XMLHttpRequest,u=[],l=[],g={},v=function(){return{ok:(a.status/100|0)==2,statusText:a.statusText,status:a.status,url:a.responseURL,text:function(){return Promise.resolve(a.responseText)},json:function(){return Promise.resolve(a.responseText).then(JSON.parse)},blob:function(){return Promise.resolve(new Blob([a.response]))},clone:v,headers:{keys:function(){return u},entries:function(){return l},get:function(E){return g[E.toLowerCase()]},has:function(E){return E.toLowerCase()in g}}}};for(var d in a.open(t.method||"get",o,!0),a.onload=function(){a.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(E,_,I){u.push(_=_.toLowerCase()),l.push([_,I]),g[_]=g[_]?g[_]+","+I:I}),r(v())},a.onerror=s,a.withCredentials=t.credentials=="include",t.headers)a.setRequestHeader(d,t.headers[d]);a.send(t.body||null)})}const p0=Object.freeze(Object.defineProperty({__proto__:null,default:l0},Symbol.toStringTag,{value:"Module"})),Bu=K.getAugmentedNamespace(p0);var f0=self.fetch||(self.fetch=Bu.default||Bu);const d0=K.getDefaultExportFromCjs(f0);function g0(o,t){if(o.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),s=0;s<r.length;s++)r[s]=255;for(var a=0;a<o.length;a++){var u=o.charAt(a),l=u.charCodeAt(0);if(r[l]!==255)throw new TypeError(u+" is ambiguous");r[l]=a}var g=o.length,v=o.charAt(0),d=Math.log(g)/Math.log(256),E=Math.log(256)/Math.log(g);function _(C){if(C instanceof Uint8Array||(ArrayBuffer.isView(C)?C=new Uint8Array(C.buffer,C.byteOffset,C.byteLength):Array.isArray(C)&&(C=Uint8Array.from(C))),!(C instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(C.length===0)return"";for(var U=0,D=0,B=0,ae=C.length;B!==ae&&C[B]===0;)B++,U++;for(var Z=(ae-B)*E+1>>>0,ee=new Uint8Array(Z);B!==ae;){for(var le=C[B],Fe=0,de=Z-1;(le!==0||Fe<D)&&de!==-1;de--,Fe++)le+=256*ee[de]>>>0,ee[de]=le%g>>>0,le=le/g>>>0;if(le!==0)throw new Error("Non-zero carry");D=Fe,B++}for(var Ce=Z-D;Ce!==Z&&ee[Ce]===0;)Ce++;for(var jt=v.repeat(U);Ce<Z;++Ce)jt+=o.charAt(ee[Ce]);return jt}function I(C){if(typeof C!="string")throw new TypeError("Expected String");if(C.length===0)return new Uint8Array;var U=0;if(C[U]!==" "){for(var D=0,B=0;C[U]===v;)D++,U++;for(var ae=(C.length-U)*d+1>>>0,Z=new Uint8Array(ae);C[U];){var ee=r[C.charCodeAt(U)];if(ee===255)return;for(var le=0,Fe=ae-1;(ee!==0||le<B)&&Fe!==-1;Fe--,le++)ee+=g*Z[Fe]>>>0,Z[Fe]=ee%256>>>0,ee=ee/256>>>0;if(ee!==0)throw new Error("Non-zero carry");B=le,U++}if(C[U]!==" "){for(var de=ae-B;de!==ae&&Z[de]===0;)de++;for(var Ce=new Uint8Array(D+(ae-de)),jt=D;de!==ae;)Ce[jt++]=Z[de++];return Ce}}}function T(C){var U=I(C);if(U)return U;throw new Error(`Non-${t} character`)}return{encode:_,decodeUnsafe:I,decode:T}}var m0=g0,y0=m0;const Bh=o=>{if(o instanceof Uint8Array&&o.constructor.name==="Uint8Array")return o;if(o instanceof ArrayBuffer)return new Uint8Array(o);if(ArrayBuffer.isView(o))return new Uint8Array(o.buffer,o.byteOffset,o.byteLength);throw new Error("Unknown type, must be binary type")},v0=o=>new TextEncoder().encode(o),w0=o=>new TextDecoder().decode(o);class _0{constructor(t,r,s){this.name=t,this.prefix=r,this.baseEncode=s}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}}class b0{constructor(t,r,s){if(this.name=t,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=s}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return Wh(this,t)}}class E0{constructor(t){this.decoders=t}or(t){return Wh(this,t)}decode(t){const r=t[0],s=this.decoders[r];if(s)return s.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const Wh=(o,t)=>new E0({...o.decoders||{[o.prefix]:o},...t.decoders||{[t.prefix]:t}});class I0{constructor(t,r,s,a){this.name=t,this.prefix=r,this.baseEncode=s,this.baseDecode=a,this.encoder=new _0(t,r,s),this.decoder=new b0(t,r,a)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}}const As=({name:o,prefix:t,encode:r,decode:s})=>new I0(o,t,r,s),_i=({prefix:o,name:t,alphabet:r})=>{const{encode:s,decode:a}=y0(r,t);return As({prefix:o,name:t,encode:s,decode:u=>Bh(a(u))})},P0=(o,t,r,s)=>{const a={};for(let E=0;E<t.length;++E)a[t[E]]=E;let u=o.length;for(;o[u-1]==="=";)--u;const l=new Uint8Array(u*r/8|0);let g=0,v=0,d=0;for(let E=0;E<u;++E){const _=a[o[E]];if(_===void 0)throw new SyntaxError(`Non-${s} character`);v=v<<r|_,g+=r,g>=8&&(g-=8,l[d++]=255&v>>g)}if(g>=r||255&v<<8-g)throw new SyntaxError("Unexpected end of data");return l},S0=(o,t,r)=>{const s=t[t.length-1]==="=",a=(1<<r)-1;let u="",l=0,g=0;for(let v=0;v<o.length;++v)for(g=g<<8|o[v],l+=8;l>r;)l-=r,u+=t[a&g>>l];if(l&&(u+=t[a&g<<r-l]),s)for(;u.length*r&7;)u+="=";return u},Oe=({name:o,prefix:t,bitsPerChar:r,alphabet:s})=>As({prefix:t,name:o,encode(a){return S0(a,s,r)},decode(a){return P0(a,s,r,o)}}),O0=As({prefix:"\0",name:"identity",encode:o=>w0(o),decode:o=>v0(o)});var R0=Object.freeze({__proto__:null,identity:O0});const $0=Oe({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var N0=Object.freeze({__proto__:null,base2:$0});const C0=Oe({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var T0=Object.freeze({__proto__:null,base8:C0});const A0=_i({prefix:"9",name:"base10",alphabet:"0123456789"});var x0=Object.freeze({__proto__:null,base10:A0});const D0=Oe({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),j0=Oe({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var F0=Object.freeze({__proto__:null,base16:D0,base16upper:j0});const q0=Oe({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),U0=Oe({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),M0=Oe({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),L0=Oe({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),k0=Oe({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),z0=Oe({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),H0=Oe({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),K0=Oe({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),V0=Oe({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var B0=Object.freeze({__proto__:null,base32:q0,base32upper:U0,base32pad:M0,base32padupper:L0,base32hex:k0,base32hexupper:z0,base32hexpad:H0,base32hexpadupper:K0,base32z:V0});const W0=_i({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),J0=_i({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var G0=Object.freeze({__proto__:null,base36:W0,base36upper:J0});const Q0=_i({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Y0=_i({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Z0=Object.freeze({__proto__:null,base58btc:Q0,base58flickr:Y0});const X0=Oe({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),eb=Oe({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),tb=Oe({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),rb=Oe({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var ib=Object.freeze({__proto__:null,base64:X0,base64pad:eb,base64url:tb,base64urlpad:rb});const Jh=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),sb=Jh.reduce((o,t,r)=>(o[r]=t,o),[]),nb=Jh.reduce((o,t,r)=>(o[t.codePointAt(0)]=r,o),[]);function ob(o){return o.reduce((t,r)=>(t+=sb[r],t),"")}function ab(o){const t=[];for(const r of o){const s=nb[r.codePointAt(0)];if(s===void 0)throw new Error(`Non-base256emoji character: ${r}`);t.push(s)}return new Uint8Array(t)}const cb=As({prefix:"🚀",name:"base256emoji",encode:ob,decode:ab});var ub=Object.freeze({__proto__:null,base256emoji:cb}),hb=Gh,Wu=128,lb=-128,pb=Math.pow(2,31);function Gh(o,t,r){t=t||[],r=r||0;for(var s=r;o>=pb;)t[r++]=o&255|Wu,o/=128;for(;o&lb;)t[r++]=o&255|Wu,o>>>=7;return t[r]=o|0,Gh.bytes=r-s+1,t}var fb=Ro,db=128,Ju=127;function Ro(o,s){var r=0,s=s||0,a=0,u=s,l,g=o.length;do{if(u>=g)throw Ro.bytes=0,new RangeError("Could not decode varint");l=o[u++],r+=a<28?(l&Ju)<<a:(l&Ju)*Math.pow(2,a),a+=7}while(l>=db);return Ro.bytes=u-s,r}var gb=Math.pow(2,7),mb=Math.pow(2,14),yb=Math.pow(2,21),vb=Math.pow(2,28),wb=Math.pow(2,35),_b=Math.pow(2,42),bb=Math.pow(2,49),Eb=Math.pow(2,56),Ib=Math.pow(2,63),Pb=function(o){return o<gb?1:o<mb?2:o<yb?3:o<vb?4:o<wb?5:o<_b?6:o<bb?7:o<Eb?8:o<Ib?9:10},Sb={encode:hb,decode:fb,encodingLength:Pb},Qh=Sb;const Gu=(o,t,r=0)=>(Qh.encode(o,t,r),t),Qu=o=>Qh.encodingLength(o),$o=(o,t)=>{const r=t.byteLength,s=Qu(o),a=s+Qu(r),u=new Uint8Array(a+r);return Gu(o,u,0),Gu(r,u,s),u.set(t,a),new Ob(o,r,t,u)};class Ob{constructor(t,r,s,a){this.code=t,this.size=r,this.digest=s,this.bytes=a}}const Yh=({name:o,code:t,encode:r})=>new Rb(o,t,r);class Rb{constructor(t,r,s){this.name=t,this.code=r,this.encode=s}digest(t){if(t instanceof Uint8Array){const r=this.encode(t);return r instanceof Uint8Array?$o(this.code,r):r.then(s=>$o(this.code,s))}else throw Error("Unknown type, must be binary type")}}const Zh=o=>async t=>new Uint8Array(await crypto.subtle.digest(o,t)),$b=Yh({name:"sha2-256",code:18,encode:Zh("SHA-256")}),Nb=Yh({name:"sha2-512",code:19,encode:Zh("SHA-512")});var Cb=Object.freeze({__proto__:null,sha256:$b,sha512:Nb});const Xh=0,Tb="identity",el=Bh,Ab=o=>$o(Xh,el(o)),xb={code:Xh,name:Tb,encode:el,digest:Ab};var Db=Object.freeze({__proto__:null,identity:xb});new TextEncoder,new TextDecoder;const Yu={...R0,...N0,...T0,...x0,...F0,...B0,...G0,...Z0,...ib,...ub};({...Cb,...Db});function tl(o){return globalThis.Buffer!=null?new Uint8Array(o.buffer,o.byteOffset,o.byteLength):o}function jb(o=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?tl(globalThis.Buffer.allocUnsafe(o)):new Uint8Array(o)}function rl(o,t,r,s){return{name:o,prefix:t,encoder:{name:o,prefix:t,encode:r},decoder:{decode:s}}}const Zu=rl("utf8","u",o=>"u"+new TextDecoder("utf8").decode(o),o=>new TextEncoder().encode(o.substring(1))),co=rl("ascii","a",o=>{let t="a";for(let r=0;r<o.length;r++)t+=String.fromCharCode(o[r]);return t},o=>{o=o.substring(1);const t=jb(o.length);for(let r=0;r<o.length;r++)t[r]=o.charCodeAt(r);return t}),Fb={utf8:Zu,"utf-8":Zu,hex:Yu.base16,latin1:co,ascii:co,binary:co,...Yu};function qb(o,t="utf8"){const r=Fb[t];if(!r)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?tl(globalThis.Buffer.from(o,"utf-8")):r.decoder.decode(`${r.prefix}${o}`)}const il="wc",Ub=2,sl="core",Bt=`${il}@2:${sl}:`,Mb={logger:"error"},Lb={database:":memory:"},kb="crypto",Xu="client_ed25519_seed",zb=q.cjs.ONE_DAY,Hb="keychain",Kb="0.3",Vb="messages",Bb="0.3",Wb=q.cjs.SIX_HOURS,Jb="publisher",nl="irn",Gb="error",ol="wss://relay.walletconnect.com",eh="wss://relay.walletconnect.org",Qb="relayer",Ne={message:"relayer_message",message_ack:"relayer_message_ack",connect:"relayer_connect",disconnect:"relayer_disconnect",error:"relayer_error",connection_stalled:"relayer_connection_stalled",publish:"relayer_publish"},Yb="_subscription",Tt={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},Zb=q.cjs.ONE_SECOND,Xb="2.11.0",eE=1e4,tE="0.3",rE="WALLETCONNECT_CLIENT_ID",dt={created:"subscription_created",deleted:"subscription_deleted",sync:"subscription_sync",resubscribed:"subscription_resubscribed"},iE="subscription",sE="0.3",nE=q.cjs.FIVE_SECONDS*1e3,oE="pairing",aE="0.3",ci={wc_pairingDelete:{req:{ttl:q.cjs.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:q.cjs.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:q.cjs.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:q.cjs.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:q.cjs.ONE_DAY,prompt:!1,tag:0},res:{ttl:q.cjs.ONE_DAY,prompt:!1,tag:0}}},di={create:"pairing_create",expire:"pairing_expire",delete:"pairing_delete",ping:"pairing_ping"},_t={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},cE="history",uE="0.3",hE="expirer",at={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},lE="0.3",uo="verify-api",Nr="https://verify.walletconnect.com",No="https://verify.walletconnect.org",pE=[Nr,No],fE="echo",dE="https://echo.walletconnect.com";class gE{constructor(t,r){this.core=t,this.logger=r,this.keychain=new Map,this.name=Hb,this.version=Kb,this.initialized=!1,this.storagePrefix=Bt,this.init=async()=>{if(!this.initialized){const s=await this.getKeyChain();typeof s<"u"&&(this.keychain=s),this.initialized=!0}},this.has=s=>(this.isInitialized(),this.keychain.has(s)),this.set=async(s,a)=>{this.isInitialized(),this.keychain.set(s,a),await this.persist()},this.get=s=>{this.isInitialized();const a=this.keychain.get(s);if(typeof a>"u"){const{message:u}=A("NO_MATCHING_KEY",`${this.name}: ${s}`);throw new Error(u)}return a},this.del=async s=>{this.isInitialized(),this.keychain.delete(s),await this.persist()},this.core=t,this.logger=S.E(r,this.name)}get context(){return S.y(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(t){await this.core.storage.setItem(this.storageKey,Lh(t))}async getKeyChain(){const t=await this.core.storage.getItem(this.storageKey);return typeof t<"u"?kh(t):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){const{message:t}=A("NOT_INITIALIZED",this.name);throw new Error(t)}}}class mE{constructor(t,r,s){this.core=t,this.logger=r,this.name=kb,this.initialized=!1,this.init=async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)},this.hasKeys=a=>(this.isInitialized(),this.keychain.has(a)),this.getClientId=async()=>{this.isInitialized();const a=await this.getClientSeed(),u=S.Po(a);return S.Qe(u.publicKey)},this.generateKeyPair=()=>{this.isInitialized();const a=W_();return this.setPrivateKey(a.publicKey,a.privateKey)},this.signJWT=async a=>{this.isInitialized();const u=await this.getClientSeed(),l=S.Po(u),g=So(),v=zb;return await S.Qo(g,a,v,l)},this.generateSharedKey=(a,u,l)=>{this.isInitialized();const g=this.getPrivateKey(a),v=J_(g,u);return this.setSymKey(v,l)},this.setSymKey=async(a,u)=>{this.isInitialized();const l=u||G_(a);return await this.keychain.set(l,a),l},this.deleteKeyPair=async a=>{this.isInitialized(),await this.keychain.del(a)},this.deleteSymKey=async a=>{this.isInitialized(),await this.keychain.del(a)},this.encode=async(a,u,l)=>{this.isInitialized();const g=Mh(l),v=Cs(u);if(Au(g)){const I=g.senderPublicKey,T=g.receiverPublicKey;a=await this.generateSharedKey(I,T)}const d=this.getSymKey(a),{type:E,senderPublicKey:_}=g;return Y_({type:E,symKey:d,message:v,senderPublicKey:_})},this.decode=async(a,u,l)=>{this.isInitialized();const g=e1(u,l);if(Au(g)){const v=g.receiverPublicKey,d=g.senderPublicKey;a=await this.generateSharedKey(v,d)}try{const v=this.getSymKey(a),d=Z_({symKey:v,encoded:u});return Ns(d)}catch(v){this.logger.error(`Failed to decode message from topic: '${a}', clientId: '${await this.getClientId()}'`),this.logger.error(v)}},this.getPayloadType=a=>{const u=Ps(a);return vi(u.type)},this.getPayloadSenderPublicKey=a=>{const u=Ps(a);return u.senderPublicKey?S.toString(u.senderPublicKey,je):void 0},this.core=t,this.logger=S.E(r,this.name),this.keychain=s||new gE(this.core,this.logger)}get context(){return S.y(this.logger)}async setPrivateKey(t,r){return await this.keychain.set(t,r),t}getPrivateKey(t){return this.keychain.get(t)}async getClientSeed(){let t="";try{t=this.keychain.get(Xu)}catch{t=So(),await this.keychain.set(Xu,t)}return qb(t,"base16")}getSymKey(t){return this.keychain.get(t)}isInitialized(){if(!this.initialized){const{message:t}=A("NOT_INITIALIZED",this.name);throw new Error(t)}}}class yE extends I_{constructor(t,r){super(t,r),this.logger=t,this.core=r,this.messages=new Map,this.name=Vb,this.version=Bb,this.initialized=!1,this.storagePrefix=Bt,this.init=async()=>{if(!this.initialized){this.logger.trace("Initialized");try{const s=await this.getRelayerMessages();typeof s<"u"&&(this.messages=s),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size})}catch(s){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(s)}finally{this.initialized=!0}}},this.set=async(s,a)=>{this.isInitialized();const u=Cr(a);let l=this.messages.get(s);return typeof l>"u"&&(l={}),typeof l[u]<"u"||(l[u]=a,this.messages.set(s,l),await this.persist()),u},this.get=s=>{this.isInitialized();let a=this.messages.get(s);return typeof a>"u"&&(a={}),a},this.has=(s,a)=>{this.isInitialized();const u=this.get(s),l=Cr(a);return typeof u[l]<"u"},this.del=async s=>{this.isInitialized(),this.messages.delete(s),await this.persist()},this.logger=S.E(t,this.name),this.core=r}get context(){return S.y(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setRelayerMessages(t){await this.core.storage.setItem(this.storageKey,Lh(t))}async getRelayerMessages(){const t=await this.core.storage.getItem(this.storageKey);return typeof t<"u"?kh(t):void 0}async persist(){await this.setRelayerMessages(this.messages)}isInitialized(){if(!this.initialized){const{message:t}=A("NOT_INITIALIZED",this.name);throw new Error(t)}}}class vE extends P_{constructor(t,r){super(t,r),this.relayer=t,this.logger=r,this.events=new Ve.eventsExports.EventEmitter,this.name=Jb,this.queue=new Map,this.publishTimeout=q.cjs.toMiliseconds(q.cjs.TEN_SECONDS),this.needsTransportRestart=!1,this.publish=async(s,a,u)=>{var l;this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:s,message:a,opts:u}});try{const g=(u==null?void 0:u.ttl)||Wb,v=Oo(u),d=(u==null?void 0:u.prompt)||!1,E=(u==null?void 0:u.tag)||0,_=(u==null?void 0:u.id)||S.getBigIntRpcId().toString(),I={topic:s,message:a,opts:{ttl:g,relay:v,prompt:d,tag:E,id:_}},T=setTimeout(()=>this.queue.set(_,I),this.publishTimeout);try{await await yi(this.rpcPublish(s,a,g,v,d,E,_),this.publishTimeout,"Failed to publish payload, please try again."),this.removeRequestFromQueue(_),this.relayer.events.emit(Ne.publish,I)}catch(C){if(this.logger.debug("Publishing Payload stalled"),this.needsTransportRestart=!0,(l=u==null?void 0:u.internal)!=null&&l.throwOnFailedPublish)throw this.removeRequestFromQueue(_),C;return}finally{clearTimeout(T)}this.logger.debug("Successfully Published Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:s,message:a,opts:u}})}catch(g){throw this.logger.debug("Failed to Publish Payload"),this.logger.error(g),g}},this.on=(s,a)=>{this.events.on(s,a)},this.once=(s,a)=>{this.events.once(s,a)},this.off=(s,a)=>{this.events.off(s,a)},this.removeListener=(s,a)=>{this.events.removeListener(s,a)},this.relayer=t,this.logger=S.E(r,this.name),this.registerEventListeners()}get context(){return S.y(this.logger)}rpcPublish(t,r,s,a,u,l,g){var v,d,E,_;const I={method:Es(a.protocol).publish,params:{topic:t,message:r,ttl:s,prompt:u,tag:l},id:g};return De((v=I.params)==null?void 0:v.prompt)&&((d=I.params)==null||delete d.prompt),De((E=I.params)==null?void 0:E.tag)&&((_=I.params)==null||delete _.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:I}),this.relayer.request(I)}removeRequestFromQueue(t){this.queue.delete(t)}checkQueue(){this.queue.forEach(async t=>{const{topic:r,message:s,opts:a}=t;await this.publish(r,s,a)})}registerEventListeners(){this.relayer.core.heartbeat.on(xr.HEARTBEAT_EVENTS.pulse,()=>{if(this.needsTransportRestart){this.needsTransportRestart=!1,this.relayer.events.emit(Ne.connection_stalled);return}this.checkQueue()}),this.relayer.on(Ne.message_ack,t=>{this.removeRequestFromQueue(t.id.toString())})}}class wE{constructor(){this.map=new Map,this.set=(t,r)=>{const s=this.get(t);this.exists(t,r)||this.map.set(t,[...s,r])},this.get=t=>this.map.get(t)||[],this.exists=(t,r)=>this.get(t).includes(r),this.delete=(t,r)=>{if(typeof r>"u"){this.map.delete(t);return}if(!this.map.has(t))return;const s=this.get(t);if(!this.exists(t,r))return;const a=s.filter(u=>u!==r);if(!a.length){this.map.delete(t);return}this.map.set(t,a)},this.clear=()=>{this.map.clear()}}get topics(){return Array.from(this.map.keys())}}var _E=Object.defineProperty,bE=Object.defineProperties,EE=Object.getOwnPropertyDescriptors,th=Object.getOwnPropertySymbols,IE=Object.prototype.hasOwnProperty,PE=Object.prototype.propertyIsEnumerable,rh=(o,t,r)=>t in o?_E(o,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[t]=r,ui=(o,t)=>{for(var r in t||(t={}))IE.call(t,r)&&rh(o,r,t[r]);if(th)for(var r of th(t))PE.call(t,r)&&rh(o,r,t[r]);return o},ho=(o,t)=>bE(o,EE(t));class SE extends R_{constructor(t,r){super(t,r),this.relayer=t,this.logger=r,this.subscriptions=new Map,this.topicMap=new wE,this.events=new Ve.eventsExports.EventEmitter,this.name=iE,this.version=sE,this.pending=new Map,this.cached=[],this.initialized=!1,this.pendingSubscriptionWatchLabel="pending_sub_watch_label",this.pollingInterval=20,this.storagePrefix=Bt,this.subscribeTimeout=1e4,this.restartInProgress=!1,this.batchSubscribeTopicsLimit=500,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),this.registerEventListeners(),this.clientId=await this.relayer.core.crypto.getClientId())},this.subscribe=async(s,a)=>{await this.restartToComplete(),this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:s,opts:a}});try{const u=Oo(a),l={topic:s,relay:u};this.pending.set(s,l);const g=await this.rpcSubscribe(s,u);return this.onSubscribe(g,l),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:s,opts:a}}),g}catch(u){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(u),u}},this.unsubscribe=async(s,a)=>{await this.restartToComplete(),this.isInitialized(),typeof(a==null?void 0:a.id)<"u"?await this.unsubscribeById(s,a.id,a):await this.unsubscribeByTopic(s,a)},this.isSubscribed=async s=>this.topics.includes(s)?!0:await new Promise((a,u)=>{const l=new q.cjs.Watch;l.start(this.pendingSubscriptionWatchLabel);const g=setInterval(()=>{!this.pending.has(s)&&this.topics.includes(s)&&(clearInterval(g),l.stop(this.pendingSubscriptionWatchLabel),a(!0)),l.elapsed(this.pendingSubscriptionWatchLabel)>=nE&&(clearInterval(g),l.stop(this.pendingSubscriptionWatchLabel),u(new Error("Subscription resolution timeout")))},this.pollingInterval)}).catch(()=>!1),this.on=(s,a)=>{this.events.on(s,a)},this.once=(s,a)=>{this.events.once(s,a)},this.off=(s,a)=>{this.events.off(s,a)},this.removeListener=(s,a)=>{this.events.removeListener(s,a)},this.restart=async()=>{this.restartInProgress=!0,await this.restore(),await this.reset(),this.restartInProgress=!1},this.relayer=t,this.logger=S.E(r,this.name),this.clientId=""}get context(){return S.y(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.relayer.core.customStoragePrefix+"//"+this.name}get length(){return this.subscriptions.size}get ids(){return Array.from(this.subscriptions.keys())}get values(){return Array.from(this.subscriptions.values())}get topics(){return this.topicMap.topics}hasSubscription(t,r){let s=!1;try{s=this.getSubscription(t).topic===r}catch{}return s}onEnable(){this.cached=[],this.initialized=!0}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear()}async unsubscribeByTopic(t,r){const s=this.topicMap.get(t);await Promise.all(s.map(async a=>await this.unsubscribeById(t,a,r)))}async unsubscribeById(t,r,s){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:t,id:r,opts:s}});try{const a=Oo(s);await this.rpcUnsubscribe(t,r,a);const u=ye("USER_DISCONNECTED",`${this.name}, ${t}`);await this.onUnsubscribe(t,r,u),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:t,id:r,opts:s}})}catch(a){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(a),a}}async rpcSubscribe(t,r){const s={method:Es(r.protocol).subscribe,params:{topic:t}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:s});try{await await yi(this.relayer.request(s),this.subscribeTimeout)}catch{this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(Ne.connection_stalled)}return Cr(t+this.clientId)}async rpcBatchSubscribe(t){if(!t.length)return;const r=t[0].relay,s={method:Es(r.protocol).batchSubscribe,params:{topics:t.map(a=>a.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:s});try{return await await yi(this.relayer.request(s),this.subscribeTimeout)}catch{this.logger.debug("Outgoing Relay Payload stalled"),this.relayer.events.emit(Ne.connection_stalled)}}rpcUnsubscribe(t,r,s){const a={method:Es(s.protocol).unsubscribe,params:{topic:t,id:r}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:a}),this.relayer.request(a)}onSubscribe(t,r){this.setSubscription(t,ho(ui({},r),{id:t})),this.pending.delete(r.topic)}onBatchSubscribe(t){t.length&&t.forEach(r=>{this.setSubscription(r.id,ui({},r)),this.pending.delete(r.topic)})}async onUnsubscribe(t,r,s){this.events.removeAllListeners(r),this.hasSubscription(r,t)&&this.deleteSubscription(r,s),await this.relayer.messages.del(t)}async setRelayerSubscriptions(t){await this.relayer.core.storage.setItem(this.storageKey,t)}async getRelayerSubscriptions(){return await this.relayer.core.storage.getItem(this.storageKey)}setSubscription(t,r){this.subscriptions.has(t)||(this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:t,subscription:r}),this.addSubscription(t,r))}addSubscription(t,r){this.subscriptions.set(t,ui({},r)),this.topicMap.set(r.topic,t),this.events.emit(dt.created,r)}getSubscription(t){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:t});const r=this.subscriptions.get(t);if(!r){const{message:s}=A("NO_MATCHING_KEY",`${this.name}: ${t}`);throw new Error(s)}return r}deleteSubscription(t,r){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:t,reason:r});const s=this.getSubscription(t);this.subscriptions.delete(t),this.topicMap.delete(s.topic,t),this.events.emit(dt.deleted,ho(ui({},s),{reason:r}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(dt.sync)}async reset(){if(this.cached.length){const t=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let r=0;r<t;r++){const s=this.cached.splice(0,this.batchSubscribeTopicsLimit);await this.batchSubscribe(s)}}this.events.emit(dt.resubscribed)}async restore(){try{const t=await this.getRelayerSubscriptions();if(typeof t>"u"||!t.length)return;if(this.subscriptions.size){const{message:r}=A("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),new Error(r)}this.cached=t,this.logger.debug(`Successfully Restored subscriptions for ${this.name}`),this.logger.trace({type:"method",method:"restore",subscriptions:this.values})}catch(t){this.logger.debug(`Failed to Restore subscriptions for ${this.name}`),this.logger.error(t)}}async batchSubscribe(t){if(!t.length)return;const r=await this.rpcBatchSubscribe(t);or(r)&&this.onBatchSubscribe(r.map((s,a)=>ho(ui({},t[a]),{id:s})))}async onConnect(){this.restartInProgress||(await this.restart(),this.onEnable())}onDisconnect(){this.onDisable()}async checkPending(){if(!this.initialized||this.relayer.transportExplicitlyClosed)return;const t=[];this.pending.forEach(r=>{t.push(r)}),await this.batchSubscribe(t)}registerEventListeners(){this.relayer.core.heartbeat.on(xr.HEARTBEAT_EVENTS.pulse,async()=>{await this.checkPending()}),this.relayer.on(Ne.connect,async()=>{await this.onConnect()}),this.relayer.on(Ne.disconnect,()=>{this.onDisconnect()}),this.events.on(dt.created,async t=>{const r=dt.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:t}),await this.persist()}),this.events.on(dt.deleted,async t=>{const r=dt.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:t}),await this.persist()})}isInitialized(){if(!this.initialized){const{message:t}=A("NOT_INITIALIZED",this.name);throw new Error(t)}}async restartToComplete(){this.restartInProgress&&await new Promise(t=>{const r=setInterval(()=>{this.restartInProgress||(clearInterval(r),t())},this.pollingInterval)})}}var OE=Object.defineProperty,ih=Object.getOwnPropertySymbols,RE=Object.prototype.hasOwnProperty,$E=Object.prototype.propertyIsEnumerable,sh=(o,t,r)=>t in o?OE(o,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[t]=r,NE=(o,t)=>{for(var r in t||(t={}))RE.call(t,r)&&sh(o,r,t[r]);if(ih)for(var r of ih(t))$E.call(t,r)&&sh(o,r,t[r]);return o};class CE extends S_{constructor(t){super(t),this.protocol="wc",this.version=2,this.events=new Ve.eventsExports.EventEmitter,this.name=Qb,this.transportExplicitlyClosed=!1,this.initialized=!1,this.connectionAttemptInProgress=!1,this.connectionStatusPollingInterval=20,this.staleConnectionErrors=["socket hang up","socket stalled"],this.hasExperiencedNetworkDisruption=!1,this.request=async r=>{this.logger.debug("Publishing Request Payload");try{return await this.toEstablishConnection(),await this.provider.request(r)}catch(s){throw this.logger.debug("Failed to Publish Request"),this.logger.error(s),s}},this.onPayloadHandler=r=>{this.onProviderPayload(r)},this.onConnectHandler=()=>{this.events.emit(Ne.connect)},this.onDisconnectHandler=()=>{this.onProviderDisconnect()},this.onProviderErrorHandler=r=>{this.logger.error(r),this.events.emit(Ne.error,r),this.logger.info("Fatal socket error received, closing transport"),this.transportClose()},this.registerProviderListeners=()=>{this.provider.on(Tt.payload,this.onPayloadHandler),this.provider.on(Tt.connect,this.onConnectHandler),this.provider.on(Tt.disconnect,this.onDisconnectHandler),this.provider.on(Tt.error,this.onProviderErrorHandler)},this.core=t.core,this.logger=typeof t.logger<"u"&&typeof t.logger!="string"?S.E(t.logger,this.name):S.Tt(S.k({level:t.logger||Gb})),this.messages=new yE(this.logger,t.core),this.subscriber=new SE(this,this.logger),this.publisher=new vE(this,this.logger),this.relayUrl=(t==null?void 0:t.relayUrl)||ol,this.projectId=t.projectId,this.bundleId=o1(),this.provider={}}async init(){this.logger.trace("Initialized"),this.registerEventListeners(),await this.createProvider(),await Promise.all([this.messages.init(),this.subscriber.init()]);try{await this.transportOpen()}catch{this.logger.warn(`Connection via ${this.relayUrl} failed, attempting to connect via failover domain ${eh}...`),await this.restartTransport(eh)}this.initialized=!0,setTimeout(async()=>{this.subscriber.topics.length===0&&(this.logger.info("No topics subscribed to after init, closing transport"),await this.transportClose(),this.transportExplicitlyClosed=!1)},eE)}get context(){return S.y(this.logger)}get connected(){return this.provider.connection.connected}get connecting(){return this.provider.connection.connecting}async publish(t,r,s){this.isInitialized(),await this.publisher.publish(t,r,s),await this.recordMessageEvent({topic:t,message:r,publishedAt:Date.now()})}async subscribe(t,r){var s;this.isInitialized();let a=((s=this.subscriber.topicMap.get(t))==null?void 0:s[0])||"";if(a)return a;let u;const l=g=>{g.topic===t&&(this.subscriber.off(dt.created,l),u())};return await Promise.all([new Promise(g=>{u=g,this.subscriber.on(dt.created,l)}),new Promise(async g=>{a=await this.subscriber.subscribe(t,r),g()})]),a}async unsubscribe(t,r){this.isInitialized(),await this.subscriber.unsubscribe(t,r)}on(t,r){this.events.on(t,r)}once(t,r){this.events.once(t,r)}off(t,r){this.events.off(t,r)}removeListener(t,r){this.events.removeListener(t,r)}async transportClose(){this.transportExplicitlyClosed=!0,this.hasExperiencedNetworkDisruption&&this.connected?await yi(this.provider.disconnect(),1e3,"provider.disconnect()").catch(()=>this.onProviderDisconnect()):this.connected&&await this.provider.disconnect()}async transportOpen(t){if(this.transportExplicitlyClosed=!1,await this.confirmOnlineStateOrThrow(),!this.connectionAttemptInProgress){t&&t!==this.relayUrl&&(this.relayUrl=t,await this.transportClose(),await this.createProvider()),this.connectionAttemptInProgress=!0;try{await Promise.all([new Promise(r=>{if(!this.initialized)return r();this.subscriber.once(dt.resubscribed,()=>{r()})}),new Promise(async(r,s)=>{try{await yi(this.provider.connect(),1e4,`Socket stalled when trying to connect to ${this.relayUrl}`)}catch(a){s(a);return}r()})])}catch(r){this.logger.error(r);const s=r;if(!this.isConnectionStalled(s.message))throw r;this.provider.events.emit(Tt.disconnect)}finally{this.connectionAttemptInProgress=!1,this.hasExperiencedNetworkDisruption=!1}}}async restartTransport(t){await this.confirmOnlineStateOrThrow(),!this.connectionAttemptInProgress&&(this.relayUrl=t||this.relayUrl,await this.transportClose(),await this.createProvider(),await this.transportOpen())}async confirmOnlineStateOrThrow(){if(!await Hu())throw new Error("No internet connection detected. Please restart your network and try again.")}isConnectionStalled(t){return this.staleConnectionErrors.some(r=>t.includes(r))}async createProvider(){this.provider.connection&&this.unregisterProviderListeners();const t=await this.core.crypto.signJWT(this.relayUrl);this.provider=new xt(new h0(p1({sdkVersion:Xb,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:t,useOnCloseEvent:!0,bundleId:this.bundleId}))),this.registerProviderListeners()}async recordMessageEvent(t){const{topic:r,message:s}=t;await this.messages.set(r,s)}async shouldIgnoreMessageEvent(t){const{topic:r,message:s}=t;if(!s||s.length===0)return this.logger.debug(`Ignoring invalid/empty message: ${s}`),!0;if(!await this.subscriber.isSubscribed(r))return this.logger.debug(`Ignoring message for non-subscribed topic ${r}`),!0;const a=this.messages.has(r,s);return a&&this.logger.debug(`Ignoring duplicate message: ${s}`),a}async onProviderPayload(t){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:t}),S.isJsonRpcRequest(t)){if(!t.method.endsWith(Yb))return;const r=t.params,{topic:s,message:a,publishedAt:u}=r.data,l={topic:s,message:a,publishedAt:u};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(NE({type:"event",event:r.id},l)),this.events.emit(r.id,l),await this.acknowledgePayload(t),await this.onMessageEvent(l)}else S.isJsonRpcResponse(t)&&this.events.emit(Ne.message_ack,t)}async onMessageEvent(t){await this.shouldIgnoreMessageEvent(t)||(this.events.emit(Ne.message,t),await this.recordMessageEvent(t))}async acknowledgePayload(t){const r=S.formatJsonRpcResult(t.id,!0);await this.provider.connection.send(r)}unregisterProviderListeners(){this.provider.off(Tt.payload,this.onPayloadHandler),this.provider.off(Tt.connect,this.onConnectHandler),this.provider.off(Tt.disconnect,this.onDisconnectHandler),this.provider.off(Tt.error,this.onProviderErrorHandler)}async registerEventListeners(){this.events.on(Ne.connection_stalled,()=>{this.restartTransport().catch(r=>this.logger.error(r))});let t=await Hu();s0(async r=>{this.initialized&&t!==r&&(t=r,r?await this.restartTransport().catch(s=>this.logger.error(s)):(this.hasExperiencedNetworkDisruption=!0,await this.transportClose().catch(s=>this.logger.error(s))))})}onProviderDisconnect(){this.events.emit(Ne.disconnect),this.attemptToReconnect()}attemptToReconnect(){this.transportExplicitlyClosed||(this.logger.info("attemptToReconnect called. Connecting..."),setTimeout(async()=>{await this.restartTransport().catch(t=>this.logger.error(t))},q.cjs.toMiliseconds(Zb)))}isInitialized(){if(!this.initialized){const{message:t}=A("NOT_INITIALIZED",this.name);throw new Error(t)}}async toEstablishConnection(){if(await this.confirmOnlineStateOrThrow(),!this.connected){if(this.connectionAttemptInProgress)return await new Promise(t=>{const r=setInterval(()=>{this.connected&&(clearInterval(r),t())},this.connectionStatusPollingInterval)});await this.restartTransport()}}}var TE=Object.defineProperty,nh=Object.getOwnPropertySymbols,AE=Object.prototype.hasOwnProperty,xE=Object.prototype.propertyIsEnumerable,oh=(o,t,r)=>t in o?TE(o,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[t]=r,ah=(o,t)=>{for(var r in t||(t={}))AE.call(t,r)&&oh(o,r,t[r]);if(nh)for(var r of nh(t))xE.call(t,r)&&oh(o,r,t[r]);return o};class xs extends O_{constructor(t,r,s,a=Bt,u=void 0){super(t,r,s,a),this.core=t,this.logger=r,this.name=s,this.map=new Map,this.version=tE,this.cached=[],this.initialized=!1,this.storagePrefix=Bt,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(l=>{this.getKey&&l!==null&&!De(l)?this.map.set(this.getKey(l),l):j1(l)?this.map.set(l.id,l):F1(l)&&this.map.set(l.topic,l)}),this.cached=[],this.initialized=!0)},this.set=async(l,g)=>{this.isInitialized(),this.map.has(l)?await this.update(l,g):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:l,value:g}),this.map.set(l,g),await this.persist())},this.get=l=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:l}),this.getData(l)),this.getAll=l=>(this.isInitialized(),l?this.values.filter(g=>Object.keys(l).every(v=>S._s(g[v],l[v]))):this.values),this.update=async(l,g)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:l,update:g});const v=ah(ah({},this.getData(l)),g);this.map.set(l,v),await this.persist()},this.delete=async(l,g)=>{this.isInitialized(),this.map.has(l)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:l,reason:g}),this.map.delete(l),await this.persist())},this.logger=S.E(r,this.name),this.storagePrefix=a,this.getKey=u}get context(){return S.y(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.map.size}get keys(){return Array.from(this.map.keys())}get values(){return Array.from(this.map.values())}async setDataStore(t){await this.core.storage.setItem(this.storageKey,t)}async getDataStore(){return await this.core.storage.getItem(this.storageKey)}getData(t){const r=this.map.get(t);if(!r){const{message:s}=A("NO_MATCHING_KEY",`${this.name}: ${t}`);throw this.logger.error(s),new Error(s)}return r}async persist(){await this.setDataStore(this.values)}async restore(){try{const t=await this.getDataStore();if(typeof t>"u"||!t.length)return;if(this.map.size){const{message:r}=A("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),new Error(r)}this.cached=t,this.logger.debug(`Successfully Restored value for ${this.name}`),this.logger.trace({type:"method",method:"restore",value:this.values})}catch(t){this.logger.debug(`Failed to Restore value for ${this.name}`),this.logger.error(t)}}isInitialized(){if(!this.initialized){const{message:t}=A("NOT_INITIALIZED",this.name);throw new Error(t)}}}class DE{constructor(t,r){this.core=t,this.logger=r,this.name=oE,this.version=aE,this.events=new Ve.ss,this.initialized=!1,this.storagePrefix=Bt,this.ignoredPayloadTypes=[ur],this.registeredMethods=[],this.init=async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"))},this.register=({methods:s})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...s])]},this.create=async()=>{this.isInitialized();const s=So(),a=await this.core.crypto.setSymKey(s),u=gt(q.cjs.FIVE_MINUTES),l={protocol:nl},g={topic:a,expiry:u,relay:l,active:!1},v=S1({protocol:this.core.protocol,version:this.core.version,topic:a,symKey:s,relay:l});return await this.pairings.set(a,g),await this.core.relayer.subscribe(a),this.core.expirer.set(a,u),{topic:a,uri:v}},this.pair=async s=>{this.isInitialized(),this.isValidPair(s);const{topic:a,symKey:u,relay:l}=Uu(s.uri);let g;if(this.pairings.keys.includes(a)&&(g=this.pairings.get(a),g.active))throw new Error(`Pairing already exists: ${a}. Please try again with a new connection URI.`);const v=gt(q.cjs.FIVE_MINUTES),d={topic:a,relay:l,expiry:v,active:!1};return await this.pairings.set(a,d),this.core.expirer.set(a,v),s.activatePairing&&await this.activate({topic:a}),this.events.emit(di.create,d),this.core.crypto.keychain.has(a)||(await this.core.crypto.setSymKey(u,a),await this.core.relayer.subscribe(a,{relay:l})),d},this.activate=async({topic:s})=>{this.isInitialized();const a=gt(q.cjs.THIRTY_DAYS);await this.pairings.update(s,{active:!0,expiry:a}),this.core.expirer.set(s,a)},this.ping=async s=>{this.isInitialized(),await this.isValidPing(s);const{topic:a}=s;if(this.pairings.keys.includes(a)){const u=await this.sendRequest(a,"wc_pairingPing",{}),{done:l,resolve:g,reject:v}=$r();this.events.once(ve("pairing_ping",u),({error:d})=>{d?v(d):g()}),await l()}},this.updateExpiry=async({topic:s,expiry:a})=>{this.isInitialized(),await this.pairings.update(s,{expiry:a})},this.updateMetadata=async({topic:s,metadata:a})=>{this.isInitialized(),await this.pairings.update(s,{peerMetadata:a})},this.getPairings=()=>(this.isInitialized(),this.pairings.values),this.disconnect=async s=>{this.isInitialized(),await this.isValidDisconnect(s);const{topic:a}=s;this.pairings.keys.includes(a)&&(await this.sendRequest(a,"wc_pairingDelete",ye("USER_DISCONNECTED")),await this.deletePairing(a))},this.sendRequest=async(s,a,u)=>{const l=S.formatJsonRpcRequest(a,u),g=await this.core.crypto.encode(s,l),v=ci[a].req;return this.core.history.set(s,l),this.core.relayer.publish(s,g,v),l.id},this.sendResult=async(s,a,u)=>{const l=S.formatJsonRpcResult(s,u),g=await this.core.crypto.encode(a,l),v=await this.core.history.get(a,s),d=ci[v.request.method].res;await this.core.relayer.publish(a,g,d),await this.core.history.resolve(l)},this.sendError=async(s,a,u)=>{const l=S.formatJsonRpcError(s,u),g=await this.core.crypto.encode(a,l),v=await this.core.history.get(a,s),d=ci[v.request.method]?ci[v.request.method].res:ci.unregistered_method.res;await this.core.relayer.publish(a,g,d),await this.core.history.resolve(l)},this.deletePairing=async(s,a)=>{await this.core.relayer.unsubscribe(s),await Promise.all([this.pairings.delete(s,ye("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(s),a?Promise.resolve():this.core.expirer.del(s)])},this.cleanup=async()=>{const s=this.pairings.getAll().filter(a=>Vt(a.expiry));await Promise.all(s.map(a=>this.deletePairing(a.topic)))},this.onRelayEventRequest=s=>{const{topic:a,payload:u}=s;switch(u.method){case"wc_pairingPing":return this.onPairingPingRequest(a,u);case"wc_pairingDelete":return this.onPairingDeleteRequest(a,u);default:return this.onUnknownRpcMethodRequest(a,u)}},this.onRelayEventResponse=async s=>{const{topic:a,payload:u}=s,l=(await this.core.history.get(a,u.id)).request.method;switch(l){case"wc_pairingPing":return this.onPairingPingResponse(a,u);default:return this.onUnknownRpcMethodResponse(l)}},this.onPairingPingRequest=async(s,a)=>{const{id:u}=a;try{this.isValidPing({topic:s}),await this.sendResult(u,s,!0),this.events.emit(di.ping,{id:u,topic:s})}catch(l){await this.sendError(u,s,l),this.logger.error(l)}},this.onPairingPingResponse=(s,a)=>{const{id:u}=a;setTimeout(()=>{S.isJsonRpcResult(a)?this.events.emit(ve("pairing_ping",u),{}):S.isJsonRpcError(a)&&this.events.emit(ve("pairing_ping",u),{error:a.error})},500)},this.onPairingDeleteRequest=async(s,a)=>{const{id:u}=a;try{this.isValidDisconnect({topic:s}),await this.deletePairing(s),this.events.emit(di.delete,{id:u,topic:s})}catch(l){await this.sendError(u,s,l),this.logger.error(l)}},this.onUnknownRpcMethodRequest=async(s,a)=>{const{id:u,method:l}=a;try{if(this.registeredMethods.includes(l))return;const g=ye("WC_METHOD_UNSUPPORTED",l);await this.sendError(u,s,g),this.logger.error(g)}catch(g){await this.sendError(u,s,g),this.logger.error(g)}},this.onUnknownRpcMethodResponse=s=>{this.registeredMethods.includes(s)||this.logger.error(ye("WC_METHOD_UNSUPPORTED",s))},this.isValidPair=s=>{var a;if(!He(s)){const{message:l}=A("MISSING_OR_INVALID",`pair() params: ${s}`);throw new Error(l)}if(!D1(s.uri)){const{message:l}=A("MISSING_OR_INVALID",`pair() uri: ${s.uri}`);throw new Error(l)}const u=Uu(s.uri);if(!((a=u==null?void 0:u.relay)!=null&&a.protocol)){const{message:l}=A("MISSING_OR_INVALID","pair() uri#relay-protocol");throw new Error(l)}if(!(u!=null&&u.symKey)){const{message:l}=A("MISSING_OR_INVALID","pair() uri#symKey");throw new Error(l)}},this.isValidPing=async s=>{if(!He(s)){const{message:u}=A("MISSING_OR_INVALID",`ping() params: ${s}`);throw new Error(u)}const{topic:a}=s;await this.isValidPairingTopic(a)},this.isValidDisconnect=async s=>{if(!He(s)){const{message:u}=A("MISSING_OR_INVALID",`disconnect() params: ${s}`);throw new Error(u)}const{topic:a}=s;await this.isValidPairingTopic(a)},this.isValidPairingTopic=async s=>{if(!Ie(s,!1)){const{message:a}=A("MISSING_OR_INVALID",`pairing topic should be a string: ${s}`);throw new Error(a)}if(!this.pairings.keys.includes(s)){const{message:a}=A("NO_MATCHING_KEY",`pairing topic doesn't exist: ${s}`);throw new Error(a)}if(Vt(this.pairings.get(s).expiry)){await this.deletePairing(s);const{message:a}=A("EXPIRED",`pairing topic: ${s}`);throw new Error(a)}},this.core=t,this.logger=S.E(r,this.name),this.pairings=new xs(this.core,this.logger,this.name,this.storagePrefix)}get context(){return S.y(this.logger)}isInitialized(){if(!this.initialized){const{message:t}=A("NOT_INITIALIZED",this.name);throw new Error(t)}}registerRelayerEvents(){this.core.relayer.on(Ne.message,async t=>{const{topic:r,message:s}=t;if(!this.pairings.keys.includes(r)||this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(s)))return;const a=await this.core.crypto.decode(r,s);try{S.isJsonRpcRequest(a)?(this.core.history.set(r,a),this.onRelayEventRequest({topic:r,payload:a})):S.isJsonRpcResponse(a)&&(await this.core.history.resolve(a),await this.onRelayEventResponse({topic:r,payload:a}),this.core.history.delete(r,a.id))}catch(u){this.logger.error(u)}})}registerExpirerEvents(){this.core.expirer.on(at.expired,async t=>{const{topic:r}=Hh(t.target);r&&this.pairings.keys.includes(r)&&(await this.deletePairing(r,!0),this.events.emit(di.expire,{topic:r}))})}}class jE extends E_{constructor(t,r){super(t,r),this.core=t,this.logger=r,this.records=new Map,this.events=new Ve.eventsExports.EventEmitter,this.name=cE,this.version=uE,this.cached=[],this.initialized=!1,this.storagePrefix=Bt,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(s=>this.records.set(s.id,s)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.set=(s,a,u)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:s,request:a,chainId:u}),this.records.has(a.id))return;const l={id:a.id,topic:s,request:{method:a.method,params:a.params||null},chainId:u,expiry:gt(q.cjs.THIRTY_DAYS)};this.records.set(l.id,l),this.events.emit(_t.created,l)},this.resolve=async s=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:s}),!this.records.has(s.id))return;const a=await this.getRecord(s.id);typeof a.response>"u"&&(a.response=S.isJsonRpcError(s)?{error:s.error}:{result:s.result},this.records.set(a.id,a),this.events.emit(_t.updated,a))},this.get=async(s,a)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:s,id:a}),await this.getRecord(a)),this.delete=(s,a)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:a}),this.values.forEach(u=>{if(u.topic===s){if(typeof a<"u"&&u.id!==a)return;this.records.delete(u.id),this.events.emit(_t.deleted,u)}})},this.exists=async(s,a)=>(this.isInitialized(),this.records.has(a)?(await this.getRecord(a)).topic===s:!1),this.on=(s,a)=>{this.events.on(s,a)},this.once=(s,a)=>{this.events.once(s,a)},this.off=(s,a)=>{this.events.off(s,a)},this.removeListener=(s,a)=>{this.events.removeListener(s,a)},this.logger=S.E(r,this.name)}get context(){return S.y(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get size(){return this.records.size}get keys(){return Array.from(this.records.keys())}get values(){return Array.from(this.records.values())}get pending(){const t=[];return this.values.forEach(r=>{if(typeof r.response<"u")return;const s={topic:r.topic,request:S.formatJsonRpcRequest(r.request.method,r.request.params,r.id),chainId:r.chainId};return t.push(s)}),t}async setJsonRpcRecords(t){await this.core.storage.setItem(this.storageKey,t)}async getJsonRpcRecords(){return await this.core.storage.getItem(this.storageKey)}getRecord(t){this.isInitialized();const r=this.records.get(t);if(!r){const{message:s}=A("NO_MATCHING_KEY",`${this.name}: ${t}`);throw new Error(s)}return r}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(_t.sync)}async restore(){try{const t=await this.getJsonRpcRecords();if(typeof t>"u"||!t.length)return;if(this.records.size){const{message:r}=A("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),new Error(r)}this.cached=t,this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",records:this.values})}catch(t){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(t)}}registerEventListeners(){this.events.on(_t.created,t=>{const r=_t.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:t}),this.persist()}),this.events.on(_t.updated,t=>{const r=_t.updated;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:t}),this.persist()}),this.events.on(_t.deleted,t=>{const r=_t.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:t}),this.persist()}),this.core.heartbeat.on(xr.HEARTBEAT_EVENTS.pulse,()=>{this.cleanup()})}cleanup(){try{this.records.forEach(t=>{q.cjs.toMiliseconds(t.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${t.id}`),this.delete(t.topic,t.id))})}catch(t){this.logger.warn(t)}}isInitialized(){if(!this.initialized){const{message:t}=A("NOT_INITIALIZED",this.name);throw new Error(t)}}}class FE extends $_{constructor(t,r){super(t,r),this.core=t,this.logger=r,this.expirations=new Map,this.events=new Ve.eventsExports.EventEmitter,this.name=hE,this.version=lE,this.cached=[],this.initialized=!1,this.storagePrefix=Bt,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(s=>this.expirations.set(s.target,s)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.has=s=>{try{const a=this.formatTarget(s);return typeof this.getExpiration(a)<"u"}catch{return!1}},this.set=(s,a)=>{this.isInitialized();const u=this.formatTarget(s),l={target:u,expiry:a};this.expirations.set(u,l),this.checkExpiry(u,l),this.events.emit(at.created,{target:u,expiration:l})},this.get=s=>{this.isInitialized();const a=this.formatTarget(s);return this.getExpiration(a)},this.del=s=>{if(this.isInitialized(),this.has(s)){const a=this.formatTarget(s),u=this.getExpiration(a);this.expirations.delete(a),this.events.emit(at.deleted,{target:a,expiration:u})}},this.on=(s,a)=>{this.events.on(s,a)},this.once=(s,a)=>{this.events.once(s,a)},this.off=(s,a)=>{this.events.off(s,a)},this.removeListener=(s,a)=>{this.events.removeListener(s,a)},this.logger=S.E(r,this.name)}get context(){return S.y(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.expirations.size}get keys(){return Array.from(this.expirations.keys())}get values(){return Array.from(this.expirations.values())}formatTarget(t){if(typeof t=="string")return f1(t);if(typeof t=="number")return d1(t);const{message:r}=A("UNKNOWN_TYPE",`Target type: ${typeof t}`);throw new Error(r)}async setExpirations(t){await this.core.storage.setItem(this.storageKey,t)}async getExpirations(){return await this.core.storage.getItem(this.storageKey)}async persist(){await this.setExpirations(this.values),this.events.emit(at.sync)}async restore(){try{const t=await this.getExpirations();if(typeof t>"u"||!t.length)return;if(this.expirations.size){const{message:r}=A("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),new Error(r)}this.cached=t,this.logger.debug(`Successfully Restored expirations for ${this.name}`),this.logger.trace({type:"method",method:"restore",expirations:this.values})}catch(t){this.logger.debug(`Failed to Restore expirations for ${this.name}`),this.logger.error(t)}}getExpiration(t){const r=this.expirations.get(t);if(!r){const{message:s}=A("NO_MATCHING_KEY",`${this.name}: ${t}`);throw this.logger.error(s),new Error(s)}return r}checkExpiry(t,r){const{expiry:s}=r;q.cjs.toMiliseconds(s)-Date.now()<=0&&this.expire(t,r)}expire(t,r){this.expirations.delete(t),this.events.emit(at.expired,{target:t,expiration:r})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((t,r)=>this.checkExpiry(r,t))}registerEventListeners(){this.core.heartbeat.on(xr.HEARTBEAT_EVENTS.pulse,()=>this.checkExpirations()),this.events.on(at.created,t=>{const r=at.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:t}),this.persist()}),this.events.on(at.expired,t=>{const r=at.expired;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:t}),this.persist()}),this.events.on(at.deleted,t=>{const r=at.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:t}),this.persist()})}isInitialized(){if(!this.initialized){const{message:t}=A("NOT_INITIALIZED",this.name);throw new Error(t)}}}class qE extends N_{constructor(t,r){super(t,r),this.projectId=t,this.logger=r,this.name=uo,this.initialized=!1,this.queue=[],this.verifyDisabled=!1,this.init=async s=>{if(this.verifyDisabled||jr()||!Fr())return;const a=this.getVerifyUrl(s==null?void 0:s.verifyUrl);this.verifyUrl!==a&&this.removeIframe(),this.verifyUrl=a;try{await this.createIframe()}catch(u){this.logger.info(`Verify iframe failed to load: ${this.verifyUrl}`),this.logger.info(u)}if(!this.initialized){this.removeIframe(),this.verifyUrl=No;try{await this.createIframe()}catch(u){this.logger.info(`Verify iframe failed to load: ${this.verifyUrl}`),this.logger.info(u),this.verifyDisabled=!0}}},this.register=async s=>{this.initialized?this.sendPost(s.attestationId):(this.addToQueue(s.attestationId),await this.init())},this.resolve=async s=>{if(this.isDevEnv)return"";const a=this.getVerifyUrl(s==null?void 0:s.verifyUrl);let u;try{u=await this.fetchAttestation(s.attestationId,a)}catch(l){this.logger.info(`failed to resolve attestation: ${s.attestationId} from url: ${a}`),this.logger.info(l),u=await this.fetchAttestation(s.attestationId,No)}return u},this.fetchAttestation=async(s,a)=>{this.logger.info(`resolving attestation: ${s} from url: ${a}`);const u=this.startAbortTimer(q.cjs.ONE_SECOND*2),l=await fetch(`${a}/attestation/${s}`,{signal:this.abortController.signal});return clearTimeout(u),l.status===200?await l.json():void 0},this.addToQueue=s=>{this.queue.push(s)},this.processQueue=()=>{this.queue.length!==0&&(this.queue.forEach(s=>this.sendPost(s)),this.queue=[])},this.sendPost=s=>{var a;try{if(!this.iframe)return;(a=this.iframe.contentWindow)==null||a.postMessage(s,"*"),this.logger.info(`postMessage sent: ${s} ${this.verifyUrl}`)}catch{}},this.createIframe=async()=>{let s;const a=u=>{u.data==="verify_ready"&&(this.initialized=!0,this.processQueue(),window.removeEventListener("message",a),s())};await Promise.race([new Promise(u=>{if(document.getElementById(uo))return u();window.addEventListener("message",a);const l=document.createElement("iframe");l.id=uo,l.src=`${this.verifyUrl}/${this.projectId}`,l.style.display="none",document.body.append(l),this.iframe=l,s=u}),new Promise((u,l)=>setTimeout(()=>{window.removeEventListener("message",a),l("verify iframe load timeout")},q.cjs.toMiliseconds(q.cjs.FIVE_SECONDS)))])},this.removeIframe=()=>{this.iframe&&(this.iframe.remove(),this.iframe=void 0,this.initialized=!1)},this.getVerifyUrl=s=>{let a=s||Nr;return pE.includes(a)||(this.logger.info(`verify url: ${a}, not included in trusted list, assigning default: ${Nr}`),a=Nr),a},this.logger=S.E(r,this.name),this.verifyUrl=Nr,this.abortController=new AbortController,this.isDevEnv=qo()&&K.dist.process.env.IS_VITEST}get context(){return S.y(this.logger)}startAbortTimer(t){return this.abortController=new AbortController,setTimeout(()=>this.abortController.abort(),q.cjs.toMiliseconds(t))}}class UE extends C_{constructor(t,r){super(t,r),this.projectId=t,this.logger=r,this.context=fE,this.registerDeviceToken=async s=>{const{clientId:a,token:u,notificationType:l,enableEncrypted:g=!1}=s,v=`${dE}/${this.projectId}/clients`;await d0(v,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:a,type:l,token:u,always_raw:g})})},this.logger=S.E(r,this.context)}}var ME=Object.defineProperty,ch=Object.getOwnPropertySymbols,LE=Object.prototype.hasOwnProperty,kE=Object.prototype.propertyIsEnumerable,uh=(o,t,r)=>t in o?ME(o,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[t]=r,hh=(o,t)=>{for(var r in t||(t={}))LE.call(t,r)&&uh(o,r,t[r]);if(ch)for(var r of ch(t))kE.call(t,r)&&uh(o,r,t[r]);return o};class Lo extends b_{constructor(t){super(t),this.protocol=il,this.version=Ub,this.name=sl,this.events=new Ve.eventsExports.EventEmitter,this.initialized=!1,this.on=(s,a)=>this.events.on(s,a),this.once=(s,a)=>this.events.once(s,a),this.off=(s,a)=>this.events.off(s,a),this.removeListener=(s,a)=>this.events.removeListener(s,a),this.projectId=t==null?void 0:t.projectId,this.relayUrl=(t==null?void 0:t.relayUrl)||ol,this.customStoragePrefix=t!=null&&t.customStoragePrefix?`:${t.customStoragePrefix}`:"";const r=typeof(t==null?void 0:t.logger)<"u"&&typeof(t==null?void 0:t.logger)!="string"?t.logger:S.Tt(S.k({level:(t==null?void 0:t.logger)||Mb.logger}));this.logger=S.E(r,this.name),this.heartbeat=new xr.HeartBeat,this.crypto=new mE(this,this.logger,t==null?void 0:t.keychain),this.history=new jE(this,this.logger),this.expirer=new FE(this,this.logger),this.storage=t!=null&&t.storage?t.storage:new Gw(hh(hh({},Lb),t==null?void 0:t.storageOptions)),this.relayer=new CE({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new DE(this,this.logger),this.verify=new qE(this.projectId||"",this.logger),this.echoClient=new UE(this.projectId||"",this.logger)}static async init(t){const r=new Lo(t);await r.initialize();const s=await r.crypto.getClientId();return await r.storage.setItem(rE,s),r}get context(){return S.y(this.logger)}async start(){this.initialized||await this.initialize()}async initialize(){this.logger.trace("Initialized");try{await this.crypto.init(),await this.history.init(),await this.expirer.init(),await this.relayer.init(),await this.heartbeat.init(),await this.pairing.init(),this.initialized=!0,this.logger.info("Core Initialization Success")}catch(t){throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`,t),this.logger.error(t.message),t}}}const zE=Lo,al="wc",cl=2,ul="client",ko=`${al}@${cl}:${ul}:`,lo={name:ul,logger:"error"},lh="WALLETCONNECT_DEEPLINK_CHOICE",HE="proposal",hl="Proposal expired",KE="session",ys=q.cjs.SEVEN_DAYS,VE="engine",hi={wc_sessionPropose:{req:{ttl:q.cjs.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:q.cjs.FIVE_MINUTES,prompt:!1,tag:1101}},wc_sessionSettle:{req:{ttl:q.cjs.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:q.cjs.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:q.cjs.ONE_DAY,prompt:!1,tag:1104},res:{ttl:q.cjs.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:q.cjs.ONE_DAY,prompt:!1,tag:1106},res:{ttl:q.cjs.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:q.cjs.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:q.cjs.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:q.cjs.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:q.cjs.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:q.cjs.ONE_DAY,prompt:!1,tag:1112},res:{ttl:q.cjs.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:q.cjs.THIRTY_SECONDS,prompt:!1,tag:1114},res:{ttl:q.cjs.THIRTY_SECONDS,prompt:!1,tag:1115}}},po={min:q.cjs.FIVE_MINUTES,max:q.cjs.SEVEN_DAYS},At={idle:"IDLE",active:"ACTIVE"},BE="request",WE=["wc_sessionPropose","wc_sessionRequest","wc_authRequest"];var JE=Object.defineProperty,GE=Object.defineProperties,QE=Object.getOwnPropertyDescriptors,ph=Object.getOwnPropertySymbols,YE=Object.prototype.hasOwnProperty,ZE=Object.prototype.propertyIsEnumerable,fh=(o,t,r)=>t in o?JE(o,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[t]=r,ke=(o,t)=>{for(var r in t||(t={}))YE.call(t,r)&&fh(o,r,t[r]);if(ph)for(var r of ph(t))ZE.call(t,r)&&fh(o,r,t[r]);return o},li=(o,t)=>GE(o,QE(t));class XE extends A_{constructor(t){super(t),this.name=VE,this.events=new Ve.ss,this.initialized=!1,this.ignoredPayloadTypes=[ur],this.requestQueue={state:At.idle,queue:[]},this.sessionRequestQueue={state:At.idle,queue:[]},this.requestQueueDelay=q.cjs.ONE_SECOND,this.init=async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.registerPairingEvents(),this.client.core.pairing.register({methods:Object.keys(hi)}),this.initialized=!0,setTimeout(()=>{this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue()},q.cjs.toMiliseconds(this.requestQueueDelay)))},this.connect=async r=>{await this.isInitialized();const s=li(ke({},r),{requiredNamespaces:r.requiredNamespaces||{},optionalNamespaces:r.optionalNamespaces||{}});await this.isValidConnect(s);const{pairingTopic:a,requiredNamespaces:u,optionalNamespaces:l,sessionProperties:g,relays:v}=s;let d=a,E,_=!1;if(d&&(_=this.client.core.pairing.pairings.get(d).active),!d||!_){const{topic:Z,uri:ee}=await this.client.core.pairing.create();d=Z,E=ee}const I=await this.client.core.crypto.generateKeyPair(),T=ke({requiredNamespaces:u,optionalNamespaces:l,relays:v??[{protocol:nl}],proposer:{publicKey:I,metadata:this.client.metadata}},g&&{sessionProperties:g}),{reject:C,resolve:U,done:D}=$r(q.cjs.FIVE_MINUTES,hl);if(this.events.once(ve("session_connect"),async({error:Z,session:ee})=>{if(Z)C(Z);else if(ee){ee.self.publicKey=I;const le=li(ke({},ee),{requiredNamespaces:ee.requiredNamespaces,optionalNamespaces:ee.optionalNamespaces});await this.client.session.set(ee.topic,le),await this.setExpiry(ee.topic,ee.expiry),d&&await this.client.core.pairing.updateMetadata({topic:d,metadata:ee.peer.metadata}),U(le)}}),!d){const{message:Z}=A("NO_MATCHING_KEY",`connect() pairing topic: ${d}`);throw new Error(Z)}const B=await this.sendRequest({topic:d,method:"wc_sessionPropose",params:T}),ae=gt(q.cjs.FIVE_MINUTES);return await this.setProposal(B,ke({id:B,expiry:ae},T)),{uri:E,approval:D}},this.pair=async r=>(await this.isInitialized(),await this.client.core.pairing.pair(r)),this.approve=async r=>{await this.isInitialized(),await this.isValidApprove(r);const{id:s,relayProtocol:a,namespaces:u,sessionProperties:l}=r,g=this.client.proposal.get(s);let{pairingTopic:v,proposer:d,requiredNamespaces:E,optionalNamespaces:_}=g;v=v||"",Tr(E)||(E=N1(u,"approve()"));const I=await this.client.core.crypto.generateKeyPair(),T=d.publicKey,C=await this.client.core.crypto.generateSharedKey(I,T);v&&s&&(await this.client.core.pairing.updateMetadata({topic:v,metadata:d.metadata}),await this.sendResult({id:s,topic:v,result:{relay:{protocol:a??"irn"},responderPublicKey:I}}),await this.client.proposal.delete(s,ye("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:v}));const U=ke({relay:{protocol:a??"irn"},namespaces:u,requiredNamespaces:E,optionalNamespaces:_,pairingTopic:v,controller:{publicKey:I,metadata:this.client.metadata},expiry:gt(ys)},l&&{sessionProperties:l});await this.client.core.relayer.subscribe(C),await this.sendRequest({topic:C,method:"wc_sessionSettle",params:U,throwOnFailedPublish:!0});const D=li(ke({},U),{topic:C,pairingTopic:v,acknowledged:!1,self:U.controller,peer:{publicKey:d.publicKey,metadata:d.metadata},controller:I});return await this.client.session.set(C,D),await this.setExpiry(C,gt(ys)),{topic:C,acknowledged:()=>new Promise(B=>setTimeout(()=>B(this.client.session.get(C)),500))}},this.reject=async r=>{await this.isInitialized(),await this.isValidReject(r);const{id:s,reason:a}=r,{pairingTopic:u}=this.client.proposal.get(s);u&&(await this.sendError(s,u,a),await this.client.proposal.delete(s,ye("USER_DISCONNECTED")))},this.update=async r=>{await this.isInitialized(),await this.isValidUpdate(r);const{topic:s,namespaces:a}=r,u=await this.sendRequest({topic:s,method:"wc_sessionUpdate",params:{namespaces:a}}),{done:l,resolve:g,reject:v}=$r();return this.events.once(ve("session_update",u),({error:d})=>{d?v(d):g()}),await this.client.session.update(s,{namespaces:a}),{acknowledged:l}},this.extend=async r=>{await this.isInitialized(),await this.isValidExtend(r);const{topic:s}=r,a=await this.sendRequest({topic:s,method:"wc_sessionExtend",params:{}}),{done:u,resolve:l,reject:g}=$r();return this.events.once(ve("session_extend",a),({error:v})=>{v?g(v):l()}),await this.setExpiry(s,gt(ys)),{acknowledged:u}},this.request=async r=>{await this.isInitialized(),await this.isValidRequest(r);const{chainId:s,request:a,topic:u,expiry:l}=r,g=S.payloadId(),{done:v,resolve:d,reject:E}=$r(l,"Request expired. Please try again.");return this.events.once(ve("session_request",g),({error:_,result:I})=>{_?E(_):d(I)}),await Promise.all([new Promise(async _=>{await this.sendRequest({clientRpcId:g,topic:u,method:"wc_sessionRequest",params:{request:a,chainId:s},expiry:l,throwOnFailedPublish:!0}).catch(I=>E(I)),this.client.events.emit("session_request_sent",{topic:u,request:a,chainId:s,id:g}),_()}),new Promise(async _=>{const I=await m1(this.client.core.storage,lh);g1({id:g,topic:u,wcDeepLink:I}),_()}),v()]).then(_=>_[2])},this.respond=async r=>{await this.isInitialized(),await this.isValidRespond(r);const{topic:s,response:a}=r,{id:u}=a;S.isJsonRpcResult(a)?await this.sendResult({id:u,topic:s,result:a.result,throwOnFailedPublish:!0}):S.isJsonRpcError(a)&&await this.sendError(u,s,a.error),this.cleanupAfterResponse(r)},this.ping=async r=>{await this.isInitialized(),await this.isValidPing(r);const{topic:s}=r;if(this.client.session.keys.includes(s)){const a=await this.sendRequest({topic:s,method:"wc_sessionPing",params:{}}),{done:u,resolve:l,reject:g}=$r();this.events.once(ve("session_ping",a),({error:v})=>{v?g(v):l()}),await u()}else this.client.core.pairing.pairings.keys.includes(s)&&await this.client.core.pairing.ping({topic:s})},this.emit=async r=>{await this.isInitialized(),await this.isValidEmit(r);const{topic:s,event:a,chainId:u}=r;await this.sendRequest({topic:s,method:"wc_sessionEvent",params:{event:a,chainId:u}})},this.disconnect=async r=>{await this.isInitialized(),await this.isValidDisconnect(r);const{topic:s}=r;this.client.session.keys.includes(s)?(await this.sendRequest({topic:s,method:"wc_sessionDelete",params:ye("USER_DISCONNECTED"),throwOnFailedPublish:!0}),await this.deleteSession(s)):await this.client.core.pairing.disconnect({topic:s})},this.find=r=>(this.isInitialized(),this.client.session.getAll().filter(s=>A1(s,r))),this.getPendingSessionRequests=()=>(this.isInitialized(),this.client.pendingRequest.getAll()),this.cleanupDuplicatePairings=async r=>{if(r.pairingTopic)try{const s=this.client.core.pairing.pairings.get(r.pairingTopic),a=this.client.core.pairing.pairings.getAll().filter(u=>{var l,g;return((l=u.peerMetadata)==null?void 0:l.url)&&((g=u.peerMetadata)==null?void 0:g.url)===r.peer.metadata.url&&u.topic&&u.topic!==s.topic});if(a.length===0)return;this.client.logger.info(`Cleaning up ${a.length} duplicate pairing(s)`),await Promise.all(a.map(u=>this.client.core.pairing.disconnect({topic:u.topic}))),this.client.logger.info("Duplicate pairings clean up finished")}catch(s){this.client.logger.error(s)}},this.deleteSession=async(r,s)=>{const{self:a}=this.client.session.get(r);await this.client.core.relayer.unsubscribe(r),this.client.session.delete(r,ye("USER_DISCONNECTED")),this.client.core.crypto.keychain.has(a.publicKey)&&await this.client.core.crypto.deleteKeyPair(a.publicKey),this.client.core.crypto.keychain.has(r)&&await this.client.core.crypto.deleteSymKey(r),s||this.client.core.expirer.del(r),this.client.core.storage.removeItem(lh).catch(u=>this.client.logger.warn(u)),this.getPendingSessionRequests().forEach(u=>{u.topic===r&&this.deletePendingSessionRequest(u.id,ye("USER_DISCONNECTED"))})},this.deleteProposal=async(r,s)=>{await Promise.all([this.client.proposal.delete(r,ye("USER_DISCONNECTED")),s?Promise.resolve():this.client.core.expirer.del(r)])},this.deletePendingSessionRequest=async(r,s,a=!1)=>{await Promise.all([this.client.pendingRequest.delete(r,s),a?Promise.resolve():this.client.core.expirer.del(r)]),this.sessionRequestQueue.queue=this.sessionRequestQueue.queue.filter(u=>u.id!==r),a&&(this.sessionRequestQueue.state=At.idle)},this.setExpiry=async(r,s)=>{this.client.session.keys.includes(r)&&await this.client.session.update(r,{expiry:s}),this.client.core.expirer.set(r,s)},this.setProposal=async(r,s)=>{await this.client.proposal.set(r,s),this.client.core.expirer.set(r,s.expiry)},this.setPendingSessionRequest=async r=>{const s=hi.wc_sessionRequest.req.ttl,{id:a,topic:u,params:l,verifyContext:g}=r;await this.client.pendingRequest.set(a,{id:a,topic:u,params:l,verifyContext:g}),s&&this.client.core.expirer.set(a,gt(s))},this.sendRequest=async r=>{const{topic:s,method:a,params:u,expiry:l,relayRpcId:g,clientRpcId:v,throwOnFailedPublish:d}=r,E=S.formatJsonRpcRequest(a,u,v);if(Fr()&&WE.includes(a)){const T=Cr(JSON.stringify(E));this.client.core.verify.register({attestationId:T})}const _=await this.client.core.crypto.encode(s,E),I=hi[a].req;return l&&(I.ttl=l),g&&(I.id=g),this.client.core.history.set(s,E),d?(I.internal=li(ke({},I.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(s,_,I)):this.client.core.relayer.publish(s,_,I).catch(T=>this.client.logger.error(T)),E.id},this.sendResult=async r=>{const{id:s,topic:a,result:u,throwOnFailedPublish:l}=r,g=S.formatJsonRpcResult(s,u),v=await this.client.core.crypto.encode(a,g),d=await this.client.core.history.get(a,s),E=hi[d.request.method].res;l?(E.internal=li(ke({},E.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(a,v,E)):this.client.core.relayer.publish(a,v,E).catch(_=>this.client.logger.error(_)),await this.client.core.history.resolve(g)},this.sendError=async(r,s,a)=>{const u=S.formatJsonRpcError(r,a),l=await this.client.core.crypto.encode(s,u),g=await this.client.core.history.get(s,r),v=hi[g.request.method].res;this.client.core.relayer.publish(s,l,v),await this.client.core.history.resolve(u)},this.cleanup=async()=>{const r=[],s=[];this.client.session.getAll().forEach(a=>{Vt(a.expiry)&&r.push(a.topic)}),this.client.proposal.getAll().forEach(a=>{Vt(a.expiry)&&s.push(a.id)}),await Promise.all([...r.map(a=>this.deleteSession(a)),...s.map(a=>this.deleteProposal(a))])},this.onRelayEventRequest=async r=>{this.requestQueue.queue.push(r),await this.processRequestsQueue()},this.processRequestsQueue=async()=>{if(this.requestQueue.state===At.active){this.client.logger.info("Request queue already active, skipping...");return}for(this.client.logger.info(`Request queue starting with ${this.requestQueue.queue.length} requests`);this.requestQueue.queue.length>0;){this.requestQueue.state=At.active;const r=this.requestQueue.queue.shift();if(r)try{this.processRequest(r),await new Promise(s=>setTimeout(s,300))}catch(s){this.client.logger.warn(s)}}this.requestQueue.state=At.idle},this.processRequest=r=>{const{topic:s,payload:a}=r,u=a.method;switch(u){case"wc_sessionPropose":return this.onSessionProposeRequest(s,a);case"wc_sessionSettle":return this.onSessionSettleRequest(s,a);case"wc_sessionUpdate":return this.onSessionUpdateRequest(s,a);case"wc_sessionExtend":return this.onSessionExtendRequest(s,a);case"wc_sessionPing":return this.onSessionPingRequest(s,a);case"wc_sessionDelete":return this.onSessionDeleteRequest(s,a);case"wc_sessionRequest":return this.onSessionRequest(s,a);case"wc_sessionEvent":return this.onSessionEventRequest(s,a);default:return this.client.logger.info(`Unsupported request method ${u}`)}},this.onRelayEventResponse=async r=>{const{topic:s,payload:a}=r,u=(await this.client.core.history.get(s,a.id)).request.method;switch(u){case"wc_sessionPropose":return this.onSessionProposeResponse(s,a);case"wc_sessionSettle":return this.onSessionSettleResponse(s,a);case"wc_sessionUpdate":return this.onSessionUpdateResponse(s,a);case"wc_sessionExtend":return this.onSessionExtendResponse(s,a);case"wc_sessionPing":return this.onSessionPingResponse(s,a);case"wc_sessionRequest":return this.onSessionRequestResponse(s,a);default:return this.client.logger.info(`Unsupported response method ${u}`)}},this.onRelayEventUnknownPayload=r=>{const{topic:s}=r,{message:a}=A("MISSING_OR_INVALID",`Decoded payload on topic ${s} is not identifiable as a JSON-RPC request or a response.`);throw new Error(a)},this.onSessionProposeRequest=async(r,s)=>{const{params:a,id:u}=s;try{this.isValidConnect(ke({},s.params));const l=gt(q.cjs.FIVE_MINUTES),g=ke({id:u,pairingTopic:r,expiry:l},a);await this.setProposal(u,g);const v=Cr(JSON.stringify(s)),d=await this.getVerifyContext(v,g.proposer.metadata);this.client.events.emit("session_proposal",{id:u,params:g,verifyContext:d})}catch(l){await this.sendError(u,r,l),this.client.logger.error(l)}},this.onSessionProposeResponse=async(r,s)=>{const{id:a}=s;if(S.isJsonRpcResult(s)){const{result:u}=s;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:u});const l=this.client.proposal.get(a);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:l});const g=l.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:g});const v=u.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:v});const d=await this.client.core.crypto.generateSharedKey(g,v);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",sessionTopic:d});const E=await this.client.core.relayer.subscribe(d);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:E}),await this.client.core.pairing.activate({topic:r})}else S.isJsonRpcError(s)&&(await this.client.proposal.delete(a,ye("USER_DISCONNECTED")),this.events.emit(ve("session_connect"),{error:s.error}))},this.onSessionSettleRequest=async(r,s)=>{const{id:a,params:u}=s;try{this.isValidSessionSettleRequest(u);const{relay:l,controller:g,expiry:v,namespaces:d,requiredNamespaces:E,optionalNamespaces:_,sessionProperties:I,pairingTopic:T}=s.params,C=ke({topic:r,relay:l,expiry:v,namespaces:d,acknowledged:!0,pairingTopic:T,requiredNamespaces:E,optionalNamespaces:_,controller:g.publicKey,self:{publicKey:"",metadata:this.client.metadata},peer:{publicKey:g.publicKey,metadata:g.metadata}},I&&{sessionProperties:I});await this.sendResult({id:s.id,topic:r,result:!0}),this.events.emit(ve("session_connect"),{session:C}),this.cleanupDuplicatePairings(C)}catch(l){await this.sendError(a,r,l),this.client.logger.error(l)}},this.onSessionSettleResponse=async(r,s)=>{const{id:a}=s;S.isJsonRpcResult(s)?(await this.client.session.update(r,{acknowledged:!0}),this.events.emit(ve("session_approve",a),{})):S.isJsonRpcError(s)&&(await this.client.session.delete(r,ye("USER_DISCONNECTED")),this.events.emit(ve("session_approve",a),{error:s.error}))},this.onSessionUpdateRequest=async(r,s)=>{const{params:a,id:u}=s;try{const l=`${r}_session_update`,g=ms.get(l);if(g&&this.isRequestOutOfSync(g,u)){this.client.logger.info(`Discarding out of sync request - ${u}`);return}this.isValidUpdate(ke({topic:r},a)),await this.client.session.update(r,{namespaces:a.namespaces}),await this.sendResult({id:u,topic:r,result:!0}),this.client.events.emit("session_update",{id:u,topic:r,params:a}),ms.set(l,u)}catch(l){await this.sendError(u,r,l),this.client.logger.error(l)}},this.isRequestOutOfSync=(r,s)=>parseInt(s.toString().slice(0,-3))<=parseInt(r.toString().slice(0,-3)),this.onSessionUpdateResponse=(r,s)=>{const{id:a}=s;S.isJsonRpcResult(s)?this.events.emit(ve("session_update",a),{}):S.isJsonRpcError(s)&&this.events.emit(ve("session_update",a),{error:s.error})},this.onSessionExtendRequest=async(r,s)=>{const{id:a}=s;try{this.isValidExtend({topic:r}),await this.setExpiry(r,gt(ys)),await this.sendResult({id:a,topic:r,result:!0}),this.client.events.emit("session_extend",{id:a,topic:r})}catch(u){await this.sendError(a,r,u),this.client.logger.error(u)}},this.onSessionExtendResponse=(r,s)=>{const{id:a}=s;S.isJsonRpcResult(s)?this.events.emit(ve("session_extend",a),{}):S.isJsonRpcError(s)&&this.events.emit(ve("session_extend",a),{error:s.error})},this.onSessionPingRequest=async(r,s)=>{const{id:a}=s;try{this.isValidPing({topic:r}),await this.sendResult({id:a,topic:r,result:!0}),this.client.events.emit("session_ping",{id:a,topic:r})}catch(u){await this.sendError(a,r,u),this.client.logger.error(u)}},this.onSessionPingResponse=(r,s)=>{const{id:a}=s;setTimeout(()=>{S.isJsonRpcResult(s)?this.events.emit(ve("session_ping",a),{}):S.isJsonRpcError(s)&&this.events.emit(ve("session_ping",a),{error:s.error})},500)},this.onSessionDeleteRequest=async(r,s)=>{const{id:a}=s;try{this.isValidDisconnect({topic:r,reason:s.params}),await Promise.all([new Promise(u=>{this.client.core.relayer.once(Ne.publish,async()=>{u(await this.deleteSession(r))})}),this.sendResult({id:a,topic:r,result:!0})]),this.client.events.emit("session_delete",{id:a,topic:r})}catch(u){this.client.logger.error(u)}},this.onSessionRequest=async(r,s)=>{const{id:a,params:u}=s;try{this.isValidRequest(ke({topic:r},u));const l=Cr(JSON.stringify(S.formatJsonRpcRequest("wc_sessionRequest",u,a))),g=this.client.session.get(r),v=await this.getVerifyContext(l,g.peer.metadata),d={id:a,topic:r,params:u,verifyContext:v};await this.setPendingSessionRequest(d),this.addSessionRequestToSessionRequestQueue(d),this.processSessionRequestQueue()}catch(l){await this.sendError(a,r,l),this.client.logger.error(l)}},this.onSessionRequestResponse=(r,s)=>{const{id:a}=s;S.isJsonRpcResult(s)?this.events.emit(ve("session_request",a),{result:s.result}):S.isJsonRpcError(s)&&this.events.emit(ve("session_request",a),{error:s.error})},this.onSessionEventRequest=async(r,s)=>{const{id:a,params:u}=s;try{const l=`${r}_session_event_${u.event.name}`,g=ms.get(l);if(g&&this.isRequestOutOfSync(g,a)){this.client.logger.info(`Discarding out of sync request - ${a}`);return}this.isValidEmit(ke({topic:r},u)),this.client.events.emit("session_event",{id:a,topic:r,params:u}),ms.set(l,a)}catch(l){await this.sendError(a,r,l),this.client.logger.error(l)}},this.addSessionRequestToSessionRequestQueue=r=>{this.sessionRequestQueue.queue.push(r)},this.cleanupAfterResponse=r=>{this.deletePendingSessionRequest(r.response.id,{message:"fulfilled",code:0}),setTimeout(()=>{this.sessionRequestQueue.state=At.idle,this.processSessionRequestQueue()},q.cjs.toMiliseconds(this.requestQueueDelay))},this.processSessionRequestQueue=()=>{if(this.sessionRequestQueue.state===At.active){this.client.logger.info("session request queue is already active.");return}const r=this.sessionRequestQueue.queue[0];if(!r){this.client.logger.info("session request queue is empty.");return}try{this.sessionRequestQueue.state=At.active,this.client.events.emit("session_request",r)}catch(s){this.client.logger.error(s)}},this.onPairingCreated=r=>{if(r.active)return;const s=this.client.proposal.getAll().find(a=>a.pairingTopic===r.topic);s&&this.onSessionProposeRequest(r.topic,S.formatJsonRpcRequest("wc_sessionPropose",{requiredNamespaces:s.requiredNamespaces,optionalNamespaces:s.optionalNamespaces,relays:s.relays,proposer:s.proposer,sessionProperties:s.sessionProperties},s.id))},this.isValidConnect=async r=>{if(!He(r)){const{message:v}=A("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(r)}`);throw new Error(v)}const{pairingTopic:s,requiredNamespaces:a,optionalNamespaces:u,sessionProperties:l,relays:g}=r;if(De(s)||await this.isValidPairingTopic(s),!K1(g)){const{message:v}=A("MISSING_OR_INVALID",`connect() relays: ${g}`);throw new Error(v)}!De(a)&&Tr(a)!==0&&this.validateNamespaces(a,"requiredNamespaces"),!De(u)&&Tr(u)!==0&&this.validateNamespaces(u,"optionalNamespaces"),De(l)||this.validateSessionProps(l,"sessionProperties")},this.validateNamespaces=(r,s)=>{const a=H1(r,"connect()",s);if(a)throw new Error(a.message)},this.isValidApprove=async r=>{if(!He(r))throw new Error(A("MISSING_OR_INVALID",`approve() params: ${r}`).message);const{id:s,namespaces:a,relayProtocol:u,sessionProperties:l}=r;await this.isValidProposalId(s);const g=this.client.proposal.get(s),v=Is(a,"approve()");if(v)throw new Error(v.message);const d=ku(g.requiredNamespaces,a,"approve()");if(d)throw new Error(d.message);if(!Ie(u,!0)){const{message:E}=A("MISSING_OR_INVALID",`approve() relayProtocol: ${u}`);throw new Error(E)}De(l)||this.validateSessionProps(l,"sessionProperties")},this.isValidReject=async r=>{if(!He(r)){const{message:u}=A("MISSING_OR_INVALID",`reject() params: ${r}`);throw new Error(u)}const{id:s,reason:a}=r;if(await this.isValidProposalId(s),!B1(a)){const{message:u}=A("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(a)}`);throw new Error(u)}},this.isValidSessionSettleRequest=r=>{if(!He(r)){const{message:d}=A("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${r}`);throw new Error(d)}const{relay:s,controller:a,namespaces:u,expiry:l}=r;if(!Vh(s)){const{message:d}=A("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(d)}const g=q1(a,"onSessionSettleRequest()");if(g)throw new Error(g.message);const v=Is(u,"onSessionSettleRequest()");if(v)throw new Error(v.message);if(Vt(l)){const{message:d}=A("EXPIRED","onSessionSettleRequest()");throw new Error(d)}},this.isValidUpdate=async r=>{if(!He(r)){const{message:v}=A("MISSING_OR_INVALID",`update() params: ${r}`);throw new Error(v)}const{topic:s,namespaces:a}=r;await this.isValidSessionTopic(s);const u=this.client.session.get(s),l=Is(a,"update()");if(l)throw new Error(l.message);const g=ku(u.requiredNamespaces,a,"update()");if(g)throw new Error(g.message)},this.isValidExtend=async r=>{if(!He(r)){const{message:a}=A("MISSING_OR_INVALID",`extend() params: ${r}`);throw new Error(a)}const{topic:s}=r;await this.isValidSessionTopic(s)},this.isValidRequest=async r=>{if(!He(r)){const{message:v}=A("MISSING_OR_INVALID",`request() params: ${r}`);throw new Error(v)}const{topic:s,request:a,chainId:u,expiry:l}=r;await this.isValidSessionTopic(s);const{namespaces:g}=this.client.session.get(s);if(!Lu(g,u)){const{message:v}=A("MISSING_OR_INVALID",`request() chainId: ${u}`);throw new Error(v)}if(!W1(a)){const{message:v}=A("MISSING_OR_INVALID",`request() ${JSON.stringify(a)}`);throw new Error(v)}if(!Q1(g,u,a.method)){const{message:v}=A("MISSING_OR_INVALID",`request() method: ${a.method}`);throw new Error(v)}if(l&&!e0(l,po)){const{message:v}=A("MISSING_OR_INVALID",`request() expiry: ${l}. Expiry must be a number (in seconds) between ${po.min} and ${po.max}`);throw new Error(v)}},this.isValidRespond=async r=>{var s;if(!He(r)){const{message:l}=A("MISSING_OR_INVALID",`respond() params: ${r}`);throw new Error(l)}const{topic:a,response:u}=r;try{await this.isValidSessionTopic(a)}catch(l){throw(s=r==null?void 0:r.response)!=null&&s.id&&this.cleanupAfterResponse(r),l}if(!J1(u)){const{message:l}=A("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(u)}`);throw new Error(l)}},this.isValidPing=async r=>{if(!He(r)){const{message:a}=A("MISSING_OR_INVALID",`ping() params: ${r}`);throw new Error(a)}const{topic:s}=r;await this.isValidSessionOrPairingTopic(s)},this.isValidEmit=async r=>{if(!He(r)){const{message:g}=A("MISSING_OR_INVALID",`emit() params: ${r}`);throw new Error(g)}const{topic:s,event:a,chainId:u}=r;await this.isValidSessionTopic(s);const{namespaces:l}=this.client.session.get(s);if(!Lu(l,u)){const{message:g}=A("MISSING_OR_INVALID",`emit() chainId: ${u}`);throw new Error(g)}if(!G1(a)){const{message:g}=A("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(a)}`);throw new Error(g)}if(!Y1(l,u,a.name)){const{message:g}=A("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(a)}`);throw new Error(g)}},this.isValidDisconnect=async r=>{if(!He(r)){const{message:a}=A("MISSING_OR_INVALID",`disconnect() params: ${r}`);throw new Error(a)}const{topic:s}=r;await this.isValidSessionOrPairingTopic(s)},this.getVerifyContext=async(r,s)=>{const a={verified:{verifyUrl:s.verifyUrl||Nr,validation:"UNKNOWN",origin:s.url||""}};try{const u=await this.client.core.verify.resolve({attestationId:r,verifyUrl:s.verifyUrl});u&&(a.verified.origin=u.origin,a.verified.isScam=u.isScam,a.verified.validation=u.origin===new URL(s.url).origin?"VALID":"INVALID")}catch(u){this.client.logger.info(u)}return this.client.logger.info(`Verify context: ${JSON.stringify(a)}`),a},this.validateSessionProps=(r,s)=>{Object.values(r).forEach(a=>{if(!Ie(a,!1)){const{message:u}=A("MISSING_OR_INVALID",`${s} must be in Record<string, string> format. Received: ${JSON.stringify(a)}`);throw new Error(u)}})}}async isInitialized(){if(!this.initialized){const{message:t}=A("NOT_INITIALIZED",this.name);throw new Error(t)}await this.client.core.relayer.confirmOnlineStateOrThrow()}registerRelayerEvents(){this.client.core.relayer.on(Ne.message,async t=>{const{topic:r,message:s}=t;if(this.ignoredPayloadTypes.includes(this.client.core.crypto.getPayloadType(s)))return;const a=await this.client.core.crypto.decode(r,s);try{S.isJsonRpcRequest(a)?(this.client.core.history.set(r,a),this.onRelayEventRequest({topic:r,payload:a})):S.isJsonRpcResponse(a)?(await this.client.core.history.resolve(a),await this.onRelayEventResponse({topic:r,payload:a}),this.client.core.history.delete(r,a.id)):this.onRelayEventUnknownPayload({topic:r,payload:a})}catch(u){this.client.logger.error(u)}})}registerExpirerEvents(){this.client.core.expirer.on(at.expired,async t=>{const{topic:r,id:s}=Hh(t.target);if(s&&this.client.pendingRequest.keys.includes(s))return await this.deletePendingSessionRequest(s,A("EXPIRED"),!0);r?this.client.session.keys.includes(r)&&(await this.deleteSession(r,!0),this.client.events.emit("session_expire",{topic:r})):s&&(await this.deleteProposal(s,!0),this.client.events.emit("proposal_expire",{id:s}))})}registerPairingEvents(){this.client.core.pairing.events.on(di.create,t=>this.onPairingCreated(t))}isValidPairingTopic(t){if(!Ie(t,!1)){const{message:r}=A("MISSING_OR_INVALID",`pairing topic should be a string: ${t}`);throw new Error(r)}if(!this.client.core.pairing.pairings.keys.includes(t)){const{message:r}=A("NO_MATCHING_KEY",`pairing topic doesn't exist: ${t}`);throw new Error(r)}if(Vt(this.client.core.pairing.pairings.get(t).expiry)){const{message:r}=A("EXPIRED",`pairing topic: ${t}`);throw new Error(r)}}async isValidSessionTopic(t){if(!Ie(t,!1)){const{message:r}=A("MISSING_OR_INVALID",`session topic should be a string: ${t}`);throw new Error(r)}if(!this.client.session.keys.includes(t)){const{message:r}=A("NO_MATCHING_KEY",`session topic doesn't exist: ${t}`);throw new Error(r)}if(Vt(this.client.session.get(t).expiry)){await this.deleteSession(t);const{message:r}=A("EXPIRED",`session topic: ${t}`);throw new Error(r)}}async isValidSessionOrPairingTopic(t){if(this.client.session.keys.includes(t))await this.isValidSessionTopic(t);else if(this.client.core.pairing.pairings.keys.includes(t))this.isValidPairingTopic(t);else if(Ie(t,!1)){const{message:r}=A("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${t}`);throw new Error(r)}else{const{message:r}=A("MISSING_OR_INVALID",`session or pairing topic should be a string: ${t}`);throw new Error(r)}}async isValidProposalId(t){if(!V1(t)){const{message:r}=A("MISSING_OR_INVALID",`proposal id should be a number: ${t}`);throw new Error(r)}if(!this.client.proposal.keys.includes(t)){const{message:r}=A("NO_MATCHING_KEY",`proposal id doesn't exist: ${t}`);throw new Error(r)}if(Vt(this.client.proposal.get(t).expiry)){await this.deleteProposal(t);const{message:r}=A("EXPIRED",`proposal id: ${t}`);throw new Error(r)}}}class eI extends xs{constructor(t,r){super(t,r,HE,ko),this.core=t,this.logger=r}}class tI extends xs{constructor(t,r){super(t,r,KE,ko),this.core=t,this.logger=r}}class rI extends xs{constructor(t,r){super(t,r,BE,ko,s=>s.id),this.core=t,this.logger=r}}let iI=class ll extends T_{constructor(t){super(t),this.protocol=al,this.version=cl,this.name=lo.name,this.events=new Ve.eventsExports.EventEmitter,this.on=(s,a)=>this.events.on(s,a),this.once=(s,a)=>this.events.once(s,a),this.off=(s,a)=>this.events.off(s,a),this.removeListener=(s,a)=>this.events.removeListener(s,a),this.removeAllListeners=s=>this.events.removeAllListeners(s),this.connect=async s=>{try{return await this.engine.connect(s)}catch(a){throw this.logger.error(a.message),a}},this.pair=async s=>{try{return await this.engine.pair(s)}catch(a){throw this.logger.error(a.message),a}},this.approve=async s=>{try{return await this.engine.approve(s)}catch(a){throw this.logger.error(a.message),a}},this.reject=async s=>{try{return await this.engine.reject(s)}catch(a){throw this.logger.error(a.message),a}},this.update=async s=>{try{return await this.engine.update(s)}catch(a){throw this.logger.error(a.message),a}},this.extend=async s=>{try{return await this.engine.extend(s)}catch(a){throw this.logger.error(a.message),a}},this.request=async s=>{try{return await this.engine.request(s)}catch(a){throw this.logger.error(a.message),a}},this.respond=async s=>{try{return await this.engine.respond(s)}catch(a){throw this.logger.error(a.message),a}},this.ping=async s=>{try{return await this.engine.ping(s)}catch(a){throw this.logger.error(a.message),a}},this.emit=async s=>{try{return await this.engine.emit(s)}catch(a){throw this.logger.error(a.message),a}},this.disconnect=async s=>{try{return await this.engine.disconnect(s)}catch(a){throw this.logger.error(a.message),a}},this.find=s=>{try{return this.engine.find(s)}catch(a){throw this.logger.error(a.message),a}},this.getPendingSessionRequests=()=>{try{return this.engine.getPendingSessionRequests()}catch(s){throw this.logger.error(s.message),s}},this.name=(t==null?void 0:t.name)||lo.name,this.metadata=(t==null?void 0:t.metadata)||c1();const r=typeof(t==null?void 0:t.logger)<"u"&&typeof(t==null?void 0:t.logger)!="string"?t.logger:S.Tt(S.k({level:(t==null?void 0:t.logger)||lo.logger}));this.core=(t==null?void 0:t.core)||new zE(t),this.logger=S.E(r,this.name),this.session=new tI(this.core,this.logger),this.proposal=new eI(this.core,this.logger),this.pendingRequest=new rI(this.core,this.logger),this.engine=new XE(this)}static async init(t){const r=new ll(t);return await r.initialize(),r}get context(){return S.y(this.logger)}get pairing(){return this.core.pairing.pairings}async initialize(){this.logger.trace("Initialized");try{await this.core.start(),await this.session.init(),await this.proposal.init(),await this.pendingRequest.init(),await this.engine.init(),this.core.verify.init({verifyUrl:this.metadata.verifyUrl}),this.logger.info("SignClient Initialization Success")}catch(t){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(t.message),t}}};const sI=o=>JSON.stringify(o,(t,r)=>typeof r=="bigint"?r.toString()+"n":r),nI=o=>{const t=/([\[:])?(\d{17,}|(?:[9](?:[1-9]07199254740991|0[1-9]7199254740991|00[8-9]199254740991|007[2-9]99254740991|007199[3-9]54740991|0071992[6-9]4740991|00719925[5-9]740991|007199254[8-9]40991|0071992547[5-9]0991|00719925474[1-9]991|00719925474099[2-9])))([,\}\]])/g,r=o.replace(t,'$1"$2n"$3');return JSON.parse(r,(s,a)=>typeof a=="string"&&a.match(/^\d+n$/)?BigInt(a.substring(0,a.length-1)):a)};function oI(o){if(typeof o!="string")throw new Error(`Cannot safe json parse value of type ${typeof o}`);try{return nI(o)}catch{return o}}function dh(o){return typeof o=="string"?o:sI(o)||""}var aI=Object.defineProperty,cI=Object.defineProperties,uI=Object.getOwnPropertyDescriptors,gh=Object.getOwnPropertySymbols,hI=Object.prototype.hasOwnProperty,lI=Object.prototype.propertyIsEnumerable,mh=(o,t,r)=>t in o?aI(o,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[t]=r,yh=(o,t)=>{for(var r in t||(t={}))hI.call(t,r)&&mh(o,r,t[r]);if(gh)for(var r of gh(t))lI.call(t,r)&&mh(o,r,t[r]);return o},vh=(o,t)=>cI(o,uI(t));const pI={Accept:"application/json","Content-Type":"application/json"},fI="POST",wh={headers:pI,method:fI},_h=10;let Jt=class{constructor(t,r=!1){if(this.url=t,this.disableProviderPing=r,this.events=new Ve.eventsExports.EventEmitter,this.isAvailable=!1,this.registering=!1,!S.isHttpUrl(t))throw new Error(`Provided URL is not compatible with HTTP connection: ${t}`);this.url=t,this.disableProviderPing=r}get connected(){return this.isAvailable}get connecting(){return this.registering}on(t,r){this.events.on(t,r)}once(t,r){this.events.once(t,r)}off(t,r){this.events.off(t,r)}removeListener(t,r){this.events.removeListener(t,r)}async open(t=this.url){await this.register(t)}async close(){if(!this.isAvailable)throw new Error("Connection already closed");this.onClose()}async send(t){this.isAvailable||await this.register();try{const r=dh(t),s=await(await K.o(this.url,vh(yh({},wh),{body:r}))).json();this.onPayload({data:s})}catch(r){this.onError(t.id,r)}}async register(t=this.url){if(!S.isHttpUrl(t))throw new Error(`Provided URL is not compatible with HTTP connection: ${t}`);if(this.registering){const r=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=r||this.events.listenerCount("open")>=r)&&this.events.setMaxListeners(r+1),new Promise((s,a)=>{this.events.once("register_error",u=>{this.resetMaxListeners(),a(u)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.isAvailable>"u")return a(new Error("HTTP connection is missing or invalid"));s()})})}this.url=t,this.registering=!0;try{if(!this.disableProviderPing){const r=dh({id:1,jsonrpc:"2.0",method:"test",params:[]});await K.o(t,vh(yh({},wh),{body:r}))}this.onOpen()}catch(r){const s=this.parseError(r);throw this.events.emit("register_error",s),this.onClose(),s}}onOpen(){this.isAvailable=!0,this.registering=!1,this.events.emit("open")}onClose(){this.isAvailable=!1,this.registering=!1,this.events.emit("close")}onPayload(t){if(typeof t.data>"u")return;const r=typeof t.data=="string"?oI(t.data):t.data;this.events.emit("payload",r)}onError(t,r){const s=this.parseError(r),a=s.message||s.toString(),u=S.formatJsonRpcError(t,a);this.events.emit("payload",u)}parseError(t,r=this.url){return S.parseConnectionError(t,r,"HTTP")}resetMaxListeners(){this.events.getMaxListeners()>_h&&this.events.setMaxListeners(_h)}};const bh="error",dI="wss://relay.walletconnect.com",gI="wc",mI="universal_provider",Eh=`${gI}@2:${mI}:`,yI="https://rpc.walletconnect.com/v1/",Dt={DEFAULT_CHAIN_CHANGED:"default_chain_changed"};var pi=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof K.dist.global<"u"?K.dist.global:typeof self<"u"?self:{},Co={exports:{}};/**
|
|
21
|
-
* @license
|
|
22
|
-
* Lodash <https://lodash.com/>
|
|
23
|
-
* Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
|
|
24
|
-
* Released under MIT license <https://lodash.com/license>
|
|
25
|
-
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
|
26
|
-
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|
27
|
-
*/(function(o,t){(function(){var r,s="4.17.21",a=200,u="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",l="Expected a function",g="Invalid `variable` option passed into `_.template`",v="__lodash_hash_undefined__",d=500,E="__lodash_placeholder__",_=1,I=2,T=4,C=1,U=2,D=1,B=2,ae=4,Z=8,ee=16,le=32,Fe=64,de=128,Ce=256,jt=512,ml=30,yl="...",vl=800,wl=16,Ho=1,_l=2,bl=3,bi=1/0,lr=9007199254740991,El=17976931348623157e292,Ei=NaN,mt=4294967295,Il=mt-1,Pl=mt>>>1,Sl=[["ary",de],["bind",D],["bindKey",B],["curry",Z],["curryRight",ee],["flip",jt],["partial",le],["partialRight",Fe],["rearg",Ce]],pr="[object Arguments]",Ii="[object Array]",Ol="[object AsyncFunction]",Ur="[object Boolean]",Mr="[object Date]",Rl="[object DOMException]",Pi="[object Error]",Si="[object Function]",Ko="[object GeneratorFunction]",ct="[object Map]",Lr="[object Number]",$l="[object Null]",bt="[object Object]",Vo="[object Promise]",Nl="[object Proxy]",kr="[object RegExp]",ut="[object Set]",zr="[object String]",Oi="[object Symbol]",Cl="[object Undefined]",Hr="[object WeakMap]",Tl="[object WeakSet]",Kr="[object ArrayBuffer]",fr="[object DataView]",js="[object Float32Array]",Fs="[object Float64Array]",qs="[object Int8Array]",Us="[object Int16Array]",Ms="[object Int32Array]",Ls="[object Uint8Array]",ks="[object Uint8ClampedArray]",zs="[object Uint16Array]",Hs="[object Uint32Array]",Al=/\b__p \+= '';/g,xl=/\b(__p \+=) '' \+/g,Dl=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Bo=/&(?:amp|lt|gt|quot|#39);/g,Wo=/[&<>"']/g,jl=RegExp(Bo.source),Fl=RegExp(Wo.source),ql=/<%-([\s\S]+?)%>/g,Ul=/<%([\s\S]+?)%>/g,Jo=/<%=([\s\S]+?)%>/g,Ml=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Ll=/^\w*$/,kl=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Ks=/[\\^$.*+?()[\]{}|]/g,zl=RegExp(Ks.source),Vs=/^\s+/,Hl=/\s/,Kl=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Vl=/\{\n\/\* \[wrapped with (.+)\] \*/,Bl=/,? & /,Wl=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Jl=/[()=,{}\[\]\/\s]/,Gl=/\\(\\)?/g,Ql=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,Go=/\w*$/,Yl=/^[-+]0x[0-9a-f]+$/i,Zl=/^0b[01]+$/i,Xl=/^\[object .+?Constructor\]$/,ep=/^0o[0-7]+$/i,tp=/^(?:0|[1-9]\d*)$/,rp=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Ri=/($^)/,ip=/['\n\r\u2028\u2029\\]/g,$i="\\ud800-\\udfff",sp="\\u0300-\\u036f",np="\\ufe20-\\ufe2f",op="\\u20d0-\\u20ff",Qo=sp+np+op,Yo="\\u2700-\\u27bf",Zo="a-z\\xdf-\\xf6\\xf8-\\xff",ap="\\xac\\xb1\\xd7\\xf7",cp="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",up="\\u2000-\\u206f",hp=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Xo="A-Z\\xc0-\\xd6\\xd8-\\xde",ea="\\ufe0e\\ufe0f",ta=ap+cp+up+hp,Bs="['’]",lp="["+$i+"]",ra="["+ta+"]",Ni="["+Qo+"]",ia="\\d+",pp="["+Yo+"]",sa="["+Zo+"]",na="[^"+$i+ta+ia+Yo+Zo+Xo+"]",Ws="\\ud83c[\\udffb-\\udfff]",fp="(?:"+Ni+"|"+Ws+")",oa="[^"+$i+"]",Js="(?:\\ud83c[\\udde6-\\uddff]){2}",Gs="[\\ud800-\\udbff][\\udc00-\\udfff]",dr="["+Xo+"]",aa="\\u200d",ca="(?:"+sa+"|"+na+")",dp="(?:"+dr+"|"+na+")",ua="(?:"+Bs+"(?:d|ll|m|re|s|t|ve))?",ha="(?:"+Bs+"(?:D|LL|M|RE|S|T|VE))?",la=fp+"?",pa="["+ea+"]?",gp="(?:"+aa+"(?:"+[oa,Js,Gs].join("|")+")"+pa+la+")*",mp="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",yp="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",fa=pa+la+gp,vp="(?:"+[pp,Js,Gs].join("|")+")"+fa,wp="(?:"+[oa+Ni+"?",Ni,Js,Gs,lp].join("|")+")",_p=RegExp(Bs,"g"),bp=RegExp(Ni,"g"),Qs=RegExp(Ws+"(?="+Ws+")|"+wp+fa,"g"),Ep=RegExp([dr+"?"+sa+"+"+ua+"(?="+[ra,dr,"$"].join("|")+")",dp+"+"+ha+"(?="+[ra,dr+ca,"$"].join("|")+")",dr+"?"+ca+"+"+ua,dr+"+"+ha,yp,mp,ia,vp].join("|"),"g"),Ip=RegExp("["+aa+$i+Qo+ea+"]"),Pp=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Sp=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],Op=-1,ce={};ce[js]=ce[Fs]=ce[qs]=ce[Us]=ce[Ms]=ce[Ls]=ce[ks]=ce[zs]=ce[Hs]=!0,ce[pr]=ce[Ii]=ce[Kr]=ce[Ur]=ce[fr]=ce[Mr]=ce[Pi]=ce[Si]=ce[ct]=ce[Lr]=ce[bt]=ce[kr]=ce[ut]=ce[zr]=ce[Hr]=!1;var se={};se[pr]=se[Ii]=se[Kr]=se[fr]=se[Ur]=se[Mr]=se[js]=se[Fs]=se[qs]=se[Us]=se[Ms]=se[ct]=se[Lr]=se[bt]=se[kr]=se[ut]=se[zr]=se[Oi]=se[Ls]=se[ks]=se[zs]=se[Hs]=!0,se[Pi]=se[Si]=se[Hr]=!1;var Rp={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"},$p={"&":"&","<":"<",">":">",'"':""","'":"'"},Np={"&":"&","<":"<",">":">",""":'"',"'":"'"},Cp={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Tp=parseFloat,Ap=parseInt,da=typeof pi=="object"&&pi&&pi.Object===Object&&pi,xp=typeof self=="object"&&self&&self.Object===Object&&self,Pe=da||xp||Function("return this")(),Ys=t&&!t.nodeType&&t,Gt=Ys&&!0&&o&&!o.nodeType&&o,ga=Gt&&Gt.exports===Ys,Zs=ga&&da.process,Xe=function(){try{var w=Gt&&Gt.require&&Gt.require("util").types;return w||Zs&&Zs.binding&&Zs.binding("util")}catch{}}(),ma=Xe&&Xe.isArrayBuffer,ya=Xe&&Xe.isDate,va=Xe&&Xe.isMap,wa=Xe&&Xe.isRegExp,_a=Xe&&Xe.isSet,ba=Xe&&Xe.isTypedArray;function Be(w,O,P){switch(P.length){case 0:return w.call(O);case 1:return w.call(O,P[0]);case 2:return w.call(O,P[0],P[1]);case 3:return w.call(O,P[0],P[1],P[2])}return w.apply(O,P)}function Dp(w,O,P,j){for(var z=-1,X=w==null?0:w.length;++z<X;){var we=w[z];O(j,we,P(we),w)}return j}function et(w,O){for(var P=-1,j=w==null?0:w.length;++P<j&&O(w[P],P,w)!==!1;);return w}function jp(w,O){for(var P=w==null?0:w.length;P--&&O(w[P],P,w)!==!1;);return w}function Ea(w,O){for(var P=-1,j=w==null?0:w.length;++P<j;)if(!O(w[P],P,w))return!1;return!0}function Ft(w,O){for(var P=-1,j=w==null?0:w.length,z=0,X=[];++P<j;){var we=w[P];O(we,P,w)&&(X[z++]=we)}return X}function Ci(w,O){var P=w==null?0:w.length;return!!P&&gr(w,O,0)>-1}function Xs(w,O,P){for(var j=-1,z=w==null?0:w.length;++j<z;)if(P(O,w[j]))return!0;return!1}function ue(w,O){for(var P=-1,j=w==null?0:w.length,z=Array(j);++P<j;)z[P]=O(w[P],P,w);return z}function qt(w,O){for(var P=-1,j=O.length,z=w.length;++P<j;)w[z+P]=O[P];return w}function en(w,O,P,j){var z=-1,X=w==null?0:w.length;for(j&&X&&(P=w[++z]);++z<X;)P=O(P,w[z],z,w);return P}function Fp(w,O,P,j){var z=w==null?0:w.length;for(j&&z&&(P=w[--z]);z--;)P=O(P,w[z],z,w);return P}function tn(w,O){for(var P=-1,j=w==null?0:w.length;++P<j;)if(O(w[P],P,w))return!0;return!1}var qp=rn("length");function Up(w){return w.split("")}function Mp(w){return w.match(Wl)||[]}function Ia(w,O,P){var j;return P(w,function(z,X,we){if(O(z,X,we))return j=X,!1}),j}function Ti(w,O,P,j){for(var z=w.length,X=P+(j?1:-1);j?X--:++X<z;)if(O(w[X],X,w))return X;return-1}function gr(w,O,P){return O===O?Yp(w,O,P):Ti(w,Pa,P)}function Lp(w,O,P,j){for(var z=P-1,X=w.length;++z<X;)if(j(w[z],O))return z;return-1}function Pa(w){return w!==w}function Sa(w,O){var P=w==null?0:w.length;return P?nn(w,O)/P:Ei}function rn(w){return function(O){return O==null?r:O[w]}}function sn(w){return function(O){return w==null?r:w[O]}}function Oa(w,O,P,j,z){return z(w,function(X,we,ie){P=j?(j=!1,X):O(P,X,we,ie)}),P}function kp(w,O){var P=w.length;for(w.sort(O);P--;)w[P]=w[P].value;return w}function nn(w,O){for(var P,j=-1,z=w.length;++j<z;){var X=O(w[j]);X!==r&&(P=P===r?X:P+X)}return P}function on(w,O){for(var P=-1,j=Array(w);++P<w;)j[P]=O(P);return j}function zp(w,O){return ue(O,function(P){return[P,w[P]]})}function Ra(w){return w&&w.slice(0,Ta(w)+1).replace(Vs,"")}function We(w){return function(O){return w(O)}}function an(w,O){return ue(O,function(P){return w[P]})}function Vr(w,O){return w.has(O)}function $a(w,O){for(var P=-1,j=w.length;++P<j&&gr(O,w[P],0)>-1;);return P}function Na(w,O){for(var P=w.length;P--&&gr(O,w[P],0)>-1;);return P}function Hp(w,O){for(var P=w.length,j=0;P--;)w[P]===O&&++j;return j}var Kp=sn(Rp),Vp=sn($p);function Bp(w){return"\\"+Cp[w]}function Wp(w,O){return w==null?r:w[O]}function mr(w){return Ip.test(w)}function Jp(w){return Pp.test(w)}function Gp(w){for(var O,P=[];!(O=w.next()).done;)P.push(O.value);return P}function cn(w){var O=-1,P=Array(w.size);return w.forEach(function(j,z){P[++O]=[z,j]}),P}function Ca(w,O){return function(P){return w(O(P))}}function Ut(w,O){for(var P=-1,j=w.length,z=0,X=[];++P<j;){var we=w[P];(we===O||we===E)&&(w[P]=E,X[z++]=P)}return X}function Ai(w){var O=-1,P=Array(w.size);return w.forEach(function(j){P[++O]=j}),P}function Qp(w){var O=-1,P=Array(w.size);return w.forEach(function(j){P[++O]=[j,j]}),P}function Yp(w,O,P){for(var j=P-1,z=w.length;++j<z;)if(w[j]===O)return j;return-1}function Zp(w,O,P){for(var j=P+1;j--;)if(w[j]===O)return j;return j}function yr(w){return mr(w)?ef(w):qp(w)}function ht(w){return mr(w)?tf(w):Up(w)}function Ta(w){for(var O=w.length;O--&&Hl.test(w.charAt(O)););return O}var Xp=sn(Np);function ef(w){for(var O=Qs.lastIndex=0;Qs.test(w);)++O;return O}function tf(w){return w.match(Qs)||[]}function rf(w){return w.match(Ep)||[]}var sf=function w(O){O=O==null?Pe:vr.defaults(Pe.Object(),O,vr.pick(Pe,Sp));var P=O.Array,j=O.Date,z=O.Error,X=O.Function,we=O.Math,ie=O.Object,un=O.RegExp,nf=O.String,tt=O.TypeError,xi=P.prototype,of=X.prototype,wr=ie.prototype,Di=O["__core-js_shared__"],ji=of.toString,re=wr.hasOwnProperty,af=0,Aa=function(){var e=/[^.]+$/.exec(Di&&Di.keys&&Di.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),Fi=wr.toString,cf=ji.call(ie),uf=Pe._,hf=un("^"+ji.call(re).replace(Ks,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),qi=ga?O.Buffer:r,Mt=O.Symbol,Ui=O.Uint8Array,xa=qi?qi.allocUnsafe:r,Mi=Ca(ie.getPrototypeOf,ie),Da=ie.create,ja=wr.propertyIsEnumerable,Li=xi.splice,Fa=Mt?Mt.isConcatSpreadable:r,Br=Mt?Mt.iterator:r,Qt=Mt?Mt.toStringTag:r,ki=function(){try{var e=tr(ie,"defineProperty");return e({},"",{}),e}catch{}}(),lf=O.clearTimeout!==Pe.clearTimeout&&O.clearTimeout,pf=j&&j.now!==Pe.Date.now&&j.now,ff=O.setTimeout!==Pe.setTimeout&&O.setTimeout,zi=we.ceil,Hi=we.floor,hn=ie.getOwnPropertySymbols,df=qi?qi.isBuffer:r,qa=O.isFinite,gf=xi.join,mf=Ca(ie.keys,ie),_e=we.max,Re=we.min,yf=j.now,vf=O.parseInt,Ua=we.random,wf=xi.reverse,ln=tr(O,"DataView"),Wr=tr(O,"Map"),pn=tr(O,"Promise"),_r=tr(O,"Set"),Jr=tr(O,"WeakMap"),Gr=tr(ie,"create"),Ki=Jr&&new Jr,br={},_f=rr(ln),bf=rr(Wr),Ef=rr(pn),If=rr(_r),Pf=rr(Jr),Vi=Mt?Mt.prototype:r,Qr=Vi?Vi.valueOf:r,Ma=Vi?Vi.toString:r;function p(e){if(fe(e)&&!H(e)&&!(e instanceof Q)){if(e instanceof rt)return e;if(re.call(e,"__wrapped__"))return Lc(e)}return new rt(e)}var Er=function(){function e(){}return function(i){if(!pe(i))return{};if(Da)return Da(i);e.prototype=i;var n=new e;return e.prototype=r,n}}();function Bi(){}function rt(e,i){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!i,this.__index__=0,this.__values__=r}p.templateSettings={escape:ql,evaluate:Ul,interpolate:Jo,variable:"",imports:{_:p}},p.prototype=Bi.prototype,p.prototype.constructor=p,rt.prototype=Er(Bi.prototype),rt.prototype.constructor=rt;function Q(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=mt,this.__views__=[]}function Sf(){var e=new Q(this.__wrapped__);return e.__actions__=qe(this.__actions__),e.__dir__=this.__dir__,e.__filtered__=this.__filtered__,e.__iteratees__=qe(this.__iteratees__),e.__takeCount__=this.__takeCount__,e.__views__=qe(this.__views__),e}function Of(){if(this.__filtered__){var e=new Q(this);e.__dir__=-1,e.__filtered__=!0}else e=this.clone(),e.__dir__*=-1;return e}function Rf(){var e=this.__wrapped__.value(),i=this.__dir__,n=H(e),c=i<0,h=n?e.length:0,f=Md(0,h,this.__views__),m=f.start,y=f.end,b=y-m,R=c?y:m-1,$=this.__iteratees__,N=$.length,x=0,F=Re(b,this.__takeCount__);if(!n||!c&&h==b&&F==b)return uc(e,this.__actions__);var L=[];e:for(;b--&&x<F;){R+=i;for(var W=-1,k=e[R];++W<N;){var G=$[W],Y=G.iteratee,Qe=G.type,xe=Y(k);if(Qe==_l)k=xe;else if(!xe){if(Qe==Ho)continue e;break e}}L[x++]=k}return L}Q.prototype=Er(Bi.prototype),Q.prototype.constructor=Q;function Yt(e){var i=-1,n=e==null?0:e.length;for(this.clear();++i<n;){var c=e[i];this.set(c[0],c[1])}}function $f(){this.__data__=Gr?Gr(null):{},this.size=0}function Nf(e){var i=this.has(e)&&delete this.__data__[e];return this.size-=i?1:0,i}function Cf(e){var i=this.__data__;if(Gr){var n=i[e];return n===v?r:n}return re.call(i,e)?i[e]:r}function Tf(e){var i=this.__data__;return Gr?i[e]!==r:re.call(i,e)}function Af(e,i){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=Gr&&i===r?v:i,this}Yt.prototype.clear=$f,Yt.prototype.delete=Nf,Yt.prototype.get=Cf,Yt.prototype.has=Tf,Yt.prototype.set=Af;function Et(e){var i=-1,n=e==null?0:e.length;for(this.clear();++i<n;){var c=e[i];this.set(c[0],c[1])}}function xf(){this.__data__=[],this.size=0}function Df(e){var i=this.__data__,n=Wi(i,e);if(n<0)return!1;var c=i.length-1;return n==c?i.pop():Li.call(i,n,1),--this.size,!0}function jf(e){var i=this.__data__,n=Wi(i,e);return n<0?r:i[n][1]}function Ff(e){return Wi(this.__data__,e)>-1}function qf(e,i){var n=this.__data__,c=Wi(n,e);return c<0?(++this.size,n.push([e,i])):n[c][1]=i,this}Et.prototype.clear=xf,Et.prototype.delete=Df,Et.prototype.get=jf,Et.prototype.has=Ff,Et.prototype.set=qf;function It(e){var i=-1,n=e==null?0:e.length;for(this.clear();++i<n;){var c=e[i];this.set(c[0],c[1])}}function Uf(){this.size=0,this.__data__={hash:new Yt,map:new(Wr||Et),string:new Yt}}function Mf(e){var i=ns(this,e).delete(e);return this.size-=i?1:0,i}function Lf(e){return ns(this,e).get(e)}function kf(e){return ns(this,e).has(e)}function zf(e,i){var n=ns(this,e),c=n.size;return n.set(e,i),this.size+=n.size==c?0:1,this}It.prototype.clear=Uf,It.prototype.delete=Mf,It.prototype.get=Lf,It.prototype.has=kf,It.prototype.set=zf;function Zt(e){var i=-1,n=e==null?0:e.length;for(this.__data__=new It;++i<n;)this.add(e[i])}function Hf(e){return this.__data__.set(e,v),this}function Kf(e){return this.__data__.has(e)}Zt.prototype.add=Zt.prototype.push=Hf,Zt.prototype.has=Kf;function lt(e){var i=this.__data__=new Et(e);this.size=i.size}function Vf(){this.__data__=new Et,this.size=0}function Bf(e){var i=this.__data__,n=i.delete(e);return this.size=i.size,n}function Wf(e){return this.__data__.get(e)}function Jf(e){return this.__data__.has(e)}function Gf(e,i){var n=this.__data__;if(n instanceof Et){var c=n.__data__;if(!Wr||c.length<a-1)return c.push([e,i]),this.size=++n.size,this;n=this.__data__=new It(c)}return n.set(e,i),this.size=n.size,this}lt.prototype.clear=Vf,lt.prototype.delete=Bf,lt.prototype.get=Wf,lt.prototype.has=Jf,lt.prototype.set=Gf;function La(e,i){var n=H(e),c=!n&&ir(e),h=!n&&!c&&Kt(e),f=!n&&!c&&!h&&Or(e),m=n||c||h||f,y=m?on(e.length,nf):[],b=y.length;for(var R in e)(i||re.call(e,R))&&!(m&&(R=="length"||h&&(R=="offset"||R=="parent")||f&&(R=="buffer"||R=="byteLength"||R=="byteOffset")||Rt(R,b)))&&y.push(R);return y}function ka(e){var i=e.length;return i?e[In(0,i-1)]:r}function Qf(e,i){return os(qe(e),Xt(i,0,e.length))}function Yf(e){return os(qe(e))}function fn(e,i,n){(n!==r&&!pt(e[i],n)||n===r&&!(i in e))&&Pt(e,i,n)}function Yr(e,i,n){var c=e[i];(!(re.call(e,i)&&pt(c,n))||n===r&&!(i in e))&&Pt(e,i,n)}function Wi(e,i){for(var n=e.length;n--;)if(pt(e[n][0],i))return n;return-1}function Zf(e,i,n,c){return Lt(e,function(h,f,m){i(c,h,n(h),m)}),c}function za(e,i){return e&&vt(i,be(i),e)}function Xf(e,i){return e&&vt(i,Me(i),e)}function Pt(e,i,n){i=="__proto__"&&ki?ki(e,i,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[i]=n}function dn(e,i){for(var n=-1,c=i.length,h=P(c),f=e==null;++n<c;)h[n]=f?r:Jn(e,i[n]);return h}function Xt(e,i,n){return e===e&&(n!==r&&(e=e<=n?e:n),i!==r&&(e=e>=i?e:i)),e}function it(e,i,n,c,h,f){var m,y=i&_,b=i&I,R=i&T;if(n&&(m=h?n(e,c,h,f):n(e)),m!==r)return m;if(!pe(e))return e;var $=H(e);if($){if(m=kd(e),!y)return qe(e,m)}else{var N=$e(e),x=N==Si||N==Ko;if(Kt(e))return pc(e,y);if(N==bt||N==pr||x&&!h){if(m=b||x?{}:Tc(e),!y)return b?Cd(e,Xf(m,e)):Nd(e,za(m,e))}else{if(!se[N])return h?e:{};m=zd(e,N,y)}}f||(f=new lt);var F=f.get(e);if(F)return F;f.set(e,m),ou(e)?e.forEach(function(k){m.add(it(k,i,n,k,e,f))}):su(e)&&e.forEach(function(k,G){m.set(G,it(k,i,n,G,e,f))});var L=R?b?Dn:xn:b?Me:be,W=$?r:L(e);return et(W||e,function(k,G){W&&(G=k,k=e[G]),Yr(m,G,it(k,i,n,G,e,f))}),m}function ed(e){var i=be(e);return function(n){return Ha(n,e,i)}}function Ha(e,i,n){var c=n.length;if(e==null)return!c;for(e=ie(e);c--;){var h=n[c],f=i[h],m=e[h];if(m===r&&!(h in e)||!f(m))return!1}return!0}function Ka(e,i,n){if(typeof e!="function")throw new tt(l);return si(function(){e.apply(r,n)},i)}function Zr(e,i,n,c){var h=-1,f=Ci,m=!0,y=e.length,b=[],R=i.length;if(!y)return b;n&&(i=ue(i,We(n))),c?(f=Xs,m=!1):i.length>=a&&(f=Vr,m=!1,i=new Zt(i));e:for(;++h<y;){var $=e[h],N=n==null?$:n($);if($=c||$!==0?$:0,m&&N===N){for(var x=R;x--;)if(i[x]===N)continue e;b.push($)}else f(i,N,c)||b.push($)}return b}var Lt=yc(yt),Va=yc(mn,!0);function td(e,i){var n=!0;return Lt(e,function(c,h,f){return n=!!i(c,h,f),n}),n}function Ji(e,i,n){for(var c=-1,h=e.length;++c<h;){var f=e[c],m=i(f);if(m!=null&&(y===r?m===m&&!Ge(m):n(m,y)))var y=m,b=f}return b}function rd(e,i,n,c){var h=e.length;for(n=V(n),n<0&&(n=-n>h?0:h+n),c=c===r||c>h?h:V(c),c<0&&(c+=h),c=n>c?0:cu(c);n<c;)e[n++]=i;return e}function Ba(e,i){var n=[];return Lt(e,function(c,h,f){i(c,h,f)&&n.push(c)}),n}function Se(e,i,n,c,h){var f=-1,m=e.length;for(n||(n=Kd),h||(h=[]);++f<m;){var y=e[f];i>0&&n(y)?i>1?Se(y,i-1,n,c,h):qt(h,y):c||(h[h.length]=y)}return h}var gn=vc(),Wa=vc(!0);function yt(e,i){return e&&gn(e,i,be)}function mn(e,i){return e&&Wa(e,i,be)}function Gi(e,i){return Ft(i,function(n){return $t(e[n])})}function er(e,i){i=zt(i,e);for(var n=0,c=i.length;e!=null&&n<c;)e=e[wt(i[n++])];return n&&n==c?e:r}function Ja(e,i,n){var c=i(e);return H(e)?c:qt(c,n(e))}function Te(e){return e==null?e===r?Cl:$l:Qt&&Qt in ie(e)?Ud(e):Yd(e)}function yn(e,i){return e>i}function id(e,i){return e!=null&&re.call(e,i)}function sd(e,i){return e!=null&&i in ie(e)}function nd(e,i,n){return e>=Re(i,n)&&e<_e(i,n)}function vn(e,i,n){for(var c=n?Xs:Ci,h=e[0].length,f=e.length,m=f,y=P(f),b=1/0,R=[];m--;){var $=e[m];m&&i&&($=ue($,We(i))),b=Re($.length,b),y[m]=!n&&(i||h>=120&&$.length>=120)?new Zt(m&&$):r}$=e[0];var N=-1,x=y[0];e:for(;++N<h&&R.length<b;){var F=$[N],L=i?i(F):F;if(F=n||F!==0?F:0,!(x?Vr(x,L):c(R,L,n))){for(m=f;--m;){var W=y[m];if(!(W?Vr(W,L):c(e[m],L,n)))continue e}x&&x.push(L),R.push(F)}}return R}function od(e,i,n,c){return yt(e,function(h,f,m){i(c,n(h),f,m)}),c}function Xr(e,i,n){i=zt(i,e),e=jc(e,i);var c=e==null?e:e[wt(nt(i))];return c==null?r:Be(c,e,n)}function Ga(e){return fe(e)&&Te(e)==pr}function ad(e){return fe(e)&&Te(e)==Kr}function cd(e){return fe(e)&&Te(e)==Mr}function ei(e,i,n,c,h){return e===i?!0:e==null||i==null||!fe(e)&&!fe(i)?e!==e&&i!==i:ud(e,i,n,c,ei,h)}function ud(e,i,n,c,h,f){var m=H(e),y=H(i),b=m?Ii:$e(e),R=y?Ii:$e(i);b=b==pr?bt:b,R=R==pr?bt:R;var $=b==bt,N=R==bt,x=b==R;if(x&&Kt(e)){if(!Kt(i))return!1;m=!0,$=!1}if(x&&!$)return f||(f=new lt),m||Or(e)?$c(e,i,n,c,h,f):Fd(e,i,b,n,c,h,f);if(!(n&C)){var F=$&&re.call(e,"__wrapped__"),L=N&&re.call(i,"__wrapped__");if(F||L){var W=F?e.value():e,k=L?i.value():i;return f||(f=new lt),h(W,k,n,c,f)}}return x?(f||(f=new lt),qd(e,i,n,c,h,f)):!1}function hd(e){return fe(e)&&$e(e)==ct}function wn(e,i,n,c){var h=n.length,f=h,m=!c;if(e==null)return!f;for(e=ie(e);h--;){var y=n[h];if(m&&y[2]?y[1]!==e[y[0]]:!(y[0]in e))return!1}for(;++h<f;){y=n[h];var b=y[0],R=e[b],$=y[1];if(m&&y[2]){if(R===r&&!(b in e))return!1}else{var N=new lt;if(c)var x=c(R,$,b,e,i,N);if(!(x===r?ei($,R,C|U,c,N):x))return!1}}return!0}function Qa(e){if(!pe(e)||Bd(e))return!1;var i=$t(e)?hf:Xl;return i.test(rr(e))}function ld(e){return fe(e)&&Te(e)==kr}function pd(e){return fe(e)&&$e(e)==ut}function fd(e){return fe(e)&&ps(e.length)&&!!ce[Te(e)]}function Ya(e){return typeof e=="function"?e:e==null?Le:typeof e=="object"?H(e)?ec(e[0],e[1]):Xa(e):wu(e)}function _n(e){if(!ii(e))return mf(e);var i=[];for(var n in ie(e))re.call(e,n)&&n!="constructor"&&i.push(n);return i}function dd(e){if(!pe(e))return Qd(e);var i=ii(e),n=[];for(var c in e)c=="constructor"&&(i||!re.call(e,c))||n.push(c);return n}function bn(e,i){return e<i}function Za(e,i){var n=-1,c=Ue(e)?P(e.length):[];return Lt(e,function(h,f,m){c[++n]=i(h,f,m)}),c}function Xa(e){var i=Fn(e);return i.length==1&&i[0][2]?xc(i[0][0],i[0][1]):function(n){return n===e||wn(n,e,i)}}function ec(e,i){return Un(e)&&Ac(i)?xc(wt(e),i):function(n){var c=Jn(n,e);return c===r&&c===i?Gn(n,e):ei(i,c,C|U)}}function Qi(e,i,n,c,h){e!==i&&gn(i,function(f,m){if(h||(h=new lt),pe(f))gd(e,i,m,n,Qi,c,h);else{var y=c?c(Ln(e,m),f,m+"",e,i,h):r;y===r&&(y=f),fn(e,m,y)}},Me)}function gd(e,i,n,c,h,f,m){var y=Ln(e,n),b=Ln(i,n),R=m.get(b);if(R){fn(e,n,R);return}var $=f?f(y,b,n+"",e,i,m):r,N=$===r;if(N){var x=H(b),F=!x&&Kt(b),L=!x&&!F&&Or(b);$=b,x||F||L?H(y)?$=y:ge(y)?$=qe(y):F?(N=!1,$=pc(b,!0)):L?(N=!1,$=fc(b,!0)):$=[]:ni(b)||ir(b)?($=y,ir(y)?$=uu(y):(!pe(y)||$t(y))&&($=Tc(b))):N=!1}N&&(m.set(b,$),h($,b,c,f,m),m.delete(b)),fn(e,n,$)}function tc(e,i){var n=e.length;if(n)return i+=i<0?n:0,Rt(i,n)?e[i]:r}function rc(e,i,n){i.length?i=ue(i,function(f){return H(f)?function(m){return er(m,f.length===1?f[0]:f)}:f}):i=[Le];var c=-1;i=ue(i,We(M()));var h=Za(e,function(f,m,y){var b=ue(i,function(R){return R(f)});return{criteria:b,index:++c,value:f}});return kp(h,function(f,m){return $d(f,m,n)})}function md(e,i){return ic(e,i,function(n,c){return Gn(e,c)})}function ic(e,i,n){for(var c=-1,h=i.length,f={};++c<h;){var m=i[c],y=er(e,m);n(y,m)&&ti(f,zt(m,e),y)}return f}function yd(e){return function(i){return er(i,e)}}function En(e,i,n,c){var h=c?Lp:gr,f=-1,m=i.length,y=e;for(e===i&&(i=qe(i)),n&&(y=ue(e,We(n)));++f<m;)for(var b=0,R=i[f],$=n?n(R):R;(b=h(y,$,b,c))>-1;)y!==e&&Li.call(y,b,1),Li.call(e,b,1);return e}function sc(e,i){for(var n=e?i.length:0,c=n-1;n--;){var h=i[n];if(n==c||h!==f){var f=h;Rt(h)?Li.call(e,h,1):On(e,h)}}return e}function In(e,i){return e+Hi(Ua()*(i-e+1))}function vd(e,i,n,c){for(var h=-1,f=_e(zi((i-e)/(n||1)),0),m=P(f);f--;)m[c?f:++h]=e,e+=n;return m}function Pn(e,i){var n="";if(!e||i<1||i>lr)return n;do i%2&&(n+=e),i=Hi(i/2),i&&(e+=e);while(i);return n}function J(e,i){return kn(Dc(e,i,Le),e+"")}function wd(e){return ka(Rr(e))}function _d(e,i){var n=Rr(e);return os(n,Xt(i,0,n.length))}function ti(e,i,n,c){if(!pe(e))return e;i=zt(i,e);for(var h=-1,f=i.length,m=f-1,y=e;y!=null&&++h<f;){var b=wt(i[h]),R=n;if(b==="__proto__"||b==="constructor"||b==="prototype")return e;if(h!=m){var $=y[b];R=c?c($,b,y):r,R===r&&(R=pe($)?$:Rt(i[h+1])?[]:{})}Yr(y,b,R),y=y[b]}return e}var nc=Ki?function(e,i){return Ki.set(e,i),e}:Le,bd=ki?function(e,i){return ki(e,"toString",{configurable:!0,enumerable:!1,value:Yn(i),writable:!0})}:Le;function Ed(e){return os(Rr(e))}function st(e,i,n){var c=-1,h=e.length;i<0&&(i=-i>h?0:h+i),n=n>h?h:n,n<0&&(n+=h),h=i>n?0:n-i>>>0,i>>>=0;for(var f=P(h);++c<h;)f[c]=e[c+i];return f}function Id(e,i){var n;return Lt(e,function(c,h,f){return n=i(c,h,f),!n}),!!n}function Yi(e,i,n){var c=0,h=e==null?c:e.length;if(typeof i=="number"&&i===i&&h<=Pl){for(;c<h;){var f=c+h>>>1,m=e[f];m!==null&&!Ge(m)&&(n?m<=i:m<i)?c=f+1:h=f}return h}return Sn(e,i,Le,n)}function Sn(e,i,n,c){var h=0,f=e==null?0:e.length;if(f===0)return 0;i=n(i);for(var m=i!==i,y=i===null,b=Ge(i),R=i===r;h<f;){var $=Hi((h+f)/2),N=n(e[$]),x=N!==r,F=N===null,L=N===N,W=Ge(N);if(m)var k=c||L;else R?k=L&&(c||x):y?k=L&&x&&(c||!F):b?k=L&&x&&!F&&(c||!W):F||W?k=!1:k=c?N<=i:N<i;k?h=$+1:f=$}return Re(f,Il)}function oc(e,i){for(var n=-1,c=e.length,h=0,f=[];++n<c;){var m=e[n],y=i?i(m):m;if(!n||!pt(y,b)){var b=y;f[h++]=m===0?0:m}}return f}function ac(e){return typeof e=="number"?e:Ge(e)?Ei:+e}function Je(e){if(typeof e=="string")return e;if(H(e))return ue(e,Je)+"";if(Ge(e))return Ma?Ma.call(e):"";var i=e+"";return i=="0"&&1/e==-1/0?"-0":i}function kt(e,i,n){var c=-1,h=Ci,f=e.length,m=!0,y=[],b=y;if(n)m=!1,h=Xs;else if(f>=a){var R=i?null:Dd(e);if(R)return Ai(R);m=!1,h=Vr,b=new Zt}else b=i?[]:y;e:for(;++c<f;){var $=e[c],N=i?i($):$;if($=n||$!==0?$:0,m&&N===N){for(var x=b.length;x--;)if(b[x]===N)continue e;i&&b.push(N),y.push($)}else h(b,N,n)||(b!==y&&b.push(N),y.push($))}return y}function On(e,i){return i=zt(i,e),e=jc(e,i),e==null||delete e[wt(nt(i))]}function cc(e,i,n,c){return ti(e,i,n(er(e,i)),c)}function Zi(e,i,n,c){for(var h=e.length,f=c?h:-1;(c?f--:++f<h)&&i(e[f],f,e););return n?st(e,c?0:f,c?f+1:h):st(e,c?f+1:0,c?h:f)}function uc(e,i){var n=e;return n instanceof Q&&(n=n.value()),en(i,function(c,h){return h.func.apply(h.thisArg,qt([c],h.args))},n)}function Rn(e,i,n){var c=e.length;if(c<2)return c?kt(e[0]):[];for(var h=-1,f=P(c);++h<c;)for(var m=e[h],y=-1;++y<c;)y!=h&&(f[h]=Zr(f[h]||m,e[y],i,n));return kt(Se(f,1),i,n)}function hc(e,i,n){for(var c=-1,h=e.length,f=i.length,m={};++c<h;){var y=c<f?i[c]:r;n(m,e[c],y)}return m}function $n(e){return ge(e)?e:[]}function Nn(e){return typeof e=="function"?e:Le}function zt(e,i){return H(e)?e:Un(e,i)?[e]:Mc(te(e))}var Pd=J;function Ht(e,i,n){var c=e.length;return n=n===r?c:n,!i&&n>=c?e:st(e,i,n)}var lc=lf||function(e){return Pe.clearTimeout(e)};function pc(e,i){if(i)return e.slice();var n=e.length,c=xa?xa(n):new e.constructor(n);return e.copy(c),c}function Cn(e){var i=new e.constructor(e.byteLength);return new Ui(i).set(new Ui(e)),i}function Sd(e,i){var n=i?Cn(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}function Od(e){var i=new e.constructor(e.source,Go.exec(e));return i.lastIndex=e.lastIndex,i}function Rd(e){return Qr?ie(Qr.call(e)):{}}function fc(e,i){var n=i?Cn(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}function dc(e,i){if(e!==i){var n=e!==r,c=e===null,h=e===e,f=Ge(e),m=i!==r,y=i===null,b=i===i,R=Ge(i);if(!y&&!R&&!f&&e>i||f&&m&&b&&!y&&!R||c&&m&&b||!n&&b||!h)return 1;if(!c&&!f&&!R&&e<i||R&&n&&h&&!c&&!f||y&&n&&h||!m&&h||!b)return-1}return 0}function $d(e,i,n){for(var c=-1,h=e.criteria,f=i.criteria,m=h.length,y=n.length;++c<m;){var b=dc(h[c],f[c]);if(b){if(c>=y)return b;var R=n[c];return b*(R=="desc"?-1:1)}}return e.index-i.index}function gc(e,i,n,c){for(var h=-1,f=e.length,m=n.length,y=-1,b=i.length,R=_e(f-m,0),$=P(b+R),N=!c;++y<b;)$[y]=i[y];for(;++h<m;)(N||h<f)&&($[n[h]]=e[h]);for(;R--;)$[y++]=e[h++];return $}function mc(e,i,n,c){for(var h=-1,f=e.length,m=-1,y=n.length,b=-1,R=i.length,$=_e(f-y,0),N=P($+R),x=!c;++h<$;)N[h]=e[h];for(var F=h;++b<R;)N[F+b]=i[b];for(;++m<y;)(x||h<f)&&(N[F+n[m]]=e[h++]);return N}function qe(e,i){var n=-1,c=e.length;for(i||(i=P(c));++n<c;)i[n]=e[n];return i}function vt(e,i,n,c){var h=!n;n||(n={});for(var f=-1,m=i.length;++f<m;){var y=i[f],b=c?c(n[y],e[y],y,n,e):r;b===r&&(b=e[y]),h?Pt(n,y,b):Yr(n,y,b)}return n}function Nd(e,i){return vt(e,qn(e),i)}function Cd(e,i){return vt(e,Nc(e),i)}function Xi(e,i){return function(n,c){var h=H(n)?Dp:Zf,f=i?i():{};return h(n,e,M(c,2),f)}}function Ir(e){return J(function(i,n){var c=-1,h=n.length,f=h>1?n[h-1]:r,m=h>2?n[2]:r;for(f=e.length>3&&typeof f=="function"?(h--,f):r,m&&Ae(n[0],n[1],m)&&(f=h<3?r:f,h=1),i=ie(i);++c<h;){var y=n[c];y&&e(i,y,c,f)}return i})}function yc(e,i){return function(n,c){if(n==null)return n;if(!Ue(n))return e(n,c);for(var h=n.length,f=i?h:-1,m=ie(n);(i?f--:++f<h)&&c(m[f],f,m)!==!1;);return n}}function vc(e){return function(i,n,c){for(var h=-1,f=ie(i),m=c(i),y=m.length;y--;){var b=m[e?y:++h];if(n(f[b],b,f)===!1)break}return i}}function Td(e,i,n){var c=i&D,h=ri(e);function f(){var m=this&&this!==Pe&&this instanceof f?h:e;return m.apply(c?n:this,arguments)}return f}function wc(e){return function(i){i=te(i);var n=mr(i)?ht(i):r,c=n?n[0]:i.charAt(0),h=n?Ht(n,1).join(""):i.slice(1);return c[e]()+h}}function Pr(e){return function(i){return en(yu(mu(i).replace(_p,"")),e,"")}}function ri(e){return function(){var i=arguments;switch(i.length){case 0:return new e;case 1:return new e(i[0]);case 2:return new e(i[0],i[1]);case 3:return new e(i[0],i[1],i[2]);case 4:return new e(i[0],i[1],i[2],i[3]);case 5:return new e(i[0],i[1],i[2],i[3],i[4]);case 6:return new e(i[0],i[1],i[2],i[3],i[4],i[5]);case 7:return new e(i[0],i[1],i[2],i[3],i[4],i[5],i[6])}var n=Er(e.prototype),c=e.apply(n,i);return pe(c)?c:n}}function Ad(e,i,n){var c=ri(e);function h(){for(var f=arguments.length,m=P(f),y=f,b=Sr(h);y--;)m[y]=arguments[y];var R=f<3&&m[0]!==b&&m[f-1]!==b?[]:Ut(m,b);if(f-=R.length,f<n)return Pc(e,i,es,h.placeholder,r,m,R,r,r,n-f);var $=this&&this!==Pe&&this instanceof h?c:e;return Be($,this,m)}return h}function _c(e){return function(i,n,c){var h=ie(i);if(!Ue(i)){var f=M(n,3);i=be(i),n=function(y){return f(h[y],y,h)}}var m=e(i,n,c);return m>-1?h[f?i[m]:m]:r}}function bc(e){return Ot(function(i){var n=i.length,c=n,h=rt.prototype.thru;for(e&&i.reverse();c--;){var f=i[c];if(typeof f!="function")throw new tt(l);if(h&&!m&&ss(f)=="wrapper")var m=new rt([],!0)}for(c=m?c:n;++c<n;){f=i[c];var y=ss(f),b=y=="wrapper"?jn(f):r;b&&Mn(b[0])&&b[1]==(de|Z|le|Ce)&&!b[4].length&&b[9]==1?m=m[ss(b[0])].apply(m,b[3]):m=f.length==1&&Mn(f)?m[y]():m.thru(f)}return function(){var R=arguments,$=R[0];if(m&&R.length==1&&H($))return m.plant($).value();for(var N=0,x=n?i[N].apply(this,R):$;++N<n;)x=i[N].call(this,x);return x}})}function es(e,i,n,c,h,f,m,y,b,R){var $=i&de,N=i&D,x=i&B,F=i&(Z|ee),L=i&jt,W=x?r:ri(e);function k(){for(var G=arguments.length,Y=P(G),Qe=G;Qe--;)Y[Qe]=arguments[Qe];if(F)var xe=Sr(k),Ye=Hp(Y,xe);if(c&&(Y=gc(Y,c,h,F)),f&&(Y=mc(Y,f,m,F)),G-=Ye,F&&G<R){var me=Ut(Y,xe);return Pc(e,i,es,k.placeholder,n,Y,me,y,b,R-G)}var ft=N?n:this,Ct=x?ft[e]:e;return G=Y.length,y?Y=Zd(Y,y):L&&G>1&&Y.reverse(),$&&b<G&&(Y.length=b),this&&this!==Pe&&this instanceof k&&(Ct=W||ri(Ct)),Ct.apply(ft,Y)}return k}function Ec(e,i){return function(n,c){return od(n,e,i(c),{})}}function ts(e,i){return function(n,c){var h;if(n===r&&c===r)return i;if(n!==r&&(h=n),c!==r){if(h===r)return c;typeof n=="string"||typeof c=="string"?(n=Je(n),c=Je(c)):(n=ac(n),c=ac(c)),h=e(n,c)}return h}}function Tn(e){return Ot(function(i){return i=ue(i,We(M())),J(function(n){var c=this;return e(i,function(h){return Be(h,c,n)})})})}function rs(e,i){i=i===r?" ":Je(i);var n=i.length;if(n<2)return n?Pn(i,e):i;var c=Pn(i,zi(e/yr(i)));return mr(i)?Ht(ht(c),0,e).join(""):c.slice(0,e)}function xd(e,i,n,c){var h=i&D,f=ri(e);function m(){for(var y=-1,b=arguments.length,R=-1,$=c.length,N=P($+b),x=this&&this!==Pe&&this instanceof m?f:e;++R<$;)N[R]=c[R];for(;b--;)N[R++]=arguments[++y];return Be(x,h?n:this,N)}return m}function Ic(e){return function(i,n,c){return c&&typeof c!="number"&&Ae(i,n,c)&&(n=c=r),i=Nt(i),n===r?(n=i,i=0):n=Nt(n),c=c===r?i<n?1:-1:Nt(c),vd(i,n,c,e)}}function is(e){return function(i,n){return typeof i=="string"&&typeof n=="string"||(i=ot(i),n=ot(n)),e(i,n)}}function Pc(e,i,n,c,h,f,m,y,b,R){var $=i&Z,N=$?m:r,x=$?r:m,F=$?f:r,L=$?r:f;i|=$?le:Fe,i&=~($?Fe:le),i&ae||(i&=-4);var W=[e,i,h,F,N,L,x,y,b,R],k=n.apply(r,W);return Mn(e)&&Fc(k,W),k.placeholder=c,qc(k,e,i)}function An(e){var i=we[e];return function(n,c){if(n=ot(n),c=c==null?0:Re(V(c),292),c&&qa(n)){var h=(te(n)+"e").split("e"),f=i(h[0]+"e"+(+h[1]+c));return h=(te(f)+"e").split("e"),+(h[0]+"e"+(+h[1]-c))}return i(n)}}var Dd=_r&&1/Ai(new _r([,-0]))[1]==bi?function(e){return new _r(e)}:eo;function Sc(e){return function(i){var n=$e(i);return n==ct?cn(i):n==ut?Qp(i):zp(i,e(i))}}function St(e,i,n,c,h,f,m,y){var b=i&B;if(!b&&typeof e!="function")throw new tt(l);var R=c?c.length:0;if(R||(i&=-97,c=h=r),m=m===r?m:_e(V(m),0),y=y===r?y:V(y),R-=h?h.length:0,i&Fe){var $=c,N=h;c=h=r}var x=b?r:jn(e),F=[e,i,n,c,h,$,N,f,m,y];if(x&&Gd(F,x),e=F[0],i=F[1],n=F[2],c=F[3],h=F[4],y=F[9]=F[9]===r?b?0:e.length:_e(F[9]-R,0),!y&&i&(Z|ee)&&(i&=-25),!i||i==D)var L=Td(e,i,n);else i==Z||i==ee?L=Ad(e,i,y):(i==le||i==(D|le))&&!h.length?L=xd(e,i,n,c):L=es.apply(r,F);var W=x?nc:Fc;return qc(W(L,F),e,i)}function Oc(e,i,n,c){return e===r||pt(e,wr[n])&&!re.call(c,n)?i:e}function Rc(e,i,n,c,h,f){return pe(e)&&pe(i)&&(f.set(i,e),Qi(e,i,r,Rc,f),f.delete(i)),e}function jd(e){return ni(e)?r:e}function $c(e,i,n,c,h,f){var m=n&C,y=e.length,b=i.length;if(y!=b&&!(m&&b>y))return!1;var R=f.get(e),$=f.get(i);if(R&&$)return R==i&&$==e;var N=-1,x=!0,F=n&U?new Zt:r;for(f.set(e,i),f.set(i,e);++N<y;){var L=e[N],W=i[N];if(c)var k=m?c(W,L,N,i,e,f):c(L,W,N,e,i,f);if(k!==r){if(k)continue;x=!1;break}if(F){if(!tn(i,function(G,Y){if(!Vr(F,Y)&&(L===G||h(L,G,n,c,f)))return F.push(Y)})){x=!1;break}}else if(!(L===W||h(L,W,n,c,f))){x=!1;break}}return f.delete(e),f.delete(i),x}function Fd(e,i,n,c,h,f,m){switch(n){case fr:if(e.byteLength!=i.byteLength||e.byteOffset!=i.byteOffset)return!1;e=e.buffer,i=i.buffer;case Kr:return!(e.byteLength!=i.byteLength||!f(new Ui(e),new Ui(i)));case Ur:case Mr:case Lr:return pt(+e,+i);case Pi:return e.name==i.name&&e.message==i.message;case kr:case zr:return e==i+"";case ct:var y=cn;case ut:var b=c&C;if(y||(y=Ai),e.size!=i.size&&!b)return!1;var R=m.get(e);if(R)return R==i;c|=U,m.set(e,i);var $=$c(y(e),y(i),c,h,f,m);return m.delete(e),$;case Oi:if(Qr)return Qr.call(e)==Qr.call(i)}return!1}function qd(e,i,n,c,h,f){var m=n&C,y=xn(e),b=y.length,R=xn(i),$=R.length;if(b!=$&&!m)return!1;for(var N=b;N--;){var x=y[N];if(!(m?x in i:re.call(i,x)))return!1}var F=f.get(e),L=f.get(i);if(F&&L)return F==i&&L==e;var W=!0;f.set(e,i),f.set(i,e);for(var k=m;++N<b;){x=y[N];var G=e[x],Y=i[x];if(c)var Qe=m?c(Y,G,x,i,e,f):c(G,Y,x,e,i,f);if(!(Qe===r?G===Y||h(G,Y,n,c,f):Qe)){W=!1;break}k||(k=x=="constructor")}if(W&&!k){var xe=e.constructor,Ye=i.constructor;xe!=Ye&&"constructor"in e&&"constructor"in i&&!(typeof xe=="function"&&xe instanceof xe&&typeof Ye=="function"&&Ye instanceof Ye)&&(W=!1)}return f.delete(e),f.delete(i),W}function Ot(e){return kn(Dc(e,r,Hc),e+"")}function xn(e){return Ja(e,be,qn)}function Dn(e){return Ja(e,Me,Nc)}var jn=Ki?function(e){return Ki.get(e)}:eo;function ss(e){for(var i=e.name+"",n=br[i],c=re.call(br,i)?n.length:0;c--;){var h=n[c],f=h.func;if(f==null||f==e)return h.name}return i}function Sr(e){var i=re.call(p,"placeholder")?p:e;return i.placeholder}function M(){var e=p.iteratee||Zn;return e=e===Zn?Ya:e,arguments.length?e(arguments[0],arguments[1]):e}function ns(e,i){var n=e.__data__;return Vd(i)?n[typeof i=="string"?"string":"hash"]:n.map}function Fn(e){for(var i=be(e),n=i.length;n--;){var c=i[n],h=e[c];i[n]=[c,h,Ac(h)]}return i}function tr(e,i){var n=Wp(e,i);return Qa(n)?n:r}function Ud(e){var i=re.call(e,Qt),n=e[Qt];try{e[Qt]=r;var c=!0}catch{}var h=Fi.call(e);return c&&(i?e[Qt]=n:delete e[Qt]),h}var qn=hn?function(e){return e==null?[]:(e=ie(e),Ft(hn(e),function(i){return ja.call(e,i)}))}:to,Nc=hn?function(e){for(var i=[];e;)qt(i,qn(e)),e=Mi(e);return i}:to,$e=Te;(ln&&$e(new ln(new ArrayBuffer(1)))!=fr||Wr&&$e(new Wr)!=ct||pn&&$e(pn.resolve())!=Vo||_r&&$e(new _r)!=ut||Jr&&$e(new Jr)!=Hr)&&($e=function(e){var i=Te(e),n=i==bt?e.constructor:r,c=n?rr(n):"";if(c)switch(c){case _f:return fr;case bf:return ct;case Ef:return Vo;case If:return ut;case Pf:return Hr}return i});function Md(e,i,n){for(var c=-1,h=n.length;++c<h;){var f=n[c],m=f.size;switch(f.type){case"drop":e+=m;break;case"dropRight":i-=m;break;case"take":i=Re(i,e+m);break;case"takeRight":e=_e(e,i-m);break}}return{start:e,end:i}}function Ld(e){var i=e.match(Vl);return i?i[1].split(Bl):[]}function Cc(e,i,n){i=zt(i,e);for(var c=-1,h=i.length,f=!1;++c<h;){var m=wt(i[c]);if(!(f=e!=null&&n(e,m)))break;e=e[m]}return f||++c!=h?f:(h=e==null?0:e.length,!!h&&ps(h)&&Rt(m,h)&&(H(e)||ir(e)))}function kd(e){var i=e.length,n=new e.constructor(i);return i&&typeof e[0]=="string"&&re.call(e,"index")&&(n.index=e.index,n.input=e.input),n}function Tc(e){return typeof e.constructor=="function"&&!ii(e)?Er(Mi(e)):{}}function zd(e,i,n){var c=e.constructor;switch(i){case Kr:return Cn(e);case Ur:case Mr:return new c(+e);case fr:return Sd(e,n);case js:case Fs:case qs:case Us:case Ms:case Ls:case ks:case zs:case Hs:return fc(e,n);case ct:return new c;case Lr:case zr:return new c(e);case kr:return Od(e);case ut:return new c;case Oi:return Rd(e)}}function Hd(e,i){var n=i.length;if(!n)return e;var c=n-1;return i[c]=(n>1?"& ":"")+i[c],i=i.join(n>2?", ":" "),e.replace(Kl,`{
|
|
28
|
-
/* [wrapped with `+i+`] */
|
|
29
|
-
`)}function Kd(e){return H(e)||ir(e)||!!(Fa&&e&&e[Fa])}function Rt(e,i){var n=typeof e;return i=i??lr,!!i&&(n=="number"||n!="symbol"&&tp.test(e))&&e>-1&&e%1==0&&e<i}function Ae(e,i,n){if(!pe(n))return!1;var c=typeof i;return(c=="number"?Ue(n)&&Rt(i,n.length):c=="string"&&i in n)?pt(n[i],e):!1}function Un(e,i){if(H(e))return!1;var n=typeof e;return n=="number"||n=="symbol"||n=="boolean"||e==null||Ge(e)?!0:Ll.test(e)||!Ml.test(e)||i!=null&&e in ie(i)}function Vd(e){var i=typeof e;return i=="string"||i=="number"||i=="symbol"||i=="boolean"?e!=="__proto__":e===null}function Mn(e){var i=ss(e),n=p[i];if(typeof n!="function"||!(i in Q.prototype))return!1;if(e===n)return!0;var c=jn(n);return!!c&&e===c[0]}function Bd(e){return!!Aa&&Aa in e}var Wd=Di?$t:ro;function ii(e){var i=e&&e.constructor,n=typeof i=="function"&&i.prototype||wr;return e===n}function Ac(e){return e===e&&!pe(e)}function xc(e,i){return function(n){return n==null?!1:n[e]===i&&(i!==r||e in ie(n))}}function Jd(e){var i=hs(e,function(c){return n.size===d&&n.clear(),c}),n=i.cache;return i}function Gd(e,i){var n=e[1],c=i[1],h=n|c,f=h<(D|B|de),m=c==de&&n==Z||c==de&&n==Ce&&e[7].length<=i[8]||c==(de|Ce)&&i[7].length<=i[8]&&n==Z;if(!(f||m))return e;c&D&&(e[2]=i[2],h|=n&D?0:ae);var y=i[3];if(y){var b=e[3];e[3]=b?gc(b,y,i[4]):y,e[4]=b?Ut(e[3],E):i[4]}return y=i[5],y&&(b=e[5],e[5]=b?mc(b,y,i[6]):y,e[6]=b?Ut(e[5],E):i[6]),y=i[7],y&&(e[7]=y),c&de&&(e[8]=e[8]==null?i[8]:Re(e[8],i[8])),e[9]==null&&(e[9]=i[9]),e[0]=i[0],e[1]=h,e}function Qd(e){var i=[];if(e!=null)for(var n in ie(e))i.push(n);return i}function Yd(e){return Fi.call(e)}function Dc(e,i,n){return i=_e(i===r?e.length-1:i,0),function(){for(var c=arguments,h=-1,f=_e(c.length-i,0),m=P(f);++h<f;)m[h]=c[i+h];h=-1;for(var y=P(i+1);++h<i;)y[h]=c[h];return y[i]=n(m),Be(e,this,y)}}function jc(e,i){return i.length<2?e:er(e,st(i,0,-1))}function Zd(e,i){for(var n=e.length,c=Re(i.length,n),h=qe(e);c--;){var f=i[c];e[c]=Rt(f,n)?h[f]:r}return e}function Ln(e,i){if(!(i==="constructor"&&typeof e[i]=="function")&&i!="__proto__")return e[i]}var Fc=Uc(nc),si=ff||function(e,i){return Pe.setTimeout(e,i)},kn=Uc(bd);function qc(e,i,n){var c=i+"";return kn(e,Hd(c,Xd(Ld(c),n)))}function Uc(e){var i=0,n=0;return function(){var c=yf(),h=wl-(c-n);if(n=c,h>0){if(++i>=vl)return arguments[0]}else i=0;return e.apply(r,arguments)}}function os(e,i){var n=-1,c=e.length,h=c-1;for(i=i===r?c:i;++n<i;){var f=In(n,h),m=e[f];e[f]=e[n],e[n]=m}return e.length=i,e}var Mc=Jd(function(e){var i=[];return e.charCodeAt(0)===46&&i.push(""),e.replace(kl,function(n,c,h,f){i.push(h?f.replace(Gl,"$1"):c||n)}),i});function wt(e){if(typeof e=="string"||Ge(e))return e;var i=e+"";return i=="0"&&1/e==-1/0?"-0":i}function rr(e){if(e!=null){try{return ji.call(e)}catch{}try{return e+""}catch{}}return""}function Xd(e,i){return et(Sl,function(n){var c="_."+n[0];i&n[1]&&!Ci(e,c)&&e.push(c)}),e.sort()}function Lc(e){if(e instanceof Q)return e.clone();var i=new rt(e.__wrapped__,e.__chain__);return i.__actions__=qe(e.__actions__),i.__index__=e.__index__,i.__values__=e.__values__,i}function eg(e,i,n){(n?Ae(e,i,n):i===r)?i=1:i=_e(V(i),0);var c=e==null?0:e.length;if(!c||i<1)return[];for(var h=0,f=0,m=P(zi(c/i));h<c;)m[f++]=st(e,h,h+=i);return m}function tg(e){for(var i=-1,n=e==null?0:e.length,c=0,h=[];++i<n;){var f=e[i];f&&(h[c++]=f)}return h}function rg(){var e=arguments.length;if(!e)return[];for(var i=P(e-1),n=arguments[0],c=e;c--;)i[c-1]=arguments[c];return qt(H(n)?qe(n):[n],Se(i,1))}var ig=J(function(e,i){return ge(e)?Zr(e,Se(i,1,ge,!0)):[]}),sg=J(function(e,i){var n=nt(i);return ge(n)&&(n=r),ge(e)?Zr(e,Se(i,1,ge,!0),M(n,2)):[]}),ng=J(function(e,i){var n=nt(i);return ge(n)&&(n=r),ge(e)?Zr(e,Se(i,1,ge,!0),r,n):[]});function og(e,i,n){var c=e==null?0:e.length;return c?(i=n||i===r?1:V(i),st(e,i<0?0:i,c)):[]}function ag(e,i,n){var c=e==null?0:e.length;return c?(i=n||i===r?1:V(i),i=c-i,st(e,0,i<0?0:i)):[]}function cg(e,i){return e&&e.length?Zi(e,M(i,3),!0,!0):[]}function ug(e,i){return e&&e.length?Zi(e,M(i,3),!0):[]}function hg(e,i,n,c){var h=e==null?0:e.length;return h?(n&&typeof n!="number"&&Ae(e,i,n)&&(n=0,c=h),rd(e,i,n,c)):[]}function kc(e,i,n){var c=e==null?0:e.length;if(!c)return-1;var h=n==null?0:V(n);return h<0&&(h=_e(c+h,0)),Ti(e,M(i,3),h)}function zc(e,i,n){var c=e==null?0:e.length;if(!c)return-1;var h=c-1;return n!==r&&(h=V(n),h=n<0?_e(c+h,0):Re(h,c-1)),Ti(e,M(i,3),h,!0)}function Hc(e){var i=e==null?0:e.length;return i?Se(e,1):[]}function lg(e){var i=e==null?0:e.length;return i?Se(e,bi):[]}function pg(e,i){var n=e==null?0:e.length;return n?(i=i===r?1:V(i),Se(e,i)):[]}function fg(e){for(var i=-1,n=e==null?0:e.length,c={};++i<n;){var h=e[i];c[h[0]]=h[1]}return c}function Kc(e){return e&&e.length?e[0]:r}function dg(e,i,n){var c=e==null?0:e.length;if(!c)return-1;var h=n==null?0:V(n);return h<0&&(h=_e(c+h,0)),gr(e,i,h)}function gg(e){var i=e==null?0:e.length;return i?st(e,0,-1):[]}var mg=J(function(e){var i=ue(e,$n);return i.length&&i[0]===e[0]?vn(i):[]}),yg=J(function(e){var i=nt(e),n=ue(e,$n);return i===nt(n)?i=r:n.pop(),n.length&&n[0]===e[0]?vn(n,M(i,2)):[]}),vg=J(function(e){var i=nt(e),n=ue(e,$n);return i=typeof i=="function"?i:r,i&&n.pop(),n.length&&n[0]===e[0]?vn(n,r,i):[]});function wg(e,i){return e==null?"":gf.call(e,i)}function nt(e){var i=e==null?0:e.length;return i?e[i-1]:r}function _g(e,i,n){var c=e==null?0:e.length;if(!c)return-1;var h=c;return n!==r&&(h=V(n),h=h<0?_e(c+h,0):Re(h,c-1)),i===i?Zp(e,i,h):Ti(e,Pa,h,!0)}function bg(e,i){return e&&e.length?tc(e,V(i)):r}var Eg=J(Vc);function Vc(e,i){return e&&e.length&&i&&i.length?En(e,i):e}function Ig(e,i,n){return e&&e.length&&i&&i.length?En(e,i,M(n,2)):e}function Pg(e,i,n){return e&&e.length&&i&&i.length?En(e,i,r,n):e}var Sg=Ot(function(e,i){var n=e==null?0:e.length,c=dn(e,i);return sc(e,ue(i,function(h){return Rt(h,n)?+h:h}).sort(dc)),c});function Og(e,i){var n=[];if(!(e&&e.length))return n;var c=-1,h=[],f=e.length;for(i=M(i,3);++c<f;){var m=e[c];i(m,c,e)&&(n.push(m),h.push(c))}return sc(e,h),n}function zn(e){return e==null?e:wf.call(e)}function Rg(e,i,n){var c=e==null?0:e.length;return c?(n&&typeof n!="number"&&Ae(e,i,n)?(i=0,n=c):(i=i==null?0:V(i),n=n===r?c:V(n)),st(e,i,n)):[]}function $g(e,i){return Yi(e,i)}function Ng(e,i,n){return Sn(e,i,M(n,2))}function Cg(e,i){var n=e==null?0:e.length;if(n){var c=Yi(e,i);if(c<n&&pt(e[c],i))return c}return-1}function Tg(e,i){return Yi(e,i,!0)}function Ag(e,i,n){return Sn(e,i,M(n,2),!0)}function xg(e,i){var n=e==null?0:e.length;if(n){var c=Yi(e,i,!0)-1;if(pt(e[c],i))return c}return-1}function Dg(e){return e&&e.length?oc(e):[]}function jg(e,i){return e&&e.length?oc(e,M(i,2)):[]}function Fg(e){var i=e==null?0:e.length;return i?st(e,1,i):[]}function qg(e,i,n){return e&&e.length?(i=n||i===r?1:V(i),st(e,0,i<0?0:i)):[]}function Ug(e,i,n){var c=e==null?0:e.length;return c?(i=n||i===r?1:V(i),i=c-i,st(e,i<0?0:i,c)):[]}function Mg(e,i){return e&&e.length?Zi(e,M(i,3),!1,!0):[]}function Lg(e,i){return e&&e.length?Zi(e,M(i,3)):[]}var kg=J(function(e){return kt(Se(e,1,ge,!0))}),zg=J(function(e){var i=nt(e);return ge(i)&&(i=r),kt(Se(e,1,ge,!0),M(i,2))}),Hg=J(function(e){var i=nt(e);return i=typeof i=="function"?i:r,kt(Se(e,1,ge,!0),r,i)});function Kg(e){return e&&e.length?kt(e):[]}function Vg(e,i){return e&&e.length?kt(e,M(i,2)):[]}function Bg(e,i){return i=typeof i=="function"?i:r,e&&e.length?kt(e,r,i):[]}function Hn(e){if(!(e&&e.length))return[];var i=0;return e=Ft(e,function(n){if(ge(n))return i=_e(n.length,i),!0}),on(i,function(n){return ue(e,rn(n))})}function Bc(e,i){if(!(e&&e.length))return[];var n=Hn(e);return i==null?n:ue(n,function(c){return Be(i,r,c)})}var Wg=J(function(e,i){return ge(e)?Zr(e,i):[]}),Jg=J(function(e){return Rn(Ft(e,ge))}),Gg=J(function(e){var i=nt(e);return ge(i)&&(i=r),Rn(Ft(e,ge),M(i,2))}),Qg=J(function(e){var i=nt(e);return i=typeof i=="function"?i:r,Rn(Ft(e,ge),r,i)}),Yg=J(Hn);function Zg(e,i){return hc(e||[],i||[],Yr)}function Xg(e,i){return hc(e||[],i||[],ti)}var em=J(function(e){var i=e.length,n=i>1?e[i-1]:r;return n=typeof n=="function"?(e.pop(),n):r,Bc(e,n)});function Wc(e){var i=p(e);return i.__chain__=!0,i}function tm(e,i){return i(e),e}function as(e,i){return i(e)}var rm=Ot(function(e){var i=e.length,n=i?e[0]:0,c=this.__wrapped__,h=function(f){return dn(f,e)};return i>1||this.__actions__.length||!(c instanceof Q)||!Rt(n)?this.thru(h):(c=c.slice(n,+n+(i?1:0)),c.__actions__.push({func:as,args:[h],thisArg:r}),new rt(c,this.__chain__).thru(function(f){return i&&!f.length&&f.push(r),f}))});function im(){return Wc(this)}function sm(){return new rt(this.value(),this.__chain__)}function nm(){this.__values__===r&&(this.__values__=au(this.value()));var e=this.__index__>=this.__values__.length,i=e?r:this.__values__[this.__index__++];return{done:e,value:i}}function om(){return this}function am(e){for(var i,n=this;n instanceof Bi;){var c=Lc(n);c.__index__=0,c.__values__=r,i?h.__wrapped__=c:i=c;var h=c;n=n.__wrapped__}return h.__wrapped__=e,i}function cm(){var e=this.__wrapped__;if(e instanceof Q){var i=e;return this.__actions__.length&&(i=new Q(this)),i=i.reverse(),i.__actions__.push({func:as,args:[zn],thisArg:r}),new rt(i,this.__chain__)}return this.thru(zn)}function um(){return uc(this.__wrapped__,this.__actions__)}var hm=Xi(function(e,i,n){re.call(e,n)?++e[n]:Pt(e,n,1)});function lm(e,i,n){var c=H(e)?Ea:td;return n&&Ae(e,i,n)&&(i=r),c(e,M(i,3))}function pm(e,i){var n=H(e)?Ft:Ba;return n(e,M(i,3))}var fm=_c(kc),dm=_c(zc);function gm(e,i){return Se(cs(e,i),1)}function mm(e,i){return Se(cs(e,i),bi)}function ym(e,i,n){return n=n===r?1:V(n),Se(cs(e,i),n)}function Jc(e,i){var n=H(e)?et:Lt;return n(e,M(i,3))}function Gc(e,i){var n=H(e)?jp:Va;return n(e,M(i,3))}var vm=Xi(function(e,i,n){re.call(e,n)?e[n].push(i):Pt(e,n,[i])});function wm(e,i,n,c){e=Ue(e)?e:Rr(e),n=n&&!c?V(n):0;var h=e.length;return n<0&&(n=_e(h+n,0)),fs(e)?n<=h&&e.indexOf(i,n)>-1:!!h&&gr(e,i,n)>-1}var _m=J(function(e,i,n){var c=-1,h=typeof i=="function",f=Ue(e)?P(e.length):[];return Lt(e,function(m){f[++c]=h?Be(i,m,n):Xr(m,i,n)}),f}),bm=Xi(function(e,i,n){Pt(e,n,i)});function cs(e,i){var n=H(e)?ue:Za;return n(e,M(i,3))}function Em(e,i,n,c){return e==null?[]:(H(i)||(i=i==null?[]:[i]),n=c?r:n,H(n)||(n=n==null?[]:[n]),rc(e,i,n))}var Im=Xi(function(e,i,n){e[n?0:1].push(i)},function(){return[[],[]]});function Pm(e,i,n){var c=H(e)?en:Oa,h=arguments.length<3;return c(e,M(i,4),n,h,Lt)}function Sm(e,i,n){var c=H(e)?Fp:Oa,h=arguments.length<3;return c(e,M(i,4),n,h,Va)}function Om(e,i){var n=H(e)?Ft:Ba;return n(e,ls(M(i,3)))}function Rm(e){var i=H(e)?ka:wd;return i(e)}function $m(e,i,n){(n?Ae(e,i,n):i===r)?i=1:i=V(i);var c=H(e)?Qf:_d;return c(e,i)}function Nm(e){var i=H(e)?Yf:Ed;return i(e)}function Cm(e){if(e==null)return 0;if(Ue(e))return fs(e)?yr(e):e.length;var i=$e(e);return i==ct||i==ut?e.size:_n(e).length}function Tm(e,i,n){var c=H(e)?tn:Id;return n&&Ae(e,i,n)&&(i=r),c(e,M(i,3))}var Am=J(function(e,i){if(e==null)return[];var n=i.length;return n>1&&Ae(e,i[0],i[1])?i=[]:n>2&&Ae(i[0],i[1],i[2])&&(i=[i[0]]),rc(e,Se(i,1),[])}),us=pf||function(){return Pe.Date.now()};function xm(e,i){if(typeof i!="function")throw new tt(l);return e=V(e),function(){if(--e<1)return i.apply(this,arguments)}}function Qc(e,i,n){return i=n?r:i,i=e&&i==null?e.length:i,St(e,de,r,r,r,r,i)}function Yc(e,i){var n;if(typeof i!="function")throw new tt(l);return e=V(e),function(){return--e>0&&(n=i.apply(this,arguments)),e<=1&&(i=r),n}}var Kn=J(function(e,i,n){var c=D;if(n.length){var h=Ut(n,Sr(Kn));c|=le}return St(e,c,i,n,h)}),Zc=J(function(e,i,n){var c=D|B;if(n.length){var h=Ut(n,Sr(Zc));c|=le}return St(i,c,e,n,h)});function Xc(e,i,n){i=n?r:i;var c=St(e,Z,r,r,r,r,r,i);return c.placeholder=Xc.placeholder,c}function eu(e,i,n){i=n?r:i;var c=St(e,ee,r,r,r,r,r,i);return c.placeholder=eu.placeholder,c}function tu(e,i,n){var c,h,f,m,y,b,R=0,$=!1,N=!1,x=!0;if(typeof e!="function")throw new tt(l);i=ot(i)||0,pe(n)&&($=!!n.leading,N="maxWait"in n,f=N?_e(ot(n.maxWait)||0,i):f,x="trailing"in n?!!n.trailing:x);function F(me){var ft=c,Ct=h;return c=h=r,R=me,m=e.apply(Ct,ft),m}function L(me){return R=me,y=si(G,i),$?F(me):m}function W(me){var ft=me-b,Ct=me-R,_u=i-ft;return N?Re(_u,f-Ct):_u}function k(me){var ft=me-b,Ct=me-R;return b===r||ft>=i||ft<0||N&&Ct>=f}function G(){var me=us();if(k(me))return Y(me);y=si(G,W(me))}function Y(me){return y=r,x&&c?F(me):(c=h=r,m)}function Qe(){y!==r&&lc(y),R=0,c=b=h=y=r}function xe(){return y===r?m:Y(us())}function Ye(){var me=us(),ft=k(me);if(c=arguments,h=this,b=me,ft){if(y===r)return L(b);if(N)return lc(y),y=si(G,i),F(b)}return y===r&&(y=si(G,i)),m}return Ye.cancel=Qe,Ye.flush=xe,Ye}var Dm=J(function(e,i){return Ka(e,1,i)}),jm=J(function(e,i,n){return Ka(e,ot(i)||0,n)});function Fm(e){return St(e,jt)}function hs(e,i){if(typeof e!="function"||i!=null&&typeof i!="function")throw new tt(l);var n=function(){var c=arguments,h=i?i.apply(this,c):c[0],f=n.cache;if(f.has(h))return f.get(h);var m=e.apply(this,c);return n.cache=f.set(h,m)||f,m};return n.cache=new(hs.Cache||It),n}hs.Cache=It;function ls(e){if(typeof e!="function")throw new tt(l);return function(){var i=arguments;switch(i.length){case 0:return!e.call(this);case 1:return!e.call(this,i[0]);case 2:return!e.call(this,i[0],i[1]);case 3:return!e.call(this,i[0],i[1],i[2])}return!e.apply(this,i)}}function qm(e){return Yc(2,e)}var Um=Pd(function(e,i){i=i.length==1&&H(i[0])?ue(i[0],We(M())):ue(Se(i,1),We(M()));var n=i.length;return J(function(c){for(var h=-1,f=Re(c.length,n);++h<f;)c[h]=i[h].call(this,c[h]);return Be(e,this,c)})}),Vn=J(function(e,i){var n=Ut(i,Sr(Vn));return St(e,le,r,i,n)}),ru=J(function(e,i){var n=Ut(i,Sr(ru));return St(e,Fe,r,i,n)}),Mm=Ot(function(e,i){return St(e,Ce,r,r,r,i)});function Lm(e,i){if(typeof e!="function")throw new tt(l);return i=i===r?i:V(i),J(e,i)}function km(e,i){if(typeof e!="function")throw new tt(l);return i=i==null?0:_e(V(i),0),J(function(n){var c=n[i],h=Ht(n,0,i);return c&&qt(h,c),Be(e,this,h)})}function zm(e,i,n){var c=!0,h=!0;if(typeof e!="function")throw new tt(l);return pe(n)&&(c="leading"in n?!!n.leading:c,h="trailing"in n?!!n.trailing:h),tu(e,i,{leading:c,maxWait:i,trailing:h})}function Hm(e){return Qc(e,1)}function Km(e,i){return Vn(Nn(i),e)}function Vm(){if(!arguments.length)return[];var e=arguments[0];return H(e)?e:[e]}function Bm(e){return it(e,T)}function Wm(e,i){return i=typeof i=="function"?i:r,it(e,T,i)}function Jm(e){return it(e,_|T)}function Gm(e,i){return i=typeof i=="function"?i:r,it(e,_|T,i)}function Qm(e,i){return i==null||Ha(e,i,be(i))}function pt(e,i){return e===i||e!==e&&i!==i}var Ym=is(yn),Zm=is(function(e,i){return e>=i}),ir=Ga(function(){return arguments}())?Ga:function(e){return fe(e)&&re.call(e,"callee")&&!ja.call(e,"callee")},H=P.isArray,Xm=ma?We(ma):ad;function Ue(e){return e!=null&&ps(e.length)&&!$t(e)}function ge(e){return fe(e)&&Ue(e)}function ey(e){return e===!0||e===!1||fe(e)&&Te(e)==Ur}var Kt=df||ro,ty=ya?We(ya):cd;function ry(e){return fe(e)&&e.nodeType===1&&!ni(e)}function iy(e){if(e==null)return!0;if(Ue(e)&&(H(e)||typeof e=="string"||typeof e.splice=="function"||Kt(e)||Or(e)||ir(e)))return!e.length;var i=$e(e);if(i==ct||i==ut)return!e.size;if(ii(e))return!_n(e).length;for(var n in e)if(re.call(e,n))return!1;return!0}function sy(e,i){return ei(e,i)}function ny(e,i,n){n=typeof n=="function"?n:r;var c=n?n(e,i):r;return c===r?ei(e,i,r,n):!!c}function Bn(e){if(!fe(e))return!1;var i=Te(e);return i==Pi||i==Rl||typeof e.message=="string"&&typeof e.name=="string"&&!ni(e)}function oy(e){return typeof e=="number"&&qa(e)}function $t(e){if(!pe(e))return!1;var i=Te(e);return i==Si||i==Ko||i==Ol||i==Nl}function iu(e){return typeof e=="number"&&e==V(e)}function ps(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=lr}function pe(e){var i=typeof e;return e!=null&&(i=="object"||i=="function")}function fe(e){return e!=null&&typeof e=="object"}var su=va?We(va):hd;function ay(e,i){return e===i||wn(e,i,Fn(i))}function cy(e,i,n){return n=typeof n=="function"?n:r,wn(e,i,Fn(i),n)}function uy(e){return nu(e)&&e!=+e}function hy(e){if(Wd(e))throw new z(u);return Qa(e)}function ly(e){return e===null}function py(e){return e==null}function nu(e){return typeof e=="number"||fe(e)&&Te(e)==Lr}function ni(e){if(!fe(e)||Te(e)!=bt)return!1;var i=Mi(e);if(i===null)return!0;var n=re.call(i,"constructor")&&i.constructor;return typeof n=="function"&&n instanceof n&&ji.call(n)==cf}var Wn=wa?We(wa):ld;function fy(e){return iu(e)&&e>=-9007199254740991&&e<=lr}var ou=_a?We(_a):pd;function fs(e){return typeof e=="string"||!H(e)&&fe(e)&&Te(e)==zr}function Ge(e){return typeof e=="symbol"||fe(e)&&Te(e)==Oi}var Or=ba?We(ba):fd;function dy(e){return e===r}function gy(e){return fe(e)&&$e(e)==Hr}function my(e){return fe(e)&&Te(e)==Tl}var yy=is(bn),vy=is(function(e,i){return e<=i});function au(e){if(!e)return[];if(Ue(e))return fs(e)?ht(e):qe(e);if(Br&&e[Br])return Gp(e[Br]());var i=$e(e),n=i==ct?cn:i==ut?Ai:Rr;return n(e)}function Nt(e){if(!e)return e===0?e:0;if(e=ot(e),e===bi||e===-1/0){var i=e<0?-1:1;return i*El}return e===e?e:0}function V(e){var i=Nt(e),n=i%1;return i===i?n?i-n:i:0}function cu(e){return e?Xt(V(e),0,mt):0}function ot(e){if(typeof e=="number")return e;if(Ge(e))return Ei;if(pe(e)){var i=typeof e.valueOf=="function"?e.valueOf():e;e=pe(i)?i+"":i}if(typeof e!="string")return e===0?e:+e;e=Ra(e);var n=Zl.test(e);return n||ep.test(e)?Ap(e.slice(2),n?2:8):Yl.test(e)?Ei:+e}function uu(e){return vt(e,Me(e))}function wy(e){return e?Xt(V(e),-9007199254740991,lr):e===0?e:0}function te(e){return e==null?"":Je(e)}var _y=Ir(function(e,i){if(ii(i)||Ue(i)){vt(i,be(i),e);return}for(var n in i)re.call(i,n)&&Yr(e,n,i[n])}),hu=Ir(function(e,i){vt(i,Me(i),e)}),ds=Ir(function(e,i,n,c){vt(i,Me(i),e,c)}),by=Ir(function(e,i,n,c){vt(i,be(i),e,c)}),Ey=Ot(dn);function Iy(e,i){var n=Er(e);return i==null?n:za(n,i)}var Py=J(function(e,i){e=ie(e);var n=-1,c=i.length,h=c>2?i[2]:r;for(h&&Ae(i[0],i[1],h)&&(c=1);++n<c;)for(var f=i[n],m=Me(f),y=-1,b=m.length;++y<b;){var R=m[y],$=e[R];($===r||pt($,wr[R])&&!re.call(e,R))&&(e[R]=f[R])}return e}),Sy=J(function(e){return e.push(r,Rc),Be(lu,r,e)});function Oy(e,i){return Ia(e,M(i,3),yt)}function Ry(e,i){return Ia(e,M(i,3),mn)}function $y(e,i){return e==null?e:gn(e,M(i,3),Me)}function Ny(e,i){return e==null?e:Wa(e,M(i,3),Me)}function Cy(e,i){return e&&yt(e,M(i,3))}function Ty(e,i){return e&&mn(e,M(i,3))}function Ay(e){return e==null?[]:Gi(e,be(e))}function xy(e){return e==null?[]:Gi(e,Me(e))}function Jn(e,i,n){var c=e==null?r:er(e,i);return c===r?n:c}function Dy(e,i){return e!=null&&Cc(e,i,id)}function Gn(e,i){return e!=null&&Cc(e,i,sd)}var jy=Ec(function(e,i,n){i!=null&&typeof i.toString!="function"&&(i=Fi.call(i)),e[i]=n},Yn(Le)),Fy=Ec(function(e,i,n){i!=null&&typeof i.toString!="function"&&(i=Fi.call(i)),re.call(e,i)?e[i].push(n):e[i]=[n]},M),qy=J(Xr);function be(e){return Ue(e)?La(e):_n(e)}function Me(e){return Ue(e)?La(e,!0):dd(e)}function Uy(e,i){var n={};return i=M(i,3),yt(e,function(c,h,f){Pt(n,i(c,h,f),c)}),n}function My(e,i){var n={};return i=M(i,3),yt(e,function(c,h,f){Pt(n,h,i(c,h,f))}),n}var Ly=Ir(function(e,i,n){Qi(e,i,n)}),lu=Ir(function(e,i,n,c){Qi(e,i,n,c)}),ky=Ot(function(e,i){var n={};if(e==null)return n;var c=!1;i=ue(i,function(f){return f=zt(f,e),c||(c=f.length>1),f}),vt(e,Dn(e),n),c&&(n=it(n,_|I|T,jd));for(var h=i.length;h--;)On(n,i[h]);return n});function zy(e,i){return pu(e,ls(M(i)))}var Hy=Ot(function(e,i){return e==null?{}:md(e,i)});function pu(e,i){if(e==null)return{};var n=ue(Dn(e),function(c){return[c]});return i=M(i),ic(e,n,function(c,h){return i(c,h[0])})}function Ky(e,i,n){i=zt(i,e);var c=-1,h=i.length;for(h||(h=1,e=r);++c<h;){var f=e==null?r:e[wt(i[c])];f===r&&(c=h,f=n),e=$t(f)?f.call(e):f}return e}function Vy(e,i,n){return e==null?e:ti(e,i,n)}function By(e,i,n,c){return c=typeof c=="function"?c:r,e==null?e:ti(e,i,n,c)}var fu=Sc(be),du=Sc(Me);function Wy(e,i,n){var c=H(e),h=c||Kt(e)||Or(e);if(i=M(i,4),n==null){var f=e&&e.constructor;h?n=c?new f:[]:pe(e)?n=$t(f)?Er(Mi(e)):{}:n={}}return(h?et:yt)(e,function(m,y,b){return i(n,m,y,b)}),n}function Jy(e,i){return e==null?!0:On(e,i)}function Gy(e,i,n){return e==null?e:cc(e,i,Nn(n))}function Qy(e,i,n,c){return c=typeof c=="function"?c:r,e==null?e:cc(e,i,Nn(n),c)}function Rr(e){return e==null?[]:an(e,be(e))}function Yy(e){return e==null?[]:an(e,Me(e))}function Zy(e,i,n){return n===r&&(n=i,i=r),n!==r&&(n=ot(n),n=n===n?n:0),i!==r&&(i=ot(i),i=i===i?i:0),Xt(ot(e),i,n)}function Xy(e,i,n){return i=Nt(i),n===r?(n=i,i=0):n=Nt(n),e=ot(e),nd(e,i,n)}function ev(e,i,n){if(n&&typeof n!="boolean"&&Ae(e,i,n)&&(i=n=r),n===r&&(typeof i=="boolean"?(n=i,i=r):typeof e=="boolean"&&(n=e,e=r)),e===r&&i===r?(e=0,i=1):(e=Nt(e),i===r?(i=e,e=0):i=Nt(i)),e>i){var c=e;e=i,i=c}if(n||e%1||i%1){var h=Ua();return Re(e+h*(i-e+Tp("1e-"+((h+"").length-1))),i)}return In(e,i)}var tv=Pr(function(e,i,n){return i=i.toLowerCase(),e+(n?gu(i):i)});function gu(e){return Qn(te(e).toLowerCase())}function mu(e){return e=te(e),e&&e.replace(rp,Kp).replace(bp,"")}function rv(e,i,n){e=te(e),i=Je(i);var c=e.length;n=n===r?c:Xt(V(n),0,c);var h=n;return n-=i.length,n>=0&&e.slice(n,h)==i}function iv(e){return e=te(e),e&&Fl.test(e)?e.replace(Wo,Vp):e}function sv(e){return e=te(e),e&&zl.test(e)?e.replace(Ks,"\\$&"):e}var nv=Pr(function(e,i,n){return e+(n?"-":"")+i.toLowerCase()}),ov=Pr(function(e,i,n){return e+(n?" ":"")+i.toLowerCase()}),av=wc("toLowerCase");function cv(e,i,n){e=te(e),i=V(i);var c=i?yr(e):0;if(!i||c>=i)return e;var h=(i-c)/2;return rs(Hi(h),n)+e+rs(zi(h),n)}function uv(e,i,n){e=te(e),i=V(i);var c=i?yr(e):0;return i&&c<i?e+rs(i-c,n):e}function hv(e,i,n){e=te(e),i=V(i);var c=i?yr(e):0;return i&&c<i?rs(i-c,n)+e:e}function lv(e,i,n){return n||i==null?i=0:i&&(i=+i),vf(te(e).replace(Vs,""),i||0)}function pv(e,i,n){return(n?Ae(e,i,n):i===r)?i=1:i=V(i),Pn(te(e),i)}function fv(){var e=arguments,i=te(e[0]);return e.length<3?i:i.replace(e[1],e[2])}var dv=Pr(function(e,i,n){return e+(n?"_":"")+i.toLowerCase()});function gv(e,i,n){return n&&typeof n!="number"&&Ae(e,i,n)&&(i=n=r),n=n===r?mt:n>>>0,n?(e=te(e),e&&(typeof i=="string"||i!=null&&!Wn(i))&&(i=Je(i),!i&&mr(e))?Ht(ht(e),0,n):e.split(i,n)):[]}var mv=Pr(function(e,i,n){return e+(n?" ":"")+Qn(i)});function yv(e,i,n){return e=te(e),n=n==null?0:Xt(V(n),0,e.length),i=Je(i),e.slice(n,n+i.length)==i}function vv(e,i,n){var c=p.templateSettings;n&&Ae(e,i,n)&&(i=r),e=te(e),i=ds({},i,c,Oc);var h=ds({},i.imports,c.imports,Oc),f=be(h),m=an(h,f),y,b,R=0,$=i.interpolate||Ri,N="__p += '",x=un((i.escape||Ri).source+"|"+$.source+"|"+($===Jo?Ql:Ri).source+"|"+(i.evaluate||Ri).source+"|$","g"),F="//# sourceURL="+(re.call(i,"sourceURL")?(i.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++Op+"]")+`
|
|
30
|
-
`;e.replace(x,function(k,G,Y,Qe,xe,Ye){return Y||(Y=Qe),N+=e.slice(R,Ye).replace(ip,Bp),G&&(y=!0,N+=`' +
|
|
31
|
-
__e(`+G+`) +
|
|
32
|
-
'`),xe&&(b=!0,N+=`';
|
|
33
|
-
`+xe+`;
|
|
34
|
-
__p += '`),Y&&(N+=`' +
|
|
35
|
-
((__t = (`+Y+`)) == null ? '' : __t) +
|
|
36
|
-
'`),R=Ye+k.length,k}),N+=`';
|
|
37
|
-
`;var L=re.call(i,"variable")&&i.variable;if(!L)N=`with (obj) {
|
|
38
|
-
`+N+`
|
|
39
|
-
}
|
|
40
|
-
`;else if(Jl.test(L))throw new z(g);N=(b?N.replace(Al,""):N).replace(xl,"$1").replace(Dl,"$1;"),N="function("+(L||"obj")+`) {
|
|
41
|
-
`+(L?"":`obj || (obj = {});
|
|
42
|
-
`)+"var __t, __p = ''"+(y?", __e = _.escape":"")+(b?`, __j = Array.prototype.join;
|
|
43
|
-
function print() { __p += __j.call(arguments, '') }
|
|
44
|
-
`:`;
|
|
45
|
-
`)+N+`return __p
|
|
46
|
-
}`;var W=vu(function(){return X(f,F+"return "+N).apply(r,m)});if(W.source=N,Bn(W))throw W;return W}function wv(e){return te(e).toLowerCase()}function _v(e){return te(e).toUpperCase()}function bv(e,i,n){if(e=te(e),e&&(n||i===r))return Ra(e);if(!e||!(i=Je(i)))return e;var c=ht(e),h=ht(i),f=$a(c,h),m=Na(c,h)+1;return Ht(c,f,m).join("")}function Ev(e,i,n){if(e=te(e),e&&(n||i===r))return e.slice(0,Ta(e)+1);if(!e||!(i=Je(i)))return e;var c=ht(e),h=Na(c,ht(i))+1;return Ht(c,0,h).join("")}function Iv(e,i,n){if(e=te(e),e&&(n||i===r))return e.replace(Vs,"");if(!e||!(i=Je(i)))return e;var c=ht(e),h=$a(c,ht(i));return Ht(c,h).join("")}function Pv(e,i){var n=ml,c=yl;if(pe(i)){var h="separator"in i?i.separator:h;n="length"in i?V(i.length):n,c="omission"in i?Je(i.omission):c}e=te(e);var f=e.length;if(mr(e)){var m=ht(e);f=m.length}if(n>=f)return e;var y=n-yr(c);if(y<1)return c;var b=m?Ht(m,0,y).join(""):e.slice(0,y);if(h===r)return b+c;if(m&&(y+=b.length-y),Wn(h)){if(e.slice(y).search(h)){var R,$=b;for(h.global||(h=un(h.source,te(Go.exec(h))+"g")),h.lastIndex=0;R=h.exec($);)var N=R.index;b=b.slice(0,N===r?y:N)}}else if(e.indexOf(Je(h),y)!=y){var x=b.lastIndexOf(h);x>-1&&(b=b.slice(0,x))}return b+c}function Sv(e){return e=te(e),e&&jl.test(e)?e.replace(Bo,Xp):e}var Ov=Pr(function(e,i,n){return e+(n?" ":"")+i.toUpperCase()}),Qn=wc("toUpperCase");function yu(e,i,n){return e=te(e),i=n?r:i,i===r?Jp(e)?rf(e):Mp(e):e.match(i)||[]}var vu=J(function(e,i){try{return Be(e,r,i)}catch(n){return Bn(n)?n:new z(n)}}),Rv=Ot(function(e,i){return et(i,function(n){n=wt(n),Pt(e,n,Kn(e[n],e))}),e});function $v(e){var i=e==null?0:e.length,n=M();return e=i?ue(e,function(c){if(typeof c[1]!="function")throw new tt(l);return[n(c[0]),c[1]]}):[],J(function(c){for(var h=-1;++h<i;){var f=e[h];if(Be(f[0],this,c))return Be(f[1],this,c)}})}function Nv(e){return ed(it(e,_))}function Yn(e){return function(){return e}}function Cv(e,i){return e==null||e!==e?i:e}var Tv=bc(),Av=bc(!0);function Le(e){return e}function Zn(e){return Ya(typeof e=="function"?e:it(e,_))}function xv(e){return Xa(it(e,_))}function Dv(e,i){return ec(e,it(i,_))}var jv=J(function(e,i){return function(n){return Xr(n,e,i)}}),Fv=J(function(e,i){return function(n){return Xr(e,n,i)}});function Xn(e,i,n){var c=be(i),h=Gi(i,c);n==null&&!(pe(i)&&(h.length||!c.length))&&(n=i,i=e,e=this,h=Gi(i,be(i)));var f=!(pe(n)&&"chain"in n)||!!n.chain,m=$t(e);return et(h,function(y){var b=i[y];e[y]=b,m&&(e.prototype[y]=function(){var R=this.__chain__;if(f||R){var $=e(this.__wrapped__),N=$.__actions__=qe(this.__actions__);return N.push({func:b,args:arguments,thisArg:e}),$.__chain__=R,$}return b.apply(e,qt([this.value()],arguments))})}),e}function qv(){return Pe._===this&&(Pe._=uf),this}function eo(){}function Uv(e){return e=V(e),J(function(i){return tc(i,e)})}var Mv=Tn(ue),Lv=Tn(Ea),kv=Tn(tn);function wu(e){return Un(e)?rn(wt(e)):yd(e)}function zv(e){return function(i){return e==null?r:er(e,i)}}var Hv=Ic(),Kv=Ic(!0);function to(){return[]}function ro(){return!1}function Vv(){return{}}function Bv(){return""}function Wv(){return!0}function Jv(e,i){if(e=V(e),e<1||e>lr)return[];var n=mt,c=Re(e,mt);i=M(i),e-=mt;for(var h=on(c,i);++n<e;)i(n);return h}function Gv(e){return H(e)?ue(e,wt):Ge(e)?[e]:qe(Mc(te(e)))}function Qv(e){var i=++af;return te(e)+i}var Yv=ts(function(e,i){return e+i},0),Zv=An("ceil"),Xv=ts(function(e,i){return e/i},1),ew=An("floor");function tw(e){return e&&e.length?Ji(e,Le,yn):r}function rw(e,i){return e&&e.length?Ji(e,M(i,2),yn):r}function iw(e){return Sa(e,Le)}function sw(e,i){return Sa(e,M(i,2))}function nw(e){return e&&e.length?Ji(e,Le,bn):r}function ow(e,i){return e&&e.length?Ji(e,M(i,2),bn):r}var aw=ts(function(e,i){return e*i},1),cw=An("round"),uw=ts(function(e,i){return e-i},0);function hw(e){return e&&e.length?nn(e,Le):0}function lw(e,i){return e&&e.length?nn(e,M(i,2)):0}return p.after=xm,p.ary=Qc,p.assign=_y,p.assignIn=hu,p.assignInWith=ds,p.assignWith=by,p.at=Ey,p.before=Yc,p.bind=Kn,p.bindAll=Rv,p.bindKey=Zc,p.castArray=Vm,p.chain=Wc,p.chunk=eg,p.compact=tg,p.concat=rg,p.cond=$v,p.conforms=Nv,p.constant=Yn,p.countBy=hm,p.create=Iy,p.curry=Xc,p.curryRight=eu,p.debounce=tu,p.defaults=Py,p.defaultsDeep=Sy,p.defer=Dm,p.delay=jm,p.difference=ig,p.differenceBy=sg,p.differenceWith=ng,p.drop=og,p.dropRight=ag,p.dropRightWhile=cg,p.dropWhile=ug,p.fill=hg,p.filter=pm,p.flatMap=gm,p.flatMapDeep=mm,p.flatMapDepth=ym,p.flatten=Hc,p.flattenDeep=lg,p.flattenDepth=pg,p.flip=Fm,p.flow=Tv,p.flowRight=Av,p.fromPairs=fg,p.functions=Ay,p.functionsIn=xy,p.groupBy=vm,p.initial=gg,p.intersection=mg,p.intersectionBy=yg,p.intersectionWith=vg,p.invert=jy,p.invertBy=Fy,p.invokeMap=_m,p.iteratee=Zn,p.keyBy=bm,p.keys=be,p.keysIn=Me,p.map=cs,p.mapKeys=Uy,p.mapValues=My,p.matches=xv,p.matchesProperty=Dv,p.memoize=hs,p.merge=Ly,p.mergeWith=lu,p.method=jv,p.methodOf=Fv,p.mixin=Xn,p.negate=ls,p.nthArg=Uv,p.omit=ky,p.omitBy=zy,p.once=qm,p.orderBy=Em,p.over=Mv,p.overArgs=Um,p.overEvery=Lv,p.overSome=kv,p.partial=Vn,p.partialRight=ru,p.partition=Im,p.pick=Hy,p.pickBy=pu,p.property=wu,p.propertyOf=zv,p.pull=Eg,p.pullAll=Vc,p.pullAllBy=Ig,p.pullAllWith=Pg,p.pullAt=Sg,p.range=Hv,p.rangeRight=Kv,p.rearg=Mm,p.reject=Om,p.remove=Og,p.rest=Lm,p.reverse=zn,p.sampleSize=$m,p.set=Vy,p.setWith=By,p.shuffle=Nm,p.slice=Rg,p.sortBy=Am,p.sortedUniq=Dg,p.sortedUniqBy=jg,p.split=gv,p.spread=km,p.tail=Fg,p.take=qg,p.takeRight=Ug,p.takeRightWhile=Mg,p.takeWhile=Lg,p.tap=tm,p.throttle=zm,p.thru=as,p.toArray=au,p.toPairs=fu,p.toPairsIn=du,p.toPath=Gv,p.toPlainObject=uu,p.transform=Wy,p.unary=Hm,p.union=kg,p.unionBy=zg,p.unionWith=Hg,p.uniq=Kg,p.uniqBy=Vg,p.uniqWith=Bg,p.unset=Jy,p.unzip=Hn,p.unzipWith=Bc,p.update=Gy,p.updateWith=Qy,p.values=Rr,p.valuesIn=Yy,p.without=Wg,p.words=yu,p.wrap=Km,p.xor=Jg,p.xorBy=Gg,p.xorWith=Qg,p.zip=Yg,p.zipObject=Zg,p.zipObjectDeep=Xg,p.zipWith=em,p.entries=fu,p.entriesIn=du,p.extend=hu,p.extendWith=ds,Xn(p,p),p.add=Yv,p.attempt=vu,p.camelCase=tv,p.capitalize=gu,p.ceil=Zv,p.clamp=Zy,p.clone=Bm,p.cloneDeep=Jm,p.cloneDeepWith=Gm,p.cloneWith=Wm,p.conformsTo=Qm,p.deburr=mu,p.defaultTo=Cv,p.divide=Xv,p.endsWith=rv,p.eq=pt,p.escape=iv,p.escapeRegExp=sv,p.every=lm,p.find=fm,p.findIndex=kc,p.findKey=Oy,p.findLast=dm,p.findLastIndex=zc,p.findLastKey=Ry,p.floor=ew,p.forEach=Jc,p.forEachRight=Gc,p.forIn=$y,p.forInRight=Ny,p.forOwn=Cy,p.forOwnRight=Ty,p.get=Jn,p.gt=Ym,p.gte=Zm,p.has=Dy,p.hasIn=Gn,p.head=Kc,p.identity=Le,p.includes=wm,p.indexOf=dg,p.inRange=Xy,p.invoke=qy,p.isArguments=ir,p.isArray=H,p.isArrayBuffer=Xm,p.isArrayLike=Ue,p.isArrayLikeObject=ge,p.isBoolean=ey,p.isBuffer=Kt,p.isDate=ty,p.isElement=ry,p.isEmpty=iy,p.isEqual=sy,p.isEqualWith=ny,p.isError=Bn,p.isFinite=oy,p.isFunction=$t,p.isInteger=iu,p.isLength=ps,p.isMap=su,p.isMatch=ay,p.isMatchWith=cy,p.isNaN=uy,p.isNative=hy,p.isNil=py,p.isNull=ly,p.isNumber=nu,p.isObject=pe,p.isObjectLike=fe,p.isPlainObject=ni,p.isRegExp=Wn,p.isSafeInteger=fy,p.isSet=ou,p.isString=fs,p.isSymbol=Ge,p.isTypedArray=Or,p.isUndefined=dy,p.isWeakMap=gy,p.isWeakSet=my,p.join=wg,p.kebabCase=nv,p.last=nt,p.lastIndexOf=_g,p.lowerCase=ov,p.lowerFirst=av,p.lt=yy,p.lte=vy,p.max=tw,p.maxBy=rw,p.mean=iw,p.meanBy=sw,p.min=nw,p.minBy=ow,p.stubArray=to,p.stubFalse=ro,p.stubObject=Vv,p.stubString=Bv,p.stubTrue=Wv,p.multiply=aw,p.nth=bg,p.noConflict=qv,p.noop=eo,p.now=us,p.pad=cv,p.padEnd=uv,p.padStart=hv,p.parseInt=lv,p.random=ev,p.reduce=Pm,p.reduceRight=Sm,p.repeat=pv,p.replace=fv,p.result=Ky,p.round=cw,p.runInContext=w,p.sample=Rm,p.size=Cm,p.snakeCase=dv,p.some=Tm,p.sortedIndex=$g,p.sortedIndexBy=Ng,p.sortedIndexOf=Cg,p.sortedLastIndex=Tg,p.sortedLastIndexBy=Ag,p.sortedLastIndexOf=xg,p.startCase=mv,p.startsWith=yv,p.subtract=uw,p.sum=hw,p.sumBy=lw,p.template=vv,p.times=Jv,p.toFinite=Nt,p.toInteger=V,p.toLength=cu,p.toLower=wv,p.toNumber=ot,p.toSafeInteger=wy,p.toString=te,p.toUpper=_v,p.trim=bv,p.trimEnd=Ev,p.trimStart=Iv,p.truncate=Pv,p.unescape=Sv,p.uniqueId=Qv,p.upperCase=Ov,p.upperFirst=Qn,p.each=Jc,p.eachRight=Gc,p.first=Kc,Xn(p,function(){var e={};return yt(p,function(i,n){re.call(p.prototype,n)||(e[n]=i)}),e}(),{chain:!1}),p.VERSION=s,et(["bind","bindKey","curry","curryRight","partial","partialRight"],function(e){p[e].placeholder=p}),et(["drop","take"],function(e,i){Q.prototype[e]=function(n){n=n===r?1:_e(V(n),0);var c=this.__filtered__&&!i?new Q(this):this.clone();return c.__filtered__?c.__takeCount__=Re(n,c.__takeCount__):c.__views__.push({size:Re(n,mt),type:e+(c.__dir__<0?"Right":"")}),c},Q.prototype[e+"Right"]=function(n){return this.reverse()[e](n).reverse()}}),et(["filter","map","takeWhile"],function(e,i){var n=i+1,c=n==Ho||n==bl;Q.prototype[e]=function(h){var f=this.clone();return f.__iteratees__.push({iteratee:M(h,3),type:n}),f.__filtered__=f.__filtered__||c,f}}),et(["head","last"],function(e,i){var n="take"+(i?"Right":"");Q.prototype[e]=function(){return this[n](1).value()[0]}}),et(["initial","tail"],function(e,i){var n="drop"+(i?"":"Right");Q.prototype[e]=function(){return this.__filtered__?new Q(this):this[n](1)}}),Q.prototype.compact=function(){return this.filter(Le)},Q.prototype.find=function(e){return this.filter(e).head()},Q.prototype.findLast=function(e){return this.reverse().find(e)},Q.prototype.invokeMap=J(function(e,i){return typeof e=="function"?new Q(this):this.map(function(n){return Xr(n,e,i)})}),Q.prototype.reject=function(e){return this.filter(ls(M(e)))},Q.prototype.slice=function(e,i){e=V(e);var n=this;return n.__filtered__&&(e>0||i<0)?new Q(n):(e<0?n=n.takeRight(-e):e&&(n=n.drop(e)),i!==r&&(i=V(i),n=i<0?n.dropRight(-i):n.take(i-e)),n)},Q.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},Q.prototype.toArray=function(){return this.take(mt)},yt(Q.prototype,function(e,i){var n=/^(?:filter|find|map|reject)|While$/.test(i),c=/^(?:head|last)$/.test(i),h=p[c?"take"+(i=="last"?"Right":""):i],f=c||/^find/.test(i);h&&(p.prototype[i]=function(){var m=this.__wrapped__,y=c?[1]:arguments,b=m instanceof Q,R=y[0],$=b||H(m),N=function(G){var Y=h.apply(p,qt([G],y));return c&&x?Y[0]:Y};$&&n&&typeof R=="function"&&R.length!=1&&(b=$=!1);var x=this.__chain__,F=!!this.__actions__.length,L=f&&!x,W=b&&!F;if(!f&&$){m=W?m:new Q(this);var k=e.apply(m,y);return k.__actions__.push({func:as,args:[N],thisArg:r}),new rt(k,x)}return L&&W?e.apply(this,y):(k=this.thru(N),L?c?k.value()[0]:k.value():k)})}),et(["pop","push","shift","sort","splice","unshift"],function(e){var i=xi[e],n=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",c=/^(?:pop|shift)$/.test(e);p.prototype[e]=function(){var h=arguments;if(c&&!this.__chain__){var f=this.value();return i.apply(H(f)?f:[],h)}return this[n](function(m){return i.apply(H(m)?m:[],h)})}}),yt(Q.prototype,function(e,i){var n=p[i];if(n){var c=n.name+"";re.call(br,c)||(br[c]=[]),br[c].push({name:i,func:n})}}),br[es(r,B).name]=[{name:"wrapper",func:r}],Q.prototype.clone=Sf,Q.prototype.reverse=Of,Q.prototype.value=Rf,p.prototype.at=rm,p.prototype.chain=im,p.prototype.commit=sm,p.prototype.next=nm,p.prototype.plant=am,p.prototype.reverse=cm,p.prototype.toJSON=p.prototype.valueOf=p.prototype.value=um,p.prototype.first=p.prototype.head,Br&&(p.prototype[Br]=om),p},vr=sf();Gt?((Gt.exports=vr)._=vr,Ys._=vr):Pe._=vr}).call(pi)})(Co,Co.exports);var vI=Object.defineProperty,wI=Object.defineProperties,_I=Object.getOwnPropertyDescriptors,Ih=Object.getOwnPropertySymbols,bI=Object.prototype.hasOwnProperty,EI=Object.prototype.propertyIsEnumerable,Ph=(o,t,r)=>t in o?vI(o,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[t]=r,vs=(o,t)=>{for(var r in t||(t={}))bI.call(t,r)&&Ph(o,r,t[r]);if(Ih)for(var r of Ih(t))EI.call(t,r)&&Ph(o,r,t[r]);return o},II=(o,t)=>wI(o,_I(t));function Wt(o,t,r){var s;const a=V_(o);return((s=t.rpcMap)==null?void 0:s[a.reference])||`${yI}?chainId=${a.namespace}:${a.reference}&projectId=${r}`}function hr(o){return o.includes(":")?o.split(":")[1]:o}function pl(o){return o.map(t=>`${t.split(":")[0]}:${t.split(":")[1]}`)}function PI(o,t){const r=Object.keys(t.namespaces).filter(a=>a.includes(o));if(!r.length)return[];const s=[];return r.forEach(a=>{const u=t.namespaces[a].accounts;s.push(...u)}),s}function SI(o={},t={}){const r=Sh(o),s=Sh(t);return Co.exports.merge(r,s)}function Sh(o){var t,r,s,a;const u={};if(!Tr(o))return u;for(const[l,g]of Object.entries(o)){const v=Uo(l)?[l]:g.chains,d=g.methods||[],E=g.events||[],_=g.rpcMap||{},I=fi(l);u[I]=II(vs(vs({},u[I]),g),{chains:oo(v,(t=u[I])==null?void 0:t.chains),methods:oo(d,(r=u[I])==null?void 0:r.methods),events:oo(E,(s=u[I])==null?void 0:s.events),rpcMap:vs(vs({},_),(a=u[I])==null?void 0:a.rpcMap)})}return u}function OI(o){return o.includes(":")?o.split(":")[2]:o}function RI(o){const t={};for(const[r,s]of Object.entries(o)){const a=s.methods||[],u=s.events||[],l=s.accounts||[],g=Uo(r)?[r]:s.chains?s.chains:pl(s.accounts);t[r]={chains:g,methods:a,events:u,accounts:l}}return t}function fo(o){return typeof o=="number"?o:o.includes("0x")?parseInt(o,16):o.includes(":")?Number(o.split(":")[1]):Number(o)}const fl={},he=o=>fl[o],go=(o,t)=>{fl[o]=t};class $I{constructor(t){this.name="polkadot",this.namespace=t.namespace,this.events=he("events"),this.client=he("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,r){this.httpProviders[t]||this.setHttpProvider(t,r),this.chainId=t,this.events.emit(Dt.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}getAccounts(){const t=this.namespace.accounts;return t?t.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2])||[]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(r=>{var s;const a=hr(r);t[a]=this.createHttpProvider(a,(s=this.namespace.rpcMap)==null?void 0:s[r])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,r=this.httpProviders[t];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return r}setHttpProvider(t,r){const s=this.createHttpProvider(t,r);s&&(this.httpProviders[t]=s)}createHttpProvider(t,r){const s=r||Wt(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new xt(new Jt(s,he("disableProviderPing")))}}class NI{constructor(t){this.name="eip155",this.namespace=t.namespace,this.events=he("events"),this.client=he("client"),this.httpProviders=this.createHttpProviders(),this.chainId=parseInt(this.getDefaultChain())}async request(t){switch(t.request.method){case"eth_requestAccounts":return this.getAccounts();case"eth_accounts":return this.getAccounts();case"wallet_switchEthereumChain":return await this.handleSwitchChain(t);case"eth_chainId":return parseInt(this.getDefaultChain())}return this.namespace.methods.includes(t.request.method)?await this.client.request(t):this.getHttpProvider().request(t.request)}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}setDefaultChain(t,r){this.httpProviders[t]||this.setHttpProvider(parseInt(t),r),this.chainId=parseInt(t),this.events.emit(Dt.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId.toString();if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}createHttpProvider(t,r){const s=r||Wt(`${this.name}:${t}`,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new xt(new Jt(s,he("disableProviderPing")))}setHttpProvider(t,r){const s=this.createHttpProvider(t,r);s&&(this.httpProviders[t]=s)}createHttpProviders(){const t={};return this.namespace.chains.forEach(r=>{var s;const a=parseInt(hr(r));t[a]=this.createHttpProvider(a,(s=this.namespace.rpcMap)==null?void 0:s[r])}),t}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}getHttpProvider(){const t=this.chainId,r=this.httpProviders[t];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return r}async handleSwitchChain(t){var r,s;let a=t.request.params?(r=t.request.params[0])==null?void 0:r.chainId:"0x0";a=a.startsWith("0x")?a:`0x${a}`;const u=parseInt(a,16);if(this.isChainApproved(u))this.setDefaultChain(`${u}`);else if(this.namespace.methods.includes("wallet_switchEthereumChain"))await this.client.request({topic:t.topic,request:{method:t.request.method,params:[{chainId:a}]},chainId:(s=this.namespace.chains)==null?void 0:s[0]}),this.setDefaultChain(`${u}`);else throw new Error(`Failed to switch to chain 'eip155:${u}'. The chain is not approved or the wallet does not support 'wallet_switchEthereumChain' method.`);return null}isChainApproved(t){return this.namespace.chains.includes(`${this.name}:${t}`)}}class CI{constructor(t){this.name="solana",this.namespace=t.namespace,this.events=he("events"),this.client=he("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,r){this.httpProviders[t]||this.setHttpProvider(t,r),this.chainId=t,this.events.emit(Dt.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(r=>{var s;const a=hr(r);t[a]=this.createHttpProvider(a,(s=this.namespace.rpcMap)==null?void 0:s[r])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,r=this.httpProviders[t];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return r}setHttpProvider(t,r){const s=this.createHttpProvider(t,r);s&&(this.httpProviders[t]=s)}createHttpProvider(t,r){const s=r||Wt(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new xt(new Jt(s,he("disableProviderPing")))}}class TI{constructor(t){this.name="cosmos",this.namespace=t.namespace,this.events=he("events"),this.client=he("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,r){this.httpProviders[t]||this.setHttpProvider(t,r),this.chainId=t,this.events.emit(Dt.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(r=>{var s;const a=hr(r);t[a]=this.createHttpProvider(a,(s=this.namespace.rpcMap)==null?void 0:s[r])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,r=this.httpProviders[t];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return r}setHttpProvider(t,r){const s=this.createHttpProvider(t,r);s&&(this.httpProviders[t]=s)}createHttpProvider(t,r){const s=r||Wt(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new xt(new Jt(s,he("disableProviderPing")))}}class AI{constructor(t){this.name="cip34",this.namespace=t.namespace,this.events=he("events"),this.client=he("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,r){this.httpProviders[t]||this.setHttpProvider(t,r),this.chainId=t,this.events.emit(Dt.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(r=>{const s=this.getCardanoRPCUrl(r),a=hr(r);t[a]=this.createHttpProvider(a,s)}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,r=this.httpProviders[t];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return r}getCardanoRPCUrl(t){const r=this.namespace.rpcMap;if(r)return r[t]}setHttpProvider(t,r){const s=this.createHttpProvider(t,r);s&&(this.httpProviders[t]=s)}createHttpProvider(t,r){const s=r||this.getCardanoRPCUrl(t);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new xt(new Jt(s,he("disableProviderPing")))}}class xI{constructor(t){this.name="elrond",this.namespace=t.namespace,this.events=he("events"),this.client=he("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,r){this.httpProviders[t]||this.setHttpProvider(t,r),this.chainId=t,this.events.emit(Dt.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(r=>{var s;const a=hr(r);t[a]=this.createHttpProvider(a,(s=this.namespace.rpcMap)==null?void 0:s[r])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,r=this.httpProviders[t];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return r}setHttpProvider(t,r){const s=this.createHttpProvider(t,r);s&&(this.httpProviders[t]=s)}createHttpProvider(t,r){const s=r||Wt(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new xt(new Jt(s,he("disableProviderPing")))}}class DI{constructor(t){this.name="multiversx",this.namespace=t.namespace,this.events=he("events"),this.client=he("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,r){this.httpProviders[t]||this.setHttpProvider(t,r),this.chainId=t,this.events.emit(Dt.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(r=>{var s;const a=hr(r);t[a]=this.createHttpProvider(a,(s=this.namespace.rpcMap)==null?void 0:s[r])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,r=this.httpProviders[t];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return r}setHttpProvider(t,r){const s=this.createHttpProvider(t,r);s&&(this.httpProviders[t]=s)}createHttpProvider(t,r){const s=r||Wt(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new xt(new Jt(s,he("disableProviderPing")))}}class jI{constructor(t){this.name="near",this.namespace=t.namespace,this.events=he("events"),this.client=he("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,r){if(this.chainId=t,!this.httpProviders[t]){const s=r||Wt(`${this.name}:${t}`,this.namespace);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);this.setHttpProvider(t,s)}this.events.emit(Dt.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const t=this.namespace.accounts;return t?t.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2])||[]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(r=>{var s;t[r]=this.createHttpProvider(r,(s=this.namespace.rpcMap)==null?void 0:s[r])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,r=this.httpProviders[t];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return r}setHttpProvider(t,r){const s=this.createHttpProvider(t,r);s&&(this.httpProviders[t]=s)}createHttpProvider(t,r){const s=r||Wt(t,this.namespace);return typeof s>"u"?void 0:new xt(new Jt(s,he("disableProviderPing")))}}var FI=Object.defineProperty,qI=Object.defineProperties,UI=Object.getOwnPropertyDescriptors,Oh=Object.getOwnPropertySymbols,MI=Object.prototype.hasOwnProperty,LI=Object.prototype.propertyIsEnumerable,Rh=(o,t,r)=>t in o?FI(o,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[t]=r,ws=(o,t)=>{for(var r in t||(t={}))MI.call(t,r)&&Rh(o,r,t[r]);if(Oh)for(var r of Oh(t))LI.call(t,r)&&Rh(o,r,t[r]);return o},mo=(o,t)=>qI(o,UI(t));class zo{constructor(t){this.events=new Ve.ss,this.rpcProviders={},this.shouldAbortPairingAttempt=!1,this.maxPairingAttempts=10,this.disableProviderPing=!1,this.providerOpts=t,this.logger=typeof(t==null?void 0:t.logger)<"u"&&typeof(t==null?void 0:t.logger)!="string"?t.logger:S.Tt(S.k({level:(t==null?void 0:t.logger)||bh})),this.disableProviderPing=(t==null?void 0:t.disableProviderPing)||!1}static async init(t){const r=new zo(t);return await r.initialize(),r}async request(t,r){const[s,a]=this.validateChain(r);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(s).request({request:ws({},t),chainId:`${s}:${a}`,topic:this.session.topic})}sendAsync(t,r,s){const a=new Date().getTime();this.request(t,s).then(u=>r(null,S.formatJsonRpcResult(a,u))).catch(u=>r(u,void 0))}async enable(){if(!this.client)throw new Error("Sign Client not initialized");return this.session||await this.connect({namespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties}),await this.requestAccounts()}async disconnect(){var t;if(!this.session)throw new Error("Please call connect() before enable()");await this.client.disconnect({topic:(t=this.session)==null?void 0:t.topic,reason:ye("USER_DISCONNECTED")}),await this.cleanup()}async connect(t){if(!this.client)throw new Error("Sign Client not initialized");if(this.setNamespaces(t),await this.cleanupPendingPairings(),!t.skipPairing)return await this.pair(t.pairingTopic)}on(t,r){this.events.on(t,r)}once(t,r){this.events.once(t,r)}removeListener(t,r){this.events.removeListener(t,r)}off(t,r){this.events.off(t,r)}get isWalletConnect(){return!0}async pair(t){this.shouldAbortPairingAttempt=!1;let r=0;do{if(this.shouldAbortPairingAttempt)throw new Error("Pairing aborted");if(r>=this.maxPairingAttempts)throw new Error("Max auto pairing attempts reached");const{uri:s,approval:a}=await this.client.connect({pairingTopic:t,requiredNamespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties});s&&(this.uri=s,this.events.emit("display_uri",s)),await a().then(u=>{this.session=u,this.namespaces||(this.namespaces=RI(u.namespaces),this.persist("namespaces",this.namespaces))}).catch(u=>{if(u.message!==hl)throw u;r++})}while(!this.session);return this.onConnect(),this.session}setDefaultChain(t,r){try{if(!this.session)return;const[s,a]=this.validateChain(t);this.getProvider(s).setDefaultChain(a,r)}catch(s){if(!/Please call connect/.test(s.message))throw s}}async cleanupPendingPairings(t={}){this.logger.info("Cleaning up inactive pairings...");const r=this.client.pairing.getAll();if(or(r)){for(const s of r)t.deletePairings?this.client.core.expirer.set(s.topic,0):await this.client.core.relayer.subscriber.unsubscribe(s.topic);this.logger.info(`Inactive pairings cleared: ${r.length}`)}}abortPairingAttempt(){this.shouldAbortPairingAttempt=!0}async checkStorage(){if(this.namespaces=await this.getFromStore("namespaces"),this.optionalNamespaces=await this.getFromStore("optionalNamespaces")||{},this.client.session.length){const t=this.client.session.keys.length-1;this.session=this.client.session.get(this.client.session.keys[t]),this.createProviders()}}async initialize(){this.logger.trace("Initialized"),await this.createClient(),await this.checkStorage(),this.registerEventListeners()}async createClient(){this.client=this.providerOpts.client||await iI.init({logger:this.providerOpts.logger||bh,relayUrl:this.providerOpts.relayUrl||dI,projectId:this.providerOpts.projectId,metadata:this.providerOpts.metadata,storageOptions:this.providerOpts.storageOptions,storage:this.providerOpts.storage,name:this.providerOpts.name}),this.logger.trace("SignClient Initialized")}createProviders(){if(!this.client)throw new Error("Sign Client not initialized");if(!this.session)throw new Error("Session not initialized. Please call connect() before enable()");const t=[...new Set(Object.keys(this.session.namespaces).map(r=>fi(r)))];go("client",this.client),go("events",this.events),go("disableProviderPing",this.disableProviderPing),t.forEach(r=>{if(!this.session)return;const s=PI(r,this.session),a=pl(s),u=SI(this.namespaces,this.optionalNamespaces),l=mo(ws({},u[r]),{accounts:s,chains:a});switch(r){case"eip155":this.rpcProviders[r]=new NI({namespace:l});break;case"solana":this.rpcProviders[r]=new CI({namespace:l});break;case"cosmos":this.rpcProviders[r]=new TI({namespace:l});break;case"polkadot":this.rpcProviders[r]=new $I({namespace:l});break;case"cip34":this.rpcProviders[r]=new AI({namespace:l});break;case"elrond":this.rpcProviders[r]=new xI({namespace:l});break;case"multiversx":this.rpcProviders[r]=new DI({namespace:l});break;case"near":this.rpcProviders[r]=new jI({namespace:l});break}})}registerEventListeners(){if(typeof this.client>"u")throw new Error("Sign Client is not initialized");this.client.on("session_ping",t=>{this.events.emit("session_ping",t)}),this.client.on("session_event",t=>{const{params:r}=t,{event:s}=r;if(s.name==="accountsChanged"){const a=s.data;a&&or(a)&&this.events.emit("accountsChanged",a.map(OI))}else if(s.name==="chainChanged"){const a=r.chainId,u=r.event.data,l=fi(a),g=fo(a)!==fo(u)?`${l}:${fo(u)}`:a;this.onChainChanged(g)}else this.events.emit(s.name,s.data);this.events.emit("session_event",t)}),this.client.on("session_update",({topic:t,params:r})=>{var s;const{namespaces:a}=r,u=(s=this.client)==null?void 0:s.session.get(t);this.session=mo(ws({},u),{namespaces:a}),this.onSessionUpdate(),this.events.emit("session_update",{topic:t,params:r})}),this.client.on("session_delete",async t=>{await this.cleanup(),this.events.emit("session_delete",t),this.events.emit("disconnect",mo(ws({},ye("USER_DISCONNECTED")),{data:t.topic}))}),this.on(Dt.DEFAULT_CHAIN_CHANGED,t=>{this.onChainChanged(t,!0)})}getProvider(t){if(!this.rpcProviders[t])throw new Error(`Provider not found: ${t}`);return this.rpcProviders[t]}onSessionUpdate(){Object.keys(this.rpcProviders).forEach(t=>{var r;this.getProvider(t).updateNamespace((r=this.session)==null?void 0:r.namespaces[t])})}setNamespaces(t){const{namespaces:r,optionalNamespaces:s,sessionProperties:a}=t;r&&Object.keys(r).length&&(this.namespaces=r),s&&Object.keys(s).length&&(this.optionalNamespaces=s),this.sessionProperties=a,this.persist("namespaces",r),this.persist("optionalNamespaces",s)}validateChain(t){const[r,s]=(t==null?void 0:t.split(":"))||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return[r,s];if(r&&!Object.keys(this.namespaces||{}).map(l=>fi(l)).includes(r))throw new Error(`Namespace '${r}' is not configured. Please call connect() first with namespace config.`);if(r&&s)return[r,s];const a=fi(Object.keys(this.namespaces)[0]),u=this.rpcProviders[a].getDefaultChain();return[a,u]}async requestAccounts(){const[t]=this.validateChain();return await this.getProvider(t).requestAccounts()}onChainChanged(t,r=!1){var s;if(!this.namespaces)return;const[a,u]=this.validateChain(t);r||this.getProvider(a).setDefaultChain(u),((s=this.namespaces[a])!=null?s:this.namespaces[`${a}:${u}`]).defaultChain=u,this.persist("namespaces",this.namespaces),this.events.emit("chainChanged",u)}onConnect(){this.createProviders(),this.events.emit("connect",{session:this.session})}async cleanup(){this.session=void 0,this.namespaces=void 0,this.optionalNamespaces=void 0,this.sessionProperties=void 0,this.persist("namespaces",void 0),this.persist("optionalNamespaces",void 0),this.persist("sessionProperties",void 0),await this.cleanupPendingPairings({deletePairings:!0})}persist(t,r){this.client.core.storage.setItem(`${Eh}/${t}`,r)}async getFromStore(t){return await this.client.core.storage.getItem(`${Eh}/${t}`)}}const kI=zo,zI="wc",HI="ethereum_provider",KI=`${zI}@2:${HI}:`,VI="https://rpc.walletconnect.com/v1/",Os=["eth_sendTransaction","personal_sign"],dl=["eth_accounts","eth_requestAccounts","eth_sendRawTransaction","eth_sign","eth_signTransaction","eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4","eth_sendTransaction","personal_sign","wallet_switchEthereumChain","wallet_addEthereumChain","wallet_getPermissions","wallet_requestPermissions","wallet_registerOnboarding","wallet_watchAsset","wallet_scanQRCode"],Rs=["chainChanged","accountsChanged"],gl=["chainChanged","accountsChanged","message","disconnect","connect"];var BI=Object.defineProperty,WI=Object.defineProperties,JI=Object.getOwnPropertyDescriptors,$h=Object.getOwnPropertySymbols,GI=Object.prototype.hasOwnProperty,QI=Object.prototype.propertyIsEnumerable,Nh=(o,t,r)=>t in o?BI(o,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[t]=r,gi=(o,t)=>{for(var r in t||(t={}))GI.call(t,r)&&Nh(o,r,t[r]);if($h)for(var r of $h(t))QI.call(t,r)&&Nh(o,r,t[r]);return o},Ch=(o,t)=>WI(o,JI(t));function $s(o){return Number(o[0].split(":")[1])}function yo(o){return`0x${o.toString(16)}`}function YI(o){const{chains:t,optionalChains:r,methods:s,optionalMethods:a,events:u,optionalEvents:l,rpcMap:g}=o;if(!vo(t))throw new Error("Invalid chains");const v={chains:t,methods:s||Os,events:u||Rs,rpcMap:gi({},t.length?{[$s(t)]:g[$s(t)]}:{})},d=u==null?void 0:u.filter(T=>!Rs.includes(T)),E=s==null?void 0:s.filter(T=>!Os.includes(T));if(!r&&!l&&!a&&!(d!=null&&d.length)&&!(E!=null&&E.length))return{required:t.length?v:void 0};const _=(d==null?void 0:d.length)&&(E==null?void 0:E.length)||!r,I={chains:[...new Set(_?v.chains.concat(r||[]):r)],methods:[...new Set(v.methods.concat(a!=null&&a.length?a:dl))],events:[...new Set(v.events.concat(l!=null&&l.length?l:gl))],rpcMap:g};return{required:t.length?v:void 0,optional:r.length?I:void 0}}class Ds{constructor(){this.events=new Ve.eventsExports.EventEmitter,this.namespace="eip155",this.accounts=[],this.chainId=1,this.STORAGE_KEY=KI,this.on=(t,r)=>(this.events.on(t,r),this),this.once=(t,r)=>(this.events.once(t,r),this),this.removeListener=(t,r)=>(this.events.removeListener(t,r),this),this.off=(t,r)=>(this.events.off(t,r),this),this.parseAccount=t=>this.isCompatibleChainId(t)?this.parseAccountId(t).address:t,this.signer={},this.rpc={}}static async init(t){const r=new Ds;return await r.initialize(t),r}async request(t){return await this.signer.request(t,this.formatChainId(this.chainId))}sendAsync(t,r){this.signer.sendAsync(t,r,this.formatChainId(this.chainId))}get connected(){return this.signer.client?this.signer.client.core.relayer.connected:!1}get connecting(){return this.signer.client?this.signer.client.core.relayer.connecting:!1}async enable(){return this.session||await this.connect(),await this.request({method:"eth_requestAccounts"})}async connect(t){if(!this.signer.client)throw new Error("Provider not initialized. Call init() first");this.loadConnectOpts(t);const{required:r,optional:s}=YI(this.rpc);try{const a=await new Promise(async(l,g)=>{var v;this.rpc.showQrModal&&((v=this.modal)==null||v.subscribeModal(d=>{!d.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),g(new Error("Connection request reset. Please try again.")))})),await this.signer.connect(Ch(gi({namespaces:gi({},r&&{[this.namespace]:r})},s&&{optionalNamespaces:{[this.namespace]:s}}),{pairingTopic:t==null?void 0:t.pairingTopic})).then(d=>{l(d)}).catch(d=>{g(new Error(d.message))})});if(!a)return;const u=Iw(a.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:u),this.setAccounts(u),this.events.emit("connect",{chainId:yo(this.chainId)})}catch(a){throw this.signer.logger.error(a),a}finally{this.modal&&this.modal.closeModal()}}async disconnect(){this.session&&await this.signer.disconnect(),this.reset()}get isWalletConnect(){return!0}get session(){return this.signer.session}registerEventListeners(){this.signer.on("session_event",t=>{const{params:r}=t,{event:s}=r;s.name==="accountsChanged"?(this.accounts=this.parseAccounts(s.data),this.events.emit("accountsChanged",this.accounts)):s.name==="chainChanged"?this.setChainId(this.formatChainId(s.data)):this.events.emit(s.name,s.data),this.events.emit("session_event",t)}),this.signer.on("chainChanged",t=>{const r=parseInt(t);this.chainId=r,this.events.emit("chainChanged",yo(this.chainId)),this.persist()}),this.signer.on("session_update",t=>{this.events.emit("session_update",t)}),this.signer.on("session_delete",t=>{this.reset(),this.events.emit("session_delete",t),this.events.emit("disconnect",Ch(gi({},Sw("USER_DISCONNECTED")),{data:t.topic,name:"USER_DISCONNECTED"}))}),this.signer.on("display_uri",t=>{var r,s;this.rpc.showQrModal&&((r=this.modal)==null||r.closeModal(),(s=this.modal)==null||s.openModal({uri:t})),this.events.emit("display_uri",t)})}switchEthereumChain(t){this.request({method:"wallet_switchEthereumChain",params:[{chainId:t.toString(16)}]})}isCompatibleChainId(t){return typeof t=="string"?t.startsWith(`${this.namespace}:`):!1}formatChainId(t){return`${this.namespace}:${t}`}parseChainId(t){return Number(t.split(":")[1])}setChainIds(t){const r=t.filter(s=>this.isCompatibleChainId(s)).map(s=>this.parseChainId(s));r.length&&(this.chainId=r[0],this.events.emit("chainChanged",yo(this.chainId)),this.persist())}setChainId(t){if(this.isCompatibleChainId(t)){const r=this.parseChainId(t);this.chainId=r,this.switchEthereumChain(r)}}parseAccountId(t){const[r,s,a]=t.split(":");return{chainId:`${r}:${s}`,address:a}}setAccounts(t){this.accounts=t.filter(r=>this.parseChainId(this.parseAccountId(r).chainId)===this.chainId).map(r=>this.parseAccountId(r).address),this.events.emit("accountsChanged",this.accounts)}getRpcConfig(t){var r,s;const a=(r=t==null?void 0:t.chains)!=null?r:[],u=(s=t==null?void 0:t.optionalChains)!=null?s:[],l=a.concat(u);if(!l.length)throw new Error("No chains specified in either `chains` or `optionalChains`");const g=a.length?(t==null?void 0:t.methods)||Os:[],v=a.length?(t==null?void 0:t.events)||Rs:[],d=(t==null?void 0:t.optionalMethods)||[],E=(t==null?void 0:t.optionalEvents)||[],_=(t==null?void 0:t.rpcMap)||this.buildRpcMap(l,t.projectId),I=(t==null?void 0:t.qrModalOptions)||void 0;return{chains:a==null?void 0:a.map(T=>this.formatChainId(T)),optionalChains:u.map(T=>this.formatChainId(T)),methods:g,events:v,optionalMethods:d,optionalEvents:E,rpcMap:_,showQrModal:!!(t!=null&&t.showQrModal),qrModalOptions:I,projectId:t.projectId,metadata:t.metadata}}buildRpcMap(t,r){const s={};return t.forEach(a=>{s[a]=this.getRpcUrl(a,r)}),s}async initialize(t){if(this.rpc=this.getRpcConfig(t),this.chainId=this.rpc.chains.length?$s(this.rpc.chains):$s(this.rpc.optionalChains),this.signer=await kI.init({projectId:this.rpc.projectId,metadata:this.rpc.metadata,disableProviderPing:t.disableProviderPing,relayUrl:t.relayUrl,storageOptions:t.storageOptions}),this.registerEventListeners(),await this.loadPersistedSession(),this.rpc.showQrModal){let r;try{const{WalletConnectModal:s}=await Promise.resolve().then(()=>require("./index-Cuov-W4s.js")).then(a=>a.index);r=s}catch{throw new Error("To use QR modal, please install @walletconnect/modal package")}if(r)try{this.modal=new r(gi({projectId:this.rpc.projectId},this.rpc.qrModalOptions))}catch(s){throw this.signer.logger.error(s),new Error("Could not generate WalletConnectModal Instance")}}}loadConnectOpts(t){if(!t)return;const{chains:r,optionalChains:s,rpcMap:a}=t;r&&vo(r)&&(this.rpc.chains=r.map(u=>this.formatChainId(u)),r.forEach(u=>{this.rpc.rpcMap[u]=(a==null?void 0:a[u])||this.getRpcUrl(u)})),s&&vo(s)&&(this.rpc.optionalChains=[],this.rpc.optionalChains=s==null?void 0:s.map(u=>this.formatChainId(u)),s.forEach(u=>{this.rpc.rpcMap[u]=(a==null?void 0:a[u])||this.getRpcUrl(u)}))}getRpcUrl(t,r){var s;return((s=this.rpc.rpcMap)==null?void 0:s[t])||`${VI}?chainId=eip155:${t}&projectId=${r||this.rpc.projectId}`}async loadPersistedSession(){if(!this.session)return;const t=await this.signer.client.core.storage.getItem(`${this.STORAGE_KEY}/chainId`),r=this.session.namespaces[`${this.namespace}:${t}`]?this.session.namespaces[`${this.namespace}:${t}`]:this.session.namespaces[this.namespace];this.setChainIds(t?[this.formatChainId(t)]:r==null?void 0:r.accounts),this.setAccounts(r==null?void 0:r.accounts)}reset(){this.chainId=1,this.accounts=[]}persist(){this.session&&this.signer.client.core.storage.setItem(`${this.STORAGE_KEY}/chainId`,this.chainId)}parseAccounts(t){return typeof t=="string"||t instanceof String?[this.parseAccount(t)]:t.map(r=>this.parseAccount(r))}}const ZI=Ds;exports.EthereumProvider=ZI;exports.OPTIONAL_EVENTS=gl;exports.OPTIONAL_METHODS=dl;exports.REQUIRED_EVENTS=Rs;exports.REQUIRED_METHODS=Os;exports.default=Ds;
|