@vleap/warps 2.3.0-alpha.0 → 2.3.0-alpha.2
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/index.js +27 -4
- package/dist/index.mjs +27 -4
- package/package.json +12 -11
package/dist/index.mjs
CHANGED
|
@@ -1,12 +1,35 @@
|
|
|
1
|
-
var oe=(a=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(a,{get:(t,e)=>(typeof require<"u"?require:t)[e]}):a)(function(a){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+a+'" is not supported')});import{Address as vt,TransactionsFactoryConfig as Te,TransferTransactionsFactory as Ce}from"@multiversx/sdk-core";import We from"ajv";var p={HttpProtocolPrefix:"http",IdentifierParamName:"warp",IdentifierParamSeparator:":",IdentifierType:{Alias:"alias",Hash:"hash"},Source:{UserWallet:"user:wallet"},Globals:{UserWallet:{Placeholder:"USER_WALLET",Accessor:a=>a.config.user?.wallet},ChainApiUrl:{Placeholder:"CHAIN_API",Accessor:a=>a.chain.apiUrl},ChainExplorerUrl:{Placeholder:"CHAIN_EXPLORER",Accessor:a=>a.chain.explorerUrl}},Vars:{Query:"query",Env:"env"},ArgParamsSeparator:":",ArgCompositeSeparator:"|",Transform:{Prefix:"transform:"},Egld:{Identifier:"EGLD",EsdtIdentifier:"EGLD-000000",DisplayName:"eGold",Decimals:18}};var F={Warp:"2.0.1",Brand:"0.1.0",Abi:"0.1.0"},W={LatestWarpSchemaUrl:`https://raw.githubusercontent.com/vLeapGroup/warps-specs/refs/heads/main/schemas/v${F.Warp}.schema.json`,LatestBrandSchemaUrl:`https://raw.githubusercontent.com/vLeapGroup/warps-specs/refs/heads/main/schemas/brand/v${F.Brand}.schema.json`,DefaultClientUrl:a=>a==="devnet"?"https://devnet.usewarp.to":a==="testnet"?"https://testnet.usewarp.to":"https://usewarp.to",SuperClientUrls:["https://usewarp.to","https://testnet.usewarp.to","https://devnet.usewarp.to"],MainChain:{Name:"multiversx",DisplayName:"MultiversX",ApiUrl:a=>a==="devnet"?"https://devnet-api.multiversx.com":a==="testnet"?"https://testnet-api.multiversx.com":"https://api.multiversx.com",ExplorerUrl:a=>a==="devnet"?"https://devnet-explorer.multiversx.com":a==="testnet"?"https://testnet-explorer.multiversx.com":"https://explorer.multiversx.com",BlockTime:a=>6e3,AddressHrp:"erd",ChainId:a=>a==="devnet"?"D":a==="testnet"?"T":"1"},Registry:{Contract:a=>a==="devnet"?"erd1qqqqqqqqqqqqqpgqje2f99vr6r7sk54thg03c9suzcvwr4nfl3tsfkdl36":a==="testnet"?"####":"erd1qqqqqqqqqqqqqpgq3mrpj3u6q7tejv6d7eqhnyd27n9v5c5tl3ts08mffe"},AvailableActionInputSources:["field","query",p.Source.UserWallet],AvailableActionInputTypes:["string","uint8","uint16","uint32","uint64","biguint","boolean","address"],AvailableActionInputPositions:["receiver","value","transfer","arg:1","arg:2","arg:3","arg:4","arg:5","arg:6","arg:7","arg:8","arg:9","arg:10","data","ignore"]};var T=a=>({name:W.MainChain.Name,displayName:W.MainChain.DisplayName,chainId:W.MainChain.ChainId(a.env),blockTime:W.MainChain.BlockTime(a.env),addressHrp:W.MainChain.AddressHrp,apiUrl:W.MainChain.ApiUrl(a.env),explorerUrl:W.MainChain.ExplorerUrl(a.env)}),gr=(a,t)=>a.explorerUrl+(t?"/"+t:""),O=a=>{if(a==="warp")return`warp:${F.Warp}`;if(a==="brand")return`brand:${F.Brand}`;if(a==="abi")return`abi:${F.Abi}`;throw new Error(`getLatestProtocolIdentifier: Invalid protocol name: ${a}`)},_=(a,t)=>a?.actions[t-1],Y=a=>({name:a.name.toString(),displayName:a.display_name.toString(),chainId:a.chain_id.toString(),blockTime:a.block_time.toNumber(),addressHrp:a.address_hrp.toString(),apiUrl:a.api_url.toString(),explorerUrl:a.explorer_url.toString()}),H=(a,t)=>{let e=a.toString(),[r,n=""]=e.split("."),i=Math.abs(t);if(t>0)return BigInt(r+n.padEnd(i,"0"));if(t<0){let s=r+n;if(i>=s.length)return 0n;let o=s.slice(0,-i)||"0";return BigInt(o)}else return e.includes(".")?BigInt(e.split(".")[0]):BigInt(e)},Tt=(a,t=100)=>{if(!a)return"";let e=a.replace(/<\/?(h[1-6])[^>]*>/gi," - ").replace(/<\/?(p|div|ul|ol|li|br|hr)[^>]*>/gi," ").replace(/<[^>]+>/g,"").replace(/\s+/g," ").trim();return e=e.startsWith("- ")?e.slice(2):e,e=e.length>t?e.substring(0,e.lastIndexOf(" ",t))+"...":e,e},D=(a,t)=>a.replace(/\{\{([^}]+)\}\}/g,(e,r)=>t[r]||"");import{DevnetEntrypoint as me,MainnetEntrypoint as he,TestnetEntrypoint as ye}from"@multiversx/sdk-core";var q=class{constructor(t="warp-cache"){this.prefix=t}getKey(t){return`${this.prefix}:${t}`}get(t){try{let e=localStorage.getItem(this.getKey(t));if(!e)return null;let r=JSON.parse(e);return Date.now()>r.expiresAt?(localStorage.removeItem(this.getKey(t)),null):r.value}catch{return null}}set(t,e,r){let n={value:e,expiresAt:Date.now()+r*1e3};localStorage.setItem(this.getKey(t),JSON.stringify(n))}forget(t){localStorage.removeItem(this.getKey(t))}clear(){for(let t=0;t<localStorage.length;t++){let e=localStorage.key(t);e?.startsWith(this.prefix)&&localStorage.removeItem(e)}}};var R=class R{get(t){let e=R.cache.get(t);return e?Date.now()>e.expiresAt?(R.cache.delete(t),null):e.value:null}set(t,e,r){let n=Date.now()+r*1e3;R.cache.set(t,{value:e,expiresAt:n})}forget(t){R.cache.delete(t)}clear(){R.cache.clear()}};R.cache=new Map;var M=R;var Ct={OneMinute:60,OneHour:60*60,OneDay:60*60*24,OneWeek:60*60*24*7,OneMonth:60*60*24*30,OneYear:60*60*24*365},E={Warp:a=>`warp:${a}`,WarpAbi:a=>`warp-abi:${a}`,RegistryInfo:a=>`registry-info:${a}`,Brand:a=>`brand:${a}`,ChainInfo:a=>`chain:${a}`,ChainInfos:()=>"chains"},V=class{constructor(t){this.strategy=this.selectStrategy(t)}selectStrategy(t){return t==="localStorage"?new q:t==="memory"?new M:typeof window<"u"&&window.localStorage?new q:new M}set(t,e,r){this.strategy.set(t,e,r)}get(t){return this.strategy.get(t)}forget(t){this.strategy.forget(t)}clear(){this.strategy.clear()}};import ge from"qr-code-styling";import{Address as Wt,TransactionsFactoryConfig as ue,TransferTransactionsFactory as pe}from"@multiversx/sdk-core";var k=class k{static info(...t){k.isTestEnv||console.info(...t)}static warn(...t){k.isTestEnv||console.warn(...t)}static error(...t){k.isTestEnv||console.error(...t)}};k.isTestEnv=typeof process<"u"&&process.env.JEST_WORKER_ID!==void 0;var A=k;import ce from"ajv";var j=class{constructor(t){this.config=t;this.config=t}async validate(t){let e=[];return e.push(...this.validateMaxOneValuePosition(t)),e.push(...this.validateVariableNamesAndResultNamesUppercase(t)),e.push(...this.validateAbiIsSetIfApplicable(t)),e.push(...await this.validateSchema(t)),{valid:e.length===0,errors:e}}validateMaxOneValuePosition(t){return t.actions.filter(r=>r.inputs?r.inputs.some(n=>n.position==="value"):!1).length>1?["Only one value position action is allowed"]:[]}validateVariableNamesAndResultNamesUppercase(t){let e=[],r=(n,i)=>{n&&Object.keys(n).forEach(s=>{s!==s.toUpperCase()&&e.push(`${i} name '${s}' must be uppercase`)})};return r(t.vars,"Variable"),r(t.results,"Result"),e}validateAbiIsSetIfApplicable(t){let e=t.actions.some(i=>i.type==="contract"),r=t.actions.some(i=>i.type==="query");if(!e&&!r)return[];let n=t.actions.some(i=>i.abi);return t.results&&!n?["ABI is required when results are present for contract or query actions"]:[]}async validateSchema(t){try{let e=this.config.schema?.warp||W.LatestWarpSchemaUrl,n=await(await fetch(e)).json(),i=new ce,s=i.compile(n);return s(t)?[]:[`Schema validation failed: ${i.errorsText(s.errors)}`]}catch(e){return[`Schema validation failed: ${e instanceof Error?e.message:String(e)}`]}}};var Q=class{constructor(t){this.pendingWarp={protocol:O("warp"),name:"",title:"",description:null,preview:"",actions:[]};this.config=t,this.cache=new V(t.cache?.type)}createInscriptionTransaction(t){if(!this.config.user?.wallet)throw new Error("WarpBuilder: user address not set");let e=T(this.config),r=new ue({chainID:e.chainId}),n=new pe({config:r}),i=Wt.newFromBech32(this.config.user.wallet),s=JSON.stringify(t),o=n.createTransactionForTransfer(i,{receiver:Wt.newFromBech32(this.config.user.wallet),nativeAmount:BigInt(0),data:Uint8Array.from(Buffer.from(s))});return o.gasLimit=o.gasLimit+BigInt(2e6),o}async createFromRaw(t,e=!0){let r=JSON.parse(t);return e&&await this.validate(r),r}async createFromTransaction(t,e=!1){let r=await this.createFromRaw(t.data.toString(),e);return r.meta={hash:t.hash,creator:t.sender.toBech32(),createdAt:new Date(t.timestamp*1e3).toISOString()},r}async createFromTransactionHash(t,e){let r=E.Warp(t);if(e){let o=this.cache.get(r);if(o)return A.info(`WarpBuilder (createFromTransactionHash): Warp found in cache: ${t}`),o}let n=T(this.config),s=g.getChainEntrypoint(n,this.config.env).createNetworkProvider();try{let o=await s.getTransaction(t),c=await this.createFromTransaction(o);return e&&e.ttl&&c&&this.cache.set(r,c,e.ttl),c}catch(o){return console.error("WarpBuilder: Error creating from transaction hash",o),null}}setName(t){return this.pendingWarp.name=t,this}setTitle(t){return this.pendingWarp.title=t,this}setDescription(t){return this.pendingWarp.description=t,this}setPreview(t){return this.pendingWarp.preview=t,this}setActions(t){return this.pendingWarp.actions=t,this}addAction(t){return this.pendingWarp.actions.push(t),this}async build(){return this.ensure(this.pendingWarp.protocol,"protocol is required"),this.ensure(this.pendingWarp.name,"name is required"),this.ensure(this.pendingWarp.title,"title is required"),this.ensure(this.pendingWarp.actions.length>0,"actions are required"),await this.validate(this.pendingWarp),this.pendingWarp}getDescriptionPreview(t,e=100){return Tt(t,e)}ensure(t,e){if(!t)throw new Error(e)}async validate(t){let r=await new j(this.config).validate(t);if(!r.valid)throw new Error(r.errors.join(`
|
|
2
|
-
`))}};var U=class{static async apply(t,e){let r=this.applyVars(t,e);return await this.applyGlobals(t,r)}static async applyGlobals(t,e){let r={...e};return r.actions=await Promise.all(r.actions.map(async n=>await this.applyActionGlobals(t,n))),r=await this.applyRootGlobals(r,t),r}static applyVars(t,e){if(!e?.vars)return e;let r=JSON.stringify(e),n=(i,s)=>{r=r.replace(new RegExp(`{{${i.toUpperCase()}}}`,"g"),s.toString())};return Object.entries(e.vars).forEach(([i,s])=>{if(typeof s!="string")n(i,s);else if(s.startsWith(`${p.Vars.Query}:`)){if(!t.currentUrl)throw new Error("WarpUtils: currentUrl config is required to prepare vars");let o=s.split(`${p.Vars.Query}:`)[1],c=new URLSearchParams(t.currentUrl.split("?")[1]).get(o);c&&n(i,c)}else if(s.startsWith(`${p.Vars.Env}:`)){let o=s.split(`${p.Vars.Env}:`)[1],c=t.vars?.[o];c&&n(i,c)}else s===p.Source.UserWallet&&t.user?.wallet?n(i,t.user.wallet):n(i,s)}),JSON.parse(r)}static async applyRootGlobals(t,e){let r=JSON.stringify(t),n={config:e,chain:T(e)};return Object.values(p.Globals).forEach(i=>{let s=i.Accessor(n);s!=null&&(r=r.replace(new RegExp(`{{${i.Placeholder}}}`,"g"),s.toString()))}),JSON.parse(r)}static async applyActionGlobals(t,e){let r=await g.getChainInfoForAction(t,e),n=JSON.stringify(e),i={config:t,chain:r};return Object.values(p.Globals).forEach(s=>{let o=s.Accessor(i);o!=null&&(n=n.replace(new RegExp(`{{${s.Placeholder}}}`,"g"),o.toString()))}),JSON.parse(n)}};import{AbiRegistry as It,Address as S,AddressValue as tt,BytesValue as C,SmartContractTransactionsFactory as fe,TransactionsFactoryConfig as de}from"@multiversx/sdk-core/out";var Z={buildInfo:{rustc:{version:"1.86.0",commitHash:"05f9846f893b09a1be1fc8560e33fc3c815cfecb",commitDate:"2025-03-31",channel:"Stable",short:"rustc 1.86.0 (05f9846f8 2025-03-31)"},contractCrate:{name:"registry",version:"0.0.1"},framework:{name:"multiversx-sc",version:"0.51.1"}},name:"RegistryContract",constructor:{inputs:[{name:"unit_price",type:"BigUint"},{name:"vault",type:"Address"}],outputs:[]},upgradeConstructor:{inputs:[],outputs:[]},endpoints:[{name:"registerWarp",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"hash",type:"bytes"},{name:"alias_opt",type:"optional<bytes>",multi_arg:!0},{name:"brand_opt",type:"optional<bytes>",multi_arg:!0}],outputs:[],allow_multiple_var_args:!0},{name:"unregisterWarp",mutability:"mutable",inputs:[{name:"warp",type:"bytes"}],outputs:[]},{name:"upgradeWarp",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"alias",type:"bytes"},{name:"new_warp",type:"bytes"}],outputs:[]},{name:"setWarpAlias",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"hash",type:"bytes"},{name:"alias",type:"bytes"}],outputs:[]},{name:"forceRemoveAlias",mutability:"mutable",inputs:[{name:"hash",type:"bytes"}],outputs:[]},{name:"verifyWarp",mutability:"mutable",inputs:[{name:"warp",type:"bytes"}],outputs:[]},{name:"transferOwnership",mutability:"mutable",inputs:[{name:"warp",type:"bytes"},{name:"new_owner",type:"Address"}],outputs:[]},{name:"getUserWarps",mutability:"readonly",inputs:[{name:"address",type:"Address"}],outputs:[{type:"variadic<InfoView>",multi_result:!0}]},{name:"getInfoByAlias",mutability:"readonly",inputs:[{name:"alias",type:"bytes"}],outputs:[{type:"InfoView"}]},{name:"getInfoByHash",mutability:"readonly",inputs:[{name:"hash",type:"bytes"}],outputs:[{type:"InfoView"}]},{name:"setVault",onlyOwner:!0,mutability:"mutable",inputs:[{name:"vault",type:"Address"}],outputs:[]},{name:"setUnitPrice",onlyOwner:!0,mutability:"mutable",inputs:[{name:"amount",type:"BigUint"}],outputs:[]},{name:"addAdmin",onlyOwner:!0,mutability:"mutable",inputs:[{name:"address",type:"Address"}],outputs:[]},{name:"removeAdmin",onlyOwner:!0,mutability:"mutable",inputs:[{name:"address",type:"Address"}],outputs:[]},{name:"getConfig",mutability:"readonly",inputs:[],outputs:[{type:"ConfigView"}]},{name:"registerBrand",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"hash",type:"bytes"}],outputs:[]},{name:"brandWarp",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"warp",type:"bytes"},{name:"brand",type:"bytes"}],outputs:[]},{name:"getUserBrands",mutability:"readonly",inputs:[{name:"user",type:"Address"}],outputs:[{type:"variadic<bytes>",multi_result:!0}]},{name:"setChain",onlyOwner:!0,mutability:"mutable",inputs:[{name:"name",type:"bytes"},{name:"display_name",type:"bytes"},{name:"chain_id",type:"bytes"},{name:"block_time",type:"u32"},{name:"address_hrp",type:"bytes"},{name:"api_url",type:"bytes"},{name:"explorer_url",type:"bytes"}],outputs:[]},{name:"removeChain",onlyOwner:!0,mutability:"mutable",inputs:[{name:"name",type:"bytes"}],outputs:[]},{name:"getChain",mutability:"readonly",inputs:[{name:"name",type:"bytes"}],outputs:[{type:"ChainView"}]},{name:"getChains",mutability:"readonly",inputs:[],outputs:[{type:"variadic<ChainView>",multi_result:!0}]}],events:[{identifier:"warpRegistered",inputs:[{name:"hash",type:"bytes",indexed:!0},{name:"alias",type:"bytes",indexed:!0},{name:"trust",type:"bytes",indexed:!0}]},{identifier:"warpUnregistered",inputs:[{name:"hash",type:"bytes",indexed:!0}]},{identifier:"warpUpgraded",inputs:[{name:"alias",type:"bytes",indexed:!0},{name:"new_warp",type:"bytes",indexed:!0},{name:"trust",type:"bytes",indexed:!0}]},{identifier:"warpVerified",inputs:[{name:"hash",type:"bytes",indexed:!0}]},{identifier:"aliasUpdated",inputs:[{name:"hash",type:"bytes",indexed:!0},{name:"alias",type:"bytes",indexed:!0}]},{identifier:"ownershipTransferred",inputs:[{name:"warp",type:"bytes",indexed:!0},{name:"old_owner",type:"Address",indexed:!0},{name:"new_owner",type:"Address",indexed:!0}]}],esdtAttributes:[],hasCallback:!1,types:{ChainView:{type:"struct",fields:[{name:"name",type:"bytes"},{name:"display_name",type:"bytes"},{name:"chain_id",type:"bytes"},{name:"block_time",type:"u32"},{name:"address_hrp",type:"bytes"},{name:"api_url",type:"bytes"},{name:"explorer_url",type:"bytes"}]},ConfigView:{type:"struct",fields:[{name:"unit_price",type:"BigUint"},{name:"admins",type:"List<Address>"}]},InfoView:{type:"struct",fields:[{name:"hash",type:"bytes"},{name:"alias",type:"Option<bytes>"},{name:"trust",type:"bytes"},{name:"owner",type:"Address"},{name:"created_at",type:"u64"},{name:"upgraded_at",type:"u64"},{name:"brand",type:"Option<bytes>"},{name:"upgrade",type:"Option<bytes>"}]}}};var G=a=>({hash:a.hash.toString("hex"),alias:a.alias?.toString()||null,trust:a.trust.toString(),owner:a.owner.toString(),createdAt:a.created_at.toNumber(),upgradedAt:a.upgraded_at?.toNumber(),brand:a.brand?.toString("hex")||null,upgrade:a.upgrade?.toString("hex")||null}),bt=a=>({unitPrice:BigInt(a.unit_price.toString()),admins:a.admins.map(t=>t.toBech32())});var $=class{constructor(t){this.config=t,this.cache=new V(t.cache?.type),this.registryConfig={unitPrice:BigInt(0),admins:[]}}async init(){await this.loadRegistryConfigs()}createWarpRegisterTransaction(t,e,r){if(this.registryConfig.unitPrice===BigInt(0))throw new Error("WarpRegistry: config not loaded. forgot to call init()?");if(!this.config.user?.wallet)throw new Error("WarpRegistry: user address not set");let n=S.newFromBech32(this.config.user.wallet),i=()=>this.isCurrentUserAdmin()?BigInt(0):e&&r?this.registryConfig.unitPrice*BigInt(3):e?this.registryConfig.unitPrice*BigInt(2):this.registryConfig.unitPrice,s=()=>e&&r?[C.fromHex(t),C.fromUTF8(e),C.fromHex(r)]:e?[C.fromHex(t),C.fromUTF8(e)]:[C.fromHex(t)];return this.getFactory().createTransactionForExecute(n,{contract:this.getRegistryContractAddress(),function:"registerWarp",gasLimit:BigInt(1e7),nativeTransferAmount:i(),arguments:s()})}createWarpUnregisterTransaction(t){if(!this.config.user?.wallet)throw new Error("WarpRegistry: user address not set");let e=S.newFromBech32(this.config.user.wallet);return this.getFactory().createTransactionForExecute(e,{contract:this.getRegistryContractAddress(),function:"unregisterWarp",gasLimit:BigInt(1e7),arguments:[C.fromHex(t)]})}createWarpUpgradeTransaction(t,e){if(this.registryConfig.unitPrice===BigInt(0))throw new Error("WarpRegistry: config not loaded. forgot to call init()?");if(!this.config.user?.wallet)throw new Error("WarpRegistry: user address not set");let r=S.newFromBech32(this.config.user.wallet);return this.getFactory().createTransactionForExecute(r,{contract:this.getRegistryContractAddress(),function:"upgradeWarp",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[C.fromUTF8(t),C.fromHex(e)]})}createWarpAliasSetTransaction(t,e){if(!this.config.user?.wallet)throw new Error("WarpRegistry: user address not set");let r=S.newFromBech32(this.config.user.wallet);return this.getFactory().createTransactionForExecute(r,{contract:this.getRegistryContractAddress(),function:"setWarpAlias",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[C.fromHex(t),C.fromUTF8(e)]})}createWarpVerifyTransaction(t){if(!this.config.user?.wallet)throw new Error("WarpRegistry: user address not set");let e=S.newFromBech32(this.config.user.wallet);return this.getFactory().createTransactionForExecute(e,{contract:this.getRegistryContractAddress(),function:"verifyWarp",gasLimit:BigInt(1e7),arguments:[C.fromHex(t)]})}createWarpTransferOwnershipTransaction(t,e){if(!this.config.user?.wallet)throw new Error("WarpRegistry: user address not set");let r=S.newFromBech32(this.config.user.wallet);return this.getFactory().createTransactionForExecute(r,{contract:this.getRegistryContractAddress(),function:"transferOwnership",gasLimit:BigInt(1e7),arguments:[C.fromHex(t),new tt(new S(e))]})}createBrandRegisterTransaction(t){if(this.registryConfig.unitPrice===BigInt(0))throw new Error("WarpRegistry: config not loaded. forgot to call init()?");if(!this.config.user?.wallet)throw new Error("WarpRegistry: user address not set");let e=S.newFromBech32(this.config.user.wallet);return this.getFactory().createTransactionForExecute(e,{contract:this.getRegistryContractAddress(),function:"registerBrand",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[C.fromHex(t)]})}createWarpBrandingTransaction(t,e){if(!this.config.user?.wallet)throw new Error("WarpRegistry: user address not set");let r=S.newFromBech32(this.config.user.wallet);return this.getFactory().createTransactionForExecute(r,{contract:this.getRegistryContractAddress(),function:"brandWarp",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[C.fromHex(t),C.fromHex(e)]})}async getInfoByAlias(t,e){try{let r=E.RegistryInfo(t),n=e?this.cache.get(r):null;if(n)return A.info(`WarpRegistry (getInfoByAlias): RegistryInfo found in cache: ${t}`),n;let i=this.getRegistryContractAddress(),s=this.getController(),o=s.createQuery({contract:i,function:"getInfoByAlias",arguments:[C.fromUTF8(t)]}),c=await s.runQuery(o),[u]=s.parseQueryResponse(c),l=u?G(u):null,f=l?.brand?await this.fetchBrand(l.brand):null;return e&&e.ttl&&this.cache.set(r,{registryInfo:l,brand:f},e.ttl),{registryInfo:l,brand:f}}catch{return{registryInfo:null,brand:null}}}async getInfoByHash(t,e){try{let r=E.RegistryInfo(t);if(e){let f=this.cache.get(r);if(f)return A.info(`WarpRegistry (getInfoByHash): RegistryInfo found in cache: ${t}`),f}let n=this.getRegistryContractAddress(),i=this.getController(),s=i.createQuery({contract:n,function:"getInfoByHash",arguments:[C.fromHex(t)]}),o=await i.runQuery(s),[c]=i.parseQueryResponse(o),u=c?G(c):null,l=u?.brand?await this.fetchBrand(u.brand):null;return e&&e.ttl&&this.cache.set(r,{registryInfo:u,brand:l},e.ttl),{registryInfo:u,brand:l}}catch{return{registryInfo:null,brand:null}}}async getUserWarpRegistryInfos(t){try{let e=t||this.config.user?.wallet;if(!e)throw new Error("WarpRegistry: user address not set");let r=this.getRegistryContractAddress(),n=this.getController(),i=n.createQuery({contract:r,function:"getUserWarps",arguments:[new tt(new S(e))]}),s=await n.runQuery(i),[o]=n.parseQueryResponse(s);return o.map(G)}catch{return[]}}async getUserBrands(t){try{let e=t||this.config.user?.wallet;if(!e)throw new Error("WarpRegistry: user address not set");let r=this.getRegistryContractAddress(),n=this.getController(),i=n.createQuery({contract:r,function:"getUserBrands",arguments:[new tt(new S(e))]}),s=await n.runQuery(i),[o]=n.parseQueryResponse(s),c=o.map(f=>f.toString("hex")),u={ttl:365*24*60*60};return(await Promise.all(c.map(f=>this.fetchBrand(f,u)))).filter(f=>f!==null)}catch{return[]}}async getChainInfos(t){let e=E.ChainInfos();if(t&&t.ttl){let u=this.cache.get(e);if(u)return A.info("WarpRegistry (getChainInfos): ChainInfos found in cache"),u}let r=this.getRegistryContractAddress(),n=this.getController(),i=n.createQuery({contract:r,function:"getChains",arguments:[]}),s=await n.runQuery(i),[o]=n.parseQueryResponse(s),c=o.map(Y);if(t&&t.ttl){for(let u of c)this.cache.set(E.ChainInfo(u.chain),u,t.ttl);this.cache.set(e,c,t.ttl)}return c}async getChainInfo(t,e){try{let r=E.ChainInfo(t),n=e?this.cache.get(r):null;if(n)return A.info(`WarpRegistry (getChainInfo): ChainInfo found in cache: ${t}`),n;let i=this.getRegistryContractAddress(),s=this.getController(),o=s.createQuery({contract:i,function:"getChain",arguments:[C.fromUTF8(t)]}),c=await s.runQuery(o),[u]=s.parseQueryResponse(c),l=u?Y(u):null;return e&&e.ttl&&l&&this.cache.set(r,l,e.ttl),l}catch{return null}}async fetchBrand(t,e){let r=E.Brand(t),n=e?this.cache.get(r):null;if(n)return A.info(`WarpRegistry (fetchBrand): Brand found in cache: ${t}`),n;let i=T(this.config),o=g.getChainEntrypoint(i,this.config.env).createNetworkProvider();try{let c=await o.getTransaction(t),u=JSON.parse(c.data.toString());return u.meta={hash:c.hash,creator:c.sender.bech32(),createdAt:new Date(c.timestamp*1e3).toISOString()},e&&e.ttl&&this.cache.set(r,u,e.ttl),u}catch{return null}}getRegistryContractAddress(){return S.newFromBech32(this.config.registry?.contract||W.Registry.Contract(this.config.env))}async loadRegistryConfigs(){let t=this.getRegistryContractAddress(),e=this.getController(),[r]=await e.query({contract:t,function:"getConfig",arguments:[]}),n=r?bt(r):null;this.registryConfig=n||{unitPrice:BigInt(0),admins:[]}}getFactory(){let t=T(this.config),e=new de({chainID:t.chainId}),r=It.create(Z);return new fe({config:e,abi:r})}getController(){let t=T(this.config),e=g.getChainEntrypoint(t,this.config.env),r=It.create(Z);return e.createSmartContractController(r)}isCurrentUserAdmin(){return!!this.config.user?.wallet&&this.registryConfig.admins.includes(this.config.user.wallet)}};var z=class{constructor(t){this.config=t;this.config=t}isValid(t){return t.startsWith(p.HttpProtocolPrefix)?!!this.extractIdentifierInfoFromUrl(t):!1}async detectFromHtml(t){if(!t.length)return{match:!1,results:[]};let n=[...t.matchAll(/https?:\/\/[^\s"'<>]+/gi)].map(u=>u[0]).filter(u=>this.isValid(u)).map(u=>this.detect(u)),s=(await Promise.all(n)).filter(u=>u.match),o=s.length>0,c=s.map(u=>({url:u.url,warp:u.warp}));return{match:o,results:c}}async detect(t,e){let r={match:!1,url:t,warp:null,registryInfo:null,brand:null},n=t.startsWith(p.HttpProtocolPrefix)?this.extractIdentifierInfoFromUrl(t):g.getInfoFromPrefixedIdentifier(t);if(!n)return r;try{let{type:i,identifierBase:s}=n,o=new Q(this.config),c=new $(this.config),u=null,l=null,f=null;if(i==="hash"){u=await o.createFromTransactionHash(s,e);let y=await c.getInfoByHash(s,e);l=y.registryInfo,f=y.brand}else if(i==="alias"){let y=await c.getInfoByAlias(s,e);l=y.registryInfo,f=y.brand,y.registryInfo&&(u=await o.createFromTransactionHash(y.registryInfo.hash,e))}let h=u?await U.apply(this.config,u):null;return h?{match:!0,url:t,warp:h,registryInfo:l,brand:f}:r}catch(i){return A.error("Error detecting warp link",i),r}}build(t,e){let r=this.config.clientUrl||W.DefaultClientUrl(this.config.env),n=t===p.IdentifierType.Alias?encodeURIComponent(e):encodeURIComponent(t+p.IdentifierParamSeparator+e);return W.SuperClientUrls.includes(r)?`${r}/${n}`:`${r}?${p.IdentifierParamName}=${n}`}buildFromPrefixedIdentifier(t){let e=g.getInfoFromPrefixedIdentifier(t);return e?this.build(e.type,e.identifierBase):""}generateQrCode(t,e,r=512,n="white",i="black",s="#23F7DD"){let o=this.build(t,e);return new ge({type:"svg",width:r,height:r,data:String(o),margin:16,qrOptions:{typeNumber:0,mode:"Byte",errorCorrectionLevel:"Q"},backgroundOptions:{color:n},dotsOptions:{type:"extra-rounded",color:i},cornersSquareOptions:{type:"extra-rounded",color:i},cornersDotOptions:{type:"square",color:i},imageOptions:{hideBackgroundDots:!0,imageSize:.4,margin:8},image:`data:image/svg+xml;utf8,<svg width="16" height="16" viewBox="0 0 100 100" fill="${encodeURIComponent(s)}" xmlns="http://www.w3.org/2000/svg"><path d="M54.8383 50.0242L95 28.8232L88.2456 16L51.4717 30.6974C50.5241 31.0764 49.4759 31.0764 48.5283 30.6974L11.7544 16L5 28.8232L45.1616 50.0242L5 71.2255L11.7544 84.0488L48.5283 69.351C49.4759 68.9724 50.5241 68.9724 51.4717 69.351L88.2456 84.0488L95 71.2255L54.8383 50.0242Z"/></svg>`})}extractIdentifierInfoFromUrl(t){let e=new URL(t),r=W.SuperClientUrls.includes(e.origin),n=e.searchParams.get(p.IdentifierParamName),i=r&&!n?e.pathname.split("/")[1]:n;if(!i)return null;let s=decodeURIComponent(i);return g.getInfoFromPrefixedIdentifier(s)}};var we="https://",g=class{static getInfoFromPrefixedIdentifier(t){let e=decodeURIComponent(t),r=e.includes(p.IdentifierParamSeparator)?e:`${p.IdentifierType.Alias}${p.IdentifierParamSeparator}${e}`,[n,i]=r.split(p.IdentifierParamSeparator),s=i.split("?")[0];return{type:n,identifier:i,identifierBase:s}}static getNextInfo(t,e,r,n){let i=e.actions?.[r]?.next||e.next||null;if(!i)return null;if(i.startsWith(we))return[{identifier:null,url:i}];let[s,o]=i.split("?");if(!o)return[{identifier:s,url:this.buildNextUrl(s,t)}];let c=o.match(/{{([^}]+)\[\](\.[^}]+)?}}/g)||[];if(c.length===0){let d=D(o,{...e.vars,...n}),m=d?`${s}?${d}`:s;return[{identifier:m,url:this.buildNextUrl(m,t)}]}let u=c[0];if(!u)return[];let l=u.match(/{{([^[]+)\[\]/),f=l?l[1]:null;if(!f||n[f]===void 0)return[];let h=Array.isArray(n[f])?n[f]:[n[f]];if(h.length===0)return[];let y=c.filter(d=>d.includes(`{{${f}[]`)).map(d=>{let m=d.match(/\[\](\.[^}]+)?}}/),w=m&&m[1]||"";return{placeholder:d,field:w?w.slice(1):"",regex:new RegExp(d.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"g")}});return h.map(d=>{let m=o;for(let{regex:b,field:P}of y){let x=P?this.getNestedValue(d,P):d;if(x==null)return null;m=m.replace(b,x)}if(m.includes("{{")||m.includes("}}"))return null;let w=m?`${s}?${m}`:s;return{identifier:w,url:this.buildNextUrl(w,t)}}).filter(d=>d!==null)}static buildNextUrl(t,e){let[r,n]=t.split("?"),i=this.getInfoFromPrefixedIdentifier(r)||{type:"alias",identifier:r,identifierBase:r},o=new z(e).build(i.type,i.identifierBase);if(!n)return o;let c=new URL(o);return new URLSearchParams(n).forEach((u,l)=>c.searchParams.set(l,u)),c.toString().replace(/\/\?/,"?")}static getNestedValue(t,e){return e.split(".").reduce((r,n)=>r?.[n],t)}static async getChainInfoForAction(t,e){if(!e.chain)return T(t);let r=await new $(t).getChainInfo(e.chain,{ttl:Ct.OneWeek});if(!r)throw new Error(`WarpActionExecutor: Chain info not found for ${e.chain}`);return r}static getChainEntrypoint(t,e){let r="warp-sdk",n="api";return e==="devnet"?new me(t.apiUrl,n,r):e==="testnet"?new ye(t.apiUrl,n,r):new he(t.apiUrl,n,r)}};var At=class{constructor(t){this.pendingBrand={protocol:O("brand"),name:"",description:"",logo:""};this.config=t}createInscriptionTransaction(t){if(!this.config.user?.wallet)throw new Error("BrandBuilder: user address not set");let e=T(this.config),r=new Te({chainID:e.chainId}),n=new Ce({config:r}),i=vt.newFromBech32(this.config.user.wallet),s=JSON.stringify(t);return n.createTransactionForNativeTokenTransfer(i,{receiver:vt.newFromBech32(this.config.user.wallet),nativeAmount:BigInt(0),data:Uint8Array.from(Buffer.from(s))})}async createFromRaw(t,e=!0){let r=JSON.parse(t);return e&&await this.ensureValidSchema(r),r}async createFromTransaction(t,e=!1){return await this.createFromRaw(t.data.toString(),e)}async createFromTransactionHash(t){let e=T(this.config),n=g.getChainEntrypoint(e,this.config.env).createNetworkProvider();try{let i=await n.getTransaction(t);return this.createFromTransaction(i)}catch(i){return console.error("BrandBuilder: Error creating from transaction hash",i),null}}setName(t){return this.pendingBrand.name=t,this}setDescription(t){return this.pendingBrand.description=t,this}setLogo(t){return this.pendingBrand.logo=t,this}setUrls(t){return this.pendingBrand.urls=t,this}setColors(t){return this.pendingBrand.colors=t,this}setCta(t){return this.pendingBrand.cta=t,this}async build(){return this.ensure(this.pendingBrand.name,"name is required"),this.ensure(this.pendingBrand.description,"description is required"),this.ensure(this.pendingBrand.logo,"logo is required"),await this.ensureValidSchema(this.pendingBrand),this.pendingBrand}ensure(t,e){if(!t)throw new Error(`Warp: ${e}`)}async ensureValidSchema(t){let e=this.config.schema?.brand||W.LatestBrandSchemaUrl,n=await(await fetch(e)).json(),i=new We,s=i.compile(n);if(!s(t))throw new Error(`BrandBuilder: schema validation failed: ${i.errorsText(s.errors)}`)}};import{Address as be,AddressValue as Ie,BigUIntType as ve,BigUIntValue as xt,BooleanValue as Ae,BytesValue as xe,CodeMetadata as Be,CodeMetadataValue as Se,CompositeType as Ee,CompositeValue as Pe,Field as et,FieldDefinition as rt,List as Re,NothingValue as Ve,OptionalValue as nt,OptionValue as it,StringValue as Ue,Struct as Ne,StructType as Fe,TokenIdentifierType as Oe,TokenIdentifierValue as Bt,U16Value as ke,U32Value as $e,U64Type as Le,U64Value as St,U8Value as _e,VariadicValue as qe}from"@multiversx/sdk-core/out";var Nn=(a,t)=>a?it.newProvided(a):t?it.newMissingTyped(t):it.newMissing(),Fn=(a,t)=>a?new nt(a.getType(),a):t?new nt(t):nt.newMissing(),On=a=>{if(a.length===0)throw new Error("Cannot create a list from an empty array");let t=a[0].getType();return new Re(t,a)},kn=a=>qe.fromItems(...a),$n=a=>{let t=a.map(e=>e.getType());return new Pe(new Ee(...t),a)},Ln=a=>Ue.fromUTF8(a),_n=a=>new _e(a),qn=a=>new ke(a),Mn=a=>new $e(a),Hn=a=>new St(a),Dn=a=>new xt(BigInt(a)),jn=a=>new Ae(a),Qn=a=>new Ie(be.newFromBech32(a)),Gn=a=>new Bt(a),zn=a=>xe.fromHex(a),Kn=a=>new Ne(new Fe("EsdtTokenPayment",[new rt("token_identifier","",new Oe),new rt("token_nonce","",new Le),new rt("amount","",new ve)]),[new et(new Bt(a.token.identifier),"token_identifier"),new et(new St(BigInt(a.token.nonce)),"token_nonce"),new et(new xt(BigInt(a.amount)),"amount")]),Jn=a=>new Se(Be.newFromBytes(Uint8Array.from(Buffer.from(a,"hex")))),Xn=()=>new Ve;import{Address as Me,TransactionsFactoryConfig as He,TransferTransactionsFactory as De}from"@multiversx/sdk-core";var K=class{constructor(t){this.cache=new V;this.config=t}createInscriptionTransaction(t){if(!this.config.user?.wallet)throw new Error("WarpBuilder: user address not set");let e=T(this.config),r=new He({chainID:e.chainId}),n=new De({config:r}),i={protocol:O("abi"),content:t},s=Me.newFromBech32(this.config.user.wallet),o=JSON.stringify(i),c=n.createTransactionForTransfer(s,{receiver:s,nativeAmount:BigInt(0),data:Uint8Array.from(Buffer.from(o))});return c.gasLimit=c.gasLimit+BigInt(2e6),c}async createFromRaw(t){return JSON.parse(t)}async createFromTransaction(t){let e=await this.createFromRaw(t.data.toString());return e.meta={hash:t.hash,creator:t.sender.bech32(),createdAt:new Date(t.timestamp*1e3).toISOString()},e}async createFromTransactionHash(t,e){let r=E.WarpAbi(t);if(e){let o=this.cache.get(r);if(o)return A.info(`WarpAbiBuilder (createFromTransactionHash): Warp abi found in cache: ${t}`),o}let n=T(this.config),s=g.getChainEntrypoint(n,this.config.env).createNetworkProvider();try{let o=await s.getTransaction(t),c=await this.createFromTransaction(o);return e&&e.ttl&&c&&this.cache.set(r,c,e.ttl),c}catch(o){return console.error("WarpAbiBuilder: Error creating from transaction hash",o),null}}};import{AbiRegistry as yt,Address as wt,ArgSerializer as ir,SmartContractTransactionsFactory as ar,Token as ne,TokenComputer as sr,TokenTransfer as ie,TransactionsFactoryConfig as or,TransferTransactionsFactory as cr}from"@multiversx/sdk-core";import{SmartContractTransactionsOutcomeParser as Ye,TransactionEventsParser as Ze,findEventsByFirstTopic as tr}from"@multiversx/sdk-core/out";import{Address as je,AddressType as Et,AddressValue as Pt,BigUIntType as at,BigUIntValue as st,BooleanType as Rt,BooleanValue as Vt,BytesType as Ut,BytesValue as Nt,CodeMetadata as Qe,CodeMetadataType as Ft,CodeMetadataValue as Ot,CompositeType as kt,CompositeValue as $t,Field as ot,FieldDefinition as ct,List as Lt,ListType as Ge,NothingValue as B,OptionalType as ze,OptionalValue as ut,OptionType as Ke,OptionValue as pt,StringType as _t,StringValue as qt,Struct as Je,StructType as Mt,Token as Xe,TokenIdentifierType as lt,TokenIdentifierValue as ft,TokenTransfer as Ht,U16Type as Dt,U16Value as jt,U32Type as Qt,U32Value as Gt,U64Type as dt,U64Value as gt,U8Type as zt,U8Value as Kt,VariadicType as Jt,VariadicValue as Xt}from"@multiversx/sdk-core/out";var Yt=new RegExp(`${p.ArgParamsSeparator}(.*)`),L=class{nativeToString(t,e){return t==="esdt"&&e instanceof Ht?`esdt:${e.token.identifier}|${e.token.nonce.toString()}|${e.amount.toString()}`:`${t}:${e?.toString()??""}`}typedToString(t){if(t.hasClassOrSuperclass(pt.ClassName))return t.isSet()?`option:${this.typedToString(t.getTypedValue())}`:"option:null";if(t.hasClassOrSuperclass(ut.ClassName))return t.isSet()?`optional:${this.typedToString(t.getTypedValue())}`:"optional:null";if(t.hasClassOrSuperclass(Lt.ClassName)){let e=t.getItems(),n=e.map(s=>this.typedToString(s).split(p.ArgParamsSeparator)[0])[0],i=e.map(s=>this.typedToString(s).split(p.ArgParamsSeparator)[1]);return`list:${n}:${i.join(",")}`}if(t.hasClassOrSuperclass(Xt.ClassName)){let e=t.getItems(),n=e.map(s=>this.typedToString(s).split(p.ArgParamsSeparator)[0])[0],i=e.map(s=>this.typedToString(s).split(p.ArgParamsSeparator)[1]);return`variadic:${n}:${i.join(",")}`}if(t.hasClassOrSuperclass($t.ClassName)){let e=t.getItems(),r=e.map(o=>this.typedToString(o).split(p.ArgParamsSeparator)[0]),n=e.map(o=>this.typedToString(o).split(p.ArgParamsSeparator)[1]),i=r.join(p.ArgCompositeSeparator),s=n.join(p.ArgCompositeSeparator);return`composite(${i}):${s}`}if(t.hasClassOrSuperclass(st.ClassName)||t.getType().getName()==="BigUint")return`biguint:${BigInt(t.valueOf().toFixed())}`;if(t.hasClassOrSuperclass(Kt.ClassName))return`uint8:${t.valueOf().toNumber()}`;if(t.hasClassOrSuperclass(jt.ClassName))return`uint16:${t.valueOf().toNumber()}`;if(t.hasClassOrSuperclass(Gt.ClassName))return`uint32:${t.valueOf().toNumber()}`;if(t.hasClassOrSuperclass(gt.ClassName))return`uint64:${BigInt(t.valueOf().toFixed())}`;if(t.hasClassOrSuperclass(qt.ClassName))return`string:${t.valueOf()}`;if(t.hasClassOrSuperclass(Vt.ClassName))return`bool:${t.valueOf()}`;if(t.hasClassOrSuperclass(Pt.ClassName))return`address:${t.valueOf().bech32()}`;if(t.hasClassOrSuperclass(ft.ClassName))return`token:${t.valueOf()}`;if(t.hasClassOrSuperclass(Nt.ClassName))return`hex:${t.valueOf().toString("hex")}`;if(t.hasClassOrSuperclass(Ot.ClassName))return`codemeta:${t.valueOf().toBuffer().toString("hex")}`;if(t.getType().getName()==="EsdtTokenPayment"){let e=t.getFieldValue("token_identifier").valueOf(),r=t.getFieldValue("token_nonce").valueOf(),n=t.getFieldValue("amount").valueOf();return`esdt:${e}|${r}|${n}`}throw new Error(`WarpArgSerializer (typedToString): Unsupported input type: ${t.getClassName()}`)}typedToNative(t){let e=this.typedToString(t);return this.stringToNative(e)}nativeToTyped(t,e){let r=this.nativeToString(t,e);return this.stringToTyped(r)}nativeToType(t){if(t.startsWith("composite")){let e=t.match(/\(([^)]+)\)/)?.[1];return new kt(...e.split(p.ArgCompositeSeparator).map(r=>this.nativeToType(r)))}if(t==="string")return new _t;if(t==="uint8")return new zt;if(t==="uint16")return new Dt;if(t==="uint32")return new Qt;if(t==="uint64")return new dt;if(t==="biguint")return new at;if(t==="bool")return new Rt;if(t==="address")return new Et;if(t==="token")return new lt;if(t==="hex")return new Ut;if(t==="codemeta")return new Ft;if(t==="esdt"||t==="nft")return new Mt("EsdtTokenPayment",[new ct("token_identifier","",new lt),new ct("token_nonce","",new dt),new ct("amount","",new at)]);throw new Error(`WarpArgSerializer (nativeToType): Unsupported input type: ${t}`)}stringToNative(t){let e=t.split(p.ArgParamsSeparator),r=e[0],n=e.slice(1).join(p.ArgParamsSeparator);if(r==="null")return[r,null];if(r==="option"){let[i,s]=n.split(p.ArgParamsSeparator);return[`option:${i}`,s||null]}else if(r==="optional"){let[i,s]=n.split(p.ArgParamsSeparator);return[`optional:${i}`,s||null]}else if(r==="list"){let i=n.split(p.ArgParamsSeparator),s=i.slice(0,-1).join(p.ArgParamsSeparator),o=i[i.length-1],u=(o?o.split(","):[]).map(l=>this.stringToNative(`${s}:${l}`)[1]);return[`list:${s}`,u]}else if(r==="variadic"){let i=n.split(p.ArgParamsSeparator),s=i.slice(0,-1).join(p.ArgParamsSeparator),o=i[i.length-1],u=(o?o.split(","):[]).map(l=>this.stringToNative(`${s}:${l}`)[1]);return[`variadic:${s}`,u]}else if(r.startsWith("composite")){let i=r.match(/\(([^)]+)\)/)?.[1]?.split(p.ArgCompositeSeparator),o=n.split(p.ArgCompositeSeparator).map((c,u)=>this.stringToNative(`${i[u]}:${c}`)[1]);return[r,o]}else{if(r==="string")return[r,n];if(r==="uint8"||r==="uint16"||r==="uint32")return[r,Number(n)];if(r==="uint64"||r==="biguint")return[r,BigInt(n||0)];if(r==="bool")return[r,n==="true"];if(r==="address")return[r,n];if(r==="token")return[r,n];if(r==="hex")return[r,n];if(r==="codemeta")return[r,n];if(r==="esdt"){let[i,s,o]=n.split(p.ArgCompositeSeparator);return[r,new Ht({token:new Xe({identifier:i,nonce:BigInt(s)}),amount:BigInt(o)})]}}throw new Error(`WarpArgSerializer (stringToNative): Unsupported input type: ${r}`)}stringToTyped(t){let[e,r]=t.split(/:(.*)/,2);if(e==="null"||e===null)return new B;if(e==="option"){let n=this.stringToTyped(r);return n instanceof B?pt.newMissingTyped(n.getType()):pt.newProvided(n)}if(e==="optional"){let n=this.stringToTyped(r);return n instanceof B?ut.newMissing():new ut(n.getType(),n)}if(e==="list"){let[n,i]=r.split(Yt,2),o=i.split(",").map(c=>this.stringToTyped(`${n}:${c}`));return new Lt(this.nativeToType(n),o)}if(e==="variadic"){let[n,i]=r.split(Yt,2),o=i.split(",").map(c=>this.stringToTyped(`${n}:${c}`));return new Xt(new Jt(this.nativeToType(n)),o)}if(e.startsWith("composite")){let n=e.match(/\(([^)]+)\)/)?.[1],i=r.split(p.ArgCompositeSeparator),s=n.split(p.ArgCompositeSeparator),o=i.map((u,l)=>this.stringToTyped(`${s[l]}:${u}`)),c=o.map(u=>u.getType());return new $t(new kt(...c),o)}if(e==="string")return r?qt.fromUTF8(r):new B;if(e==="uint8")return r?new Kt(Number(r)):new B;if(e==="uint16")return r?new jt(Number(r)):new B;if(e==="uint32")return r?new Gt(Number(r)):new B;if(e==="uint64")return r?new gt(BigInt(r)):new B;if(e==="biguint")return r?new st(BigInt(r)):new B;if(e==="bool")return r?new Vt(typeof r=="boolean"?r:r==="true"):new B;if(e==="address")return r?new Pt(je.newFromBech32(r)):new B;if(e==="token")return r?new ft(r):new B;if(e==="hex")return r?Nt.fromHex(r):new B;if(e==="codemeta")return new Ot(Qe.newFromBytes(Uint8Array.from(Buffer.from(r,"hex"))));if(e==="esdt"){let n=r.split(p.ArgCompositeSeparator);return new Je(this.nativeToType("esdt"),[new ot(new ft(n[0]),"token_identifier"),new ot(new gt(BigInt(n[1])),"token_nonce"),new ot(new st(BigInt(n[2])),"amount")])}throw new Error(`WarpArgSerializer (stringToTyped): Unsupported input type: ${e}`)}typeToString(t){if(t instanceof Ke)return"option:"+this.typeToString(t.getFirstTypeParameter());if(t instanceof ze)return"optional:"+this.typeToString(t.getFirstTypeParameter());if(t instanceof Ge)return"list:"+this.typeToString(t.getFirstTypeParameter());if(t instanceof Jt)return"variadic:"+this.typeToString(t.getFirstTypeParameter());if(t instanceof _t)return"string";if(t instanceof zt)return"uint8";if(t instanceof Dt)return"uint16";if(t instanceof Qt)return"uint32";if(t instanceof dt)return"uint64";if(t instanceof at)return"biguint";if(t instanceof Rt)return"bool";if(t instanceof Et)return"address";if(t instanceof lt)return"token";if(t instanceof Ut)return"hex";if(t instanceof Ft)return"codemeta";if(t instanceof Mt&&t.getClassName()==="EsdtTokenPayment")return"esdt";throw new Error(`WarpArgSerializer (typeToString): Unsupported input type: ${t.getClassName()}`)}};var er=async(a,t)=>{if(typeof window>"u"){let{VM:e}=oe("vm2"),r=new e({timeout:1e3,sandbox:{input:t},eval:!1,wasm:!1});return a.trim().startsWith("(")&&a.includes("=>")?r.run(`(${a})(input)`):null}return new Promise((e,r)=>{try{let n=new Blob([`
|
|
1
|
+
var ne=(c=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(c,{get:(r,i)=>(typeof require<"u"?require:r)[i]}):c)(function(c){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+c+'" is not supported')});var he=(c,r)=>()=>(r||c((r={exports:{}}).exports,r),r.exports);var He=he(Qt=>{"use strict";var $t=["Number","String","Boolean","Date","RegExp","Map","WeakMap","Set","WeakSet","Promise","Function"],Gt=["RangeError","ReferenceError","SyntaxError","TypeError","EvalError","URIError","Error"],Ua="Operation not allowed on contextified object.",We={__proto__:null,Object:Object.prototype,Array:Array.prototype};for(let c=0;c<$t.length;c++){let r=$t[c],i=global[r];i&&(We[r]=i.prototype)}for(let c=0;c<Gt.length;c++){let r=Gt[c],i=global[r];i&&(We[r]=i.prototype)}var{getPrototypeOf:Ge,setPrototypeOf:Kt,defineProperty:Ue,deleteProperty:ja,getOwnPropertyDescriptor:qa,isExtensible:Pr,preventExtensions:Pn,apply:ie,construct:$a,set:Ga,get:Ha,has:za,ownKeys:Ka,enumerate:Qa}=Reflect,Ja=Object,{freeze:Br,prototype:Wr}=Ja,Rr=Wr.hasOwnProperty,Ht=Proxy,Nn=WeakMap,{get:Nr,set:jt}=Nn.prototype,zt=Map,qt=zt.prototype.get,at=zt.prototype.set,Xa=Function,Ya=Xa.prototype.bind,Za=Array.isArray,eo=Error.captureStackTrace,to=Symbol.prototype.toString,Vr=Symbol.toStringTag,ro=Symbol.iterator,io=Symbol.for("nodejs.util.inspect.custom"),le=class extends Error{constructor(r,i){super(r),this.name="VMError",this.code=i,eo(this,this.constructor)}};We.VMError=le.prototype;function ke(){return new le("Unexpected")}if(!Kt(Qt,null))throw ke();function Or(c,r){let i=qa(c,r);if(!i)return i;if(!Kt(i,null))throw ke();return i}function Vn(c){"use strict";return Vn[c],ke()}function Rn(c,r){return r}var no=Br({__proto__:null,get(c,r,i){throw typeof r=="symbol"&&(r=ie(to,r,[])),new le(`Unexpected access to key '${r}'`)}}),On=Br({__proto__:null}),Wn=new Ht(On,no);function Bn(){}if(!Ue(Bn,"prototype",{__proto__:null,value:Wn}))throw ke();function so(){}var ao=Br({__proto__:Wn,construct(){return this}});function oo(c){let r=new Ht(c,ao);try{return new r,!0}catch{return!1}}function uo(c,r){let i;if(typeof c=="function")oo(c)?i=ie(Ya,so,[null]):i=()=>{};else if(Za(c))i=[];else return{__proto__:r};if(!Kt(i,r))throw ke();return i}function co(c,r){let i=new Nn,s=new zt,u=new zt;function l(L,T,S){ie(at,s,[L,Rn]),ie(at,s,[T,(k,W)=>xe(k,W,L)]),S&&ie(at,u,[L,S])}function p(L,T,S){let k;ie(at,s,[T,(W,F)=>(k||(k=L(),ie(at,s,[k,Rn]),S&&ie(at,u,[k,S])),xe(W,F,k))])}let f={__proto__:null,globalPrototypes:We,safeGetOwnPropertyDescriptor:Or,fromArguments:$e,from:Re,fromWithFactory:Je,ensureThis:At,mapping:i,connect:Be,reflectSet:Ga,reflectGet:Ha,reflectDefineProperty:Ue,reflectDeleteProperty:ja,reflectApply:ie,reflectConstruct:$a,reflectHas:za,reflectOwnKeys:Ka,reflectEnumerate:Qa,reflectGetPrototypeOf:Ge,reflectIsExtensible:Pr,reflectPreventExtensions:Pn,objectHasOwnProperty:Rr,weakMapSet:jt,addProtoMapping:l,addProtoMappingFactory:p,defaultFactory:Ae,protectedFactory:ye,readonlyFactory:Pe,VMError:le},b=typeof c!="object";b&&(c=c(f,r)),f.other=c;let{globalPrototypes:x,safeGetOwnPropertyDescriptor:C,fromArguments:I,from:R,mapping:V,reflectSet:O,reflectGet:y,reflectDefineProperty:m,reflectDeleteProperty:d,reflectApply:g,reflectConstruct:_,reflectHas:a,reflectOwnKeys:E,reflectEnumerate:N,reflectGetPrototypeOf:A,reflectIsExtensible:z,reflectPreventExtensions:G,objectHasOwnProperty:K,weakMapSet:pe}=c;function Qe(L,T){try{return g(K,L,[T])===!0}catch(S){throw re(S)}}function Et(L,T,S,k){let W;if(k.get||k.set){let F=k.get;if(!F)return;try{W=g(F,T,[S])}catch(j){throw re(j)}}else W=k.value;return L.fromOtherWithContext(W)}function de(L,T,S){if(!ie(Rr,T,[S]))return!1;try{L[S]=R(T[S])}catch(k){throw re(k)}return!0}class Ee extends Bn{constructor(T){super(),this.objectWrapper=()=>T}getObject(){return this.objectWrapper()}getFactory(){return Ae}fromOtherWithContext(T){return Je(this.getFactory(),T)}doPreventExtensions(T,S,k){let W;try{W=E(S)}catch(F){throw re(F)}for(let F=0;F<W.length;F++){let j=W[F],Q;try{Q=C(S,j)}catch(me){throw re(me)}if(Q){if(Q.configurable)Q.get||Q.set?Q={__proto__:null,configurable:!0,enumerable:Q.enumerable,writable:!0,value:null}:Q.value=null;else{let me=Or(T,j);if(me&&!me.configurable)continue;Q.get||Q.set?(Q.get=this.fromOtherWithContext(Q.get),Q.set=this.fromOtherWithContext(Q.set)):typeof S=="function"&&(j==="caller"||j==="callee"||j==="arguments")?Q.value=null:Q.value=this.fromOtherWithContext(Q.value)}if(!Ue(T,j,Q))throw ke()}}if(!Pn(T))throw ke()}get(T,S,k){let W=this.getObject();switch(S){case"constructor":{let j=C(W,S);if(j)return Et(this,W,S,j);let Q=Ge(T);return Q===null?void 0:Q.constructor}case"__proto__":{let j=C(W,S);return j?Et(this,W,S,j):Ge(T)}case Vr:if(!Qe(W,Vr)){let j=Ge(T),Q=ie(qt,u,[j]);if(Q)return Q}break;case"arguments":case"caller":case"callee":if(typeof W=="function"&&Qe(W,S))throw Vn(S);break}let F;try{F=y(W,S)}catch(j){throw re(j)}return this.fromOtherWithContext(F)}set(T,S,k,W){let F=this.getObject();if(S==="__proto__"&&!Qe(F,S))return this.setPrototypeOf(T,k);try{return k=R(k),O(F,S,k)===!0}catch(j){throw re(j)}}getPrototypeOf(T){return Ge(T)}setPrototypeOf(T,S){throw new le(Ua)}apply(T,S,k){let W=this.getObject(),F;try{S=R(S),k=I(k),F=g(W,S,k)}catch(j){throw re(j)}return Re(F)}construct(T,S,k){let W=this.getObject(),F;try{S=I(S),F=_(W,S)}catch(j){throw re(j)}return Je(this.getFactory(),F,Re(W))}getOwnPropertyDescriptorDesc(T,S,k){let W=this.getObject();return k&&typeof W=="function"&&(S==="arguments"||S==="caller"||S==="callee")&&(k.value=null),k}getOwnPropertyDescriptor(T,S){let k=this.getObject(),W;try{W=C(k,S)}catch(j){throw re(j)}if(W=this.getOwnPropertyDescriptorDesc(T,S,W),!W)return;let F;if(W.get||W.set?F={__proto__:null,get:this.fromOtherWithContext(W.get),set:this.fromOtherWithContext(W.set),enumerable:W.enumerable===!0,configurable:W.configurable===!0}:F={__proto__:null,value:this.fromOtherWithContext(W.value),writable:W.writable===!0,enumerable:W.enumerable===!0,configurable:W.configurable===!0},!F.configurable){let j=Or(T,S);if((!j||j.configurable||j.writable!==F.writable)&&!Ue(T,S,F))throw ke()}return F}definePropertyDesc(T,S,k){return k}defineProperty(T,S,k){let W=this.getObject();if(!Kt(k,null))throw ke();if(k=this.definePropertyDesc(T,S,k),!k)return!1;let F={__proto__:null},j=!0,Q=!0,me=!0;j&=de(F,k,"get"),j&=de(F,k,"set"),Q&=de(F,k,"value"),Q&=de(F,k,"writable"),me&=de(F,k,"enumerable"),me&=de(F,k,"configurable");try{if(!m(W,S,F))return!1;F.configurable!==!0&&(!me||!(j||Q))&&(F=C(W,S))}catch(Ne){throw re(Ne)}if(!F.configurable){let Ne;if(F.get||F.set?Ne={__proto__:null,get:this.fromOtherWithContext(F.get),set:this.fromOtherWithContext(F.set),enumerable:F.enumerable,configurable:F.configurable}:Ne={__proto__:null,value:this.fromOtherWithContext(F.value),writable:F.writable,enumerable:F.enumerable,configurable:F.configurable},!Ue(T,S,Ne))throw ke()}return!0}deleteProperty(T,S){let k=this.getObject();try{return d(k,S)===!0}catch(W){throw re(W)}}has(T,S){let k=this.getObject();try{return a(k,S)===!0}catch(W){throw re(W)}}isExtensible(T){let S=this.getObject();try{if(z(S))return!0}catch(k){throw re(k)}return Pr(T)&&this.doPreventExtensions(T,S,this),!1}ownKeys(T){let S=this.getObject(),k;try{k=E(S)}catch(W){throw re(W)}return Re(k)}preventExtensions(T){let S=this.getObject();try{if(!G(S))return!1}catch(k){throw re(k)}return Pr(T)&&this.doPreventExtensions(T,S,this),!0}enumerate(T){let S=this.getObject(),k;try{k=N(S)}catch(W){throw re(W)}return this.fromOtherWithContext(k)}}Ee.prototype[io]=void 0,Ee.prototype[Vr]="VM2 Wrapper",Ee.prototype[ro]=void 0;function Ae(L){return new Ee(L)}class Ce extends Ee{getFactory(){return ye}set(T,S,k,W){return typeof k=="function"?Ue(W,S,{__proto__:null,value:k,writable:!0,enumerable:!0,configurable:!0})===!0:super.set(T,S,k,W)}definePropertyDesc(T,S,k){if(!(k&&(k.set||k.get||typeof k.value=="function")))return k}}function ye(L){return new Ce(L)}class ft extends Ee{getFactory(){return Pe}set(T,S,k,W){return Ue(W,S,{__proto__:null,value:k,writable:!0,enumerable:!0,configurable:!0})}setPrototypeOf(T,S){return!1}defineProperty(T,S,k){return!1}deleteProperty(T,S){return!1}isExtensible(T){return!1}preventExtensions(T){return!1}}function Pe(L){return new ft(L)}class qe extends ft{constructor(T,S){super(T),this.mock=S}get(T,S,k){let W=this.getObject(),F=this.mock;return ie(Rr,F,S)&&!Qe(W,S)?F[S]:super.get(T,S,k)}}function Re(L){return Je(Ae,L)}function xe(L,T,S){let k=uo(T,S),W=L(T),F=new Ht(k,W);try{g(pe,V,[F,T]),r(F,W)}catch{throw new le("Unexpected error")}if(!b)return ie(jt,i,[T,F]),F;let j=new Ht(F,On);try{g(pe,V,[j,T]),r(j,W)}catch{throw new le("Unexpected error")}return ie(jt,i,[T,j]),j}function At(L){let T=typeof L;switch(T){case"object":if(L===null)return null;case"function":let S=Ge(L);if(!S)return L;for(;S;){let k=ie(qt,s,[S]);if(k){let W=ie(Nr,i,[L]);return W||k(Ae,L)}S=Ge(S)}return L;case"undefined":case"string":case"number":case"boolean":case"symbol":case"bigint":return L;default:throw new le(`Unknown type '${T}'`)}}function re(L){for(let T=0;T<10;T++){let S=typeof L;switch(S){case"object":if(L===null)return null;case"function":let k=ie(Nr,i,[L]);if(k)return k;let W;try{W=A(L)}catch(F){L=F;break}if(!W)return xe(Ae,L,null);for(;;){let F=ie(qt,s,[W]);if(F)return F(Ae,L);try{W=A(W)}catch(j){L=j;break}if(!W)return xe(Ae,L,Wr)}break;case"undefined":case"string":case"number":case"boolean":case"symbol":case"bigint":return L;default:throw new le(`Unknown type '${S}'`)}}throw new le("Exception recursion depth")}function Je(L,T,S){let k=typeof T;switch(k){case"object":if(T===null)return null;case"function":let W=ie(Nr,i,[T]);if(W)return W;if(S)return xe(L,T,S);try{S=A(T)}catch(F){throw re(F)}if(!S)return xe(L,T,null);do{let F=ie(qt,s,[S]);if(F)return F(L,T);try{S=A(S)}catch(j){throw re(j)}}while(S);return xe(L,T,Wr);case"undefined":case"string":case"number":case"boolean":case"symbol":case"bigint":return T;default:throw new le(`Unknown type '${k}'`)}}function $e(L){let T=[];for(let S=0;S<L.length;S++){let k=Re(L[S]);Ue(T,S,{__proto__:null,value:k,writable:!0,enumerable:!0,configurable:!0})}return T}function Be(L,T){try{g(pe,V,[L,T])}catch{throw new le("Unexpected error")}ie(jt,i,[T,L])}l(We.Object,x.Object),l(We.Array,x.Array);for(let L=0;L<$t.length;L++){let T=$t[L],S=We[T],k=x[T];S&&k&&l(S,k,T)}for(let L=0;L<Gt.length;L++){let T=Gt[L],S=We[T],k=x[T];S&&k&&l(S,k,"Error")}return l(We.VMError,x.VMError,"Error"),f.BaseHandler=Ee,f.ProtectedHandler=Ce,f.ReadOnlyHandler=ft,f.ReadOnlyMockHandler=qe,f}Qt.createBridge=co;Qt.VMError=le});var wt=he(Lr=>{"use strict";var{VMError:Fn}=He(),Fr;function lo(){if(!Fr)try{let c=ne("coffee-script");Fr=(r,i)=>c.compile(r,{header:!1,bare:!0})}catch{throw new Fn("Coffee-Script compiler is not installed.")}return Fr}function Ln(c){return c.startsWith("#!")?"//"+c.substring(2):c}function po(c,r){return Ln(c)}function ho(c){if(typeof c=="function")return c;switch(c){case"coffeescript":case"coffee-script":case"cs":case"text/coffeescript":return lo();case"javascript":case"java-script":case"js":case"text/javascript":return po;default:throw new Fn(`Unsupported compiler '${c}'.`)}}Lr.removeShebang=Ln;Lr.lookupCompiler=ho});var Dn=he((Jt,Mn)=>{"use strict";(function(c,r){typeof Jt=="object"&&typeof Mn<"u"?r(Jt):typeof define=="function"&&define.amd?define(["exports"],r):(c=typeof globalThis<"u"?globalThis:c||self,r(c.acorn={}))})(Jt,function(c){"use strict";var r=[509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,574,3,9,9,7,9,32,4,318,1,80,3,71,10,50,3,123,2,54,14,32,10,3,1,11,3,46,10,8,0,46,9,7,2,37,13,2,9,6,1,45,0,13,2,49,13,9,3,2,11,83,11,7,0,3,0,158,11,6,9,7,3,56,1,2,6,3,1,3,2,10,0,11,1,3,6,4,4,68,8,2,0,3,0,2,3,2,4,2,0,15,1,83,17,10,9,5,0,82,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,7,19,58,14,5,9,243,14,166,9,71,5,2,1,3,3,2,0,2,1,13,9,120,6,3,6,4,0,29,9,41,6,2,3,9,0,10,10,47,15,343,9,54,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,49,4,2,1,2,4,9,9,330,3,10,1,2,0,49,6,4,4,14,10,5350,0,7,14,11465,27,2343,9,87,9,39,4,60,6,26,9,535,9,470,0,2,54,8,3,82,0,12,1,19628,1,4178,9,519,45,3,22,543,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,101,0,161,6,10,9,357,0,62,13,499,13,245,1,2,9,726,6,110,6,6,9,4759,9,787719,239],i=[0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,14,29,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,13,10,2,14,2,6,2,1,2,10,2,14,2,6,2,1,4,51,13,310,10,21,11,7,25,5,2,41,2,8,70,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,71,55,7,1,65,0,16,3,2,2,2,28,43,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,14,35,39,27,10,22,251,41,7,1,17,2,60,28,11,0,9,21,43,17,47,20,28,22,13,52,58,1,3,0,14,44,33,24,27,35,30,0,3,0,9,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,20,1,64,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,31,9,2,0,3,0,2,37,2,0,26,0,2,0,45,52,19,3,21,2,31,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,14,0,72,26,38,6,186,43,117,63,32,7,3,0,3,7,2,1,2,23,16,0,2,0,95,7,3,38,17,0,2,0,29,0,11,39,8,0,22,0,12,45,20,0,19,72,200,32,32,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,26,5,2,1,2,31,15,0,328,18,16,0,2,12,2,33,125,0,80,921,103,110,18,195,2637,96,16,1071,18,5,26,3994,6,582,6842,29,1763,568,8,30,18,78,18,29,19,47,17,3,32,20,6,18,433,44,212,63,129,74,6,0,67,12,65,1,2,0,29,6135,9,1237,42,9,8936,3,2,6,2,1,2,290,16,0,30,2,3,0,15,3,9,395,2309,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,1845,30,7,5,262,61,147,44,11,6,17,0,322,29,19,43,485,27,229,29,3,0,496,6,2,3,2,1,2,14,2,196,60,67,8,0,1205,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42719,33,4153,7,221,3,5761,15,7472,16,621,2467,541,1507,4938,6,4191],s="\u200C\u200D\xB7\u0300-\u036F\u0387\u0483-\u0487\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u0669\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u06F0-\u06F9\u0711\u0730-\u074A\u07A6-\u07B0\u07C0-\u07C9\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u0897-\u089F\u08CA-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0966-\u096F\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09E6-\u09EF\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A66-\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AE6-\u0AEF\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B55-\u0B57\u0B62\u0B63\u0B66-\u0B6F\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0BE6-\u0BEF\u0C00-\u0C04\u0C3C\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C66-\u0C6F\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0CE6-\u0CEF\u0CF3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D66-\u0D6F\u0D81-\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0E50-\u0E59\u0EB1\u0EB4-\u0EBC\u0EC8-\u0ECE\u0ED0-\u0ED9\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1040-\u1049\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F-\u109D\u135D-\u135F\u1369-\u1371\u1712-\u1715\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u17E0-\u17E9\u180B-\u180D\u180F-\u1819\u18A9\u1920-\u192B\u1930-\u193B\u1946-\u194F\u19D0-\u19DA\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AB0-\u1ABD\u1ABF-\u1ACE\u1B00-\u1B04\u1B34-\u1B44\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BB0-\u1BB9\u1BE6-\u1BF3\u1C24-\u1C37\u1C40-\u1C49\u1C50-\u1C59\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DFF\u200C\u200D\u203F\u2040\u2054\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\u30FB\uA620-\uA629\uA66F\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA82C\uA880\uA881\uA8B4-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F1\uA8FF-\uA909\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9D0-\uA9D9\uA9E5\uA9F0-\uA9F9\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA50-\uAA59\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uABF0-\uABF9\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFF10-\uFF19\uFF3F\uFF65",u="\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C8A\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309B-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CD\uA7D0\uA7D1\uA7D3\uA7D5-\uA7DC\uA7F2-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC",l={3:"abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile",5:"class enum extends super const export import",6:"enum",strict:"implements interface let package private protected public static yield",strictBind:"eval arguments"},p="break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this",f={5:p,"5module":p+" export import",6:p+" const class extends export import super"},b=/^in(stanceof)?$/,x=new RegExp("["+u+"]"),C=new RegExp("["+u+s+"]");function I(e,t){for(var n=65536,o=0;o<t.length;o+=2){if(n+=t[o],n>e)return!1;if(n+=t[o+1],n>=e)return!0}return!1}function R(e,t){return e<65?e===36:e<91?!0:e<97?e===95:e<123?!0:e<=65535?e>=170&&x.test(String.fromCharCode(e)):t===!1?!1:I(e,i)}function V(e,t){return e<48?e===36:e<58?!0:e<65?!1:e<91?!0:e<97?e===95:e<123?!0:e<=65535?e>=170&&C.test(String.fromCharCode(e)):t===!1?!1:I(e,i)||I(e,r)}var O=function(t,n){n===void 0&&(n={}),this.label=t,this.keyword=n.keyword,this.beforeExpr=!!n.beforeExpr,this.startsExpr=!!n.startsExpr,this.isLoop=!!n.isLoop,this.isAssign=!!n.isAssign,this.prefix=!!n.prefix,this.postfix=!!n.postfix,this.binop=n.binop||null,this.updateContext=null};function y(e,t){return new O(e,{beforeExpr:!0,binop:t})}var m={beforeExpr:!0},d={startsExpr:!0},g={};function _(e,t){return t===void 0&&(t={}),t.keyword=e,g[e]=new O(e,t)}var a={num:new O("num",d),regexp:new O("regexp",d),string:new O("string",d),name:new O("name",d),privateId:new O("privateId",d),eof:new O("eof"),bracketL:new O("[",{beforeExpr:!0,startsExpr:!0}),bracketR:new O("]"),braceL:new O("{",{beforeExpr:!0,startsExpr:!0}),braceR:new O("}"),parenL:new O("(",{beforeExpr:!0,startsExpr:!0}),parenR:new O(")"),comma:new O(",",m),semi:new O(";",m),colon:new O(":",m),dot:new O("."),question:new O("?",m),questionDot:new O("?."),arrow:new O("=>",m),template:new O("template"),invalidTemplate:new O("invalidTemplate"),ellipsis:new O("...",m),backQuote:new O("`",d),dollarBraceL:new O("${",{beforeExpr:!0,startsExpr:!0}),eq:new O("=",{beforeExpr:!0,isAssign:!0}),assign:new O("_=",{beforeExpr:!0,isAssign:!0}),incDec:new O("++/--",{prefix:!0,postfix:!0,startsExpr:!0}),prefix:new O("!/~",{beforeExpr:!0,prefix:!0,startsExpr:!0}),logicalOR:y("||",1),logicalAND:y("&&",2),bitwiseOR:y("|",3),bitwiseXOR:y("^",4),bitwiseAND:y("&",5),equality:y("==/!=/===/!==",6),relational:y("</>/<=/>=",7),bitShift:y("<</>>/>>>",8),plusMin:new O("+/-",{beforeExpr:!0,binop:9,prefix:!0,startsExpr:!0}),modulo:y("%",10),star:y("*",10),slash:y("/",10),starstar:new O("**",{beforeExpr:!0}),coalesce:y("??",1),_break:_("break"),_case:_("case",m),_catch:_("catch"),_continue:_("continue"),_debugger:_("debugger"),_default:_("default",m),_do:_("do",{isLoop:!0,beforeExpr:!0}),_else:_("else",m),_finally:_("finally"),_for:_("for",{isLoop:!0}),_function:_("function",d),_if:_("if"),_return:_("return",m),_switch:_("switch"),_throw:_("throw",m),_try:_("try"),_var:_("var"),_const:_("const"),_while:_("while",{isLoop:!0}),_with:_("with"),_new:_("new",{beforeExpr:!0,startsExpr:!0}),_this:_("this",d),_super:_("super",d),_class:_("class",d),_extends:_("extends",m),_export:_("export"),_import:_("import",d),_null:_("null",d),_true:_("true",d),_false:_("false",d),_in:_("in",{beforeExpr:!0,binop:7}),_instanceof:_("instanceof",{beforeExpr:!0,binop:7}),_typeof:_("typeof",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_void:_("void",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_delete:_("delete",{beforeExpr:!0,prefix:!0,startsExpr:!0})},E=/\r\n?|\n|\u2028|\u2029/,N=new RegExp(E.source,"g");function A(e){return e===10||e===13||e===8232||e===8233}function z(e,t,n){n===void 0&&(n=e.length);for(var o=t;o<n;o++){var h=e.charCodeAt(o);if(A(h))return o<n-1&&h===13&&e.charCodeAt(o+1)===10?o+2:o+1}return-1}var G=/[\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff]/,K=/(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g,pe=Object.prototype,Qe=pe.hasOwnProperty,Et=pe.toString,de=Object.hasOwn||function(e,t){return Qe.call(e,t)},Ee=Array.isArray||function(e){return Et.call(e)==="[object Array]"},Ae=Object.create(null);function Ce(e){return Ae[e]||(Ae[e]=new RegExp("^(?:"+e.replace(/ /g,"|")+")$"))}function ye(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10)+55296,(e&1023)+56320))}var ft=/(?:[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/,Pe=function(t,n){this.line=t,this.column=n};Pe.prototype.offset=function(t){return new Pe(this.line,this.column+t)};var qe=function(t,n,o){this.start=n,this.end=o,t.sourceFile!==null&&(this.source=t.sourceFile)};function Re(e,t){for(var n=1,o=0;;){var h=z(e,o,t);if(h<0)return new Pe(n,t-o);++n,o=h}}var xe={ecmaVersion:null,sourceType:"script",onInsertedSemicolon:null,onTrailingComma:null,allowReserved:null,allowReturnOutsideFunction:!1,allowImportExportEverywhere:!1,allowAwaitOutsideFunction:null,allowSuperOutsideMethod:null,allowHashBang:!1,checkPrivateFields:!0,locations:!1,onToken:null,onComment:null,ranges:!1,program:null,sourceFile:null,directSourceFile:null,preserveParens:!1},At=!1;function re(e){var t={};for(var n in xe)t[n]=e&&de(e,n)?e[n]:xe[n];if(t.ecmaVersion==="latest"?t.ecmaVersion=1e8:t.ecmaVersion==null?(!At&&typeof console=="object"&&console.warn&&(At=!0,console.warn(`Since Acorn 8.0.0, options.ecmaVersion is required.
|
|
2
|
+
Defaulting to 2020, but this will stop working in the future.`)),t.ecmaVersion=11):t.ecmaVersion>=2015&&(t.ecmaVersion-=2009),t.allowReserved==null&&(t.allowReserved=t.ecmaVersion<5),(!e||e.allowHashBang==null)&&(t.allowHashBang=t.ecmaVersion>=14),Ee(t.onToken)){var o=t.onToken;t.onToken=function(h){return o.push(h)}}return Ee(t.onComment)&&(t.onComment=Je(t,t.onComment)),t}function Je(e,t){return function(n,o,h,v,w,P){var B={type:n?"Block":"Line",value:o,start:h,end:v};e.locations&&(B.loc=new qe(this,w,P)),e.ranges&&(B.range=[h,v]),t.push(B)}}var $e=1,Be=2,L=4,T=8,S=16,k=32,W=64,F=128,j=256,Q=512,me=$e|Be|j;function Ne(e,t){return Be|(e?L:0)|(t?T:0)}var It=0,ur=1,Ve=2,bi=3,wi=4,_i=5,te=function(t,n,o){this.options=t=re(t),this.sourceFile=t.sourceFile,this.keywords=Ce(f[t.ecmaVersion>=6?6:t.sourceType==="module"?"5module":5]);var h="";t.allowReserved!==!0&&(h=l[t.ecmaVersion>=6?6:t.ecmaVersion===5?5:3],t.sourceType==="module"&&(h+=" await")),this.reservedWords=Ce(h);var v=(h?h+" ":"")+l.strict;this.reservedWordsStrict=Ce(v),this.reservedWordsStrictBind=Ce(v+" "+l.strictBind),this.input=String(n),this.containsEsc=!1,o?(this.pos=o,this.lineStart=this.input.lastIndexOf(`
|
|
3
|
+
`,o-1)+1,this.curLine=this.input.slice(0,this.lineStart).split(E).length):(this.pos=this.lineStart=0,this.curLine=1),this.type=a.eof,this.value=null,this.start=this.end=this.pos,this.startLoc=this.endLoc=this.curPosition(),this.lastTokEndLoc=this.lastTokStartLoc=null,this.lastTokStart=this.lastTokEnd=this.pos,this.context=this.initialContext(),this.exprAllowed=!0,this.inModule=t.sourceType==="module",this.strict=this.inModule||this.strictDirective(this.pos),this.potentialArrowAt=-1,this.potentialArrowInForAwait=!1,this.yieldPos=this.awaitPos=this.awaitIdentPos=0,this.labels=[],this.undefinedExports=Object.create(null),this.pos===0&&t.allowHashBang&&this.input.slice(0,2)==="#!"&&this.skipLineComment(2),this.scopeStack=[],this.enterScope($e),this.regexpState=null,this.privateNameStack=[]},Ie={inFunction:{configurable:!0},inGenerator:{configurable:!0},inAsync:{configurable:!0},canAwait:{configurable:!0},allowSuper:{configurable:!0},allowDirectSuper:{configurable:!0},treatFunctionsAsVar:{configurable:!0},allowNewDotTarget:{configurable:!0},inClassStaticBlock:{configurable:!0}};te.prototype.parse=function(){var t=this.options.program||this.startNode();return this.nextToken(),this.parseTopLevel(t)},Ie.inFunction.get=function(){return(this.currentVarScope().flags&Be)>0},Ie.inGenerator.get=function(){return(this.currentVarScope().flags&T)>0},Ie.inAsync.get=function(){return(this.currentVarScope().flags&L)>0},Ie.canAwait.get=function(){for(var e=this.scopeStack.length-1;e>=0;e--){var t=this.scopeStack[e],n=t.flags;if(n&(j|Q))return!1;if(n&Be)return(n&L)>0}return this.inModule&&this.options.ecmaVersion>=13||this.options.allowAwaitOutsideFunction},Ie.allowSuper.get=function(){var e=this.currentThisScope(),t=e.flags;return(t&W)>0||this.options.allowSuperOutsideMethod},Ie.allowDirectSuper.get=function(){return(this.currentThisScope().flags&F)>0},Ie.treatFunctionsAsVar.get=function(){return this.treatFunctionsAsVarInScope(this.currentScope())},Ie.allowNewDotTarget.get=function(){for(var e=this.scopeStack.length-1;e>=0;e--){var t=this.scopeStack[e],n=t.flags;if(n&(j|Q)||n&Be&&!(n&S))return!0}return!1},Ie.inClassStaticBlock.get=function(){return(this.currentVarScope().flags&j)>0},te.extend=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];for(var o=this,h=0;h<t.length;h++)o=t[h](o);return o},te.parse=function(t,n){return new this(n,t).parse()},te.parseExpressionAt=function(t,n,o){var h=new this(o,t,n);return h.nextToken(),h.parseExpression()},te.tokenizer=function(t,n){return new this(n,t)},Object.defineProperties(te.prototype,Ie);var ce=te.prototype,_s=/^(?:'((?:\\[^]|[^'\\])*?)'|"((?:\\[^]|[^"\\])*?)")/;ce.strictDirective=function(e){if(this.options.ecmaVersion<5)return!1;for(;;){K.lastIndex=e,e+=K.exec(this.input)[0].length;var t=_s.exec(this.input.slice(e));if(!t)return!1;if((t[1]||t[2])==="use strict"){K.lastIndex=e+t[0].length;var n=K.exec(this.input),o=n.index+n[0].length,h=this.input.charAt(o);return h===";"||h==="}"||E.test(n[0])&&!(/[(`.[+\-/*%<>=,?^&]/.test(h)||h==="!"&&this.input.charAt(o+1)==="=")}e+=t[0].length,K.lastIndex=e,e+=K.exec(this.input)[0].length,this.input[e]===";"&&e++}},ce.eat=function(e){return this.type===e?(this.next(),!0):!1},ce.isContextual=function(e){return this.type===a.name&&this.value===e&&!this.containsEsc},ce.eatContextual=function(e){return this.isContextual(e)?(this.next(),!0):!1},ce.expectContextual=function(e){this.eatContextual(e)||this.unexpected()},ce.canInsertSemicolon=function(){return this.type===a.eof||this.type===a.braceR||E.test(this.input.slice(this.lastTokEnd,this.start))},ce.insertSemicolon=function(){if(this.canInsertSemicolon())return this.options.onInsertedSemicolon&&this.options.onInsertedSemicolon(this.lastTokEnd,this.lastTokEndLoc),!0},ce.semicolon=function(){!this.eat(a.semi)&&!this.insertSemicolon()&&this.unexpected()},ce.afterTrailingComma=function(e,t){if(this.type===e)return this.options.onTrailingComma&&this.options.onTrailingComma(this.lastTokStart,this.lastTokStartLoc),t||this.next(),!0},ce.expect=function(e){this.eat(e)||this.unexpected()},ce.unexpected=function(e){this.raise(e??this.start,"Unexpected token")};var Tt=function(){this.shorthandAssign=this.trailingComma=this.parenthesizedAssign=this.parenthesizedBind=this.doubleProto=-1};ce.checkPatternErrors=function(e,t){if(e){e.trailingComma>-1&&this.raiseRecoverable(e.trailingComma,"Comma is not permitted after the rest element");var n=t?e.parenthesizedAssign:e.parenthesizedBind;n>-1&&this.raiseRecoverable(n,t?"Assigning to rvalue":"Parenthesized pattern")}},ce.checkExpressionErrors=function(e,t){if(!e)return!1;var n=e.shorthandAssign,o=e.doubleProto;if(!t)return n>=0||o>=0;n>=0&&this.raise(n,"Shorthand property assignments are valid only in destructuring patterns"),o>=0&&this.raiseRecoverable(o,"Redefinition of __proto__ property")},ce.checkYieldAwaitInDefaultParams=function(){this.yieldPos&&(!this.awaitPos||this.yieldPos<this.awaitPos)&&this.raise(this.yieldPos,"Yield expression cannot be a default value"),this.awaitPos&&this.raise(this.awaitPos,"Await expression cannot be a default value")},ce.isSimpleAssignTarget=function(e){return e.type==="ParenthesizedExpression"?this.isSimpleAssignTarget(e.expression):e.type==="Identifier"||e.type==="MemberExpression"};var D=te.prototype;D.parseTopLevel=function(e){var t=Object.create(null);for(e.body||(e.body=[]);this.type!==a.eof;){var n=this.parseStatement(null,!0,t);e.body.push(n)}if(this.inModule)for(var o=0,h=Object.keys(this.undefinedExports);o<h.length;o+=1){var v=h[o];this.raiseRecoverable(this.undefinedExports[v].start,"Export '"+v+"' is not defined")}return this.adaptDirectivePrologue(e.body),this.next(),e.sourceType=this.options.sourceType,this.finishNode(e,"Program")};var cr={kind:"loop"},Cs={kind:"switch"};D.isLet=function(e){if(this.options.ecmaVersion<6||!this.isContextual("let"))return!1;K.lastIndex=this.pos;var t=K.exec(this.input),n=this.pos+t[0].length,o=this.input.charCodeAt(n);if(o===91||o===92)return!0;if(e)return!1;if(o===123||o>55295&&o<56320)return!0;if(R(o,!0)){for(var h=n+1;V(o=this.input.charCodeAt(h),!0);)++h;if(o===92||o>55295&&o<56320)return!0;var v=this.input.slice(n,h);if(!b.test(v))return!0}return!1},D.isAsyncFunction=function(){if(this.options.ecmaVersion<8||!this.isContextual("async"))return!1;K.lastIndex=this.pos;var e=K.exec(this.input),t=this.pos+e[0].length,n;return!E.test(this.input.slice(this.pos,t))&&this.input.slice(t,t+8)==="function"&&(t+8===this.input.length||!(V(n=this.input.charCodeAt(t+8))||n>55295&&n<56320))},D.isUsingKeyword=function(e,t){if(this.options.ecmaVersion<17||!this.isContextual(e?"await":"using"))return!1;K.lastIndex=this.pos;var n=K.exec(this.input),o=this.pos+n[0].length;if(E.test(this.input.slice(this.pos,o)))return!1;if(e){var h=o+5,v;if(this.input.slice(o,h)!=="using"||h===this.input.length||V(v=this.input.charCodeAt(h))||v>55295&&v<56320)return!1;K.lastIndex=h;var w=K.exec(this.input);if(w&&E.test(this.input.slice(h,h+w[0].length)))return!1}if(t){var P=o+2,B;if(this.input.slice(o,P)==="of"&&(P===this.input.length||!V(B=this.input.charCodeAt(P))&&!(B>55295&&B<56320)))return!1}var q=this.input.charCodeAt(o);return R(q,!0)||q===92},D.isAwaitUsing=function(e){return this.isUsingKeyword(!0,e)},D.isUsing=function(e){return this.isUsingKeyword(!1,e)},D.parseStatement=function(e,t,n){var o=this.type,h=this.startNode(),v;switch(this.isLet(e)&&(o=a._var,v="let"),o){case a._break:case a._continue:return this.parseBreakContinueStatement(h,o.keyword);case a._debugger:return this.parseDebuggerStatement(h);case a._do:return this.parseDoStatement(h);case a._for:return this.parseForStatement(h);case a._function:return e&&(this.strict||e!=="if"&&e!=="label")&&this.options.ecmaVersion>=6&&this.unexpected(),this.parseFunctionStatement(h,!1,!e);case a._class:return e&&this.unexpected(),this.parseClass(h,!0);case a._if:return this.parseIfStatement(h);case a._return:return this.parseReturnStatement(h);case a._switch:return this.parseSwitchStatement(h);case a._throw:return this.parseThrowStatement(h);case a._try:return this.parseTryStatement(h);case a._const:case a._var:return v=v||this.value,e&&v!=="var"&&this.unexpected(),this.parseVarStatement(h,v);case a._while:return this.parseWhileStatement(h);case a._with:return this.parseWithStatement(h);case a.braceL:return this.parseBlock(!0,h);case a.semi:return this.parseEmptyStatement(h);case a._export:case a._import:if(this.options.ecmaVersion>10&&o===a._import){K.lastIndex=this.pos;var w=K.exec(this.input),P=this.pos+w[0].length,B=this.input.charCodeAt(P);if(B===40||B===46)return this.parseExpressionStatement(h,this.parseExpression())}return this.options.allowImportExportEverywhere||(t||this.raise(this.start,"'import' and 'export' may only appear at the top level"),this.inModule||this.raise(this.start,"'import' and 'export' may appear only with 'sourceType: module'")),o===a._import?this.parseImport(h):this.parseExport(h,n);default:if(this.isAsyncFunction())return e&&this.unexpected(),this.next(),this.parseFunctionStatement(h,!0,!e);var q=this.isAwaitUsing(!1)?"await using":this.isUsing(!1)?"using":null;if(q)return t&&this.options.sourceType==="script"&&this.raise(this.start,"Using declaration cannot appear in the top level when source type is `script`"),q==="await using"&&(this.canAwait||this.raise(this.start,"Await using cannot appear outside of async function"),this.next()),this.next(),this.parseVar(h,!1,q),this.semicolon(),this.finishNode(h,"VariableDeclaration");var H=this.value,ee=this.parseExpression();return o===a.name&&ee.type==="Identifier"&&this.eat(a.colon)?this.parseLabeledStatement(h,H,ee,e):this.parseExpressionStatement(h,ee)}},D.parseBreakContinueStatement=function(e,t){var n=t==="break";this.next(),this.eat(a.semi)||this.insertSemicolon()?e.label=null:this.type!==a.name?this.unexpected():(e.label=this.parseIdent(),this.semicolon());for(var o=0;o<this.labels.length;++o){var h=this.labels[o];if((e.label==null||h.name===e.label.name)&&(h.kind!=null&&(n||h.kind==="loop")||e.label&&n))break}return o===this.labels.length&&this.raise(e.start,"Unsyntactic "+t),this.finishNode(e,n?"BreakStatement":"ContinueStatement")},D.parseDebuggerStatement=function(e){return this.next(),this.semicolon(),this.finishNode(e,"DebuggerStatement")},D.parseDoStatement=function(e){return this.next(),this.labels.push(cr),e.body=this.parseStatement("do"),this.labels.pop(),this.expect(a._while),e.test=this.parseParenExpression(),this.options.ecmaVersion>=6?this.eat(a.semi):this.semicolon(),this.finishNode(e,"DoWhileStatement")},D.parseForStatement=function(e){this.next();var t=this.options.ecmaVersion>=9&&this.canAwait&&this.eatContextual("await")?this.lastTokStart:-1;if(this.labels.push(cr),this.enterScope(0),this.expect(a.parenL),this.type===a.semi)return t>-1&&this.unexpected(t),this.parseFor(e,null);var n=this.isLet();if(this.type===a._var||this.type===a._const||n){var o=this.startNode(),h=n?"let":this.value;return this.next(),this.parseVar(o,!0,h),this.finishNode(o,"VariableDeclaration"),this.parseForAfterInit(e,o,t)}var v=this.isContextual("let"),w=!1,P=this.isUsing(!0)?"using":this.isAwaitUsing(!0)?"await using":null;if(P){var B=this.startNode();return this.next(),P==="await using"&&this.next(),this.parseVar(B,!0,P),this.finishNode(B,"VariableDeclaration"),this.parseForAfterInit(e,B,t)}var q=this.containsEsc,H=new Tt,ee=this.start,ue=t>-1?this.parseExprSubscripts(H,"await"):this.parseExpression(!0,H);return this.type===a._in||(w=this.options.ecmaVersion>=6&&this.isContextual("of"))?(t>-1?(this.type===a._in&&this.unexpected(t),e.await=!0):w&&this.options.ecmaVersion>=8&&(ue.start===ee&&!q&&ue.type==="Identifier"&&ue.name==="async"?this.unexpected():this.options.ecmaVersion>=9&&(e.await=!1)),v&&w&&this.raise(ue.start,"The left-hand side of a for-of loop may not start with 'let'."),this.toAssignable(ue,!1,H),this.checkLValPattern(ue),this.parseForIn(e,ue)):(this.checkExpressionErrors(H,!0),t>-1&&this.unexpected(t),this.parseFor(e,ue))},D.parseForAfterInit=function(e,t,n){return(this.type===a._in||this.options.ecmaVersion>=6&&this.isContextual("of"))&&t.declarations.length===1?(this.options.ecmaVersion>=9&&(this.type===a._in?n>-1&&this.unexpected(n):e.await=n>-1),this.parseForIn(e,t)):(n>-1&&this.unexpected(n),this.parseFor(e,t))},D.parseFunctionStatement=function(e,t,n){return this.next(),this.parseFunction(e,dt|(n?0:lr),!1,t)},D.parseIfStatement=function(e){return this.next(),e.test=this.parseParenExpression(),e.consequent=this.parseStatement("if"),e.alternate=this.eat(a._else)?this.parseStatement("if"):null,this.finishNode(e,"IfStatement")},D.parseReturnStatement=function(e){return!this.inFunction&&!this.options.allowReturnOutsideFunction&&this.raise(this.start,"'return' outside of function"),this.next(),this.eat(a.semi)||this.insertSemicolon()?e.argument=null:(e.argument=this.parseExpression(),this.semicolon()),this.finishNode(e,"ReturnStatement")},D.parseSwitchStatement=function(e){this.next(),e.discriminant=this.parseParenExpression(),e.cases=[],this.expect(a.braceL),this.labels.push(Cs),this.enterScope(0);for(var t,n=!1;this.type!==a.braceR;)if(this.type===a._case||this.type===a._default){var o=this.type===a._case;t&&this.finishNode(t,"SwitchCase"),e.cases.push(t=this.startNode()),t.consequent=[],this.next(),o?t.test=this.parseExpression():(n&&this.raiseRecoverable(this.lastTokStart,"Multiple default clauses"),n=!0,t.test=null),this.expect(a.colon)}else t||this.unexpected(),t.consequent.push(this.parseStatement(null));return this.exitScope(),t&&this.finishNode(t,"SwitchCase"),this.next(),this.labels.pop(),this.finishNode(e,"SwitchStatement")},D.parseThrowStatement=function(e){return this.next(),E.test(this.input.slice(this.lastTokEnd,this.start))&&this.raise(this.lastTokEnd,"Illegal newline after throw"),e.argument=this.parseExpression(),this.semicolon(),this.finishNode(e,"ThrowStatement")};var Ss=[];D.parseCatchClauseParam=function(){var e=this.parseBindingAtom(),t=e.type==="Identifier";return this.enterScope(t?k:0),this.checkLValPattern(e,t?wi:Ve),this.expect(a.parenR),e},D.parseTryStatement=function(e){if(this.next(),e.block=this.parseBlock(),e.handler=null,this.type===a._catch){var t=this.startNode();this.next(),this.eat(a.parenL)?t.param=this.parseCatchClauseParam():(this.options.ecmaVersion<10&&this.unexpected(),t.param=null,this.enterScope(0)),t.body=this.parseBlock(!1),this.exitScope(),e.handler=this.finishNode(t,"CatchClause")}return e.finalizer=this.eat(a._finally)?this.parseBlock():null,!e.handler&&!e.finalizer&&this.raise(e.start,"Missing catch or finally clause"),this.finishNode(e,"TryStatement")},D.parseVarStatement=function(e,t,n){return this.next(),this.parseVar(e,!1,t,n),this.semicolon(),this.finishNode(e,"VariableDeclaration")},D.parseWhileStatement=function(e){return this.next(),e.test=this.parseParenExpression(),this.labels.push(cr),e.body=this.parseStatement("while"),this.labels.pop(),this.finishNode(e,"WhileStatement")},D.parseWithStatement=function(e){return this.strict&&this.raise(this.start,"'with' in strict mode"),this.next(),e.object=this.parseParenExpression(),e.body=this.parseStatement("with"),this.finishNode(e,"WithStatement")},D.parseEmptyStatement=function(e){return this.next(),this.finishNode(e,"EmptyStatement")},D.parseLabeledStatement=function(e,t,n,o){for(var h=0,v=this.labels;h<v.length;h+=1){var w=v[h];w.name===t&&this.raise(n.start,"Label '"+t+"' is already declared")}for(var P=this.type.isLoop?"loop":this.type===a._switch?"switch":null,B=this.labels.length-1;B>=0;B--){var q=this.labels[B];if(q.statementStart===e.start)q.statementStart=this.start,q.kind=P;else break}return this.labels.push({name:t,kind:P,statementStart:this.start}),e.body=this.parseStatement(o?o.indexOf("label")===-1?o+"label":o:"label"),this.labels.pop(),e.label=n,this.finishNode(e,"LabeledStatement")},D.parseExpressionStatement=function(e,t){return e.expression=t,this.semicolon(),this.finishNode(e,"ExpressionStatement")},D.parseBlock=function(e,t,n){for(e===void 0&&(e=!0),t===void 0&&(t=this.startNode()),t.body=[],this.expect(a.braceL),e&&this.enterScope(0);this.type!==a.braceR;){var o=this.parseStatement(null);t.body.push(o)}return n&&(this.strict=!1),this.next(),e&&this.exitScope(),this.finishNode(t,"BlockStatement")},D.parseFor=function(e,t){return e.init=t,this.expect(a.semi),e.test=this.type===a.semi?null:this.parseExpression(),this.expect(a.semi),e.update=this.type===a.parenR?null:this.parseExpression(),this.expect(a.parenR),e.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(e,"ForStatement")},D.parseForIn=function(e,t){var n=this.type===a._in;return this.next(),t.type==="VariableDeclaration"&&t.declarations[0].init!=null&&(!n||this.options.ecmaVersion<8||this.strict||t.kind!=="var"||t.declarations[0].id.type!=="Identifier")&&this.raise(t.start,(n?"for-in":"for-of")+" loop variable declaration may not have an initializer"),e.left=t,e.right=n?this.parseExpression():this.parseMaybeAssign(),this.expect(a.parenR),e.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(e,n?"ForInStatement":"ForOfStatement")},D.parseVar=function(e,t,n,o){for(e.declarations=[],e.kind=n;;){var h=this.startNode();if(this.parseVarId(h,n),this.eat(a.eq)?h.init=this.parseMaybeAssign(t):!o&&n==="const"&&!(this.type===a._in||this.options.ecmaVersion>=6&&this.isContextual("of"))?this.unexpected():!o&&(n==="using"||n==="await using")&&this.options.ecmaVersion>=17&&this.type!==a._in&&!this.isContextual("of")?this.raise(this.lastTokEnd,"Missing initializer in "+n+" declaration"):!o&&h.id.type!=="Identifier"&&!(t&&(this.type===a._in||this.isContextual("of")))?this.raise(this.lastTokEnd,"Complex binding patterns require an initialization value"):h.init=null,e.declarations.push(this.finishNode(h,"VariableDeclarator")),!this.eat(a.comma))break}return e},D.parseVarId=function(e,t){e.id=t==="using"||t==="await using"?this.parseIdent():this.parseBindingAtom(),this.checkLValPattern(e.id,t==="var"?ur:Ve,!1)};var dt=1,lr=2,Ci=4;D.parseFunction=function(e,t,n,o,h){this.initFunction(e),(this.options.ecmaVersion>=9||this.options.ecmaVersion>=6&&!o)&&(this.type===a.star&&t&lr&&this.unexpected(),e.generator=this.eat(a.star)),this.options.ecmaVersion>=8&&(e.async=!!o),t&dt&&(e.id=t&Ci&&this.type!==a.name?null:this.parseIdent(),e.id&&!(t&lr)&&this.checkLValSimple(e.id,this.strict||e.generator||e.async?this.treatFunctionsAsVar?ur:Ve:bi));var v=this.yieldPos,w=this.awaitPos,P=this.awaitIdentPos;return this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(Ne(e.async,e.generator)),t&dt||(e.id=this.type===a.name?this.parseIdent():null),this.parseFunctionParams(e),this.parseFunctionBody(e,n,!1,h),this.yieldPos=v,this.awaitPos=w,this.awaitIdentPos=P,this.finishNode(e,t&dt?"FunctionDeclaration":"FunctionExpression")},D.parseFunctionParams=function(e){this.expect(a.parenL),e.params=this.parseBindingList(a.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams()},D.parseClass=function(e,t){this.next();var n=this.strict;this.strict=!0,this.parseClassId(e,t),this.parseClassSuper(e);var o=this.enterClassBody(),h=this.startNode(),v=!1;for(h.body=[],this.expect(a.braceL);this.type!==a.braceR;){var w=this.parseClassElement(e.superClass!==null);w&&(h.body.push(w),w.type==="MethodDefinition"&&w.kind==="constructor"?(v&&this.raiseRecoverable(w.start,"Duplicate constructor in the same class"),v=!0):w.key&&w.key.type==="PrivateIdentifier"&&Es(o,w)&&this.raiseRecoverable(w.key.start,"Identifier '#"+w.key.name+"' has already been declared"))}return this.strict=n,this.next(),e.body=this.finishNode(h,"ClassBody"),this.exitClassBody(),this.finishNode(e,t?"ClassDeclaration":"ClassExpression")},D.parseClassElement=function(e){if(this.eat(a.semi))return null;var t=this.options.ecmaVersion,n=this.startNode(),o="",h=!1,v=!1,w="method",P=!1;if(this.eatContextual("static")){if(t>=13&&this.eat(a.braceL))return this.parseClassStaticBlock(n),n;this.isClassElementNameStart()||this.type===a.star?P=!0:o="static"}if(n.static=P,!o&&t>=8&&this.eatContextual("async")&&((this.isClassElementNameStart()||this.type===a.star)&&!this.canInsertSemicolon()?v=!0:o="async"),!o&&(t>=9||!v)&&this.eat(a.star)&&(h=!0),!o&&!v&&!h){var B=this.value;(this.eatContextual("get")||this.eatContextual("set"))&&(this.isClassElementNameStart()?w=B:o=B)}if(o?(n.computed=!1,n.key=this.startNodeAt(this.lastTokStart,this.lastTokStartLoc),n.key.name=o,this.finishNode(n.key,"Identifier")):this.parseClassElementName(n),t<13||this.type===a.parenL||w!=="method"||h||v){var q=!n.static&&kt(n,"constructor"),H=q&&e;q&&w!=="method"&&this.raise(n.key.start,"Constructor can't have get/set modifier"),n.kind=q?"constructor":w,this.parseClassMethod(n,h,v,H)}else this.parseClassField(n);return n},D.isClassElementNameStart=function(){return this.type===a.name||this.type===a.privateId||this.type===a.num||this.type===a.string||this.type===a.bracketL||this.type.keyword},D.parseClassElementName=function(e){this.type===a.privateId?(this.value==="constructor"&&this.raise(this.start,"Classes can't have an element named '#constructor'"),e.computed=!1,e.key=this.parsePrivateIdent()):this.parsePropertyName(e)},D.parseClassMethod=function(e,t,n,o){var h=e.key;e.kind==="constructor"?(t&&this.raise(h.start,"Constructor can't be a generator"),n&&this.raise(h.start,"Constructor can't be an async method")):e.static&&kt(e,"prototype")&&this.raise(h.start,"Classes may not have a static property named prototype");var v=e.value=this.parseMethod(t,n,o);return e.kind==="get"&&v.params.length!==0&&this.raiseRecoverable(v.start,"getter should have no params"),e.kind==="set"&&v.params.length!==1&&this.raiseRecoverable(v.start,"setter should have exactly one param"),e.kind==="set"&&v.params[0].type==="RestElement"&&this.raiseRecoverable(v.params[0].start,"Setter cannot use rest params"),this.finishNode(e,"MethodDefinition")},D.parseClassField=function(e){return kt(e,"constructor")?this.raise(e.key.start,"Classes can't have a field named 'constructor'"):e.static&&kt(e,"prototype")&&this.raise(e.key.start,"Classes can't have a static field named 'prototype'"),this.eat(a.eq)?(this.enterScope(Q|W),e.value=this.parseMaybeAssign(),this.exitScope()):e.value=null,this.semicolon(),this.finishNode(e,"PropertyDefinition")},D.parseClassStaticBlock=function(e){e.body=[];var t=this.labels;for(this.labels=[],this.enterScope(j|W);this.type!==a.braceR;){var n=this.parseStatement(null);e.body.push(n)}return this.next(),this.exitScope(),this.labels=t,this.finishNode(e,"StaticBlock")},D.parseClassId=function(e,t){this.type===a.name?(e.id=this.parseIdent(),t&&this.checkLValSimple(e.id,Ve,!1)):(t===!0&&this.unexpected(),e.id=null)},D.parseClassSuper=function(e){e.superClass=this.eat(a._extends)?this.parseExprSubscripts(null,!1):null},D.enterClassBody=function(){var e={declared:Object.create(null),used:[]};return this.privateNameStack.push(e),e.declared},D.exitClassBody=function(){var e=this.privateNameStack.pop(),t=e.declared,n=e.used;if(this.options.checkPrivateFields)for(var o=this.privateNameStack.length,h=o===0?null:this.privateNameStack[o-1],v=0;v<n.length;++v){var w=n[v];de(t,w.name)||(h?h.used.push(w):this.raiseRecoverable(w.start,"Private field '#"+w.name+"' must be declared in an enclosing class"))}};function Es(e,t){var n=t.key.name,o=e[n],h="true";return t.type==="MethodDefinition"&&(t.kind==="get"||t.kind==="set")&&(h=(t.static?"s":"i")+t.kind),o==="iget"&&h==="iset"||o==="iset"&&h==="iget"||o==="sget"&&h==="sset"||o==="sset"&&h==="sget"?(e[n]="true",!1):o?!0:(e[n]=h,!1)}function kt(e,t){var n=e.computed,o=e.key;return!n&&(o.type==="Identifier"&&o.name===t||o.type==="Literal"&&o.value===t)}D.parseExportAllDeclaration=function(e,t){return this.options.ecmaVersion>=11&&(this.eatContextual("as")?(e.exported=this.parseModuleExportName(),this.checkExport(t,e.exported,this.lastTokStart)):e.exported=null),this.expectContextual("from"),this.type!==a.string&&this.unexpected(),e.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(e,"ExportAllDeclaration")},D.parseExport=function(e,t){if(this.next(),this.eat(a.star))return this.parseExportAllDeclaration(e,t);if(this.eat(a._default))return this.checkExport(t,"default",this.lastTokStart),e.declaration=this.parseExportDefaultDeclaration(),this.finishNode(e,"ExportDefaultDeclaration");if(this.shouldParseExportStatement())e.declaration=this.parseExportDeclaration(e),e.declaration.type==="VariableDeclaration"?this.checkVariableExport(t,e.declaration.declarations):this.checkExport(t,e.declaration.id,e.declaration.id.start),e.specifiers=[],e.source=null,this.options.ecmaVersion>=16&&(e.attributes=[]);else{if(e.declaration=null,e.specifiers=this.parseExportSpecifiers(t),this.eatContextual("from"))this.type!==a.string&&this.unexpected(),e.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause());else{for(var n=0,o=e.specifiers;n<o.length;n+=1){var h=o[n];this.checkUnreserved(h.local),this.checkLocalExport(h.local),h.local.type==="Literal"&&this.raise(h.local.start,"A string literal cannot be used as an exported binding without `from`.")}e.source=null,this.options.ecmaVersion>=16&&(e.attributes=[])}this.semicolon()}return this.finishNode(e,"ExportNamedDeclaration")},D.parseExportDeclaration=function(e){return this.parseStatement(null)},D.parseExportDefaultDeclaration=function(){var e;if(this.type===a._function||(e=this.isAsyncFunction())){var t=this.startNode();return this.next(),e&&this.next(),this.parseFunction(t,dt|Ci,!1,e)}else if(this.type===a._class){var n=this.startNode();return this.parseClass(n,"nullableID")}else{var o=this.parseMaybeAssign();return this.semicolon(),o}},D.checkExport=function(e,t,n){e&&(typeof t!="string"&&(t=t.type==="Identifier"?t.name:t.value),de(e,t)&&this.raiseRecoverable(n,"Duplicate export '"+t+"'"),e[t]=!0)},D.checkPatternExport=function(e,t){var n=t.type;if(n==="Identifier")this.checkExport(e,t,t.start);else if(n==="ObjectPattern")for(var o=0,h=t.properties;o<h.length;o+=1){var v=h[o];this.checkPatternExport(e,v)}else if(n==="ArrayPattern")for(var w=0,P=t.elements;w<P.length;w+=1){var B=P[w];B&&this.checkPatternExport(e,B)}else n==="Property"?this.checkPatternExport(e,t.value):n==="AssignmentPattern"?this.checkPatternExport(e,t.left):n==="RestElement"&&this.checkPatternExport(e,t.argument)},D.checkVariableExport=function(e,t){if(e)for(var n=0,o=t;n<o.length;n+=1){var h=o[n];this.checkPatternExport(e,h.id)}},D.shouldParseExportStatement=function(){return this.type.keyword==="var"||this.type.keyword==="const"||this.type.keyword==="class"||this.type.keyword==="function"||this.isLet()||this.isAsyncFunction()},D.parseExportSpecifier=function(e){var t=this.startNode();return t.local=this.parseModuleExportName(),t.exported=this.eatContextual("as")?this.parseModuleExportName():t.local,this.checkExport(e,t.exported,t.exported.start),this.finishNode(t,"ExportSpecifier")},D.parseExportSpecifiers=function(e){var t=[],n=!0;for(this.expect(a.braceL);!this.eat(a.braceR);){if(n)n=!1;else if(this.expect(a.comma),this.afterTrailingComma(a.braceR))break;t.push(this.parseExportSpecifier(e))}return t},D.parseImport=function(e){return this.next(),this.type===a.string?(e.specifiers=Ss,e.source=this.parseExprAtom()):(e.specifiers=this.parseImportSpecifiers(),this.expectContextual("from"),e.source=this.type===a.string?this.parseExprAtom():this.unexpected()),this.options.ecmaVersion>=16&&(e.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(e,"ImportDeclaration")},D.parseImportSpecifier=function(){var e=this.startNode();return e.imported=this.parseModuleExportName(),this.eatContextual("as")?e.local=this.parseIdent():(this.checkUnreserved(e.imported),e.local=e.imported),this.checkLValSimple(e.local,Ve),this.finishNode(e,"ImportSpecifier")},D.parseImportDefaultSpecifier=function(){var e=this.startNode();return e.local=this.parseIdent(),this.checkLValSimple(e.local,Ve),this.finishNode(e,"ImportDefaultSpecifier")},D.parseImportNamespaceSpecifier=function(){var e=this.startNode();return this.next(),this.expectContextual("as"),e.local=this.parseIdent(),this.checkLValSimple(e.local,Ve),this.finishNode(e,"ImportNamespaceSpecifier")},D.parseImportSpecifiers=function(){var e=[],t=!0;if(this.type===a.name&&(e.push(this.parseImportDefaultSpecifier()),!this.eat(a.comma)))return e;if(this.type===a.star)return e.push(this.parseImportNamespaceSpecifier()),e;for(this.expect(a.braceL);!this.eat(a.braceR);){if(t)t=!1;else if(this.expect(a.comma),this.afterTrailingComma(a.braceR))break;e.push(this.parseImportSpecifier())}return e},D.parseWithClause=function(){var e=[];if(!this.eat(a._with))return e;this.expect(a.braceL);for(var t={},n=!0;!this.eat(a.braceR);){if(n)n=!1;else if(this.expect(a.comma),this.afterTrailingComma(a.braceR))break;var o=this.parseImportAttribute(),h=o.key.type==="Identifier"?o.key.name:o.key.value;de(t,h)&&this.raiseRecoverable(o.key.start,"Duplicate attribute key '"+h+"'"),t[h]=!0,e.push(o)}return e},D.parseImportAttribute=function(){var e=this.startNode();return e.key=this.type===a.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!=="never"),this.expect(a.colon),this.type!==a.string&&this.unexpected(),e.value=this.parseExprAtom(),this.finishNode(e,"ImportAttribute")},D.parseModuleExportName=function(){if(this.options.ecmaVersion>=13&&this.type===a.string){var e=this.parseLiteral(this.value);return ft.test(e.value)&&this.raise(e.start,"An export name cannot include a lone surrogate."),e}return this.parseIdent(!0)},D.adaptDirectivePrologue=function(e){for(var t=0;t<e.length&&this.isDirectiveCandidate(e[t]);++t)e[t].directive=e[t].expression.raw.slice(1,-1)},D.isDirectiveCandidate=function(e){return this.options.ecmaVersion>=5&&e.type==="ExpressionStatement"&&e.expression.type==="Literal"&&typeof e.expression.value=="string"&&(this.input[e.start]==='"'||this.input[e.start]==="'")};var ve=te.prototype;ve.toAssignable=function(e,t,n){if(this.options.ecmaVersion>=6&&e)switch(e.type){case"Identifier":this.inAsync&&e.name==="await"&&this.raise(e.start,"Cannot use 'await' as identifier inside an async function");break;case"ObjectPattern":case"ArrayPattern":case"AssignmentPattern":case"RestElement":break;case"ObjectExpression":e.type="ObjectPattern",n&&this.checkPatternErrors(n,!0);for(var o=0,h=e.properties;o<h.length;o+=1){var v=h[o];this.toAssignable(v,t),v.type==="RestElement"&&(v.argument.type==="ArrayPattern"||v.argument.type==="ObjectPattern")&&this.raise(v.argument.start,"Unexpected token")}break;case"Property":e.kind!=="init"&&this.raise(e.key.start,"Object pattern can't contain getter or setter"),this.toAssignable(e.value,t);break;case"ArrayExpression":e.type="ArrayPattern",n&&this.checkPatternErrors(n,!0),this.toAssignableList(e.elements,t);break;case"SpreadElement":e.type="RestElement",this.toAssignable(e.argument,t),e.argument.type==="AssignmentPattern"&&this.raise(e.argument.start,"Rest elements cannot have a default value");break;case"AssignmentExpression":e.operator!=="="&&this.raise(e.left.end,"Only '=' operator can be used for specifying default value."),e.type="AssignmentPattern",delete e.operator,this.toAssignable(e.left,t);break;case"ParenthesizedExpression":this.toAssignable(e.expression,t,n);break;case"ChainExpression":this.raiseRecoverable(e.start,"Optional chaining cannot appear in left-hand side");break;case"MemberExpression":if(!t)break;default:this.raise(e.start,"Assigning to rvalue")}else n&&this.checkPatternErrors(n,!0);return e},ve.toAssignableList=function(e,t){for(var n=e.length,o=0;o<n;o++){var h=e[o];h&&this.toAssignable(h,t)}if(n){var v=e[n-1];this.options.ecmaVersion===6&&t&&v&&v.type==="RestElement"&&v.argument.type!=="Identifier"&&this.unexpected(v.argument.start)}return e},ve.parseSpread=function(e){var t=this.startNode();return this.next(),t.argument=this.parseMaybeAssign(!1,e),this.finishNode(t,"SpreadElement")},ve.parseRestBinding=function(){var e=this.startNode();return this.next(),this.options.ecmaVersion===6&&this.type!==a.name&&this.unexpected(),e.argument=this.parseBindingAtom(),this.finishNode(e,"RestElement")},ve.parseBindingAtom=function(){if(this.options.ecmaVersion>=6)switch(this.type){case a.bracketL:var e=this.startNode();return this.next(),e.elements=this.parseBindingList(a.bracketR,!0,!0),this.finishNode(e,"ArrayPattern");case a.braceL:return this.parseObj(!0)}return this.parseIdent()},ve.parseBindingList=function(e,t,n,o){for(var h=[],v=!0;!this.eat(e);)if(v?v=!1:this.expect(a.comma),t&&this.type===a.comma)h.push(null);else{if(n&&this.afterTrailingComma(e))break;if(this.type===a.ellipsis){var w=this.parseRestBinding();this.parseBindingListItem(w),h.push(w),this.type===a.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element"),this.expect(e);break}else h.push(this.parseAssignableListItem(o))}return h},ve.parseAssignableListItem=function(e){var t=this.parseMaybeDefault(this.start,this.startLoc);return this.parseBindingListItem(t),t},ve.parseBindingListItem=function(e){return e},ve.parseMaybeDefault=function(e,t,n){if(n=n||this.parseBindingAtom(),this.options.ecmaVersion<6||!this.eat(a.eq))return n;var o=this.startNodeAt(e,t);return o.left=n,o.right=this.parseMaybeAssign(),this.finishNode(o,"AssignmentPattern")},ve.checkLValSimple=function(e,t,n){t===void 0&&(t=It);var o=t!==It;switch(e.type){case"Identifier":this.strict&&this.reservedWordsStrictBind.test(e.name)&&this.raiseRecoverable(e.start,(o?"Binding ":"Assigning to ")+e.name+" in strict mode"),o&&(t===Ve&&e.name==="let"&&this.raiseRecoverable(e.start,"let is disallowed as a lexically bound name"),n&&(de(n,e.name)&&this.raiseRecoverable(e.start,"Argument name clash"),n[e.name]=!0),t!==_i&&this.declareName(e.name,t,e.start));break;case"ChainExpression":this.raiseRecoverable(e.start,"Optional chaining cannot appear in left-hand side");break;case"MemberExpression":o&&this.raiseRecoverable(e.start,"Binding member expression");break;case"ParenthesizedExpression":return o&&this.raiseRecoverable(e.start,"Binding parenthesized expression"),this.checkLValSimple(e.expression,t,n);default:this.raise(e.start,(o?"Binding":"Assigning to")+" rvalue")}},ve.checkLValPattern=function(e,t,n){switch(t===void 0&&(t=It),e.type){case"ObjectPattern":for(var o=0,h=e.properties;o<h.length;o+=1){var v=h[o];this.checkLValInnerPattern(v,t,n)}break;case"ArrayPattern":for(var w=0,P=e.elements;w<P.length;w+=1){var B=P[w];B&&this.checkLValInnerPattern(B,t,n)}break;default:this.checkLValSimple(e,t,n)}},ve.checkLValInnerPattern=function(e,t,n){switch(t===void 0&&(t=It),e.type){case"Property":this.checkLValInnerPattern(e.value,t,n);break;case"AssignmentPattern":this.checkLValPattern(e.left,t,n);break;case"RestElement":this.checkLValPattern(e.argument,t,n);break;default:this.checkLValPattern(e,t,n)}};var be=function(t,n,o,h,v){this.token=t,this.isExpr=!!n,this.preserveSpace=!!o,this.override=h,this.generator=!!v},Z={b_stat:new be("{",!1),b_expr:new be("{",!0),b_tmpl:new be("${",!1),p_stat:new be("(",!1),p_expr:new be("(",!0),q_tmpl:new be("`",!0,!0,function(e){return e.tryReadTemplateToken()}),f_stat:new be("function",!1),f_expr:new be("function",!0),f_expr_gen:new be("function",!0,!1,null,!0),f_gen:new be("function",!1,!1,null,!0)},Xe=te.prototype;Xe.initialContext=function(){return[Z.b_stat]},Xe.curContext=function(){return this.context[this.context.length-1]},Xe.braceIsBlock=function(e){var t=this.curContext();return t===Z.f_expr||t===Z.f_stat?!0:e===a.colon&&(t===Z.b_stat||t===Z.b_expr)?!t.isExpr:e===a._return||e===a.name&&this.exprAllowed?E.test(this.input.slice(this.lastTokEnd,this.start)):e===a._else||e===a.semi||e===a.eof||e===a.parenR||e===a.arrow?!0:e===a.braceL?t===Z.b_stat:e===a._var||e===a._const||e===a.name?!1:!this.exprAllowed},Xe.inGeneratorContext=function(){for(var e=this.context.length-1;e>=1;e--){var t=this.context[e];if(t.token==="function")return t.generator}return!1},Xe.updateContext=function(e){var t,n=this.type;n.keyword&&e===a.dot?this.exprAllowed=!1:(t=n.updateContext)?t.call(this,e):this.exprAllowed=n.beforeExpr},Xe.overrideContext=function(e){this.curContext()!==e&&(this.context[this.context.length-1]=e)},a.parenR.updateContext=a.braceR.updateContext=function(){if(this.context.length===1){this.exprAllowed=!0;return}var e=this.context.pop();e===Z.b_stat&&this.curContext().token==="function"&&(e=this.context.pop()),this.exprAllowed=!e.isExpr},a.braceL.updateContext=function(e){this.context.push(this.braceIsBlock(e)?Z.b_stat:Z.b_expr),this.exprAllowed=!0},a.dollarBraceL.updateContext=function(){this.context.push(Z.b_tmpl),this.exprAllowed=!0},a.parenL.updateContext=function(e){var t=e===a._if||e===a._for||e===a._with||e===a._while;this.context.push(t?Z.p_stat:Z.p_expr),this.exprAllowed=!0},a.incDec.updateContext=function(){},a._function.updateContext=a._class.updateContext=function(e){e.beforeExpr&&e!==a._else&&!(e===a.semi&&this.curContext()!==Z.p_stat)&&!(e===a._return&&E.test(this.input.slice(this.lastTokEnd,this.start)))&&!((e===a.colon||e===a.braceL)&&this.curContext()===Z.b_stat)?this.context.push(Z.f_expr):this.context.push(Z.f_stat),this.exprAllowed=!1},a.colon.updateContext=function(){this.curContext().token==="function"&&this.context.pop(),this.exprAllowed=!0},a.backQuote.updateContext=function(){this.curContext()===Z.q_tmpl?this.context.pop():this.context.push(Z.q_tmpl),this.exprAllowed=!1},a.star.updateContext=function(e){if(e===a._function){var t=this.context.length-1;this.context[t]===Z.f_expr?this.context[t]=Z.f_expr_gen:this.context[t]=Z.f_gen}this.exprAllowed=!0},a.name.updateContext=function(e){var t=!1;this.options.ecmaVersion>=6&&e!==a.dot&&(this.value==="of"&&!this.exprAllowed||this.value==="yield"&&this.inGeneratorContext())&&(t=!0),this.exprAllowed=t};var $=te.prototype;$.checkPropClash=function(e,t,n){if(!(this.options.ecmaVersion>=9&&e.type==="SpreadElement")&&!(this.options.ecmaVersion>=6&&(e.computed||e.method||e.shorthand))){var o=e.key,h;switch(o.type){case"Identifier":h=o.name;break;case"Literal":h=String(o.value);break;default:return}var v=e.kind;if(this.options.ecmaVersion>=6){h==="__proto__"&&v==="init"&&(t.proto&&(n?n.doubleProto<0&&(n.doubleProto=o.start):this.raiseRecoverable(o.start,"Redefinition of __proto__ property")),t.proto=!0);return}h="$"+h;var w=t[h];if(w){var P;v==="init"?P=this.strict&&w.init||w.get||w.set:P=w.init||w[v],P&&this.raiseRecoverable(o.start,"Redefinition of property")}else w=t[h]={init:!1,get:!1,set:!1};w[v]=!0}},$.parseExpression=function(e,t){var n=this.start,o=this.startLoc,h=this.parseMaybeAssign(e,t);if(this.type===a.comma){var v=this.startNodeAt(n,o);for(v.expressions=[h];this.eat(a.comma);)v.expressions.push(this.parseMaybeAssign(e,t));return this.finishNode(v,"SequenceExpression")}return h},$.parseMaybeAssign=function(e,t,n){if(this.isContextual("yield")){if(this.inGenerator)return this.parseYield(e);this.exprAllowed=!1}var o=!1,h=-1,v=-1,w=-1;t?(h=t.parenthesizedAssign,v=t.trailingComma,w=t.doubleProto,t.parenthesizedAssign=t.trailingComma=-1):(t=new Tt,o=!0);var P=this.start,B=this.startLoc;(this.type===a.parenL||this.type===a.name)&&(this.potentialArrowAt=this.start,this.potentialArrowInForAwait=e==="await");var q=this.parseMaybeConditional(e,t);if(n&&(q=n.call(this,q,P,B)),this.type.isAssign){var H=this.startNodeAt(P,B);return H.operator=this.value,this.type===a.eq&&(q=this.toAssignable(q,!1,t)),o||(t.parenthesizedAssign=t.trailingComma=t.doubleProto=-1),t.shorthandAssign>=q.start&&(t.shorthandAssign=-1),this.type===a.eq?this.checkLValPattern(q):this.checkLValSimple(q),H.left=q,this.next(),H.right=this.parseMaybeAssign(e),w>-1&&(t.doubleProto=w),this.finishNode(H,"AssignmentExpression")}else o&&this.checkExpressionErrors(t,!0);return h>-1&&(t.parenthesizedAssign=h),v>-1&&(t.trailingComma=v),q},$.parseMaybeConditional=function(e,t){var n=this.start,o=this.startLoc,h=this.parseExprOps(e,t);if(this.checkExpressionErrors(t))return h;if(this.eat(a.question)){var v=this.startNodeAt(n,o);return v.test=h,v.consequent=this.parseMaybeAssign(),this.expect(a.colon),v.alternate=this.parseMaybeAssign(e),this.finishNode(v,"ConditionalExpression")}return h},$.parseExprOps=function(e,t){var n=this.start,o=this.startLoc,h=this.parseMaybeUnary(t,!1,!1,e);return this.checkExpressionErrors(t)||h.start===n&&h.type==="ArrowFunctionExpression"?h:this.parseExprOp(h,n,o,-1,e)},$.parseExprOp=function(e,t,n,o,h){var v=this.type.binop;if(v!=null&&(!h||this.type!==a._in)&&v>o){var w=this.type===a.logicalOR||this.type===a.logicalAND,P=this.type===a.coalesce;P&&(v=a.logicalAND.binop);var B=this.value;this.next();var q=this.start,H=this.startLoc,ee=this.parseExprOp(this.parseMaybeUnary(null,!1,!1,h),q,H,v,h),ue=this.buildBinary(t,n,e,ee,B,w||P);return(w&&this.type===a.coalesce||P&&(this.type===a.logicalOR||this.type===a.logicalAND))&&this.raiseRecoverable(this.start,"Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses"),this.parseExprOp(ue,t,n,o,h)}return e},$.buildBinary=function(e,t,n,o,h,v){o.type==="PrivateIdentifier"&&this.raise(o.start,"Private identifier can only be left side of binary expression");var w=this.startNodeAt(e,t);return w.left=n,w.operator=h,w.right=o,this.finishNode(w,v?"LogicalExpression":"BinaryExpression")},$.parseMaybeUnary=function(e,t,n,o){var h=this.start,v=this.startLoc,w;if(this.isContextual("await")&&this.canAwait)w=this.parseAwait(o),t=!0;else if(this.type.prefix){var P=this.startNode(),B=this.type===a.incDec;P.operator=this.value,P.prefix=!0,this.next(),P.argument=this.parseMaybeUnary(null,!0,B,o),this.checkExpressionErrors(e,!0),B?this.checkLValSimple(P.argument):this.strict&&P.operator==="delete"&&Si(P.argument)?this.raiseRecoverable(P.start,"Deleting local variable in strict mode"):P.operator==="delete"&&pr(P.argument)?this.raiseRecoverable(P.start,"Private fields can not be deleted"):t=!0,w=this.finishNode(P,B?"UpdateExpression":"UnaryExpression")}else if(!t&&this.type===a.privateId)(o||this.privateNameStack.length===0)&&this.options.checkPrivateFields&&this.unexpected(),w=this.parsePrivateIdent(),this.type!==a._in&&this.unexpected();else{if(w=this.parseExprSubscripts(e,o),this.checkExpressionErrors(e))return w;for(;this.type.postfix&&!this.canInsertSemicolon();){var q=this.startNodeAt(h,v);q.operator=this.value,q.prefix=!1,q.argument=w,this.checkLValSimple(w),this.next(),w=this.finishNode(q,"UpdateExpression")}}if(!n&&this.eat(a.starstar))if(t)this.unexpected(this.lastTokStart);else return this.buildBinary(h,v,w,this.parseMaybeUnary(null,!1,!1,o),"**",!1);else return w};function Si(e){return e.type==="Identifier"||e.type==="ParenthesizedExpression"&&Si(e.expression)}function pr(e){return e.type==="MemberExpression"&&e.property.type==="PrivateIdentifier"||e.type==="ChainExpression"&&pr(e.expression)||e.type==="ParenthesizedExpression"&&pr(e.expression)}$.parseExprSubscripts=function(e,t){var n=this.start,o=this.startLoc,h=this.parseExprAtom(e,t);if(h.type==="ArrowFunctionExpression"&&this.input.slice(this.lastTokStart,this.lastTokEnd)!==")")return h;var v=this.parseSubscripts(h,n,o,!1,t);return e&&v.type==="MemberExpression"&&(e.parenthesizedAssign>=v.start&&(e.parenthesizedAssign=-1),e.parenthesizedBind>=v.start&&(e.parenthesizedBind=-1),e.trailingComma>=v.start&&(e.trailingComma=-1)),v},$.parseSubscripts=function(e,t,n,o,h){for(var v=this.options.ecmaVersion>=8&&e.type==="Identifier"&&e.name==="async"&&this.lastTokEnd===e.end&&!this.canInsertSemicolon()&&e.end-e.start===5&&this.potentialArrowAt===e.start,w=!1;;){var P=this.parseSubscript(e,t,n,o,v,w,h);if(P.optional&&(w=!0),P===e||P.type==="ArrowFunctionExpression"){if(w){var B=this.startNodeAt(t,n);B.expression=P,P=this.finishNode(B,"ChainExpression")}return P}e=P}},$.shouldParseAsyncArrow=function(){return!this.canInsertSemicolon()&&this.eat(a.arrow)},$.parseSubscriptAsyncArrow=function(e,t,n,o){return this.parseArrowExpression(this.startNodeAt(e,t),n,!0,o)},$.parseSubscript=function(e,t,n,o,h,v,w){var P=this.options.ecmaVersion>=11,B=P&&this.eat(a.questionDot);o&&B&&this.raise(this.lastTokStart,"Optional chaining cannot appear in the callee of new expressions");var q=this.eat(a.bracketL);if(q||B&&this.type!==a.parenL&&this.type!==a.backQuote||this.eat(a.dot)){var H=this.startNodeAt(t,n);H.object=e,q?(H.property=this.parseExpression(),this.expect(a.bracketR)):this.type===a.privateId&&e.type!=="Super"?H.property=this.parsePrivateIdent():H.property=this.parseIdent(this.options.allowReserved!=="never"),H.computed=!!q,P&&(H.optional=B),e=this.finishNode(H,"MemberExpression")}else if(!o&&this.eat(a.parenL)){var ee=new Tt,ue=this.yieldPos,yt=this.awaitPos,Ye=this.awaitIdentPos;this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0;var Ot=this.parseExprList(a.parenR,this.options.ecmaVersion>=8,!1,ee);if(h&&!B&&this.shouldParseAsyncArrow())return this.checkPatternErrors(ee,!1),this.checkYieldAwaitInDefaultParams(),this.awaitIdentPos>0&&this.raise(this.awaitIdentPos,"Cannot use 'await' as identifier inside an async function"),this.yieldPos=ue,this.awaitPos=yt,this.awaitIdentPos=Ye,this.parseSubscriptAsyncArrow(t,n,Ot,w);this.checkExpressionErrors(ee,!0),this.yieldPos=ue||this.yieldPos,this.awaitPos=yt||this.awaitPos,this.awaitIdentPos=Ye||this.awaitIdentPos;var Ze=this.startNodeAt(t,n);Ze.callee=e,Ze.arguments=Ot,P&&(Ze.optional=B),e=this.finishNode(Ze,"CallExpression")}else if(this.type===a.backQuote){(B||v)&&this.raise(this.start,"Optional chaining cannot appear in the tag of tagged template expressions");var et=this.startNodeAt(t,n);et.tag=e,et.quasi=this.parseTemplate({isTagged:!0}),e=this.finishNode(et,"TaggedTemplateExpression")}return e},$.parseExprAtom=function(e,t,n){this.type===a.slash&&this.readRegexp();var o,h=this.potentialArrowAt===this.start;switch(this.type){case a._super:return this.allowSuper||this.raise(this.start,"'super' keyword outside a method"),o=this.startNode(),this.next(),this.type===a.parenL&&!this.allowDirectSuper&&this.raise(o.start,"super() call outside constructor of a subclass"),this.type!==a.dot&&this.type!==a.bracketL&&this.type!==a.parenL&&this.unexpected(),this.finishNode(o,"Super");case a._this:return o=this.startNode(),this.next(),this.finishNode(o,"ThisExpression");case a.name:var v=this.start,w=this.startLoc,P=this.containsEsc,B=this.parseIdent(!1);if(this.options.ecmaVersion>=8&&!P&&B.name==="async"&&!this.canInsertSemicolon()&&this.eat(a._function))return this.overrideContext(Z.f_expr),this.parseFunction(this.startNodeAt(v,w),0,!1,!0,t);if(h&&!this.canInsertSemicolon()){if(this.eat(a.arrow))return this.parseArrowExpression(this.startNodeAt(v,w),[B],!1,t);if(this.options.ecmaVersion>=8&&B.name==="async"&&this.type===a.name&&!P&&(!this.potentialArrowInForAwait||this.value!=="of"||this.containsEsc))return B=this.parseIdent(!1),(this.canInsertSemicolon()||!this.eat(a.arrow))&&this.unexpected(),this.parseArrowExpression(this.startNodeAt(v,w),[B],!0,t)}return B;case a.regexp:var q=this.value;return o=this.parseLiteral(q.value),o.regex={pattern:q.pattern,flags:q.flags},o;case a.num:case a.string:return this.parseLiteral(this.value);case a._null:case a._true:case a._false:return o=this.startNode(),o.value=this.type===a._null?null:this.type===a._true,o.raw=this.type.keyword,this.next(),this.finishNode(o,"Literal");case a.parenL:var H=this.start,ee=this.parseParenAndDistinguishExpression(h,t);return e&&(e.parenthesizedAssign<0&&!this.isSimpleAssignTarget(ee)&&(e.parenthesizedAssign=H),e.parenthesizedBind<0&&(e.parenthesizedBind=H)),ee;case a.bracketL:return o=this.startNode(),this.next(),o.elements=this.parseExprList(a.bracketR,!0,!0,e),this.finishNode(o,"ArrayExpression");case a.braceL:return this.overrideContext(Z.b_expr),this.parseObj(!1,e);case a._function:return o=this.startNode(),this.next(),this.parseFunction(o,0);case a._class:return this.parseClass(this.startNode(),!1);case a._new:return this.parseNew();case a.backQuote:return this.parseTemplate();case a._import:return this.options.ecmaVersion>=11?this.parseExprImport(n):this.unexpected();default:return this.parseExprAtomDefault()}},$.parseExprAtomDefault=function(){this.unexpected()},$.parseExprImport=function(e){var t=this.startNode();if(this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword import"),this.next(),this.type===a.parenL&&!e)return this.parseDynamicImport(t);if(this.type===a.dot){var n=this.startNodeAt(t.start,t.loc&&t.loc.start);return n.name="import",t.meta=this.finishNode(n,"Identifier"),this.parseImportMeta(t)}else this.unexpected()},$.parseDynamicImport=function(e){if(this.next(),e.source=this.parseMaybeAssign(),this.options.ecmaVersion>=16)this.eat(a.parenR)?e.options=null:(this.expect(a.comma),this.afterTrailingComma(a.parenR)?e.options=null:(e.options=this.parseMaybeAssign(),this.eat(a.parenR)||(this.expect(a.comma),this.afterTrailingComma(a.parenR)||this.unexpected())));else if(!this.eat(a.parenR)){var t=this.start;this.eat(a.comma)&&this.eat(a.parenR)?this.raiseRecoverable(t,"Trailing comma is not allowed in import()"):this.unexpected(t)}return this.finishNode(e,"ImportExpression")},$.parseImportMeta=function(e){this.next();var t=this.containsEsc;return e.property=this.parseIdent(!0),e.property.name!=="meta"&&this.raiseRecoverable(e.property.start,"The only valid meta property for import is 'import.meta'"),t&&this.raiseRecoverable(e.start,"'import.meta' must not contain escaped characters"),this.options.sourceType!=="module"&&!this.options.allowImportExportEverywhere&&this.raiseRecoverable(e.start,"Cannot use 'import.meta' outside a module"),this.finishNode(e,"MetaProperty")},$.parseLiteral=function(e){var t=this.startNode();return t.value=e,t.raw=this.input.slice(this.start,this.end),t.raw.charCodeAt(t.raw.length-1)===110&&(t.bigint=t.value!=null?t.value.toString():t.raw.slice(0,-1).replace(/_/g,"")),this.next(),this.finishNode(t,"Literal")},$.parseParenExpression=function(){this.expect(a.parenL);var e=this.parseExpression();return this.expect(a.parenR),e},$.shouldParseArrow=function(e){return!this.canInsertSemicolon()},$.parseParenAndDistinguishExpression=function(e,t){var n=this.start,o=this.startLoc,h,v=this.options.ecmaVersion>=8;if(this.options.ecmaVersion>=6){this.next();var w=this.start,P=this.startLoc,B=[],q=!0,H=!1,ee=new Tt,ue=this.yieldPos,yt=this.awaitPos,Ye;for(this.yieldPos=0,this.awaitPos=0;this.type!==a.parenR;)if(q?q=!1:this.expect(a.comma),v&&this.afterTrailingComma(a.parenR,!0)){H=!0;break}else if(this.type===a.ellipsis){Ye=this.start,B.push(this.parseParenItem(this.parseRestBinding())),this.type===a.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element");break}else B.push(this.parseMaybeAssign(!1,ee,this.parseParenItem));var Ot=this.lastTokEnd,Ze=this.lastTokEndLoc;if(this.expect(a.parenR),e&&this.shouldParseArrow(B)&&this.eat(a.arrow))return this.checkPatternErrors(ee,!1),this.checkYieldAwaitInDefaultParams(),this.yieldPos=ue,this.awaitPos=yt,this.parseParenArrowList(n,o,B,t);(!B.length||H)&&this.unexpected(this.lastTokStart),Ye&&this.unexpected(Ye),this.checkExpressionErrors(ee,!0),this.yieldPos=ue||this.yieldPos,this.awaitPos=yt||this.awaitPos,B.length>1?(h=this.startNodeAt(w,P),h.expressions=B,this.finishNodeAt(h,"SequenceExpression",Ot,Ze)):h=B[0]}else h=this.parseParenExpression();if(this.options.preserveParens){var et=this.startNodeAt(n,o);return et.expression=h,this.finishNode(et,"ParenthesizedExpression")}else return h},$.parseParenItem=function(e){return e},$.parseParenArrowList=function(e,t,n,o){return this.parseArrowExpression(this.startNodeAt(e,t),n,!1,o)};var As=[];$.parseNew=function(){this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword new");var e=this.startNode();if(this.next(),this.options.ecmaVersion>=6&&this.type===a.dot){var t=this.startNodeAt(e.start,e.loc&&e.loc.start);t.name="new",e.meta=this.finishNode(t,"Identifier"),this.next();var n=this.containsEsc;return e.property=this.parseIdent(!0),e.property.name!=="target"&&this.raiseRecoverable(e.property.start,"The only valid meta property for new is 'new.target'"),n&&this.raiseRecoverable(e.start,"'new.target' must not contain escaped characters"),this.allowNewDotTarget||this.raiseRecoverable(e.start,"'new.target' can only be used in functions and class static block"),this.finishNode(e,"MetaProperty")}var o=this.start,h=this.startLoc;return e.callee=this.parseSubscripts(this.parseExprAtom(null,!1,!0),o,h,!0,!1),this.eat(a.parenL)?e.arguments=this.parseExprList(a.parenR,this.options.ecmaVersion>=8,!1):e.arguments=As,this.finishNode(e,"NewExpression")},$.parseTemplateElement=function(e){var t=e.isTagged,n=this.startNode();return this.type===a.invalidTemplate?(t||this.raiseRecoverable(this.start,"Bad escape sequence in untagged template literal"),n.value={raw:this.value.replace(/\r\n?/g,`
|
|
4
|
+
`),cooked:null}):n.value={raw:this.input.slice(this.start,this.end).replace(/\r\n?/g,`
|
|
5
|
+
`),cooked:this.value},this.next(),n.tail=this.type===a.backQuote,this.finishNode(n,"TemplateElement")},$.parseTemplate=function(e){e===void 0&&(e={});var t=e.isTagged;t===void 0&&(t=!1);var n=this.startNode();this.next(),n.expressions=[];var o=this.parseTemplateElement({isTagged:t});for(n.quasis=[o];!o.tail;)this.type===a.eof&&this.raise(this.pos,"Unterminated template literal"),this.expect(a.dollarBraceL),n.expressions.push(this.parseExpression()),this.expect(a.braceR),n.quasis.push(o=this.parseTemplateElement({isTagged:t}));return this.next(),this.finishNode(n,"TemplateLiteral")},$.isAsyncProp=function(e){return!e.computed&&e.key.type==="Identifier"&&e.key.name==="async"&&(this.type===a.name||this.type===a.num||this.type===a.string||this.type===a.bracketL||this.type.keyword||this.options.ecmaVersion>=9&&this.type===a.star)&&!E.test(this.input.slice(this.lastTokEnd,this.start))},$.parseObj=function(e,t){var n=this.startNode(),o=!0,h={};for(n.properties=[],this.next();!this.eat(a.braceR);){if(o)o=!1;else if(this.expect(a.comma),this.options.ecmaVersion>=5&&this.afterTrailingComma(a.braceR))break;var v=this.parseProperty(e,t);e||this.checkPropClash(v,h,t),n.properties.push(v)}return this.finishNode(n,e?"ObjectPattern":"ObjectExpression")},$.parseProperty=function(e,t){var n=this.startNode(),o,h,v,w;if(this.options.ecmaVersion>=9&&this.eat(a.ellipsis))return e?(n.argument=this.parseIdent(!1),this.type===a.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element"),this.finishNode(n,"RestElement")):(n.argument=this.parseMaybeAssign(!1,t),this.type===a.comma&&t&&t.trailingComma<0&&(t.trailingComma=this.start),this.finishNode(n,"SpreadElement"));this.options.ecmaVersion>=6&&(n.method=!1,n.shorthand=!1,(e||t)&&(v=this.start,w=this.startLoc),e||(o=this.eat(a.star)));var P=this.containsEsc;return this.parsePropertyName(n),!e&&!P&&this.options.ecmaVersion>=8&&!o&&this.isAsyncProp(n)?(h=!0,o=this.options.ecmaVersion>=9&&this.eat(a.star),this.parsePropertyName(n)):h=!1,this.parsePropertyValue(n,e,o,h,v,w,t,P),this.finishNode(n,"Property")},$.parseGetterSetter=function(e){var t=e.key.name;this.parsePropertyName(e),e.value=this.parseMethod(!1),e.kind=t;var n=e.kind==="get"?0:1;if(e.value.params.length!==n){var o=e.value.start;e.kind==="get"?this.raiseRecoverable(o,"getter should have no params"):this.raiseRecoverable(o,"setter should have exactly one param")}else e.kind==="set"&&e.value.params[0].type==="RestElement"&&this.raiseRecoverable(e.value.params[0].start,"Setter cannot use rest params")},$.parsePropertyValue=function(e,t,n,o,h,v,w,P){(n||o)&&this.type===a.colon&&this.unexpected(),this.eat(a.colon)?(e.value=t?this.parseMaybeDefault(this.start,this.startLoc):this.parseMaybeAssign(!1,w),e.kind="init"):this.options.ecmaVersion>=6&&this.type===a.parenL?(t&&this.unexpected(),e.method=!0,e.value=this.parseMethod(n,o),e.kind="init"):!t&&!P&&this.options.ecmaVersion>=5&&!e.computed&&e.key.type==="Identifier"&&(e.key.name==="get"||e.key.name==="set")&&this.type!==a.comma&&this.type!==a.braceR&&this.type!==a.eq?((n||o)&&this.unexpected(),this.parseGetterSetter(e)):this.options.ecmaVersion>=6&&!e.computed&&e.key.type==="Identifier"?((n||o)&&this.unexpected(),this.checkUnreserved(e.key),e.key.name==="await"&&!this.awaitIdentPos&&(this.awaitIdentPos=h),t?e.value=this.parseMaybeDefault(h,v,this.copyNode(e.key)):this.type===a.eq&&w?(w.shorthandAssign<0&&(w.shorthandAssign=this.start),e.value=this.parseMaybeDefault(h,v,this.copyNode(e.key))):e.value=this.copyNode(e.key),e.kind="init",e.shorthand=!0):this.unexpected()},$.parsePropertyName=function(e){if(this.options.ecmaVersion>=6){if(this.eat(a.bracketL))return e.computed=!0,e.key=this.parseMaybeAssign(),this.expect(a.bracketR),e.key;e.computed=!1}return e.key=this.type===a.num||this.type===a.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!=="never")},$.initFunction=function(e){e.id=null,this.options.ecmaVersion>=6&&(e.generator=e.expression=!1),this.options.ecmaVersion>=8&&(e.async=!1)},$.parseMethod=function(e,t,n){var o=this.startNode(),h=this.yieldPos,v=this.awaitPos,w=this.awaitIdentPos;return this.initFunction(o),this.options.ecmaVersion>=6&&(o.generator=e),this.options.ecmaVersion>=8&&(o.async=!!t),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(Ne(t,o.generator)|W|(n?F:0)),this.expect(a.parenL),o.params=this.parseBindingList(a.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams(),this.parseFunctionBody(o,!1,!0,!1),this.yieldPos=h,this.awaitPos=v,this.awaitIdentPos=w,this.finishNode(o,"FunctionExpression")},$.parseArrowExpression=function(e,t,n,o){var h=this.yieldPos,v=this.awaitPos,w=this.awaitIdentPos;return this.enterScope(Ne(n,!1)|S),this.initFunction(e),this.options.ecmaVersion>=8&&(e.async=!!n),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,e.params=this.toAssignableList(t,!0),this.parseFunctionBody(e,!0,!1,o),this.yieldPos=h,this.awaitPos=v,this.awaitIdentPos=w,this.finishNode(e,"ArrowFunctionExpression")},$.parseFunctionBody=function(e,t,n,o){var h=t&&this.type!==a.braceL,v=this.strict,w=!1;if(h)e.body=this.parseMaybeAssign(o),e.expression=!0,this.checkParams(e,!1);else{var P=this.options.ecmaVersion>=7&&!this.isSimpleParamList(e.params);(!v||P)&&(w=this.strictDirective(this.end),w&&P&&this.raiseRecoverable(e.start,"Illegal 'use strict' directive in function with non-simple parameter list"));var B=this.labels;this.labels=[],w&&(this.strict=!0),this.checkParams(e,!v&&!w&&!t&&!n&&this.isSimpleParamList(e.params)),this.strict&&e.id&&this.checkLValSimple(e.id,_i),e.body=this.parseBlock(!1,void 0,w&&!v),e.expression=!1,this.adaptDirectivePrologue(e.body.body),this.labels=B}this.exitScope()},$.isSimpleParamList=function(e){for(var t=0,n=e;t<n.length;t+=1){var o=n[t];if(o.type!=="Identifier")return!1}return!0},$.checkParams=function(e,t){for(var n=Object.create(null),o=0,h=e.params;o<h.length;o+=1){var v=h[o];this.checkLValInnerPattern(v,ur,t?null:n)}},$.parseExprList=function(e,t,n,o){for(var h=[],v=!0;!this.eat(e);){if(v)v=!1;else if(this.expect(a.comma),t&&this.afterTrailingComma(e))break;var w=void 0;n&&this.type===a.comma?w=null:this.type===a.ellipsis?(w=this.parseSpread(o),o&&this.type===a.comma&&o.trailingComma<0&&(o.trailingComma=this.start)):w=this.parseMaybeAssign(!1,o),h.push(w)}return h},$.checkUnreserved=function(e){var t=e.start,n=e.end,o=e.name;if(this.inGenerator&&o==="yield"&&this.raiseRecoverable(t,"Cannot use 'yield' as identifier inside a generator"),this.inAsync&&o==="await"&&this.raiseRecoverable(t,"Cannot use 'await' as identifier inside an async function"),!(this.currentThisScope().flags&me)&&o==="arguments"&&this.raiseRecoverable(t,"Cannot use 'arguments' in class field initializer"),this.inClassStaticBlock&&(o==="arguments"||o==="await")&&this.raise(t,"Cannot use "+o+" in class static initialization block"),this.keywords.test(o)&&this.raise(t,"Unexpected keyword '"+o+"'"),!(this.options.ecmaVersion<6&&this.input.slice(t,n).indexOf("\\")!==-1)){var h=this.strict?this.reservedWordsStrict:this.reservedWords;h.test(o)&&(!this.inAsync&&o==="await"&&this.raiseRecoverable(t,"Cannot use keyword 'await' outside an async function"),this.raiseRecoverable(t,"The keyword '"+o+"' is reserved"))}},$.parseIdent=function(e){var t=this.parseIdentNode();return this.next(!!e),this.finishNode(t,"Identifier"),e||(this.checkUnreserved(t),t.name==="await"&&!this.awaitIdentPos&&(this.awaitIdentPos=t.start)),t},$.parseIdentNode=function(){var e=this.startNode();return this.type===a.name?e.name=this.value:this.type.keyword?(e.name=this.type.keyword,(e.name==="class"||e.name==="function")&&(this.lastTokEnd!==this.lastTokStart+1||this.input.charCodeAt(this.lastTokStart)!==46)&&this.context.pop(),this.type=a.name):this.unexpected(),e},$.parsePrivateIdent=function(){var e=this.startNode();return this.type===a.privateId?e.name=this.value:this.unexpected(),this.next(),this.finishNode(e,"PrivateIdentifier"),this.options.checkPrivateFields&&(this.privateNameStack.length===0?this.raise(e.start,"Private field '#"+e.name+"' must be declared in an enclosing class"):this.privateNameStack[this.privateNameStack.length-1].used.push(e)),e},$.parseYield=function(e){this.yieldPos||(this.yieldPos=this.start);var t=this.startNode();return this.next(),this.type===a.semi||this.canInsertSemicolon()||this.type!==a.star&&!this.type.startsExpr?(t.delegate=!1,t.argument=null):(t.delegate=this.eat(a.star),t.argument=this.parseMaybeAssign(e)),this.finishNode(t,"YieldExpression")},$.parseAwait=function(e){this.awaitPos||(this.awaitPos=this.start);var t=this.startNode();return this.next(),t.argument=this.parseMaybeUnary(null,!0,!1,e),this.finishNode(t,"AwaitExpression")};var Pt=te.prototype;Pt.raise=function(e,t){var n=Re(this.input,e);t+=" ("+n.line+":"+n.column+")",this.sourceFile&&(t+=" in "+this.sourceFile);var o=new SyntaxError(t);throw o.pos=e,o.loc=n,o.raisedAt=this.pos,o},Pt.raiseRecoverable=Pt.raise,Pt.curPosition=function(){if(this.options.locations)return new Pe(this.curLine,this.pos-this.lineStart)};var Fe=te.prototype,Is=function(t){this.flags=t,this.var=[],this.lexical=[],this.functions=[]};Fe.enterScope=function(e){this.scopeStack.push(new Is(e))},Fe.exitScope=function(){this.scopeStack.pop()},Fe.treatFunctionsAsVarInScope=function(e){return e.flags&Be||!this.inModule&&e.flags&$e},Fe.declareName=function(e,t,n){var o=!1;if(t===Ve){var h=this.currentScope();o=h.lexical.indexOf(e)>-1||h.functions.indexOf(e)>-1||h.var.indexOf(e)>-1,h.lexical.push(e),this.inModule&&h.flags&$e&&delete this.undefinedExports[e]}else if(t===wi){var v=this.currentScope();v.lexical.push(e)}else if(t===bi){var w=this.currentScope();this.treatFunctionsAsVar?o=w.lexical.indexOf(e)>-1:o=w.lexical.indexOf(e)>-1||w.var.indexOf(e)>-1,w.functions.push(e)}else for(var P=this.scopeStack.length-1;P>=0;--P){var B=this.scopeStack[P];if(B.lexical.indexOf(e)>-1&&!(B.flags&k&&B.lexical[0]===e)||!this.treatFunctionsAsVarInScope(B)&&B.functions.indexOf(e)>-1){o=!0;break}if(B.var.push(e),this.inModule&&B.flags&$e&&delete this.undefinedExports[e],B.flags&me)break}o&&this.raiseRecoverable(n,"Identifier '"+e+"' has already been declared")},Fe.checkLocalExport=function(e){this.scopeStack[0].lexical.indexOf(e.name)===-1&&this.scopeStack[0].var.indexOf(e.name)===-1&&(this.undefinedExports[e.name]=e)},Fe.currentScope=function(){return this.scopeStack[this.scopeStack.length-1]},Fe.currentVarScope=function(){for(var e=this.scopeStack.length-1;;e--){var t=this.scopeStack[e];if(t.flags&(me|Q|j))return t}},Fe.currentThisScope=function(){for(var e=this.scopeStack.length-1;;e--){var t=this.scopeStack[e];if(t.flags&(me|Q|j)&&!(t.flags&S))return t}};var mt=function(t,n,o){this.type="",this.start=n,this.end=0,t.options.locations&&(this.loc=new qe(t,o)),t.options.directSourceFile&&(this.sourceFile=t.options.directSourceFile),t.options.ranges&&(this.range=[n,0])},gt=te.prototype;gt.startNode=function(){return new mt(this,this.start,this.startLoc)},gt.startNodeAt=function(e,t){return new mt(this,e,t)};function Ei(e,t,n,o){return e.type=t,e.end=n,this.options.locations&&(e.loc.end=o),this.options.ranges&&(e.range[1]=n),e}gt.finishNode=function(e,t){return Ei.call(this,e,t,this.lastTokEnd,this.lastTokEndLoc)},gt.finishNodeAt=function(e,t,n,o){return Ei.call(this,e,t,n,o)},gt.copyNode=function(e){var t=new mt(this,e.start,this.startLoc);for(var n in e)t[n]=e[n];return t};var Ts="Gara Garay Gukh Gurung_Khema Hrkt Katakana_Or_Hiragana Kawi Kirat_Rai Krai Nag_Mundari Nagm Ol_Onal Onao Sunu Sunuwar Todhri Todr Tulu_Tigalari Tutg Unknown Zzzz",Ai="ASCII ASCII_Hex_Digit AHex Alphabetic Alpha Any Assigned Bidi_Control Bidi_C Bidi_Mirrored Bidi_M Case_Ignorable CI Cased Changes_When_Casefolded CWCF Changes_When_Casemapped CWCM Changes_When_Lowercased CWL Changes_When_NFKC_Casefolded CWKCF Changes_When_Titlecased CWT Changes_When_Uppercased CWU Dash Default_Ignorable_Code_Point DI Deprecated Dep Diacritic Dia Emoji Emoji_Component Emoji_Modifier Emoji_Modifier_Base Emoji_Presentation Extender Ext Grapheme_Base Gr_Base Grapheme_Extend Gr_Ext Hex_Digit Hex IDS_Binary_Operator IDSB IDS_Trinary_Operator IDST ID_Continue IDC ID_Start IDS Ideographic Ideo Join_Control Join_C Logical_Order_Exception LOE Lowercase Lower Math Noncharacter_Code_Point NChar Pattern_Syntax Pat_Syn Pattern_White_Space Pat_WS Quotation_Mark QMark Radical Regional_Indicator RI Sentence_Terminal STerm Soft_Dotted SD Terminal_Punctuation Term Unified_Ideograph UIdeo Uppercase Upper Variation_Selector VS White_Space space XID_Continue XIDC XID_Start XIDS",Ii=Ai+" Extended_Pictographic",Ti=Ii,ki=Ti+" EBase EComp EMod EPres ExtPict",Pi=ki,ks=Pi,Ps={9:Ai,10:Ii,11:Ti,12:ki,13:Pi,14:ks},Rs="Basic_Emoji Emoji_Keycap_Sequence RGI_Emoji_Modifier_Sequence RGI_Emoji_Flag_Sequence RGI_Emoji_Tag_Sequence RGI_Emoji_ZWJ_Sequence RGI_Emoji",Ns={9:"",10:"",11:"",12:"",13:"",14:Rs},Ri="Cased_Letter LC Close_Punctuation Pe Connector_Punctuation Pc Control Cc cntrl Currency_Symbol Sc Dash_Punctuation Pd Decimal_Number Nd digit Enclosing_Mark Me Final_Punctuation Pf Format Cf Initial_Punctuation Pi Letter L Letter_Number Nl Line_Separator Zl Lowercase_Letter Ll Mark M Combining_Mark Math_Symbol Sm Modifier_Letter Lm Modifier_Symbol Sk Nonspacing_Mark Mn Number N Open_Punctuation Ps Other C Other_Letter Lo Other_Number No Other_Punctuation Po Other_Symbol So Paragraph_Separator Zp Private_Use Co Punctuation P punct Separator Z Space_Separator Zs Spacing_Mark Mc Surrogate Cs Symbol S Titlecase_Letter Lt Unassigned Cn Uppercase_Letter Lu",Ni="Adlam Adlm Ahom Anatolian_Hieroglyphs Hluw Arabic Arab Armenian Armn Avestan Avst Balinese Bali Bamum Bamu Bassa_Vah Bass Batak Batk Bengali Beng Bhaiksuki Bhks Bopomofo Bopo Brahmi Brah Braille Brai Buginese Bugi Buhid Buhd Canadian_Aboriginal Cans Carian Cari Caucasian_Albanian Aghb Chakma Cakm Cham Cham Cherokee Cher Common Zyyy Coptic Copt Qaac Cuneiform Xsux Cypriot Cprt Cyrillic Cyrl Deseret Dsrt Devanagari Deva Duployan Dupl Egyptian_Hieroglyphs Egyp Elbasan Elba Ethiopic Ethi Georgian Geor Glagolitic Glag Gothic Goth Grantha Gran Greek Grek Gujarati Gujr Gurmukhi Guru Han Hani Hangul Hang Hanunoo Hano Hatran Hatr Hebrew Hebr Hiragana Hira Imperial_Aramaic Armi Inherited Zinh Qaai Inscriptional_Pahlavi Phli Inscriptional_Parthian Prti Javanese Java Kaithi Kthi Kannada Knda Katakana Kana Kayah_Li Kali Kharoshthi Khar Khmer Khmr Khojki Khoj Khudawadi Sind Lao Laoo Latin Latn Lepcha Lepc Limbu Limb Linear_A Lina Linear_B Linb Lisu Lisu Lycian Lyci Lydian Lydi Mahajani Mahj Malayalam Mlym Mandaic Mand Manichaean Mani Marchen Marc Masaram_Gondi Gonm Meetei_Mayek Mtei Mende_Kikakui Mend Meroitic_Cursive Merc Meroitic_Hieroglyphs Mero Miao Plrd Modi Mongolian Mong Mro Mroo Multani Mult Myanmar Mymr Nabataean Nbat New_Tai_Lue Talu Newa Newa Nko Nkoo Nushu Nshu Ogham Ogam Ol_Chiki Olck Old_Hungarian Hung Old_Italic Ital Old_North_Arabian Narb Old_Permic Perm Old_Persian Xpeo Old_South_Arabian Sarb Old_Turkic Orkh Oriya Orya Osage Osge Osmanya Osma Pahawh_Hmong Hmng Palmyrene Palm Pau_Cin_Hau Pauc Phags_Pa Phag Phoenician Phnx Psalter_Pahlavi Phlp Rejang Rjng Runic Runr Samaritan Samr Saurashtra Saur Sharada Shrd Shavian Shaw Siddham Sidd SignWriting Sgnw Sinhala Sinh Sora_Sompeng Sora Soyombo Soyo Sundanese Sund Syloti_Nagri Sylo Syriac Syrc Tagalog Tglg Tagbanwa Tagb Tai_Le Tale Tai_Tham Lana Tai_Viet Tavt Takri Takr Tamil Taml Tangut Tang Telugu Telu Thaana Thaa Thai Thai Tibetan Tibt Tifinagh Tfng Tirhuta Tirh Ugaritic Ugar Vai Vaii Warang_Citi Wara Yi Yiii Zanabazar_Square Zanb",Vi=Ni+" Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd",Oi=Vi+" Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho",Wi=Oi+" Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi",Bi=Wi+" Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith",Vs=Bi+" "+Ts,Os={9:Ni,10:Vi,11:Oi,12:Wi,13:Bi,14:Vs},Fi={};function Ws(e){var t=Fi[e]={binary:Ce(Ps[e]+" "+Ri),binaryOfStrings:Ce(Ns[e]),nonBinary:{General_Category:Ce(Ri),Script:Ce(Os[e])}};t.nonBinary.Script_Extensions=t.nonBinary.Script,t.nonBinary.gc=t.nonBinary.General_Category,t.nonBinary.sc=t.nonBinary.Script,t.nonBinary.scx=t.nonBinary.Script_Extensions}for(var hr=0,Li=[9,10,11,12,13,14];hr<Li.length;hr+=1){var Bs=Li[hr];Ws(Bs)}var M=te.prototype,Rt=function(t,n){this.parent=t,this.base=n||this};Rt.prototype.separatedFrom=function(t){for(var n=this;n;n=n.parent)for(var o=t;o;o=o.parent)if(n.base===o.base&&n!==o)return!0;return!1},Rt.prototype.sibling=function(){return new Rt(this.parent,this.base)};var Te=function(t){this.parser=t,this.validFlags="gim"+(t.options.ecmaVersion>=6?"uy":"")+(t.options.ecmaVersion>=9?"s":"")+(t.options.ecmaVersion>=13?"d":"")+(t.options.ecmaVersion>=15?"v":""),this.unicodeProperties=Fi[t.options.ecmaVersion>=14?14:t.options.ecmaVersion],this.source="",this.flags="",this.start=0,this.switchU=!1,this.switchV=!1,this.switchN=!1,this.pos=0,this.lastIntValue=0,this.lastStringValue="",this.lastAssertionIsQuantifiable=!1,this.numCapturingParens=0,this.maxBackReference=0,this.groupNames=Object.create(null),this.backReferenceNames=[],this.branchID=null};Te.prototype.reset=function(t,n,o){var h=o.indexOf("v")!==-1,v=o.indexOf("u")!==-1;this.start=t|0,this.source=n+"",this.flags=o,h&&this.parser.options.ecmaVersion>=15?(this.switchU=!0,this.switchV=!0,this.switchN=!0):(this.switchU=v&&this.parser.options.ecmaVersion>=6,this.switchV=!1,this.switchN=v&&this.parser.options.ecmaVersion>=9)},Te.prototype.raise=function(t){this.parser.raiseRecoverable(this.start,"Invalid regular expression: /"+this.source+"/: "+t)},Te.prototype.at=function(t,n){n===void 0&&(n=!1);var o=this.source,h=o.length;if(t>=h)return-1;var v=o.charCodeAt(t);if(!(n||this.switchU)||v<=55295||v>=57344||t+1>=h)return v;var w=o.charCodeAt(t+1);return w>=56320&&w<=57343?(v<<10)+w-56613888:v},Te.prototype.nextIndex=function(t,n){n===void 0&&(n=!1);var o=this.source,h=o.length;if(t>=h)return h;var v=o.charCodeAt(t),w;return!(n||this.switchU)||v<=55295||v>=57344||t+1>=h||(w=o.charCodeAt(t+1))<56320||w>57343?t+1:t+2},Te.prototype.current=function(t){return t===void 0&&(t=!1),this.at(this.pos,t)},Te.prototype.lookahead=function(t){return t===void 0&&(t=!1),this.at(this.nextIndex(this.pos,t),t)},Te.prototype.advance=function(t){t===void 0&&(t=!1),this.pos=this.nextIndex(this.pos,t)},Te.prototype.eat=function(t,n){return n===void 0&&(n=!1),this.current(n)===t?(this.advance(n),!0):!1},Te.prototype.eatChars=function(t,n){n===void 0&&(n=!1);for(var o=this.pos,h=0,v=t;h<v.length;h+=1){var w=v[h],P=this.at(o,n);if(P===-1||P!==w)return!1;o=this.nextIndex(o,n)}return this.pos=o,!0},M.validateRegExpFlags=function(e){for(var t=e.validFlags,n=e.flags,o=!1,h=!1,v=0;v<n.length;v++){var w=n.charAt(v);t.indexOf(w)===-1&&this.raise(e.start,"Invalid regular expression flag"),n.indexOf(w,v+1)>-1&&this.raise(e.start,"Duplicate regular expression flag"),w==="u"&&(o=!0),w==="v"&&(h=!0)}this.options.ecmaVersion>=15&&o&&h&&this.raise(e.start,"Invalid regular expression flag")};function Fs(e){for(var t in e)return!0;return!1}M.validateRegExpPattern=function(e){this.regexp_pattern(e),!e.switchN&&this.options.ecmaVersion>=9&&Fs(e.groupNames)&&(e.switchN=!0,this.regexp_pattern(e))},M.regexp_pattern=function(e){e.pos=0,e.lastIntValue=0,e.lastStringValue="",e.lastAssertionIsQuantifiable=!1,e.numCapturingParens=0,e.maxBackReference=0,e.groupNames=Object.create(null),e.backReferenceNames.length=0,e.branchID=null,this.regexp_disjunction(e),e.pos!==e.source.length&&(e.eat(41)&&e.raise("Unmatched ')'"),(e.eat(93)||e.eat(125))&&e.raise("Lone quantifier brackets")),e.maxBackReference>e.numCapturingParens&&e.raise("Invalid escape");for(var t=0,n=e.backReferenceNames;t<n.length;t+=1){var o=n[t];e.groupNames[o]||e.raise("Invalid named capture referenced")}},M.regexp_disjunction=function(e){var t=this.options.ecmaVersion>=16;for(t&&(e.branchID=new Rt(e.branchID,null)),this.regexp_alternative(e);e.eat(124);)t&&(e.branchID=e.branchID.sibling()),this.regexp_alternative(e);t&&(e.branchID=e.branchID.parent),this.regexp_eatQuantifier(e,!0)&&e.raise("Nothing to repeat"),e.eat(123)&&e.raise("Lone quantifier brackets")},M.regexp_alternative=function(e){for(;e.pos<e.source.length&&this.regexp_eatTerm(e););},M.regexp_eatTerm=function(e){return this.regexp_eatAssertion(e)?(e.lastAssertionIsQuantifiable&&this.regexp_eatQuantifier(e)&&e.switchU&&e.raise("Invalid quantifier"),!0):(e.switchU?this.regexp_eatAtom(e):this.regexp_eatExtendedAtom(e))?(this.regexp_eatQuantifier(e),!0):!1},M.regexp_eatAssertion=function(e){var t=e.pos;if(e.lastAssertionIsQuantifiable=!1,e.eat(94)||e.eat(36))return!0;if(e.eat(92)){if(e.eat(66)||e.eat(98))return!0;e.pos=t}if(e.eat(40)&&e.eat(63)){var n=!1;if(this.options.ecmaVersion>=9&&(n=e.eat(60)),e.eat(61)||e.eat(33))return this.regexp_disjunction(e),e.eat(41)||e.raise("Unterminated group"),e.lastAssertionIsQuantifiable=!n,!0}return e.pos=t,!1},M.regexp_eatQuantifier=function(e,t){return t===void 0&&(t=!1),this.regexp_eatQuantifierPrefix(e,t)?(e.eat(63),!0):!1},M.regexp_eatQuantifierPrefix=function(e,t){return e.eat(42)||e.eat(43)||e.eat(63)||this.regexp_eatBracedQuantifier(e,t)},M.regexp_eatBracedQuantifier=function(e,t){var n=e.pos;if(e.eat(123)){var o=0,h=-1;if(this.regexp_eatDecimalDigits(e)&&(o=e.lastIntValue,e.eat(44)&&this.regexp_eatDecimalDigits(e)&&(h=e.lastIntValue),e.eat(125)))return h!==-1&&h<o&&!t&&e.raise("numbers out of order in {} quantifier"),!0;e.switchU&&!t&&e.raise("Incomplete quantifier"),e.pos=n}return!1},M.regexp_eatAtom=function(e){return this.regexp_eatPatternCharacters(e)||e.eat(46)||this.regexp_eatReverseSolidusAtomEscape(e)||this.regexp_eatCharacterClass(e)||this.regexp_eatUncapturingGroup(e)||this.regexp_eatCapturingGroup(e)},M.regexp_eatReverseSolidusAtomEscape=function(e){var t=e.pos;if(e.eat(92)){if(this.regexp_eatAtomEscape(e))return!0;e.pos=t}return!1},M.regexp_eatUncapturingGroup=function(e){var t=e.pos;if(e.eat(40)){if(e.eat(63)){if(this.options.ecmaVersion>=16){var n=this.regexp_eatModifiers(e),o=e.eat(45);if(n||o){for(var h=0;h<n.length;h++){var v=n.charAt(h);n.indexOf(v,h+1)>-1&&e.raise("Duplicate regular expression modifiers")}if(o){var w=this.regexp_eatModifiers(e);!n&&!w&&e.current()===58&&e.raise("Invalid regular expression modifiers");for(var P=0;P<w.length;P++){var B=w.charAt(P);(w.indexOf(B,P+1)>-1||n.indexOf(B)>-1)&&e.raise("Duplicate regular expression modifiers")}}}}if(e.eat(58)){if(this.regexp_disjunction(e),e.eat(41))return!0;e.raise("Unterminated group")}}e.pos=t}return!1},M.regexp_eatCapturingGroup=function(e){if(e.eat(40)){if(this.options.ecmaVersion>=9?this.regexp_groupSpecifier(e):e.current()===63&&e.raise("Invalid group"),this.regexp_disjunction(e),e.eat(41))return e.numCapturingParens+=1,!0;e.raise("Unterminated group")}return!1},M.regexp_eatModifiers=function(e){for(var t="",n=0;(n=e.current())!==-1&&Ls(n);)t+=ye(n),e.advance();return t};function Ls(e){return e===105||e===109||e===115}M.regexp_eatExtendedAtom=function(e){return e.eat(46)||this.regexp_eatReverseSolidusAtomEscape(e)||this.regexp_eatCharacterClass(e)||this.regexp_eatUncapturingGroup(e)||this.regexp_eatCapturingGroup(e)||this.regexp_eatInvalidBracedQuantifier(e)||this.regexp_eatExtendedPatternCharacter(e)},M.regexp_eatInvalidBracedQuantifier=function(e){return this.regexp_eatBracedQuantifier(e,!0)&&e.raise("Nothing to repeat"),!1},M.regexp_eatSyntaxCharacter=function(e){var t=e.current();return Mi(t)?(e.lastIntValue=t,e.advance(),!0):!1};function Mi(e){return e===36||e>=40&&e<=43||e===46||e===63||e>=91&&e<=94||e>=123&&e<=125}M.regexp_eatPatternCharacters=function(e){for(var t=e.pos,n=0;(n=e.current())!==-1&&!Mi(n);)e.advance();return e.pos!==t},M.regexp_eatExtendedPatternCharacter=function(e){var t=e.current();return t!==-1&&t!==36&&!(t>=40&&t<=43)&&t!==46&&t!==63&&t!==91&&t!==94&&t!==124?(e.advance(),!0):!1},M.regexp_groupSpecifier=function(e){if(e.eat(63)){this.regexp_eatGroupName(e)||e.raise("Invalid group");var t=this.options.ecmaVersion>=16,n=e.groupNames[e.lastStringValue];if(n)if(t)for(var o=0,h=n;o<h.length;o+=1){var v=h[o];v.separatedFrom(e.branchID)||e.raise("Duplicate capture group name")}else e.raise("Duplicate capture group name");t?(n||(e.groupNames[e.lastStringValue]=[])).push(e.branchID):e.groupNames[e.lastStringValue]=!0}},M.regexp_eatGroupName=function(e){if(e.lastStringValue="",e.eat(60)){if(this.regexp_eatRegExpIdentifierName(e)&&e.eat(62))return!0;e.raise("Invalid capture group name")}return!1},M.regexp_eatRegExpIdentifierName=function(e){if(e.lastStringValue="",this.regexp_eatRegExpIdentifierStart(e)){for(e.lastStringValue+=ye(e.lastIntValue);this.regexp_eatRegExpIdentifierPart(e);)e.lastStringValue+=ye(e.lastIntValue);return!0}return!1},M.regexp_eatRegExpIdentifierStart=function(e){var t=e.pos,n=this.options.ecmaVersion>=11,o=e.current(n);return e.advance(n),o===92&&this.regexp_eatRegExpUnicodeEscapeSequence(e,n)&&(o=e.lastIntValue),Ms(o)?(e.lastIntValue=o,!0):(e.pos=t,!1)};function Ms(e){return R(e,!0)||e===36||e===95}M.regexp_eatRegExpIdentifierPart=function(e){var t=e.pos,n=this.options.ecmaVersion>=11,o=e.current(n);return e.advance(n),o===92&&this.regexp_eatRegExpUnicodeEscapeSequence(e,n)&&(o=e.lastIntValue),Ds(o)?(e.lastIntValue=o,!0):(e.pos=t,!1)};function Ds(e){return V(e,!0)||e===36||e===95||e===8204||e===8205}M.regexp_eatAtomEscape=function(e){return this.regexp_eatBackReference(e)||this.regexp_eatCharacterClassEscape(e)||this.regexp_eatCharacterEscape(e)||e.switchN&&this.regexp_eatKGroupName(e)?!0:(e.switchU&&(e.current()===99&&e.raise("Invalid unicode escape"),e.raise("Invalid escape")),!1)},M.regexp_eatBackReference=function(e){var t=e.pos;if(this.regexp_eatDecimalEscape(e)){var n=e.lastIntValue;if(e.switchU)return n>e.maxBackReference&&(e.maxBackReference=n),!0;if(n<=e.numCapturingParens)return!0;e.pos=t}return!1},M.regexp_eatKGroupName=function(e){if(e.eat(107)){if(this.regexp_eatGroupName(e))return e.backReferenceNames.push(e.lastStringValue),!0;e.raise("Invalid named reference")}return!1},M.regexp_eatCharacterEscape=function(e){return this.regexp_eatControlEscape(e)||this.regexp_eatCControlLetter(e)||this.regexp_eatZero(e)||this.regexp_eatHexEscapeSequence(e)||this.regexp_eatRegExpUnicodeEscapeSequence(e,!1)||!e.switchU&&this.regexp_eatLegacyOctalEscapeSequence(e)||this.regexp_eatIdentityEscape(e)},M.regexp_eatCControlLetter=function(e){var t=e.pos;if(e.eat(99)){if(this.regexp_eatControlLetter(e))return!0;e.pos=t}return!1},M.regexp_eatZero=function(e){return e.current()===48&&!Nt(e.lookahead())?(e.lastIntValue=0,e.advance(),!0):!1},M.regexp_eatControlEscape=function(e){var t=e.current();return t===116?(e.lastIntValue=9,e.advance(),!0):t===110?(e.lastIntValue=10,e.advance(),!0):t===118?(e.lastIntValue=11,e.advance(),!0):t===102?(e.lastIntValue=12,e.advance(),!0):t===114?(e.lastIntValue=13,e.advance(),!0):!1},M.regexp_eatControlLetter=function(e){var t=e.current();return Di(t)?(e.lastIntValue=t%32,e.advance(),!0):!1};function Di(e){return e>=65&&e<=90||e>=97&&e<=122}M.regexp_eatRegExpUnicodeEscapeSequence=function(e,t){t===void 0&&(t=!1);var n=e.pos,o=t||e.switchU;if(e.eat(117)){if(this.regexp_eatFixedHexDigits(e,4)){var h=e.lastIntValue;if(o&&h>=55296&&h<=56319){var v=e.pos;if(e.eat(92)&&e.eat(117)&&this.regexp_eatFixedHexDigits(e,4)){var w=e.lastIntValue;if(w>=56320&&w<=57343)return e.lastIntValue=(h-55296)*1024+(w-56320)+65536,!0}e.pos=v,e.lastIntValue=h}return!0}if(o&&e.eat(123)&&this.regexp_eatHexDigits(e)&&e.eat(125)&&Us(e.lastIntValue))return!0;o&&e.raise("Invalid unicode escape"),e.pos=n}return!1};function Us(e){return e>=0&&e<=1114111}M.regexp_eatIdentityEscape=function(e){if(e.switchU)return this.regexp_eatSyntaxCharacter(e)?!0:e.eat(47)?(e.lastIntValue=47,!0):!1;var t=e.current();return t!==99&&(!e.switchN||t!==107)?(e.lastIntValue=t,e.advance(),!0):!1},M.regexp_eatDecimalEscape=function(e){e.lastIntValue=0;var t=e.current();if(t>=49&&t<=57){do e.lastIntValue=10*e.lastIntValue+(t-48),e.advance();while((t=e.current())>=48&&t<=57);return!0}return!1};var Ui=0,Oe=1,we=2;M.regexp_eatCharacterClassEscape=function(e){var t=e.current();if(js(t))return e.lastIntValue=-1,e.advance(),Oe;var n=!1;if(e.switchU&&this.options.ecmaVersion>=9&&((n=t===80)||t===112)){e.lastIntValue=-1,e.advance();var o;if(e.eat(123)&&(o=this.regexp_eatUnicodePropertyValueExpression(e))&&e.eat(125))return n&&o===we&&e.raise("Invalid property name"),o;e.raise("Invalid property name")}return Ui};function js(e){return e===100||e===68||e===115||e===83||e===119||e===87}M.regexp_eatUnicodePropertyValueExpression=function(e){var t=e.pos;if(this.regexp_eatUnicodePropertyName(e)&&e.eat(61)){var n=e.lastStringValue;if(this.regexp_eatUnicodePropertyValue(e)){var o=e.lastStringValue;return this.regexp_validateUnicodePropertyNameAndValue(e,n,o),Oe}}if(e.pos=t,this.regexp_eatLoneUnicodePropertyNameOrValue(e)){var h=e.lastStringValue;return this.regexp_validateUnicodePropertyNameOrValue(e,h)}return Ui},M.regexp_validateUnicodePropertyNameAndValue=function(e,t,n){de(e.unicodeProperties.nonBinary,t)||e.raise("Invalid property name"),e.unicodeProperties.nonBinary[t].test(n)||e.raise("Invalid property value")},M.regexp_validateUnicodePropertyNameOrValue=function(e,t){if(e.unicodeProperties.binary.test(t))return Oe;if(e.switchV&&e.unicodeProperties.binaryOfStrings.test(t))return we;e.raise("Invalid property name")},M.regexp_eatUnicodePropertyName=function(e){var t=0;for(e.lastStringValue="";ji(t=e.current());)e.lastStringValue+=ye(t),e.advance();return e.lastStringValue!==""};function ji(e){return Di(e)||e===95}M.regexp_eatUnicodePropertyValue=function(e){var t=0;for(e.lastStringValue="";qs(t=e.current());)e.lastStringValue+=ye(t),e.advance();return e.lastStringValue!==""};function qs(e){return ji(e)||Nt(e)}M.regexp_eatLoneUnicodePropertyNameOrValue=function(e){return this.regexp_eatUnicodePropertyValue(e)},M.regexp_eatCharacterClass=function(e){if(e.eat(91)){var t=e.eat(94),n=this.regexp_classContents(e);return e.eat(93)||e.raise("Unterminated character class"),t&&n===we&&e.raise("Negated character class may contain strings"),!0}return!1},M.regexp_classContents=function(e){return e.current()===93?Oe:e.switchV?this.regexp_classSetExpression(e):(this.regexp_nonEmptyClassRanges(e),Oe)},M.regexp_nonEmptyClassRanges=function(e){for(;this.regexp_eatClassAtom(e);){var t=e.lastIntValue;if(e.eat(45)&&this.regexp_eatClassAtom(e)){var n=e.lastIntValue;e.switchU&&(t===-1||n===-1)&&e.raise("Invalid character class"),t!==-1&&n!==-1&&t>n&&e.raise("Range out of order in character class")}}},M.regexp_eatClassAtom=function(e){var t=e.pos;if(e.eat(92)){if(this.regexp_eatClassEscape(e))return!0;if(e.switchU){var n=e.current();(n===99||Gi(n))&&e.raise("Invalid class escape"),e.raise("Invalid escape")}e.pos=t}var o=e.current();return o!==93?(e.lastIntValue=o,e.advance(),!0):!1},M.regexp_eatClassEscape=function(e){var t=e.pos;if(e.eat(98))return e.lastIntValue=8,!0;if(e.switchU&&e.eat(45))return e.lastIntValue=45,!0;if(!e.switchU&&e.eat(99)){if(this.regexp_eatClassControlLetter(e))return!0;e.pos=t}return this.regexp_eatCharacterClassEscape(e)||this.regexp_eatCharacterEscape(e)},M.regexp_classSetExpression=function(e){var t=Oe,n;if(!this.regexp_eatClassSetRange(e))if(n=this.regexp_eatClassSetOperand(e)){n===we&&(t=we);for(var o=e.pos;e.eatChars([38,38]);){if(e.current()!==38&&(n=this.regexp_eatClassSetOperand(e))){n!==we&&(t=Oe);continue}e.raise("Invalid character in character class")}if(o!==e.pos)return t;for(;e.eatChars([45,45]);)this.regexp_eatClassSetOperand(e)||e.raise("Invalid character in character class");if(o!==e.pos)return t}else e.raise("Invalid character in character class");for(;;)if(!this.regexp_eatClassSetRange(e)){if(n=this.regexp_eatClassSetOperand(e),!n)return t;n===we&&(t=we)}},M.regexp_eatClassSetRange=function(e){var t=e.pos;if(this.regexp_eatClassSetCharacter(e)){var n=e.lastIntValue;if(e.eat(45)&&this.regexp_eatClassSetCharacter(e)){var o=e.lastIntValue;return n!==-1&&o!==-1&&n>o&&e.raise("Range out of order in character class"),!0}e.pos=t}return!1},M.regexp_eatClassSetOperand=function(e){return this.regexp_eatClassSetCharacter(e)?Oe:this.regexp_eatClassStringDisjunction(e)||this.regexp_eatNestedClass(e)},M.regexp_eatNestedClass=function(e){var t=e.pos;if(e.eat(91)){var n=e.eat(94),o=this.regexp_classContents(e);if(e.eat(93))return n&&o===we&&e.raise("Negated character class may contain strings"),o;e.pos=t}if(e.eat(92)){var h=this.regexp_eatCharacterClassEscape(e);if(h)return h;e.pos=t}return null},M.regexp_eatClassStringDisjunction=function(e){var t=e.pos;if(e.eatChars([92,113])){if(e.eat(123)){var n=this.regexp_classStringDisjunctionContents(e);if(e.eat(125))return n}else e.raise("Invalid escape");e.pos=t}return null},M.regexp_classStringDisjunctionContents=function(e){for(var t=this.regexp_classString(e);e.eat(124);)this.regexp_classString(e)===we&&(t=we);return t},M.regexp_classString=function(e){for(var t=0;this.regexp_eatClassSetCharacter(e);)t++;return t===1?Oe:we},M.regexp_eatClassSetCharacter=function(e){var t=e.pos;if(e.eat(92))return this.regexp_eatCharacterEscape(e)||this.regexp_eatClassSetReservedPunctuator(e)?!0:e.eat(98)?(e.lastIntValue=8,!0):(e.pos=t,!1);var n=e.current();return n<0||n===e.lookahead()&&$s(n)||Gs(n)?!1:(e.advance(),e.lastIntValue=n,!0)};function $s(e){return e===33||e>=35&&e<=38||e>=42&&e<=44||e===46||e>=58&&e<=64||e===94||e===96||e===126}function Gs(e){return e===40||e===41||e===45||e===47||e>=91&&e<=93||e>=123&&e<=125}M.regexp_eatClassSetReservedPunctuator=function(e){var t=e.current();return Hs(t)?(e.lastIntValue=t,e.advance(),!0):!1};function Hs(e){return e===33||e===35||e===37||e===38||e===44||e===45||e>=58&&e<=62||e===64||e===96||e===126}M.regexp_eatClassControlLetter=function(e){var t=e.current();return Nt(t)||t===95?(e.lastIntValue=t%32,e.advance(),!0):!1},M.regexp_eatHexEscapeSequence=function(e){var t=e.pos;if(e.eat(120)){if(this.regexp_eatFixedHexDigits(e,2))return!0;e.switchU&&e.raise("Invalid escape"),e.pos=t}return!1},M.regexp_eatDecimalDigits=function(e){var t=e.pos,n=0;for(e.lastIntValue=0;Nt(n=e.current());)e.lastIntValue=10*e.lastIntValue+(n-48),e.advance();return e.pos!==t};function Nt(e){return e>=48&&e<=57}M.regexp_eatHexDigits=function(e){var t=e.pos,n=0;for(e.lastIntValue=0;qi(n=e.current());)e.lastIntValue=16*e.lastIntValue+$i(n),e.advance();return e.pos!==t};function qi(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}function $i(e){return e>=65&&e<=70?10+(e-65):e>=97&&e<=102?10+(e-97):e-48}M.regexp_eatLegacyOctalEscapeSequence=function(e){if(this.regexp_eatOctalDigit(e)){var t=e.lastIntValue;if(this.regexp_eatOctalDigit(e)){var n=e.lastIntValue;t<=3&&this.regexp_eatOctalDigit(e)?e.lastIntValue=t*64+n*8+e.lastIntValue:e.lastIntValue=t*8+n}else e.lastIntValue=t;return!0}return!1},M.regexp_eatOctalDigit=function(e){var t=e.current();return Gi(t)?(e.lastIntValue=t-48,e.advance(),!0):(e.lastIntValue=0,!1)};function Gi(e){return e>=48&&e<=55}M.regexp_eatFixedHexDigits=function(e,t){var n=e.pos;e.lastIntValue=0;for(var o=0;o<t;++o){var h=e.current();if(!qi(h))return e.pos=n,!1;e.lastIntValue=16*e.lastIntValue+$i(h),e.advance()}return!0};var Vt=function(t){this.type=t.type,this.value=t.value,this.start=t.start,this.end=t.end,t.options.locations&&(this.loc=new qe(t,t.startLoc,t.endLoc)),t.options.ranges&&(this.range=[t.start,t.end])},J=te.prototype;J.next=function(e){!e&&this.type.keyword&&this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword "+this.type.keyword),this.options.onToken&&this.options.onToken(new Vt(this)),this.lastTokEnd=this.end,this.lastTokStart=this.start,this.lastTokEndLoc=this.endLoc,this.lastTokStartLoc=this.startLoc,this.nextToken()},J.getToken=function(){return this.next(),new Vt(this)},typeof Symbol<"u"&&(J[Symbol.iterator]=function(){var e=this;return{next:function(){var t=e.getToken();return{done:t.type===a.eof,value:t}}}}),J.nextToken=function(){var e=this.curContext();if((!e||!e.preserveSpace)&&this.skipSpace(),this.start=this.pos,this.options.locations&&(this.startLoc=this.curPosition()),this.pos>=this.input.length)return this.finishToken(a.eof);if(e.override)return e.override(this);this.readToken(this.fullCharCodeAtPos())},J.readToken=function(e){return R(e,this.options.ecmaVersion>=6)||e===92?this.readWord():this.getTokenFromCode(e)},J.fullCharCodeAtPos=function(){var e=this.input.charCodeAt(this.pos);if(e<=55295||e>=56320)return e;var t=this.input.charCodeAt(this.pos+1);return t<=56319||t>=57344?e:(e<<10)+t-56613888},J.skipBlockComment=function(){var e=this.options.onComment&&this.curPosition(),t=this.pos,n=this.input.indexOf("*/",this.pos+=2);if(n===-1&&this.raise(this.pos-2,"Unterminated comment"),this.pos=n+2,this.options.locations)for(var o=void 0,h=t;(o=z(this.input,h,this.pos))>-1;)++this.curLine,h=this.lineStart=o;this.options.onComment&&this.options.onComment(!0,this.input.slice(t+2,n),t,this.pos,e,this.curPosition())},J.skipLineComment=function(e){for(var t=this.pos,n=this.options.onComment&&this.curPosition(),o=this.input.charCodeAt(this.pos+=e);this.pos<this.input.length&&!A(o);)o=this.input.charCodeAt(++this.pos);this.options.onComment&&this.options.onComment(!1,this.input.slice(t+e,this.pos),t,this.pos,n,this.curPosition())},J.skipSpace=function(){e:for(;this.pos<this.input.length;){var e=this.input.charCodeAt(this.pos);switch(e){case 32:case 160:++this.pos;break;case 13:this.input.charCodeAt(this.pos+1)===10&&++this.pos;case 10:case 8232:case 8233:++this.pos,this.options.locations&&(++this.curLine,this.lineStart=this.pos);break;case 47:switch(this.input.charCodeAt(this.pos+1)){case 42:this.skipBlockComment();break;case 47:this.skipLineComment(2);break;default:break e}break;default:if(e>8&&e<14||e>=5760&&G.test(String.fromCharCode(e)))++this.pos;else break e}}},J.finishToken=function(e,t){this.end=this.pos,this.options.locations&&(this.endLoc=this.curPosition());var n=this.type;this.type=e,this.value=t,this.updateContext(n)},J.readToken_dot=function(){var e=this.input.charCodeAt(this.pos+1);if(e>=48&&e<=57)return this.readNumber(!0);var t=this.input.charCodeAt(this.pos+2);return this.options.ecmaVersion>=6&&e===46&&t===46?(this.pos+=3,this.finishToken(a.ellipsis)):(++this.pos,this.finishToken(a.dot))},J.readToken_slash=function(){var e=this.input.charCodeAt(this.pos+1);return this.exprAllowed?(++this.pos,this.readRegexp()):e===61?this.finishOp(a.assign,2):this.finishOp(a.slash,1)},J.readToken_mult_modulo_exp=function(e){var t=this.input.charCodeAt(this.pos+1),n=1,o=e===42?a.star:a.modulo;return this.options.ecmaVersion>=7&&e===42&&t===42&&(++n,o=a.starstar,t=this.input.charCodeAt(this.pos+2)),t===61?this.finishOp(a.assign,n+1):this.finishOp(o,n)},J.readToken_pipe_amp=function(e){var t=this.input.charCodeAt(this.pos+1);if(t===e){if(this.options.ecmaVersion>=12){var n=this.input.charCodeAt(this.pos+2);if(n===61)return this.finishOp(a.assign,3)}return this.finishOp(e===124?a.logicalOR:a.logicalAND,2)}return t===61?this.finishOp(a.assign,2):this.finishOp(e===124?a.bitwiseOR:a.bitwiseAND,1)},J.readToken_caret=function(){var e=this.input.charCodeAt(this.pos+1);return e===61?this.finishOp(a.assign,2):this.finishOp(a.bitwiseXOR,1)},J.readToken_plus_min=function(e){var t=this.input.charCodeAt(this.pos+1);return t===e?t===45&&!this.inModule&&this.input.charCodeAt(this.pos+2)===62&&(this.lastTokEnd===0||E.test(this.input.slice(this.lastTokEnd,this.pos)))?(this.skipLineComment(3),this.skipSpace(),this.nextToken()):this.finishOp(a.incDec,2):t===61?this.finishOp(a.assign,2):this.finishOp(a.plusMin,1)},J.readToken_lt_gt=function(e){var t=this.input.charCodeAt(this.pos+1),n=1;return t===e?(n=e===62&&this.input.charCodeAt(this.pos+2)===62?3:2,this.input.charCodeAt(this.pos+n)===61?this.finishOp(a.assign,n+1):this.finishOp(a.bitShift,n)):t===33&&e===60&&!this.inModule&&this.input.charCodeAt(this.pos+2)===45&&this.input.charCodeAt(this.pos+3)===45?(this.skipLineComment(4),this.skipSpace(),this.nextToken()):(t===61&&(n=2),this.finishOp(a.relational,n))},J.readToken_eq_excl=function(e){var t=this.input.charCodeAt(this.pos+1);return t===61?this.finishOp(a.equality,this.input.charCodeAt(this.pos+2)===61?3:2):e===61&&t===62&&this.options.ecmaVersion>=6?(this.pos+=2,this.finishToken(a.arrow)):this.finishOp(e===61?a.eq:a.prefix,1)},J.readToken_question=function(){var e=this.options.ecmaVersion;if(e>=11){var t=this.input.charCodeAt(this.pos+1);if(t===46){var n=this.input.charCodeAt(this.pos+2);if(n<48||n>57)return this.finishOp(a.questionDot,2)}if(t===63){if(e>=12){var o=this.input.charCodeAt(this.pos+2);if(o===61)return this.finishOp(a.assign,3)}return this.finishOp(a.coalesce,2)}}return this.finishOp(a.question,1)},J.readToken_numberSign=function(){var e=this.options.ecmaVersion,t=35;if(e>=13&&(++this.pos,t=this.fullCharCodeAtPos(),R(t,!0)||t===92))return this.finishToken(a.privateId,this.readWord1());this.raise(this.pos,"Unexpected character '"+ye(t)+"'")},J.getTokenFromCode=function(e){switch(e){case 46:return this.readToken_dot();case 40:return++this.pos,this.finishToken(a.parenL);case 41:return++this.pos,this.finishToken(a.parenR);case 59:return++this.pos,this.finishToken(a.semi);case 44:return++this.pos,this.finishToken(a.comma);case 91:return++this.pos,this.finishToken(a.bracketL);case 93:return++this.pos,this.finishToken(a.bracketR);case 123:return++this.pos,this.finishToken(a.braceL);case 125:return++this.pos,this.finishToken(a.braceR);case 58:return++this.pos,this.finishToken(a.colon);case 96:if(this.options.ecmaVersion<6)break;return++this.pos,this.finishToken(a.backQuote);case 48:var t=this.input.charCodeAt(this.pos+1);if(t===120||t===88)return this.readRadixNumber(16);if(this.options.ecmaVersion>=6){if(t===111||t===79)return this.readRadixNumber(8);if(t===98||t===66)return this.readRadixNumber(2)}case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return this.readNumber(!1);case 34:case 39:return this.readString(e);case 47:return this.readToken_slash();case 37:case 42:return this.readToken_mult_modulo_exp(e);case 124:case 38:return this.readToken_pipe_amp(e);case 94:return this.readToken_caret();case 43:case 45:return this.readToken_plus_min(e);case 60:case 62:return this.readToken_lt_gt(e);case 61:case 33:return this.readToken_eq_excl(e);case 63:return this.readToken_question();case 126:return this.finishOp(a.prefix,1);case 35:return this.readToken_numberSign()}this.raise(this.pos,"Unexpected character '"+ye(e)+"'")},J.finishOp=function(e,t){var n=this.input.slice(this.pos,this.pos+t);return this.pos+=t,this.finishToken(e,n)},J.readRegexp=function(){for(var e,t,n=this.pos;;){this.pos>=this.input.length&&this.raise(n,"Unterminated regular expression");var o=this.input.charAt(this.pos);if(E.test(o)&&this.raise(n,"Unterminated regular expression"),e)e=!1;else{if(o==="[")t=!0;else if(o==="]"&&t)t=!1;else if(o==="/"&&!t)break;e=o==="\\"}++this.pos}var h=this.input.slice(n,this.pos);++this.pos;var v=this.pos,w=this.readWord1();this.containsEsc&&this.unexpected(v);var P=this.regexpState||(this.regexpState=new Te(this));P.reset(n,h,w),this.validateRegExpFlags(P),this.validateRegExpPattern(P);var B=null;try{B=new RegExp(h,w)}catch{}return this.finishToken(a.regexp,{pattern:h,flags:w,value:B})},J.readInt=function(e,t,n){for(var o=this.options.ecmaVersion>=12&&t===void 0,h=n&&this.input.charCodeAt(this.pos)===48,v=this.pos,w=0,P=0,B=0,q=t??1/0;B<q;++B,++this.pos){var H=this.input.charCodeAt(this.pos),ee=void 0;if(o&&H===95){h&&this.raiseRecoverable(this.pos,"Numeric separator is not allowed in legacy octal numeric literals"),P===95&&this.raiseRecoverable(this.pos,"Numeric separator must be exactly one underscore"),B===0&&this.raiseRecoverable(this.pos,"Numeric separator is not allowed at the first of digits"),P=H;continue}if(H>=97?ee=H-97+10:H>=65?ee=H-65+10:H>=48&&H<=57?ee=H-48:ee=1/0,ee>=e)break;P=H,w=w*e+ee}return o&&P===95&&this.raiseRecoverable(this.pos-1,"Numeric separator is not allowed at the last of digits"),this.pos===v||t!=null&&this.pos-v!==t?null:w};function zs(e,t){return t?parseInt(e,8):parseFloat(e.replace(/_/g,""))}function Hi(e){return typeof BigInt!="function"?null:BigInt(e.replace(/_/g,""))}J.readRadixNumber=function(e){var t=this.pos;this.pos+=2;var n=this.readInt(e);return n==null&&this.raise(this.start+2,"Expected number in radix "+e),this.options.ecmaVersion>=11&&this.input.charCodeAt(this.pos)===110?(n=Hi(this.input.slice(t,this.pos)),++this.pos):R(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(a.num,n)},J.readNumber=function(e){var t=this.pos;!e&&this.readInt(10,void 0,!0)===null&&this.raise(t,"Invalid number");var n=this.pos-t>=2&&this.input.charCodeAt(t)===48;n&&this.strict&&this.raise(t,"Invalid number");var o=this.input.charCodeAt(this.pos);if(!n&&!e&&this.options.ecmaVersion>=11&&o===110){var h=Hi(this.input.slice(t,this.pos));return++this.pos,R(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(a.num,h)}n&&/[89]/.test(this.input.slice(t,this.pos))&&(n=!1),o===46&&!n&&(++this.pos,this.readInt(10),o=this.input.charCodeAt(this.pos)),(o===69||o===101)&&!n&&(o=this.input.charCodeAt(++this.pos),(o===43||o===45)&&++this.pos,this.readInt(10)===null&&this.raise(t,"Invalid number")),R(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number");var v=zs(this.input.slice(t,this.pos),n);return this.finishToken(a.num,v)},J.readCodePoint=function(){var e=this.input.charCodeAt(this.pos),t;if(e===123){this.options.ecmaVersion<6&&this.unexpected();var n=++this.pos;t=this.readHexChar(this.input.indexOf("}",this.pos)-this.pos),++this.pos,t>1114111&&this.invalidStringToken(n,"Code point out of bounds")}else t=this.readHexChar(4);return t},J.readString=function(e){for(var t="",n=++this.pos;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated string constant");var o=this.input.charCodeAt(this.pos);if(o===e)break;o===92?(t+=this.input.slice(n,this.pos),t+=this.readEscapedChar(!1),n=this.pos):o===8232||o===8233?(this.options.ecmaVersion<10&&this.raise(this.start,"Unterminated string constant"),++this.pos,this.options.locations&&(this.curLine++,this.lineStart=this.pos)):(A(o)&&this.raise(this.start,"Unterminated string constant"),++this.pos)}return t+=this.input.slice(n,this.pos++),this.finishToken(a.string,t)};var zi={};J.tryReadTemplateToken=function(){this.inTemplateElement=!0;try{this.readTmplToken()}catch(e){if(e===zi)this.readInvalidTemplateToken();else throw e}this.inTemplateElement=!1},J.invalidStringToken=function(e,t){if(this.inTemplateElement&&this.options.ecmaVersion>=9)throw zi;this.raise(e,t)},J.readTmplToken=function(){for(var e="",t=this.pos;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated template");var n=this.input.charCodeAt(this.pos);if(n===96||n===36&&this.input.charCodeAt(this.pos+1)===123)return this.pos===this.start&&(this.type===a.template||this.type===a.invalidTemplate)?n===36?(this.pos+=2,this.finishToken(a.dollarBraceL)):(++this.pos,this.finishToken(a.backQuote)):(e+=this.input.slice(t,this.pos),this.finishToken(a.template,e));if(n===92)e+=this.input.slice(t,this.pos),e+=this.readEscapedChar(!0),t=this.pos;else if(A(n)){switch(e+=this.input.slice(t,this.pos),++this.pos,n){case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:e+=`
|
|
6
|
+
`;break;default:e+=String.fromCharCode(n);break}this.options.locations&&(++this.curLine,this.lineStart=this.pos),t=this.pos}else++this.pos}},J.readInvalidTemplateToken=function(){for(;this.pos<this.input.length;this.pos++)switch(this.input[this.pos]){case"\\":++this.pos;break;case"$":if(this.input[this.pos+1]!=="{")break;case"`":return this.finishToken(a.invalidTemplate,this.input.slice(this.start,this.pos));case"\r":this.input[this.pos+1]===`
|
|
7
|
+
`&&++this.pos;case`
|
|
8
|
+
`:case"\u2028":case"\u2029":++this.curLine,this.lineStart=this.pos+1;break}this.raise(this.start,"Unterminated template")},J.readEscapedChar=function(e){var t=this.input.charCodeAt(++this.pos);switch(++this.pos,t){case 110:return`
|
|
9
|
+
`;case 114:return"\r";case 120:return String.fromCharCode(this.readHexChar(2));case 117:return ye(this.readCodePoint());case 116:return" ";case 98:return"\b";case 118:return"\v";case 102:return"\f";case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:return this.options.locations&&(this.lineStart=this.pos,++this.curLine),"";case 56:case 57:if(this.strict&&this.invalidStringToken(this.pos-1,"Invalid escape sequence"),e){var n=this.pos-1;this.invalidStringToken(n,"Invalid escape sequence in template string")}default:if(t>=48&&t<=55){var o=this.input.substr(this.pos-1,3).match(/^[0-7]+/)[0],h=parseInt(o,8);return h>255&&(o=o.slice(0,-1),h=parseInt(o,8)),this.pos+=o.length-1,t=this.input.charCodeAt(this.pos),(o!=="0"||t===56||t===57)&&(this.strict||e)&&this.invalidStringToken(this.pos-1-o.length,e?"Octal literal in template string":"Octal literal in strict mode"),String.fromCharCode(h)}return A(t)?(this.options.locations&&(this.lineStart=this.pos,++this.curLine),""):String.fromCharCode(t)}},J.readHexChar=function(e){var t=this.pos,n=this.readInt(16,e);return n===null&&this.invalidStringToken(t,"Bad character escape sequence"),n},J.readWord1=function(){this.containsEsc=!1;for(var e="",t=!0,n=this.pos,o=this.options.ecmaVersion>=6;this.pos<this.input.length;){var h=this.fullCharCodeAtPos();if(V(h,o))this.pos+=h<=65535?1:2;else if(h===92){this.containsEsc=!0,e+=this.input.slice(n,this.pos);var v=this.pos;this.input.charCodeAt(++this.pos)!==117&&this.invalidStringToken(this.pos,"Expecting Unicode escape sequence \\uXXXX"),++this.pos;var w=this.readCodePoint();(t?R:V)(w,o)||this.invalidStringToken(v,"Invalid Unicode escape"),e+=ye(w),n=this.pos}else break;t=!1}return e+this.input.slice(n,this.pos)},J.readWord=function(){var e=this.readWord1(),t=a.name;return this.keywords.test(e)&&(t=g[e]),this.finishToken(t,e)};var Ki="8.15.0";te.acorn={Parser:te,version:Ki,defaultOptions:xe,Position:Pe,SourceLocation:qe,getLineInfo:Re,Node:mt,TokenType:O,tokTypes:a,keywordTypes:g,TokContext:be,tokContexts:Z,isIdentifierChar:V,isIdentifierStart:R,Token:Vt,isNewLine:A,lineBreak:E,lineBreakG:N,nonASCIIwhitespace:G};function Ks(e,t){return te.parse(e,t)}function Qs(e,t,n){return te.parseExpressionAt(e,t,n)}function Js(e,t){return te.tokenizer(e,t)}c.Node=mt,c.Parser=te,c.Position=Pe,c.SourceLocation=qe,c.TokContext=be,c.Token=Vt,c.TokenType=O,c.defaultOptions=xe,c.getLineInfo=Re,c.isIdentifierChar=V,c.isIdentifierStart=R,c.isNewLine=A,c.keywordTypes=g,c.lineBreak=E,c.lineBreakG=N,c.nonASCIIwhitespace=G,c.parse=Ks,c.parseExpressionAt=Qs,c.tokContexts=Z,c.tokTypes=a,c.tokenizer=Js,c.version=Ki})});var jn=he((Xt,Un)=>{"use strict";(function(c,r){typeof Xt=="object"&&typeof Un<"u"?r(Xt):typeof define=="function"&&define.amd?define(["exports"],r):(c=typeof globalThis<"u"?globalThis:c||self,r((c.acorn=c.acorn||{},c.acorn.walk={})))})(Xt,function(c){"use strict";function r(m,d,g,_,a){g||(g=y),function E(N,A,z){var G=z||N.type;g[G](N,A,E),d[G]&&d[G](N,A)}(m,_,a)}function i(m,d,g,_,a){var E=[];g||(g=y),function N(A,z,G){var K=G||A.type,pe=A!==E[E.length-1];pe&&E.push(A),g[K](A,z,N),d[K]&&d[K](A,z||E,E),pe&&E.pop()}(m,_,a)}function s(m,d,g,_,a){var E=g?R(g,_||void 0):_;(function N(A,z,G){E[G||A.type](A,z,N)})(m,d,a)}function u(m){return typeof m=="string"?function(d){return d===m}:m||function(){return!0}}var l=function(d,g){this.node=d,this.state=g};function p(m,d,g,_,a){g||(g=y);var E;(function N(A,z,G){var K=G||A.type;g[K](A,z,N),E!==A&&(d(A,z,K),E=A)})(m,_,a)}function f(m,d,g,_){g||(g=y);var a=[],E;(function N(A,z,G){var K=G||A.type,pe=A!==a[a.length-1];pe&&a.push(A),g[K](A,z,N),E!==A&&(d(A,z||a,a,K),E=A),pe&&a.pop()})(m,_)}function b(m,d,g,_,a,E){a||(a=y),_=u(_);try{(function N(A,z,G){var K=G||A.type;if((d==null||A.start<=d)&&(g==null||A.end>=g)&&a[K](A,z,N),(d==null||A.start===d)&&(g==null||A.end===g)&&_(K,A))throw new l(A,z)})(m,E)}catch(N){if(N instanceof l)return N;throw N}}function x(m,d,g,_,a){g=u(g),_||(_=y);try{(function E(N,A,z){var G=z||N.type;if(!(N.start>d||N.end<d)&&(_[G](N,A,E),g(G,N)))throw new l(N,A)})(m,a)}catch(E){if(E instanceof l)return E;throw E}}function C(m,d,g,_,a){g=u(g),_||(_=y);try{(function E(N,A,z){if(!(N.end<d)){var G=z||N.type;if(N.start>=d&&g(G,N))throw new l(N,A);_[G](N,A,E)}})(m,a)}catch(E){if(E instanceof l)return E;throw E}}function I(m,d,g,_,a){g=u(g),_||(_=y);var E;return function N(A,z,G){if(!(A.start>d)){var K=G||A.type;A.end<=d&&(!E||E.node.end<A.end)&&g(K,A)&&(E=new l(A,z)),_[K](A,z,N)}}(m,a),E}function R(m,d){var g=Object.create(d||y);for(var _ in m)g[_]=m[_];return g}function V(m,d,g){g(m,d)}function O(m,d,g){}var y={};y.Program=y.BlockStatement=y.StaticBlock=function(m,d,g){for(var _=0,a=m.body;_<a.length;_+=1){var E=a[_];g(E,d,"Statement")}},y.Statement=V,y.EmptyStatement=O,y.ExpressionStatement=y.ParenthesizedExpression=y.ChainExpression=function(m,d,g){return g(m.expression,d,"Expression")},y.IfStatement=function(m,d,g){g(m.test,d,"Expression"),g(m.consequent,d,"Statement"),m.alternate&&g(m.alternate,d,"Statement")},y.LabeledStatement=function(m,d,g){return g(m.body,d,"Statement")},y.BreakStatement=y.ContinueStatement=O,y.WithStatement=function(m,d,g){g(m.object,d,"Expression"),g(m.body,d,"Statement")},y.SwitchStatement=function(m,d,g){g(m.discriminant,d,"Expression");for(var _=0,a=m.cases;_<a.length;_+=1){var E=a[_];g(E,d)}},y.SwitchCase=function(m,d,g){m.test&&g(m.test,d,"Expression");for(var _=0,a=m.consequent;_<a.length;_+=1){var E=a[_];g(E,d,"Statement")}},y.ReturnStatement=y.YieldExpression=y.AwaitExpression=function(m,d,g){m.argument&&g(m.argument,d,"Expression")},y.ThrowStatement=y.SpreadElement=function(m,d,g){return g(m.argument,d,"Expression")},y.TryStatement=function(m,d,g){g(m.block,d,"Statement"),m.handler&&g(m.handler,d),m.finalizer&&g(m.finalizer,d,"Statement")},y.CatchClause=function(m,d,g){m.param&&g(m.param,d,"Pattern"),g(m.body,d,"Statement")},y.WhileStatement=y.DoWhileStatement=function(m,d,g){g(m.test,d,"Expression"),g(m.body,d,"Statement")},y.ForStatement=function(m,d,g){m.init&&g(m.init,d,"ForInit"),m.test&&g(m.test,d,"Expression"),m.update&&g(m.update,d,"Expression"),g(m.body,d,"Statement")},y.ForInStatement=y.ForOfStatement=function(m,d,g){g(m.left,d,"ForInit"),g(m.right,d,"Expression"),g(m.body,d,"Statement")},y.ForInit=function(m,d,g){m.type==="VariableDeclaration"?g(m,d):g(m,d,"Expression")},y.DebuggerStatement=O,y.FunctionDeclaration=function(m,d,g){return g(m,d,"Function")},y.VariableDeclaration=function(m,d,g){for(var _=0,a=m.declarations;_<a.length;_+=1){var E=a[_];g(E,d)}},y.VariableDeclarator=function(m,d,g){g(m.id,d,"Pattern"),m.init&&g(m.init,d,"Expression")},y.Function=function(m,d,g){m.id&&g(m.id,d,"Pattern");for(var _=0,a=m.params;_<a.length;_+=1){var E=a[_];g(E,d,"Pattern")}g(m.body,d,m.expression?"Expression":"Statement")},y.Pattern=function(m,d,g){m.type==="Identifier"?g(m,d,"VariablePattern"):m.type==="MemberExpression"?g(m,d,"MemberPattern"):g(m,d)},y.VariablePattern=O,y.MemberPattern=V,y.RestElement=function(m,d,g){return g(m.argument,d,"Pattern")},y.ArrayPattern=function(m,d,g){for(var _=0,a=m.elements;_<a.length;_+=1){var E=a[_];E&&g(E,d,"Pattern")}},y.ObjectPattern=function(m,d,g){for(var _=0,a=m.properties;_<a.length;_+=1){var E=a[_];E.type==="Property"?(E.computed&&g(E.key,d,"Expression"),g(E.value,d,"Pattern")):E.type==="RestElement"&&g(E.argument,d,"Pattern")}},y.Expression=V,y.ThisExpression=y.Super=y.MetaProperty=O,y.ArrayExpression=function(m,d,g){for(var _=0,a=m.elements;_<a.length;_+=1){var E=a[_];E&&g(E,d,"Expression")}},y.ObjectExpression=function(m,d,g){for(var _=0,a=m.properties;_<a.length;_+=1){var E=a[_];g(E,d)}},y.FunctionExpression=y.ArrowFunctionExpression=y.FunctionDeclaration,y.SequenceExpression=function(m,d,g){for(var _=0,a=m.expressions;_<a.length;_+=1){var E=a[_];g(E,d,"Expression")}},y.TemplateLiteral=function(m,d,g){for(var _=0,a=m.quasis;_<a.length;_+=1){var E=a[_];g(E,d)}for(var N=0,A=m.expressions;N<A.length;N+=1){var z=A[N];g(z,d,"Expression")}},y.TemplateElement=O,y.UnaryExpression=y.UpdateExpression=function(m,d,g){g(m.argument,d,"Expression")},y.BinaryExpression=y.LogicalExpression=function(m,d,g){g(m.left,d,"Expression"),g(m.right,d,"Expression")},y.AssignmentExpression=y.AssignmentPattern=function(m,d,g){g(m.left,d,"Pattern"),g(m.right,d,"Expression")},y.ConditionalExpression=function(m,d,g){g(m.test,d,"Expression"),g(m.consequent,d,"Expression"),g(m.alternate,d,"Expression")},y.NewExpression=y.CallExpression=function(m,d,g){if(g(m.callee,d,"Expression"),m.arguments)for(var _=0,a=m.arguments;_<a.length;_+=1){var E=a[_];g(E,d,"Expression")}},y.MemberExpression=function(m,d,g){g(m.object,d,"Expression"),m.computed&&g(m.property,d,"Expression")},y.ExportNamedDeclaration=y.ExportDefaultDeclaration=function(m,d,g){m.declaration&&g(m.declaration,d,m.type==="ExportNamedDeclaration"||m.declaration.id?"Statement":"Expression"),m.source&&g(m.source,d,"Expression")},y.ExportAllDeclaration=function(m,d,g){m.exported&&g(m.exported,d),g(m.source,d,"Expression")},y.ImportDeclaration=function(m,d,g){for(var _=0,a=m.specifiers;_<a.length;_+=1){var E=a[_];g(E,d)}g(m.source,d,"Expression")},y.ImportExpression=function(m,d,g){g(m.source,d,"Expression")},y.ImportSpecifier=y.ImportDefaultSpecifier=y.ImportNamespaceSpecifier=y.Identifier=y.PrivateIdentifier=y.Literal=O,y.TaggedTemplateExpression=function(m,d,g){g(m.tag,d,"Expression"),g(m.quasi,d,"Expression")},y.ClassDeclaration=y.ClassExpression=function(m,d,g){return g(m,d,"Class")},y.Class=function(m,d,g){m.id&&g(m.id,d,"Pattern"),m.superClass&&g(m.superClass,d,"Expression"),g(m.body,d)},y.ClassBody=function(m,d,g){for(var _=0,a=m.body;_<a.length;_+=1){var E=a[_];g(E,d)}},y.MethodDefinition=y.PropertyDefinition=y.Property=function(m,d,g){m.computed&&g(m.key,d,"Expression"),m.value&&g(m.value,d,"Expression")},c.ancestor=i,c.base=y,c.findNodeAfter=C,c.findNodeAround=x,c.findNodeAt=b,c.findNodeBefore=I,c.full=p,c.fullAncestor=f,c.make=R,c.recursive=s,c.simple=r})});var Yt=he(Dr=>{"use strict";var{Parser:fo,isNewLine:mo,getLineInfo:go}=Dn(),{full:yo}=jn(),ot="VM2_INTERNAL_STATE_DO_NOT_USE_OR_PROGRAM_WILL_FAIL";function Mr(c,r){if(!c)throw new Error(`None existent node expected '${r}'`);if(c.type!==r)throw new Error(`Invalid node type '${c.type}' expected '${r}'`);return c}function qn(c,r,i,s,u){let l=go(r,s),p=s;for(;p<r.length&&!mo(r.charCodeAt(p));)p++;let f=u.start===s?u.end:s+1;(!f||f>p)&&(f=p);let b=f-s;if(b<=0&&(b=1),c==="Unexpected token"){let R=u.type;R.label==="name"||R.label==="privateId"?c="Unexpected identifier":R.label==="eof"?c="Unexpected end of input":R.label==="num"?c="Unexpected number":R.label==="string"?c="Unexpected string":R.label==="regexp"?(c="Unexpected token '/'",b=1):c=`Unexpected token '${u.value||R.label}'`}let x=new SyntaxError(c);if(!i)return x;let C=r.slice(s-l.column,p),I=C.slice(0,l.column).replace(/\S/g," ")+"^".repeat(b);return x.stack=`${i}:${l.line}
|
|
10
|
+
${C}
|
|
11
|
+
${I}
|
|
12
|
+
|
|
13
|
+
${x.stack}`,x}function xo(c,r,i,s,u){let l,p;if(c===null){if(l=r,!/\b(?:catch|import|async)\b/.test(l))return{__proto__:null,code:l,hasAsync:!1}}else l=i?"(async function":"(function",s&&(l+="*"),l+=" anonymous(",l+=c,p=l.length,l+=`
|
|
14
|
+
) {
|
|
15
|
+
`,l+=r,l+=`
|
|
16
|
+
})`;let f=new fo({__proto__:null,ecmaVersion:2022,allowAwaitOutsideFunction:c===null&&i,allowReturnOutsideFunction:c===null},l),b;try{b=f.parse()}catch(d){if(d instanceof SyntaxError&&d.pos!==void 0){let g=d.message,_=g.match(/^(.*) \(\d+:\d+\)$/);_&&(g=_[1]),d=qn(g,l,u,d.pos,f)}throw d}if(c!==null){let d=Mr(b,"Program").body;if(d.length!==1)throw new SyntaxError("Single function literal required");let g=d[0];if(g.type!=="ExpressionStatement")throw new SyntaxError("Single function literal required");let _=g.expression;if(_.type!=="FunctionExpression")throw new SyntaxError("Single function literal required");if(_.body.start!==p+3)throw new SyntaxError("Unexpected end of arg string")}let x=[],C=!1,I=-100,R=100,V,O="VM2_INTERNAL_TMPNAME";if(yo(b,(d,g,_)=>{_==="Function"&&d.async&&(C=!0);let a=d.type;if(a==="CatchClause"){let E=d.param;if(E)if(E.type==="Identifier"){let N=Mr(E,"Identifier").name,A=Mr(d.body,"BlockStatement");A.body.length>0&&x.push({__proto__:null,pos:A.body[0].start,order:I,coder:()=>`${N}=${ot}.handleException(${N});`})}else x.push({__proto__:null,pos:d.start,order:R,coder:()=>`catch(${O}){${O}=${ot}.handleException(${O});try{throw ${O};}`}),x.push({__proto__:null,pos:d.body.end,order:I,coder:()=>"}"})}else a==="WithStatement"?(x.push({__proto__:null,pos:d.object.start,order:I,coder:()=>ot+".wrapWith("}),x.push({__proto__:null,pos:d.object.end,order:R,coder:()=>")"})):a==="Identifier"?d.name===ot?(V===void 0||V.start>d.start)&&(V=d):d.name.startsWith(O)&&(O=d.name+"_UNIQUE"):a==="ImportExpression"&&x.push({__proto__:null,pos:d.start,order:R,coder:()=>ot+"."})}),V)throw qn("Use of internal vm2 state variable",l,u,V.start,{__proto__:null,start:V.start,end:V.end});if(x.length===0)return{__proto__:null,code:l,hasAsync:C};x.sort((d,g)=>d.pos==g.pos?d.order-g.order:d.pos-g.pos);let y="",m=0;for(let d=0;d<x.length;d++){let g=x[d];y+=l.substring(m,g.pos)+g.coder(),m=g.pos}return y+=l.substring(m),{__proto__:null,code:y,hasAsync:C}}Dr.INTERNAL_STATE_NAME=ot;Dr.transformer=xo});var ut=he(_t=>{"use strict";var{Script:vo}=ne("vm"),{lookupCompiler:bo,removeShebang:wo}=wt(),{transformer:_o}=Yt(),Co=Object.defineProperties,qr="(function (exports, require, module, __filename, __dirname) { ",$n=qr+'"use strict"; ',Ur=`
|
|
17
|
+
});`,jr=class{constructor(r,i){let s=`${r}`,u,l;arguments.length===2?typeof i=="object"?(l=i||{__proto__:null},u=l.filename):(l={__proto__:null},u=i):arguments.length>2?(l=arguments[2]||{__proto__:null},u=i||l.filename):l={__proto__:null};let{compiler:p="javascript",lineOffset:f=0,columnOffset:b=0}=l,x=bo(p);Co(this,{__proto__:null,code:{__proto__:null,get(){return this._prefix+this._code+this._suffix},set(C){let I=String(C);I===this._code&&this._prefix===""&&this._suffix===""||(this._code=I,this._prefix="",this._suffix="",this._compiledVM=null,this._compiledNodeVM=null,this._compiledCode=null)},enumerable:!0},filename:{__proto__:null,value:u||"vm.js",enumerable:!0},lineOffset:{__proto__:null,value:f,enumerable:!0},columnOffset:{__proto__:null,value:b,enumerable:!0},compiler:{__proto__:null,value:p,enumerable:!0},_code:{__proto__:null,value:s,writable:!0},_prefix:{__proto__:null,value:"",writable:!0},_suffix:{__proto__:null,value:"",writable:!0},_compiledVM:{__proto__:null,value:null,writable:!0},_compiledNodeVM:{__proto__:null,value:null,writable:!0},_compiledNodeVMStrict:{__proto__:null,value:null,writable:!0},_compiledCode:{__proto__:null,value:null,writable:!0},_hasAsync:{__proto__:null,value:!1,writable:!0},_compiler:{__proto__:null,value:x}})}wrap(r,i){let s=`${r}`,u=`${i}`;return this._prefix===s&&this._suffix===u?this:(this._prefix=s,this._suffix=u,this._compiledVM=null,this._compiledNodeVM=null,this._compiledNodeVMStrict=null,this)}compile(){return this._compileVM(),this}getCompiledCode(){if(!this._compiledCode){let r=this._compiler(this._prefix+wo(this._code)+this._suffix,this.filename),i=_o(null,r,!1,!1,this.filename);this._compiledCode=i.code,this._hasAsync=i.hasAsync}return this._compiledCode}_compile(r,i){return new vo(r+this.getCompiledCode()+i,{__proto__:null,filename:this.filename,displayErrors:!1,lineOffset:this.lineOffset,columnOffset:this.columnOffset})}_compileVM(){let r=this._compiledVM;return r||(this._compiledVM=r=this._compile("","")),r}_compileNodeVM(){let r=this._compiledNodeVM;return r||(this._compiledNodeVM=r=this._compile(qr,Ur)),r}_compileNodeVMStrict(){let r=this._compiledNodeVMStrict;return r||(this._compiledNodeVMStrict=r=this._compile($n,Ur)),r}};_t.MODULE_PREFIX=qr;_t.STRICT_MODULE_PREFIX=$n;_t.MODULE_SUFFIX=Ur;_t.VMScript=jr});var er=he(Kn=>{"use strict";var St=ne("fs"),So=ne("path"),{Script:Qr,createContext:Hn}=ne("vm"),{EventEmitter:Eo}=ne("events"),{INSPECT_MAX_BYTES:Ao}=ne("buffer"),{createBridge:Io,VMError:Zt}=He(),{transformer:zn,INTERNAL_STATE_NAME:To}=Yt(),{lookupCompiler:ko}=wt(),{VMScript:Po}=ut(),{inspect:Ro}=ne("util"),No=Object.defineProperties,Vo=Object.freeze({Buffer,Function,Object,transformAndCheck:Oo,INSPECT_MAX_BYTES:Ao,INTERNAL_STATE_NAME:To});function ct(c,r){return new Qr(r,{__proto__:null,filename:c,displayErrors:!1})}var ze=Object.freeze({__proto__:null,displayErrors:!1});function $r(c){if(!c)throw new Zt("Async not available")}function Oo(c,r,i,s,u){let l=zn(c,r,i,s,void 0);return $r(u||!l.hasAsync),l.code}var Ct=null,Gn=null;function Wo(c,r){Ct||(Ct=Hn(),Gn=new Qr("fn()",{__proto__:null,filename:"timeout_bridge.js",displayErrors:!1})),Ct.fn=c;try{return Gn.runInContext(Ct,{__proto__:null,displayErrors:!1,timeout:r})}finally{Ct.fn=null}}var Bo=ct(`${__dirname}/bridge.js`,`(function(global) {"use strict"; const exports = {};${St.readFileSync(`${__dirname}/bridge.js`,"utf8")}
|
|
18
|
+
return exports;})`),Fo=ct(`${__dirname}/setup-sandbox.js`,`(function(global, host, bridge, data, context) { ${St.readFileSync(`${__dirname}/setup-sandbox.js`,"utf8")}
|
|
19
|
+
})`),Lo=ct("get_global.js","this"),Gr=null,Hr=null,zr=null;try{Gr=ct("get_generator_function.js","(function*(){}).constructor")}catch{}try{Hr=ct("get_async_function.js","(async function(){}).constructor")}catch{}try{zr=ct("get_async_generator_function.js","(async function*(){}).constructor")}catch{}var Kr=class extends Eo{constructor(r={}){super();let{timeout:i,sandbox:s,compiler:u="javascript",allowAsync:l=!0}=r,p=r.eval!==!1,f=r.wasm!==!1,b=l&&!r.fixAsync;if(s&&typeof s!="object")throw new Zt("Sandbox must be object.");let x=ko(u),C=Hn(void 0,{__proto__:null,codeGeneration:{__proto__:null,strings:p,wasm:f}}),I=Lo.runInContext(C,ze),{createBridge:R}=Bo.runInContext(C,ze)(I),V=Io(R,()=>{}),O={__proto__:null,allowAsync:b};Gr&&(O.GeneratorFunction=Gr.runInContext(C,ze)),Hr&&(O.AsyncFunction=Hr.runInContext(C,ze)),zr&&(O.AsyncGeneratorFunction=zr.runInContext(C,ze));let y=Fo.runInContext(C,ze)(I,Vo,V.other,O,C),m=E=>{let N;try{N=E.runInContext(C,ze)}catch(A){throw V.from(A)}return V.from(N)},d=(E,N)=>{try{y.readonly(E,N)}catch(A){throw V.from(A)}return E},g=E=>{let N=V.other;try{N.fromWithFactory(N.protectedFactory,E)}catch(A){throw V.from(A)}return E},_=(E,N)=>{let A=V.other,z;try{z=A.from(N),A.addProtoMapping(z,E)}catch(G){throw V.from(G)}V.addProtoMapping(E,z)},a=(E,N)=>{let A=V.other,z=()=>{let G=N(this);return V.addProtoMapping(E,G),G};try{let G=A.from(z);A.addProtoMappingFactory(G,E)}catch(G){throw V.from(G)}};No(this,{__proto__:null,timeout:{__proto__:null,value:i,writable:!0,enumerable:!0},compiler:{__proto__:null,value:u,enumerable:!0},sandbox:{__proto__:null,value:V.from(I),enumerable:!0},_runScript:{__proto__:null,value:m},_makeReadonly:{__proto__:null,value:d},_makeProtected:{__proto__:null,value:g},_addProtoMapping:{__proto__:null,value:_},_addProtoMappingFactory:{__proto__:null,value:a},_compiler:{__proto__:null,value:x},_allowAsync:{__proto__:null,value:b}}),this.readonly(Ro),s&&this.setGlobals(s)}setGlobals(r){for(let i in r)Object.prototype.hasOwnProperty.call(r,i)&&(this.sandbox[i]=r[i]);return this}setGlobal(r,i){return this.sandbox[r]=i,this}getGlobal(r){return this.sandbox[r]}freeze(r,i){return this.readonly(r),i&&(this.sandbox[i]=r),r}readonly(r,i){return this._makeReadonly(r,i)}protect(r,i){return this._makeProtected(r),i&&(this.sandbox[i]=r),r}run(r,i){let s,u;if(typeof i=="object"?u=i.filename:u=i,r instanceof Po)s=r._compileVM(),$r(this._allowAsync||!r._hasAsync);else{let l=u||"vm.js",p=this._compiler(r,l),f=zn(null,p,!1,!1,l);p=f.code,$r(this._allowAsync||!f.hasAsync),s=new Qr(p,{__proto__:null,filename:l,displayErrors:!1})}return this.timeout?Wo(()=>this._runScript(s),this.timeout):this._runScript(s)}runFile(r){let i=So.resolve(r);if(!St.existsSync(i))throw new Zt(`Script '${r}' not found.`);if(St.statSync(i).isDirectory())throw new Zt("Script must be file, got directory.");return this.run(St.readFileSync(i,"utf8"),i)}};Kn.VM=Kr});var rr=he(Yr=>{"use strict";var{VMError:Y}=He(),{VMScript:Mo}=ut(),{jsCopmiler:Do}=wt(),Uo=/^((?:@[^/\\%]+\/)?[^/\\%]+)(\/.*)?$/;function jo(c){let r=+c;return`${r}`!==c?!1:r>=0&&r<4294967295}var tr=class{constructor(r,i,s){this.fs=r,this.globalPaths=i,this.builtins=s}init(r){}isPathAllowed(r){return!1}checkAccess(r,i){if(!this.isPathAllowed(i))throw new Y(`Module '${i}' is not allowed to be required. The path is outside the border!`,"EDENIED")}pathIsRelative(r){if(r===""||r[0]!==".")return!1;if(r.length===1)return!0;let i=r[1]==="."?2:1;return r.length<=i?!1:this.fs.isSeparator(r[i])}pathIsAbsolute(r){return r!==""&&(this.fs.isSeparator(r[0])||this.fs.isAbsolute(r))}lookupPaths(r,i){return this.pathIsRelative(i)?[r.path||"."]:[...r.paths,...this.globalPaths]}getBuiltinModulesList(r){if(this.builtins===void 0)return[];let i=[];return this.builtins.forEach((s,u)=>{typeof s=="object"&&s.init(r),i.push(u)}),i}loadBuiltinModule(r,i){if(this.builtins===void 0)return;let s=this.builtins.get(i);if(s)return typeof s=="function"?s(r):s.load(r)}makeExtensionHandler(r,i){return(s,u)=>{u=this.fs.resolve(u),this.checkAccess(s,u),this[i](r,s,u)}}getExtensions(r){return{__proto__:null,".js":this.makeExtensionHandler(r,"loadJS"),".json":this.makeExtensionHandler(r,"loadJSON")," .node":this.makeExtensionHandler(r,"loadNode")}}loadJS(r,i,s){throw new Y(`Access denied to require '${s}'`,"EDENIED")}loadJSON(r,i,s){throw new Y(`Access denied to require '${s}'`,"EDENIED")}loadNode(r,i,s){throw new Y(`Access denied to require '${s}'`,"EDENIED")}registerModule(r,i,s,u,l){}resolve(r,i,s,u,l){return i.startsWith("node:")||this.builtins.has(i)?i:this.resolveFull(r,i,s,u,l)}resolveFull(r,i,s,u,l){throw new Y(`Cannot find module '${i}'`,"ENOTFOUND")}genLookupPaths(r){let i=[];for(;;){this.fs.basename(r)!=="node_modules"&&i.push(this.fs.join(r,"node_modules"));let u=this.fs.dirname(r);if(u==r)break;r=u}return i}};function qo(c,r){try{let i=c.statSync(r,{__proto__:null,throwIfNoEntry:!1});return i&&i.isDirectory()}catch{return!1}}function Qn(c,r){try{let i=c.statSync(r,{__proto__:null,throwIfNoEntry:!1});return i&&i.isFile()}catch{return!1}}function Jr(c,r){return c.readFileSync(r,{encoding:"utf8"})}function $o(c,r){return Qn(c,r)?Jr(c,r):void 0}var Xr=class extends tr{constructor(r,i,s){super(r,i,s),this.packageCache=new Map,this.scriptCache=new Map}getCompiler(r){return Do}isStrict(r){return!0}readScript(r){let i=this.scriptCache.get(r);return i||(i=new Mo(Jr(this.fs,r),{filename:r,compiler:this.getCompiler(r)}),this.scriptCache.set(r,i)),i}loadJS(r,i,s){let u=this.readScript(s);r.run(u,{filename:s,strict:this.isStrict(s),module:i,wrapper:"none",dirname:i.path})}loadJSON(r,i,s){let u=Jr(this.fs,s);i.exports=r._jsonParse(u)}loadNode(r,i,s){throw new Y("Native modules can be required only with context set to 'host'.")}customResolve(r,i,s){}resolveFull(r,i,s,u,l){let p=r.path||".",f=this.loadPackageSelf(i,p,u);if(f||i[0]==="#"&&(f=this.loadPackageImports(i,p,u),f))return f;if(this.pathIsAbsolute(i)){if(f=this.loadAsFileOrDirectory(i,u),f)return f;throw new Y(`Cannot find module '${i}'`,"ENOTFOUND")}else if(this.pathIsRelative(i)){if(typeof s=="object"&&s!==null){let x=s.paths;if(Array.isArray(x)){for(let C=0;C<x.length;C++)if(f=this.loadAsFileOrDirectory(this.fs.join(x[C],i),u),f)return f}else if(x===void 0){if(f=this.loadAsFileOrDirectory(this.fs.join(p,i),u),f)return f}else throw new Y("Invalid options.paths option.")}else if(f=this.loadAsFileOrDirectory(this.fs.join(p,i),u),f)return f;throw new Y(`Cannot find module '${i}'`,"ENOTFOUND")}let b;if(typeof s=="object"&&s!==null){let x=s.paths;if(Array.isArray(x)){b=[];for(let C=0;C<x.length;C++){let I=this.genLookupPaths(x[C]);for(let R=0;R<I.length;R++)b.includes(I[R])||b.push(I[R]);if(C===0){let R=this.globalPaths;for(let V=0;V<R.length;V++)b.includes(R[V])||b.push(R[V])}}}else if(x===void 0)b=[...r.paths,...this.globalPaths];else throw new Y("Invalid options.paths option.")}else b=[...r.paths,...this.globalPaths];return f=this.loadNodeModules(i,b,u),f||(f=this.customResolve(i,p,u),f)?f:super.resolveFull(r,i,s,u,l)}loadAsFileOrDirectory(r,i){let s=this.loadAsFile(r,i);return s||this.loadAsDirectory(r,i)}tryFile(r){return r=this.fs.resolve(r),this.isPathAllowed(r)&&Qn(this.fs,r)?r:void 0}tryWithExtension(r,i){for(let s=0;s<i.length;s++){let u=i[s];if(u!==this.fs.basename(u))continue;let l=this.tryFile(r+u);if(l)return l}}readPackage(r){let i=this.fs.resolve(this.fs.join(r,"package.json")),s=this.packageCache.get(i);if(s!==void 0)return s;if(!this.isPathAllowed(i))return;let u=$o(this.fs,i);if(!u)return this.packageCache.set(i,!1),!1;let l;try{l=JSON.parse(u)}catch(f){throw f.path=i,f.message="Error parsing "+i+": "+f.message,f}let p={name:l.name,main:l.main,exports:l.exports,imports:l.imports,type:l.type};return this.packageCache.set(i,p),p}readPackageScope(r){for(;;){let i=this.fs.dirname(r);if(i===r||this.fs.basename(i)==="node_modules")break;let u=this.readPackage(i);if(u)return{data:u,scope:i};r=i}return{data:void 0,scope:void 0}}loadAsFile(r,i){let s=this.tryFile(r);return s||this.tryWithExtension(r,i)}loadIndex(r,i){return this.tryWithExtension(this.fs.join(r,"index"),i)}loadAsPackage(r,i,s){if(i&&typeof i.main=="string"){let u=this.fs.join(r,i.main),l=this.loadAsFile(u,s);if(l||(l=this.loadIndex(u,s),l)||(l=this.loadIndex(r,s),l))return l;throw new Y(`Cannot find module '${r}'`,"ENOTFOUND")}return this.loadIndex(r,s)}loadAsDirectory(r,i){let s=this.readPackage(r);return this.loadAsPackage(r,s,i)}loadNodeModules(r,i,s){for(let u=0;u<i.length;u++){let l=i[u],p=this.loadPackageExports(r,l,s);if(p||(p=this.loadAsFile(l+"/"+r,s),p)||(p=this.loadAsDirectory(l+"/"+r,s),p))return p}}loadPackageImports(r,i,s){let{data:u,scope:l}=this.readPackageScope(i);if(!u||typeof u.imports!="object"||u.imports===null||Array.isArray(u.imports))return;if(r==="#"||r.startsWith("#/"))throw new Y(`Invalid module specifier '${r}'`,"ERR_INVALID_MODULE_SPECIFIER");let p=this.packageImportsExportsResolve(r,u.imports,l,!0,["node","require"],s);if(!p)throw new Y(`Package import not defined for '${r}'`,"ERR_PACKAGE_IMPORT_NOT_DEFINED");return this.resolveEsmMatch(p,r,s)}loadPackageExports(r,i,s){let u=r.match(Uo);if(!u)return;let l=this.fs.join(i,u[1]),p=this.readPackage(l);if(!p||!p.exports)return;let f=this.packageExportsResolve(l,"."+(u[2]||""),p.exports,["node","require"],s);return this.resolveEsmMatch(f,r,s)}loadPackageSelf(r,i,s){let{data:u,scope:l}=this.readPackageScope(i);if(!u||!u.exports||r!==u.name&&!r.startsWith(u.name+"/"))return;let p=this.packageExportsResolve(l,"."+r.slice(u.name.length),u.exports,["node","require"],s);return this.resolveEsmMatch(p,r,s)}resolveEsmMatch(r,i,s){let u=r,l=!0,p=u,f;if(l?f=this.tryFile(p):f=this.loadAsFileOrDirectory(p,s),f)return f;throw new Y(`Cannot find module '${i}'`,"ENOTFOUND")}packageExportsResolve(r,i,s,u,l){let p=!1;if(typeof s=="object"&&!Array.isArray(s)){let f=Object.getOwnPropertyNames(s);if(f.length>0){p=f[0][0]===".";for(let b=0;b<f.length;b++)if(p!==(f[b][0]==="."))throw new Y("Invalid package configuration","ERR_INVALID_PACKAGE_CONFIGURATION")}}if(i==="."){let f;if(typeof s=="string"||Array.isArray(s)||!p?f=s:p&&(f=s["."]),f){let b=this.packageTargetResolve(r,f,"",!1,!1,u,l);if(b)return b}}else if(p){let f=this.packageImportsExportsResolve(i,s,r,!1,u,l);if(f)return f}throw new Y(`Package path '${i}' is not exported`,"ERR_PACKAGE_PATH_NOT_EXPORTED")}packageImportsExportsResolve(r,i,s,u,l,p){let f=i[r];if(f&&r.indexOf("*")===-1)return this.packageTargetResolve(s,f,"",!1,u,l,p);let b=Object.getOwnPropertyNames(i),x="",C;for(let I=0;I<b.length;I++){let R=b[I];if(r.length<R.length)continue;let V=R.indexOf("*");if(V===-1)continue;let O=R.slice(0,V);if(r.startsWith(O)&&R.indexOf("*",V+1)===-1){let y=R.slice(V+1);r.endsWith(y)&&this.patternKeyCompare(x,R)===1&&(f=i[R],x=R,C=r.slice(O.length,r.length-y.length))}}return C?this.packageTargetResolve(s,f,C,!0,u,l,p):null}patternKeyCompare(r,i){let s=r.indexOf("*"),u=s===-1?r.length:s+1,l=i.indexOf("*"),p=l===-1?i.length:l+1;return u>p?-1:p>u||s===-1?1:l===-1||r.length>i.length?-1:i.length>r.length?1:0}packageTargetResolve(r,i,s,u,l,p,f){if(typeof i=="string"){if(!u&&s.length>0&&!i.endsWith("/"))throw new Y(`Invalid package specifier '${s}'`,"ERR_INVALID_MODULE_SPECIFIER");if(!i.startsWith("./")){if(l&&!i.startsWith("../")&&!i.startsWith("/")){let x=!1;try{new URL(i),x=!0}catch{}if(!x)return u?this.packageResolve(i.replace(/\*/g,s),r,p,f):this.packageResolve(this.fs.join(i,s),r,p,f)}throw new Y(`Invalid package target for '${s}'`,"ERR_INVALID_PACKAGE_TARGET")}if(i=decodeURI(i),i.split(/[/\\]/).slice(1).findIndex(x=>x==="."||x===".."||x.toLowerCase()==="node_modules")!==-1)throw new Y(`Invalid package target for '${s}'`,"ERR_INVALID_PACKAGE_TARGET");let b=this.fs.join(r,i);if(s=decodeURI(s),s.split(/[/\\]/).findIndex(x=>x==="."||x===".."||x.toLowerCase()==="node_modules")!==-1)throw new Y(`Invalid package specifier '${s}'`,"ERR_INVALID_MODULE_SPECIFIER");return u?b.replace(/\*/g,s):this.fs.join(b,s)}else if(Array.isArray(i)){if(i.length===0)return null;let b;for(let x=0;x<i.length;x++){let C=i[x],I;try{I=this.packageTargetResolve(r,C,s,u,l,p,f)}catch(R){if(R.code!=="ERR_INVALID_PACKAGE_TARGET")throw R;b=R;continue}if(I!==void 0)return I;I===null&&(b=null)}if(b==null)return b;throw b}else if(typeof i=="object"&&i!==null){let b=Object.getOwnPropertyNames(i);for(let x=0;x<b.length;x++){let C=b[x];if(jo(C))throw new Y(`Invalid package configuration for '${s}'`,"ERR_INVALID_PACKAGE_CONFIGURATION")}for(let x=0;x<b.length;x++){let C=b[x];if(C==="default"||p.includes(C)){let I=i[C],R=this.packageTargetResolve(r,I,s,u,l,p,f);if(R!==void 0)return R}}return}else if(i==null)return null;throw new Y(`Invalid package target for '${s}'`,"ERR_INVALID_PACKAGE_TARGET")}packageResolve(r,i,s,u){let l;if(r==="")throw new Y(`Invalid package specifier '${r}'`,"ERR_INVALID_MODULE_SPECIFIER");if(this.builtins.has(r))return"node:"+r;let p=r.indexOf("/");if(r[0]==="@"){if(p===-1)throw new Y(`Invalid package specifier '${r}'`,"ERR_INVALID_MODULE_SPECIFIER");p=r.indexOf("/",p+1)}if(l=p===-1?r:r.slice(0,p),p!==0&&(l[0]==="."||l.indexOf("\\")>=0||l.indexOf("%")>=0))throw new Y(`Invalid package specifier '${r}'`,"ERR_INVALID_MODULE_SPECIFIER");let f="."+r.slice(l.length);if(f[f.length-1]==="/")throw new Y(`Invalid package specifier '${r}'`,"ERR_INVALID_MODULE_SPECIFIER");let b=this.packageSelfResolve(l,f,i);if(b)return b;let x;for(;;){x=this.fs.resolve(this.fs.join(i,"node_modules",r));let I=this.fs.dirname(i);if(this.isPathAllowed(x)&&qo(this.fs,x))break;if(I===i)throw new Y(`Cannot find module '${r}'`,"ENOTFOUND");i=I}let C=this.readPackage(x);return C&&C.exports?this.packageExportsResolve(x,f,C.exports,s,u):f==="."?this.loadAsPackage(f,C,u):this.fs.join(x,f)}};Yr.Resolver=tr;Yr.DefaultResolver=Xr});var ii=he(ri=>{"use strict";var Ke=ne("path"),Zr=ne("fs"),ei=class{resolve(r){return Ke.resolve(r)}isSeparator(r){return r==="/"||r===Ke.sep}isAbsolute(r){return Ke.isAbsolute(r)}join(...r){return Ke.join(...r)}basename(r){return Ke.basename(r)}dirname(r){return Ke.dirname(r)}statSync(r,i){return Zr.statSync(r,i)}readFileSync(r,i){return Zr.readFileSync(r,i)}},ti=class{constructor({fs:r=Zr,path:i=Ke}={}){this.fs=r,this.path=i}resolve(r){return this.path.resolve(r)}isSeparator(r){return r==="/"||r===this.path.sep}isAbsolute(r){return this.path.isAbsolute(r)}join(...r){return this.path.join(...r)}basename(r){return this.path.basename(r)}dirname(r){return this.path.dirname(r)}statSync(r,i){return this.fs.statSync(r,i)}readFileSync(r,i){return this.fs.readFileSync(r,i)}};ri.DefaultFileSystem=ei;ri.VMFileSystem=ti});var Yn=he(ui=>{"use strict";var Go=ne("fs"),Ho=ne("module"),{EventEmitter:pt}=ne("events"),zo=ne("util"),{VMScript:oi}=ut(),{VM:Ko}=er(),Jn=new WeakMap;function Qo(c){return Jn.get(c)}var ni;function Jo(c){return ni||(ni=new oi("return buffer=>({Buffer: buffer});",{__proto__:null,filename:"buffer.js"})),c.run(ni,{__proto__:null,strict:!0,wrapper:"none"})(Buffer)}var si;function Xo(c){si||(si=new oi(`return function inherits(ctor, superCtor) {
|
|
20
|
+
ctor.super_ = superCtor;
|
|
21
|
+
Object.setPrototypeOf(ctor.prototype, superCtor.prototype);
|
|
22
|
+
}`,{__proto__:null,filename:"util.js"}));let r=c.run(si,{__proto__:null,strict:!0,wrapper:"none"}),i=Object.assign({},zo);return i.inherits=r,c.readonly(i)}var lt=(Ho.builtinModules||Object.getOwnPropertyNames(process.binding("natives"))).filter(c=>!c.startsWith("internal/")),Xn=null;if(pt.EventEmitterAsyncResource){let{AsyncResource:c}=ne("async_hooks"),r=Symbol("kEventEmitter");class i extends c{constructor(u,l,p){super(l,p),this[r]=u}get eventEmitter(){return this[r]}}Xn=i}var ai,Yo={events:{init(c){if(!ai){let s=Go.readFileSync(`${__dirname}/events.js`,"utf8");ai=new oi(`(function (fromhost) { const module = {}; module.exports={};{ ${s}
|
|
23
|
+
} return module.exports;})`,{filename:"events.js"})}let i=Ko.prototype.run.call(c,ai)(c.readonly({kErrorMonitor:pt.errorMonitor,once:pt.once,on:pt.on,getEventListeners:pt.getEventListeners,EventEmitterReferencingAsyncResource:Xn}));Jn.set(c,i),c._addProtoMapping(pt.prototype,i.EventEmitter.prototype)},load:Qo},buffer:Jo,util:Xo};function ir(c,r,i){if(c.has(r))return;let s=Yo[r];c.set(r,s||(u=>u.readonly(i(r))))}function Zo(c,r,i,s){let u=new Map;if(i){let l=Object.getOwnPropertyNames(i);for(let p=0;p<l.length;p++){let f=l[p];u.set(f,b=>b.readonly(i[f]))}}if(s){let l=Object.getOwnPropertyNames(s);for(let p=0;p<l.length;p++){let f=l[p];u.set(f,s[f])}}if(Array.isArray(c))if(c.indexOf("*")>=0)for(let p=0;p<lt.length;p++){let f=lt[p];c.indexOf(`-${f}`)===-1&&ir(u,f,r)}else for(let p=0;p<lt.length;p++){let f=lt[p];c.indexOf(f)!==-1&&ir(u,f,r)}else if(c)for(let l=0;l<lt.length;l++){let p=lt[l];c[p]&&ir(u,p,r)}return u}function eu(c,r){let i=new Map;for(let s=0;s<c.length;s++){let u=c[s];ir(i,u,r)}return i}ui.makeBuiltinsFromLegacyOptions=Zo;ui.makeBuiltins=eu});var fi=he(rs=>{"use strict";var{Resolver:ci,DefaultResolver:tu}=rr(),{VMError:ru}=He(),{DefaultFileSystem:iu}=ii(),{makeBuiltinsFromLegacyOptions:Zn}=Yn(),{jsCompiler:nu}=wt();function es(c){return ne(c)}function li(c){return c.replace(/[.*+\-?^${}()|[\]\\]/g,"\\$&")}function ts(c){return li(c).replace(/\\\\|\//g,"[\\\\/]").replace(/\\\*\\\*/g,".*").replace(/\\\*/g,"[^\\\\/]*").replace(/\\\?/g,"[^\\\\/]")}function su(c){let r=ts(c);return new RegExp(`[\\\\/]node_modules[\\\\/]${r}(?:[\\\\/](?!(?:.*[\\\\/])?node_modules[\\\\/]).*)?$`)}var nr=class extends tu{constructor(r,i,s,u,l,p,f,b,x){super(r,i,s),this.rootPaths=u,this.pathContext=l,this.customResolver=p,this.hostRequire=f,this.compiler=b,this.strict=x}isPathAllowed(r){return this.rootPaths===void 0||this.rootPaths.some(i=>{if(!r.startsWith(i))return!1;let s=i.length;return r.length===s||s>0&&this.fs.isSeparator(i[s-1])?!0:this.fs.isSeparator(r[s])})}loadJS(r,i,s){if(this.pathContext(s,"js")!=="host")return super.loadJS(r,i,s);let u=this.hostRequire(s);i.exports=r.readonly(u)}loadNode(r,i,s){if(this.pathContext(s,"node")!=="host")return super.loadNode(r,i,s);let u=this.hostRequire(s);i.exports=r.readonly(u)}customResolve(r,i,s){if(this.customResolver===void 0)return;let u=this.customResolver(r,i);if(!u)return;if(typeof u=="string")return this.loadAsFileOrDirectory(u,s);let{module:l=r,path:p}=u;return this.loadNodeModules(l,[p],s)}getCompiler(r){return this.compiler}isStrict(r){return this.strict}},pi=class extends nr{constructor(r,i,s,u,l,p,f,b,x,C,I){super(r,i,s,u,l,p,f,b,x),this.externals=C.map(su),this.externalCache=C.map(R=>new RegExp(ts(R))),this.currMod=void 0,this.trustedMods=new WeakMap,this.allowTransitive=I}isPathAllowed(r){return this.isPathAllowedForModule(r,this.currMod)}isPathAllowedForModule(r,i){if(!super.isPathAllowed(r))return!1;if(i){if(i.allowTransitive)return!0;if(r.startsWith(i.path)){let s=r.slice(i.path.length);if(!/(?:^|[\\\\/])node_modules(?:$|[\\\\/])/.test(s))return!0}}return this.externals.some(s=>s.test(r))}registerModule(r,i,s,u,l){let p=this.trustedMods.get(u);this.trustedMods.set(r,{filename:i,path:s,paths:this.genLookupPaths(s),allowTransitive:this.allowTransitive&&(l&&p&&p.allowTransitive||this.externals.some(f=>f.test(i)))})}resolveFull(r,i,s,u,l){if(this.currMod=void 0,!l)return super.resolveFull(r,i,s,u,!1);let p=this.trustedMods.get(r);if(!p||r.path!==p.path)return super.resolveFull(r,i,s,u,!1);let f=[...r.paths];if(f.length!==p.paths.length)return super.resolveFull(r,i,s,u,!1);for(let b=0;b<f.length;b++)if(f[b]!==p.paths[b])return super.resolveFull(r,i,s,u,!1);try{return this.currMod=p,super.resolveFull(p,i,s,u,!0)}finally{this.currMod=void 0}}checkAccess(r,i){let s=this.trustedMods.get(r);if((!s||s.filename!==i)&&!this.isPathAllowedForModule(i,void 0))throw new ru(`Module '${i}' is not allowed to be required. The path is outside the border!`,"EDENIED")}loadJS(r,i,s){if(this.pathContext(s,"js")!=="host"){let u=this.trustedMods.get(i),l=this.readScript(s);r.run(l,{filename:s,strict:this.isStrict(s),module:i,wrapper:"none",dirname:u?u.path:i.path})}else{let u=this.hostRequire(s);i.exports=r.readonly(u)}}customResolve(r,i,s){if(this.customResolver===void 0||!(this.pathIsAbsolute(r)||this.pathIsRelative(r))&&!this.externalCache.some(f=>f.test(r)))return;let u=this.customResolver(r,i);if(!u)return;if(typeof u=="string")return this.externals.push(new RegExp("^"+li(u))),this.loadAsFileOrDirectory(u,s);let{module:l=r,path:p}=u;return this.externals.push(new RegExp("^"+li(p))),this.loadNodeModules(l,[p],s)}},hi=new iu,au=new ci(hi,[],new Map);function ou(c,r,i){if(!c){if(!r)return au;let d=Zn(void 0,es,void 0,r);return new ci(hi,[],d)}let{builtin:s,mock:u,external:l,root:p,resolve:f,customRequire:b=es,context:x="host",strict:C=!0,fs:I=hi}=c,R=Zn(s,b,u,r);if(!l)return new ci(I,[],R);i||(i=nu);let V=p?(Array.isArray(p)?p:[p]).map(d=>I.resolve(d)):void 0,O=typeof x=="function"?x:()=>x;if(typeof l!="object")return new nr(I,[],R,V,O,f,b,i,C);let y=!1,m;return Array.isArray(l)?m=l:(m=l.modules,y=x!=="host"&&l.transitive),new pi(I,[],R,V,O,f,b,i,C,m,y)}rs.makeResolverFromLegacyOptions=ou});var ls=he(cs=>{"use strict";var sr=ne("fs"),is=ne("path"),{Script:as}=ne("vm"),{VMError:ht}=He(),{VMScript:uu,MODULE_PREFIX:cu,STRICT_MODULE_PREFIX:lu,MODULE_SUFFIX:pu}=ut(),{transformer:hu}=Yt(),{VM:os}=er(),{makeResolverFromLegacyOptions:fu}=fi(),{Resolver:du}=rr(),ns=Object.defineProperty,mu=Object.defineProperties,ss=Object.freeze({__proto__:null,version:parseInt(process.versions.node.split(".")[0]),process,console,setTimeout,setInterval,setImmediate,clearTimeout,clearInterval,clearImmediate});function us(c,r){return new as(r,{__proto__:null,filename:c,displayErrors:!1})}var di=null,mi=null,gu=Object.freeze({__proto__:null,vm2:bu});function yu(c,r,i){let s={__proto__:null},u=r.makeExtensionHandler(c,"loadJS");for(let l=0;l<i.length;l++)s["."+i[l]]=u;return s[".json"]||(s[".json"]=r.makeExtensionHandler(c,"loadJSON")),s[".node"]||(s[".node"]=r.makeExtensionHandler(c,"loadNode")),s}function xu(c){if(c===void 0)return;if(!Array.isArray(c))return!0;let r=[...c];return r.some(i=>typeof i!="string")?!0:r}function vu(c){return c===void 0||c==null||typeof c!="object"&&typeof c!="function"?c:{unsafeOptions:c,paths:xu(c.paths)}}var ar=class c extends os{constructor(r={}){let{compiler:i,eval:s,wasm:u,console:l="inherit",require:p=!1,nesting:f=!1,wrapper:b="commonjs",sourceExtensions:x=["js"],argv:C,env:I,strict:R=!1,sandbox:V}=r;if(V&&typeof V!="object")throw new ht("Sandbox must be an object.");super({__proto__:null,compiler:i,eval:s,wasm:u});let O=p instanceof du,y=O?p:fu(p,f&&gu,this._compiler);ns(this,"options",{__proto__:null,value:{console:l,require:p,nesting:f,wrapper:b,sourceExtensions:x,strict:R}}),ns(this,"resolver",{__proto__:null,value:y,enumerable:!0}),di||(di=us(`${__dirname}/setup-node-sandbox.js`,`(function (host, data) { ${sr.readFileSync(`${__dirname}/setup-node-sandbox.js`,"utf8")}
|
|
24
|
+
})`));let m=this._runScript(di),d=yu(this,y,x);this.readonly(ss);let{Module:g,jsonParse:_,createRequireForModule:a,requireImpl:E}=m(ss,{__proto__:null,argv:C,env:I,console:l,extensions:d,emitArgs:(N,A)=>{if(typeof N!="string"&&typeof N!="symbol")throw new Error("Event is not a string");return this.emit(N,...A)},globalPaths:[...y.globalPaths],getLookupPathsFor:N=>typeof N!="string"?[]:[...y.genLookupPaths(N)],resolve:(N,A,z,G,K)=>{if(typeof A!="string")throw new Error("Id is not a string");let pe=Object.getOwnPropertyNames(G);return y.resolve(N,A,vu(z),pe,!!K)},lookupPaths:(N,A)=>{if(typeof A!="string")throw new Error("Id is not a string");return[...y.lookupPaths(N,A)]},loadBuiltinModule:N=>{if(typeof N!="string")throw new Error("Id is not a string");return y.loadBuiltinModule(this,N)},registerModule:(N,A,z,G,K)=>y.registerModule(N,A,z,G,K),builtinModules:[...y.getBuiltinModulesList(this)],dirname:N=>typeof N!="string"?N:y.fs.dirname(N),basename:N=>typeof N!="string"?N:y.fs.basename(N)});if(mu(this,{__proto__:null,_Module:{__proto__:null,value:g},_jsonParse:{__proto__:null,value:_},_createRequireForModule:{__proto__:null,value:a},_requireImpl:{__proto__:null,value:E},_cacheRequireModule:{__proto__:null,value:null,writable:!0}}),y.init(this),V&&this.setGlobals(V),!O&&p&&p.import)if(Array.isArray(p.import))for(let N=0,A=p.import.length;N<A;N++)this.require(p.import[N]);else this.require(p.import)}get _resolver(){return this.resolver}call(r,...i){if(typeof r=="function")return r(...i);throw new ht("Unrecognized method type.")}require(r){let i=this.resolver.fs.resolve("."),s=this._cacheRequireModule;if(!s||s.path!==i){let u=this.resolver.fs.join(i,"/vm.js");s=new this._Module(u,i),this.resolver.registerModule(s,u,i,null,!1),this._cacheRequireModule=s}return this._requireImpl(s,r,!0)}run(r,i){let s,u;typeof i=="object"?u=i.filename:(u=i,i={__proto__:null});let{strict:l=this.options.strict,wrapper:p=this.options.wrapper,module:f,require:b,dirname:x=null}=i,C=f,I=x;if(r instanceof uu){if(s=l?r._compileNodeVMStrict():r._compileNodeVM(),!C){let y=this.resolver.fs.resolve(r.filename);I=this.resolver.fs.dirname(y),C=new this._Module(y,I),this.resolver.registerModule(C,y,I,null,!1)}}else{let y=u||"vm.js";if(!C)if(u){let g=this.resolver.fs.resolve(u);I=this.resolver.fs.dirname(g),C=new this._Module(g,I),this.resolver.registerModule(C,g,I,null,!1)}else C=new this._Module(null,null),C.id=y;let m=l?lu:cu,d=this._compiler(r,y);d=hu(null,d,!1,!1,y).code,s=new as(m+d+pu,{__proto__:null,filename:y,displayErrors:!1})}let R=this._runScript(s),V=b||this._createRequireForModule(C),O=Reflect.apply(R,this.sandbox,[C.exports,V,C,u,I]);return p==="commonjs"?C.exports:O}static code(r,i,s){let u;if(i!=null)if(typeof i=="object")s=i,u=s.filename;else if(typeof i=="string")u=i;else throw new ht("Invalid arguments.");else typeof s=="object"&&(u=s.filename);if(arguments.length>3)throw new ht("Invalid number of arguments.");let l=typeof u=="string"?is.resolve(u):void 0;return new c(s).run(r,l)}static file(r,i){let s=is.resolve(r);if(!sr.existsSync(s))throw new ht(`Script '${r}' not found.`);if(sr.statSync(s).isDirectory())throw new ht("Script must be file, got directory.");return new c(i).run(sr.readFileSync(s,"utf8"),s)}};function bu(c){return mi||(mi=us("nesting.js","(vm, nodevm) => ({VM: vm, NodeVM: nodevm})")),c._runScript(mi)(c.readonly(os),c.readonly(ar))}cs.NodeVM=ar});var ps=he(je=>{"use strict";var{VMError:wu}=He(),{VMScript:_u}=ut(),{VM:Cu}=er(),{NodeVM:Su}=ls(),{VMFileSystem:Eu}=ii(),{Resolver:Au}=rr(),{makeResolverFromLegacyOptions:Iu}=fi();je.VMError=wu;je.VMScript=_u;je.NodeVM=Su;je.VM=Cu;je.VMFileSystem=Eu;je.Resolver=Au;je.makeResolverFromLegacyOptions=Iu});var fs=he((Zl,hs)=>{"use strict";if(parseInt(process.versions.node.split(".")[0])<6)throw new Error("vm2 requires Node.js version 6 or newer.");hs.exports=ps()});import{Address as en,TransactionsFactoryConfig as ua,TransferTransactionsFactory as ca}from"@multiversx/sdk-core";import la from"ajv";var U={HttpProtocolPrefix:"http",IdentifierParamName:"warp",IdentifierParamSeparator:":",IdentifierType:{Alias:"alias",Hash:"hash"},Source:{UserWallet:"user:wallet"},Globals:{UserWallet:{Placeholder:"USER_WALLET",Accessor:c=>c.config.user?.wallet},ChainApiUrl:{Placeholder:"CHAIN_API",Accessor:c=>c.chain.apiUrl},ChainExplorerUrl:{Placeholder:"CHAIN_EXPLORER",Accessor:c=>c.chain.explorerUrl}},Vars:{Query:"query",Env:"env"},ArgParamsSeparator:":",ArgCompositeSeparator:"|",Transform:{Prefix:"transform:"},Egld:{Identifier:"EGLD",EsdtIdentifier:"EGLD-000000",DisplayName:"eGold",Decimals:18}};var tt={Warp:"2.0.1",Brand:"0.1.0",Abi:"0.1.0"},oe={LatestWarpSchemaUrl:`https://raw.githubusercontent.com/vLeapGroup/warps-specs/refs/heads/main/schemas/v${tt.Warp}.schema.json`,LatestBrandSchemaUrl:`https://raw.githubusercontent.com/vLeapGroup/warps-specs/refs/heads/main/schemas/brand/v${tt.Brand}.schema.json`,DefaultClientUrl:c=>c==="devnet"?"https://devnet.usewarp.to":c==="testnet"?"https://testnet.usewarp.to":"https://usewarp.to",SuperClientUrls:["https://usewarp.to","https://testnet.usewarp.to","https://devnet.usewarp.to"],MainChain:{Name:"multiversx",DisplayName:"MultiversX",ApiUrl:c=>c==="devnet"?"https://devnet-api.multiversx.com":c==="testnet"?"https://testnet-api.multiversx.com":"https://api.multiversx.com",ExplorerUrl:c=>c==="devnet"?"https://devnet-explorer.multiversx.com":c==="testnet"?"https://testnet-explorer.multiversx.com":"https://explorer.multiversx.com",BlockTime:c=>6e3,AddressHrp:"erd",ChainId:c=>c==="devnet"?"D":c==="testnet"?"T":"1"},Registry:{Contract:c=>c==="devnet"?"erd1qqqqqqqqqqqqqpgqje2f99vr6r7sk54thg03c9suzcvwr4nfl3tsfkdl36":c==="testnet"?"####":"erd1qqqqqqqqqqqqqpgq3mrpj3u6q7tejv6d7eqhnyd27n9v5c5tl3ts08mffe"},AvailableActionInputSources:["field","query",U.Source.UserWallet],AvailableActionInputTypes:["string","uint8","uint16","uint32","uint64","biguint","boolean","address"],AvailableActionInputPositions:["receiver","value","transfer","arg:1","arg:2","arg:3","arg:4","arg:5","arg:6","arg:7","arg:8","arg:9","arg:10","data","ignore"]};var se=c=>({name:oe.MainChain.Name,displayName:oe.MainChain.DisplayName,chainId:oe.MainChain.ChainId(c.env),blockTime:oe.MainChain.BlockTime(c.env),addressHrp:oe.MainChain.AddressHrp,apiUrl:oe.MainChain.ApiUrl(c.env),explorerUrl:oe.MainChain.ExplorerUrl(c.env)}),$u=(c,r)=>c.explorerUrl+(r?"/"+r:""),rt=c=>{if(c==="warp")return`warp:${tt.Warp}`;if(c==="brand")return`brand:${tt.Brand}`;if(c==="abi")return`abi:${tt.Abi}`;throw new Error(`getLatestProtocolIdentifier: Invalid protocol name: ${c}`)},xt=(c,r)=>c?.actions[r-1],fr=c=>({name:c.name.toString(),displayName:c.display_name.toString(),chainId:c.chain_id.toString(),blockTime:c.block_time.toNumber(),addressHrp:c.address_hrp.toString(),apiUrl:c.api_url.toString(),explorerUrl:c.explorer_url.toString()}),Wt=(c,r)=>{let i=c.toString(),[s,u=""]=i.split("."),l=Math.abs(r);if(r>0)return BigInt(s+u.padEnd(l,"0"));if(r<0){let p=s+u;if(l>=p.length)return 0n;let f=p.slice(0,-l)||"0";return BigInt(f)}else return i.includes(".")?BigInt(i.split(".")[0]):BigInt(i)},Qi=(c,r=100)=>{if(!c)return"";let i=c.replace(/<\/?(h[1-6])[^>]*>/gi," - ").replace(/<\/?(p|div|ul|ol|li|br|hr)[^>]*>/gi," ").replace(/<[^>]+>/g,"").replace(/\s+/g," ").trim();return i=i.startsWith("- ")?i.slice(2):i,i=i.length>r?i.substring(0,i.lastIndexOf(" ",r))+"...":i,i},Bt=(c,r)=>c.replace(/\{\{([^}]+)\}\}/g,(i,s)=>r[s]||"");import{DevnetEntrypoint as na,MainnetEntrypoint as sa,TestnetEntrypoint as aa}from"@multiversx/sdk-core";var vt=class{constructor(r="warp-cache"){this.prefix=r}getKey(r){return`${this.prefix}:${r}`}get(r){try{let i=localStorage.getItem(this.getKey(r));if(!i)return null;let s=JSON.parse(i);return Date.now()>s.expiresAt?(localStorage.removeItem(this.getKey(r)),null):s.value}catch{return null}}set(r,i,s){let u={value:i,expiresAt:Date.now()+s*1e3};localStorage.setItem(this.getKey(r),JSON.stringify(u))}forget(r){localStorage.removeItem(this.getKey(r))}clear(){for(let r=0;r<localStorage.length;r++){let i=localStorage.key(r);i?.startsWith(this.prefix)&&localStorage.removeItem(i)}}};var Le=class Le{get(r){let i=Le.cache.get(r);return i?Date.now()>i.expiresAt?(Le.cache.delete(r),null):i.value:null}set(r,i,s){let u=Date.now()+s*1e3;Le.cache.set(r,{value:i,expiresAt:u})}forget(r){Le.cache.delete(r)}clear(){Le.cache.clear()}};Le.cache=new Map;var bt=Le;var Ji={OneMinute:60,OneHour:60*60,OneDay:60*60*24,OneWeek:60*60*24*7,OneMonth:60*60*24*30,OneYear:60*60*24*365},Se={Warp:c=>`warp:${c}`,WarpAbi:c=>`warp-abi:${c}`,RegistryInfo:c=>`registry-info:${c}`,Brand:c=>`brand:${c}`,ChainInfo:c=>`chain:${c}`,ChainInfos:()=>"chains"},Me=class{constructor(r){this.strategy=this.selectStrategy(r)}selectStrategy(r){return r==="localStorage"?new vt:r==="memory"?new bt:typeof window<"u"&&window.localStorage?new vt:new bt}set(r,i,s){this.strategy.set(r,i,s)}get(r){return this.strategy.get(r)}forget(r){this.strategy.forget(r)}clear(){this.strategy.clear()}};import ia from"qr-code-styling";import{Address as Xi,TransactionsFactoryConfig as Ys,TransferTransactionsFactory as Zs}from"@multiversx/sdk-core";var it=class it{static info(...r){it.isTestEnv||console.info(...r)}static warn(...r){it.isTestEnv||console.warn(...r)}static error(...r){it.isTestEnv||console.error(...r)}};it.isTestEnv=typeof process<"u"&&process.env.JEST_WORKER_ID!==void 0;var fe=it;import Xs from"ajv";var Ft=class{constructor(r){this.config=r;this.config=r}async validate(r){let i=[];return i.push(...this.validateMaxOneValuePosition(r)),i.push(...this.validateVariableNamesAndResultNamesUppercase(r)),i.push(...this.validateAbiIsSetIfApplicable(r)),i.push(...await this.validateSchema(r)),{valid:i.length===0,errors:i}}validateMaxOneValuePosition(r){return r.actions.filter(s=>s.inputs?s.inputs.some(u=>u.position==="value"):!1).length>1?["Only one value position action is allowed"]:[]}validateVariableNamesAndResultNamesUppercase(r){let i=[],s=(u,l)=>{u&&Object.keys(u).forEach(p=>{p!==p.toUpperCase()&&i.push(`${l} name '${p}' must be uppercase`)})};return s(r.vars,"Variable"),s(r.results,"Result"),i}validateAbiIsSetIfApplicable(r){let i=r.actions.some(l=>l.type==="contract"),s=r.actions.some(l=>l.type==="query");if(!i&&!s)return[];let u=r.actions.some(l=>l.abi);return r.results&&!u?["ABI is required when results are present for contract or query actions"]:[]}async validateSchema(r){try{let i=this.config.schema?.warp||oe.LatestWarpSchemaUrl,u=await(await fetch(i)).json(),l=new Xs,p=l.compile(u);return p(r)?[]:[`Schema validation failed: ${l.errorsText(p.errors)}`]}catch(i){return[`Schema validation failed: ${i instanceof Error?i.message:String(i)}`]}}};var Lt=class{constructor(r){this.pendingWarp={protocol:rt("warp"),name:"",title:"",description:null,preview:"",actions:[]};this.config=r,this.cache=new Me(r.cache?.type)}createInscriptionTransaction(r){if(!this.config.user?.wallet)throw new Error("WarpBuilder: user address not set");let i=se(this.config),s=new Ys({chainID:i.chainId}),u=new Zs({config:s}),l=Xi.newFromBech32(this.config.user.wallet),p=JSON.stringify(r),f=u.createTransactionForTransfer(l,{receiver:Xi.newFromBech32(this.config.user.wallet),nativeAmount:BigInt(0),data:Uint8Array.from(Buffer.from(p))});return f.gasLimit=f.gasLimit+BigInt(2e6),f}async createFromRaw(r,i=!0){let s=JSON.parse(r);return i&&await this.validate(s),s}async createFromTransaction(r,i=!1){let s=await this.createFromRaw(r.data.toString(),i);return s.meta={hash:r.hash,creator:r.sender.toBech32(),createdAt:new Date(r.timestamp*1e3).toISOString()},s}async createFromTransactionHash(r,i){let s=Se.Warp(r);if(i){let f=this.cache.get(s);if(f)return fe.info(`WarpBuilder (createFromTransactionHash): Warp found in cache: ${r}`),f}let u=se(this.config),p=X.getChainEntrypoint(u,this.config.env).createNetworkProvider();try{let f=await p.getTransaction(r),b=await this.createFromTransaction(f);return i&&i.ttl&&b&&this.cache.set(s,b,i.ttl),b}catch(f){return console.error("WarpBuilder: Error creating from transaction hash",f),null}}setName(r){return this.pendingWarp.name=r,this}setTitle(r){return this.pendingWarp.title=r,this}setDescription(r){return this.pendingWarp.description=r,this}setPreview(r){return this.pendingWarp.preview=r,this}setActions(r){return this.pendingWarp.actions=r,this}addAction(r){return this.pendingWarp.actions.push(r),this}async build(){return this.ensure(this.pendingWarp.protocol,"protocol is required"),this.ensure(this.pendingWarp.name,"name is required"),this.ensure(this.pendingWarp.title,"title is required"),this.ensure(this.pendingWarp.actions.length>0,"actions are required"),await this.validate(this.pendingWarp),this.pendingWarp}getDescriptionPreview(r,i=100){return Qi(r,i)}ensure(r,i){if(!r)throw new Error(i)}async validate(r){let s=await new Ft(this.config).validate(r);if(!s.valid)throw new Error(s.errors.join(`
|
|
25
|
+
`))}};var De=class{static async apply(r,i){let s=this.applyVars(r,i);return await this.applyGlobals(r,s)}static async applyGlobals(r,i){let s={...i};return s.actions=await Promise.all(s.actions.map(async u=>await this.applyActionGlobals(r,u))),s=await this.applyRootGlobals(s,r),s}static applyVars(r,i){if(!i?.vars)return i;let s=JSON.stringify(i),u=(l,p)=>{s=s.replace(new RegExp(`{{${l.toUpperCase()}}}`,"g"),p.toString())};return Object.entries(i.vars).forEach(([l,p])=>{if(typeof p!="string")u(l,p);else if(p.startsWith(`${U.Vars.Query}:`)){if(!r.currentUrl)throw new Error("WarpUtils: currentUrl config is required to prepare vars");let f=p.split(`${U.Vars.Query}:`)[1],b=new URLSearchParams(r.currentUrl.split("?")[1]).get(f);b&&u(l,b)}else if(p.startsWith(`${U.Vars.Env}:`)){let f=p.split(`${U.Vars.Env}:`)[1],b=r.vars?.[f];b&&u(l,b)}else p===U.Source.UserWallet&&r.user?.wallet?u(l,r.user.wallet):u(l,p)}),JSON.parse(s)}static async applyRootGlobals(r,i){let s=JSON.stringify(r),u={config:i,chain:se(i)};return Object.values(U.Globals).forEach(l=>{let p=l.Accessor(u);p!=null&&(s=s.replace(new RegExp(`{{${l.Placeholder}}}`,"g"),p.toString()))}),JSON.parse(s)}static async applyActionGlobals(r,i){let s=await X.getChainInfoForAction(r,i),u=JSON.stringify(i),l={config:r,chain:s};return Object.values(U.Globals).forEach(p=>{let f=p.Accessor(l);f!=null&&(u=u.replace(new RegExp(`{{${p.Placeholder}}}`,"g"),f.toString()))}),JSON.parse(u)}};import{AbiRegistry as Zi,Address as _e,AddressValue as mr,BytesValue as ae,SmartContractTransactionsFactory as ta,TransactionsFactoryConfig as ra}from"@multiversx/sdk-core/out";var dr={buildInfo:{rustc:{version:"1.86.0",commitHash:"05f9846f893b09a1be1fc8560e33fc3c815cfecb",commitDate:"2025-03-31",channel:"Stable",short:"rustc 1.86.0 (05f9846f8 2025-03-31)"},contractCrate:{name:"registry",version:"0.0.1"},framework:{name:"multiversx-sc",version:"0.51.1"}},name:"RegistryContract",constructor:{inputs:[{name:"unit_price",type:"BigUint"},{name:"vault",type:"Address"}],outputs:[]},upgradeConstructor:{inputs:[],outputs:[]},endpoints:[{name:"registerWarp",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"hash",type:"bytes"},{name:"alias_opt",type:"optional<bytes>",multi_arg:!0},{name:"brand_opt",type:"optional<bytes>",multi_arg:!0}],outputs:[],allow_multiple_var_args:!0},{name:"unregisterWarp",mutability:"mutable",inputs:[{name:"warp",type:"bytes"}],outputs:[]},{name:"upgradeWarp",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"alias",type:"bytes"},{name:"new_warp",type:"bytes"}],outputs:[]},{name:"setWarpAlias",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"hash",type:"bytes"},{name:"alias",type:"bytes"}],outputs:[]},{name:"forceRemoveAlias",mutability:"mutable",inputs:[{name:"hash",type:"bytes"}],outputs:[]},{name:"verifyWarp",mutability:"mutable",inputs:[{name:"warp",type:"bytes"}],outputs:[]},{name:"transferOwnership",mutability:"mutable",inputs:[{name:"warp",type:"bytes"},{name:"new_owner",type:"Address"}],outputs:[]},{name:"getUserWarps",mutability:"readonly",inputs:[{name:"address",type:"Address"}],outputs:[{type:"variadic<InfoView>",multi_result:!0}]},{name:"getInfoByAlias",mutability:"readonly",inputs:[{name:"alias",type:"bytes"}],outputs:[{type:"InfoView"}]},{name:"getInfoByHash",mutability:"readonly",inputs:[{name:"hash",type:"bytes"}],outputs:[{type:"InfoView"}]},{name:"setVault",onlyOwner:!0,mutability:"mutable",inputs:[{name:"vault",type:"Address"}],outputs:[]},{name:"setUnitPrice",onlyOwner:!0,mutability:"mutable",inputs:[{name:"amount",type:"BigUint"}],outputs:[]},{name:"addAdmin",onlyOwner:!0,mutability:"mutable",inputs:[{name:"address",type:"Address"}],outputs:[]},{name:"removeAdmin",onlyOwner:!0,mutability:"mutable",inputs:[{name:"address",type:"Address"}],outputs:[]},{name:"getConfig",mutability:"readonly",inputs:[],outputs:[{type:"ConfigView"}]},{name:"registerBrand",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"hash",type:"bytes"}],outputs:[]},{name:"brandWarp",mutability:"mutable",payableInTokens:["EGLD"],inputs:[{name:"warp",type:"bytes"},{name:"brand",type:"bytes"}],outputs:[]},{name:"getUserBrands",mutability:"readonly",inputs:[{name:"user",type:"Address"}],outputs:[{type:"variadic<bytes>",multi_result:!0}]},{name:"setChain",onlyOwner:!0,mutability:"mutable",inputs:[{name:"name",type:"bytes"},{name:"display_name",type:"bytes"},{name:"chain_id",type:"bytes"},{name:"block_time",type:"u32"},{name:"address_hrp",type:"bytes"},{name:"api_url",type:"bytes"},{name:"explorer_url",type:"bytes"}],outputs:[]},{name:"removeChain",onlyOwner:!0,mutability:"mutable",inputs:[{name:"name",type:"bytes"}],outputs:[]},{name:"getChain",mutability:"readonly",inputs:[{name:"name",type:"bytes"}],outputs:[{type:"ChainView"}]},{name:"getChains",mutability:"readonly",inputs:[],outputs:[{type:"variadic<ChainView>",multi_result:!0}]}],events:[{identifier:"warpRegistered",inputs:[{name:"hash",type:"bytes",indexed:!0},{name:"alias",type:"bytes",indexed:!0},{name:"trust",type:"bytes",indexed:!0}]},{identifier:"warpUnregistered",inputs:[{name:"hash",type:"bytes",indexed:!0}]},{identifier:"warpUpgraded",inputs:[{name:"alias",type:"bytes",indexed:!0},{name:"new_warp",type:"bytes",indexed:!0},{name:"trust",type:"bytes",indexed:!0}]},{identifier:"warpVerified",inputs:[{name:"hash",type:"bytes",indexed:!0}]},{identifier:"aliasUpdated",inputs:[{name:"hash",type:"bytes",indexed:!0},{name:"alias",type:"bytes",indexed:!0}]},{identifier:"ownershipTransferred",inputs:[{name:"warp",type:"bytes",indexed:!0},{name:"old_owner",type:"Address",indexed:!0},{name:"new_owner",type:"Address",indexed:!0}]}],esdtAttributes:[],hasCallback:!1,types:{ChainView:{type:"struct",fields:[{name:"name",type:"bytes"},{name:"display_name",type:"bytes"},{name:"chain_id",type:"bytes"},{name:"block_time",type:"u32"},{name:"address_hrp",type:"bytes"},{name:"api_url",type:"bytes"},{name:"explorer_url",type:"bytes"}]},ConfigView:{type:"struct",fields:[{name:"unit_price",type:"BigUint"},{name:"admins",type:"List<Address>"}]},InfoView:{type:"struct",fields:[{name:"hash",type:"bytes"},{name:"alias",type:"Option<bytes>"},{name:"trust",type:"bytes"},{name:"owner",type:"Address"},{name:"created_at",type:"u64"},{name:"upgraded_at",type:"u64"},{name:"brand",type:"Option<bytes>"},{name:"upgrade",type:"Option<bytes>"}]}}};var Mt=c=>({hash:c.hash.toString("hex"),alias:c.alias?.toString()||null,trust:c.trust.toString(),owner:c.owner.toString(),createdAt:c.created_at.toNumber(),upgradedAt:c.upgraded_at?.toNumber(),brand:c.brand?.toString("hex")||null,upgrade:c.upgrade?.toString("hex")||null}),Yi=c=>({unitPrice:BigInt(c.unit_price.toString()),admins:c.admins.map(r=>r.toBech32())});var nt=class{constructor(r){this.config=r,this.cache=new Me(r.cache?.type),this.registryConfig={unitPrice:BigInt(0),admins:[]}}async init(){await this.loadRegistryConfigs()}createWarpRegisterTransaction(r,i,s){if(this.registryConfig.unitPrice===BigInt(0))throw new Error("WarpRegistry: config not loaded. forgot to call init()?");if(!this.config.user?.wallet)throw new Error("WarpRegistry: user address not set");let u=_e.newFromBech32(this.config.user.wallet),l=()=>this.isCurrentUserAdmin()?BigInt(0):i&&s?this.registryConfig.unitPrice*BigInt(3):i?this.registryConfig.unitPrice*BigInt(2):this.registryConfig.unitPrice,p=()=>i&&s?[ae.fromHex(r),ae.fromUTF8(i),ae.fromHex(s)]:i?[ae.fromHex(r),ae.fromUTF8(i)]:[ae.fromHex(r)];return this.getFactory().createTransactionForExecute(u,{contract:this.getRegistryContractAddress(),function:"registerWarp",gasLimit:BigInt(1e7),nativeTransferAmount:l(),arguments:p()})}createWarpUnregisterTransaction(r){if(!this.config.user?.wallet)throw new Error("WarpRegistry: user address not set");let i=_e.newFromBech32(this.config.user.wallet);return this.getFactory().createTransactionForExecute(i,{contract:this.getRegistryContractAddress(),function:"unregisterWarp",gasLimit:BigInt(1e7),arguments:[ae.fromHex(r)]})}createWarpUpgradeTransaction(r,i){if(this.registryConfig.unitPrice===BigInt(0))throw new Error("WarpRegistry: config not loaded. forgot to call init()?");if(!this.config.user?.wallet)throw new Error("WarpRegistry: user address not set");let s=_e.newFromBech32(this.config.user.wallet);return this.getFactory().createTransactionForExecute(s,{contract:this.getRegistryContractAddress(),function:"upgradeWarp",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[ae.fromUTF8(r),ae.fromHex(i)]})}createWarpAliasSetTransaction(r,i){if(!this.config.user?.wallet)throw new Error("WarpRegistry: user address not set");let s=_e.newFromBech32(this.config.user.wallet);return this.getFactory().createTransactionForExecute(s,{contract:this.getRegistryContractAddress(),function:"setWarpAlias",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[ae.fromHex(r),ae.fromUTF8(i)]})}createWarpVerifyTransaction(r){if(!this.config.user?.wallet)throw new Error("WarpRegistry: user address not set");let i=_e.newFromBech32(this.config.user.wallet);return this.getFactory().createTransactionForExecute(i,{contract:this.getRegistryContractAddress(),function:"verifyWarp",gasLimit:BigInt(1e7),arguments:[ae.fromHex(r)]})}createWarpTransferOwnershipTransaction(r,i){if(!this.config.user?.wallet)throw new Error("WarpRegistry: user address not set");let s=_e.newFromBech32(this.config.user.wallet);return this.getFactory().createTransactionForExecute(s,{contract:this.getRegistryContractAddress(),function:"transferOwnership",gasLimit:BigInt(1e7),arguments:[ae.fromHex(r),new mr(new _e(i))]})}createBrandRegisterTransaction(r){if(this.registryConfig.unitPrice===BigInt(0))throw new Error("WarpRegistry: config not loaded. forgot to call init()?");if(!this.config.user?.wallet)throw new Error("WarpRegistry: user address not set");let i=_e.newFromBech32(this.config.user.wallet);return this.getFactory().createTransactionForExecute(i,{contract:this.getRegistryContractAddress(),function:"registerBrand",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[ae.fromHex(r)]})}createWarpBrandingTransaction(r,i){if(!this.config.user?.wallet)throw new Error("WarpRegistry: user address not set");let s=_e.newFromBech32(this.config.user.wallet);return this.getFactory().createTransactionForExecute(s,{contract:this.getRegistryContractAddress(),function:"brandWarp",gasLimit:BigInt(1e7),nativeTransferAmount:this.isCurrentUserAdmin()?void 0:this.registryConfig.unitPrice,arguments:[ae.fromHex(r),ae.fromHex(i)]})}async getInfoByAlias(r,i){try{let s=Se.RegistryInfo(r),u=i?this.cache.get(s):null;if(u)return fe.info(`WarpRegistry (getInfoByAlias): RegistryInfo found in cache: ${r}`),u;let l=this.getRegistryContractAddress(),p=this.getController(),f=p.createQuery({contract:l,function:"getInfoByAlias",arguments:[ae.fromUTF8(r)]}),b=await p.runQuery(f),[x]=p.parseQueryResponse(b),C=x?Mt(x):null,I=C?.brand?await this.fetchBrand(C.brand):null;return i&&i.ttl&&this.cache.set(s,{registryInfo:C,brand:I},i.ttl),{registryInfo:C,brand:I}}catch{return{registryInfo:null,brand:null}}}async getInfoByHash(r,i){try{let s=Se.RegistryInfo(r);if(i){let I=this.cache.get(s);if(I)return fe.info(`WarpRegistry (getInfoByHash): RegistryInfo found in cache: ${r}`),I}let u=this.getRegistryContractAddress(),l=this.getController(),p=l.createQuery({contract:u,function:"getInfoByHash",arguments:[ae.fromHex(r)]}),f=await l.runQuery(p),[b]=l.parseQueryResponse(f),x=b?Mt(b):null,C=x?.brand?await this.fetchBrand(x.brand):null;return i&&i.ttl&&this.cache.set(s,{registryInfo:x,brand:C},i.ttl),{registryInfo:x,brand:C}}catch{return{registryInfo:null,brand:null}}}async getUserWarpRegistryInfos(r){try{let i=r||this.config.user?.wallet;if(!i)throw new Error("WarpRegistry: user address not set");let s=this.getRegistryContractAddress(),u=this.getController(),l=u.createQuery({contract:s,function:"getUserWarps",arguments:[new mr(new _e(i))]}),p=await u.runQuery(l),[f]=u.parseQueryResponse(p);return f.map(Mt)}catch{return[]}}async getUserBrands(r){try{let i=r||this.config.user?.wallet;if(!i)throw new Error("WarpRegistry: user address not set");let s=this.getRegistryContractAddress(),u=this.getController(),l=u.createQuery({contract:s,function:"getUserBrands",arguments:[new mr(new _e(i))]}),p=await u.runQuery(l),[f]=u.parseQueryResponse(p),b=f.map(I=>I.toString("hex")),x={ttl:365*24*60*60};return(await Promise.all(b.map(I=>this.fetchBrand(I,x)))).filter(I=>I!==null)}catch{return[]}}async getChainInfos(r){let i=Se.ChainInfos();if(r&&r.ttl){let x=this.cache.get(i);if(x)return fe.info("WarpRegistry (getChainInfos): ChainInfos found in cache"),x}let s=this.getRegistryContractAddress(),u=this.getController(),l=u.createQuery({contract:s,function:"getChains",arguments:[]}),p=await u.runQuery(l),[f]=u.parseQueryResponse(p),b=f.map(fr);if(r&&r.ttl){for(let x of b)this.cache.set(Se.ChainInfo(x.chain),x,r.ttl);this.cache.set(i,b,r.ttl)}return b}async getChainInfo(r,i){try{let s=Se.ChainInfo(r),u=i?this.cache.get(s):null;if(u)return fe.info(`WarpRegistry (getChainInfo): ChainInfo found in cache: ${r}`),u;let l=this.getRegistryContractAddress(),p=this.getController(),f=p.createQuery({contract:l,function:"getChain",arguments:[ae.fromUTF8(r)]}),b=await p.runQuery(f),[x]=p.parseQueryResponse(b),C=x?fr(x):null;return i&&i.ttl&&C&&this.cache.set(s,C,i.ttl),C}catch{return null}}async fetchBrand(r,i){let s=Se.Brand(r),u=i?this.cache.get(s):null;if(u)return fe.info(`WarpRegistry (fetchBrand): Brand found in cache: ${r}`),u;let l=se(this.config),f=X.getChainEntrypoint(l,this.config.env).createNetworkProvider();try{let b=await f.getTransaction(r),x=JSON.parse(b.data.toString());return x.meta={hash:b.hash,creator:b.sender.bech32(),createdAt:new Date(b.timestamp*1e3).toISOString()},i&&i.ttl&&this.cache.set(s,x,i.ttl),x}catch{return null}}getRegistryContractAddress(){return _e.newFromBech32(this.config.registry?.contract||oe.Registry.Contract(this.config.env))}async loadRegistryConfigs(){let r=this.getRegistryContractAddress(),i=this.getController(),[s]=await i.query({contract:r,function:"getConfig",arguments:[]}),u=s?Yi(s):null;this.registryConfig=u||{unitPrice:BigInt(0),admins:[]}}getFactory(){let r=se(this.config),i=new ra({chainID:r.chainId}),s=Zi.create(dr);return new ta({config:i,abi:s})}getController(){let r=se(this.config),i=X.getChainEntrypoint(r,this.config.env),s=Zi.create(dr);return i.createSmartContractController(s)}isCurrentUserAdmin(){return!!this.config.user?.wallet&&this.registryConfig.admins.includes(this.config.user.wallet)}};var Dt=class{constructor(r){this.config=r;this.config=r}isValid(r){return r.startsWith(U.HttpProtocolPrefix)?!!this.extractIdentifierInfoFromUrl(r):!1}async detectFromHtml(r){if(!r.length)return{match:!1,results:[]};let u=[...r.matchAll(/https?:\/\/[^\s"'<>]+/gi)].map(x=>x[0]).filter(x=>this.isValid(x)).map(x=>this.detect(x)),p=(await Promise.all(u)).filter(x=>x.match),f=p.length>0,b=p.map(x=>({url:x.url,warp:x.warp}));return{match:f,results:b}}async detect(r,i){let s={match:!1,url:r,warp:null,registryInfo:null,brand:null},u=r.startsWith(U.HttpProtocolPrefix)?this.extractIdentifierInfoFromUrl(r):X.getInfoFromPrefixedIdentifier(r);if(!u)return s;try{let{type:l,identifierBase:p}=u,f=new Lt(this.config),b=new nt(this.config),x=null,C=null,I=null;if(l==="hash"){x=await f.createFromTransactionHash(p,i);let V=await b.getInfoByHash(p,i);C=V.registryInfo,I=V.brand}else if(l==="alias"){let V=await b.getInfoByAlias(p,i);C=V.registryInfo,I=V.brand,V.registryInfo&&(x=await f.createFromTransactionHash(V.registryInfo.hash,i))}let R=x?await De.apply(this.config,x):null;return R?{match:!0,url:r,warp:R,registryInfo:C,brand:I}:s}catch(l){return fe.error("Error detecting warp link",l),s}}build(r,i){let s=this.config.clientUrl||oe.DefaultClientUrl(this.config.env),u=r===U.IdentifierType.Alias?encodeURIComponent(i):encodeURIComponent(r+U.IdentifierParamSeparator+i);return oe.SuperClientUrls.includes(s)?`${s}/${u}`:`${s}?${U.IdentifierParamName}=${u}`}buildFromPrefixedIdentifier(r){let i=X.getInfoFromPrefixedIdentifier(r);return i?this.build(i.type,i.identifierBase):""}generateQrCode(r,i,s=512,u="white",l="black",p="#23F7DD"){let f=this.build(r,i);return new ia({type:"svg",width:s,height:s,data:String(f),margin:16,qrOptions:{typeNumber:0,mode:"Byte",errorCorrectionLevel:"Q"},backgroundOptions:{color:u},dotsOptions:{type:"extra-rounded",color:l},cornersSquareOptions:{type:"extra-rounded",color:l},cornersDotOptions:{type:"square",color:l},imageOptions:{hideBackgroundDots:!0,imageSize:.4,margin:8},image:`data:image/svg+xml;utf8,<svg width="16" height="16" viewBox="0 0 100 100" fill="${encodeURIComponent(p)}" xmlns="http://www.w3.org/2000/svg"><path d="M54.8383 50.0242L95 28.8232L88.2456 16L51.4717 30.6974C50.5241 31.0764 49.4759 31.0764 48.5283 30.6974L11.7544 16L5 28.8232L45.1616 50.0242L5 71.2255L11.7544 84.0488L48.5283 69.351C49.4759 68.9724 50.5241 68.9724 51.4717 69.351L88.2456 84.0488L95 71.2255L54.8383 50.0242Z"/></svg>`})}extractIdentifierInfoFromUrl(r){let i=new URL(r),s=oe.SuperClientUrls.includes(i.origin),u=i.searchParams.get(U.IdentifierParamName),l=s&&!u?i.pathname.split("/")[1]:u;if(!l)return null;let p=decodeURIComponent(l);return X.getInfoFromPrefixedIdentifier(p)}};var oa="https://",X=class{static getInfoFromPrefixedIdentifier(r){let i=decodeURIComponent(r),s=i.includes(U.IdentifierParamSeparator)?i:`${U.IdentifierType.Alias}${U.IdentifierParamSeparator}${i}`,[u,l]=s.split(U.IdentifierParamSeparator),p=l.split("?")[0];return{type:u,identifier:l,identifierBase:p}}static getNextInfo(r,i,s,u){let l=i.actions?.[s]?.next||i.next||null;if(!l)return null;if(l.startsWith(oa))return[{identifier:null,url:l}];let[p,f]=l.split("?");if(!f)return[{identifier:p,url:this.buildNextUrl(p,r)}];let b=f.match(/{{([^}]+)\[\](\.[^}]+)?}}/g)||[];if(b.length===0){let y=Bt(f,{...i.vars,...u}),m=y?`${p}?${y}`:p;return[{identifier:m,url:this.buildNextUrl(m,r)}]}let x=b[0];if(!x)return[];let C=x.match(/{{([^[]+)\[\]/),I=C?C[1]:null;if(!I||u[I]===void 0)return[];let R=Array.isArray(u[I])?u[I]:[u[I]];if(R.length===0)return[];let V=b.filter(y=>y.includes(`{{${I}[]`)).map(y=>{let m=y.match(/\[\](\.[^}]+)?}}/),d=m&&m[1]||"";return{placeholder:y,field:d?d.slice(1):"",regex:new RegExp(y.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"g")}});return R.map(y=>{let m=f;for(let{regex:g,field:_}of V){let a=_?this.getNestedValue(y,_):y;if(a==null)return null;m=m.replace(g,a)}if(m.includes("{{")||m.includes("}}"))return null;let d=m?`${p}?${m}`:p;return{identifier:d,url:this.buildNextUrl(d,r)}}).filter(y=>y!==null)}static buildNextUrl(r,i){let[s,u]=r.split("?"),l=this.getInfoFromPrefixedIdentifier(s)||{type:"alias",identifier:s,identifierBase:s},f=new Dt(i).build(l.type,l.identifierBase);if(!u)return f;let b=new URL(f);return new URLSearchParams(u).forEach((x,C)=>b.searchParams.set(C,x)),b.toString().replace(/\/\?/,"?")}static getNestedValue(r,i){return i.split(".").reduce((s,u)=>s?.[u],r)}static async getChainInfoForAction(r,i){if(!i.chain)return se(r);let s=await new nt(r).getChainInfo(i.chain,{ttl:Ji.OneWeek});if(!s)throw new Error(`WarpActionExecutor: Chain info not found for ${i.chain}`);return s}static getChainEntrypoint(r,i){let s="warp-sdk",u="api";return i==="devnet"?new na(r.apiUrl,u,s):i==="testnet"?new aa(r.apiUrl,u,s):new sa(r.apiUrl,u,s)}};var tn=class{constructor(r){this.pendingBrand={protocol:rt("brand"),name:"",description:"",logo:""};this.config=r}createInscriptionTransaction(r){if(!this.config.user?.wallet)throw new Error("BrandBuilder: user address not set");let i=se(this.config),s=new ua({chainID:i.chainId}),u=new ca({config:s}),l=en.newFromBech32(this.config.user.wallet),p=JSON.stringify(r);return u.createTransactionForNativeTokenTransfer(l,{receiver:en.newFromBech32(this.config.user.wallet),nativeAmount:BigInt(0),data:Uint8Array.from(Buffer.from(p))})}async createFromRaw(r,i=!0){let s=JSON.parse(r);return i&&await this.ensureValidSchema(s),s}async createFromTransaction(r,i=!1){return await this.createFromRaw(r.data.toString(),i)}async createFromTransactionHash(r){let i=se(this.config),u=X.getChainEntrypoint(i,this.config.env).createNetworkProvider();try{let l=await u.getTransaction(r);return this.createFromTransaction(l)}catch(l){return console.error("BrandBuilder: Error creating from transaction hash",l),null}}setName(r){return this.pendingBrand.name=r,this}setDescription(r){return this.pendingBrand.description=r,this}setLogo(r){return this.pendingBrand.logo=r,this}setUrls(r){return this.pendingBrand.urls=r,this}setColors(r){return this.pendingBrand.colors=r,this}setCta(r){return this.pendingBrand.cta=r,this}async build(){return this.ensure(this.pendingBrand.name,"name is required"),this.ensure(this.pendingBrand.description,"description is required"),this.ensure(this.pendingBrand.logo,"logo is required"),await this.ensureValidSchema(this.pendingBrand),this.pendingBrand}ensure(r,i){if(!r)throw new Error(`Warp: ${i}`)}async ensureValidSchema(r){let i=this.config.schema?.brand||oe.LatestBrandSchemaUrl,u=await(await fetch(i)).json(),l=new la,p=l.compile(u);if(!p(r))throw new Error(`BrandBuilder: schema validation failed: ${l.errorsText(p.errors)}`)}};import{Address as pa,AddressValue as ha,BigUIntType as fa,BigUIntValue as rn,BooleanValue as da,BytesValue as ma,CodeMetadata as ga,CodeMetadataValue as ya,CompositeType as xa,CompositeValue as va,Field as gr,FieldDefinition as yr,List as ba,NothingValue as wa,OptionalValue as xr,OptionValue as vr,StringValue as _a,Struct as Ca,StructType as Sa,TokenIdentifierType as Ea,TokenIdentifierValue as nn,U16Value as Aa,U32Value as Ia,U64Type as Ta,U64Value as sn,U8Value as ka,VariadicValue as Pa}from"@multiversx/sdk-core/out";var cl=(c,r)=>c?vr.newProvided(c):r?vr.newMissingTyped(r):vr.newMissing(),ll=(c,r)=>c?new xr(c.getType(),c):r?new xr(r):xr.newMissing(),pl=c=>{if(c.length===0)throw new Error("Cannot create a list from an empty array");let r=c[0].getType();return new ba(r,c)},hl=c=>Pa.fromItems(...c),fl=c=>{let r=c.map(i=>i.getType());return new va(new xa(...r),c)},dl=c=>_a.fromUTF8(c),ml=c=>new ka(c),gl=c=>new Aa(c),yl=c=>new Ia(c),xl=c=>new sn(c),vl=c=>new rn(BigInt(c)),bl=c=>new da(c),wl=c=>new ha(pa.newFromBech32(c)),_l=c=>new nn(c),Cl=c=>ma.fromHex(c),Sl=c=>new Ca(new Sa("EsdtTokenPayment",[new yr("token_identifier","",new Ea),new yr("token_nonce","",new Ta),new yr("amount","",new fa)]),[new gr(new nn(c.token.identifier),"token_identifier"),new gr(new sn(BigInt(c.token.nonce)),"token_nonce"),new gr(new rn(BigInt(c.amount)),"amount")]),El=c=>new ya(ga.newFromBytes(Uint8Array.from(Buffer.from(c,"hex")))),Al=()=>new wa;import{Address as Ra,TransactionsFactoryConfig as Na,TransferTransactionsFactory as Va}from"@multiversx/sdk-core";var Ut=class{constructor(r){this.cache=new Me;this.config=r}createInscriptionTransaction(r){if(!this.config.user?.wallet)throw new Error("WarpBuilder: user address not set");let i=se(this.config),s=new Na({chainID:i.chainId}),u=new Va({config:s}),l={protocol:rt("abi"),content:r},p=Ra.newFromBech32(this.config.user.wallet),f=JSON.stringify(l),b=u.createTransactionForTransfer(p,{receiver:p,nativeAmount:BigInt(0),data:Uint8Array.from(Buffer.from(f))});return b.gasLimit=b.gasLimit+BigInt(2e6),b}async createFromRaw(r){return JSON.parse(r)}async createFromTransaction(r){let i=await this.createFromRaw(r.data.toString());return i.meta={hash:r.hash,creator:r.sender.bech32(),createdAt:new Date(r.timestamp*1e3).toISOString()},i}async createFromTransactionHash(r,i){let s=Se.WarpAbi(r);if(i){let f=this.cache.get(s);if(f)return fe.info(`WarpAbiBuilder (createFromTransactionHash): Warp abi found in cache: ${r}`),f}let u=se(this.config),p=X.getChainEntrypoint(u,this.config.env).createNetworkProvider();try{let f=await p.getTransaction(r),b=await this.createFromTransaction(f);return i&&i.ttl&&b&&this.cache.set(s,b,i.ttl),b}catch(f){return console.error("WarpAbiBuilder: Error creating from transaction hash",f),null}}};import{AbiRegistry as xi,Address as vi,ArgSerializer as Ou,SmartContractTransactionsFactory as Wu,Token as xs,TokenComputer as Bu,TokenTransfer as vs,TransactionsFactoryConfig as Fu,TransferTransactionsFactory as Lu}from"@multiversx/sdk-core";import{SmartContractTransactionsOutcomeParser as Tu,TransactionEventsParser as ku,findEventsByFirstTopic as Pu}from"@multiversx/sdk-core/out";import{Address as Oa,AddressType as an,AddressValue as on,BigUIntType as br,BigUIntValue as wr,BooleanType as un,BooleanValue as cn,BytesType as ln,BytesValue as pn,CodeMetadata as Wa,CodeMetadataType as hn,CodeMetadataValue as fn,CompositeType as dn,CompositeValue as mn,Field as _r,FieldDefinition as Cr,List as gn,ListType as Ba,NothingValue as ge,OptionalType as Fa,OptionalValue as Sr,OptionType as La,OptionValue as Er,StringType as yn,StringValue as xn,Struct as Ma,StructType as vn,Token as Da,TokenIdentifierType as Ar,TokenIdentifierValue as Ir,TokenTransfer as bn,U16Type as wn,U16Value as _n,U32Type as Cn,U32Value as Sn,U64Type as Tr,U64Value as kr,U8Type as En,U8Value as An,VariadicType as In,VariadicValue as Tn}from"@multiversx/sdk-core/out";var kn=new RegExp(`${U.ArgParamsSeparator}(.*)`),st=class{nativeToString(r,i){return r==="esdt"&&i instanceof bn?`esdt:${i.token.identifier}|${i.token.nonce.toString()}|${i.amount.toString()}`:`${r}:${i?.toString()??""}`}typedToString(r){if(r.hasClassOrSuperclass(Er.ClassName))return r.isSet()?`option:${this.typedToString(r.getTypedValue())}`:"option:null";if(r.hasClassOrSuperclass(Sr.ClassName))return r.isSet()?`optional:${this.typedToString(r.getTypedValue())}`:"optional:null";if(r.hasClassOrSuperclass(gn.ClassName)){let i=r.getItems(),u=i.map(p=>this.typedToString(p).split(U.ArgParamsSeparator)[0])[0],l=i.map(p=>this.typedToString(p).split(U.ArgParamsSeparator)[1]);return`list:${u}:${l.join(",")}`}if(r.hasClassOrSuperclass(Tn.ClassName)){let i=r.getItems(),u=i.map(p=>this.typedToString(p).split(U.ArgParamsSeparator)[0])[0],l=i.map(p=>this.typedToString(p).split(U.ArgParamsSeparator)[1]);return`variadic:${u}:${l.join(",")}`}if(r.hasClassOrSuperclass(mn.ClassName)){let i=r.getItems(),s=i.map(f=>this.typedToString(f).split(U.ArgParamsSeparator)[0]),u=i.map(f=>this.typedToString(f).split(U.ArgParamsSeparator)[1]),l=s.join(U.ArgCompositeSeparator),p=u.join(U.ArgCompositeSeparator);return`composite(${l}):${p}`}if(r.hasClassOrSuperclass(wr.ClassName)||r.getType().getName()==="BigUint")return`biguint:${BigInt(r.valueOf().toFixed())}`;if(r.hasClassOrSuperclass(An.ClassName))return`uint8:${r.valueOf().toNumber()}`;if(r.hasClassOrSuperclass(_n.ClassName))return`uint16:${r.valueOf().toNumber()}`;if(r.hasClassOrSuperclass(Sn.ClassName))return`uint32:${r.valueOf().toNumber()}`;if(r.hasClassOrSuperclass(kr.ClassName))return`uint64:${BigInt(r.valueOf().toFixed())}`;if(r.hasClassOrSuperclass(xn.ClassName))return`string:${r.valueOf()}`;if(r.hasClassOrSuperclass(cn.ClassName))return`bool:${r.valueOf()}`;if(r.hasClassOrSuperclass(on.ClassName))return`address:${r.valueOf().bech32()}`;if(r.hasClassOrSuperclass(Ir.ClassName))return`token:${r.valueOf()}`;if(r.hasClassOrSuperclass(pn.ClassName))return`hex:${r.valueOf().toString("hex")}`;if(r.hasClassOrSuperclass(fn.ClassName))return`codemeta:${r.valueOf().toBuffer().toString("hex")}`;if(r.getType().getName()==="EsdtTokenPayment"){let i=r.getFieldValue("token_identifier").valueOf(),s=r.getFieldValue("token_nonce").valueOf(),u=r.getFieldValue("amount").valueOf();return`esdt:${i}|${s}|${u}`}throw new Error(`WarpArgSerializer (typedToString): Unsupported input type: ${r.getClassName()}`)}typedToNative(r){let i=this.typedToString(r);return this.stringToNative(i)}nativeToTyped(r,i){let s=this.nativeToString(r,i);return this.stringToTyped(s)}nativeToType(r){if(r.startsWith("composite")){let i=r.match(/\(([^)]+)\)/)?.[1];return new dn(...i.split(U.ArgCompositeSeparator).map(s=>this.nativeToType(s)))}if(r==="string")return new yn;if(r==="uint8")return new En;if(r==="uint16")return new wn;if(r==="uint32")return new Cn;if(r==="uint64")return new Tr;if(r==="biguint")return new br;if(r==="bool")return new un;if(r==="address")return new an;if(r==="token")return new Ar;if(r==="hex")return new ln;if(r==="codemeta")return new hn;if(r==="esdt"||r==="nft")return new vn("EsdtTokenPayment",[new Cr("token_identifier","",new Ar),new Cr("token_nonce","",new Tr),new Cr("amount","",new br)]);throw new Error(`WarpArgSerializer (nativeToType): Unsupported input type: ${r}`)}stringToNative(r){let i=r.split(U.ArgParamsSeparator),s=i[0],u=i.slice(1).join(U.ArgParamsSeparator);if(s==="null")return[s,null];if(s==="option"){let[l,p]=u.split(U.ArgParamsSeparator);return[`option:${l}`,p||null]}else if(s==="optional"){let[l,p]=u.split(U.ArgParamsSeparator);return[`optional:${l}`,p||null]}else if(s==="list"){let l=u.split(U.ArgParamsSeparator),p=l.slice(0,-1).join(U.ArgParamsSeparator),f=l[l.length-1],x=(f?f.split(","):[]).map(C=>this.stringToNative(`${p}:${C}`)[1]);return[`list:${p}`,x]}else if(s==="variadic"){let l=u.split(U.ArgParamsSeparator),p=l.slice(0,-1).join(U.ArgParamsSeparator),f=l[l.length-1],x=(f?f.split(","):[]).map(C=>this.stringToNative(`${p}:${C}`)[1]);return[`variadic:${p}`,x]}else if(s.startsWith("composite")){let l=s.match(/\(([^)]+)\)/)?.[1]?.split(U.ArgCompositeSeparator),f=u.split(U.ArgCompositeSeparator).map((b,x)=>this.stringToNative(`${l[x]}:${b}`)[1]);return[s,f]}else{if(s==="string")return[s,u];if(s==="uint8"||s==="uint16"||s==="uint32")return[s,Number(u)];if(s==="uint64"||s==="biguint")return[s,BigInt(u||0)];if(s==="bool")return[s,u==="true"];if(s==="address")return[s,u];if(s==="token")return[s,u];if(s==="hex")return[s,u];if(s==="codemeta")return[s,u];if(s==="esdt"){let[l,p,f]=u.split(U.ArgCompositeSeparator);return[s,new bn({token:new Da({identifier:l,nonce:BigInt(p)}),amount:BigInt(f)})]}}throw new Error(`WarpArgSerializer (stringToNative): Unsupported input type: ${s}`)}stringToTyped(r){let[i,s]=r.split(/:(.*)/,2);if(i==="null"||i===null)return new ge;if(i==="option"){let u=this.stringToTyped(s);return u instanceof ge?Er.newMissingTyped(u.getType()):Er.newProvided(u)}if(i==="optional"){let u=this.stringToTyped(s);return u instanceof ge?Sr.newMissing():new Sr(u.getType(),u)}if(i==="list"){let[u,l]=s.split(kn,2),f=l.split(",").map(b=>this.stringToTyped(`${u}:${b}`));return new gn(this.nativeToType(u),f)}if(i==="variadic"){let[u,l]=s.split(kn,2),f=l.split(",").map(b=>this.stringToTyped(`${u}:${b}`));return new Tn(new In(this.nativeToType(u)),f)}if(i.startsWith("composite")){let u=i.match(/\(([^)]+)\)/)?.[1],l=s.split(U.ArgCompositeSeparator),p=u.split(U.ArgCompositeSeparator),f=l.map((x,C)=>this.stringToTyped(`${p[C]}:${x}`)),b=f.map(x=>x.getType());return new mn(new dn(...b),f)}if(i==="string")return s?xn.fromUTF8(s):new ge;if(i==="uint8")return s?new An(Number(s)):new ge;if(i==="uint16")return s?new _n(Number(s)):new ge;if(i==="uint32")return s?new Sn(Number(s)):new ge;if(i==="uint64")return s?new kr(BigInt(s)):new ge;if(i==="biguint")return s?new wr(BigInt(s)):new ge;if(i==="bool")return s?new cn(typeof s=="boolean"?s:s==="true"):new ge;if(i==="address")return s?new on(Oa.newFromBech32(s)):new ge;if(i==="token")return s?new Ir(s):new ge;if(i==="hex")return s?pn.fromHex(s):new ge;if(i==="codemeta")return new fn(Wa.newFromBytes(Uint8Array.from(Buffer.from(s,"hex"))));if(i==="esdt"){let u=s.split(U.ArgCompositeSeparator);return new Ma(this.nativeToType("esdt"),[new _r(new Ir(u[0]),"token_identifier"),new _r(new kr(BigInt(u[1])),"token_nonce"),new _r(new wr(BigInt(u[2])),"amount")])}throw new Error(`WarpArgSerializer (stringToTyped): Unsupported input type: ${i}`)}typeToString(r){if(r instanceof La)return"option:"+this.typeToString(r.getFirstTypeParameter());if(r instanceof Fa)return"optional:"+this.typeToString(r.getFirstTypeParameter());if(r instanceof Ba)return"list:"+this.typeToString(r.getFirstTypeParameter());if(r instanceof In)return"variadic:"+this.typeToString(r.getFirstTypeParameter());if(r instanceof yn)return"string";if(r instanceof En)return"uint8";if(r instanceof wn)return"uint16";if(r instanceof Cn)return"uint32";if(r instanceof Tr)return"uint64";if(r instanceof br)return"biguint";if(r instanceof un)return"bool";if(r instanceof an)return"address";if(r instanceof Ar)return"token";if(r instanceof ln)return"hex";if(r instanceof hn)return"codemeta";if(r instanceof vn&&r.getClassName()==="EsdtTokenPayment")return"esdt";throw new Error(`WarpArgSerializer (typeToString): Unsupported input type: ${r.getClassName()}`)}};var Ru=async(c,r)=>{if(typeof window>"u"){let i;try{i=fs().VM}catch{throw new Error("The 'vm2' package is required for transform execution in Node.js environments. Please install it with 'npm install vm2', or use this library in a browser environment.")}let s=new i({timeout:1e3,sandbox:{input:r},eval:!1,wasm:!1});return c.trim().startsWith("(")&&c.includes("=>")?s.run(`(${c})(input)`):null}return new Promise((i,s)=>{try{let u=new Blob([`
|
|
3
26
|
self.onmessage = function(e) {
|
|
4
27
|
try {
|
|
5
28
|
const input = e.data;
|
|
6
|
-
const result = (${
|
|
29
|
+
const result = (${c})(input);
|
|
7
30
|
self.postMessage({ result });
|
|
8
31
|
} catch (error) {
|
|
9
32
|
self.postMessage({ error: error.toString() });
|
|
10
33
|
}
|
|
11
34
|
};
|
|
12
|
-
`],{type:"application/javascript"}),i=URL.createObjectURL(n),s=new Worker(i);s.onmessage=function(o){o.data.error?r(new Error(o.data.error)):e(o.data.result),s.terminate(),URL.revokeObjectURL(i)},s.onerror=function(o){r(new Error(`Error in transform: ${o.message}`)),s.terminate(),URL.revokeObjectURL(i)},s.postMessage(t)}catch(n){return r(n)}})},mt=a=>{if(a==="out")return 1;let t=a.match(/^out\[(\d+)\]/);return t?parseInt(t[1],10):(a.startsWith("out.")||a.startsWith("event."),null)},rr=(a,t)=>t.reduce((e,r)=>e&&e[r]!==void 0?e[r]:null,a),ht=async(a,t)=>{if(!a.results)return t;let e={...t},r=Object.entries(a.results).filter(([,n])=>n.startsWith(p.Transform.Prefix)).map(([n,i])=>({key:n,code:i.substring(p.Transform.Prefix.length)}));for(let{key:n,code:i}of r)try{e[n]=await er(i,e)}catch(s){console.error(`Transform error for result '${n}':`,s),e[n]=null}return e},Zt=async(a,t,e,r,n=1)=>{let i=[],s={};if(!t.results||!e.abi||e.type!=="contract")return{values:i,results:s};let o=await a.getAbiForAction(e),c=new Ze({abi:o}),l=new Ye({abi:o}).parseExecute({transactionOnNetwork:r,function:e.func||void 0});for(let[f,h]of Object.entries(t.results)){if(h.startsWith(p.Transform.Prefix))continue;let y=mt(h);if(y!==null&&y!==n){s[f]=null;continue}let[v,d,m]=h.split(".");if(v==="event"){if(!d||isNaN(Number(m)))continue;let w=Number(m),b=tr(r,d),P=c.parseEvents({events:b})[0],x=Object.values(P)[w]||null;i.push(x),s[f]=x&&x.valueOf()}else if(v==="out"||v.startsWith("out[")){if(!d)continue;let w=Number(d),b=l.values[w-1]||null;i.push(b),s[f]=b&&b.valueOf()}}return{values:i,results:await ht(t,s)}},te=async(a,t,e=1)=>{let r=new L,n=t.map(c=>r.typedToString(c)),i=t.map(c=>r.typedToNative(c)[1]),s={};if(!a.results)return{values:n,results:s};let o=c=>{let u=c.split(".").slice(1).map(f=>parseInt(f)-1);if(u.length===0)return;let l=i[u[0]];for(let f=1;f<u.length;f++){if(l==null)return;l=l[u[f]]}return l};for(let[c,u]of Object.entries(a.results)){if(u.startsWith(p.Transform.Prefix))continue;let l=mt(u);if(l!==null&&l!==e){s[c]=null;continue}(u.startsWith("out.")||u==="out"||u.startsWith("out["))&&(s[c]=o(u)||null)}return{values:n,results:await ht(a,s)}},ee=async(a,t,e=1)=>{let r=[],n={};for(let[i,s]of Object.entries(a.results||{})){if(s.startsWith(p.Transform.Prefix))continue;let o=mt(s);if(o!==null&&o!==e){n[i]=null;continue}let[c,...u]=s.split(".");if(c!=="out"&&!c.startsWith("out["))continue;let l=u.length===0?t?.data||t:rr(t,u);r.push(l),n[i]=l}return{values:r,results:await ht(a,n)}};var nr=[{id:"EGLD",name:"eGold",decimals:18},{id:"EGLD-000000",name:"eGold",decimals:18}],re=a=>nr.find(t=>t.id===a)||null;var J=class{constructor(t){this.config=t}async getContract(t,e){try{let i=await g.getChainEntrypoint(e,this.config.env).createNetworkProvider().doGetGeneric(`accounts/${t}`);return{address:t,owner:i.ownerAddress,verified:i.isVerified||!1}}catch(r){return console.error("WarpContractLoader: getContract error",r),null}}async getVerificationInfo(t,e){try{let i=await g.getChainEntrypoint(e,this.config.env).createNetworkProvider().doGetGeneric(`accounts/${t}/verification`);return{codeHash:i.codeHash,abi:i.source.abi}}catch(r){return console.error("WarpContractLoader: getVerificationInfo error",r),null}}};var ae=class{constructor(t){if(!t.currentUrl)throw new Error("WarpActionExecutor: currentUrl config not set");this.config=t,this.url=new URL(t.currentUrl),this.serializer=new L,this.contractLoader=new J(t)}async createTransactionForExecute(t,e,r){let n=_(t,e);if(!this.config.user?.wallet)throw new Error("WarpActionExecutor: user address not set");let i=wt.newFromBech32(this.config.user.wallet),s=await g.getChainInfoForAction(this.config,n),o=new or({chainID:s.chainId}),{destination:c,args:u,value:l,transfers:f,data:h}=await this.getTxComponentsFromInputs(s,n,r,i),y=u.map(v=>this.serializer.stringToTyped(v));if(n.type==="transfer")return new cr({config:o}).createTransactionForTransfer(i,{receiver:c,nativeAmount:l,tokenTransfers:f,data:h?new Uint8Array(h):void 0});if(n.type==="contract"&&c.isSmartContract())return new ar({config:o}).createTransactionForExecute(i,{contract:c,function:"func"in n&&n.func||"",gasLimit:"gasLimit"in n?BigInt(n.gasLimit||0):0n,arguments:y,tokenTransfers:f,nativeTransferAmount:l});throw n.type==="query"?new Error("WarpActionExecutor: Invalid action type for createTransactionForExecute; Use executeQuery instead"):n.type==="collect"?new Error("WarpActionExecutor: Invalid action type for createTransactionForExecute; Use executeCollect instead"):new Error(`WarpActionExecutor: Invalid action type (${n.type})`)}async getTransactionExecutionResults(t,e,r){let n=_(t,e),i=await U.apply(this.config,t),{values:s,results:o}=await Zt(this,i,n,r,e),c=g.getNextInfo(this.config,i,e,o),u=this.getPreparedMessages(i,o);return{success:r.status.isSuccessful(),warp:i,action:e,user:this.config.user?.wallet||null,txHash:r.hash,next:c,values:s,results:o,messages:u}}async executeQuery(t,e,r){let n=_(t,e);if(!n)throw new Error("WarpActionExecutor: Action not found");if(!n.func)throw new Error("WarpActionExecutor: Function not found");let i=await g.getChainInfoForAction(this.config,n),s=await U.apply(this.config,t),o=await this.getAbiForAction(n),{args:c}=await this.getTxComponentsFromInputs(i,n,r),u=c.map(I=>this.serializer.stringToTyped(I)),l=g.getChainEntrypoint(i,this.config.env),f=wt.newFromBech32(n.address),h=l.createSmartContractController(o),y=h.createQuery({contract:f,function:n.func,arguments:u}),v=await h.runQuery(y),d=v.returnCode==="ok",m=new ir,w=o.getEndpoint(v.function),b=v.returnDataParts.map(I=>Buffer.from(I)),P=m.buffersToValues(b,w.output),{values:x,results:N}=await te(s,P,e),X=g.getNextInfo(this.config,s,e,N);return{success:d,warp:s,action:e,user:this.config.user?.wallet||null,txHash:null,next:X,values:x,results:N,messages:this.getPreparedMessages(s,N)}}async executeCollect(t,e,r,n){let i=_(t,e);if(!i)throw new Error("WarpActionExecutor: Action not found");let s=await g.getChainInfoForAction(this.config,i),o=await U.apply(this.config,t),c=await this.getResolvedInputs(s,i,r),u=this.getModifiedInputs(c),l=d=>{if(!d.value)return null;let m=this.serializer.stringToNative(d.value)[1];if(d.input.type==="biguint")return m.toString();if(d.input.type==="esdt"){let w=m;return{token:w.token.identifier,nonce:w.token.nonce.toString(),amount:w.amount.toString()}}else return m},f=new Headers;f.set("Content-Type","application/json"),f.set("Accept","application/json"),Object.entries(i.destination.headers||{}).forEach(([d,m])=>{f.set(d,m)});let h=Object.fromEntries(u.map(d=>[d.input.as||d.input.name,l(d)])),y=i.destination.method||"GET",v=y==="GET"?void 0:JSON.stringify({inputs:h,meta:n});try{let d=await fetch(i.destination.url,{method:y,headers:f,body:v}),m=await d.json(),{values:w,results:b}=await ee(o,m,e),P=g.getNextInfo(this.config,o,e,b);return{success:d.ok,warp:o,action:e,user:this.config.user?.wallet||null,txHash:null,next:P,values:w,results:b,messages:this.getPreparedMessages(o,b)}}catch(d){return console.error(d),{success:!1,warp:o,action:e,user:this.config.user?.wallet||null,txHash:null,next:null,values:[],results:{},messages:{}}}}async getTxComponentsFromInputs(t,e,r,n){let i=await this.getResolvedInputs(t,e,r),s=this.getModifiedInputs(i),o=s.find(I=>I.input.position==="receiver")?.value,c="address"in e?e.address:null,u=o?.split(":")[1]||c||n?.toBech32();if(!u)throw new Error("WarpActionExecutor: Destination/Receiver not provided");let l=wt.newFromBech32(u),f=this.getPreparedArgs(e,s),h=s.find(I=>I.input.position==="value")?.value||null,y="value"in e?e.value:null,v=BigInt(h?.split(":")[1]||y||0),d=s.filter(I=>I.input.position==="transfer"&&I.value).map(I=>I.value),w=[...("transfers"in e?e.transfers:[])?.map(this.toTypedTransfer)||[],...d?.map(I=>this.serializer.stringToNative(I)[1])||[]],b=s.find(I=>I.input.position==="data")?.value,P="data"in e?e.data||"":null,x=b||P||null,N=x?this.serializer.stringToTyped(x).valueOf():null,X=N?Buffer.from(N):null;return{destination:l,args:f,value:v,transfers:w,data:X}}async getResolvedInputs(t,e,r){let n=e.inputs||[],i=await Promise.all(r.map(o=>this.preprocessInput(t,o))),s=(o,c)=>{if(o.source==="query"){let u=this.url.searchParams.get(o.name);return u?this.serializer.nativeToString(o.type,u):null}else return o.source===p.Source.UserWallet?this.config.user?.wallet?this.serializer.nativeToString("address",this.config.user.wallet):null:i[c]||null};return n.map((o,c)=>({input:o,value:s(o,c)}))}getModifiedInputs(t){return t.map((e,r)=>{if(e.input.modifier?.startsWith("scale:")){let[,n]=e.input.modifier.split(":");if(isNaN(Number(n))){let i=Number(t.find(c=>c.input.name===n)?.value?.split(":")[1]);if(!i)throw new Error(`WarpActionExecutor: Exponent value not found for input ${n}`);let s=e.value?.split(":")[1];if(!s)throw new Error("WarpActionExecutor: Scalable value not found");let o=H(s,+i);return{...e,value:`${e.input.type}:${o}`}}else{let i=e.value?.split(":")[1];if(!i)throw new Error("WarpActionExecutor: Scalable value not found");let s=H(i,+n);return{...e,value:`${e.input.type}:${s}`}}}else return e})}async preprocessInput(t,e){try{let[r,n]=e.split(p.ArgParamsSeparator,2);if(r==="esdt"){let[i,s,o,c]=n.split(p.ArgCompositeSeparator);if(c)return e;let u=new ne({identifier:i,nonce:BigInt(s)});if(!new sr().isFungible(u))return e;let h=re(i)?.decimals;if(h||(h=(await(await fetch(`${t.apiUrl}/tokens/${i}`)).json()).decimals),!h)throw new Error(`WarpActionExecutor: Decimals not found for token ${i}`);let y=new ie({token:u,amount:H(o,h)});return this.serializer.nativeToString(r,y)+p.ArgCompositeSeparator+h}return e}catch{return e}}async getAbiForAction(t){if(t.abi)return await this.fetchAbi(t);let e=T(this.config),r=await this.contractLoader.getVerificationInfo(t.address,e);if(!r)throw new Error("WarpActionExecutor: Verification info not found");return yt.create(r.abi)}getPreparedArgs(t,e){let r="args"in t?t.args||[]:[];return e.forEach(({input:n,value:i})=>{if(!i||!n.position?.startsWith("arg:"))return;let s=Number(n.position.split(":")[1])-1;r.splice(s,0,i)}),r}getPreparedMessages(t,e){let r=Object.entries(t.messages||{}).map(([n,i])=>[n,D(i,e)]);return Object.fromEntries(r)}async fetchAbi(t){if(!t.abi)throw new Error("WarpActionExecutor: ABI not found");if(t.abi.startsWith(p.IdentifierType.Hash)){let e=new K(this.config),r=t.abi.split(p.IdentifierParamSeparator)[1],n=await e.createFromTransactionHash(r);if(!n)throw new Error(`WarpActionExecutor: ABI not found for hash: ${t.abi}`);return yt.create(n.content)}else{let r=await(await fetch(t.abi)).json();return yt.create(r)}}toTypedTransfer(t){return new ie({token:new ne({identifier:t.token,nonce:BigInt(t.nonce||0)}),amount:BigInt(t.amount||0)})}};var se=class{constructor(t){this.config=t}async search(t,e,r){if(!this.config.index?.url)throw new Error("WarpIndex: Index URL is not set");try{let n=await fetch(this.config.index?.url,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.config.index?.apiKey}`,...r},body:JSON.stringify({[this.config.index?.searchParamName||"search"]:t,...e})});if(!n.ok)throw new Error(`WarpIndex: search failed with status ${n.status}`);return(await n.json()).hits}catch(n){throw console.error("WarpIndex: Error searching for warps: ",n),n}}};export{At as BrandBuilder,E as CacheKey,Ct as CacheTtl,W as Config,K as WarpAbiBuilder,ae as WarpActionExecutor,L as WarpArgSerializer,Q as WarpBuilder,V as WarpCache,p as WarpConstants,J as WarpContractLoader,se as WarpIndex,U as WarpInterpolator,z as WarpLink,F as WarpProtocolVersions,$ as WarpRegistry,g as WarpUtils,j as WarpValidator,Qn as address,Dn as biguint,jn as boolean,Jn as codemeta,$n as composite,Kn as esdt,gr as getChainExplorerUrl,O as getLatestProtocolIdentifier,T as getMainChainInfo,_ as getWarpActionByIndex,zn as hex,On as list,Xn as nothing,Nn as option,Fn as optional,D as replacePlaceholders,H as shiftBigintBy,Ln as string,Tt as toPreviewText,Y as toTypedChainInfo,Gn as token,qn as u16,Mn as u32,Hn as u64,_n as u8,kn as variadic};
|
|
35
|
+
`],{type:"application/javascript"}),l=URL.createObjectURL(u),p=new Worker(l);p.onmessage=function(f){f.data.error?s(new Error(f.data.error)):i(f.data.result),p.terminate(),URL.revokeObjectURL(l)},p.onerror=function(f){s(new Error(`Error in transform: ${f.message}`)),p.terminate(),URL.revokeObjectURL(l)},p.postMessage(r)}catch(u){return s(u)}})},gi=c=>{if(c==="out")return 1;let r=c.match(/^out\[(\d+)\]/);return r?parseInt(r[1],10):(c.startsWith("out.")||c.startsWith("event."),null)},Nu=(c,r)=>r.reduce((i,s)=>i&&i[s]!==void 0?i[s]:null,c),yi=async(c,r)=>{if(!c.results)return r;let i={...r},s=Object.entries(c.results).filter(([,u])=>u.startsWith(U.Transform.Prefix)).map(([u,l])=>({key:u,code:l.substring(U.Transform.Prefix.length)}));for(let{key:u,code:l}of s)try{i[u]=await Ru(l,i)}catch(p){console.error(`Transform error for result '${u}':`,p),i[u]=null}return i},ds=async(c,r,i,s,u=1)=>{let l=[],p={};if(!r.results||!i.abi||i.type!=="contract")return{values:l,results:p};let f=await c.getAbiForAction(i),b=new ku({abi:f}),C=new Tu({abi:f}).parseExecute({transactionOnNetwork:s,function:i.func||void 0});for(let[I,R]of Object.entries(r.results)){if(R.startsWith(U.Transform.Prefix))continue;let V=gi(R);if(V!==null&&V!==u){p[I]=null;continue}let[O,y,m]=R.split(".");if(O==="event"){if(!y||isNaN(Number(m)))continue;let d=Number(m),g=Pu(s,y),_=b.parseEvents({events:g})[0],a=Object.values(_)[d]||null;l.push(a),p[I]=a&&a.valueOf()}else if(O==="out"||O.startsWith("out[")){if(!y)continue;let d=Number(y),g=C.values[d-1]||null;m&&(g=g[m]||null),g&&typeof g=="object"&&(g="toFixed"in g?g.toFixed():g.valueOf()),l.push(g),p[I]=g&&g.valueOf()}}return{values:l,results:await yi(r,p)}},ms=async(c,r,i=1)=>{let s=new st,u=r.map(b=>s.typedToString(b)),l=r.map(b=>s.typedToNative(b)[1]),p={};if(!c.results)return{values:u,results:p};let f=b=>{let x=b.split(".").slice(1).map(I=>parseInt(I)-1);if(x.length===0)return;let C=l[x[0]];for(let I=1;I<x.length;I++){if(C==null)return;C=C[x[I]]}return C};for(let[b,x]of Object.entries(c.results)){if(x.startsWith(U.Transform.Prefix))continue;let C=gi(x);if(C!==null&&C!==i){p[b]=null;continue}(x.startsWith("out.")||x==="out"||x.startsWith("out["))&&(p[b]=f(x)||null)}return{values:u,results:await yi(c,p)}},gs=async(c,r,i=1)=>{let s=[],u={};for(let[l,p]of Object.entries(c.results||{})){if(p.startsWith(U.Transform.Prefix))continue;let f=gi(p);if(f!==null&&f!==i){u[l]=null;continue}let[b,...x]=p.split(".");if(b!=="out"&&!b.startsWith("out["))continue;let C=x.length===0?r?.data||r:Nu(r,x);s.push(C),u[l]=C}return{values:s,results:await yi(c,u)}};var Vu=[{id:"EGLD",name:"eGold",decimals:18},{id:"EGLD-000000",name:"eGold",decimals:18}],ys=c=>Vu.find(r=>r.id===c)||null;var or=class{constructor(r){this.config=r}async getContract(r,i){try{let l=await X.getChainEntrypoint(i,this.config.env).createNetworkProvider().doGetGeneric(`accounts/${r}`);return{address:r,owner:l.ownerAddress,verified:l.isVerified||!1}}catch(s){return console.error("WarpContractLoader: getContract error",s),null}}async getVerificationInfo(r,i){try{let l=await X.getChainEntrypoint(i,this.config.env).createNetworkProvider().doGetGeneric(`accounts/${r}/verification`);return{codeHash:l.codeHash,abi:l.source.abi}}catch(s){return console.error("WarpContractLoader: getVerificationInfo error",s),null}}};var bs=class{constructor(r){if(!r.currentUrl)throw new Error("WarpActionExecutor: currentUrl config not set");this.config=r,this.url=new URL(r.currentUrl),this.serializer=new st,this.contractLoader=new or(r)}async createTransactionForExecute(r,i,s){let u=xt(r,i);if(!this.config.user?.wallet)throw new Error("WarpActionExecutor: user address not set");let l=vi.newFromBech32(this.config.user.wallet),p=await X.getChainInfoForAction(this.config,u),f=new Fu({chainID:p.chainId}),{destination:b,args:x,value:C,transfers:I,data:R}=await this.getTxComponentsFromInputs(p,u,s,l),V=x.map(O=>this.serializer.stringToTyped(O));if(u.type==="transfer")return new Lu({config:f}).createTransactionForTransfer(l,{receiver:b,nativeAmount:C,tokenTransfers:I,data:R?new Uint8Array(R):void 0});if(u.type==="contract"&&b.isSmartContract())return new Wu({config:f}).createTransactionForExecute(l,{contract:b,function:"func"in u&&u.func||"",gasLimit:"gasLimit"in u?BigInt(u.gasLimit||0):0n,arguments:V,tokenTransfers:I,nativeTransferAmount:C});throw u.type==="query"?new Error("WarpActionExecutor: Invalid action type for createTransactionForExecute; Use executeQuery instead"):u.type==="collect"?new Error("WarpActionExecutor: Invalid action type for createTransactionForExecute; Use executeCollect instead"):new Error(`WarpActionExecutor: Invalid action type (${u.type})`)}async getTransactionExecutionResults(r,i,s){let u=xt(r,i),l=await De.apply(this.config,r),{values:p,results:f}=await ds(this,l,u,s,i),b=X.getNextInfo(this.config,l,i,f),x=this.getPreparedMessages(l,f);return{success:s.status.isSuccessful(),warp:l,action:i,user:this.config.user?.wallet||null,txHash:s.hash,next:b,values:p,results:f,messages:x}}async executeQuery(r,i,s){let u=xt(r,i);if(!u)throw new Error("WarpActionExecutor: Action not found");if(!u.func)throw new Error("WarpActionExecutor: Function not found");let l=await X.getChainInfoForAction(this.config,u),p=await De.apply(this.config,r),f=await this.getAbiForAction(u),{args:b}=await this.getTxComponentsFromInputs(l,u,s),x=b.map(A=>this.serializer.stringToTyped(A)),C=X.getChainEntrypoint(l,this.config.env),I=vi.newFromBech32(u.address),R=C.createSmartContractController(f),V=R.createQuery({contract:I,function:u.func,arguments:x}),O=await R.runQuery(V),y=O.returnCode==="ok",m=new Ou,d=f.getEndpoint(O.function),g=O.returnDataParts.map(A=>Buffer.from(A)),_=m.buffersToValues(g,d.output),{values:a,results:E}=await ms(p,_,i),N=X.getNextInfo(this.config,p,i,E);return{success:y,warp:p,action:i,user:this.config.user?.wallet||null,txHash:null,next:N,values:a,results:E,messages:this.getPreparedMessages(p,E)}}async executeCollect(r,i,s,u){let l=xt(r,i);if(!l)throw new Error("WarpActionExecutor: Action not found");let p=await X.getChainInfoForAction(this.config,l),f=await De.apply(this.config,r),b=await this.getResolvedInputs(p,l,s),x=this.getModifiedInputs(b),C=y=>{if(!y.value)return null;let m=this.serializer.stringToNative(y.value)[1];if(y.input.type==="biguint")return m.toString();if(y.input.type==="esdt"){let d=m;return{token:d.token.identifier,nonce:d.token.nonce.toString(),amount:d.amount.toString()}}else return m},I=new Headers;I.set("Content-Type","application/json"),I.set("Accept","application/json"),Object.entries(l.destination.headers||{}).forEach(([y,m])=>{I.set(y,m)});let R=Object.fromEntries(x.map(y=>[y.input.as||y.input.name,C(y)])),V=l.destination.method||"GET",O=V==="GET"?void 0:JSON.stringify({inputs:R,meta:u});try{let y=await fetch(l.destination.url,{method:V,headers:I,body:O}),m=await y.json(),{values:d,results:g}=await gs(f,m,i),_=X.getNextInfo(this.config,f,i,g);return{success:y.ok,warp:f,action:i,user:this.config.user?.wallet||null,txHash:null,next:_,values:d,results:g,messages:this.getPreparedMessages(f,g)}}catch(y){return console.error(y),{success:!1,warp:f,action:i,user:this.config.user?.wallet||null,txHash:null,next:null,values:[],results:{},messages:{}}}}async getTxComponentsFromInputs(r,i,s,u){let l=await this.getResolvedInputs(r,i,s),p=this.getModifiedInputs(l),f=p.find(A=>A.input.position==="receiver")?.value,b="address"in i?i.address:null,x=f?.split(":")[1]||b||u?.toBech32();if(!x)throw new Error("WarpActionExecutor: Destination/Receiver not provided");let C=vi.newFromBech32(x),I=this.getPreparedArgs(i,p),R=p.find(A=>A.input.position==="value")?.value||null,V="value"in i?i.value:null,O=BigInt(R?.split(":")[1]||V||0),y=p.filter(A=>A.input.position==="transfer"&&A.value).map(A=>A.value),d=[...("transfers"in i?i.transfers:[])?.map(this.toTypedTransfer)||[],...y?.map(A=>this.serializer.stringToNative(A)[1])||[]],g=p.find(A=>A.input.position==="data")?.value,_="data"in i?i.data||"":null,a=g||_||null,E=a?this.serializer.stringToTyped(a).valueOf():null,N=E?Buffer.from(E):null;return{destination:C,args:I,value:O,transfers:d,data:N}}async getResolvedInputs(r,i,s){let u=i.inputs||[],l=await Promise.all(s.map(f=>this.preprocessInput(r,f))),p=(f,b)=>{if(f.source==="query"){let x=this.url.searchParams.get(f.name);return x?this.serializer.nativeToString(f.type,x):null}else return f.source===U.Source.UserWallet?this.config.user?.wallet?this.serializer.nativeToString("address",this.config.user.wallet):null:l[b]||null};return u.map((f,b)=>({input:f,value:p(f,b)}))}getModifiedInputs(r){return r.map((i,s)=>{if(i.input.modifier?.startsWith("scale:")){let[,u]=i.input.modifier.split(":");if(isNaN(Number(u))){let l=Number(r.find(b=>b.input.name===u)?.value?.split(":")[1]);if(!l)throw new Error(`WarpActionExecutor: Exponent value not found for input ${u}`);let p=i.value?.split(":")[1];if(!p)throw new Error("WarpActionExecutor: Scalable value not found");let f=Wt(p,+l);return{...i,value:`${i.input.type}:${f}`}}else{let l=i.value?.split(":")[1];if(!l)throw new Error("WarpActionExecutor: Scalable value not found");let p=Wt(l,+u);return{...i,value:`${i.input.type}:${p}`}}}else return i})}async preprocessInput(r,i){try{let[s,u]=i.split(U.ArgParamsSeparator,2);if(s==="esdt"){let[l,p,f,b]=u.split(U.ArgCompositeSeparator);if(b)return i;let x=new xs({identifier:l,nonce:BigInt(p)});if(!new Bu().isFungible(x))return i;let R=ys(l)?.decimals;if(R||(R=(await(await fetch(`${r.apiUrl}/tokens/${l}`)).json()).decimals),!R)throw new Error(`WarpActionExecutor: Decimals not found for token ${l}`);let V=new vs({token:x,amount:Wt(f,R)});return this.serializer.nativeToString(s,V)+U.ArgCompositeSeparator+R}return i}catch{return i}}async getAbiForAction(r){if(r.abi)return await this.fetchAbi(r);let i=se(this.config),s=await this.contractLoader.getVerificationInfo(r.address,i);if(!s)throw new Error("WarpActionExecutor: Verification info not found");return xi.create(s.abi)}getPreparedArgs(r,i){let s="args"in r?r.args||[]:[];return i.forEach(({input:u,value:l})=>{if(!l||!u.position?.startsWith("arg:"))return;let p=Number(u.position.split(":")[1])-1;s.splice(p,0,l)}),s}getPreparedMessages(r,i){let s=Object.entries(r.messages||{}).map(([u,l])=>[u,Bt(l,i)]);return Object.fromEntries(s)}async fetchAbi(r){if(!r.abi)throw new Error("WarpActionExecutor: ABI not found");if(r.abi.startsWith(U.IdentifierType.Hash)){let i=new Ut(this.config),s=r.abi.split(U.IdentifierParamSeparator)[1],u=await i.createFromTransactionHash(s);if(!u)throw new Error(`WarpActionExecutor: ABI not found for hash: ${r.abi}`);return xi.create(u.content)}else{let s=await(await fetch(r.abi)).json();return xi.create(s)}}toTypedTransfer(r){return new vs({token:new xs({identifier:r.token,nonce:BigInt(r.nonce||0)}),amount:BigInt(r.amount||0)})}};var ws=class{constructor(r){this.config=r}async search(r,i,s){if(!this.config.index?.url)throw new Error("WarpIndex: Index URL is not set");try{let u=await fetch(this.config.index?.url,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.config.index?.apiKey}`,...s},body:JSON.stringify({[this.config.index?.searchParamName||"search"]:r,...i})});if(!u.ok)throw new Error(`WarpIndex: search failed with status ${u.status}`);return(await u.json()).hits}catch(u){throw console.error("WarpIndex: Error searching for warps: ",u),u}}};export{tn as BrandBuilder,Se as CacheKey,Ji as CacheTtl,oe as Config,Ut as WarpAbiBuilder,bs as WarpActionExecutor,st as WarpArgSerializer,Lt as WarpBuilder,Me as WarpCache,U as WarpConstants,or as WarpContractLoader,ws as WarpIndex,De as WarpInterpolator,Dt as WarpLink,tt as WarpProtocolVersions,nt as WarpRegistry,X as WarpUtils,Ft as WarpValidator,wl as address,vl as biguint,bl as boolean,El as codemeta,fl as composite,Sl as esdt,$u as getChainExplorerUrl,rt as getLatestProtocolIdentifier,se as getMainChainInfo,xt as getWarpActionByIndex,Cl as hex,pl as list,Al as nothing,cl as option,ll as optional,Bt as replacePlaceholders,Wt as shiftBigintBy,dl as string,Qi as toPreviewText,fr as toTypedChainInfo,_l as token,gl as u16,yl as u32,xl as u64,ml as u8,hl as variadic};
|