@catena/cli 0.1.0 → 0.2.1

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.
Files changed (2) hide show
  1. package/dist/index.mjs +262 -210
  2. package/package.json +3 -3
package/dist/index.mjs CHANGED
@@ -1,15 +1,174 @@
1
1
  #!/usr/bin/env node
2
- import{defineCommand as e,renderUsage as t,runMain as n}from"citty";import*as r from"valibot";import*as i from"node:crypto";import{ECDH as a,createECDH as o,createHash as s,randomBytes as c}from"node:crypto";import{execFile as l,spawn as u}from"node:child_process";import{chmodSync as d,existsSync as f,mkdirSync as p,readFileSync as m,realpathSync as h,renameSync as g,rmSync as _,statSync as v,writeFileSync as y}from"node:fs";import{homedir as b}from"node:os";import{dirname as x,isAbsolute as S,join as C,resolve as w}from"node:path";import{createServer as T}from"node:http";import E from"semver";var D=Object.create,O=Object.defineProperty,k=Object.getOwnPropertyDescriptor,A=Object.getOwnPropertyNames,ee=Object.getPrototypeOf,j=Object.prototype.hasOwnProperty,M=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(e){throw n=[e],e}},N=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),te=(e,t)=>{let n={};for(var r in e)O(n,r,{get:e[r],enumerable:!0});return t||O(n,Symbol.toStringTag,{value:`Module`}),n},ne=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=A(t),a=0,o=i.length,s;a<o;a++)s=i[a],!j.call(e,s)&&s!==n&&O(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=k(t,s))||r.enumerable});return e},P=(e,t,n)=>(n=e==null?{}:D(ee(e)),ne(t||!e||!e.__esModule?O(n,`default`,{value:e,enumerable:!0}):n,e)),F=e=>j.call(e,`module.exports`)?e[`module.exports`]:ne(O({},`__esModule`,{value:!0}),e),re=`@catena/cli`,I=`0.1.0`;const ie=[`base`,`base-sepolia`],ae=[`usdc`],oe=r.picklist(ie),se=r.picklist(ae);r.picklist([`evm`]);const ce=r.pipe(r.string(),r.trim(),r.regex(/^0x[0-9a-fA-F]{40}$/,`Must be a 0x-prefixed hex wallet address`),r.brand(`EvmAddress`)),le=`base`,ue=`usdc`,de=[`base`];r.picklist([`always`,`testnet`]),r.picklist([`bridge-internal-transfer`,`bridge-wallet-transfer`,`wallet-bridge-transfer`,`wallet-wallet-transfer`]);const fe=[{network:`base`,networkLabel:`Base`,addressFamily:`evm`,blockExplorerUrl:`https://basescan.org`,blockExplorerName:`Basescan`,asset:`usdc`,assetLabel:`USDC`,assetDecimals:6,contractAddress:`0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913`,availabilityGate:`always`,chainFeeUsd:`0`,walletTransferFeeUsd:`0`,transferRoutes:[`bridge-internal-transfer`,`bridge-wallet-transfer`,`wallet-bridge-transfer`,`wallet-wallet-transfer`],provider:{alchemyNetwork:`base`,bridgePaymentRail:`base`}},{network:`base-sepolia`,networkLabel:`Base Sepolia`,addressFamily:`evm`,isTestnet:!0,blockExplorerUrl:`https://sepolia.basescan.org`,blockExplorerName:`Sepolia Basescan`,asset:`usdc`,assetLabel:`USDC`,assetDecimals:6,contractAddress:`0x036CbD53842c5426634e7929541eC2318f3dCF7e`,availabilityGate:`testnet`,chainFeeUsd:`0`,walletTransferFeeUsd:`0`,transferRoutes:[`wallet-wallet-transfer`],provider:{alchemyNetwork:`base-sepolia`}}];function pe(e){return{id:e.network,label:e.networkLabel,addressFamily:e.addressFamily,blockExplorerUrl:e.blockExplorerUrl,blockExplorerName:e.blockExplorerName,...e.isTestnet?{isTestnet:!0}:{}}}function L(e){return{id:e.asset,label:e.assetLabel,decimals:e.assetDecimals}}function me(e){return{network:e.network,asset:e.asset,contractAddress:e.contractAddress}}function he(e){return{id:`${e.network}-usdc`,label:`${e.networkLabel} USDC`,network:e.network,asset:`usdc`}}function R(e){let t=[];for(let n of e)t.some(e=>e.id===n.network)||t.push(pe(n));return t}function ge(e){let t=[],n=new Set;for(let r of e)n.has(r.asset)||(n.add(r.asset),t.push(L(r)));return t}function _e(e){return e.asset===ue}const ve=R(fe);ge(fe),fe.map(me),fe.filter(_e).map(he),new Map(fe.map(e=>[`${e.network}:${e.asset}`,e.contractAddress])),new Map(ve.map(e=>[e.id,e]));function z(e){console.error(ye(e)),process.exit(1)}function ye(e){return typeof e==`string`?e:e instanceof Error?e.message:String(e)}const be=r.string(),xe=r.boolean();function B(e){return e===void 0}function Se(e){return e.issues?.[0]?.message??`Invalid value`}function Ce(e,t,n,r){return z(`${e}: ${t}${r?` (got: ${String(n)})`:``}`)}function we(e,t,n,i){let a=r.safeParse(e,t);return a.success?a.output:Ce(n,Se(a),t,i)}function V(e,t){let n=t.schema??be;return{type:e,description:t.description,negativeDescription:t.negativeDescription,required:t.required,default:t.default,parseValue(e,r){let i=B(e)?t.default:e;if(B(i)){t.required===!0&&z(`${r} is required`);return}return we(n,i,r,t.showValueInError===!0)}}}function H(e){return V(`string`,e)}function Te(e){return V(`positional`,e)}function U(e){return{type:`boolean`,description:e.description,negativeDescription:e.negativeDescription,required:e.required,default:e.default,parseValue(t,n){let r=B(t)?e.default:t;if(B(r)){e.required===!0&&z(`${n} is required`);return}return we(xe,r,n,!1)}}}function Ee(e){return De(`string`,e)}function De(e,t){return V(e,{description:t.description,required:t.required,default:t.default,schema:r.picklist(t.choices,`must be one of ${t.choices.join(`|`)}`),showValueInError:!0})}function Oe(e,t){return t.type===`positional`?`<${e}>`:`--${e}`}function ke(e){let t=e.required??(e.type===`positional`?!1:void 0);return e.type===`boolean`?{type:e.type,description:e.description,negativeDescription:e.negativeDescription,required:t,default:typeof e.default==`boolean`?e.default:void 0}:{type:e.type,description:e.description,required:t,default:typeof e.default==`string`?e.default:void 0}}function W(e){return{args:Object.fromEntries(Object.entries(e).map(([e,t])=>[e,ke(t)])),label(t){return Oe(t,e[t])},parse(t){return Object.fromEntries(Object.entries(e).map(([e,n])=>[e,n.parseValue(t[e],Oe(e,n))]))}}}const Ae=H({description:`Credential profile name`}),je=U({description:`Print compact single-line JSON (for piping)`,default:!1}),Me=/^[a-zA-Z0-9_-]+$/,G=r.pipe(r.string(`ID must be a string`),r.minLength(1,`ID must not be empty`),r.maxLength(256,`ID is too long (max 256 characters)`),r.regex(Me,`ID may only contain letters, digits, hyphens, and underscores`));async function Ne(e,t){let n=de.find(e=>e===t);if(n!==void 0)return n;let r=await e.getEnabledOnchainNetworks(),i=r.find(e=>e===t);return i===void 0?z(`--network: ${t} is not available on this environment (enabled: ${r.join(`|`)})`):i}var Pe=`0.1.0`;const Fe=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,K=Pe;function Ie(e,t){if(!Fe.test(e))throw Error(`${t} must be a valid HTTP token`)}function Le(e){return e?(Ie(e.name,`clientInfo.name`),Ie(e.version,`clientInfo.version`),{"Catena-Client":e.name,"Catena-Client-Version":e.version,"User-Agent":`catena-${e.name}/${e.version} catena-agent-client/${K}`}):{}}const Re={pending:{key:`pending`,label:`Pending`,color:`neutral`},processing:{key:`processing`,label:`Processing`,color:`info`},completed:{key:`completed`,label:`Completed`,color:`success`},blocked:{key:`blocked`,label:`Blocked`,color:`error`},failed:{key:`failed`,label:`Failed`,color:`error`}};r.picklist([`created`,`initiated`,`pending`,`pending_approval`,`approved`,`evaluating`,`executing`,`manual_review`,`processing`,`provider_pending`,`completed`,`blocked`,`denied`,`expired`,`failed`,`reversed`]);const ze={created:`pending`,initiated:`pending`,pending:`pending`,pending_approval:`pending`,approved:`processing`,evaluating:`processing`,executing:`processing`,manual_review:`processing`,processing:`processing`,provider_pending:`processing`,completed:`completed`,blocked:`blocked`,denied:`blocked`,expired:`failed`,failed:`failed`,reversed:`failed`};function Be(e){let t=ze[e];return t?Re[t]:null}Re.pending,Re.processing,Re.completed,Re.blocked,Re.failed;const Ve=r.object({amount:r.string(),asset_id:r.string()}),He=r.pipe(r.string(),r.isoTimestamp()),Ue=r.object({sessionToken:r.string(),refreshToken:r.string(),expiresAt:He}),We=r.object({success:r.literal(!0)}),q=r.object({id:r.string(),name:r.string(),status:r.string(),organizationId:r.string(),operatorEmail:r.nullable(r.string())}),Ge=r.object({agent:q}),Ke=r.object({id:r.string(),ruleType:r.picklist([`per_transaction_amount`,`daily_amount`,`weekly_amount`,`monthly_amount`,`hourly_count`,`daily_count`]),thresholdAmount:r.optional(Ve),thresholdCount:r.optional(r.number()),action:r.picklist([`block`,`require_approval`]),requiredApprovals:r.number(),accountAggregationScope:r.picklist([`per_account`,`across_accounts`]),actorAggregationScope:r.picklist([`per_agent`,`per_policy`]),displayOrder:r.number()}),qe=r.object({id:r.string(),organizationId:r.string(),policyId:r.string(),capability:r.picklist([`query_balance`,`read`,`send`,`transfer`]),accountId:r.string(),rules:r.array(Ke),createdAt:He,updatedAt:He}),Je=r.object({mode:r.picklist([`open`,`restricted`]),allowedCounterparties:r.optional(r.array(r.string())),createAction:r.optional(r.picklist([`allow`,`block`,`require_approval`])),allowCreate:r.optional(r.boolean())}),Ye=r.object({id:r.optional(r.string()),description:r.optional(r.string()),version:r.optional(r.number()),name:r.string(),capabilities:r.array(r.string()),counterpartyRules:r.optional(Je),policyCapabilities:r.array(qe)}),Xe=r.object({policy:Ye}),Ze=r.object({accounts:r.array(r.object({id:r.string(),name:r.string(),type:r.string(),currency:r.string()}))}),Qe=r.object({accountId:r.string(),balance:Ve,balances:r.optional(r.object({total:Ve,available:Ve}))}),$e=r.object({id:r.string(),type:r.picklist([`operator-send`,`operator-transfer`,`operator-deposit`,`operator-refund`,`microdeposit`]),action:r.optional(r.string()),status:r.picklist([`pending`,`processing`,`completed`,`failed`,`reversed`]),movementStatus:r.picklist([`initiated`,`provider_pending`,`processing`,`completed`,`failed`,`reversed`,`manual_review`]),direction:r.picklist([`incoming`,`outgoing`]),amount:Ve,fee:Ve,currency:r.string(),counterpartyName:r.optional(r.string()),method:r.optional(r.picklist([`ach`,`wire`,`on-chain`])),memo:r.optional(r.string()),description:r.optional(r.string()),txHash:r.optional(r.string()),createdAt:He,completedAt:r.optional(He)}),et=r.object({accountId:r.string(),transactions:r.array($e),total:r.number()}),tt=r.object({accountId:r.string(),address:r.string(),liquidationAddressId:r.optional(r.string()),source:r.picklist([`wallet`,`liquidation`])}),nt=r.object({networks:r.array(oe)}),rt=r.object({id:r.string(),name:r.string(),rails:r.array(r.object({id:r.string(),type:r.string(),walletAddress:r.optional(r.string()),network:r.optional(r.string()),bankName:r.optional(r.string()),accountNumber:r.optional(r.string())}))}),it=r.object({counterparties:r.array(rt)}),at=r.pipe(r.picklist([`created`,`evaluating`,`approved`,`pending_approval`,`blocked`,`denied`,`expired`,`executing`,`completed`,`failed`]),r.transform(e=>Be(e)?.key??`processing`)),ot=r.object({type:r.literal(`submit_stamp`),signingRequestId:r.string(),signer:r.object({algorithm:r.literal(`p256`),publicKeyHex:r.string()}),preparedBody:r.object({body:r.string(),bodyHash:r.string(),expiresAt:He,prepareToken:r.string()})}),st=r.object({id:r.string(),type:r.picklist([`send`,`transfer`,`wallet_send`,`create_counterparty`,`x402`]),status:at,reasons:r.array(r.string()),data:r.optional(r.nullable(r.record(r.string(),r.unknown())),null),metadata:r.optional(r.object({dataUrl:r.nullable(r.string())})),nextAction:r.optional(ot)}),ct=[`ach`,`wire`,`on-chain`],lt=r.picklist(ct),ut=r.object({type:r.literal(`send`),accountId:r.string(),counterpartyRailId:r.string(),amount:r.string(),method:lt,memo:r.optional(r.string()),description:r.optional(r.string())}),dt=r.object({type:r.literal(`transfer`),accountId:r.string(),toAccountId:r.string(),amount:r.string(),memo:r.optional(r.string()),description:r.optional(r.string())}),ft=r.object({type:r.literal(`create_counterparty`),name:r.string(),email:r.optional(r.string()),rail:r.unknown()}),pt=r.looseObject({scheme:r.string(),network:r.string(),asset:r.string(),amount:r.string(),payTo:r.string(),maxTimeoutSeconds:r.number()}),mt=r.looseObject({url:r.string()}),ht=r.object({type:r.literal(`x402`),accountId:r.string(),paymentRequirements:pt,resource:r.optional(mt)});r.variant(`type`,[ut,dt,ft,ht]);function gt(e){return e.type===`send`||e.type===`transfer`?{...e,amount:{amount:e.amount,asset_id:`USD`}}:e}const _t=r.picklist([`user_presence_required`,`consensus_needed`,`broadcast`,`confirmed`,`rejected`,`manual_review`,`failed`]);r.object({body:r.string(),bodyHash:r.string(),expiresAt:He,prepareToken:r.string()}),r.object({publicKeyHex:r.string(),stampHeaderName:r.string(),stampHeaderValue:r.string()});const vt=r.object({intentId:r.string(),signingRequestId:r.string(),status:_t}),yt=r.object({intentId:r.string(),signingRequestId:r.string(),status:r.literal(`completed`),x402:r.object({paymentSignature:r.string()})}),bt=r.union([yt,vt]);var xt=class extends Error{status;code;constructor(e,t,n){super(n?`API error ${e} [${n}]: ${t}`:`API error ${e}: ${t}`),this.name=`ApiError`,this.status=e,this.code=n}};const St=r.object({error:r.nullish(r.string()),message:r.nullish(r.string()),code:r.nullish(r.string())});async function Ct(e){let t=r.safeParse(St,await e.json().catch(()=>void 0)),n=t.success?t.output:{};return new xt(e.status,n.error??n.message??e.statusText,n.code??void 0)}var wt=class{baseUrl;clientInfo;agentId=null;sessionToken=null;refreshToken=null;signer=null;expiresAtMs=null;refreshPromise=null;onRefresh;constructor(e){this.baseUrl=e.baseUrl,this.clientInfo=e.clientInfo,this.onRefresh=e.onRefresh}setTokens(e){let t=Date.parse(e.expiresAt);if(Number.isNaN(t))throw Error(`Invalid expiresAt timestamp: "${e.expiresAt}"`);this.agentId=e.agentId,this.sessionToken=e.sessionToken,this.refreshToken=e.refreshToken,this.signer=e.signer??null,this.expiresAtMs=t}getLocalSigner(){return this.signer}isConnected(){return this.agentId!==null}getAgentId(){return this.agentId}shouldRefreshCachedSession(){return this.sessionToken===null||this.expiresAtMs===null?!0:this.expiresAtMs<=Date.now()+300*1e3}async ensureFreshSession(){return this.isConnected()?this.shouldRefreshCachedSession()?this.dedupedRefresh():!0:!1}dedupedRefresh(){return this.refreshPromise??=this.refresh().finally(()=>{this.refreshPromise=null}),this.refreshPromise}async requestRaw(e,t=!1){if(this.agentId===null||this.refreshToken===null)throw Error(`CatenaClient is not connected. Run the link tool to authenticate.`);if((this.sessionToken===null||this.shouldRefreshCachedSession())&&!await this.ensureFreshSession())throw Error(`Cached session is missing or near expiry and refresh failed. Re-authenticate with catena link.`);let n=new URL(`${this.baseUrl}/v1/agent-api${e.path}`);for(let[t,r]of Object.entries(e.query??{}))r!==void 0&&n.searchParams.set(t,r);let r=await fetch(n.toString(),{method:e.method,headers:{"Content-Type":`application/json`,...e.headers,...Le(this.clientInfo),Authorization:`Bearer ${this.sessionToken}`},body:e.body===void 0?null:JSON.stringify(e.body)});return r.status===401&&!t&&(await r.clone().json().catch(()=>({error:`unknown`}))).error===`session_expired`&&await this.dedupedRefresh()?await this.requestRaw(e,!0):r}async request(e,t){let n=await this.requestRaw(e);if(!n.ok)throw await Ct(n);return r.parse(t,await n.json())}async refresh(){if(!this.refreshToken||this.agentId===null)return!1;let e=this.refreshToken,t=this.agentId,n=this.signer;try{let i=await fetch(`${this.baseUrl}/v1/agent-api/refresh`,{method:`POST`,headers:{"Content-Type":`application/json`,...Le(this.clientInfo)},body:JSON.stringify({refreshToken:this.refreshToken})});if(!i.ok||this.agentId!==t||this.refreshToken!==e)return!1;let a={agentId:t,...r.parse(Ue,await i.json()),...n?{signer:n}:{}};return this.setTokens(a),await this.onRefresh(a),!0}catch{return!1}}async whoami(){return(await this.request({method:`GET`,path:`/me`},Ge)).agent}async submitFeedback(e){await this.request({method:`POST`,path:`/feedback`,body:{body:e}},We)}async getPolicy(){return(await this.request({method:`GET`,path:`/policy`},Xe)).policy}async getAccounts(){return this.request({method:`GET`,path:`/accounts`},Ze)}async getEnabledOnchainNetworks(){try{return(await this.request({method:`GET`,path:`/onchain-networks`},nt)).networks}catch(e){if(e instanceof xt&&e.status===404)return[...de];throw e}}async getAccountBalance(e){return this.request({method:`GET`,path:`/accounts/${encodeURIComponent(e)}/balance`},Qe)}async getAccountTransactions(e,t={}){return this.request({method:`GET`,path:`/accounts/${encodeURIComponent(e)}/transactions`,query:{start:t.start,end:t.end,limit:t.limit?.toString(),offset:t.offset?.toString()}},et)}async getAccountDepositAddress(e,t){return this.request({method:`GET`,path:`/accounts/${encodeURIComponent(e)}/deposit-address`,query:{network:t.network,asset:t.asset}},tt)}async getCounterparties(e={}){return this.request({method:`GET`,path:`/counterparties`,query:{address:e.address,network:e.network}},it)}async createIntent(e){return this.request({method:`POST`,path:`/intents`,body:{action:gt(e.action)},...e.idempotencyKey!==void 0&&{headers:{"Idempotency-Key":e.idempotencyKey}}},st)}async getIntent(e){return this.request({method:`GET`,path:`/intents/${encodeURIComponent(e)}`},st)}async unlink(){await this.request({method:`POST`,path:`/unlink`},We),this.agentId=null,this.sessionToken=null,this.refreshToken=null,this.signer=null,this.expiresAtMs=null,this.refreshPromise=null}async submitStamp(e){return this.request({method:`POST`,path:`/intents/${encodeURIComponent(e.intentId)}/submit-stamp`,body:{preparedBody:e.preparedBody,stamp:e.stamp}},bt)}};const Tt=[`registered`,`already_registered`,`not_applicable`,`registration_failed`];function Et(){let e=o(`prime256v1`);return e.generateKeys(),{algorithm:`p256`,privateKeyHex:e.getPrivateKey().toString(`hex`).padStart(64,`0`),publicKeyHex:e.getPublicKey(`hex`,`compressed`)}}function Dt(e){try{let t=a.convertKey(e,`prime256v1`,`hex`,`hex`,`uncompressed`),n=Buffer.isBuffer(t)?t:Buffer.from(t,`hex`);return n.length===65?n:null}catch{return null}}function Ot(e){let t=Dt(e);if(!t)return null;let n=t.subarray(1,33).toString(`base64url`),r=t.subarray(33,65).toString(`base64url`);return s(`sha256`).update(`{"crv":"P-256","kty":"EC","x":"${n}","y":"${r}"}`,`utf8`).digest(`base64url`)}const kt=r.pipe(r.string(),r.regex(/^0[23][0-9a-f]{64}$/)),At=r.pipe(r.string(),r.regex(/^[0-9a-f]{64}$/)),jt=r.object({status:r.picklist(Tt),publicKeyHex:r.optional(kt),reason:r.optional(r.string())}),Mt=r.object({algorithm:r.literal(`p256`),privateKeyHex:At,publicKeyHex:kt,registration:jt}),Nt=r.object({version:r.literal(`signer-1`),signer:Mt}),Pt=r.object({version:r.literal(1),refreshToken:r.pipe(r.string(),r.minLength(1)),sessionToken:r.pipe(r.string(),r.minLength(1)),expiresAt:r.pipe(r.string(),r.isoTimestamp())}),Ft=r.object({version:r.literal(2),refreshToken:r.pipe(r.string(),r.minLength(1)),sessionToken:r.pipe(r.string(),r.minLength(1)),expiresAt:r.pipe(r.string(),r.isoTimestamp()),signer:Mt}),It=r.variant(`version`,[Pt,Ft]),Lt=r.variant(`version`,[Nt,Pt,Ft]);function Rt(e){return r.parse(It,e)}function zt(e){return r.parse(Lt,e)}function Bt(e){let t=r.safeParse(Lt,e);return t.success?t.output:null}function Vt(e){return{version:`signer-1`,signer:{algorithm:e.algorithm,privateKeyHex:e.privateKeyHex,publicKeyHex:e.publicKeyHex,registration:{status:`not_applicable`,reason:`pending_claim`}}}}function Ht(e,t){try{return zt(JSON.parse(e))}catch(e){throw Error(`${t} credential has an unsupported format`,{cause:e})}}function Ut(e){return e.signer?Rt({version:2,refreshToken:e.refreshToken,sessionToken:e.sessionToken,expiresAt:e.expiresAt,signer:e.signer}):Rt({version:1,refreshToken:e.refreshToken,sessionToken:e.sessionToken,expiresAt:e.expiresAt})}function Wt(e){return JSON.stringify(e)}function Gt(e,t){return JSON.stringify(e)===JSON.stringify(t)}function Kt(e){return(t,n)=>qt(e,t,n)}function qt(e,t,n){return new Promise((r,i)=>{let a=u(e,[...t],{stdio:[`pipe`,`pipe`,`pipe`]}),o=[],s=[],c=!1,l=!1,d=null,f=null,p=null,m=e=>{c||(c=!0,f!==null&&clearTimeout(f),p!==null&&clearTimeout(p),r(e))},h=e=>{c||(c=!0,f!==null&&clearTimeout(f),p!==null&&clearTimeout(p),i(e))};f=setTimeout(()=>{l=!0,a.kill(`SIGTERM`),p=setTimeout(()=>{a.kill(`SIGKILL`),m({stdout:o.join(``),stderr:s.join(``),status:124})},1e3)},3e4),a.stdout.setEncoding(`utf8`),a.stderr.setEncoding(`utf8`),a.stdout.on(`data`,e=>o.push(e)),a.stderr.on(`data`,e=>s.push(e)),a.on(`error`,t=>{h(Error(`Unable to run ${e}: ${t.message}`))}),a.on(`close`,t=>{if(d!==null&&t===0){h(Error(`Unable to write to ${e} stdin: ${d.message}`));return}m({stdout:o.join(``),stderr:s.join(``),status:l?124:t})}),a.stdin.on(`error`,e=>{d=e});try{a.stdin.end(n)}catch(t){h(t instanceof Error?Error(`Unable to write to ${e} stdin: ${t.message}`):Error(`Unable to write to ${e} stdin`))}})}const Jt=`catena-agent`;function Yt(e){if(!Me.test(e))throw Error(`Invalid credential location for credential storage: "${e}"`);return e}const Xt=Kt(`/usr/bin/secret-tool`);function Zt(e){return e.status===1&&e.stdout===``&&e.stderr.trim()===``}function Qt(e,t){if(t.status===0)return;let n=$t(t);throw Error(`Linux Secret Service credential ${e} failed (secret-tool exited ${t.status??`without status`}): ${n}`)}function $t(e){let t=e.stderr.toLowerCase();return e.status===124?`secret service operation timed out`:t.includes(`cannot autolaunch`)||t.includes(`dbus`)||t.includes(`d-bus`)||t.includes(`org.freedesktop.secrets`)?`secret service session is unavailable`:/\blocked\b/.test(t)?`secret service keyring appears to be locked`:t.includes(`authorization`)||t.includes(`denied`)||t.includes(`not authorized`)?`secret service authorization was denied`:`secret service operation failed; ensure the Secret Service session is available and unlocked`}function en(e){return e instanceof Error?e.message.includes(`ENOENT`)?Error(`Linux Secret Service credential operation failed: /usr/bin/secret-tool was not found. Install libsecret-tools and ensure a Secret Service keyring is available.`,{cause:e}):e:Error(String(e))}var tn=class{runSecretTool;constructor(e={}){if((e.platform??process.platform)!==`linux`)throw Error(`Linux Secret Service credential storage is only supported on Linux`);this.runSecretTool=e.runSecretTool??Xt}async save(e,t){let n=zt(t),r=Yt(e);if(await this.savePassword(r,Wt(n)),!Gt(await this.resolveDirectPassword(r),n))throw Error(`Linux Secret Service credential save verification failed`)}async resolve(e){return this.resolveDirectPassword(Yt(e))}async delete(e){await this.deletePassword(Yt(e))}async savePassword(e,t){Qt(`save`,await this.runSecretToolCommand([`store`,`--label`,`${Jt} ${e}`,`app`,Jt,`account`,e],t))}async resolvePassword(e){let t=await this.runSecretToolCommand([`lookup`,`app`,Jt,`account`,e]);return Zt(t)?null:(Qt(`resolve`,t),t.stdout.replace(/\r?\n$/,``))}async resolveDirectPassword(e){let t=await this.resolvePassword(e);return t===null?null:Ht(t,`Linux Secret Service`)}async deletePassword(e){let t=await this.runSecretToolCommand([`clear`,`app`,Jt,`account`,e]);Zt(t)||Qt(`delete`,t)}async runSecretToolCommand(e,t){try{return await this.runSecretTool(e,t)}catch(e){throw en(e)}}};const nn=Kt(`/usr/bin/security`),rn=r.object({version:r.literal(1),encoding:r.literal(`base64-json`),chunks:r.pipe(r.number(),r.integer(),r.minValue(1),r.maxValue(64)),sha256:r.pipe(r.string(),r.regex(/^[a-f0-9]{64}$/))});function an(e){return e.status===44}function on(e,t){return`${e}:chunk:${t}`}function sn(e){let t=JSON.parse(e),n=Bt(t);if(n!==null)return{kind:`direct`,payload:n};let i=r.safeParse(rn,t);if(i.success)return{kind:`legacy`,manifest:i.output};throw Error(`macOS Keychain credential has an unsupported format`)}function cn(e,t){if(t.status===0)return;let n=ln(t);throw Error(`macOS Keychain credential ${e} failed (security exited ${t.status??`without status`})${n===null?``:`: ${n}`}`)}function ln(e){let t=e.stderr.toLowerCase();return e.status===124?`keychain operation timed out`:t.includes(`stdin isn't a terminal`)?`parent process has no terminal`:t.includes(`user interaction is not allowed`)?`keychain user interaction is not allowed`:t.includes(`authorization`)||t.includes(`denied`)?`keychain authorization was denied`:t.includes(`locked`)?`keychain appears to be locked`:null}function un(e){for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(n<32||n===127)throw Error(`macOS Keychain credential values cannot contain control characters`)}return`"${e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`)}"`}function dn(e,t){return[`add-generic-password`,`-s`,un(Jt),`-a`,un(e),`-w`,un(t),`-U`].join(` `)+`
3
- `}var fn=class{runSecurity;constructor(e={}){if((e.platform??process.platform)!==`darwin`)throw Error(`macOS Keychain credential storage is only supported on macOS`);this.runSecurity=e.runSecurity??nn}async save(e,t){let n=zt(t),r=Yt(e),i=await this.resolveLegacyChunkCount(r,64);if(await this.savePassword(r,Wt(n)),!Gt(await this.resolveDirectPassword(r),n))throw Error(`macOS Keychain credential save verification failed`);await this.deleteChunks(r,i)}async resolve(e){let t=Yt(e),n=await this.resolveKeychainItem(t);return n===null?null:n.kind===`direct`?n.payload:this.resolveLegacyPayload(t,n.manifest)}async delete(e){let t=Yt(e),n=await this.resolveLegacyChunkCount(t,64);await this.deleteChunks(t,n),await this.deletePassword(t)}async savePassword(e,t){cn(`save`,await this.runSecurity([`-i`],dn(e,t)))}async resolvePassword(e){let t=await this.runSecurity([`find-generic-password`,`-a`,e,`-s`,Jt,`-w`]);return an(t)?null:(cn(`resolve`,t),t.stdout.replace(/\r?\n$/,``))}async resolveKeychainItem(e){let t=await this.resolvePassword(e);return t===null?null:sn(t)}async resolveDirectPassword(e){let t=await this.resolveKeychainItem(e);if(t===null)return null;if(t.kind!==`direct`)throw Error(`macOS Keychain credential direct verification failed`);return t.payload}async resolveLegacyPayload(e,t){let n=[];for(let r=0;r<t.chunks;r++){let t=await this.resolvePassword(on(e,r));if(t===null)throw Error(`macOS Keychain credential chunk is missing`);n.push(t)}let r=n.join(``);if(s(`sha256`).update(r).digest(`hex`)!==t.sha256)throw Error(`macOS Keychain credential checksum mismatch`);return zt(JSON.parse(Buffer.from(r,`base64`).toString(`utf8`)))}async resolveLegacyChunkCount(e,t){let n=await this.resolvePassword(e);if(n===null)return 0;try{let e=sn(n);return e.kind===`legacy`?e.manifest.chunks:0}catch{return t}}async deleteChunks(e,t){for(let n=0;n<t;n++)await this.deletePassword(on(e,n))}async deletePassword(e){let t=await this.runSecurity([`delete-generic-password`,`-a`,e,`-s`,Jt]);an(t)||cn(`delete`,t)}};function pn(e={}){let t=e.platform??process.platform;if(t===`darwin`)return new fn({platform:t});if(t===`linux`)return new tn({platform:t});throw Error(`Catena credential storage is only supported on macOS and Linux`)}const mn=/^127(?:\.(?:25[0-5]|2[0-4]\d|1?\d?\d)){3}$/;function hn(e){let t=e.replace(/^\[|\]$/g,``);return t===`localhost`||t===`::1`||mn.test(t)}function gn(e,t={}){let n;try{n=new URL(e)}catch{return!1}return n.protocol===`https:`?!0:t.allowLoopbackHttp===!0&&n.protocol===`http:`&&hn(n.hostname)}function _n(e,t){if(!gn(e,{allowLoopbackHttp:!0}))throw Error(`${t} must be an https:// URL (http:// is allowed only for a loopback host): "${e}"`)}const vn=/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,63}$/,yn=r.object({status:r.optional(r.literal(`linked`),`linked`),bank_url:r.pipe(r.string(),r.minLength(1)),agent_id:r.pipe(r.string(),r.minLength(1)),client_instance_id:r.pipe(r.string(),r.regex(Me))}),bn=r.object({status:r.literal(`pending_connection`),bank_url:r.pipe(r.string(),r.minLength(1)),client_instance_id:r.pipe(r.string(),r.regex(Me)),created_at:r.pipe(r.string(),r.isoTimestamp())}),xn=r.variant(`status`,[yn,bn]);r.object({version:r.literal(1),default_profile:r.optional(r.string()),profiles:r.record(r.string(),xn),directories:r.optional(r.record(r.string(),r.string()))});const Sn=r.object({version:r.literal(1),default_profile:r.optional(r.string()),profiles:r.record(r.string(),r.unknown()),directories:r.optional(r.record(r.string(),r.unknown()))});function Cn(){return C(process.env.HOME??b(),`.catena`)}function wn(){return C(Cn(),`profiles.json`)}function Tn(e){return vn.test(e)}function En(e){if(!Tn(e))throw Error(`invalid profile name "${e}" (expected [a-zA-Z0-9][a-zA-Z0-9._-]{0,63})`)}function Dn(e){return typeof e!=`object`||!e||!(`code`in e)?!1:typeof e.code==`string`}function On(e,t){let n;try{n=JSON.parse(e)}catch(e){throw Error(`profiles.json is not valid JSON: ${e instanceof Error?e.message:String(e)}`,{cause:e})}if(typeof n==`object`&&n&&`version`in n){let e=n;if(e.version!==1)throw Error(`profiles.json version ${String(e.version)} is not supported (expected 1)`)}let i=r.parse(Sn,n),a={};for(let[e,n]of Object.entries(i.profiles)){if(!Tn(e)){t?.(`profiles: dropping invalid profile name "${e}"`);continue}let i=r.safeParse(xn,n);if(!i.success){t?.(`profiles: dropping malformed profile "${e}"`);continue}a[e]=i.output}if(i.default_profile!==void 0&&(En(i.default_profile),!Object.hasOwn(a,i.default_profile)))throw Error(`profiles.json default_profile "${i.default_profile}" is not linked`);let o={};for(let[e,n]of Object.entries(i.directories??{})){if(!S(e)){t?.(`profiles: dropping directory binding with relative path "${e}"`);continue}if(typeof n!=`string`||!Tn(n)){t?.(`profiles: dropping malformed directory binding "${e}"`);continue}o[e]=n}return{version:1,...i.default_profile===void 0?{}:{default_profile:i.default_profile},profiles:a,...Object.keys(o).length===0?{}:{directories:o}}}function kn(e){try{return On(m(wn(),`utf-8`),e)}catch(e){if(e instanceof Error&&Dn(e)&&e.code===`ENOENT`)return{version:1,profiles:{}};throw e}}function An(){p(Cn(),{recursive:!0,mode:448}),d(Cn(),448)}function jn(e){An();let t=wn(),n=`${t}.${c(6).toString(`hex`)}.tmp`;y(n,JSON.stringify(e,null,2)+`
4
- `,{encoding:`utf-8`,mode:384}),g(n,t)}function Mn(e,t){En(e);let n=r.parse(xn,t);_n(n.bank_url,`profile "${e}" bank_url`);let i=kn();jn({...i,profiles:{...i.profiles,[e]:n}})}function Nn(e){return e.status===`linked`}function Pn(e,t){return e.replace(/\/+$/,``)===t.replace(/\/+$/,``)}function Fn(e,t){let n=Object.entries(kn().profiles).toSorted(([e],[t])=>e.localeCompare(t)).find(([,n])=>Nn(n)&&n.agent_id===e&&Pn(n.bank_url,t));return n===void 0?null:n[0]}function In(e,t){let n=Object.fromEntries(Object.entries(e??{}).filter(([,e])=>t(e)));return Object.keys(n).length===0?{}:{directories:n}}function Ln(e){En(e);let t=kn(),{[e]:n,...r}=t.profiles;jn({version:1,...t.default_profile===e||t.default_profile===void 0?{}:{default_profile:t.default_profile},profiles:r,...In(t.directories,t=>t!==e)})}function Rn(e){try{return h(w(e))}catch{return w(e)}}function zn(e){return kn().directories?.[Rn(e)]??null}function Bn(e,t){En(t);let n=kn();if(!Object.hasOwn(n.profiles,t))throw Error(`Profile "${t}" is not linked. Run catena link --profile ${t} <agent-id>.`);let r=Rn(e);return jn({...n,directories:{...n.directories,[r]:t}}),r}function Vn(e){let t=kn(),n=Rn(e);if(t.directories===void 0||!Object.hasOwn(t.directories,n))return{directory:n,removed:!1};let{[n]:r,...i}=t.directories,{directories:a,...o}=t;return jn({...o,...Object.keys(i).length===0?{}:{directories:i}}),{directory:n,removed:!0}}function Hn(e){return En(e),kn().profiles[e]??null}function Un(){return`client_${c(16).toString(`hex`)}`}function Wn(e,t){let n=Hn(e);return t.agent_id===void 0?Gn(e,t.bank_url,n):Kn(e,t.bank_url,t.agent_id,n)}function Gn(e,t,n){if(n?.status===`linked`)throw Error(`Profile "${e}" is already linked. Choose a different profile name to start agent connection.`);let r=(n?.status===`pending_connection`&&Pn(n.bank_url,t)?n.client_instance_id:null)??Un();return Mn(e,{status:`pending_connection`,bank_url:t,client_instance_id:r,created_at:n?.status===`pending_connection`?n.created_at:new Date().toISOString()}),r}function Kn(e,t,n,r){if(r?.status===`linked`){if(r.agent_id!==n)throw Error(`Profile "${e}" is already linked to a different agent (${r.agent_id}). Link ${n} under a different --profile, or run 'catena unlink --profile ${e}' first to repoint it (add --force if that agent's credential is missing or revoked).`);if(!Pn(r.bank_url,t))throw Error(`Profile "${e}" is already linked to this agent on a different bank (${r.bank_url}). Link under a different --profile, or run 'catena unlink --profile ${e}' first (add --force if that credential is missing or revoked).`);return r.client_instance_id}let i=(r?.status===`pending_connection`&&Pn(r.bank_url,t)?r.client_instance_id:null)??Un();return Mn(e,{status:`linked`,bank_url:t,agent_id:n,client_instance_id:i}),i}function qn(e){En(e);let t=kn();if(!Object.hasOwn(t.profiles,e))throw Error(`Profile "${e}" is not linked. Run catena link --profile ${e} <agent-id>.`);jn({...t,default_profile:e})}function Jn(e){let t=e.toLowerCase().replace(/[^a-z0-9._-]+/g,`-`).replace(/^[^a-z0-9]+/,``).slice(0,64);return Tn(t)?t:`agent`}function Yn(e,t){if(!t(e))return e;for(let n=2;;n++){let r=`${e.slice(0,64-String(n).length-1)}-${n}`;if(!t(r))return r}}function Xn(e){En(e.reservationName),En(e.profileName);let t=r.parse(xn,e.profile);_n(t.bank_url,`profile "${e.profileName}" bank_url`);let n=kn(),{[e.reservationName]:i,...a}=n.profiles;if(!Object.hasOwn(n.profiles,e.reservationName)||i.client_instance_id!==t.client_instance_id)throw Error(`Link reservation "${e.reservationName}" changed during setup (a concurrent link from this directory?). Re-run 'catena link'.`);if(e.profileName!==e.reservationName&&Object.hasOwn(a,e.profileName))throw Error(`Profile "${e.profileName}" already exists; cannot finalize link under that name.`);let o=Object.fromEntries(Object.entries(n.directories??{}).map(([t,n])=>[t,n===e.reservationName?e.profileName:n]));jn({version:1,...n.default_profile===void 0?{}:{default_profile:n.default_profile===e.reservationName?e.profileName:n.default_profile},profiles:{...a,[e.profileName]:t},...Object.keys(o).length===0?{}:{directories:o}})}function Zn(e){return e instanceof Error?e.message:String(e)}function Qn(e){return e??pn()}function $n(e){let{profileName:t,bankUrl:n,agentId:r,clientInstanceId:i,payload:a}=e;return{ok:!0,profileName:t,bankUrl:n,agentId:r,clientInstanceId:i,refreshToken:a.refreshToken,sessionToken:a.sessionToken,expiresAt:a.expiresAt,...`signer`in a?{signer:a.signer}:{}}}async function er(e,t){let n;try{n=Hn(e.profileName)}catch(t){return{ok:!1,profileName:e.profileName,bankUrl:e.fallbackBankUrl,message:Zn(t)}}if(n===null)return{ok:!1,profileName:e.profileName,bankUrl:e.fallbackBankUrl,message:`Profile "${e.profileName}" is not linked. Run 'catena link --profile ${e.profileName}' to authenticate.`};try{_n(n.bank_url,`profile "${e.profileName}" bank_url`)}catch(t){return{ok:!1,profileName:e.profileName,bankUrl:e.fallbackBankUrl,message:Zn(t)}}if(n.status===`pending_connection`)return{ok:!1,profileName:e.profileName,bankUrl:n.bank_url,message:`Profile "${e.profileName}" is waiting for agent connection approval. Run 'catena link --profile ${e.profileName}' to finish setup.`};let r;try{r=await Qn(t).resolve(n.client_instance_id)}catch(t){return{ok:!1,profileName:e.profileName,bankUrl:n.bank_url,message:`Profile "${e.profileName}" credential unavailable for ${n.agent_id}: ${Zn(t)}. Run 'catena link --profile ${e.profileName} ${n.agent_id}' to authenticate.`}}return r===null||r.version===`signer-1`?{ok:!1,profileName:e.profileName,bankUrl:n.bank_url,message:`Profile "${e.profileName}" credential unavailable for ${n.agent_id}. Run 'catena link --profile ${e.profileName} ${n.agent_id}' to authenticate.`}:$n({profileName:e.profileName,bankUrl:n.bank_url,agentId:n.agent_id,clientInstanceId:n.client_instance_id,payload:r})}const tr=`https://api.catena.com`,nr=`CATENA_PROFILE`;function rr(e,t,n,r){if(e.directories===void 0)return null;let i;try{i=h(t)}catch{return null}let a=Object.entries(e.directories).map(([e,t])=>[e.replace(/\/+$/,``)||`/`,t]).filter(([e])=>i===e||i.startsWith(e===`/`?`/`:`${e}/`)).toSorted(([e],[t])=>t.length-e.length),o=null;for(let[t,n]of a){if(Object.hasOwn(e.profiles,n))return n;o??=`${t} -> "${n}"`}if(o===null)return null;if(n===`error`)throw Error(`This directory is bound to a profile that no longer exists (${o}). Run 'catena profiles unbind' here, bind it with 'catena profiles bind <name>', or run 'catena link' to re-establish it.`);return r?.(`profiles: ignoring stale directory binding ${o}`),null}function ir(e,t,n){if(e.flag!==void 0&&e.flag.length>0)return En(e.flag),{name:e.flag,source:`flag`};if(e.env!==void 0&&e.env.length>0){if(!Tn(e.env))throw Error(`${nr} is set to an invalid profile name "${e.env}"`);return{name:e.env,source:`env`}}if(e.cwd!==void 0){let r=rr(t,e.cwd,n,e.log);if(r!==null)return{name:r,source:`directory`}}return t.default_profile===void 0?null:{name:t.default_profile,source:`default`}}function ar(e){return ir(e,kn(e.log),`ignore`)}function or(e){let t=kn(e.log),n=ir(e,t,`error`);if(n!==null)return n;let r=Object.keys(t.profiles),i=Object.entries(t.profiles).filter(([,e])=>Nn(e)).map(([e])=>e);if(i.length===1){let[e]=i;return{name:e,source:`single`}}if(i.length===0){if(r.length===1){let[e]=r;return{name:e,source:`single`}}return r.length>1&&e.log?.(`profiles: ignoring ${r.length} pending profiles (${r.toSorted().join(`, `)}); none is linked`),{name:`default`,source:`fallback`}}throw Error(`Multiple profiles exist and none is selected (${i.toSorted().join(`, `)}). Pass --profile <name>, set ${nr}, run 'catena profiles use <name>', or run 'catena link' from an agent directory to bind it.`)}function sr(e,t){let n=new wt({baseUrl:e.bankUrl,clientInfo:{name:`cli`,version:I},onRefresh:async n=>{await t.save(e.clientInstanceId,Ut(n))}});return n.setTokens(e),n}function cr(){return pn()}async function lr(e){let t;try{t=or({flag:e,env:process.env[nr],cwd:process.cwd(),log:e=>console.error(e)}).name}catch(e){return z(e)}let n=await er({profileName:t,fallbackBankUrl:tr},void 0);n.ok||z(n.message);let r=sr(n,cr());return await r.ensureFreshSession()||console.error(`Warning: pre-emptive session refresh failed; will retry on first request.`),r}function ur(e,t){console.log(t?.compact?JSON.stringify(e):JSON.stringify(e,null,2))}function dr(e){return e.profile===void 0||e.profile.length===0?void 0:e.profile}async function fr(e,t){try{return await t(await lr(e))}catch(e){return z(e)}}function pr(e,t){return async(n,r)=>{let i=await fr(e,n);return ur(i,t),process.exit(r?.exitCode?r.exitCode(i):0)}}function mr(e){return pr(dr(e),{compact:e.json===!0})}const hr=se.options,gr=r.pipe(r.string(),r.regex(/^\d+$/,`must be a non-negative integer`),r.transform(Number),r.maxValue(2**53-1,`must be at most ${2**53-1}`)),_r=r.pipe(gr,r.maxValue(200,`must be at most 200`)),vr={profile:Ae,json:je},yr=W(vr),br=W({account:Te({description:`Account id`,required:!0,schema:G}),...vr}),xr=W({account:Te({description:`Account id`,required:!0,schema:G}),start:H({description:`Only include transactions at or after this ISO 8601 time`}),end:H({description:`Only include transactions at or before this ISO 8601 time`}),limit:H({description:`Maximum transactions to return (default 50, max 200)`,schema:_r}),offset:H({description:`Number of transactions to skip for pagination`,schema:gr}),...vr}),Sr=W({account:Te({description:`Account id`,required:!0,schema:G}),network:H({description:`Deposit network; defaults to base. Availability depends on the connected environment.`,default:le}),asset:Ee({description:`Deposit asset (${hr.join(`|`)})`,choices:hr,default:ue}),...vr}),Cr=e({meta:{name:`accounts`,description:`Inspect bank accounts`},subCommands:{list:e({meta:{name:`list`,description:`List accounts accessible under the agent's policy`},args:yr.args,async run({args:e}){await mr(yr.parse(e))(e=>e.getAccounts())}}),balance:e({meta:{name:`balance`,description:`Request an account balance through the policy engine`},args:br.args,async run({args:e}){let t=br.parse(e);await mr(t)(e=>e.getAccountBalance(t.account))}}),transactions:e({meta:{name:`transactions`,description:`Read an account's transaction history through the policy engine`},args:xr.args,async run({args:e}){let t=xr.parse(e);await mr(t)(e=>e.getAccountTransactions(t.account,{start:t.start,end:t.end,limit:t.limit,offset:t.offset}))}}),"deposit-address":e({meta:{name:`deposit-address`,description:`Read an account deposit address through the policy engine`},args:Sr.args,async run({args:e}){let t=Sr.parse(e);await mr(t)(async e=>{let n=await Ne(e,t.network);return e.getAccountDepositAddress(t.account,{network:n,asset:t.asset})})}})}}),wr=r.pipe(r.string(),r.minLength(1,`must not be empty`)),Tr={profile:Ae,json:je},Er=W({address:H({description:`Only counterparties with a wallet rail matching this address (0x…)`,schema:ce}),network:H({description:`Only counterparties with a wallet rail on this network (e.g. base)`}),...Tr}),Dr=H({description:`Counterparty name`,required:!0,schema:wr}),Or=H({description:`Optional contact email`}),kr=W({name:Dr,"bank-name":H({description:`Receiving bank name`,required:!0,schema:wr}),"routing-number":H({description:`9-digit ABA routing number`,required:!0,schema:wr}),"account-number":H({description:`Receiving bank account number`,required:!0,schema:wr}),"account-type":Ee({description:`checking | savings (default checking)`,choices:[`checking`,`savings`]}),"address-street":H({description:`Street address of the receiving bank account holder`,required:!0,schema:wr}),"address-city":H({description:`City`,required:!0,schema:wr}),"address-state":H({description:`State (e.g. NY)`,required:!0,schema:wr}),"address-postal-code":H({description:`Postal code`,required:!0,schema:wr}),"address-country":H({description:`Default USA`}),email:Or,...Tr}),Ar=W({name:Dr,address:H({description:`Wallet address (0x… or ENS name on EVM networks)`,required:!0,schema:wr}),network:H({description:`Wallet network; defaults to base. Availability depends on the connected environment.`,default:le}),email:Or,...Tr}),jr=e({meta:{name:`list`,description:`List counterparties available under the agent's policy`},args:Er.args,async run({args:e}){let t=Er.parse(e);await mr(t)(async e=>{let n=Mr(t.network);return e.getCounterparties({address:t.address,network:n===void 0?void 0:await Ne(e,n)})})}});function Mr(e){return e&&e.length>0?e:void 0}function Nr(e){let t=Mr(e.email);return{type:`create_counterparty`,name:e.name,email:t,rail:{type:`bank`,bankName:e[`bank-name`],routingNumber:e[`routing-number`],accountNumber:e[`account-number`],addressStreet:e[`address-street`],addressCity:e[`address-city`],addressState:e[`address-state`],addressPostalCode:e[`address-postal-code`],...e[`account-type`]?{accountType:e[`account-type`]}:{},...e[`address-country`]?{addressCountry:e[`address-country`]}:{}}}}function Pr(e,t){let n=Mr(e.email);return{type:`create_counterparty`,name:e.name,email:n,rail:{type:`wallet`,walletAddress:e.address,network:t}}}const Fr=e({meta:{name:`counterparties`,description:`Inspect and create counterparties`},subCommands:{list:jr,create:e({meta:{name:`create`,description:`Request counterparty creation through the policy engine. Prints an intent envelope.`},subCommands:{bank:e({meta:{name:`bank`,description:`Request bank counterparty creation through the policy engine. Prints an intent envelope.`},args:kr.args,async run({args:e}){let t=kr.parse(e),n=Nr(t);await mr(t)(e=>e.createIntent({action:n}))}}),wallet:e({meta:{name:`wallet`,description:`Request wallet counterparty creation through the policy engine. Prints an intent envelope.`},args:Ar.args,async run({args:e}){let t=Ar.parse(e);await mr(t)(async e=>{let n=await Ne(e,t.network);return e.createIntent({action:Pr(t,n)})})}})}})}}),Ir=4e3;async function Lr(){process.stdin.setEncoding(`utf8`);let e=``;for await(let t of process.stdin)e+=t;return e}async function Rr(e){return e===void 0?(process.stdin.isTTY&&z(`<message>: pass a quoted message or pipe it on stdin; a message starting with "-" needs -- before it (catena feedback -- "<message>") or stdin`),Lr()):e}const zr=W({message:Te({description:`Plain-text feedback (1-4000 chars); omit to pipe on stdin`}),profile:Ae,json:je}),Br=e({meta:{name:`feedback`,description:`Send free-form feedback about Catena to the Catena team`},args:zr.args,async run({args:e}){(Array.isArray(e._)?e._:[]).length>1&&z(`<message>: pass the message as a single quoted argument`);let t=zr.parse(e),n=(await Rr(t.message)).trim();n.length===0&&z(`<message>: must not be empty`),n.length>Ir&&z(`<message>: must be at most ${Ir} characters (got: ${n.length})`),await mr(t)(async e=>(await e.submitFeedback(n),{ok:!0}))}});function Vr(e){return`# Catena CLI Agent Guide
2
+ import{defineCommand as e,renderUsage as t,runMain as n}from"citty";import*as r from"valibot";import*as i from"node:crypto";import{ECDH as a,createECDH as o,createHash as s,createPrivateKey as c,randomBytes as l,sign as u}from"node:crypto";import{execFile as d,spawn as f}from"node:child_process";import{chmodSync as p,existsSync as m,mkdirSync as h,readFileSync as g,realpathSync as _,renameSync as v,rmSync as y,statSync as b,writeFileSync as x}from"node:fs";import{homedir as S}from"node:os";import{dirname as C,isAbsolute as w,join as T,resolve as ee}from"node:path";import{createServer as E}from"node:http";import D from"semver";var O=Object.create,k=Object.defineProperty,te=Object.getOwnPropertyDescriptor,A=Object.getOwnPropertyNames,j=Object.getPrototypeOf,ne=Object.prototype.hasOwnProperty,re=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(e){throw n=[e],e}},M=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),N=(e,t)=>{let n={};for(var r in e)k(n,r,{get:e[r],enumerable:!0});return t||k(n,Symbol.toStringTag,{value:`Module`}),n},ie=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=A(t),a=0,o=i.length,s;a<o;a++)s=i[a],!ne.call(e,s)&&s!==n&&k(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=te(t,s))||r.enumerable});return e},ae=(e,t,n)=>(n=e==null?{}:O(j(e)),ie(t||!e||!e.__esModule?k(n,`default`,{value:e,enumerable:!0}):n,e)),P=e=>ne.call(e,`module.exports`)?e[`module.exports`]:ie(k({},`__esModule`,{value:!0}),e),oe=`@catena/cli`,se=`0.2.1`;const ce=[`base`,`base-sepolia`],le=[`usdc`],ue=r.picklist(ce),de=r.picklist(le);r.picklist([`evm`]);const fe=r.pipe(r.string(),r.trim(),r.regex(/^0x[0-9a-fA-F]{40}$/,`Must be a 0x-prefixed hex wallet address`),r.brand(`EvmAddress`)),pe=`base`,me=`usdc`;r.picklist([`always`,`testnet`]),r.picklist([`bridge-internal-transfer`,`bridge-wallet-transfer`,`wallet-bridge-transfer`,`wallet-wallet-transfer`]);const he=[{network:`base`,networkLabel:`Base`,addressFamily:`evm`,blockExplorerUrl:`https://basescan.org`,blockExplorerName:`Basescan`,asset:`usdc`,assetLabel:`USDC`,assetDecimals:6,contractAddress:`0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913`,availabilityGate:`always`,chainFeeUsd:`0`,walletTransferFeeUsd:`0`,transferRoutes:[`bridge-internal-transfer`,`bridge-wallet-transfer`,`wallet-bridge-transfer`,`wallet-wallet-transfer`],provider:{alchemyNetwork:`base`,bridgePaymentRail:`base`}},{network:`base-sepolia`,networkLabel:`Base Sepolia`,addressFamily:`evm`,isTestnet:!0,blockExplorerUrl:`https://sepolia.basescan.org`,blockExplorerName:`Sepolia Basescan`,asset:`usdc`,assetLabel:`USDC`,assetDecimals:6,contractAddress:`0x036CbD53842c5426634e7929541eC2318f3dCF7e`,availabilityGate:`testnet`,chainFeeUsd:`0`,walletTransferFeeUsd:`0`,transferRoutes:[`wallet-wallet-transfer`],provider:{alchemyNetwork:`base-sepolia`}}];function F(e){return{id:e.network,label:e.networkLabel,addressFamily:e.addressFamily,blockExplorerUrl:e.blockExplorerUrl,blockExplorerName:e.blockExplorerName,...e.isTestnet?{isTestnet:!0}:{}}}function ge(e){return{id:e.asset,label:e.assetLabel,decimals:e.assetDecimals}}function _e(e){return{network:e.network,asset:e.asset,contractAddress:e.contractAddress}}function I(e){return{id:`${e.network}-usdc`,label:`${e.networkLabel} USDC`,network:e.network,asset:`usdc`}}function ve(e){let t=[];for(let n of e)t.some(e=>e.id===n.network)||t.push(F(n));return t}function ye(e){let t=[],n=new Set;for(let r of e)n.has(r.asset)||(n.add(r.asset),t.push(ge(r)));return t}function be(e){return e.asset===me}const xe=ve(he);ye(he),he.map(_e),he.filter(be).map(I),new Map(he.map(e=>[`${e.network}:${e.asset}`,e.contractAddress])),new Map(xe.map(e=>[e.id,e]));function L(e){console.error(Se(e)),process.exit(1)}function Se(e){return typeof e==`string`?e:e instanceof Error?e.message:String(e)}const Ce=r.string(),R=r.boolean();function we(e){return e===void 0}function Te(e){return e.issues?.[0]?.message??`Invalid value`}function Ee(e,t,n,r){return L(`${e}: ${t}${r?` (got: ${String(n)})`:``}`)}function z(e,t,n,i){let a=r.safeParse(e,t);return a.success?a.output:Ee(n,Te(a),t,i)}function De(e,t){let n=t.schema??Ce;return{type:e,description:t.description,negativeDescription:t.negativeDescription,required:t.required,default:t.default,parseValue(e,r){let i=we(e)?t.default:e;if(we(i)){t.required===!0&&L(`${r} is required`);return}return z(n,i,r,t.showValueInError===!0)}}}function B(e){return De(`string`,e)}function V(e){return De(`positional`,e)}function Oe(e){return{type:`boolean`,description:e.description,negativeDescription:e.negativeDescription,required:e.required,default:e.default,parseValue(t,n){let r=we(t)?e.default:t;if(we(r)){e.required===!0&&L(`${n} is required`);return}return z(R,r,n,!1)}}}function ke(e){return Ae(`string`,e)}function Ae(e,t){return De(e,{description:t.description,required:t.required,default:t.default,schema:r.picklist(t.choices,`must be one of ${t.choices.join(`|`)}`),showValueInError:!0})}function je(e,t){return t.type===`positional`?`<${e}>`:`--${e}`}function Me(e){let t=e.required??(e.type===`positional`?!1:void 0);return e.type===`boolean`?{type:e.type,description:e.description,negativeDescription:e.negativeDescription,required:t,default:typeof e.default==`boolean`?e.default:void 0}:{type:e.type,description:e.description,required:t,default:typeof e.default==`string`?e.default:void 0}}function H(e){return{args:Object.fromEntries(Object.entries(e).map(([e,t])=>[e,Me(t)])),label(t){return je(t,e[t])},parse(t){return Object.fromEntries(Object.entries(e).map(([e,n])=>[e,n.parseValue(t[e],je(e,n))]))}}}function Ne(e){return ke({description:e.description,choices:ue.options,...e.default===void 0?{}:{default:e.default}})}const Pe=B({description:`Credential profile name`}),U=Oe({description:`Print compact single-line JSON (for piping)`,default:!1}),Fe=/^[a-zA-Z0-9_-]+$/,Ie=r.pipe(r.string(`ID must be a string`),r.minLength(1,`ID must not be empty`),r.maxLength(256,`ID is too long (max 256 characters)`),r.regex(Fe,`ID may only contain letters, digits, hyphens, and underscores`));function Le(e){return e.reduce((e,t)=>e+t.toString(16).padStart(2,`0`),``)}const W=(e,t)=>{if(!e||e.length%2!=0||!/^[0-9A-Fa-f]+$/.test(e))throw Error(`cannot create uint8array from invalid hex string: "${e}"`);let n=new Uint8Array(e.match(/../g).map(e=>parseInt(e,16)));if(!t)return n;if(e.length/2>t)throw Error(`hex value cannot fit in a buffer of `+t+` byte(s)`);let r=new Uint8Array(t);return r.set(n,t-n.length),r},Re=(e,t)=>{let n=t-e.length;if(n>0){let t=new Uint8Array(n).fill(0);return new Uint8Array([...t,...e])}if(n<0){let r=n*-1,i=0;for(let t=0;t<r&&t<e.length;t++)e[t]===0&&i++;if(i!==r)throw Error(`invalid number of starting zeroes. Expected number of zeroes: ${r}. Found: ${i}.`);return e.slice(r,r+t)}return e};function ze(e){return Ve(He(e))}function Be(e,t){return ze(W(e.padStart(Math.ceil(e.length/2)*2,`0`),t).reduce((e,t)=>e+String.fromCharCode(t),``))}function Ve(e){return e.replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=/g,``)}function He(e){if(arguments.length===0)throw TypeError(`1 argument required, but only 0 present.`);let t;for(e=`${e}`,t=0;t<e.length;t++)if(e.charCodeAt(t)>255)throw Error(`InvalidCharacterError: found code point greater than 255:${e.charCodeAt(t)} at position ${t}`);let n=``;for(t=0;t<e.length;t+=3){let r=[void 0,void 0,void 0,void 0];r[0]=e.charCodeAt(t)>>2,r[1]=(e.charCodeAt(t)&3)<<4,e.length>t+1&&(r[1]|=e.charCodeAt(t+1)>>4,r[2]=(e.charCodeAt(t+1)&15)<<2),e.length>t+2&&(r[2]|=e.charCodeAt(t+2)>>6,r[3]=e.charCodeAt(t+2)&63);for(let e=0;e<r.length;e++)r[e]===void 0?n+=`=`:n+=Ue(r[e])}return n}function Ue(e){if(e>=0&&e<64)return`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`[e]}function We(e){if(e.length>=255)throw TypeError(`Alphabet too long`);let t=new Uint8Array(256);for(let e=0;e<t.length;e++)t[e]=255;for(let n=0;n<e.length;n++){let r=e.charAt(n),i=r.charCodeAt(0);if(t[i]!==255)throw TypeError(r+` is ambiguous`);t[i]=n}let n=e.length,r=e.charAt(0),i=Math.log(n)/Math.log(256),a=Math.log(256)/Math.log(n);function o(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw TypeError(`Expected Uint8Array`);if(t.length===0)return``;let i=0,o=0,s=0,c=t.length;for(;s!==c&&t[s]===0;)s++,i++;let l=(c-s)*a+1>>>0,u=new Uint8Array(l);for(;s!==c;){let e=t[s],r=0;for(let t=l-1;(e!==0||r<o)&&t!==-1;t--,r++)e+=256*u[t]>>>0,u[t]=e%n>>>0,e=e/n>>>0;if(e!==0)throw Error(`Non-zero carry`);o=r,s++}let d=l-o;for(;d!==l&&u[d]===0;)d++;let f=r.repeat(i);for(;d<l;++d)f+=e.charAt(u[d]);return f}function s(e){if(typeof e!=`string`)throw TypeError(`Expected String`);if(e.length===0)return new Uint8Array;let a=0,o=0,s=0;for(;e[a]===r;)o++,a++;let c=(e.length-a)*i+1>>>0,l=new Uint8Array(c);for(;a<e.length;){let r=e.charCodeAt(a);if(r>255)return;let i=t[r];if(i===255)return;let o=0;for(let e=c-1;(i!==0||o<s)&&e!==-1;e--,o++)i+=n*l[e]>>>0,l[e]=i%256>>>0,i=i/256>>>0;if(i!==0)throw Error(`Non-zero carry`);s=o,a++}let u=c-s;for(;u!==c&&l[u]===0;)u++;let d=new Uint8Array(o+(c-u)),f=o;for(;u!==c;)d[f++]=l[u++];return d}function c(e){let t=s(e);if(t)return t;throw Error(`Non-base`+n+` character`)}return{encode:o,decodeUnsafe:s,decode:c}}var Ge=N({default:()=>Ke}),Ke=We(`123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz`);function G(e){let t=e;for(;t&&!(t.encode&&t.decode&&t.decodeUnsafe)&&t.default;)t=t.default;return t}G(Ge);const qe=i&&typeof i==`object`&&`webcrypto`in i?i.webcrypto:i&&typeof i==`object`&&`randomBytes`in i?i:void 0;
3
+ /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
4
+ function Je(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`}function Ye(e){if(!Number.isSafeInteger(e)||e<0)throw Error(`positive integer expected, got `+e)}function Xe(e,...t){if(!Je(e))throw Error(`Uint8Array expected`);if(t.length>0&&!t.includes(e.length))throw Error(`Uint8Array expected of length `+t+`, got length=`+e.length)}function Ze(e){if(typeof e!=`function`||typeof e.create!=`function`)throw Error(`Hash should be wrapped by utils.createHasher`);Ye(e.outputLen),Ye(e.blockLen)}function Qe(e,t=!0){if(e.destroyed)throw Error(`Hash instance has been destroyed`);if(t&&e.finished)throw Error(`Hash#digest() has already been called`)}function $e(e,t){Xe(e);let n=t.outputLen;if(e.length<n)throw Error(`digestInto() expects output buffer of length at least `+n)}function et(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function tt(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function K(e,t){return e<<32-t|e>>>t}const nt=typeof Uint8Array.from([]).toHex==`function`&&typeof Uint8Array.fromHex==`function`,rt=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`));function it(e){if(Xe(e),nt)return e.toHex();let t=``;for(let n=0;n<e.length;n++)t+=rt[e[n]];return t}const at={_0:48,_9:57,A:65,F:70,a:97,f:102};function ot(e){if(e>=at._0&&e<=at._9)return e-at._0;if(e>=at.A&&e<=at.F)return e-(at.A-10);if(e>=at.a&&e<=at.f)return e-(at.a-10)}function st(e){if(typeof e!=`string`)throw Error(`hex string expected, got `+typeof e);if(nt)return Uint8Array.fromHex(e);let t=e.length,n=t/2;if(t%2)throw Error(`hex string expected, got unpadded hex of length `+t);let r=new Uint8Array(n);for(let t=0,i=0;t<n;t++,i+=2){let n=ot(e.charCodeAt(i)),a=ot(e.charCodeAt(i+1));if(n===void 0||a===void 0){let t=e[i]+e[i+1];throw Error(`hex string expected, got non-hex character "`+t+`" at index `+i)}r[t]=n*16+a}return r}function ct(e){if(typeof e!=`string`)throw Error(`string expected`);return new Uint8Array(new TextEncoder().encode(e))}function lt(e){return typeof e==`string`&&(e=ct(e)),Xe(e),e}function ut(...e){let t=0;for(let n=0;n<e.length;n++){let r=e[n];Xe(r),t+=r.length}let n=new Uint8Array(t);for(let t=0,r=0;t<e.length;t++){let i=e[t];n.set(i,r),r+=i.length}return n}var dt=class{};function ft(e){let t=t=>e().update(lt(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function pt(e=32){if(qe&&typeof qe.getRandomValues==`function`)return qe.getRandomValues(new Uint8Array(e));if(qe&&typeof qe.randomBytes==`function`)return Uint8Array.from(qe.randomBytes(e));throw Error(`crypto.getRandomValues must be defined`)}function mt(e,t,n,r){if(typeof e.setBigUint64==`function`)return e.setBigUint64(t,n,r);let i=BigInt(32),a=BigInt(4294967295),o=Number(n>>i&a),s=Number(n&a),c=r?4:0,l=r?0:4;e.setUint32(t+c,o,r),e.setUint32(t+l,s,r)}function ht(e,t,n){return e&t^~e&n}function gt(e,t,n){return e&t^e&n^t&n}var _t=class extends dt{constructor(e,t,n,r){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.buffer=new Uint8Array(e),this.view=tt(this.buffer)}update(e){Qe(this),e=lt(e),Xe(e);let{view:t,buffer:n,blockLen:r}=this,i=e.length;for(let a=0;a<i;){let o=Math.min(r-this.pos,i-a);if(o===r){let t=tt(e);for(;r<=i-a;a+=r)this.process(t,a);continue}n.set(e.subarray(a,a+o),this.pos),this.pos+=o,a+=o,this.pos===r&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Qe(this),$e(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:r,isLE:i}=this,{pos:a}=this;t[a++]=128,et(this.buffer.subarray(a)),this.padOffset>r-a&&(this.process(n,0),a=0);for(let e=a;e<r;e++)t[e]=0;mt(n,r-8,BigInt(this.length*8),i),this.process(n,0);let o=tt(e),s=this.outputLen;if(s%4)throw Error(`_sha2: outputLen should be aligned to 32bit`);let c=s/4,l=this.get();if(c>l.length)throw Error(`_sha2: outputLen bigger than state`);for(let e=0;e<c;e++)o.setUint32(4*e,l[e],i)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||=new this.constructor,e.set(...this.get());let{blockLen:t,buffer:n,length:r,finished:i,destroyed:a,pos:o}=this;return e.destroyed=a,e.finished=i,e.length=r,e.pos=o,r%t&&e.buffer.set(n),e}clone(){return this._cloneInto()}};const vt=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),q=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]),J=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),yt=BigInt(2**32-1),bt=BigInt(32);function xt(e,t=!1){return t?{h:Number(e&yt),l:Number(e>>bt&yt)}:{h:Number(e>>bt&yt)|0,l:Number(e&yt)|0}}function St(e,t=!1){let n=e.length,r=new Uint32Array(n),i=new Uint32Array(n);for(let a=0;a<n;a++){let{h:n,l:o}=xt(e[a],t);[r[a],i[a]]=[n,o]}return[r,i]}const Ct=(e,t,n)=>e>>>n,wt=(e,t,n)=>e<<32-n|t>>>n,Tt=(e,t,n)=>e>>>n|t<<32-n,Et=(e,t,n)=>e<<32-n|t>>>n,Dt=(e,t,n)=>e<<64-n|t>>>n-32,Ot=(e,t,n)=>e>>>n-32|t<<64-n;function kt(e,t,n,r){let i=(t>>>0)+(r>>>0);return{h:e+n+(i/2**32|0)|0,l:i|0}}const At=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),jt=(e,t,n,r)=>t+n+r+(e/2**32|0)|0,Mt=(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0),Nt=(e,t,n,r,i)=>t+n+r+i+(e/2**32|0)|0,Pt=(e,t,n,r,i)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(i>>>0),Ft=(e,t,n,r,i,a)=>t+n+r+i+a+(e/2**32|0)|0,It=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Lt=new Uint32Array(64);var Rt=class extends _t{constructor(e=32){super(64,e,8,!1),this.A=vt[0]|0,this.B=vt[1]|0,this.C=vt[2]|0,this.D=vt[3]|0,this.E=vt[4]|0,this.F=vt[5]|0,this.G=vt[6]|0,this.H=vt[7]|0}get(){let{A:e,B:t,C:n,D:r,E:i,F:a,G:o,H:s}=this;return[e,t,n,r,i,a,o,s]}set(e,t,n,r,i,a,o,s){this.A=e|0,this.B=t|0,this.C=n|0,this.D=r|0,this.E=i|0,this.F=a|0,this.G=o|0,this.H=s|0}process(e,t){for(let n=0;n<16;n++,t+=4)Lt[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){let t=Lt[e-15],n=Lt[e-2],r=K(t,7)^K(t,18)^t>>>3;Lt[e]=(K(n,17)^K(n,19)^n>>>10)+Lt[e-7]+r+Lt[e-16]|0}let{A:n,B:r,C:i,D:a,E:o,F:s,G:c,H:l}=this;for(let e=0;e<64;e++){let t=K(o,6)^K(o,11)^K(o,25),u=l+t+ht(o,s,c)+It[e]+Lt[e]|0,d=(K(n,2)^K(n,13)^K(n,22))+gt(n,r,i)|0;l=c,c=s,s=o,o=a+u|0,a=i,i=r,r=n,n=u+d|0}n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,a=a+this.D|0,o=o+this.E|0,s=s+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(n,r,i,a,o,s,c,l)}roundClean(){et(Lt)}destroy(){this.set(0,0,0,0,0,0,0,0),et(this.buffer)}};const zt=St(`0x428a2f98d728ae22.0x7137449123ef65cd.0xb5c0fbcfec4d3b2f.0xe9b5dba58189dbbc.0x3956c25bf348b538.0x59f111f1b605d019.0x923f82a4af194f9b.0xab1c5ed5da6d8118.0xd807aa98a3030242.0x12835b0145706fbe.0x243185be4ee4b28c.0x550c7dc3d5ffb4e2.0x72be5d74f27b896f.0x80deb1fe3b1696b1.0x9bdc06a725c71235.0xc19bf174cf692694.0xe49b69c19ef14ad2.0xefbe4786384f25e3.0x0fc19dc68b8cd5b5.0x240ca1cc77ac9c65.0x2de92c6f592b0275.0x4a7484aa6ea6e483.0x5cb0a9dcbd41fbd4.0x76f988da831153b5.0x983e5152ee66dfab.0xa831c66d2db43210.0xb00327c898fb213f.0xbf597fc7beef0ee4.0xc6e00bf33da88fc2.0xd5a79147930aa725.0x06ca6351e003826f.0x142929670a0e6e70.0x27b70a8546d22ffc.0x2e1b21385c26c926.0x4d2c6dfc5ac42aed.0x53380d139d95b3df.0x650a73548baf63de.0x766a0abb3c77b2a8.0x81c2c92e47edaee6.0x92722c851482353b.0xa2bfe8a14cf10364.0xa81a664bbc423001.0xc24b8b70d0f89791.0xc76c51a30654be30.0xd192e819d6ef5218.0xd69906245565a910.0xf40e35855771202a.0x106aa07032bbd1b8.0x19a4c116b8d2d0c8.0x1e376c085141ab53.0x2748774cdf8eeb99.0x34b0bcb5e19b48a8.0x391c0cb3c5c95a63.0x4ed8aa4ae3418acb.0x5b9cca4f7763e373.0x682e6ff3d6b2b8a3.0x748f82ee5defb2fc.0x78a5636f43172f60.0x84c87814a1f0ab72.0x8cc702081a6439ec.0x90befffa23631e28.0xa4506cebde82bde9.0xbef9a3f7b2c67915.0xc67178f2e372532b.0xca273eceea26619c.0xd186b8c721c0c207.0xeada7dd6cde0eb1e.0xf57d4f7fee6ed178.0x06f067aa72176fba.0x0a637dc5a2c898a6.0x113f9804bef90dae.0x1b710b35131c471b.0x28db77f523047d84.0x32caab7b40c72493.0x3c9ebe0a15c9bebc.0x431d67c49c100d4c.0x4cc5d4becb3e42b6.0x597f299cfc657e2a.0x5fcb6fab3ad6faec.0x6c44198c4a475817`.split(`.`).map(e=>BigInt(e))),Bt=zt[0],Vt=zt[1],Ht=new Uint32Array(80),Ut=new Uint32Array(80);var Wt=class extends _t{constructor(e=64){super(128,e,16,!1),this.Ah=J[0]|0,this.Al=J[1]|0,this.Bh=J[2]|0,this.Bl=J[3]|0,this.Ch=J[4]|0,this.Cl=J[5]|0,this.Dh=J[6]|0,this.Dl=J[7]|0,this.Eh=J[8]|0,this.El=J[9]|0,this.Fh=J[10]|0,this.Fl=J[11]|0,this.Gh=J[12]|0,this.Gl=J[13]|0,this.Hh=J[14]|0,this.Hl=J[15]|0}get(){let{Ah:e,Al:t,Bh:n,Bl:r,Ch:i,Cl:a,Dh:o,Dl:s,Eh:c,El:l,Fh:u,Fl:d,Gh:f,Gl:p,Hh:m,Hl:h}=this;return[e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h]}set(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){this.Ah=e|0,this.Al=t|0,this.Bh=n|0,this.Bl=r|0,this.Ch=i|0,this.Cl=a|0,this.Dh=o|0,this.Dl=s|0,this.Eh=c|0,this.El=l|0,this.Fh=u|0,this.Fl=d|0,this.Gh=f|0,this.Gl=p|0,this.Hh=m|0,this.Hl=h|0}process(e,t){for(let n=0;n<16;n++,t+=4)Ht[n]=e.getUint32(t),Ut[n]=e.getUint32(t+=4);for(let e=16;e<80;e++){let t=Ht[e-15]|0,n=Ut[e-15]|0,r=Tt(t,n,1)^Tt(t,n,8)^Ct(t,n,7),i=Et(t,n,1)^Et(t,n,8)^wt(t,n,7),a=Ht[e-2]|0,o=Ut[e-2]|0,s=Tt(a,o,19)^Dt(a,o,61)^Ct(a,o,6),c=Mt(i,Et(a,o,19)^Ot(a,o,61)^wt(a,o,6),Ut[e-7],Ut[e-16]);Ht[e]=Nt(c,r,s,Ht[e-7],Ht[e-16])|0,Ut[e]=c|0}let{Ah:n,Al:r,Bh:i,Bl:a,Ch:o,Cl:s,Dh:c,Dl:l,Eh:u,El:d,Fh:f,Fl:p,Gh:m,Gl:h,Hh:g,Hl:_}=this;for(let e=0;e<80;e++){let t=Tt(u,d,14)^Tt(u,d,18)^Dt(u,d,41),v=Et(u,d,14)^Et(u,d,18)^Ot(u,d,41),y=u&f^~u&m,b=d&p^~d&h,x=Pt(_,v,b,Vt[e],Ut[e]),S=Ft(x,g,t,y,Bt[e],Ht[e]),C=x|0,w=Tt(n,r,28)^Dt(n,r,34)^Dt(n,r,39),T=Et(n,r,28)^Ot(n,r,34)^Ot(n,r,39),ee=n&i^n&o^i&o,E=r&a^r&s^a&s;g=m|0,_=h|0,m=f|0,h=p|0,f=u|0,p=d|0,{h:u,l:d}=kt(c|0,l|0,S|0,C|0),c=o|0,l=s|0,o=i|0,s=a|0,i=n|0,a=r|0;let D=At(C,T,E);n=jt(D,S,w,ee),r=D|0}({h:n,l:r}=kt(this.Ah|0,this.Al|0,n|0,r|0)),{h:i,l:a}=kt(this.Bh|0,this.Bl|0,i|0,a|0),{h:o,l:s}=kt(this.Ch|0,this.Cl|0,o|0,s|0),{h:c,l}=kt(this.Dh|0,this.Dl|0,c|0,l|0),{h:u,l:d}=kt(this.Eh|0,this.El|0,u|0,d|0),{h:f,l:p}=kt(this.Fh|0,this.Fl|0,f|0,p|0),{h:m,l:h}=kt(this.Gh|0,this.Gl|0,m|0,h|0),{h:g,l:_}=kt(this.Hh|0,this.Hl|0,g|0,_|0),this.set(n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_)}roundClean(){et(Ht,Ut)}destroy(){et(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},Gt=class extends Wt{constructor(){super(48),this.Ah=q[0]|0,this.Al=q[1]|0,this.Bh=q[2]|0,this.Bl=q[3]|0,this.Ch=q[4]|0,this.Cl=q[5]|0,this.Dh=q[6]|0,this.Dl=q[7]|0,this.Eh=q[8]|0,this.El=q[9]|0,this.Fh=q[10]|0,this.Fl=q[11]|0,this.Gh=q[12]|0,this.Gl=q[13]|0,this.Hh=q[14]|0,this.Hl=q[15]|0}};const Kt=ft(()=>new Rt),qt=ft(()=>new Wt),Jt=ft(()=>new Gt),Yt=Kt;function Xt(e){function t(t){var n=Uint8Array.from(t),r=e(n),i=n.length+4,a=new Uint8Array(i);return a.set(n,0),a.set(r.subarray(0,4),n.length),Ke.encode(a)}function n(t){var n=t.slice(0,-4),r=t.slice(-4),i=e(n);if(!(r[0]^i[0]|r[1]^i[1]|r[2]^i[2]|r[3]^i[3]))return n}function r(e){var t=Ke.decodeUnsafe(e);if(t!=null)return n(t)}function i(e){var t=n(Ke.decode(e));if(t==null)throw Error(`Invalid checksum`);return t}return{encode:t,decode:i,decodeUnsafe:r}}var Zt=N({default:()=>$t});function Qt(e){return Yt(Yt(e))}var $t=Xt(Qt);function en(e){let t=e;for(;t&&!(t.encode&&t.decode&&t.decodeUnsafe)&&t.default;)t=t.default;return t}en(Zt);var tn=[`u8`,`u16`,`u32`,`u64`,`u128`,`i8`,`i16`,`i32`,`i64`,`i128`,`f32`,`f64`],nn=function(){function e(){this.offset=0,this.buffer_size=256,this.buffer=new ArrayBuffer(this.buffer_size),this.view=new DataView(this.buffer)}return e.prototype.resize_if_necessary=function(e){if(this.buffer_size-this.offset<e){this.buffer_size=Math.max(this.buffer_size*2,this.buffer_size+e);var t=new ArrayBuffer(this.buffer_size);new Uint8Array(t).set(new Uint8Array(this.buffer)),this.buffer=t,this.view=new DataView(t)}},e.prototype.get_used_buffer=function(){return new Uint8Array(this.buffer).slice(0,this.offset)},e.prototype.store_value=function(e,t){var n=t.substring(1),r=parseInt(n)/8;this.resize_if_necessary(r);var i=t[0]===`f`?`setFloat${n}`:t[0]===`i`?`setInt${n}`:`setUint${n}`;this.view[i](this.offset,e,!0),this.offset+=r},e.prototype.store_bytes=function(e){this.resize_if_necessary(e.length),new Uint8Array(this.buffer).set(new Uint8Array(e),this.offset),this.offset+=e.length},e}(),rn=function(){function e(e){this.offset=0,this.buffer_size=e.length,this.buffer=new ArrayBuffer(e.length),new Uint8Array(this.buffer).set(e),this.view=new DataView(this.buffer)}return e.prototype.assert_enough_buffer=function(e){if(this.offset+e>this.buffer.byteLength)throw Error(`Error in schema, the buffer is smaller than expected`)},e.prototype.consume_value=function(e){var t=e.substring(1),n=parseInt(t)/8;this.assert_enough_buffer(n);var r=e[0]===`f`?`getFloat${t}`:e[0]===`i`?`getInt${t}`:`getUint${t}`,i=this.view[r](this.offset,!0);return this.offset+=n,i},e.prototype.consume_bytes=function(e){this.assert_enough_buffer(e);var t=this.buffer.slice(this.offset,this.offset+e);return this.offset+=e,t},e}(),an=(function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};return function(t,n){if(typeof n!=`function`&&n!==null)throw TypeError(`Class extends value `+String(n)+` is not a constructor or null`);e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}})();function on(e){return Array.isArray(e)||!!e&&typeof e==`object`&&`length`in e&&typeof e.length==`number`&&(e.length===0||e.length>0&&e.length-1 in e)}function sn(e,t,n){if(typeof e!==t)throw Error(`Expected ${t} not ${typeof e}(${e}) at ${n.join(`.`)}`)}function cn(e,t){var n=[`number`,`string`,`bigint`,`boolean`].includes(typeof e),r=typeof e==`object`&&!!e&&`toString`in e;if(!n&&!r)throw Error(`Expected bigint, number, boolean or string not ${typeof e}(${e}) at ${t.join(`.`)}`)}function ln(e,t,n){if(e!==t)throw Error(`Array length ${e} does not match schema length ${t} at ${n.join(`.`)}`)}function un(e,t){if(typeof e!=`object`||!e)throw Error(`Expected object not ${typeof e}(${e}) at ${t.join(`.`)}`)}tn.concat([`bool`,`string`]),function(e){an(t,e);function t(t,n){var r=`Invalid schema: ${JSON.stringify(t)} expected ${n}`;return e.call(this,r)||this}return t}(Error),function(){function e(e){this.encoded=new nn,this.fieldPath=[`value`],this.checkTypes=e}return e.prototype.encode=function(e,t){return this.encode_value(e,t),this.encoded.get_used_buffer()},e.prototype.encode_value=function(e,t){if(typeof t==`string`){if(tn.includes(t))return this.encode_integer(e,t);if(t===`string`)return this.encode_string(e);if(t===`bool`)return this.encode_boolean(e)}if(typeof t==`object`){if(`option`in t)return this.encode_option(e,t);if(`enum`in t)return this.encode_enum(e,t);if(`array`in t)return this.encode_array(e,t);if(`set`in t)return this.encode_set(e,t);if(`map`in t)return this.encode_map(e,t);if(`struct`in t)return this.encode_struct(e,t)}},e.prototype.encode_integer=function(e,t){var n=parseInt(t.substring(1));n<=32||t==`f64`?(this.checkTypes&&sn(e,`number`,this.fieldPath),this.encoded.store_value(e,t)):(this.checkTypes&&cn(e,this.fieldPath),this.encode_bigint(BigInt(e),n))},e.prototype.encode_bigint=function(e,t){for(var n=t/8,r=new Uint8Array(n),i=0;i<n;i++)r[i]=Number(e&BigInt(255)),e>>=BigInt(8);this.encoded.store_bytes(new Uint8Array(r))},e.prototype.encode_string=function(e){this.checkTypes&&sn(e,`string`,this.fieldPath);for(var t=e,n=[],r=0;r<t.length;r++){var i=t.charCodeAt(r);i<128?n.push(i):i<2048?n.push(192|i>>6,128|i&63):i<55296||i>=57344?n.push(224|i>>12,128|i>>6&63,128|i&63):(r++,i=65536+((i&1023)<<10|t.charCodeAt(r)&1023),n.push(240|i>>18,128|i>>12&63,128|i>>6&63,128|i&63))}this.encoded.store_value(n.length,`u32`),this.encoded.store_bytes(new Uint8Array(n))},e.prototype.encode_boolean=function(e){this.checkTypes&&sn(e,`boolean`,this.fieldPath),this.encoded.store_value(+!!e,`u8`)},e.prototype.encode_option=function(e,t){e==null?this.encoded.store_value(0,`u8`):(this.encoded.store_value(1,`u8`),this.encode_value(e,t.option))},e.prototype.encode_enum=function(e,t){this.checkTypes&&un(e,this.fieldPath);for(var n=Object.keys(e)[0],r=0;r<t.enum.length;r++){var i=t.enum[r];if(n===Object.keys(i.struct)[0])return this.encoded.store_value(r,`u8`),this.encode_struct(e,i)}throw Error(`Enum key (${n}) not found in enum schema: ${JSON.stringify(t)} at ${this.fieldPath.join(`.`)}`)},e.prototype.encode_array=function(e,t){if(on(e))return this.encode_arraylike(e,t);if(e instanceof ArrayBuffer)return this.encode_buffer(e,t);throw Error(`Expected Array-like not ${typeof e}(${e}) at ${this.fieldPath.join(`.`)}`)},e.prototype.encode_arraylike=function(e,t){t.array.len?ln(e.length,t.array.len,this.fieldPath):this.encoded.store_value(e.length,`u32`);for(var n=0;n<e.length;n++)this.encode_value(e[n],t.array.type)},e.prototype.encode_buffer=function(e,t){t.array.len?ln(e.byteLength,t.array.len,this.fieldPath):this.encoded.store_value(e.byteLength,`u32`),this.encoded.store_bytes(new Uint8Array(e))},e.prototype.encode_set=function(e,t){this.checkTypes&&sn(e,`object`,this.fieldPath);var n=e instanceof Set?Array.from(e.values()):Object.values(e);this.encoded.store_value(n.length,`u32`);for(var r=0,i=n;r<i.length;r++){var a=i[r];this.encode_value(a,t.set)}},e.prototype.encode_map=function(e,t){this.checkTypes&&sn(e,`object`,this.fieldPath);var n=e instanceof Map,r=n?Array.from(e.keys()):Object.keys(e);this.encoded.store_value(r.length,`u32`);for(var i=0,a=r;i<a.length;i++){var o=a[i];this.encode_value(o,t.map.key),this.encode_value(n?e.get(o):e[o],t.map.value)}},e.prototype.encode_struct=function(e,t){this.checkTypes&&sn(e,`object`,this.fieldPath);for(var n=0,r=Object.keys(t.struct);n<r.length;n++){var i=r[n];this.fieldPath.push(i),this.encode_value(e[i],t.struct[i]),this.fieldPath.pop()}},e}(),function(){function e(e){this.buffer=new rn(e)}return e.prototype.decode=function(e){return this.decode_value(e)},e.prototype.decode_value=function(e){if(typeof e==`string`){if(tn.includes(e))return this.decode_integer(e);if(e===`string`)return this.decode_string();if(e===`bool`)return this.decode_boolean()}if(typeof e==`object`){if(`option`in e)return this.decode_option(e);if(`enum`in e)return this.decode_enum(e);if(`array`in e)return this.decode_array(e);if(`set`in e)return this.decode_set(e);if(`map`in e)return this.decode_map(e);if(`struct`in e)return this.decode_struct(e)}throw Error(`Unsupported type: ${e}`)},e.prototype.decode_integer=function(e){var t=parseInt(e.substring(1));return t<=32||e==`f64`?this.buffer.consume_value(e):this.decode_bigint(t,e.startsWith(`i`))},e.prototype.decode_bigint=function(e,t){t===void 0&&(t=!1);var n=e/8,r=new Uint8Array(this.buffer.consume_bytes(n)),i=r.reduceRight(function(e,t){return e+t.toString(16).padStart(2,`0`)},``);return t&&r[n-1]?BigInt.asIntN(e,BigInt(`0x${i}`)):BigInt(`0x${i}`)},e.prototype.decode_string=function(){for(var e=this.decode_integer(`u32`),t=new Uint8Array(this.buffer.consume_bytes(e)),n=[],r=0;r<e;++r){var i=t[r];if(i<128)n.push(i);else if(i<224)n.push((i&31)<<6|t[++r]&63);else if(i<240)n.push((i&15)<<12|(t[++r]&63)<<6|t[++r]&63);else{var a=(i&7)<<18|(t[++r]&63)<<12|(t[++r]&63)<<6|t[++r]&63;n.push(a)}}return String.fromCodePoint.apply(String,n)},e.prototype.decode_boolean=function(){return this.buffer.consume_value(`u8`)>0},e.prototype.decode_option=function(e){var t=this.buffer.consume_value(`u8`);if(t===1)return this.decode_value(e.option);if(t!==0)throw Error(`Invalid option ${t}`);return null},e.prototype.decode_enum=function(e){var t,n=this.buffer.consume_value(`u8`);if(n>e.enum.length)throw Error(`Enum option ${n} is not available`);var r=e.enum[n].struct,i=Object.keys(r)[0];return t={},t[i]=this.decode_value(r[i]),t},e.prototype.decode_array=function(e){for(var t=[],n=e.array.len?e.array.len:this.decode_integer(`u32`),r=0;r<n;++r)t.push(this.decode_value(e.array.type));return t},e.prototype.decode_set=function(e){for(var t=this.decode_integer(`u32`),n=new Set,r=0;r<t;++r)n.add(this.decode_value(e.set));return n},e.prototype.decode_map=function(e){for(var t=this.decode_integer(`u32`),n=new Map,r=0;r<t;++r){var i=this.decode_value(e.map.key),a=this.decode_value(e.map.value);n.set(i,a)}return n},e.prototype.decode_struct=function(e){var t={};for(var n in e.struct)t[n]=this.decode_value(e.struct[n]);return t},e}(),new Uint8Array([75,69,77,0,16]),new Uint8Array([72,80,75,69,0,16,0,1,0,2]),new Uint8Array([72,80,75,69,45,118,49]),new Uint8Array([115,101,99,114,101,116]),new Uint8Array([101,97,101,95,112,114,107]),new Uint8Array([115,104,97,114,101,100,95,115,101,99,114,101,116]),new Uint8Array([0,32,72,80,75,69,45,118,49,72,80,75,69,0,16,0,1,0,2,107,101,121,0,143,195,174,184,50,73,10,75,90,179,228,32,35,40,125,178,154,31,75,199,194,34,192,223,34,135,39,183,10,64,33,18,47,63,4,233,32,108,209,36,19,80,53,41,180,122,198,166,48,185,46,196,207,125,35,69,8,208,175,151,113,201,158,80]),new Uint8Array([0,12,72,80,75,69,45,118,49,72,80,75,69,0,16,0,1,0,2,98,97,115,101,95,110,111,110,99,101,0,143,195,174,184,50,73,10,75,90,179,228,32,35,40,125,178,154,31,75,199,194,34,192,223,34,135,39,183,10,64,33,18,47,63,4,233,32,108,209,36,19,80,53,41,180,122,198,166,48,185,46,196,207,125,35,69,8,208,175,151,113,201,158,80]),new Uint8Array([113,111,115,95,101,110,99,114,121,112,116,105,111,110,95,104,109,97,99,95,109,101,115,115,97,103,101]);const dn=e=>{let t=W(e);if(t.length<2)throw Error(`failed to convert DER-encoded signature: insufficient length`);if(t[0]!==48)throw Error(`failed to convert DER-encoded signature: invalid format (missing SEQUENCE tag)`);let n=1,r=t[n];if(r<=127){if(t.length<2+r)throw Error(`failed to convert DER-encoded signature: inconsistent message length header`);n+=1}else throw Error(`failed to convert DER-encoded signature: unexpectedly large or invalid signature length`);if(t[n]!==2)throw Error(`failed to convert DER-encoded signature: invalid tag for r`);n++;let i=t[n];if(i>33)throw Error(`failed to convert DER-encoded signature: unexpected length for r`);n++;let a=t.slice(n,n+i);if(n+=i,t[n]!==2)throw Error(`failed to convert DER-encoded signature: invalid tag for s`);n++;let o=t[n];if(o>33)throw Error(`failed to convert DER-encoded signature: unexpected length for s`);n++;let s=t.slice(n,n+o),c=Re(a,32),l=Re(s,32);return new Uint8Array([...c,...l])};var fn;(function(e){e.NOTARIZER=`notarizer`,e.SIGNER=`signer`,e.EVM_PARSER=`evm-parser`,e.TLS_FETCHER=`tls-fetcher`,e.UMP=`ump`})(fn||={});var pn=M(((e,t)=>{(function(e,n){var r=2**-24,i=2**32,a=2**53;function o(e){var t=new ArrayBuffer(256),r=new DataView(t),o,s=0;function c(e){for(var n=t.byteLength,i=s+e;n<i;)n*=2;if(n!==t.byteLength){var a=r;t=new ArrayBuffer(n),r=new DataView(t);for(var c=s+3>>2,l=0;l<c;++l)r.setUint32(l*4,a.getUint32(l*4))}return o=e,r}function l(){s+=o}function u(e){l(c(8).setFloat64(s,e))}function d(e){l(c(1).setUint8(s,e))}function f(e){for(var t=c(e.length),n=0;n<e.length;++n)t.setUint8(s+n,e[n]);l()}function p(e){l(c(2).setUint16(s,e))}function m(e){l(c(4).setUint32(s,e))}function h(e){var t=e%i,n=(e-t)/i,r=c(8);r.setUint32(s,n),r.setUint32(s+4,t),l()}function g(e,t){t<24?d(e<<5|t):t<256?(d(e<<5|24),d(t)):t<65536?(d(e<<5|25),p(t)):t<4294967296?(d(e<<5|26),m(t)):(d(e<<5|27),h(t))}function _(e){var t;if(e===!1)return d(244);if(e===!0)return d(245);if(e===null)return d(246);if(e===n)return d(247);switch(typeof e){case`number`:if(Math.floor(e)===e){if(0<=e&&e<=a)return g(0,e);if(-a<=e&&e<0)return g(1,-(e+1))}return d(251),u(e);case`string`:var r=[];for(t=0;t<e.length;++t){var i=e.charCodeAt(t);i<128?r.push(i):i<2048?(r.push(192|i>>6),r.push(128|i&63)):i<55296?(r.push(224|i>>12),r.push(128|i>>6&63),r.push(128|i&63)):(i=(i&1023)<<10,i|=e.charCodeAt(++t)&1023,i+=65536,r.push(240|i>>18),r.push(128|i>>12&63),r.push(128|i>>6&63),r.push(128|i&63))}return g(3,r.length),f(r);default:var o;if(Array.isArray(e))for(o=e.length,g(4,o),t=0;t<o;++t)_(e[t]);else if(e instanceof Uint8Array)g(2,e.length),f(e);else{var s=Object.keys(e);for(o=s.length,g(5,o),t=0;t<o;++t){var c=s[t];_(c),_(e[c])}}}}if(_(e),`slice`in t)return t.slice(0,s);for(var v=new ArrayBuffer(s),y=new DataView(v),b=0;b<s;++b)y.setUint8(b,r.getUint8(b));return v}function s(e,t,a){var o=new DataView(e),s=0;typeof t!=`function`&&(t=function(e){return e}),typeof a!=`function`&&(a=function(){return n});function c(e,t){return s+=t,e}function l(t){return c(new Uint8Array(e,s,t),t)}function u(){var e=new DataView(new ArrayBuffer(4)),t=m(),n=t&32768,i=t&31744,a=t&1023;if(i===31744)i=261120;else if(i!==0)i+=114688;else if(a!==0)return a*r;return e.setUint32(0,n<<16|i<<13|a<<13),e.getFloat32(0)}function d(){return c(o.getFloat32(s),4)}function f(){return c(o.getFloat64(s),8)}function p(){return c(o.getUint8(s),1)}function m(){return c(o.getUint16(s),2)}function h(){return c(o.getUint32(s),4)}function g(){return h()*i+h()}function _(){return o.getUint8(s)===255?(s+=1,!0):!1}function v(e){if(e<24)return e;if(e===24)return p();if(e===25)return m();if(e===26)return h();if(e===27)return g();if(e===31)return-1;throw`Invalid length encoding`}function y(e){var t=p();if(t===255)return-1;var n=v(t&31);if(n<0||t>>5!==e)throw`Invalid indefinite length element`;return n}function b(e,t){for(var n=0;n<t;++n){var r=p();r&128&&(r<224?(r=(r&31)<<6|p()&63,--t):r<240?(r=(r&15)<<12|(p()&63)<<6|p()&63,t-=2):(r=(r&15)<<18|(p()&63)<<12|(p()&63)<<6|p()&63,t-=3)),r<65536?e.push(r):(r-=65536,e.push(55296|r>>10),e.push(56320|r&1023))}}function x(){var e=p(),r=e>>5,i=e&31,o,s;if(r===7)switch(i){case 25:return u();case 26:return d();case 27:return f()}if(s=v(i),s<0&&(r<2||6<r))throw`Invalid length`;switch(r){case 0:return s;case 1:return-1-s;case 2:if(s<0){for(var c=[],m=0;(s=y(r))>=0;)m+=s,c.push(l(s));var h=new Uint8Array(m),g=0;for(o=0;o<c.length;++o)h.set(c[o],g),g+=c[o].length;return h}return l(s);case 3:var S=[];if(s<0)for(;(s=y(r))>=0;)b(S,s);else b(S,s);return String.fromCharCode.apply(null,S);case 4:var C;if(s<0)for(C=[];!_();)C.push(x());else for(C=Array(s),o=0;o<s;++o)C[o]=x();return C;case 5:var w={};for(o=0;o<s||s<0&&!_();++o){var T=x();w[T]=x()}return w;case 6:return t(x(),s);case 7:switch(s){case 20:return!1;case 21:return!0;case 22:return null;case 23:return n;default:return a(s)}}}var S=x();if(s!==e.byteLength)throw`Remaining bytes`;return S}var c={encode:o,decode:s};typeof define==`function`&&define.amd?define(`cbor/cbor`,c):t!==void 0&&t.exports?t.exports=c:e.CBOR||=c})(e)})),mn=M((()=>{
5
+ /*! *****************************************************************************
6
+ Copyright (C) Microsoft. All rights reserved.
7
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use
8
+ this file except in compliance with the License. You may obtain a copy of the
9
+ License at http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
12
+ KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
13
+ WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
14
+ MERCHANTABLITY OR NON-INFRINGEMENT.
15
+
16
+ See the Apache Version 2.0 License for specific language governing permissions
17
+ and limitations under the License.
18
+ ***************************************************************************** */
19
+ var e;(function(e){(function(t){var n=typeof globalThis==`object`?globalThis:typeof global==`object`?global:typeof self==`object`?self:typeof this==`object`?this:s(),r=i(e);n.Reflect!==void 0&&(r=i(n.Reflect,r)),t(r,n),n.Reflect===void 0&&(n.Reflect=e);function i(e,t){return function(n,r){Object.defineProperty(e,n,{configurable:!0,writable:!0,value:r}),t&&t(n,r)}}function a(){try{return Function(`return this;`)()}catch{}}function o(){try{return(0,eval)(`(function() { return this; })()`)}catch{}}function s(){return a()||o()}})(function(e,t){var n=Object.prototype.hasOwnProperty,r=typeof Symbol==`function`,i=r&&Symbol.toPrimitive!==void 0?Symbol.toPrimitive:`@@toPrimitive`,a=r&&Symbol.iterator!==void 0?Symbol.iterator:`@@iterator`,o=typeof Object.create==`function`,s={__proto__:[]}instanceof Array,c=!o&&!s,l={create:o?function(){return Ee(Object.create(null))}:s?function(){return Ee({__proto__:null})}:function(){return Ee({})},has:c?function(e,t){return n.call(e,t)}:function(e,t){return t in e},get:c?function(e,t){return n.call(e,t)?e[t]:void 0}:function(e,t){return e[t]}},u=Object.getPrototypeOf(Function),d=typeof Map==`function`&&typeof Map.prototype.entries==`function`?Map:R(),f=typeof Set==`function`&&typeof Set.prototype.entries==`function`?Set:we(),p=typeof WeakMap==`function`?WeakMap:Te(),m=r?Symbol.for(`@reflect-metadata:registry`):void 0,h=xe(),g=L(h);function _(e,t,n,r){if(N(n)){if(!de(e)||!pe(t))throw TypeError();return E(e,t)}else{if(!de(e)||!P(t)||!P(r)&&!N(r)&&!ie(r))throw TypeError();return ie(r)&&(r=void 0),n=ue(n),D(e,t,n,r)}}e(`decorate`,_);function v(e,t){function n(n,r){if(!P(n)||!N(r)&&!me(r))throw TypeError();j(e,t,n,r)}return n}e(`metadata`,v);function y(e,t,n,r){if(!P(n))throw TypeError();return N(r)||(r=ue(r)),j(e,t,n,r)}e(`defineMetadata`,y);function b(e,t,n){if(!P(t))throw TypeError();return N(n)||(n=ue(n)),O(e,t,n)}e(`hasMetadata`,b);function x(e,t,n){if(!P(t))throw TypeError();return N(n)||(n=ue(n)),k(e,t,n)}e(`hasOwnMetadata`,x);function S(e,t,n){if(!P(t))throw TypeError();return N(n)||(n=ue(n)),te(e,t,n)}e(`getMetadata`,S);function C(e,t,n){if(!P(t))throw TypeError();return N(n)||(n=ue(n)),A(e,t,n)}e(`getOwnMetadata`,C);function w(e,t){if(!P(e))throw TypeError();return N(t)||(t=ue(t)),ne(e,t)}e(`getMetadataKeys`,w);function T(e,t){if(!P(e))throw TypeError();return N(t)||(t=ue(t)),re(e,t)}e(`getOwnMetadataKeys`,T);function ee(e,t,n){if(!P(t)||(N(n)||(n=ue(n)),!P(t)))throw TypeError();N(n)||(n=ue(n));var r=Ce(t,n,!1);return N(r)?!1:r.OrdinaryDeleteMetadata(e,t,n)}e(`deleteMetadata`,ee);function E(e,t){for(var n=e.length-1;n>=0;--n){var r=e[n],i=r(t);if(!N(i)&&!ie(i)){if(!pe(i))throw TypeError();t=i}}return t}function D(e,t,n,r){for(var i=e.length-1;i>=0;--i){var a=e[i],o=a(t,n,r);if(!N(o)&&!ie(o)){if(!P(o))throw TypeError();r=o}}return r}function O(e,t,n){if(k(e,t,n))return!0;var r=ye(t);return ie(r)?!1:O(e,r,n)}function k(e,t,n){var r=Ce(t,n,!1);return N(r)?!1:ce(r.OrdinaryHasOwnMetadata(e,t,n))}function te(e,t,n){if(k(e,t,n))return A(e,t,n);var r=ye(t);if(!ie(r))return te(e,r,n)}function A(e,t,n){var r=Ce(t,n,!1);if(!N(r))return r.OrdinaryGetOwnMetadata(e,t,n)}function j(e,t,n,r){Ce(n,r,!0).OrdinaryDefineOwnMetadata(e,t,n,r)}function ne(e,t){var n=re(e,t),r=ye(e);if(r===null)return n;var i=ne(r,t);if(i.length<=0)return n;if(n.length<=0)return i;for(var a=new f,o=[],s=0,c=n;s<c.length;s++){var l=c[s],u=a.has(l);u||(a.add(l),o.push(l))}for(var d=0,p=i;d<p.length;d++){var l=p[d],u=a.has(l);u||(a.add(l),o.push(l))}return o}function re(e,t){var n=Ce(e,t,!1);return n?n.OrdinaryOwnMetadataKeys(e,t):[]}function M(e){if(e===null)return 1;switch(typeof e){case`undefined`:return 0;case`boolean`:return 2;case`string`:return 3;case`symbol`:return 4;case`number`:return 5;case`object`:return e===null?1:6;default:return 6}}function N(e){return e===void 0}function ie(e){return e===null}function ae(e){return typeof e==`symbol`}function P(e){return typeof e==`object`?e!==null:typeof e==`function`}function oe(e,t){switch(M(e)){case 0:return e;case 1:return e;case 2:return e;case 3:return e;case 4:return e;case 5:return e}var n=t===3?`string`:t===5?`number`:`default`,r=F(e,i);if(r!==void 0){var a=r.call(e,n);if(P(a))throw TypeError();return a}return se(e,n==="default"?`number`:n)}function se(e,t){if(t===`string`){var n=e.toString;if(fe(n)){var r=n.call(e);if(!P(r))return r}var i=e.valueOf;if(fe(i)){var r=i.call(e);if(!P(r))return r}}else{var i=e.valueOf;if(fe(i)){var r=i.call(e);if(!P(r))return r}var a=e.toString;if(fe(a)){var r=a.call(e);if(!P(r))return r}}throw TypeError()}function ce(e){return!!e}function le(e){return``+e}function ue(e){var t=oe(e,3);return ae(t)?t:le(t)}function de(e){return Array.isArray?Array.isArray(e):e instanceof Object?e instanceof Array:Object.prototype.toString.call(e)===`[object Array]`}function fe(e){return typeof e==`function`}function pe(e){return typeof e==`function`}function me(e){switch(M(e)){case 3:return!0;case 4:return!0;default:return!1}}function he(e,t){return e===t||e!==e&&t!==t}function F(e,t){var n=e[t];if(n!=null){if(!fe(n))throw TypeError();return n}}function ge(e){var t=F(e,a);if(!fe(t))throw TypeError();var n=t.call(e);if(!P(n))throw TypeError();return n}function _e(e){return e.value}function I(e){var t=e.next();return t.done?!1:t}function ve(e){var t=e.return;t&&t.call(e)}function ye(e){var t=Object.getPrototypeOf(e);if(typeof e!=`function`||e===u||t!==u)return t;var n=e.prototype,r=n&&Object.getPrototypeOf(n);if(r==null||r===Object.prototype)return t;var i=r.constructor;return typeof i!=`function`||i===e?t:i}function be(){var e;!N(m)&&t.Reflect!==void 0&&!(m in t.Reflect)&&typeof t.Reflect.defineMetadata==`function`&&(e=Se(t.Reflect));var n,r,i,a=new p,o={registerProvider:s,getProvider:l,setProvider:h};return o;function s(t){if(!Object.isExtensible(o))throw Error(`Cannot add provider to a frozen registry.`);switch(!0){case e===t:break;case N(n):n=t;break;case n===t:break;case N(r):r=t;break;case r===t:break;default:i===void 0&&(i=new f),i.add(t);break}}function c(t,a){if(!N(n)){if(n.isProviderFor(t,a))return n;if(!N(r)){if(r.isProviderFor(t,a))return n;if(!N(i))for(var o=ge(i);;){var s=I(o);if(!s)return;var c=_e(s);if(c.isProviderFor(t,a))return ve(o),c}}}if(!N(e)&&e.isProviderFor(t,a))return e}function l(e,t){var n=a.get(e),r;return N(n)||(r=n.get(t)),N(r)?(r=c(e,t),N(r)||(N(n)&&(n=new d,a.set(e,n)),n.set(t,r)),r):r}function u(e){if(N(e))throw TypeError();return n===e||r===e||!N(i)&&i.has(e)}function h(e,t,n){if(!u(n))throw Error(`Metadata provider not registered.`);var r=l(e,t);if(r!==n){if(!N(r))return!1;var i=a.get(e);N(i)&&(i=new d,a.set(e,i)),i.set(t,n)}return!0}}function xe(){var e;return!N(m)&&P(t.Reflect)&&Object.isExtensible(t.Reflect)&&(e=t.Reflect[m]),N(e)&&(e=be()),!N(m)&&P(t.Reflect)&&Object.isExtensible(t.Reflect)&&Object.defineProperty(t.Reflect,m,{enumerable:!1,configurable:!1,writable:!1,value:e}),e}function L(e){var t=new p,n={isProviderFor:function(e,n){var r=t.get(e);return N(r)?!1:r.has(n)},OrdinaryDefineOwnMetadata:o,OrdinaryHasOwnMetadata:i,OrdinaryGetOwnMetadata:a,OrdinaryOwnMetadataKeys:s,OrdinaryDeleteMetadata:c};return h.registerProvider(n),n;function r(r,i,a){var o=t.get(r),s=!1;if(N(o)){if(!a)return;o=new d,t.set(r,o),s=!0}var c=o.get(i);if(N(c)){if(!a)return;if(c=new d,o.set(i,c),!e.setProvider(r,i,n))throw o.delete(i),s&&t.delete(r),Error(`Wrong provider for target.`)}return c}function i(e,t,n){var i=r(t,n,!1);return N(i)?!1:ce(i.has(e))}function a(e,t,n){var i=r(t,n,!1);if(!N(i))return i.get(e)}function o(e,t,n,i){r(n,i,!0).set(e,t)}function s(e,t){var n=[],i=r(e,t,!1);if(N(i))return n;for(var a=ge(i.keys()),o=0;;){var s=I(a);if(!s)return n.length=o,n;var c=_e(s);try{n[o]=c}catch(e){try{ve(a)}finally{throw e}}o++}}function c(e,n,i){var a=r(n,i,!1);if(N(a)||!a.delete(e))return!1;if(a.size===0){var o=t.get(n);N(o)||(o.delete(i),o.size===0&&t.delete(o))}return!0}}function Se(e){var t=e.defineMetadata,n=e.hasOwnMetadata,r=e.getOwnMetadata,i=e.getOwnMetadataKeys,a=e.deleteMetadata,o=new p;return{isProviderFor:function(e,t){var n=o.get(e);return!N(n)&&n.has(t)?!0:i(e,t).length?(N(n)&&(n=new f,o.set(e,n)),n.add(t),!0):!1},OrdinaryDefineOwnMetadata:t,OrdinaryHasOwnMetadata:n,OrdinaryGetOwnMetadata:r,OrdinaryOwnMetadataKeys:i,OrdinaryDeleteMetadata:a}}function Ce(e,t,n){var r=h.getProvider(e,t);if(!N(r))return r;if(n){if(h.setProvider(e,t,g))return g;throw Error(`Illegal state.`)}}function R(){var e={},t=[],n=function(){function e(e,t,n){this._index=0,this._keys=e,this._values=t,this._selector=n}return e.prototype[`@@iterator`]=function(){return this},e.prototype[a]=function(){return this},e.prototype.next=function(){var e=this._index;if(e>=0&&e<this._keys.length){var n=this._selector(this._keys[e],this._values[e]);return e+1>=this._keys.length?(this._index=-1,this._keys=t,this._values=t):this._index++,{value:n,done:!1}}return{value:void 0,done:!0}},e.prototype.throw=function(e){throw this._index>=0&&(this._index=-1,this._keys=t,this._values=t),e},e.prototype.return=function(e){return this._index>=0&&(this._index=-1,this._keys=t,this._values=t),{value:e,done:!0}},e}();return function(){function t(){this._keys=[],this._values=[],this._cacheKey=e,this._cacheIndex=-2}return Object.defineProperty(t.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),t.prototype.has=function(e){return this._find(e,!1)>=0},t.prototype.get=function(e){var t=this._find(e,!1);return t>=0?this._values[t]:void 0},t.prototype.set=function(e,t){var n=this._find(e,!0);return this._values[n]=t,this},t.prototype.delete=function(t){var n=this._find(t,!1);if(n>=0){for(var r=this._keys.length,i=n+1;i<r;i++)this._keys[i-1]=this._keys[i],this._values[i-1]=this._values[i];return this._keys.length--,this._values.length--,he(t,this._cacheKey)&&(this._cacheKey=e,this._cacheIndex=-2),!0}return!1},t.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=e,this._cacheIndex=-2},t.prototype.keys=function(){return new n(this._keys,this._values,r)},t.prototype.values=function(){return new n(this._keys,this._values,i)},t.prototype.entries=function(){return new n(this._keys,this._values,o)},t.prototype[`@@iterator`]=function(){return this.entries()},t.prototype[a]=function(){return this.entries()},t.prototype._find=function(e,t){if(!he(this._cacheKey,e)){this._cacheIndex=-1;for(var n=0;n<this._keys.length;n++)if(he(this._keys[n],e)){this._cacheIndex=n;break}}return this._cacheIndex<0&&t&&(this._cacheIndex=this._keys.length,this._keys.push(e),this._values.push(void 0)),this._cacheIndex},t}();function r(e,t){return e}function i(e,t){return t}function o(e,t){return[e,t]}}function we(){return function(){function e(){this._map=new d}return Object.defineProperty(e.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),e.prototype.has=function(e){return this._map.has(e)},e.prototype.add=function(e){return this._map.set(e,e),this},e.prototype.delete=function(e){return this._map.delete(e)},e.prototype.clear=function(){this._map.clear()},e.prototype.keys=function(){return this._map.keys()},e.prototype.values=function(){return this._map.keys()},e.prototype.entries=function(){return this._map.entries()},e.prototype[`@@iterator`]=function(){return this.keys()},e.prototype[a]=function(){return this.keys()},e}()}function Te(){var e=16,t=l.create(),r=i();return function(){function e(){this._key=i()}return e.prototype.has=function(e){var t=a(e,!1);return t===void 0?!1:l.has(t,this._key)},e.prototype.get=function(e){var t=a(e,!1);return t===void 0?void 0:l.get(t,this._key)},e.prototype.set=function(e,t){var n=a(e,!0);return n[this._key]=t,this},e.prototype.delete=function(e){var t=a(e,!1);return t===void 0?!1:delete t[this._key]},e.prototype.clear=function(){this._key=i()},e}();function i(){var e;do e=`@@WeakMap@@`+c();while(l.has(t,e));return t[e]=!0,e}function a(e,t){if(!n.call(e,r)){if(!t)return;Object.defineProperty(e,r,{value:l.create()})}return e[r]}function o(e,t){for(var n=0;n<t;++n)e[n]=Math.random()*255|0;return e}function s(e){if(typeof Uint8Array==`function`){var t=new Uint8Array(e);return typeof crypto<`u`?crypto.getRandomValues(t):typeof msCrypto<`u`?msCrypto.getRandomValues(t):o(t,e),t}return o(Array(e),e)}function c(){var t=s(e);t[6]=t[6]&79|64,t[8]=t[8]&191|128;for(var n=``,r=0;r<e;++r){var i=t[r];(r===4||r===6||r===8)&&(n+=`-`),i<16&&(n+=`0`),n+=i.toString(16).toLowerCase()}return n}}function Ee(e){return e.__=void 0,delete e.__,e}})})(e||={})})),Y=N({__addDisposableResource:()=>Hn,__assign:()=>Kn,__asyncDelegator:()=>Pn,__asyncGenerator:()=>Nn,__asyncValues:()=>Fn,__await:()=>Mn,__awaiter:()=>wn,__classPrivateFieldGet:()=>zn,__classPrivateFieldIn:()=>Vn,__classPrivateFieldSet:()=>Bn,__createBinding:()=>qn,__decorate:()=>_n,__disposeResources:()=>Un,__esDecorate:()=>yn,__exportStar:()=>En,__extends:()=>hn,__generator:()=>Tn,__importDefault:()=>Rn,__importStar:()=>Ln,__makeTemplateObject:()=>In,__metadata:()=>Cn,__param:()=>vn,__propKey:()=>xn,__read:()=>On,__rest:()=>gn,__rewriteRelativeImportExtension:()=>Wn,__runInitializers:()=>bn,__setFunctionName:()=>Sn,__spread:()=>kn,__spreadArray:()=>jn,__spreadArrays:()=>An,__values:()=>Dn,default:()=>Zn});function hn(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Class extends value `+String(t)+` is not a constructor or null`);Gn(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}function gn(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function _n(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}function vn(e,t){return function(n,r){t(n,r,e)}}function yn(e,t,n,r,i,a){function o(e){if(e!==void 0&&typeof e!=`function`)throw TypeError(`Function expected`);return e}for(var s=r.kind,c=s===`getter`?`get`:s===`setter`?`set`:`value`,l=!t&&e?r.static?e:e.prototype:null,u=t||(l?Object.getOwnPropertyDescriptor(l,r.name):{}),d,f=!1,p=n.length-1;p>=0;p--){var m={};for(var h in r)m[h]=h===`access`?{}:r[h];for(var h in r.access)m.access[h]=r.access[h];m.addInitializer=function(e){if(f)throw TypeError(`Cannot add initializers after decoration has completed`);a.push(o(e||null))};var g=(0,n[p])(s===`accessor`?{get:u.get,set:u.set}:u[c],m);if(s===`accessor`){if(g===void 0)continue;if(typeof g!=`object`||!g)throw TypeError(`Object expected`);(d=o(g.get))&&(u.get=d),(d=o(g.set))&&(u.set=d),(d=o(g.init))&&i.unshift(d)}else(d=o(g))&&(s===`field`?i.unshift(d):u[c]=d)}l&&Object.defineProperty(l,r.name,u),f=!0}function bn(e,t,n){for(var r=arguments.length>2,i=0;i<t.length;i++)n=r?t[i].call(e,n):t[i].call(e);return r?n:void 0}function xn(e){return typeof e==`symbol`?e:`${e}`}function Sn(e,t,n){return typeof t==`symbol`&&(t=t.description?`[${t.description}]`:``),Object.defineProperty(e,"name",{configurable:!0,value:n?`${n} ${t}`:t})}function Cn(e,t){if(typeof Reflect==`object`&&typeof Reflect.metadata==`function`)return Reflect.metadata(e,t)}function wn(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})}function Tn(e,t){var n={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},r,i,a,o=Object.create((typeof Iterator==`function`?Iterator:Object).prototype);return o.next=s(0),o.throw=s(1),o.return=s(2),typeof Symbol==`function`&&(o[Symbol.iterator]=function(){return this}),o;function s(e){return function(t){return c([e,t])}}function c(s){if(r)throw TypeError(`Generator is already executing.`);for(;o&&(o=0,s[0]&&(n=0)),n;)try{if(r=1,i&&(a=s[0]&2?i.return:s[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,s[1])).done)return a;switch(i=0,a&&(s=[s[0]&2,a.value]),s[0]){case 0:case 1:a=s;break;case 4:return n.label++,{value:s[1],done:!1};case 5:n.label++,i=s[1],s=[0];continue;case 7:s=n.ops.pop(),n.trys.pop();continue;default:if((a=n.trys,!(a=a.length>0&&a[a.length-1]))&&(s[0]===6||s[0]===2)){n=0;continue}if(s[0]===3&&(!a||s[1]>a[0]&&s[1]<a[3])){n.label=s[1];break}if(s[0]===6&&n.label<a[1]){n.label=a[1],a=s;break}if(a&&n.label<a[2]){n.label=a[2],n.ops.push(s);break}a[2]&&n.ops.pop(),n.trys.pop();continue}s=t.call(e,n)}catch(e){s=[6,e],i=0}finally{r=a=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}}function En(e,t){for(var n in e)n!=="default"&&!Object.prototype.hasOwnProperty.call(t,n)&&qn(t,e,n)}function Dn(e){var t=typeof Symbol==`function`&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length==`number`)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw TypeError(t?`Object is not iterable.`:`Symbol.iterator is not defined.`)}function On(e,t){var n=typeof Symbol==`function`&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),i,a=[],o;try{for(;(t===void 0||t-->0)&&!(i=r.next()).done;)a.push(i.value)}catch(e){o={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a}function kn(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(On(arguments[t]));return e}function An(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;for(var r=Array(e),i=0,t=0;t<n;t++)for(var a=arguments[t],o=0,s=a.length;o<s;o++,i++)r[i]=a[o];return r}function jn(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}function Mn(e){return this instanceof Mn?(this.v=e,this):new Mn(e)}function Nn(e,t,n){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var r=n.apply(e,t||[]),i,a=[];return i=Object.create((typeof AsyncIterator==`function`?AsyncIterator:Object).prototype),s(`next`),s(`throw`),s(`return`,o),i[Symbol.asyncIterator]=function(){return this},i;function o(e){return function(t){return Promise.resolve(t).then(e,d)}}function s(e,t){r[e]&&(i[e]=function(t){return new Promise(function(n,r){a.push([e,t,n,r])>1||c(e,t)})},t&&(i[e]=t(i[e])))}function c(e,t){try{l(r[e](t))}catch(e){f(a[0][3],e)}}function l(e){e.value instanceof Mn?Promise.resolve(e.value.v).then(u,d):f(a[0][2],e)}function u(e){c(`next`,e)}function d(e){c(`throw`,e)}function f(e,t){e(t),a.shift(),a.length&&c(a[0][0],a[0][1])}}function Pn(e){var t,n;return t={},r(`next`),r(`throw`,function(e){throw e}),r(`return`),t[Symbol.iterator]=function(){return this},t;function r(r,i){t[r]=e[r]?function(t){return(n=!n)?{value:Mn(e[r](t)),done:!1}:i?i(t):t}:i}}function Fn(e){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof Dn==`function`?Dn(e):e[Symbol.iterator](),n={},r(`next`),r(`throw`),r(`return`),n[Symbol.asyncIterator]=function(){return this},n);function r(t){n[t]=e[t]&&function(n){return new Promise(function(r,a){n=e[t](n),i(r,a,n.done,n.value)})}}function i(e,t,n,r){Promise.resolve(r).then(function(t){e({value:t,done:n})},t)}}function In(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}function Ln(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n=Yn(e),r=0;r<n.length;r++)n[r]!=="default"&&qn(t,e,n[r]);return Jn(t,e),t}function Rn(e){return e&&e.__esModule?e:{default:e}}function zn(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)}function Bn(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n}function Vn(e,t){if(t===null||typeof t!=`object`&&typeof t!=`function`)throw TypeError(`Cannot use 'in' operator on non-object`);return typeof e==`function`?t===e:e.has(t)}function Hn(e,t,n){if(t!=null){if(typeof t!=`object`&&typeof t!=`function`)throw TypeError(`Object expected.`);var r,i;if(n){if(!Symbol.asyncDispose)throw TypeError(`Symbol.asyncDispose is not defined.`);r=t[Symbol.asyncDispose]}if(r===void 0){if(!Symbol.dispose)throw TypeError(`Symbol.dispose is not defined.`);r=t[Symbol.dispose],n&&(i=r)}if(typeof r!=`function`)throw TypeError(`Object not disposable.`);i&&(r=function(){try{i.call(this)}catch(e){return Promise.reject(e)}}),e.stack.push({value:t,dispose:r,async:n})}else n&&e.stack.push({async:!0});return t}function Un(e){function t(t){e.error=e.hasError?new Xn(t,e.error,`An error was suppressed during disposal.`):t,e.hasError=!0}var n,r=0;function i(){for(;n=e.stack.pop();)try{if(!n.async&&r===1)return r=0,e.stack.push(n),Promise.resolve().then(i);if(n.dispose){var a=n.dispose.call(n.value);if(n.async)return r|=2,Promise.resolve(a).then(i,function(e){return t(e),i()})}else r|=1}catch(e){t(e)}if(r===1)return e.hasError?Promise.reject(e.error):Promise.resolve();if(e.hasError)throw e.error}return i()}function Wn(e,t){return typeof e==`string`&&/^\.\.?\//.test(e)?e.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(e,n,r,i,a){return n?t?`.jsx`:`.js`:r&&(!i||!a)?e:r+i+`.`+a.toLowerCase()+`js`}):e}var Gn,Kn,qn,Jn,Yn,Xn,Zn,X=re((()=>{Gn=function(e,t){return Gn=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},Gn(e,t)},Kn=function(){return Kn=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Kn.apply(this,arguments)},qn=Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]}),Jn=Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t},Yn=function(e){return Yn=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},Yn(e)},Xn=typeof SuppressedError==`function`?SuppressedError:function(e,t,n){var r=Error(n);return r.name=`SuppressedError`,r.error=e,r.suppressed=t,r},Zn={__extends:hn,__assign:Kn,__rest:gn,__decorate:_n,__param:vn,__esDecorate:yn,__runInitializers:bn,__propKey:xn,__setFunctionName:Sn,__metadata:Cn,__awaiter:wn,__generator:Tn,__createBinding:qn,__exportStar:En,__values:Dn,__read:On,__spread:kn,__spreadArrays:An,__spreadArray:jn,__await:Mn,__asyncGenerator:Nn,__asyncDelegator:Pn,__asyncValues:Fn,__makeTemplateObject:In,__importStar:Ln,__importDefault:Rn,__classPrivateFieldGet:zn,__classPrivateFieldSet:Bn,__classPrivateFieldIn:Vn,__addDisposableResource:Hn,__disposeResources:Un,__rewriteRelativeImportExtension:Wn}})),Qn=M((e=>{
20
+ /*!
21
+ * MIT License
22
+ *
23
+ * Copyright (c) 2017-2024 Peculiar Ventures, LLC
24
+ *
25
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
26
+ * of this software and associated documentation files (the "Software"), to deal
27
+ * in the Software without restriction, including without limitation the rights
28
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
29
+ * copies of the Software, and to permit persons to whom the Software is
30
+ * furnished to do so, subject to the following conditions:
31
+ *
32
+ * The above copyright notice and this permission notice shall be included in all
33
+ * copies or substantial portions of the Software.
34
+ *
35
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
36
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
37
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
38
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
39
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
40
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
41
+ * SOFTWARE.
42
+ *
43
+ */
44
+ var t=class e{static isArrayBuffer(e){return Object.prototype.toString.call(e)===`[object ArrayBuffer]`}static toArrayBuffer(e){return this.isArrayBuffer(e)?e:e.byteLength===e.buffer.byteLength||e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e.buffer:this.toUint8Array(e.buffer).slice(e.byteOffset,e.byteOffset+e.byteLength).buffer}static toUint8Array(e){return this.toView(e,Uint8Array)}static toView(e,t){if(e.constructor===t)return e;if(this.isArrayBuffer(e))return new t(e);if(this.isArrayBufferView(e))return new t(e.buffer,e.byteOffset,e.byteLength);throw TypeError(`The provided value is not of type '(ArrayBuffer or ArrayBufferView)'`)}static isBufferSource(e){return this.isArrayBufferView(e)||this.isArrayBuffer(e)}static isArrayBufferView(e){return ArrayBuffer.isView(e)||e&&this.isArrayBuffer(e.buffer)}static isEqual(t,n){let r=e.toUint8Array(t),i=e.toUint8Array(n);if(r.length!==i.byteLength)return!1;for(let e=0;e<r.length;e++)if(r[e]!==i[e])return!1;return!0}static concat(...e){let t;t=Array.isArray(e[0])&&!(e[1]instanceof Function)||Array.isArray(e[0])&&e[1]instanceof Function?e[0]:e[e.length-1]instanceof Function?e.slice(0,e.length-1):e;let n=0;for(let e of t)n+=e.byteLength;let r=new Uint8Array(n),i=0;for(let e of t){let t=this.toUint8Array(e);r.set(t,i),i+=t.length}return e[e.length-1]instanceof Function?this.toView(r,e[e.length-1]):r.buffer}};let n=`string`,r=/^[0-9a-f\s]+$/i,i=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,a=/^[a-zA-Z0-9-_]+$/;var o=class{static fromString(e){let t=unescape(encodeURIComponent(e)),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n.buffer}static toString(e){let n=t.toUint8Array(e),r=``;for(let e=0;e<n.length;e++)r+=String.fromCharCode(n[e]);return decodeURIComponent(escape(r))}},s=class{static toString(e,n=!1){let r=t.toArrayBuffer(e),i=new DataView(r),a=``;for(let e=0;e<r.byteLength;e+=2){let t=i.getUint16(e,n);a+=String.fromCharCode(t)}return a}static fromString(e,t=!1){let n=new ArrayBuffer(e.length*2),r=new DataView(n);for(let n=0;n<e.length;n++)r.setUint16(n*2,e.charCodeAt(n),t);return n}},c=class e{static isHex(e){return typeof e==n&&r.test(e)}static isBase64(e){return typeof e==n&&i.test(e)}static isBase64Url(e){return typeof e==n&&a.test(e)}static ToString(e,n=`utf8`){let r=t.toUint8Array(e);switch(n.toLowerCase()){case`utf8`:return this.ToUtf8String(r);case`binary`:return this.ToBinary(r);case`hex`:return this.ToHex(r);case`base64`:return this.ToBase64(r);case`base64url`:return this.ToBase64Url(r);case`utf16le`:return s.toString(r,!0);case`utf16`:case`utf16be`:return s.toString(r);default:throw Error(`Unknown type of encoding '${n}'`)}}static FromString(e,t=`utf8`){if(!e)return new ArrayBuffer(0);switch(t.toLowerCase()){case`utf8`:return this.FromUtf8String(e);case`binary`:return this.FromBinary(e);case`hex`:return this.FromHex(e);case`base64`:return this.FromBase64(e);case`base64url`:return this.FromBase64Url(e);case`utf16le`:return s.fromString(e,!0);case`utf16`:case`utf16be`:return s.fromString(e);default:throw Error(`Unknown type of encoding '${t}'`)}}static ToBase64(e){let n=t.toUint8Array(e);if(typeof btoa<`u`){let e=this.ToString(n,`binary`);return btoa(e)}else return Buffer.from(n).toString(`base64`)}static FromBase64(t){let n=this.formatString(t);if(!n)return new ArrayBuffer(0);if(!e.isBase64(n))throw TypeError(`Argument 'base64Text' is not Base64 encoded`);return typeof atob<`u`?this.FromBinary(atob(n)):new Uint8Array(Buffer.from(n,`base64`)).buffer}static FromBase64Url(t){let n=this.formatString(t);if(!n)return new ArrayBuffer(0);if(!e.isBase64Url(n))throw TypeError(`Argument 'base64url' is not Base64Url encoded`);return this.FromBase64(this.Base64Padding(n.replace(/\-/g,`+`).replace(/\_/g,`/`)))}static ToBase64Url(e){return this.ToBase64(e).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/\=/g,``)}static FromUtf8String(t,n=e.DEFAULT_UTF8_ENCODING){switch(n){case`ascii`:return this.FromBinary(t);case`utf8`:return o.fromString(t);case`utf16`:case`utf16be`:return s.fromString(t);case`utf16le`:case`usc2`:return s.fromString(t,!0);default:throw Error(`Unknown type of encoding '${n}'`)}}static ToUtf8String(t,n=e.DEFAULT_UTF8_ENCODING){switch(n){case`ascii`:return this.ToBinary(t);case`utf8`:return o.toString(t);case`utf16`:case`utf16be`:return s.toString(t);case`utf16le`:case`usc2`:return s.toString(t,!0);default:throw Error(`Unknown type of encoding '${n}'`)}}static FromBinary(e){let t=e.length,n=new Uint8Array(t);for(let r=0;r<t;r++)n[r]=e.charCodeAt(r);return n.buffer}static ToBinary(e){let n=t.toUint8Array(e),r=``;for(let e=0;e<n.length;e++)r+=String.fromCharCode(n[e]);return r}static ToHex(e){let n=t.toUint8Array(e),r=``,i=n.length;for(let e=0;e<i;e++){let t=n[e];t<16&&(r+=`0`),r+=t.toString(16)}return r}static FromHex(t){let n=this.formatString(t);if(!n)return new ArrayBuffer(0);if(!e.isHex(n))throw TypeError(`Argument 'hexString' is not HEX encoded`);n.length%2&&(n=`0${n}`);let r=new Uint8Array(n.length/2);for(let e=0;e<n.length;e+=2){let t=n.slice(e,e+2);r[e/2]=parseInt(t,16)}return r.buffer}static ToUtf16String(e,t=!1){return s.toString(e,t)}static FromUtf16String(e,t=!1){return s.fromString(e,t)}static Base64Padding(e){let t=4-e.length%4;if(t<4)for(let n=0;n<t;n++)e+=`=`;return e}static formatString(e){return e?.replace(/[\n\r\t ]/g,``)||``}};c.DEFAULT_UTF8_ENCODING=`utf8`;function l(e,...t){let n=arguments[0];for(let e=1;e<arguments.length;e++){let t=arguments[e];for(let e in t)n[e]=t[e]}return n}function u(...e){let t=e.map(e=>e.byteLength).reduce((e,t)=>e+t),n=new Uint8Array(t),r=0;return e.map(e=>new Uint8Array(e)).forEach(e=>{for(let t of e)n[r++]=t}),n.buffer}function d(e,t){if(!(e&&t)||e.byteLength!==t.byteLength)return!1;let n=new Uint8Array(e),r=new Uint8Array(t);for(let t=0;t<e.byteLength;t++)if(n[t]!==r[t])return!1;return!0}e.BufferSourceConverter=t,e.Convert=c,e.assign=l,e.combine=u,e.isEqual=d})),$n=M((e=>{
45
+ /*!
46
+ Copyright (c) Peculiar Ventures, LLC
47
+ */
48
+ Object.defineProperty(e,"__esModule",{value:!0});function t(e){return new Date(e.getTime()+e.getTimezoneOffset()*6e4)}function n(e,t,n){return e instanceof Object?e[t]??n:n}function r(e,t=0,n=e.byteLength-t,r=!1){let i=``;for(let a of new Uint8Array(e,t,n)){let e=a.toString(16).toUpperCase();e.length===1&&(i+=`0`),i+=e,r&&(i+=` `)}return i.trim()}function i(e,t,n,r){return t instanceof ArrayBuffer?t.byteLength?n<0?(e.error=`Wrong parameter: inputOffset less than zero`,!1):r<0?(e.error=`Wrong parameter: inputLength less than zero`,!1):t.byteLength-n-r<0?(e.error=`End of input reached before message was fully decoded (inconsistent offset and length values)`,!1):!0:(e.error=`Wrong parameter: inputBuffer has zero length`,!1):(e.error=`Wrong parameter: inputBuffer must be "ArrayBuffer"`,!1)}function a(e,t){let n=0;if(e.length===1)return e[0];for(let r=e.length-1;r>=0;r--)n+=e[e.length-1-r]*2**(t*r);return n}function o(e,t,n=-1){let r=n,i=e,a=0,o=2**t;for(let n=1;n<8;n++){if(e<o){let e;if(r<0)e=new ArrayBuffer(n),a=n;else{if(r<n)return new ArrayBuffer(0);e=new ArrayBuffer(r),a=r}let o=new Uint8Array(e);for(let e=n-1;e>=0;e--){let n=2**(e*t);o[a-e-1]=Math.floor(i/n),i-=o[a-e-1]*n}return e}o*=2**t}return new ArrayBuffer(0)}function s(...e){let t=0,n=0;for(let n of e)t+=n.byteLength;let r=new ArrayBuffer(t),i=new Uint8Array(r);for(let t of e)i.set(new Uint8Array(t),n),n+=t.byteLength;return r}function c(...e){let t=0,n=0;for(let n of e)t+=n.length;let r=new ArrayBuffer(t),i=new Uint8Array(r);for(let t of e)i.set(t,n),n+=t.length;return i}function l(){let e=new Uint8Array(this.valueHex);if(this.valueHex.byteLength>=2){let t=e[0]===255&&e[1]&128,n=e[0]===0&&(e[1]&128)==0;(t||n)&&this.warnings.push(`Needlessly long format`)}let t=new ArrayBuffer(this.valueHex.byteLength),n=new Uint8Array(t);for(let e=0;e<this.valueHex.byteLength;e++)n[e]=0;n[0]=e[0]&128;let r=a(n,8),i=new ArrayBuffer(this.valueHex.byteLength),o=new Uint8Array(i);for(let t=0;t<this.valueHex.byteLength;t++)o[t]=e[t];return o[0]&=127,a(o,8)-r}function u(e){let t=e<0?e*-1:e,n=128;for(let r=1;r<8;r++){if(t<=n){if(e<0){let e=o(n-t,8,r),i=new Uint8Array(e);return i[0]|=128,e}let i=o(t,8,r),a=new Uint8Array(i);if(a[0]&128){let e=i.slice(0),t=new Uint8Array(e);i=new ArrayBuffer(i.byteLength+1),a=new Uint8Array(i);for(let n=0;n<e.byteLength;n++)a[n+1]=t[n];a[0]=0}return i}n*=2**8}return new ArrayBuffer(0)}function d(e,t){if(e.byteLength!==t.byteLength)return!1;let n=new Uint8Array(e),r=new Uint8Array(t);for(let e=0;e<n.length;e++)if(n[e]!==r[e])return!1;return!0}function f(e,t){let n=e.toString(10);if(t<n.length)return``;let r=t-n.length,i=Array(r);for(let e=0;e<r;e++)i[e]=`0`;return i.join(``).concat(n)}let p=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=`,m=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=`;function h(e,t=!1,n=!1,r=!1){let i=0,a=0,o=0,s=``,c=t?m:p;if(r){let t=0;for(let n=0;n<e.length;n++)if(e.charCodeAt(n)!==0){t=n;break}e=e.slice(t)}for(;i<e.length;){let t=e.charCodeAt(i++);i>=e.length&&(a=1);let r=e.charCodeAt(i++);i>=e.length&&(o=1);let l=e.charCodeAt(i++),u=t>>2,d=(t&3)<<4|r>>4,f=(r&15)<<2|l>>6,p=l&63;a===1?f=p=64:o===1&&(p=64),n?f===64?s+=`${c.charAt(u)}${c.charAt(d)}`:p===64?s+=`${c.charAt(u)}${c.charAt(d)}${c.charAt(f)}`:s+=`${c.charAt(u)}${c.charAt(d)}${c.charAt(f)}${c.charAt(p)}`:s+=`${c.charAt(u)}${c.charAt(d)}${c.charAt(f)}${c.charAt(p)}`}return s}function g(e,t=!1,n=!1){let r=t?m:p;function i(e){for(let t=0;t<64;t++)if(r.charAt(t)===e)return t;return 64}function a(e){return e===64?0:e}let o=0,s=``;for(;o<e.length;){let t=i(e.charAt(o++)),n=o>=e.length?0:i(e.charAt(o++)),r=o>=e.length?0:i(e.charAt(o++)),c=o>=e.length?0:i(e.charAt(o++)),l=a(t)<<2|a(n)>>4,u=(a(n)&15)<<4|a(r)>>2,d=(a(r)&3)<<6|a(c);s+=String.fromCharCode(l),r!==64&&(s+=String.fromCharCode(u)),c!==64&&(s+=String.fromCharCode(d))}if(n){let e=s.length,t=-1;for(let n=e-1;n>=0;n--)if(s.charCodeAt(n)!==0){t=n;break}s=t===-1?``:s.slice(0,t+1)}return s}function _(e){let t=``,n=new Uint8Array(e);for(let e of n)t+=String.fromCharCode(e);return t}function v(e){let t=e.length,n=new ArrayBuffer(t),r=new Uint8Array(n);for(let n=0;n<t;n++)r[n]=e.charCodeAt(n);return n}let y=Math.log(2);function b(e){let t=Math.log(e)/y,n=Math.floor(t),r=Math.round(t);return n===r?n:r}function x(e,t){for(let n of t)delete e[n]}e.arrayBufferToString=_,e.bufferToHexCodes=r,e.checkBufferParams=i,e.clearProps=x,e.fromBase64=g,e.getParametersValue=n,e.getUTCDate=t,e.isEqualBuffer=d,e.nearestPowerOf2=b,e.padNumber=f,e.stringToArrayBuffer=v,e.toBase64=h,e.utilConcatBuf=s,e.utilConcatView=c,e.utilDecodeTC=l,e.utilEncodeTC=u,e.utilFromBase=a,e.utilToBase=o})),er=M((e=>{
49
+ /*!
50
+ * Copyright (c) 2014, GMO GlobalSign
51
+ * Copyright (c) 2015-2022, Peculiar Ventures
52
+ * All rights reserved.
53
+ *
54
+ * Author 2014-2019, Yury Strozhevsky
55
+ *
56
+ * Redistribution and use in source and binary forms, with or without modification,
57
+ * are permitted provided that the following conditions are met:
58
+ *
59
+ * * Redistributions of source code must retain the above copyright notice, this
60
+ * list of conditions and the following disclaimer.
61
+ *
62
+ * * Redistributions in binary form must reproduce the above copyright notice, this
63
+ * list of conditions and the following disclaimer in the documentation and/or
64
+ * other materials provided with the distribution.
65
+ *
66
+ * * Neither the name of the copyright holder nor the names of its
67
+ * contributors may be used to endorse or promote products derived from
68
+ * this software without specific prior written permission.
69
+ *
70
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
71
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
72
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
73
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
74
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
75
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
76
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
77
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
78
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
79
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
80
+ *
81
+ */
82
+ var t=Qn(),n=$n();function r(e){var t=Object.create(null);return e&&Object.keys(e).forEach(function(n){if(n!=="default"){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}}),t.default=e,Object.freeze(t)}var i=r(t),a=r(n);function o(){if(typeof BigInt>`u`)throw Error(`BigInt is not defined. Your environment doesn't implement BigInt.`)}function s(e){let t=0,n=0;for(let n=0;n<e.length;n++){let r=e[n];t+=r.byteLength}let r=new Uint8Array(t);for(let t=0;t<e.length;t++){let i=e[t];r.set(new Uint8Array(i),n),n+=i.byteLength}return r.buffer}function c(e,t,n,r){return t instanceof Uint8Array?t.byteLength?n<0?(e.error=`Wrong parameter: inputOffset less than zero`,!1):r<0?(e.error=`Wrong parameter: inputLength less than zero`,!1):t.byteLength-n-r<0?(e.error=`End of input reached before message was fully decoded (inconsistent offset and length values)`,!1):!0:(e.error=`Wrong parameter: inputBuffer has zero length`,!1):(e.error=`Wrong parameter: inputBuffer must be 'Uint8Array'`,!1)}var l=class{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return s(this.items)}};let u=[new Uint8Array([1])],d=`0123456789`,f=`name`,p=`valueHexView`,m=new ArrayBuffer(0),h=new Uint8Array,g=`EndOfContent`,_=`OCTET STRING`,v=`BIT STRING`;function y(e){var t;return t=class extends e{get valueHex(){return this.valueHexView.slice().buffer}set valueHex(e){this.valueHexView=new Uint8Array(e)}constructor(...e){super(...e);let t=e[0]||{};this.isHexOnly=t.isHexOnly??!1,this.valueHexView=t.valueHex?i.BufferSourceConverter.toUint8Array(t.valueHex):h}fromBER(e,t,n,r){let i=e instanceof ArrayBuffer?new Uint8Array(e):e;if(!c(this,i,t,n))return-1;let a=t+n;return this.valueHexView=i.subarray(t,a),this.valueHexView.length?(this.blockLength=n,a):(this.warnings.push(`Zero buffer length`),t)}toBER(e=!1){return this.isHexOnly?e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.byteLength===this.valueHexView.buffer.byteLength?this.valueHexView.buffer:this.valueHexView.slice().buffer:(this.error=`Flag 'isHexOnly' is not set, abort`,m)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:i.Convert.ToHex(this.valueHexView)}}},t.NAME=`hexBlock`,t}var b=class{static blockName(){return this.NAME}get valueBeforeDecode(){return this.valueBeforeDecodeView.slice().buffer}set valueBeforeDecode(e){this.valueBeforeDecodeView=new Uint8Array(e)}constructor({blockLength:e=0,error:t=``,warnings:n=[],valueBeforeDecode:r=h}={}){this.blockLength=e,this.error=t,this.warnings=n,this.valueBeforeDecodeView=i.BufferSourceConverter.toUint8Array(r)}toJSON(){return{blockName:this.constructor.NAME,blockLength:this.blockLength,error:this.error,warnings:this.warnings,valueBeforeDecode:i.Convert.ToHex(this.valueBeforeDecodeView)}}};b.NAME=`baseBlock`;var x=class extends b{fromBER(e,t,n,r){throw TypeError(`User need to make a specific function in a class which extends 'ValueBlock'`)}toBER(e,t){throw TypeError(`User need to make a specific function in a class which extends 'ValueBlock'`)}};x.NAME=`valueBlock`;var S=class extends y(b){constructor({idBlock:e={}}={}){super(),e?(this.isHexOnly=e.isHexOnly??!1,this.valueHexView=e.valueHex?i.BufferSourceConverter.toUint8Array(e.valueHex):h,this.tagClass=e.tagClass??-1,this.tagNumber=e.tagNumber??-1,this.isConstructed=e.isConstructed??!1):(this.tagClass=-1,this.tagNumber=-1,this.isConstructed=!1)}toBER(e=!1){let t=0;switch(this.tagClass){case 1:t|=0;break;case 2:t|=64;break;case 3:t|=128;break;case 4:t|=192;break;default:return this.error=`Unknown tag class`,m}if(this.isConstructed&&(t|=32),this.tagNumber<31&&!this.isHexOnly){let n=new Uint8Array(1);if(!e){let e=this.tagNumber;e&=31,t|=e,n[0]=t}return n.buffer}if(!this.isHexOnly){let n=a.utilToBase(this.tagNumber,7),r=new Uint8Array(n),i=n.byteLength,o=new Uint8Array(i+1);if(o[0]=t|31,!e){for(let e=0;e<i-1;e++)o[e+1]=r[e]|128;o[i]=r[i-1]}return o.buffer}let n=new Uint8Array(this.valueHexView.byteLength+1);if(n[0]=t|31,!e){let e=this.valueHexView;for(let t=0;t<e.length-1;t++)n[t+1]=e[t]|128;n[this.valueHexView.byteLength]=e[e.length-1]}return n.buffer}fromBER(e,t,n){let r=i.BufferSourceConverter.toUint8Array(e);if(!c(this,r,t,n))return-1;let o=r.subarray(t,t+n);if(o.length===0)return this.error=`Zero buffer length`,-1;switch(o[0]&192){case 0:this.tagClass=1;break;case 64:this.tagClass=2;break;case 128:this.tagClass=3;break;case 192:this.tagClass=4;break;default:return this.error=`Unknown tag class`,-1}this.isConstructed=(o[0]&32)==32,this.isHexOnly=!1;let s=o[0]&31;if(s!==31)this.tagNumber=s,this.blockLength=1;else{let e=0;for(;;){let t=e+1;if(t>=o.length)return this.error=`End of input reached before message was fully decoded`,-1;if(e++,!(o[t]&128))break}this.blockLength=e+1;let t=this.valueHexView=new Uint8Array(e);for(let n=0;n<e;n++)t[n]=o[n+1]&127;this.blockLength<=9?this.tagNumber=a.utilFromBase(t,7):(this.isHexOnly=!0,this.warnings.push(`Tag too long, represented as hex-coded`))}if(this.tagClass===1&&this.isConstructed)switch(this.tagNumber){case 1:case 2:case 5:case 6:case 9:case 13:case 14:case 23:case 24:case 31:case 32:case 33:case 34:return this.error=`Constructed encoding used for primitive type`,-1}return t+this.blockLength}toJSON(){return{...super.toJSON(),tagClass:this.tagClass,tagNumber:this.tagNumber,isConstructed:this.isConstructed}}};S.NAME=`identificationBlock`;var C=class extends b{constructor({lenBlock:e={}}={}){super(),this.isIndefiniteForm=e.isIndefiniteForm??!1,this.longFormUsed=e.longFormUsed??!1,this.length=e.length??0}fromBER(e,t,n){let r=i.BufferSourceConverter.toUint8Array(e);if(!c(this,r,t,n))return-1;let o=r.subarray(t,t+n);if(o.length===0)return this.error=`Zero buffer length`,-1;if(o[0]===255)return this.error=`Length block 0xFF is reserved by standard`,-1;if(this.isIndefiniteForm=o[0]===128,this.isIndefiniteForm)return this.blockLength=1,t+this.blockLength;if(this.longFormUsed=!!(o[0]&128),this.longFormUsed===!1)return this.length=o[0],this.blockLength=1,t+this.blockLength;let s=o[0]&127;if(s>8)return this.error=`Too big integer`,-1;if(s+1>o.length)return this.error=`End of input reached before message was fully decoded`,-1;let l=t+1,u=r.subarray(l,l+s);return u[s-1]===0&&this.warnings.push(`Needlessly long encoded length`),this.length=a.utilFromBase(u,8),this.longFormUsed&&this.length<=127&&this.warnings.push(`Unnecessary usage of long length form`),this.blockLength=s+1,t+this.blockLength}toBER(e=!1){let t,n;if(this.length>127&&(this.longFormUsed=!0),this.isIndefiniteForm)return t=new ArrayBuffer(1),e===!1&&(n=new Uint8Array(t),n[0]=128),t;if(this.longFormUsed){let r=a.utilToBase(this.length,8);if(r.byteLength>127)return this.error=`Too big length`,m;if(t=new ArrayBuffer(r.byteLength+1),e)return t;let i=new Uint8Array(r);n=new Uint8Array(t),n[0]=r.byteLength|128;for(let e=0;e<r.byteLength;e++)n[e+1]=i[e];return t}return t=new ArrayBuffer(1),e===!1&&(n=new Uint8Array(t),n[0]=this.length),t}toJSON(){return{...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,longFormUsed:this.longFormUsed,length:this.length}}};C.NAME=`lengthBlock`;let w={};var T=class extends b{constructor({name:e=``,optional:t=!1,primitiveSchema:n,...r}={},i){super(r),this.name=e,this.optional=t,n&&(this.primitiveSchema=n),this.idBlock=new S(r),this.lenBlock=new C(r),this.valueBlock=i?new i(r):new x(r)}fromBER(e,t,n,r){let i=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length,r);return i===-1?(this.error=this.valueBlock.error,i):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),i)}toBER(e,t){let n=t||new l;t||ee(this);let r=this.idBlock.toBER(e);if(n.write(r),this.lenBlock.isIndefiniteForm)n.write(new Uint8Array([128]).buffer),this.valueBlock.toBER(e,n),n.write(new ArrayBuffer(2));else{let t=this.valueBlock.toBER(e);this.lenBlock.length=t.byteLength;let r=this.lenBlock.toBER(e);n.write(r),n.write(t)}return t?m:n.final()}toJSON(){let e={...super.toJSON(),idBlock:this.idBlock.toJSON(),lenBlock:this.lenBlock.toJSON(),valueBlock:this.valueBlock.toJSON(),name:this.name,optional:this.optional};return this.primitiveSchema&&(e.primitiveSchema=this.primitiveSchema.toJSON()),e}toString(e=`ascii`){return e===`ascii`?this.onAsciiEncoding():i.Convert.ToHex(this.toBER())}onAsciiEncoding(){return`${this.constructor.NAME} : ${i.Convert.ToHex(this.valueBlock.valueBeforeDecodeView)}`}isEqual(e){if(this===e)return!0;if(!(e instanceof this.constructor))return!1;let t=this.toBER(),n=e.toBER();return a.isEqualBuffer(t,n)}};T.NAME=`BaseBlock`;function ee(e){if(e instanceof w.Constructed)for(let t of e.valueBlock.value)ee(t)&&(e.lenBlock.isIndefiniteForm=!0);return!!e.lenBlock?.isIndefiniteForm}var E=class extends T{getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}constructor({value:e=``,...t}={},n){super(t,n),e&&this.fromString(e)}fromBER(e,t,n){let r=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return r===-1?(this.error=this.valueBlock.error,r):(this.fromBuffer(this.valueBlock.valueHexView),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),r)}onAsciiEncoding(){return`${this.constructor.NAME} : '${this.valueBlock.value}'`}};E.NAME=`BaseStringBlock`;var D=class extends y(x){constructor({isHexOnly:e=!0,...t}={}){super(t),this.isHexOnly=e}};D.NAME=`PrimitiveValueBlock`;var O,k=class extends T{constructor(e={}){super(e,D),this.idBlock.isConstructed=!1}};O=k,w.Primitive=O,k.NAME=`PRIMITIVE`;let te=1e4,A=16*1024*1024;function j(e={}){return{depth:0,maxDepth:e.maxDepth??100,nodesCount:0,maxNodes:e.maxNodes??te,maxContentLength:e.maxContentLength??A}}function ne(e){let t=new T({},x);return t.error=e,{offset:-1,result:t}}function re(e){if(e.nodesCount+=1,e.nodesCount>e.maxNodes)return`Maximum ASN.1 node count exceeded`}function M(e,t){if(e>t.maxContentLength)return`Maximum ASN.1 content length exceeded`}function N(e,t,n,r){let i=r.depth+1;if(i>r.maxDepth)return ne(`Maximum ASN.1 nesting depth exceeded`);r.depth=i;try{return ae(e,t,n,r)}finally{--r.depth}}function ie(e,t){if(e instanceof t)return e;let n=new t;return n.idBlock=e.idBlock,n.lenBlock=e.lenBlock,n.warnings=e.warnings,n.valueBeforeDecodeView=e.valueBeforeDecodeView,n}function ae(e,t=0,n=e.length,r=j()){let i=t,a=new T({},x),o=new b;if(!c(o,e,t,n))return a.error=o.error,{offset:-1,result:a};if(!e.subarray(t,t+n).length)return a.error=`Zero buffer length`,{offset:-1,result:a};let s=re(r);if(s)return a.error=s,{offset:-1,result:a};let l=a.idBlock.fromBER(e,t,n);if(a.idBlock.warnings.length&&a.warnings.concat(a.idBlock.warnings),l===-1)return a.error=a.idBlock.error,{offset:-1,result:a};if(t=l,n-=a.idBlock.blockLength,l=a.lenBlock.fromBER(e,t,n),a.lenBlock.warnings.length&&a.warnings.concat(a.lenBlock.warnings),l===-1)return a.error=a.lenBlock.error,{offset:-1,result:a};t=l,n-=a.lenBlock.blockLength;let u=a.lenBlock.isIndefiniteForm?n:a.lenBlock.length,d=M(u,r);if(d)return a.error=d,{offset:-1,result:a};if(!a.idBlock.isConstructed&&a.lenBlock.isIndefiniteForm)return a.error=`Indefinite length form used for primitive encoding form`,{offset:-1,result:a};let f=T;switch(a.idBlock.tagClass){case 1:if(a.idBlock.tagNumber>=37&&a.idBlock.isHexOnly===!1)return a.error=`UNIVERSAL 37 and upper tags are reserved by ASN.1 standard`,{offset:-1,result:a};switch(a.idBlock.tagNumber){case 0:if(a.idBlock.isConstructed&&a.lenBlock.length>0)return a.error=`Type [UNIVERSAL 0] is reserved`,{offset:-1,result:a};f=w.EndOfContent;break;case 1:f=w.Boolean;break;case 2:f=w.Integer;break;case 3:f=w.BitString;break;case 4:f=w.OctetString;break;case 5:f=w.Null;break;case 6:f=w.ObjectIdentifier;break;case 10:f=w.Enumerated;break;case 12:f=w.Utf8String;break;case 13:f=w.RelativeObjectIdentifier;break;case 14:f=w.TIME;break;case 15:return a.error=`[UNIVERSAL 15] is reserved by ASN.1 standard`,{offset:-1,result:a};case 16:f=w.Sequence;break;case 17:f=w.Set;break;case 18:f=w.NumericString;break;case 19:f=w.PrintableString;break;case 20:f=w.TeletexString;break;case 21:f=w.VideotexString;break;case 22:f=w.IA5String;break;case 23:f=w.UTCTime;break;case 24:f=w.GeneralizedTime;break;case 25:f=w.GraphicString;break;case 26:f=w.VisibleString;break;case 27:f=w.GeneralString;break;case 28:f=w.UniversalString;break;case 29:f=w.CharacterString;break;case 30:f=w.BmpString;break;case 31:f=w.DATE;break;case 32:f=w.TimeOfDay;break;case 33:f=w.DateTime;break;case 34:f=w.Duration;break;default:{let e=a.idBlock.isConstructed?new w.Constructed:new w.Primitive;e.idBlock=a.idBlock,e.lenBlock=a.lenBlock,e.warnings=a.warnings,a=e}}break;default:f=a.idBlock.isConstructed?w.Constructed:w.Primitive}return a=ie(a,f),l=a.fromBER(e,t,u,r),a.valueBeforeDecodeView=e.subarray(i,i+a.blockLength),{offset:l,result:a}}function P(e,t={}){if(!e.byteLength){let e=new T({},x);return e.error=`Input buffer has zero length`,{offset:-1,result:e}}return ae(i.BufferSourceConverter.toUint8Array(e).slice(),0,e.byteLength,j(t))}function oe(e,t){return e?1:t}var se=class extends x{constructor({value:e=[],isIndefiniteForm:t=!1,...n}={}){super(n),this.value=e,this.isIndefiniteForm=t}fromBER(e,t,n,r){let a=i.BufferSourceConverter.toUint8Array(e),o=r??j();if(!c(this,a,t,n))return-1;if(this.valueBeforeDecodeView=a.subarray(t,t+n),this.valueBeforeDecodeView.length===0)return this.warnings.push(`Zero buffer length`),t;let s=t;for(;oe(this.isIndefiniteForm,n)>0;){let e=N(a,s,n,o);if(e.offset===-1)return this.error=e.result.error,this.warnings.concat(e.result.warnings),-1;if(s=e.offset,this.blockLength+=e.result.blockLength,n-=e.result.blockLength,this.value.push(e.result),this.isIndefiniteForm&&e.result.constructor.NAME===g)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===g?this.value.pop():this.warnings.push(`No EndOfContent block encoded`)),s}toBER(e,t){let n=t||new l;for(let t=0;t<this.value.length;t++)this.value[t].toBER(e,n);return t?m:n.final()}toJSON(){let e={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(let t of this.value)e.value.push(t.toJSON());return e}};se.NAME=`ConstructedValueBlock`;var ce,le=class extends T{constructor(e={}){super(e,se),this.idBlock.isConstructed=!0}fromBER(e,t,n,r){this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm;let i=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length,r);return i===-1?(this.error=this.valueBlock.error,i):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),i)}onAsciiEncoding(){let e=[];for(let t of this.valueBlock.value)e.push(t.toString(`ascii`).split(`
83
+ `).map(e=>` ${e}`).join(`
84
+ `));let t=this.idBlock.tagClass===3?`[${this.idBlock.tagNumber}]`:this.constructor.NAME;return e.length?`${t} :\n${e.join(`
85
+ `)}`:`${t} :`}};ce=le,w.Constructed=ce,le.NAME=`CONSTRUCTED`;var ue=class extends x{fromBER(e,t,n){return t}toBER(e){return m}};ue.override=`EndOfContentValueBlock`;var de,fe=class extends T{constructor(e={}){super(e,ue),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}};de=fe,w.EndOfContent=de,fe.NAME=g;var pe,me=class extends T{constructor(e={}){super(e,x),this.idBlock.tagClass=1,this.idBlock.tagNumber=5}fromBER(e,t,n){return this.lenBlock.length>0&&this.warnings.push(`Non-zero length of value block for Null type`),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.blockLength+=n,t+n>e.byteLength?(this.error=`End of input reached before message was fully decoded (inconsistent offset and length values)`,-1):t+n}toBER(e,t){let n=new ArrayBuffer(2);if(!e){let e=new Uint8Array(n);e[0]=5,e[1]=0}return t&&t.write(n),n}onAsciiEncoding(){return`${this.constructor.NAME}`}};pe=me,w.Null=pe,me.NAME=`NULL`;var he=class extends y(x){get value(){for(let e of this.valueHexView)if(e>0)return!0;return!1}set value(e){this.valueHexView[0]=e?255:0}constructor({value:e,...t}={}){super(t),t.valueHex?this.valueHexView=i.BufferSourceConverter.toUint8Array(t.valueHex):this.valueHexView=new Uint8Array(1),e&&(this.value=e)}fromBER(e,t,n){let r=i.BufferSourceConverter.toUint8Array(e);return c(this,r,t,n)?(this.valueHexView=r.subarray(t,t+n),n>1&&this.warnings.push(`Boolean value encoded in more then 1 octet`),this.isHexOnly=!0,a.utilDecodeTC.call(this),this.blockLength=n,t+n):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}};he.NAME=`BooleanValueBlock`;var F,ge=class extends T{getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}constructor(e={}){super(e,he),this.idBlock.tagClass=1,this.idBlock.tagNumber=1}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.getValue}`}};F=ge,w.Boolean=F,ge.NAME=`BOOLEAN`;var _e=class extends y(se){constructor({isConstructed:e=!1,...t}={}){super(t),this.isConstructed=e}fromBER(e,t,n,r){let i=0;if(this.isConstructed){if(this.isHexOnly=!1,i=se.prototype.fromBER.call(this,e,t,n,r),i===-1)return i;for(let e=0;e<this.value.length;e++){let t=this.value[e].constructor.NAME;if(t===g){if(this.isIndefiniteForm)break;return this.error=`EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only`,-1}if(t!==_)return this.error=`OCTET STRING may consists of OCTET STRINGs only`,-1}}else this.isHexOnly=!0,i=super.fromBER(e,t,n),this.blockLength=n;return i}toBER(e,t){return this.isConstructed?se.prototype.toBER.call(this,e,t):e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}};_e.NAME=`OctetStringValueBlock`;var I,ve=class extends T{constructor({idBlock:e={},lenBlock:t={},...n}={}){n.isConstructed??=!!n.value?.length,super({idBlock:{isConstructed:n.isConstructed,...e},lenBlock:{...t,isIndefiniteForm:!!n.isIndefiniteForm},...n},_e),this.idBlock.tagClass=1,this.idBlock.tagNumber=4}fromBER(e,t,n,r){if(this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,n===0)return this.idBlock.error.length===0&&(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length===0&&(this.blockLength+=this.lenBlock.blockLength),t;if(!this.valueBlock.isConstructed){let i=(e instanceof ArrayBuffer?new Uint8Array(e):e).subarray(t,t+n);try{if(i.byteLength){let e=r??j(),t=N(i,0,i.byteLength,e);t.offset!==-1&&t.offset===n&&(this.valueBlock.value=[t.result])}}catch{}}return super.fromBER(e,t,n,r)}onAsciiEncoding(){return this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length?le.prototype.onAsciiEncoding.call(this):`${this.constructor.NAME} : ${i.Convert.ToHex(this.valueBlock.valueHexView)}`}getValue(){if(!this.idBlock.isConstructed)return this.valueBlock.valueHexView.slice().buffer;let e=[];for(let t of this.valueBlock.value)t instanceof I&&e.push(t.valueBlock.valueHexView);return i.BufferSourceConverter.concat(e)}};I=ve,w.OctetString=I,ve.NAME=_;var ye=class extends y(se){constructor({unusedBits:e=0,isConstructed:t=!1,...n}={}){super(n),this.unusedBits=e,this.isConstructed=t,this.blockLength=this.valueHexView.byteLength}fromBER(e,t,n,r){if(!n)return t;let a=-1;if(this.isConstructed){if(a=se.prototype.fromBER.call(this,e,t,n,r),a===-1)return a;for(let e of this.value){let t=e.constructor.NAME;if(t===g){if(this.isIndefiniteForm)break;return this.error=`EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only`,-1}if(t!==v)return this.error=`BIT STRING may consists of BIT STRINGs only`,-1;let n=e.valueBlock;if(this.unusedBits>0&&n.unusedBits>0)return this.error=`Using of "unused bits" inside constructive BIT STRING allowed for least one only`,-1;this.unusedBits=n.unusedBits}return a}let o=i.BufferSourceConverter.toUint8Array(e);if(!c(this,o,t,n))return-1;let s=o.subarray(t,t+n);if(this.unusedBits=s[0],this.unusedBits>7)return this.error=`Unused bits for BitString must be in range 0-7`,-1;if(!this.unusedBits){let e=s.subarray(1);try{if(e.byteLength){let t=r??j(),i=N(e,0,e.byteLength,t);i.offset!==-1&&i.offset===n-1&&(this.value=[i.result])}}catch{}}return this.valueHexView=s.subarray(1),this.blockLength=s.length,t+n}toBER(e,t){if(this.isConstructed)return se.prototype.toBER.call(this,e,t);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength){let e=new Uint8Array(1);return e[0]=0,e.buffer}let n=new Uint8Array(this.valueHexView.length+1);return n[0]=this.unusedBits,n.set(this.valueHexView,1),n.buffer}toJSON(){return{...super.toJSON(),unusedBits:this.unusedBits,isConstructed:this.isConstructed}}};ye.NAME=`BitStringValueBlock`;var be,xe=class extends T{constructor({idBlock:e={},lenBlock:t={},...n}={}){n.isConstructed??=!!n.value?.length,super({idBlock:{isConstructed:n.isConstructed,...e},lenBlock:{...t,isIndefiniteForm:!!n.isIndefiniteForm},...n},ye),this.idBlock.tagClass=1,this.idBlock.tagNumber=3}fromBER(e,t,n,r){return this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,super.fromBER(e,t,n,r)}onAsciiEncoding(){if(this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length)return le.prototype.onAsciiEncoding.call(this);{let e=[],t=this.valueBlock.valueHexView;for(let n of t)e.push(n.toString(2).padStart(8,`0`));let n=e.join(``);return`${this.constructor.NAME} : ${n.substring(0,n.length-this.valueBlock.unusedBits)}`}}};be=xe,w.BitString=be,xe.NAME=v;var L;function Se(e,t){let n=new Uint8Array([0]),r=new Uint8Array(e),i=new Uint8Array(t),o=r.slice(0),s=o.length-1,c=i.slice(0),l=c.length-1,u=0,d=l<s?s:l,f=0;for(let e=d;e>=0;e--,f++){switch(!0){case f<c.length:u=o[s-f]+c[l-f]+n[0];break;default:u=o[s-f]+n[0]}switch(n[0]=u/10,!0){case f>=o.length:o=a.utilConcatView(new Uint8Array([u%10]),o);break;default:o[s-f]=u%10}}return n[0]>0&&(o=a.utilConcatView(n,o)),o}function Ce(e){if(e>=u.length)for(let t=u.length;t<=e;t++){let e=new Uint8Array([0]),n=u[t-1].slice(0);for(let t=n.length-1;t>=0;t--){let r=new Uint8Array([(n[t]<<1)+e[0]]);e[0]=r[0]/10,n[t]=r[0]%10}e[0]>0&&(n=a.utilConcatView(e,n)),u.push(n)}return u[e]}function R(e,t){let n=0,r=new Uint8Array(e),i=new Uint8Array(t),a=r.slice(0),o=a.length-1,s=i.slice(0),c=s.length-1,l,u=0;for(let e=c;e>=0;e--,u++)switch(l=a[o-u]-s[c-u]-n,!0){case l<0:n=1,a[o-u]=l+10;break;default:n=0,a[o-u]=l}if(n>0)for(let e=o-c+1;e>=0;e--,u++)if(l=a[o-u]-n,l<0)n=1,a[o-u]=l+10;else{n=0,a[o-u]=l;break}return a.slice()}var we=class extends y(x){setValueHex(){this.valueHexView.length>=4?(this.warnings.push(`Too big Integer for decoding, hex only`),this.isHexOnly=!0,this._valueDec=0):(this.isHexOnly=!1,this.valueHexView.length>0&&(this._valueDec=a.utilDecodeTC.call(this)))}constructor({value:e,...t}={}){super(t),this._valueDec=0,t.valueHex&&this.setValueHex(),e!==void 0&&(this.valueDec=e)}set valueDec(e){this._valueDec=e,this.isHexOnly=!1,this.valueHexView=new Uint8Array(a.utilEncodeTC(e))}get valueDec(){return this._valueDec}fromDER(e,t,n,r=0){let i=this.fromBER(e,t,n);if(i===-1)return i;let a=this.valueHexView;return a[0]===0&&a[1]&128?this.valueHexView=a.subarray(1):r!==0&&a.length<r&&(r-a.length>1&&(r=a.length+1),this.valueHexView=a.subarray(r-a.length)),i}toDER(e=!1){let t=this.valueHexView;switch(!0){case(t[0]&128)!=0:{let e=new Uint8Array(this.valueHexView.length+1);e[0]=0,e.set(t,1),this.valueHexView=e}break;case t[0]===0&&(t[1]&128)==0:this.valueHexView=this.valueHexView.subarray(1);break}return this.toBER(e)}fromBER(e,t,n){let r=super.fromBER(e,t,n);return r===-1||this.setValueHex(),r}toBER(e){return e?new ArrayBuffer(this.valueHexView.length):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}toString(){let e=this.valueHexView.length*8-1,t=new Uint8Array(this.valueHexView.length*8/3),n=0,r,i=this.valueHexView,a=``,o=!1;for(let o=i.byteLength-1;o>=0;o--){r=i[o];for(let i=0;i<8;i++){if((r&1)==1)switch(n){case e:t=R(Ce(n),t),a=`-`;break;default:t=Se(t,Ce(n))}n++,r>>=1}}for(let e=0;e<t.length;e++)t[e]&&(o=!0),o&&(a+=d.charAt(t[e]));return o===!1&&(a+=d.charAt(0)),a}};L=we,we.NAME=`IntegerValueBlock`,Object.defineProperty(L.prototype,"valueHex",{set:function(e){this.valueHexView=new Uint8Array(e),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var Te,Ee=class extends T{constructor(e={}){super(e,we),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return o(),BigInt(this.valueBlock.toString())}static fromBigInt(e){o();let t=BigInt(e),n=new l,r=t.toString(16).replace(/^-/,``),a=new Uint8Array(i.Convert.FromHex(r));if(t<0){let e=new Uint8Array(a.length+(a[0]&128?1:0));e[0]|=128;let r=BigInt(`0x${i.Convert.ToHex(e)}`)+t,o=i.BufferSourceConverter.toUint8Array(i.Convert.FromHex(r.toString(16)));o[0]|=128,n.write(o)}else a[0]&128&&n.write(new Uint8Array([0])),n.write(a);return new Te({valueHex:n.final()})}convertToDER(){let e=new Te({valueHex:this.valueBlock.valueHexView});return e.valueBlock.toDER(),e}convertFromDER(){return new Te({valueHex:this.valueBlock.valueHexView[0]===0?this.valueBlock.valueHexView.subarray(1):this.valueBlock.valueHexView})}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()}`}};Te=Ee,w.Integer=Te,Ee.NAME=`INTEGER`;var z,De=class extends Ee{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}};z=De,w.Enumerated=z,De.NAME=`ENUMERATED`;var B=class extends y(x){constructor({valueDec:e=-1,isFirstSid:t=!1,...n}={}){super(n),this.valueDec=e,this.isFirstSid=t}fromBER(e,t,n){if(!n)return t;let r=i.BufferSourceConverter.toUint8Array(e);if(!c(this,r,t,n))return-1;let o=r.subarray(t,t+n);this.valueHexView=new Uint8Array(n);for(let e=0;e<n&&(this.valueHexView[e]=o[e]&127,this.blockLength++,o[e]&128);e++);let s=new Uint8Array(this.blockLength);for(let e=0;e<this.blockLength;e++)s[e]=this.valueHexView[e];return this.valueHexView=s,o[this.blockLength-1]&128?(this.error=`End of input reached before message was fully decoded`,-1):(this.valueHexView[0]===0&&this.warnings.push(`Needlessly long format of SID encoding`),this.blockLength<=8?this.valueDec=a.utilFromBase(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push(`Too big SID for decoding, hex only`)),t+this.blockLength)}set valueBigInt(e){o();let t=BigInt(e).toString(2);for(;t.length%7;)t=`0`+t;let n=new Uint8Array(t.length/7);for(let e=0;e<n.length;e++)n[e]=parseInt(t.slice(e*7,e*7+7),2)+(e+1<n.length?128:0);this.fromBER(n.buffer,0,n.length)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);let t=this.valueHexView,n=new Uint8Array(this.blockLength);for(let e=0;e<this.blockLength-1;e++)n[e]=t[e]|128;return n[this.blockLength-1]=t[this.blockLength-1],n.buffer}let t=a.utilToBase(this.valueDec,7);if(t.byteLength===0)return this.error=`Error during encoding SID value`,m;let n=new Uint8Array(t.byteLength);if(!e){let e=new Uint8Array(t),r=t.byteLength-1;for(let t=0;t<r;t++)n[t]=e[t]|128;n[r]=e[r]}return n}toString(){let e=``;if(this.isHexOnly)e=i.Convert.ToHex(this.valueHexView);else if(this.isFirstSid){let t=this.valueDec;this.valueDec<=39?e=`0.`:this.valueDec<=79?(e=`1.`,t-=40):(e=`2.`,t-=80),e+=t.toString()}else e=this.valueDec.toString();return e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec,isFirstSid:this.isFirstSid}}};B.NAME=`sidBlock`;var V=class extends x{constructor({value:e=``,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let r=t;for(;n>0;){let t=new B;if(r=t.fromBER(e,r,n),r===-1)return this.blockLength=0,this.error=t.error,r;this.value.length===0&&(t.isFirstSid=!0),this.blockLength+=t.blockLength,n-=t.blockLength,this.value.push(t)}return r}toBER(e){let t=[];for(let n=0;n<this.value.length;n++){let r=this.value[n].toBER(e);if(r.byteLength===0)return this.error=this.value[n].error,m;t.push(r)}return s(t)}fromString(e){this.value=[];let t=0,n=0,r=``,i=!1;do if(n=e.indexOf(`.`,t),r=n===-1?e.substring(t):e.substring(t,n),t=n+1,i){let e=this.value[0],t=0;switch(e.valueDec){case 0:break;case 1:t=40;break;case 2:t=80;break;default:this.value=[];return}let n=parseInt(r,10);if(isNaN(n))return;e.valueDec=n+t,i=!1}else{let e=new B;if(r>2**53-1)o(),e.valueBigInt=BigInt(r);else if(e.valueDec=parseInt(r,10),isNaN(e.valueDec))return;this.value.length||(e.isFirstSid=!0,i=!0),this.value.push(e)}while(n!==-1)}toString(){let e=``,t=!1;for(let n=0;n<this.value.length;n++){t=this.value[n].isHexOnly;let r=this.value[n].toString();n!==0&&(e=`${e}.`),t?(r=`{${r}}`,this.value[n].isFirstSid?e=`2.{${r} - 80}`:e+=r):e+=r}return e}toJSON(){let e={...super.toJSON(),value:this.toString(),sidArray:[]};for(let t=0;t<this.value.length;t++)e.sidArray.push(this.value[t].toJSON());return e}};V.NAME=`ObjectIdentifierValueBlock`;var Oe,ke=class extends T{getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}constructor(e={}){super(e,V),this.idBlock.tagClass=1,this.idBlock.tagNumber=6}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||`empty`}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}};Oe=ke,w.ObjectIdentifier=Oe,ke.NAME=`OBJECT IDENTIFIER`;var Ae=class extends y(b){constructor({valueDec:e=0,...t}={}){super(t),this.valueDec=e}fromBER(e,t,n){if(n===0)return t;let r=i.BufferSourceConverter.toUint8Array(e);if(!c(this,r,t,n))return-1;let o=r.subarray(t,t+n);this.valueHexView=new Uint8Array(n);for(let e=0;e<n&&(this.valueHexView[e]=o[e]&127,this.blockLength++,o[e]&128);e++);let s=new Uint8Array(this.blockLength);for(let e=0;e<this.blockLength;e++)s[e]=this.valueHexView[e];return this.valueHexView=s,o[this.blockLength-1]&128?(this.error=`End of input reached before message was fully decoded`,-1):(this.valueHexView[0]===0&&this.warnings.push(`Needlessly long format of SID encoding`),this.blockLength<=8?this.valueDec=a.utilFromBase(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push(`Too big SID for decoding, hex only`)),t+this.blockLength)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);let t=this.valueHexView,n=new Uint8Array(this.blockLength);for(let e=0;e<this.blockLength-1;e++)n[e]=t[e]|128;return n[this.blockLength-1]=t[this.blockLength-1],n.buffer}let t=a.utilToBase(this.valueDec,7);if(t.byteLength===0)return this.error=`Error during encoding SID value`,m;let n=new Uint8Array(t.byteLength);if(!e){let e=new Uint8Array(t),r=t.byteLength-1;for(let t=0;t<r;t++)n[t]=e[t]|128;n[r]=e[r]}return n.buffer}toString(){let e=``;return e=this.isHexOnly?i.Convert.ToHex(this.valueHexView):this.valueDec.toString(),e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}};Ae.NAME=`relativeSidBlock`;var je=class extends x{constructor({value:e=``,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let r=t;for(;n>0;){let t=new Ae;if(r=t.fromBER(e,r,n),r===-1)return this.blockLength=0,this.error=t.error,r;this.blockLength+=t.blockLength,n-=t.blockLength,this.value.push(t)}return r}toBER(e,t){let n=[];for(let t=0;t<this.value.length;t++){let r=this.value[t].toBER(e);if(r.byteLength===0)return this.error=this.value[t].error,m;n.push(r)}return s(n)}fromString(e){this.value=[];let t=0,n=0,r=``;do{n=e.indexOf(`.`,t),r=n===-1?e.substring(t):e.substring(t,n),t=n+1;let i=new Ae;if(i.valueDec=parseInt(r,10),isNaN(i.valueDec))return!0;this.value.push(i)}while(n!==-1);return!0}toString(){let e=``,t=!1;for(let n=0;n<this.value.length;n++){t=this.value[n].isHexOnly;let r=this.value[n].toString();n!==0&&(e=`${e}.`),t&&(r=`{${r}}`),e+=r}return e}toJSON(){let e={...super.toJSON(),value:this.toString(),sidArray:[]};for(let t=0;t<this.value.length;t++)e.sidArray.push(this.value[t].toJSON());return e}};je.NAME=`RelativeObjectIdentifierValueBlock`;var Me,H=class extends T{getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}constructor(e={}){super(e,je),this.idBlock.tagClass=1,this.idBlock.tagNumber=13}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||`empty`}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}};Me=H,w.RelativeObjectIdentifier=Me,H.NAME=`RelativeObjectIdentifier`;var Ne,Pe=class extends le{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}};Ne=Pe,w.Sequence=Ne,Pe.NAME=`SEQUENCE`;var U,Fe=class extends le{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};U=Fe,w.Set=U,Fe.NAME=`SET`;var Ie=class extends y(x){constructor({...e}={}){super(e),this.isHexOnly=!0,this.value=``}toJSON(){return{...super.toJSON(),value:this.value}}};Ie.NAME=`StringValueBlock`;var Le=class extends Ie{};Le.NAME=`SimpleStringValueBlock`;var W=class extends E{constructor({...e}={}){super(e,Le)}fromBuffer(e){this.valueBlock.value=String.fromCharCode.apply(null,i.BufferSourceConverter.toUint8Array(e))}fromString(e){let t=e.length,n=this.valueBlock.valueHexView=new Uint8Array(t);for(let r=0;r<t;r++)n[r]=e.charCodeAt(r);this.valueBlock.value=e}};W.NAME=`SIMPLE STRING`;var Re=class extends W{fromBuffer(e){this.valueBlock.valueHexView=i.BufferSourceConverter.toUint8Array(e);try{this.valueBlock.value=i.Convert.ToUtf8String(e)}catch(t){this.warnings.push(`Error during "decodeURIComponent": ${t}, using raw string`),this.valueBlock.value=i.Convert.ToBinary(e)}}fromString(e){this.valueBlock.valueHexView=new Uint8Array(i.Convert.FromUtf8String(e)),this.valueBlock.value=e}};Re.NAME=`Utf8StringValueBlock`;var ze,Be=class extends Re{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}};ze=Be,w.Utf8String=ze,Be.NAME=`UTF8String`;var Ve=class extends W{fromBuffer(e){this.valueBlock.value=i.Convert.ToUtf16String(e),this.valueBlock.valueHexView=i.BufferSourceConverter.toUint8Array(e)}fromString(e){this.valueBlock.value=e,this.valueBlock.valueHexView=new Uint8Array(i.Convert.FromUtf16String(e))}};Ve.NAME=`BmpStringValueBlock`;var He,Ue=class extends Ve{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}};He=Ue,w.BmpString=He,Ue.NAME=`BMPString`;var We=class extends W{fromBuffer(e){let t=ArrayBuffer.isView(e)?e.slice().buffer:e.slice(0),n=new Uint8Array(t);for(let e=0;e<n.length;e+=4)n[e]=n[e+3],n[e+1]=n[e+2],n[e+2]=0,n[e+3]=0;this.valueBlock.value=String.fromCharCode.apply(null,new Uint32Array(t))}fromString(e){let t=e.length,n=this.valueBlock.valueHexView=new Uint8Array(t*4);for(let r=0;r<t;r++){let t=a.utilToBase(e.charCodeAt(r),8),i=new Uint8Array(t);if(i.length>4)continue;let o=4-i.length;for(let e=i.length-1;e>=0;e--)n[r*4+e+o]=i[e]}this.valueBlock.value=e}};We.NAME=`UniversalStringValueBlock`;var Ge,Ke=class extends We{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}};Ge=Ke,w.UniversalString=Ge,Ke.NAME=`UniversalString`;var G,qe=class extends W{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}};G=qe,w.NumericString=G,qe.NAME=`NumericString`;var Je,Ye=class extends W{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}};Je=Ye,w.PrintableString=Je,Ye.NAME=`PrintableString`;var Xe,Ze=class extends W{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}};Xe=Ze,w.TeletexString=Xe,Ze.NAME=`TeletexString`;var Qe,$e=class extends W{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}};Qe=$e,w.VideotexString=Qe,$e.NAME=`VideotexString`;var et,tt=class extends W{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}};et=tt,w.IA5String=et,tt.NAME=`IA5String`;var K,nt=class extends W{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}};K=nt,w.GraphicString=K,nt.NAME=`GraphicString`;var rt,it=class extends W{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}};rt=it,w.VisibleString=rt,it.NAME=`VisibleString`;var at,ot=class extends W{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}};at=ot,w.GeneralString=at,ot.NAME=`GeneralString`;var st,ct=class extends W{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}};st=ct,w.CharacterString=st,ct.NAME=`CharacterString`;var lt,ut=class extends it{constructor({value:e,valueDate:t,...n}={}){if(super(n),this.year=0,this.month=0,this.day=0,this.hour=0,this.minute=0,this.second=0,e){this.fromString(e),this.valueBlock.valueHexView=new Uint8Array(e.length);for(let t=0;t<e.length;t++)this.valueBlock.valueHexView[t]=e.charCodeAt(t)}t&&(this.fromDate(t),this.valueBlock.valueHexView=new Uint8Array(this.toBuffer())),this.idBlock.tagClass=1,this.idBlock.tagNumber=23}fromBuffer(e){this.fromString(String.fromCharCode.apply(null,i.BufferSourceConverter.toUint8Array(e)))}toBuffer(){let e=this.toString(),t=new ArrayBuffer(e.length),n=new Uint8Array(t);for(let t=0;t<e.length;t++)n[t]=e.charCodeAt(t);return t}fromDate(e){this.year=e.getUTCFullYear(),this.month=e.getUTCMonth()+1,this.day=e.getUTCDate(),this.hour=e.getUTCHours(),this.minute=e.getUTCMinutes(),this.second=e.getUTCSeconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second))}fromString(e){let t=/(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z/gi.exec(e);if(t===null){this.error=`Wrong input string for conversion`;return}let n=parseInt(t[1],10);n>=50?this.year=1900+n:this.year=2e3+n,this.month=parseInt(t[2],10),this.day=parseInt(t[3],10),this.hour=parseInt(t[4],10),this.minute=parseInt(t[5],10),this.second=parseInt(t[6],10)}toString(e=`iso`){if(e===`iso`){let e=Array(7);return e[0]=a.padNumber(this.year<2e3?this.year-1900:this.year-2e3,2),e[1]=a.padNumber(this.month,2),e[2]=a.padNumber(this.day,2),e[3]=a.padNumber(this.hour,2),e[4]=a.padNumber(this.minute,2),e[5]=a.padNumber(this.second,2),e[6]=`Z`,e.join(``)}return super.toString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.toDate().toISOString()}`}toJSON(){return{...super.toJSON(),year:this.year,month:this.month,day:this.day,hour:this.hour,minute:this.minute,second:this.second}}};lt=ut,w.UTCTime=lt,ut.NAME=`UTCTime`;var dt,ft=class extends ut{constructor(e={}){super(e),this.millisecond??=0,this.idBlock.tagClass=1,this.idBlock.tagNumber=24}fromDate(e){super.fromDate(e),this.millisecond=e.getUTCMilliseconds()}toDate(){let e=Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second,this.millisecond);return new Date(e)}fromString(e){let t=!1,n=``,r=``,i=0,a,o=0,s=0;if(e[e.length-1]===`Z`)n=e.substring(0,e.length-1),t=!0;else{let t=new Number(e[e.length-1]);if(isNaN(t.valueOf()))throw Error(`Wrong input string for conversion`);n=e}if(t){if(n.indexOf(`+`)!==-1||n.indexOf(`-`)!==-1)throw Error(`Wrong input string for conversion`)}else{let e=1,t=n.indexOf(`+`),r=``;if(t===-1&&(t=n.indexOf(`-`),e=-1),t!==-1){if(r=n.substring(t+1),n=n.substring(0,t),r.length!==2&&r.length!==4)throw Error(`Wrong input string for conversion`);let i=parseInt(r.substring(0,2),10);if(isNaN(i.valueOf()))throw Error(`Wrong input string for conversion`);if(o=e*i,r.length===4){if(i=parseInt(r.substring(2,4),10),isNaN(i.valueOf()))throw Error(`Wrong input string for conversion`);s=e*i}}}let c=n.indexOf(`.`);if(c===-1&&(c=n.indexOf(`,`)),c!==-1){let e=new Number(`0${n.substring(c)}`);if(isNaN(e.valueOf()))throw Error(`Wrong input string for conversion`);i=e.valueOf(),r=n.substring(0,c)}else r=n;switch(!0){case r.length===8:if(a=/(\d{4})(\d{2})(\d{2})/gi,c!==-1)throw Error(`Wrong input string for conversion`);break;case r.length===10:if(a=/(\d{4})(\d{2})(\d{2})(\d{2})/gi,c!==-1){let e=60*i;this.minute=Math.floor(e),e=60*(e-this.minute),this.second=Math.floor(e),e=1e3*(e-this.second),this.millisecond=Math.floor(e)}break;case r.length===12:if(a=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/gi,c!==-1){let e=60*i;this.second=Math.floor(e),e=1e3*(e-this.second),this.millisecond=Math.floor(e)}break;case r.length===14:if(a=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/gi,c!==-1){let e=1e3*i;this.millisecond=Math.floor(e)}break;default:throw Error(`Wrong input string for conversion`)}let l=a.exec(r);if(l===null)throw Error(`Wrong input string for conversion`);for(let e=1;e<l.length;e++)switch(e){case 1:this.year=parseInt(l[e],10);break;case 2:this.month=parseInt(l[e],10);break;case 3:this.day=parseInt(l[e],10);break;case 4:this.hour=parseInt(l[e],10)+o;break;case 5:this.minute=parseInt(l[e],10)+s;break;case 6:this.second=parseInt(l[e],10);break;default:throw Error(`Wrong input string for conversion`)}if(t===!1){let e=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);this.year=e.getUTCFullYear(),this.month=e.getUTCMonth(),this.day=e.getUTCDay(),this.hour=e.getUTCHours(),this.minute=e.getUTCMinutes(),this.second=e.getUTCSeconds(),this.millisecond=e.getUTCMilliseconds()}}toString(e=`iso`){if(e===`iso`){let e=[];return e.push(a.padNumber(this.year,4)),e.push(a.padNumber(this.month,2)),e.push(a.padNumber(this.day,2)),e.push(a.padNumber(this.hour,2)),e.push(a.padNumber(this.minute,2)),e.push(a.padNumber(this.second,2)),this.millisecond!==0&&(e.push(`.`),e.push(a.padNumber(this.millisecond,3))),e.push(`Z`),e.join(``)}return super.toString(e)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}};dt=ft,w.GeneralizedTime=dt,ft.NAME=`GeneralizedTime`;var pt,mt=class extends Be{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}};pt=mt,w.DATE=pt,mt.NAME=`DATE`;var ht,gt=class extends Be{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}};ht=gt,w.TimeOfDay=ht,gt.NAME=`TimeOfDay`;var _t,vt=class extends Be{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}};_t=vt,w.DateTime=_t,vt.NAME=`DateTime`;var q,J=class extends Be{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}};q=J,w.Duration=q,J.NAME=`Duration`;var yt,bt=class extends Be{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}};yt=bt,w.TIME=yt,bt.NAME=`TIME`;var xt=class{constructor({name:e=``,optional:t=!1}={}){this.name=e,this.optional=t}},St=class extends xt{constructor({value:e=[],...t}={}){super(t),this.value=e}},Ct=class extends xt{constructor({value:e=new xt,local:t=!1,...n}={}){super(n),this.value=e,this.local=t}},wt=class{get data(){return this.dataView.slice().buffer}set data(e){this.dataView=i.BufferSourceConverter.toUint8Array(e)}constructor({data:e=h}={}){this.dataView=i.BufferSourceConverter.toUint8Array(e)}fromBER(e,t,n){let r=t+n;return this.dataView=i.BufferSourceConverter.toUint8Array(e).subarray(t,r),r}toBER(e){return this.dataView.slice().buffer}};function Tt(e,t,n){if(n instanceof St){for(let r of n.value)if(Tt(e,t,r).verified)return{verified:!0,result:e};{let e={verified:!1,result:{error:`Wrong values for Choice type`}};return n.hasOwnProperty(f)&&(e.name=n.name),e}}if(n instanceof xt)return n.hasOwnProperty(f)&&(e[n.name]=t),{verified:!0,result:e};if(!(e instanceof Object))return{verified:!1,result:{error:`Wrong root object`}};if(!(t instanceof Object))return{verified:!1,result:{error:`Wrong ASN.1 data`}};if(!(n instanceof Object)||!(`idBlock`in n)||!(`fromBER`in n.idBlock)||!(`toBER`in n.idBlock))return{verified:!1,result:{error:`Wrong ASN.1 schema`}};let r=n.idBlock.toBER(!1);if(r.byteLength===0)return{verified:!1,result:{error:`Error encoding idBlock for ASN.1 schema`}};if(n.idBlock.fromBER(r,0,r.byteLength)===-1)return{verified:!1,result:{error:`Error decoding idBlock for ASN.1 schema`}};if(n.idBlock.hasOwnProperty(`tagClass`)===!1)return{verified:!1,result:{error:`Wrong ASN.1 schema`}};if(n.idBlock.tagClass!==t.idBlock.tagClass)return{verified:!1,result:e};if(n.idBlock.hasOwnProperty(`tagNumber`)===!1)return{verified:!1,result:{error:`Wrong ASN.1 schema`}};if(n.idBlock.tagNumber!==t.idBlock.tagNumber)return{verified:!1,result:e};if(n.idBlock.hasOwnProperty(`isConstructed`)===!1)return{verified:!1,result:{error:`Wrong ASN.1 schema`}};if(n.idBlock.isConstructed!==t.idBlock.isConstructed)return{verified:!1,result:e};if(!(`isHexOnly`in n.idBlock))return{verified:!1,result:{error:`Wrong ASN.1 schema`}};if(n.idBlock.isHexOnly!==t.idBlock.isHexOnly)return{verified:!1,result:e};if(n.idBlock.isHexOnly){if(!(p in n.idBlock))return{verified:!1,result:{error:`Wrong ASN.1 schema`}};let r=n.idBlock.valueHexView,i=t.idBlock.valueHexView;if(r.length!==i.length)return{verified:!1,result:e};for(let t=0;t<r.length;t++)if(r[t]!==i[1])return{verified:!1,result:e}}if(n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,``),n.name&&(e[n.name]=t)),n instanceof w.Constructed){let r=0,i={verified:!1,result:{error:`Unknown error`}},a=n.valueBlock.value.length;if(a>0&&n.valueBlock.value[0]instanceof Ct&&(a=t.valueBlock.value.length),a===0)return{verified:!0,result:e};if(t.valueBlock.value.length===0&&n.valueBlock.value.length!==0){let t=!0;for(let e=0;e<n.valueBlock.value.length;e++)t&&=n.valueBlock.value[e].optional||!1;return t?{verified:!0,result:e}:(n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,``),n.name&&delete e[n.name]),e.error=`Inconsistent object length`,{verified:!1,result:e})}for(let o=0;o<a;o++)if(o-r>=t.valueBlock.value.length){if(n.valueBlock.value[o].optional===!1){let t={verified:!1,result:e};return e.error=`Inconsistent length between ASN.1 data and schema`,n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,``),n.name&&(delete e[n.name],t.name=n.name)),t}}else if(n.valueBlock.value[0]instanceof Ct){if(i=Tt(e,t.valueBlock.value[o],n.valueBlock.value[0].value),i.verified===!1)if(n.valueBlock.value[0].optional)r++;else return n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,``),n.name&&delete e[n.name]),i;if(f in n.valueBlock.value[0]&&n.valueBlock.value[0].name.length>0){let r={};r=`local`in n.valueBlock.value[0]&&n.valueBlock.value[0].local?t:e,r[n.valueBlock.value[0].name]===void 0&&(r[n.valueBlock.value[0].name]=[]),r[n.valueBlock.value[0].name].push(t.valueBlock.value[o])}}else if(i=Tt(e,t.valueBlock.value[o-r],n.valueBlock.value[o]),i.verified===!1)if(n.valueBlock.value[o].optional)r++;else return n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,``),n.name&&delete e[n.name]),i;if(i.verified===!1){let t={verified:!1,result:e};return n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,``),n.name&&(delete e[n.name],t.name=n.name)),t}return{verified:!0,result:e}}if(n.primitiveSchema&&p in t.valueBlock){let r=ae(t.valueBlock.valueHexView);if(r.offset===-1){let t={verified:!1,result:r.result};return n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,``),n.name&&(delete e[n.name],t.name=n.name)),t}return Tt(e,r.result,n.primitiveSchema)}return{verified:!0,result:e}}function Et(e,t){if(!(t instanceof Object))return{verified:!1,result:{error:`Wrong ASN.1 schema type`}};let n=ae(i.BufferSourceConverter.toUint8Array(e));return n.offset===-1?{verified:!1,result:n.result}:Tt(n.result,n.result,t)}e.Any=xt,e.BaseBlock=T,e.BaseStringBlock=E,e.BitString=xe,e.BmpString=Ue,e.Boolean=ge,e.CharacterString=ct,e.Choice=St,e.Constructed=le,e.DATE=mt,e.DEFAULT_MAX_CONTENT_LENGTH=A,e.DEFAULT_MAX_DEPTH=100,e.DEFAULT_MAX_NODES=te,e.DateTime=vt,e.Duration=J,e.EndOfContent=fe,e.Enumerated=De,e.GeneralString=ot,e.GeneralizedTime=ft,e.GraphicString=nt,e.HexBlock=y,e.IA5String=tt,e.Integer=Ee,e.Null=me,e.NumericString=qe,e.ObjectIdentifier=ke,e.OctetString=ve,e.Primitive=k,e.PrintableString=Ye,e.RawData=wt,e.RelativeObjectIdentifier=H,e.Repeated=Ct,e.Sequence=Pe,e.Set=Fe,e.TIME=bt,e.TeletexString=Ze,e.TimeOfDay=gt,e.UTCTime=ut,e.UniversalString=Ke,e.Utf8String=Be,e.ValueBlock=x,e.VideotexString=$e,e.ViewWriter=l,e.VisibleString=it,e.compareSchema=Tt,e.fromBER=P,e.verifySchema=Et})),tr=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isArrayBuffer=o,e.isSharedArrayBuffer=s,e.isArrayBufferLike=c,e.isArrayBufferView=l,e.isBufferSource=u,e.assertBufferSource=d,e.toUint8Array=f,e.toUint8ArrayCopy=p,e.toArrayBuffer=m,e.toArrayBufferLike=h,e.toView=g,e.toViewCopy=_;function t(e){return Object.prototype.toString.call(e)}function n(e){return e===DataView||e.prototype instanceof DataView}function r(e){return n(e)?1:e.BYTES_PER_ELEMENT??1}function i(e){if(ArrayBuffer.isView(e))return!0;if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.byteOffset==`number`&&typeof t.byteLength==`number`&&c(t.buffer)}function a(e){let t=f(e),n=new Uint8Array(t.byteLength);return n.set(t),n}function o(e){return t(e)===`[object ArrayBuffer]`}function s(e){return typeof SharedArrayBuffer<`u`&&t(e)===`[object SharedArrayBuffer]`}function c(e){return o(e)||s(e)}function l(e){return i(e)}function u(e){return c(e)||l(e)}function d(e){if(!u(e))throw TypeError(`Expected ArrayBuffer, SharedArrayBuffer, or ArrayBufferView`)}function f(e){return d(e),c(e)?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function p(e){return a(e)}function m(e){if(d(e),o(e))return e;let t=new ArrayBuffer(e.byteLength);return new Uint8Array(t).set(f(e)),t}function h(e){return d(e),c(e)?e:e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e.buffer:a(e).buffer}function g(e,t){if(d(e),ArrayBuffer.isView(e)&&e.constructor===t)return e;let i=f(e),a=r(t);if(i.byteOffset%a!==0||i.byteLength%a!==0)throw RangeError(`Cannot create ${t.name} over unaligned byte range`);return n(t)?new t(i.buffer,i.byteOffset,i.byteLength):new t(i.buffer,i.byteOffset,i.byteLength/a)}function _(e,t){return g(p(e),t)}})),nr=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.concatToUint8Array=n,e.concat=r;let t=tr();function n(e){let n=[],r=0;for(let i of e){let e=(0,t.toUint8Array)(i);n.push(e),r+=e.byteLength}let i=new Uint8Array(r),a=0;for(let e of n)i.set(e,a),a+=e.byteLength;return i}function r(e,r,...i){let a,o;typeof r==`function`?(a=Array.from(e),o=r):(0,t.isBufferSource)(e)?a=[e,r,...i].filter(t.isBufferSource):(a=Array.from(e),r&&a.push(r),a.push(...i));let s=n(a);return o?(0,t.toView)(s,o):s.buffer}})),rr=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.equal=n;let t=tr();function n(e,n,r={}){let i=(0,t.toUint8Array)(e),a=(0,t.toUint8Array)(n);if(!r.constantTime&&i.byteLength!==a.byteLength)return!1;let o=Math.max(i.byteLength,a.byteLength),s=i.byteLength^a.byteLength;for(let e=0;e<o;e++)s|=(i[e]??0)^(a[e]??0);return s===0}})),ir=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.indexOf=u,e.lastIndexOf=d,e.includes=f,e.startsWith=p,e.endsWith=m,e.slice=h,e.tail=g,e.copy=_,e.compare=v;let t=tr();function n(e,t,n){let r=Number.isFinite(e)?Math.trunc(e):t;return r<=0?0:r>=n?n:r}function r(e,t){let r=n(t?.start,0,e),i=n(t?.end,e,e);return i>=r?[r,i]:[r,r]}function i(e,t){let r=n(t?.start,e,e),i=n(t?.end,0,e);return r>=i?[i,r]:[r,r]}function a(e,t,n){let r=Number.isFinite(e)?Math.trunc(e):t;return r<0?Math.max(n+r,0):r>n?n:r}function o(e){let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n)&255;return t}function s(e){return new TextEncoder().encode(e)}function c(e,n){return typeof e==`string`?n?.encoding===`utf8`?s(e):o(e):(0,t.toUint8Array)(e)}function l(e,t,n){for(let r=0;r<t.byteLength;r++)if(e[n+r]!==t[r])return!1;return!0}function u(e,n,i){let a=(0,t.toUint8Array)(e),o=c(n,i),[s,u]=r(a.byteLength,i);if(o.byteLength===0)return s;let d=u-o.byteLength;if(d<s)return-1;for(let e=s;e<=d;e++)if(l(a,o,e))return e;return-1}function d(e,n,r){let a=(0,t.toUint8Array)(e),o=c(n,r),[s,u]=i(a.byteLength,r);if(o.byteLength===0)return u;let d=u-o.byteLength;if(d<s)return-1;for(let e=d;e>=s;e--)if(l(a,o,e))return e;return-1}function f(e,t,n){return u(e,t,n)!==-1}function p(e,n,r){let i=(0,t.toUint8Array)(e),a=c(n,r);return a.byteLength>i.byteLength?!1:l(i,a,0)}function m(e,n,r){let i=(0,t.toUint8Array)(e),a=c(n,r);return a.byteLength>i.byteLength?!1:l(i,a,i.byteLength-a.byteLength)}function h(e,n,r){let i=(0,t.toUint8Array)(e),o=a(n,0,i.byteLength),s=a(r,i.byteLength,i.byteLength);return s<=o?i.subarray(o,o):i.subarray(o,s)}function g(e,n){let r=(0,t.toUint8Array)(e),i=Number.isFinite(n)?Math.max(0,Math.trunc(n)):0;return i>=r.byteLength?r:r.subarray(r.byteLength-i)}function _(e){return(0,t.toUint8ArrayCopy)(e)}function v(e,n){let r=(0,t.toUint8Array)(e),i=(0,t.toUint8Array)(n),a=Math.min(r.byteLength,i.byteLength);for(let e=0;e<a;e++){if(r[e]<i[e])return-1;if(r[e]>i[e])return 1}return r.byteLength<i.byteLength?-1:+(r.byteLength>i.byteLength)}})),ar=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.tail=e.startsWith=e.slice=e.lastIndexOf=e.indexOf=e.includes=e.endsWith=e.copy=e.compare=e.equal=e.concatToUint8Array=e.concat=e.toViewCopy=e.toView=e.toUint8ArrayCopy=e.toUint8Array=e.toArrayBufferLike=e.toArrayBuffer=e.isSharedArrayBuffer=e.isBufferSource=e.isArrayBufferView=e.isArrayBufferLike=e.isArrayBuffer=e.assertBufferSource=void 0;var t=tr();Object.defineProperty(e,"assertBufferSource",{enumerable:!0,get:function(){return t.assertBufferSource}}),Object.defineProperty(e,"isArrayBuffer",{enumerable:!0,get:function(){return t.isArrayBuffer}}),Object.defineProperty(e,"isArrayBufferLike",{enumerable:!0,get:function(){return t.isArrayBufferLike}}),Object.defineProperty(e,"isArrayBufferView",{enumerable:!0,get:function(){return t.isArrayBufferView}}),Object.defineProperty(e,"isBufferSource",{enumerable:!0,get:function(){return t.isBufferSource}}),Object.defineProperty(e,"isSharedArrayBuffer",{enumerable:!0,get:function(){return t.isSharedArrayBuffer}}),Object.defineProperty(e,"toArrayBuffer",{enumerable:!0,get:function(){return t.toArrayBuffer}}),Object.defineProperty(e,"toArrayBufferLike",{enumerable:!0,get:function(){return t.toArrayBufferLike}}),Object.defineProperty(e,"toUint8Array",{enumerable:!0,get:function(){return t.toUint8Array}}),Object.defineProperty(e,"toUint8ArrayCopy",{enumerable:!0,get:function(){return t.toUint8ArrayCopy}}),Object.defineProperty(e,"toView",{enumerable:!0,get:function(){return t.toView}}),Object.defineProperty(e,"toViewCopy",{enumerable:!0,get:function(){return t.toViewCopy}});var n=nr();Object.defineProperty(e,"concat",{enumerable:!0,get:function(){return n.concat}}),Object.defineProperty(e,"concatToUint8Array",{enumerable:!0,get:function(){return n.concatToUint8Array}});var r=rr();Object.defineProperty(e,"equal",{enumerable:!0,get:function(){return r.equal}});var i=ir();Object.defineProperty(e,"compare",{enumerable:!0,get:function(){return i.compare}}),Object.defineProperty(e,"copy",{enumerable:!0,get:function(){return i.copy}}),Object.defineProperty(e,"endsWith",{enumerable:!0,get:function(){return i.endsWith}}),Object.defineProperty(e,"includes",{enumerable:!0,get:function(){return i.includes}}),Object.defineProperty(e,"indexOf",{enumerable:!0,get:function(){return i.indexOf}}),Object.defineProperty(e,"lastIndexOf",{enumerable:!0,get:function(){return i.lastIndexOf}}),Object.defineProperty(e,"slice",{enumerable:!0,get:function(){return i.slice}}),Object.defineProperty(e,"startsWith",{enumerable:!0,get:function(){return i.startsWith}}),Object.defineProperty(e,"tail",{enumerable:!0,get:function(){return i.tail}})})),or=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AsnPropTypes=e.AsnTypeTypes=void 0;var t;(function(e){e[e.Sequence=0]=`Sequence`,e[e.Set=1]=`Set`,e[e.Choice=2]=`Choice`})(t||(e.AsnTypeTypes=t={}));var n;(function(e){e[e.Any=1]=`Any`,e[e.Boolean=2]=`Boolean`,e[e.OctetString=3]=`OctetString`,e[e.BitString=4]=`BitString`,e[e.Integer=5]=`Integer`,e[e.Enumerated=6]=`Enumerated`,e[e.ObjectIdentifier=7]=`ObjectIdentifier`,e[e.Utf8String=8]=`Utf8String`,e[e.BmpString=9]=`BmpString`,e[e.UniversalString=10]=`UniversalString`,e[e.NumericString=11]=`NumericString`,e[e.PrintableString=12]=`PrintableString`,e[e.TeletexString=13]=`TeletexString`,e[e.VideotexString=14]=`VideotexString`,e[e.IA5String=15]=`IA5String`,e[e.GraphicString=16]=`GraphicString`,e[e.VisibleString=17]=`VisibleString`,e[e.GeneralString=18]=`GeneralString`,e[e.CharacterString=19]=`CharacterString`,e[e.UTCTime=20]=`UTCTime`,e[e.GeneralizedTime=21]=`GeneralizedTime`,e[e.DATE=22]=`DATE`,e[e.TimeOfDay=23]=`TimeOfDay`,e[e.DateTime=24]=`DateTime`,e[e.Duration=25]=`Duration`,e[e.TIME=26]=`TIME`,e[e.Null=27]=`Null`})(n||(e.AsnPropTypes=n={}))})),sr=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.BitString=void 0;let t=(X(),P(Y)).__importStar(er()),n=ar();e.BitString=class{unusedBits=0;value=new ArrayBuffer(0);constructor(e,t=0){if(e)if(typeof e==`number`)this.fromNumber(e);else if((0,n.isBufferSource)(e))this.unusedBits=t,this.value=(0,n.toArrayBuffer)(e);else throw TypeError(`Unsupported type of 'params' argument for BitString`)}fromASN(e){if(!(e instanceof t.BitString))throw TypeError(`Argument 'asn' is not instance of ASN.1 BitString`);return this.unusedBits=e.valueBlock.unusedBits,this.value=(0,n.toArrayBuffer)(e.valueBlock.valueHex),this}toASN(){return new t.BitString({unusedBits:this.unusedBits,valueHex:this.value})}toSchema(e){return new t.BitString({name:e})}toNumber(){let e=``,t=new Uint8Array(this.value);for(let n of t)e+=n.toString(2).padStart(8,`0`);return e=e.split(``).reverse().join(``),this.unusedBits&&(e=e.slice(this.unusedBits).padStart(this.unusedBits,`0`)),parseInt(e,2)}fromNumber(e){let t=e.toString(2),n=t.length+7>>3;this.unusedBits=(n<<3)-t.length;let r=new Uint8Array(n);t=t.padStart(n<<3,`0`).split(``).reverse().join(``);let i=0;for(;i<n;)r[i]=parseInt(t.slice(i<<3,(i<<3)+8),2),i++;this.value=r.buffer}}})),cr=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.OctetString=void 0;let t=(X(),P(Y)).__importStar(er()),n=ar();e.OctetString=class{buffer;get byteLength(){return this.buffer.byteLength}get byteOffset(){return 0}constructor(e){typeof e==`number`?this.buffer=new ArrayBuffer(e):(0,n.isBufferSource)(e)?this.buffer=(0,n.toArrayBuffer)(e):Array.isArray(e)?this.buffer=new Uint8Array(e).buffer:this.buffer=new ArrayBuffer(0)}fromASN(e){if(!(e instanceof t.OctetString))throw TypeError(`Argument 'asn' is not instance of ASN.1 OctetString`);return this.buffer=(0,n.toArrayBuffer)(e.valueBlock.valueHex),this}toASN(){return new t.OctetString({valueHex:this.buffer})}toSchema(e){return new t.OctetString({name:e})}}})),lr=M((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=(X(),P(Y));t.__exportStar(sr(),e),t.__exportStar(cr(),e)})),ur=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AsnNullConverter=e.AsnGeneralizedTimeConverter=e.AsnUTCTimeConverter=e.AsnCharacterStringConverter=e.AsnGeneralStringConverter=e.AsnVisibleStringConverter=e.AsnGraphicStringConverter=e.AsnIA5StringConverter=e.AsnVideotexStringConverter=e.AsnTeletexStringConverter=e.AsnPrintableStringConverter=e.AsnNumericStringConverter=e.AsnUniversalStringConverter=e.AsnBmpStringConverter=e.AsnUtf8StringConverter=e.AsnConstructedOctetStringConverter=e.AsnOctetStringConverter=e.AsnBooleanConverter=e.AsnObjectIdentifierConverter=e.AsnBitStringConverter=e.AsnIntegerBigIntConverter=e.AsnIntegerArrayBufferConverter=e.AsnEnumeratedConverter=e.AsnIntegerConverter=e.AsnAnyConverter=void 0,e.defaultConverter=o;let t=(X(),P(Y)).__importStar(er()),n=ar(),r=or(),i=lr();e.AsnAnyConverter={fromASN:e=>e instanceof t.Null?null:(0,n.toArrayBuffer)(e.valueBeforeDecodeView),toASN:e=>{if(e===null)return new t.Null;let n=t.fromBER(e);if(n.result.error)throw Error(n.result.error);return n.result}},e.AsnIntegerConverter={fromASN:e=>e.valueBlock.valueHexView.byteLength>=4?e.valueBlock.toString():e.valueBlock.valueDec,toASN:e=>new t.Integer({value:+e})},e.AsnEnumeratedConverter={fromASN:e=>e.valueBlock.valueDec,toASN:e=>new t.Enumerated({value:e})},e.AsnIntegerArrayBufferConverter={fromASN:e=>(0,n.toArrayBuffer)(e.valueBlock.valueHexView),toASN:e=>new t.Integer({valueHex:e})},e.AsnIntegerBigIntConverter={fromASN:e=>e.toBigInt(),toASN:e=>t.Integer.fromBigInt(e)},e.AsnBitStringConverter={fromASN:e=>(0,n.toArrayBuffer)(e.valueBlock.valueHexView),toASN:e=>new t.BitString({valueHex:e})},e.AsnObjectIdentifierConverter={fromASN:e=>e.valueBlock.toString(),toASN:e=>new t.ObjectIdentifier({value:e})},e.AsnBooleanConverter={fromASN:e=>e.valueBlock.value,toASN:e=>new t.Boolean({value:e})},e.AsnOctetStringConverter={fromASN:e=>(0,n.toArrayBuffer)(e.valueBlock.valueHexView),toASN:e=>new t.OctetString({valueHex:e})},e.AsnConstructedOctetStringConverter={fromASN:e=>new i.OctetString(e.getValue()),toASN:e=>e.toASN()};function a(e){return{fromASN:e=>e.valueBlock.value,toASN:t=>new e({value:t})}}e.AsnUtf8StringConverter=a(t.Utf8String),e.AsnBmpStringConverter=a(t.BmpString),e.AsnUniversalStringConverter=a(t.UniversalString),e.AsnNumericStringConverter=a(t.NumericString),e.AsnPrintableStringConverter=a(t.PrintableString),e.AsnTeletexStringConverter=a(t.TeletexString),e.AsnVideotexStringConverter=a(t.VideotexString),e.AsnIA5StringConverter=a(t.IA5String),e.AsnGraphicStringConverter=a(t.GraphicString),e.AsnVisibleStringConverter=a(t.VisibleString),e.AsnGeneralStringConverter=a(t.GeneralString),e.AsnCharacterStringConverter=a(t.CharacterString),e.AsnUTCTimeConverter={fromASN:e=>e.toDate(),toASN:e=>new t.UTCTime({valueDate:e})},e.AsnGeneralizedTimeConverter={fromASN:e=>e.toDate(),toASN:e=>new t.GeneralizedTime({valueDate:e})},e.AsnNullConverter={fromASN:()=>null,toASN:()=>new t.Null};function o(t){switch(t){case r.AsnPropTypes.Any:return e.AsnAnyConverter;case r.AsnPropTypes.BitString:return e.AsnBitStringConverter;case r.AsnPropTypes.BmpString:return e.AsnBmpStringConverter;case r.AsnPropTypes.Boolean:return e.AsnBooleanConverter;case r.AsnPropTypes.CharacterString:return e.AsnCharacterStringConverter;case r.AsnPropTypes.Enumerated:return e.AsnEnumeratedConverter;case r.AsnPropTypes.GeneralString:return e.AsnGeneralStringConverter;case r.AsnPropTypes.GeneralizedTime:return e.AsnGeneralizedTimeConverter;case r.AsnPropTypes.GraphicString:return e.AsnGraphicStringConverter;case r.AsnPropTypes.IA5String:return e.AsnIA5StringConverter;case r.AsnPropTypes.Integer:return e.AsnIntegerConverter;case r.AsnPropTypes.Null:return e.AsnNullConverter;case r.AsnPropTypes.NumericString:return e.AsnNumericStringConverter;case r.AsnPropTypes.ObjectIdentifier:return e.AsnObjectIdentifierConverter;case r.AsnPropTypes.OctetString:return e.AsnOctetStringConverter;case r.AsnPropTypes.PrintableString:return e.AsnPrintableStringConverter;case r.AsnPropTypes.TeletexString:return e.AsnTeletexStringConverter;case r.AsnPropTypes.UTCTime:return e.AsnUTCTimeConverter;case r.AsnPropTypes.UniversalString:return e.AsnUniversalStringConverter;case r.AsnPropTypes.Utf8String:return e.AsnUtf8StringConverter;case r.AsnPropTypes.VideotexString:return e.AsnVideotexStringConverter;case r.AsnPropTypes.VisibleString:return e.AsnVisibleStringConverter;default:return null}}})),dr=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isConvertible=t,e.isTypeOfArray=n,e.isArrayEqual=r;function t(e){return typeof e==`function`&&e.prototype?e.prototype.toASN&&e.prototype.fromASN?!0:t(e.prototype):!!(e&&typeof e==`object`&&`toASN`in e&&`fromASN`in e)}function n(e){if(e){let t=Object.getPrototypeOf(e);return t?.prototype?.constructor===Array?!0:n(t)}return!1}function r(e,t){if(!(e&&t)||e.byteLength!==t.byteLength)return!1;let n=new Uint8Array(e),r=new Uint8Array(t);for(let t=0;t<e.byteLength;t++)if(n[t]!==r[t])return!1;return!0}})),fr=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AsnSchemaStorage=void 0;let t=(X(),P(Y)).__importStar(er()),n=or(),r=dr();e.AsnSchemaStorage=class{items=new WeakMap;has(e){return this.items.has(e)}get(e,t=!1){let n=this.items.get(e);if(!n)throw Error(`Cannot get schema for '${e.prototype.constructor.name}' target`);if(t&&!n.schema)throw Error(`Schema '${e.prototype.constructor.name}' doesn't contain ASN.1 schema. Call 'AsnSchemaStorage.cache'.`);return n}cache(e){let t=this.get(e);t.schema||=this.create(e,!0)}createDefault(e){let t={type:n.AsnTypeTypes.Sequence,items:{}},r=this.findParentSchema(e);return r&&(Object.assign(t,r),t.items=Object.assign({},t.items,r.items)),t}create(e,i){let a=this.items.get(e)||this.createDefault(e),o=[];for(let e in a.items){let s=a.items[e],c=i?e:``,l;if(typeof s.type==`number`){let e=n.AsnPropTypes[s.type],r=t[e];if(!r)throw Error(`Cannot get ASN1 class by name '${e}'`);l=new r({name:c})}else(0,r.isConvertible)(s.type)?l=new s.type().toSchema(c):s.optional?this.get(s.type).type===n.AsnTypeTypes.Choice?l=new t.Any({name:c}):(l=this.create(s.type,!1),l.name=c):l=new t.Any({name:c});let u=!!s.optional||s.defaultValue!==void 0;if(s.repeated&&(l.name=``,l=new(s.repeated===`set`?t.Set:t.Sequence)({name:``,value:[new t.Repeated({name:c,value:l})]})),s.context!==null&&s.context!==void 0)if(s.implicit)if(typeof s.type==`number`||(0,r.isConvertible)(s.type)){let e=s.repeated?t.Constructed:t.Primitive;o.push(new e({name:c,optional:u,idBlock:{tagClass:3,tagNumber:s.context}}))}else{this.cache(s.type);let e=!!s.repeated,n=e?l:this.get(s.type,!0).schema;n=`valueBlock`in n?n.valueBlock.value:n.value,o.push(new t.Constructed({name:e?``:c,optional:u,idBlock:{tagClass:3,tagNumber:s.context},value:n}))}else o.push(new t.Constructed({optional:u,idBlock:{tagClass:3,tagNumber:s.context},value:[l]}));else l.optional=u,o.push(l)}switch(a.type){case n.AsnTypeTypes.Sequence:return new t.Sequence({value:o,name:``});case n.AsnTypeTypes.Set:return new t.Set({value:o,name:``});case n.AsnTypeTypes.Choice:return new t.Choice({value:o,name:``});default:throw Error(`Unsupported ASN1 type in use`)}}set(e,t){return this.items.set(e,t),this}findParentSchema(e){let t=Object.getPrototypeOf(e);return t?this.items.get(t)||this.findParentSchema(t):null}}})),pr=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.schemaStorage=void 0,e.schemaStorage=new(fr()).AsnSchemaStorage})),mr=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AsnProp=e.AsnSequenceType=e.AsnSetType=e.AsnChoiceType=e.AsnType=void 0;let t=(X(),P(Y)).__importStar(ur()),n=or(),r=pr();e.AsnType=e=>t=>{let n;r.schemaStorage.has(t)?n=r.schemaStorage.get(t):(n=r.schemaStorage.createDefault(t),r.schemaStorage.set(t,n)),Object.assign(n,e)},e.AsnChoiceType=()=>(0,e.AsnType)({type:n.AsnTypeTypes.Choice}),e.AsnSetType=t=>(0,e.AsnType)({type:n.AsnTypeTypes.Set,...t}),e.AsnSequenceType=t=>(0,e.AsnType)({type:n.AsnTypeTypes.Sequence,...t}),e.AsnProp=e=>(n,i)=>{let a;r.schemaStorage.has(n.constructor)?a=r.schemaStorage.get(n.constructor):(a=r.schemaStorage.createDefault(n.constructor),r.schemaStorage.set(n.constructor,a));let o=Object.assign({},e);if(typeof o.type==`number`&&!o.converter){let r=t.defaultConverter(e.type);if(!r)throw Error(`Cannot get default converter for property '${i}' of ${n.constructor.name}`);o.converter=r}o.raw=e.raw,a.items[i]=o}})),hr=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AsnSchemaValidationError=void 0,e.AsnSchemaValidationError=class extends Error{schemas=[]}})),gr=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),(X(),P(Y)).__exportStar(hr(),e)})),_r=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AsnParser=void 0;let t=(X(),P(Y)),n=t.__importStar(er()),r=ar(),i=or(),a=t.__importStar(ur()),o=gr(),s=dr(),c=pr();e.AsnParser=class{static parse(e,t,i){let a=n.fromBER((0,r.toArrayBuffer)(e),i?.berOptions);if(a.result.error)throw Error(a.result.error);return this.fromASN(a.result,t,i)}static fromASN(e,t,n){try{if((0,s.isConvertible)(t))return new t().fromASN(e);let r=c.schemaStorage.get(t);c.schemaStorage.cache(t);let i=r.schema,a=this.handleChoiceTypes(e,r,t,i,n);if(a?.result)return a.result;a?.targetSchema&&(i=a.targetSchema);let o=this.handleSequenceTypes(e,r,t,i),l=new t;return(0,s.isTypeOfArray)(t)?this.handleArrayTypes(e,r,t,n):(this.processSchemaItems(r,o,l,n),l)}catch(e){throw e instanceof o.AsnSchemaValidationError&&e.schemas.push(t.name),e}}static handleChoiceTypes(e,t,r,a,o){if(e.constructor===n.Constructed&&t.type===i.AsnTypeTypes.Choice&&e.idBlock.tagClass===3)for(let a in t.items){let s=t.items[a];if(s.context===e.idBlock.tagNumber&&s.implicit&&typeof s.type==`function`&&c.schemaStorage.has(s.type)){let t=c.schemaStorage.get(s.type);if(t&&t.type===i.AsnTypeTypes.Sequence){let t=new n.Sequence;if(`value`in e.valueBlock&&Array.isArray(e.valueBlock.value)&&`value`in t.valueBlock){t.valueBlock.value=e.valueBlock.value;let n=this.fromASN(t,s.type,o),i=new r;return i[a]=n,{result:i}}}}}else if(e.constructor===n.Constructed&&t.type!==i.AsnTypeTypes.Choice){let r=new n.Constructed({idBlock:{tagClass:3,tagNumber:e.idBlock.tagNumber},value:t.schema.valueBlock.value});for(let n in t.items)delete e[n];return{targetSchema:r}}return null}static handleSequenceTypes(e,t,r,a){if(t.type===i.AsnTypeTypes.Sequence){let t=n.compareSchema({},e,a);if(!t.verified)throw new o.AsnSchemaValidationError(`Data does not match to ${r.name} ASN1 schema.${t.result.error?` ${t.result.error}`:``}`);return t}else{let t=n.compareSchema({},e,a);if(!t.verified)throw new o.AsnSchemaValidationError(`Data does not match to ${r.name} ASN1 schema.${t.result.error?` ${t.result.error}`:``}`);return t}}static processRepeatedField(e,t,n){let r=e.slice(t);if(r.length===1&&r[0].constructor.name===`Sequence`){let e=r[0];e.valueBlock&&e.valueBlock.value&&Array.isArray(e.valueBlock.value)&&(r=e.valueBlock.value)}if(typeof n.type==`number`){let e=a.defaultConverter(n.type);if(!e)throw Error(`No converter for ASN.1 type ${n.type}`);return r.filter(e=>e&&e.valueBlock).map(t=>{try{return e.fromASN(t)}catch{return}}).filter(e=>e!==void 0)}else return r.filter(e=>e&&e.valueBlock).map(e=>{try{return this.fromASN(e,n.type)}catch{return}}).filter(e=>e!==void 0)}static processPrimitiveField(e,t){let n=a.defaultConverter(t.type);if(!n)throw Error(`No converter for ASN.1 type ${t.type}`);return n.fromASN(e)}static isOptionalChoiceField(e){return e.optional&&typeof e.type==`function`&&c.schemaStorage.has(e.type)&&c.schemaStorage.get(e.type).type===i.AsnTypeTypes.Choice}static processOptionalChoiceField(e,t){try{return{processed:!0,value:this.fromASN(e,t.type)}}catch(e){if(e instanceof o.AsnSchemaValidationError&&/Wrong values for Choice type/.test(e.message))return{processed:!1};throw e}}static handleArrayTypes(e,t,n,r){if(!(`value`in e.valueBlock&&Array.isArray(e.valueBlock.value)))throw Error(`Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed.`);let i=t.itemType;if(typeof i==`number`){let t=a.defaultConverter(i);if(!t)throw Error(`Cannot get default converter for array item of ${n.name} ASN1 schema`);return n.from(e.valueBlock.value,e=>t.fromASN(e))}else return n.from(e.valueBlock.value,e=>this.fromASN(e,i,r))}static processSchemaItems(e,t,n,r){for(let i in e.items){let a=t.result[i];if(!a)continue;let o=e.items[i],c=o.type,l;l=typeof c==`number`||(0,s.isConvertible)(c)?this.processPrimitiveSchemaItem(a,o,c,r):this.processComplexSchemaItem(a,o,c,r),l&&typeof l==`object`&&`value`in l&&`raw`in l?(n[i]=l.value,n[`${i}Raw`]=l.raw):n[i]=l}}static processPrimitiveSchemaItem(e,t,n,r){let i=t.converter??((0,s.isConvertible)(n)?new n:null);if(!i)throw Error(`Converter is empty`);return t.repeated?this.processRepeatedPrimitiveItem(e,t,i,r):this.processSinglePrimitiveItem(e,t,n,i,r)}static processRepeatedPrimitiveItem(e,t,r,i){if(t.implicit){let a=new(t.repeated===`sequence`?n.Sequence:n.Set);a.valueBlock=e.valueBlock;let o=n.fromBER(a.toBER(!1),i?.berOptions);if(o.offset===-1)throw Error(`Cannot parse the child item. ${o.result.error}`);if(!(`value`in o.result.valueBlock&&Array.isArray(o.result.valueBlock.value)))throw Error(`Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed.`);let s=o.result.valueBlock.value;return Array.from(s,e=>r.fromASN(e))}else return Array.from(e,e=>r.fromASN(e))}static processSinglePrimitiveItem(e,t,r,a,o){let c=e;if(t.implicit){let e;if((0,s.isConvertible)(r))e=new r().toSchema(``);else{let t=i.AsnPropTypes[r],a=n[t];if(!a)throw Error(`Cannot get '${t}' class from asn1js module`);e=new a}e.valueBlock=c.valueBlock,c=n.fromBER(e.toBER(!1),o?.berOptions).result}return a.fromASN(c)}static processComplexSchemaItem(e,t,n,r){if(t.repeated){if(!Array.isArray(e))throw Error(`Cannot get list of items from the ASN.1 parsed value. ASN.1 value should be iterable.`);return Array.from(e,e=>this.fromASN(e,n,r))}else{let i=this.handleImplicitTagging(e,t,n);if(this.isOptionalChoiceField(t))try{return this.fromASN(i,n,r)}catch(e){if(e instanceof o.AsnSchemaValidationError&&/Wrong values for Choice type/.test(e.message))return;throw e}else{let a=this.fromASN(i,n,r);return t.raw?{value:a,raw:e.valueBeforeDecodeView}:a}}}static handleImplicitTagging(e,t,r){if(t.implicit&&typeof t.context==`number`){let t=c.schemaStorage.get(r);if(t.type===i.AsnTypeTypes.Sequence){let t=new n.Sequence;if(`value`in e.valueBlock&&Array.isArray(e.valueBlock.value)&&`value`in t.valueBlock)return t.valueBlock.value=e.valueBlock.value,t}else if(t.type===i.AsnTypeTypes.Set){let t=new n.Set;if(`value`in e.valueBlock&&Array.isArray(e.valueBlock.value)&&`value`in t.valueBlock)return t.valueBlock.value=e.valueBlock.value,t}}return e}}})),vr=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AsnSerializer=void 0;let t=(X(),P(Y)),n=t.__importStar(er()),r=ar(),i=t.__importStar(ur()),a=or(),o=dr(),s=pr();e.AsnSerializer=class e{static serialize(e){return e instanceof n.BaseBlock?e.toBER(!1):this.toASN(e).toBER(!1)}static toASN(t){if(t&&typeof t==`object`&&(0,o.isConvertible)(t))return t.toASN();if(!(t&&typeof t==`object`))throw TypeError(`Parameter 1 should be type of Object.`);let c=t.constructor,l=s.schemaStorage.get(c);s.schemaStorage.cache(c);let u=[];if(l.itemType){if(!Array.isArray(t))throw TypeError(`Parameter 1 should be type of Array.`);if(typeof l.itemType==`number`){let e=i.defaultConverter(l.itemType);if(!e)throw Error(`Cannot get default converter for array item of ${c.name} ASN1 schema`);u=t.map(t=>e.toASN(t))}else u=t.map(e=>this.toAsnItem({type:l.itemType},`[]`,c,e))}else for(let i in l.items){let a=l.items[i],s=t[i];if(s===void 0||a.defaultValue===s||typeof a.defaultValue==`object`&&typeof s==`object`&&(0,o.isArrayEqual)(this.serialize(a.defaultValue),this.serialize(s)))continue;let d=e.toAsnItem(a,i,c,s);if(typeof a.context==`number`)if(a.implicit)if(!a.repeated&&(typeof a.type==`number`||(0,o.isConvertible)(a.type))){let e={};e.valueHex=d instanceof n.Null?(0,r.toArrayBuffer)(d.valueBeforeDecodeView):d.valueBlock.toBER(),u.push(new n.Primitive({optional:a.optional,idBlock:{tagClass:3,tagNumber:a.context},...e}))}else u.push(new n.Constructed({optional:a.optional,idBlock:{tagClass:3,tagNumber:a.context},value:d.valueBlock.value}));else u.push(new n.Constructed({optional:a.optional,idBlock:{tagClass:3,tagNumber:a.context},value:[d]}));else a.repeated?u=u.concat(d):u.push(d)}let d;switch(l.type){case a.AsnTypeTypes.Sequence:d=new n.Sequence({value:u});break;case a.AsnTypeTypes.Set:d=new n.Set({value:u});break;case a.AsnTypeTypes.Choice:if(!u[0])throw Error(`Schema '${c.name}' has wrong data. Choice cannot be empty.`);d=u[0];break}return d}static toAsnItem(e,t,r,i){let o;if(typeof e.type==`number`){let s=e.converter;if(!s)throw Error(`Property '${t}' doesn't have converter for type ${a.AsnPropTypes[e.type]} in schema '${r.name}'`);if(e.repeated){if(!Array.isArray(i))throw TypeError(`Parameter 'objProp' should be type of Array.`);let t=Array.from(i,e=>s.toASN(e));o=new(e.repeated===`sequence`?n.Sequence:n.Set)({value:t})}else o=s.toASN(i)}else if(e.repeated){if(!Array.isArray(i))throw TypeError(`Parameter 'objProp' should be type of Array.`);let t=Array.from(i,e=>this.toASN(e));o=new(e.repeated===`sequence`?n.Sequence:n.Set)({value:t})}else o=this.toASN(i);return o}}})),yr=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AsnArray=void 0,e.AsnArray=class extends Array{constructor(e=[]){if(typeof e==`number`)super(e);else{super();for(let t of e)this.push(t)}}}})),br=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AsnConvert=void 0;let t=(X(),P(Y)).__importStar(er()),n=ar(),r=_r(),i=vr();e.AsnConvert=class e{static serialize(e){return i.AsnSerializer.serialize(e)}static parse(e,t,n){return r.AsnParser.parse(e,t,n)}static toString(r,i){let a=(0,n.isBufferSource)(r)?(0,n.toArrayBuffer)(r):e.serialize(r),o=t.fromBER(a,i?.berOptions);if(o.offset===-1)throw Error(`Cannot decode ASN.1 data. ${o.result.error}`);return o.result.toString()}}})),Z=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AsnSerializer=e.AsnParser=e.AsnPropTypes=e.AsnTypeTypes=e.AsnSetType=e.AsnSequenceType=e.AsnChoiceType=e.AsnType=e.AsnProp=void 0;let t=(X(),P(Y));t.__exportStar(ur(),e),t.__exportStar(lr(),e);var n=mr();Object.defineProperty(e,"AsnProp",{enumerable:!0,get:function(){return n.AsnProp}}),Object.defineProperty(e,"AsnType",{enumerable:!0,get:function(){return n.AsnType}}),Object.defineProperty(e,"AsnChoiceType",{enumerable:!0,get:function(){return n.AsnChoiceType}}),Object.defineProperty(e,"AsnSequenceType",{enumerable:!0,get:function(){return n.AsnSequenceType}}),Object.defineProperty(e,"AsnSetType",{enumerable:!0,get:function(){return n.AsnSetType}});var r=or();Object.defineProperty(e,"AsnTypeTypes",{enumerable:!0,get:function(){return r.AsnTypeTypes}}),Object.defineProperty(e,"AsnPropTypes",{enumerable:!0,get:function(){return r.AsnPropTypes}});var i=_r();Object.defineProperty(e,"AsnParser",{enumerable:!0,get:function(){return i.AsnParser}});var a=vr();Object.defineProperty(e,"AsnSerializer",{enumerable:!0,get:function(){return a.AsnSerializer}}),t.__exportStar(gr(),e),t.__exportStar(yr(),e),t.__exportStar(br(),e)})),xr=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.binary=void 0,e.encode=n,e.decode=r,e.is=i;let t=ar();function n(e){let n=(0,t.toUint8Array)(e),r=``;for(let e of n)r+=String.fromCharCode(e);return r}function r(e){let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n)&255;return t}function i(e){return typeof e==`string`}e.binary={encode:n,decode:r,is:i}})),Sr=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.hex=e.formats=void 0,e.normalize=m,e.is=h,e.encode=g,e.decode=_,e.parse=v,e.format=y;let t=ar(),n=/^[0-9a-f]$/i,r=[` `,` `,`
86
+ `,`\r`,`:`,`-`,`.`];function i(e){return e.separators===`none`?[]:!e.separators||e.separators===`common`?r:e.separators}function a(e){if(!e)throw TypeError(`Hex separators must be non-empty strings`)}function o(e,t,n){for(let r of n)if(e.startsWith(r,t))return r}function s(e){let t=/[A-F]/.test(e),n=/[a-f]/.test(e);return t&&!n?`upper`:`lower`}function c(e){let t=/\r\n|\n/.exec(e);if(t)return t[0]===`\r
87
+ `?`\r
88
+ `:`
89
+ `}function l(e){return e.replace(/[^0-9a-f]/gi,``)}function u(e){let t=e.match(/[0-9A-Fa-f]+|[^0-9A-Fa-f]+/g)??[];if(t.length<3)return;let n=t.filter((e,t)=>t%2==0),r=t.filter((e,t)=>t%2==1),i=r[0];if(!i||r.some(e=>e!==i)||n.some(e=>e.length===0||e.length%2!=0))return;let a=n[0]?.length??0;if(a&&!n.slice(0,-1).some(e=>e.length!==a)&&!((n[n.length-1]?.length??0)>a))return{size:a/2,separator:i}}function d(e){let t=e.trim(),n=/^0x/i.test(t)?`0x`:``,r=n?t.slice(2):t,i=c(r),a=r.split(/\r\n|\n/).filter(e=>e.length>0),o=u(a[0]?.trim()??``),d={case:s(t),prefix:n};if(o&&(d.group=o),i&&a.length>1){let e=l(a[0]??``).length/2;e>0&&a.slice(0,-1).every(t=>l(t).length/2===e)&&(d.line={bytesPerLine:e,separator:i})}return d}function f(e,t){let r=t.allowPrefix??!0,s=[...i(t)].sort((e,t)=>t.length-e.length);for(let e of s)a(e);let c=e.trim();if(/^0x/i.test(c)){if(!r)throw TypeError(`Hexadecimal text must not include a 0x prefix`);c=c.slice(2)}let l=``,u=!1;for(let e=0;e<c.length;){let r=c[e]??``;if(n.test(r)){l+=r,u=!1,e+=1;continue}let i=o(c,e,s);if(!i)throw TypeError(`Input is not valid hexadecimal text`);if(t.strict&&(u||l.length===0))throw TypeError(`Hexadecimal text contains misplaced separators`);u=!0,e+=i.length}if(t.strict&&u&&l.length>0)throw TypeError(`Hexadecimal text must not end with a separator`);if(l.length%2!=0){if(!t.allowOddLength)throw TypeError(`Hexadecimal text must contain an even number of characters`);l=`0${l}`}return l.toLowerCase()}function p(e,t){if(!t)return e.join(``);if(!Number.isInteger(t.size)||t.size<1)throw RangeError(`Hex group size must be a positive integer`);let n=[];for(let r=0;r<e.length;r+=t.size)n.push(e.slice(r,r+t.size).join(``));return n.join(t.separator)}function m(e,t={}){return f(e,t)}function h(e,t={}){if(typeof e!=`string`)return!1;try{return m(e,t),!0}catch{return!1}}function g(e,n={}){let r=(0,t.toUint8Array)(e),i=n.case??`lower`,a=Array.from(r,e=>{let t=e.toString(16).padStart(2,`0`);return i===`upper`?t.toUpperCase():t}),o=``;if(n.line){let e=n.line.bytesPerLine;if(!Number.isInteger(e)||e<1)throw RangeError(`Hex bytesPerLine must be a positive integer`);let t=n.line.separator??`
90
+ `,r=[];for(let t=0;t<a.length;t+=e)r.push(p(a.slice(t,t+e),n.group));o=r.join(t)}else o=p(a,n.group);return`${n.prefix??``}${o}`}function _(e,t={}){let n=m(e,t),r=new Uint8Array(n.length/2);for(let e=0;e<n.length;e+=2)r[e/2]=Number.parseInt(n.slice(e,e+2),16);return r}function v(e,t={}){let n=m(e,t);return{bytes:_(n),format:d(e),normalized:n}}function y(e,t){return g(e,t)}e.formats={compact:Object.freeze({}),upper:Object.freeze({case:`upper`}),colon:Object.freeze({group:{size:1,separator:`:`}}),colonUpper:Object.freeze({case:`upper`,group:{size:1,separator:`:`}}),groupsOf4:Object.freeze({group:{size:4,separator:` `}}),prefixed:Object.freeze({prefix:`0x`})},e.hex={encode:g,decode:_,format:y,formats:e.formats,is:h,normalize:m,parse:v}})),Cr=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.utf8=void 0,e.encode=n,e.decode=r;let t=ar();function n(e){return new TextEncoder().encode(e)}function r(e){return new TextDecoder(`utf-8`,{fatal:!1}).decode((0,t.toUint8Array)(e))}e.utf8={encode:n,decode:r}})),wr=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.utf16=void 0,e.encode=n,e.decode=r;let t=ar();function n(e,t={}){let n=new ArrayBuffer(e.length*2),r=new DataView(n);for(let n=0;n<e.length;n++)r.setUint16(n*2,e.charCodeAt(n),t.littleEndian??!1);return new Uint8Array(n)}function r(e,n={}){let r=(0,t.toArrayBuffer)(e),i=new DataView(r),a=``;for(let e=0;e<r.byteLength;e+=2)a+=String.fromCharCode(i.getUint16(e,n.littleEndian??!1));return a}e.utf16={encode:n,decode:r}})),Tr=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.base64=void 0,e.normalize=a,e.pad=o,e.is=s,e.encode=c,e.decode=l;let t=ar(),n=xr(),r=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;function i(){return globalThis.Buffer}function a(e){return e.replace(/[\n\r\t ]/g,``)}function o(e){let t=e.length%4;return t?e+`=`.repeat(4-t):e}function s(e){if(typeof e!=`string`)return!1;let t=a(e);return t===``||r.test(t)}function c(e,r){let a=(0,t.toUint8Array)(e),o=i();return o?o.from(a).toString(`base64`):btoa((0,n.encode)(a))}function l(e,t){let r=a(e);if(!s(r))throw TypeError(`Input is not valid Base64 text`);let o=i();return o?new Uint8Array(o.from(r,`base64`)):(0,n.decode)(atob(r))}e.base64={encode:c,decode:l,is:s,normalize:a,pad:o}})),Er=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.base64url=void 0,e.normalize=r,e.is=i,e.encode=a,e.decode=o;let t=Tr(),n=/^[A-Za-z0-9_-]*$/;function r(e){return e.replace(/[\n\r\t ]/g,``)}function i(e){return typeof e==`string`&&n.test(r(e))}function a(e,n){return t.base64.encode(e).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/g,``)}function o(e,n){let a=r(e);if(!i(a))throw TypeError(`Input is not valid Base64Url text`);return t.base64.decode(t.base64.pad(a.replace(/-/g,`+`).replace(/_/g,`/`)))}e.base64url={encode:a,decode:o,is:i,normalize:r}})),Dr=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.base64url=e.base64=e.utf16=e.utf8=e.hex=e.binary=void 0;let t=(X(),P(Y));e.binary=t.__importStar(xr()),e.hex=t.__importStar(Sr()),e.utf8=t.__importStar(Cr()),e.utf16=t.__importStar(wr()),e.base64=t.__importStar(Tr()),e.base64url=t.__importStar(Er())})),Or=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.IpConverter=void 0;let t=Dr();e.IpConverter=class{static isIPv4(e){return/^(\d{1,3}\.){3}\d{1,3}$/.test(e)}static parseIPv4(e){let t=e.split(`.`);if(t.length!==4)throw Error(`Invalid IPv4 address`);return t.map(e=>{let t=parseInt(e,10);if(isNaN(t)||t<0||t>255)throw Error(`Invalid IPv4 address part`);return t})}static parseIPv6(e){let t=this.expandIPv6(e).split(`:`);if(t.length!==8)throw Error(`Invalid IPv6 address`);return t.reduce((e,t)=>{let n=parseInt(t,16);if(isNaN(n)||n<0||n>65535)throw Error(`Invalid IPv6 address part`);return e.push(n>>8&255),e.push(n&255),e},[])}static expandIPv6(e){if(!e.includes(`::`))return e;let t=e.split(`::`);if(t.length>2)throw Error(`Invalid IPv6 address`);let n=t[0]?t[0].split(`:`):[],r=t[1]?t[1].split(`:`):[],i=8-(n.length+r.length);if(i<0)throw Error(`Invalid IPv6 address`);return[...n,...Array(i).fill(`0`),...r].join(`:`)}static formatIPv6(e){let t=[];for(let n=0;n<16;n+=2)t.push((e[n]<<8|e[n+1]).toString(16));return this.compressIPv6(t.join(`:`))}static compressIPv6(e){let t=e.split(`:`),n=-1,r=0,i=-1,a=0;for(let e=0;e<t.length;e++)t[e]===`0`?(i===-1&&(i=e),a++):(a>r&&(n=i,r=a),i=-1,a=0);return a>r&&(n=i,r=a),r>1?`${t.slice(0,n).join(`:`)}::${t.slice(n+r).join(`:`)}`:e}static parseCIDR(e){let[t,n]=e.split(`/`),r=parseInt(n,10);if(this.isIPv4(t)){if(r<0||r>32)throw Error(`Invalid IPv4 prefix length`);return[this.parseIPv4(t),r]}else{if(r<0||r>128)throw Error(`Invalid IPv6 prefix length`);return[this.parseIPv6(t),r]}}static decodeIP(e){if(e.length===64&&parseInt(e,16)===0)return`::/0`;if(e.length!==16)return e;let t=parseInt(e.slice(8),16).toString(2).split(``).reduce((e,t)=>e+ +t,0),n=e.slice(0,8).replace(/(.{2})/g,e=>`${parseInt(e,16)}.`);return n=n.slice(0,-1),`${n}/${t}`}static toString(e){let n=new Uint8Array(e);if(n.length===4)return Array.from(n).join(`.`);if(n.length===16)return this.formatIPv6(n);if(n.length===8||n.length===32){let e=n.length/2,t=n.slice(0,e),r=n.slice(e);if(n.every(e=>e===0))return n.length===8?`0.0.0.0/0`:`::/0`;let i=r.reduce((e,t)=>e+(t.toString(2).match(/1/g)||[]).length,0);return n.length===8?`${Array.from(t).join(`.`)}/${i}`:`${this.formatIPv6(t)}/${i}`}return this.decodeIP(t.hex.encode(e))}static fromString(e){if(e.includes(`/`)){let[t,n]=this.parseCIDR(e),r=new Uint8Array(t.length),i=n;for(let e=0;e<r.length;e++)i>=8?(r[e]=255,i-=8):i>0&&(r[e]=255<<8-i,i=0);let a=new Uint8Array(t.length*2);return a.set(t,0),a.set(r,t.length),a.buffer}let t=this.isIPv4(e)?this.parseIPv4(e):this.parseIPv6(e);return new Uint8Array(t).buffer}}})),kr=M((e=>{var t,n,r;Object.defineProperty(e,"__esModule",{value:!0}),e.Name=e.RDNSequence=e.RelativeDistinguishedName=e.AttributeTypeAndValue=e.AttributeValue=e.DirectoryString=void 0;let i=(X(),P(Y)),a=Z(),o=Dr(),s=class{teletexString;printableString;universalString;utf8String;bmpString;constructor(e={}){Object.assign(this,e)}toString(){return this.bmpString||this.printableString||this.teletexString||this.universalString||this.utf8String||``}};e.DirectoryString=s,i.__decorate([(0,a.AsnProp)({type:a.AsnPropTypes.TeletexString})],s.prototype,`teletexString`,void 0),i.__decorate([(0,a.AsnProp)({type:a.AsnPropTypes.PrintableString})],s.prototype,`printableString`,void 0),i.__decorate([(0,a.AsnProp)({type:a.AsnPropTypes.UniversalString})],s.prototype,`universalString`,void 0),i.__decorate([(0,a.AsnProp)({type:a.AsnPropTypes.Utf8String})],s.prototype,`utf8String`,void 0),i.__decorate([(0,a.AsnProp)({type:a.AsnPropTypes.BmpString})],s.prototype,`bmpString`,void 0),e.DirectoryString=s=i.__decorate([(0,a.AsnType)({type:a.AsnTypeTypes.Choice})],s);let c=class extends s{ia5String;anyValue;constructor(e={}){super(e),Object.assign(this,e)}toString(){return this.ia5String||(this.anyValue?o.hex.encode(this.anyValue):super.toString())}};e.AttributeValue=c,i.__decorate([(0,a.AsnProp)({type:a.AsnPropTypes.IA5String})],c.prototype,`ia5String`,void 0),i.__decorate([(0,a.AsnProp)({type:a.AsnPropTypes.Any})],c.prototype,`anyValue`,void 0),e.AttributeValue=c=i.__decorate([(0,a.AsnType)({type:a.AsnTypeTypes.Choice})],c);var l=class{type=``;value=new c;constructor(e={}){Object.assign(this,e)}};e.AttributeTypeAndValue=l,i.__decorate([(0,a.AsnProp)({type:a.AsnPropTypes.ObjectIdentifier})],l.prototype,`type`,void 0),i.__decorate([(0,a.AsnProp)({type:c})],l.prototype,`value`,void 0);let u=t=class extends a.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,t.prototype)}};e.RelativeDistinguishedName=u,e.RelativeDistinguishedName=u=t=i.__decorate([(0,a.AsnType)({type:a.AsnTypeTypes.Set,itemType:l})],u);let d=n=class extends a.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype)}};e.RDNSequence=d,e.RDNSequence=d=n=i.__decorate([(0,a.AsnType)({type:a.AsnTypeTypes.Sequence,itemType:u})],d);let f=r=class extends d{constructor(e){super(e),Object.setPrototypeOf(this,r.prototype)}};e.Name=f,e.Name=f=r=i.__decorate([(0,a.AsnType)({type:a.AsnTypeTypes.Sequence})],f)})),Ar=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.GeneralName=e.EDIPartyName=e.OtherName=e.AsnIpConverter=void 0;let t=(X(),P(Y)),n=Z(),r=Or(),i=kr();e.AsnIpConverter={fromASN:e=>r.IpConverter.toString(n.AsnOctetStringConverter.fromASN(e)),toASN:e=>n.AsnOctetStringConverter.toASN(r.IpConverter.fromString(e))};var a=class{typeId=``;value=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.OtherName=a,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.ObjectIdentifier})],a.prototype,`typeId`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Any,context:0})],a.prototype,`value`,void 0);var o=class{nameAssigner;partyName=new i.DirectoryString;constructor(e={}){Object.assign(this,e)}};e.EDIPartyName=o,t.__decorate([(0,n.AsnProp)({type:i.DirectoryString,optional:!0,context:0,implicit:!0})],o.prototype,`nameAssigner`,void 0),t.__decorate([(0,n.AsnProp)({type:i.DirectoryString,context:1,implicit:!0})],o.prototype,`partyName`,void 0);let s=class{otherName;rfc822Name;dNSName;x400Address;directoryName;ediPartyName;uniformResourceIdentifier;iPAddress;registeredID;constructor(e={}){Object.assign(this,e)}};e.GeneralName=s,t.__decorate([(0,n.AsnProp)({type:a,context:0,implicit:!0})],s.prototype,`otherName`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.IA5String,context:1,implicit:!0})],s.prototype,`rfc822Name`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.IA5String,context:2,implicit:!0})],s.prototype,`dNSName`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Any,context:3,implicit:!0})],s.prototype,`x400Address`,void 0),t.__decorate([(0,n.AsnProp)({type:i.Name,context:4,implicit:!1})],s.prototype,`directoryName`,void 0),t.__decorate([(0,n.AsnProp)({type:o,context:5})],s.prototype,`ediPartyName`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.IA5String,context:6,implicit:!0})],s.prototype,`uniformResourceIdentifier`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.OctetString,context:7,implicit:!0,converter:e.AsnIpConverter})],s.prototype,`iPAddress`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.ObjectIdentifier,context:8,implicit:!0})],s.prototype,`registeredID`,void 0),e.GeneralName=s=t.__decorate([(0,n.AsnType)({type:n.AsnTypeTypes.Choice})],s)})),Q=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.id_ce=e.id_ad_caRepository=e.id_ad_timeStamping=e.id_ad_caIssuers=e.id_ad_ocsp=e.id_qt_unotice=e.id_qt_csp=e.id_ad=e.id_kp=e.id_qt=e.id_pe=e.id_pkix=void 0,e.id_pkix=`1.3.6.1.5.5.7`,e.id_pe=`${e.id_pkix}.1`,e.id_qt=`${e.id_pkix}.2`,e.id_kp=`${e.id_pkix}.3`,e.id_ad=`${e.id_pkix}.48`,e.id_qt_csp=`${e.id_qt}.1`,e.id_qt_unotice=`${e.id_qt}.2`,e.id_ad_ocsp=`${e.id_ad}.1`,e.id_ad_caIssuers=`${e.id_ad}.2`,e.id_ad_timeStamping=`${e.id_ad}.3`,e.id_ad_caRepository=`${e.id_ad}.5`,e.id_ce=`2.5.29`})),jr=M((e=>{var t;Object.defineProperty(e,"__esModule",{value:!0}),e.AuthorityInfoAccessSyntax=e.AccessDescription=e.id_pe_authorityInfoAccess=void 0;let n=(X(),P(Y)),r=Z(),i=Ar();e.id_pe_authorityInfoAccess=`${Q().id_pe}.1`;var a=class{accessMethod=``;accessLocation=new i.GeneralName;constructor(e={}){Object.assign(this,e)}};e.AccessDescription=a,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.ObjectIdentifier})],a.prototype,`accessMethod`,void 0),n.__decorate([(0,r.AsnProp)({type:i.GeneralName})],a.prototype,`accessLocation`,void 0);let o=t=class extends r.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,t.prototype)}};e.AuthorityInfoAccessSyntax=o,e.AuthorityInfoAccessSyntax=o=t=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Sequence,itemType:a})],o)})),Mr=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AuthorityKeyIdentifier=e.KeyIdentifier=e.id_ce_authorityKeyIdentifier=void 0;let t=(X(),P(Y)),n=Z(),r=Ar();e.id_ce_authorityKeyIdentifier=`${Q().id_ce}.35`;var i=class extends n.OctetString{};e.KeyIdentifier=i;var a=class{keyIdentifier;authorityCertIssuer;authorityCertSerialNumber;constructor(e={}){e&&Object.assign(this,e)}};e.AuthorityKeyIdentifier=a,t.__decorate([(0,n.AsnProp)({type:i,context:0,optional:!0,implicit:!0})],a.prototype,`keyIdentifier`,void 0),t.__decorate([(0,n.AsnProp)({type:r.GeneralName,context:1,optional:!0,implicit:!0,repeated:`sequence`})],a.prototype,`authorityCertIssuer`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer,context:2,optional:!0,implicit:!0,converter:n.AsnIntegerArrayBufferConverter})],a.prototype,`authorityCertSerialNumber`,void 0)})),Nr=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.BasicConstraints=e.id_ce_basicConstraints=void 0;let t=(X(),P(Y)),n=Z();e.id_ce_basicConstraints=`${Q().id_ce}.19`;var r=class{cA=!1;pathLenConstraint;constructor(e={}){Object.assign(this,e)}};e.BasicConstraints=r,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Boolean,defaultValue:!1})],r.prototype,`cA`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer,optional:!0})],r.prototype,`pathLenConstraint`,void 0)})),Pr=M((e=>{var t;Object.defineProperty(e,"__esModule",{value:!0}),e.GeneralNames=void 0;let n=(X(),P(Y)),r=Z(),i=Ar(),a=t=class extends r.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,t.prototype)}};e.GeneralNames=a,e.GeneralNames=a=t=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Sequence,itemType:i.GeneralName})],a)})),Fr=M((e=>{var t;Object.defineProperty(e,"__esModule",{value:!0}),e.CertificateIssuer=e.id_ce_certificateIssuer=void 0;let n=(X(),P(Y)),r=Z(),i=Pr();e.id_ce_certificateIssuer=`${Q().id_ce}.29`;let a=t=class extends i.GeneralNames{constructor(e){super(e),Object.setPrototypeOf(this,t.prototype)}};e.CertificateIssuer=a,e.CertificateIssuer=a=t=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Sequence})],a)})),Ir=M((e=>{var t;Object.defineProperty(e,"__esModule",{value:!0}),e.CertificatePolicies=e.PolicyInformation=e.PolicyQualifierInfo=e.Qualifier=e.UserNotice=e.NoticeReference=e.DisplayText=e.id_ce_certificatePolicies_anyPolicy=e.id_ce_certificatePolicies=void 0;let n=(X(),P(Y)),r=Z();e.id_ce_certificatePolicies=`${Q().id_ce}.32`,e.id_ce_certificatePolicies_anyPolicy=`${e.id_ce_certificatePolicies}.0`;let i=class{ia5String;visibleString;bmpString;utf8String;constructor(e={}){Object.assign(this,e)}toString(){return this.ia5String||this.visibleString||this.bmpString||this.utf8String||``}};e.DisplayText=i,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.IA5String})],i.prototype,`ia5String`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.VisibleString})],i.prototype,`visibleString`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.BmpString})],i.prototype,`bmpString`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Utf8String})],i.prototype,`utf8String`,void 0),e.DisplayText=i=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Choice})],i);var a=class{organization=new i;noticeNumbers=[];constructor(e={}){Object.assign(this,e)}};e.NoticeReference=a,n.__decorate([(0,r.AsnProp)({type:i})],a.prototype,`organization`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer,repeated:`sequence`})],a.prototype,`noticeNumbers`,void 0);var o=class{noticeRef;explicitText;constructor(e={}){Object.assign(this,e)}};e.UserNotice=o,n.__decorate([(0,r.AsnProp)({type:a,optional:!0})],o.prototype,`noticeRef`,void 0),n.__decorate([(0,r.AsnProp)({type:i,optional:!0})],o.prototype,`explicitText`,void 0);let s=class{cPSuri;userNotice;constructor(e={}){Object.assign(this,e)}};e.Qualifier=s,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.IA5String})],s.prototype,`cPSuri`,void 0),n.__decorate([(0,r.AsnProp)({type:o})],s.prototype,`userNotice`,void 0),e.Qualifier=s=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Choice})],s);var c=class{policyQualifierId=``;qualifier=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.PolicyQualifierInfo=c,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.ObjectIdentifier})],c.prototype,`policyQualifierId`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Any})],c.prototype,`qualifier`,void 0);var l=class{policyIdentifier=``;policyQualifiers;constructor(e={}){Object.assign(this,e)}};e.PolicyInformation=l,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.ObjectIdentifier})],l.prototype,`policyIdentifier`,void 0),n.__decorate([(0,r.AsnProp)({type:c,repeated:`sequence`,optional:!0})],l.prototype,`policyQualifiers`,void 0);let u=t=class extends r.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,t.prototype)}};e.CertificatePolicies=u,e.CertificatePolicies=u=t=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Sequence,itemType:l})],u)})),Lr=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.CRLNumber=e.id_ce_cRLNumber=void 0;let t=(X(),P(Y)),n=Z();e.id_ce_cRLNumber=`${Q().id_ce}.20`;let r=class{value;constructor(e=0){this.value=e}};e.CRLNumber=r,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer})],r.prototype,`value`,void 0),e.CRLNumber=r=t.__decorate([(0,n.AsnType)({type:n.AsnTypeTypes.Choice})],r)})),Rr=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.BaseCRLNumber=e.id_ce_deltaCRLIndicator=void 0;let t=(X(),P(Y)),n=Z(),r=Q(),i=Lr();e.id_ce_deltaCRLIndicator=`${r.id_ce}.27`;let a=class extends i.CRLNumber{};e.BaseCRLNumber=a,e.BaseCRLNumber=a=t.__decorate([(0,n.AsnType)({type:n.AsnTypeTypes.Choice})],a)})),zr=M((e=>{var t;Object.defineProperty(e,"__esModule",{value:!0}),e.CRLDistributionPoints=e.DistributionPoint=e.DistributionPointName=e.Reason=e.ReasonFlags=e.id_ce_cRLDistributionPoints=void 0;let n=(X(),P(Y)),r=Z(),i=kr(),a=Ar();e.id_ce_cRLDistributionPoints=`${Q().id_ce}.31`;var o;(function(e){e[e.unused=1]=`unused`,e[e.keyCompromise=2]=`keyCompromise`,e[e.cACompromise=4]=`cACompromise`,e[e.affiliationChanged=8]=`affiliationChanged`,e[e.superseded=16]=`superseded`,e[e.cessationOfOperation=32]=`cessationOfOperation`,e[e.certificateHold=64]=`certificateHold`,e[e.privilegeWithdrawn=128]=`privilegeWithdrawn`,e[e.aACompromise=256]=`aACompromise`})(o||(e.ReasonFlags=o={}));var s=class extends r.BitString{toJSON(){let e=[],t=this.toNumber();return t&o.aACompromise&&e.push(`aACompromise`),t&o.affiliationChanged&&e.push(`affiliationChanged`),t&o.cACompromise&&e.push(`cACompromise`),t&o.certificateHold&&e.push(`certificateHold`),t&o.cessationOfOperation&&e.push(`cessationOfOperation`),t&o.keyCompromise&&e.push(`keyCompromise`),t&o.privilegeWithdrawn&&e.push(`privilegeWithdrawn`),t&o.superseded&&e.push(`superseded`),t&o.unused&&e.push(`unused`),e}toString(){return`[${this.toJSON().join(`, `)}]`}};e.Reason=s;let c=class{fullName;nameRelativeToCRLIssuer;constructor(e={}){Object.assign(this,e)}};e.DistributionPointName=c,n.__decorate([(0,r.AsnProp)({type:a.GeneralName,context:0,repeated:`sequence`,implicit:!0})],c.prototype,`fullName`,void 0),n.__decorate([(0,r.AsnProp)({type:i.RelativeDistinguishedName,context:1,implicit:!0})],c.prototype,`nameRelativeToCRLIssuer`,void 0),e.DistributionPointName=c=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Choice})],c);var l=class{distributionPoint;reasons;cRLIssuer;constructor(e={}){Object.assign(this,e)}};e.DistributionPoint=l,n.__decorate([(0,r.AsnProp)({type:c,context:0,optional:!0})],l.prototype,`distributionPoint`,void 0),n.__decorate([(0,r.AsnProp)({type:s,context:1,optional:!0,implicit:!0})],l.prototype,`reasons`,void 0),n.__decorate([(0,r.AsnProp)({type:a.GeneralName,context:2,optional:!0,repeated:`sequence`,implicit:!0})],l.prototype,`cRLIssuer`,void 0);let u=t=class extends r.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,t.prototype)}};e.CRLDistributionPoints=u,e.CRLDistributionPoints=u=t=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Sequence,itemType:l})],u)})),Br=M((e=>{var t;Object.defineProperty(e,"__esModule",{value:!0}),e.FreshestCRL=e.id_ce_freshestCRL=void 0;let n=(X(),P(Y)),r=Z(),i=Q(),a=zr();e.id_ce_freshestCRL=`${i.id_ce}.46`;let o=t=class extends a.CRLDistributionPoints{constructor(e){super(e),Object.setPrototypeOf(this,t.prototype)}};e.FreshestCRL=o,e.FreshestCRL=o=t=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Sequence,itemType:a.DistributionPoint})],o)})),Vr=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.IssuingDistributionPoint=e.id_ce_issuingDistributionPoint=void 0;let t=(X(),P(Y)),n=Z(),r=Q(),i=zr();e.id_ce_issuingDistributionPoint=`${r.id_ce}.28`;var a=class e{static ONLY=!1;distributionPoint;onlyContainsUserCerts=e.ONLY;onlyContainsCACerts=e.ONLY;onlySomeReasons;indirectCRL=e.ONLY;onlyContainsAttributeCerts=e.ONLY;constructor(e={}){Object.assign(this,e)}};e.IssuingDistributionPoint=a,t.__decorate([(0,n.AsnProp)({type:i.DistributionPointName,context:0,optional:!0})],a.prototype,`distributionPoint`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Boolean,context:1,defaultValue:a.ONLY,implicit:!0})],a.prototype,`onlyContainsUserCerts`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Boolean,context:2,defaultValue:a.ONLY,implicit:!0})],a.prototype,`onlyContainsCACerts`,void 0),t.__decorate([(0,n.AsnProp)({type:i.Reason,context:3,optional:!0,implicit:!0})],a.prototype,`onlySomeReasons`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Boolean,context:4,defaultValue:a.ONLY,implicit:!0})],a.prototype,`indirectCRL`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Boolean,context:5,defaultValue:a.ONLY,implicit:!0})],a.prototype,`onlyContainsAttributeCerts`,void 0)})),Hr=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.CRLReason=e.CRLReasons=e.id_ce_cRLReasons=void 0;let t=(X(),P(Y)),n=Z();e.id_ce_cRLReasons=`${Q().id_ce}.21`;var r;(function(e){e[e.unspecified=0]=`unspecified`,e[e.keyCompromise=1]=`keyCompromise`,e[e.cACompromise=2]=`cACompromise`,e[e.affiliationChanged=3]=`affiliationChanged`,e[e.superseded=4]=`superseded`,e[e.cessationOfOperation=5]=`cessationOfOperation`,e[e.certificateHold=6]=`certificateHold`,e[e.removeFromCRL=8]=`removeFromCRL`,e[e.privilegeWithdrawn=9]=`privilegeWithdrawn`,e[e.aACompromise=10]=`aACompromise`})(r||(e.CRLReasons=r={}));let i=class{reason=r.unspecified;constructor(e=r.unspecified){this.reason=e}toJSON(){return r[this.reason]}toString(){return this.toJSON()}};e.CRLReason=i,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Enumerated})],i.prototype,`reason`,void 0),e.CRLReason=i=t.__decorate([(0,n.AsnType)({type:n.AsnTypeTypes.Choice})],i)})),Ur=M((e=>{var t;Object.defineProperty(e,"__esModule",{value:!0}),e.id_kp_OCSPSigning=e.id_kp_timeStamping=e.id_kp_emailProtection=e.id_kp_codeSigning=e.id_kp_clientAuth=e.id_kp_serverAuth=e.anyExtendedKeyUsage=e.ExtendedKeyUsage=e.id_ce_extKeyUsage=void 0;let n=(X(),P(Y)),r=Z(),i=Q();e.id_ce_extKeyUsage=`${i.id_ce}.37`;let a=t=class extends r.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,t.prototype)}};e.ExtendedKeyUsage=a,e.ExtendedKeyUsage=a=t=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Sequence,itemType:r.AsnPropTypes.ObjectIdentifier})],a),e.anyExtendedKeyUsage=`${e.id_ce_extKeyUsage}.0`,e.id_kp_serverAuth=`${i.id_kp}.1`,e.id_kp_clientAuth=`${i.id_kp}.2`,e.id_kp_codeSigning=`${i.id_kp}.3`,e.id_kp_emailProtection=`${i.id_kp}.4`,e.id_kp_timeStamping=`${i.id_kp}.8`,e.id_kp_OCSPSigning=`${i.id_kp}.9`})),Wr=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.InhibitAnyPolicy=e.id_ce_inhibitAnyPolicy=void 0;let t=(X(),P(Y)),n=Z();e.id_ce_inhibitAnyPolicy=`${Q().id_ce}.54`;let r=class{value;constructor(e=new ArrayBuffer(0)){this.value=e}};e.InhibitAnyPolicy=r,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer,converter:n.AsnIntegerArrayBufferConverter})],r.prototype,`value`,void 0),e.InhibitAnyPolicy=r=t.__decorate([(0,n.AsnType)({type:n.AsnTypeTypes.Choice})],r)})),Gr=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.InvalidityDate=e.id_ce_invalidityDate=void 0;let t=(X(),P(Y)),n=Z();e.id_ce_invalidityDate=`${Q().id_ce}.24`;let r=class{value=new Date;constructor(e){e&&(this.value=e)}};e.InvalidityDate=r,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.GeneralizedTime})],r.prototype,`value`,void 0),e.InvalidityDate=r=t.__decorate([(0,n.AsnType)({type:n.AsnTypeTypes.Choice})],r)})),Kr=M((e=>{var t;Object.defineProperty(e,"__esModule",{value:!0}),e.IssueAlternativeName=e.id_ce_issuerAltName=void 0;let n=(X(),P(Y)),r=Z(),i=Pr();e.id_ce_issuerAltName=`${Q().id_ce}.18`;let a=t=class extends i.GeneralNames{constructor(e){super(e),Object.setPrototypeOf(this,t.prototype)}};e.IssueAlternativeName=a,e.IssueAlternativeName=a=t=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Sequence})],a)})),qr=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.KeyUsage=e.KeyUsageFlags=e.id_ce_keyUsage=void 0;let t=Z();e.id_ce_keyUsage=`${Q().id_ce}.15`;var n;(function(e){e[e.digitalSignature=1]=`digitalSignature`,e[e.nonRepudiation=2]=`nonRepudiation`,e[e.keyEncipherment=4]=`keyEncipherment`,e[e.dataEncipherment=8]=`dataEncipherment`,e[e.keyAgreement=16]=`keyAgreement`,e[e.keyCertSign=32]=`keyCertSign`,e[e.cRLSign=64]=`cRLSign`,e[e.encipherOnly=128]=`encipherOnly`,e[e.decipherOnly=256]=`decipherOnly`})(n||(e.KeyUsageFlags=n={})),e.KeyUsage=class extends t.BitString{toJSON(){let e=this.toNumber(),t=[];return e&n.cRLSign&&t.push(`crlSign`),e&n.dataEncipherment&&t.push(`dataEncipherment`),e&n.decipherOnly&&t.push(`decipherOnly`),e&n.digitalSignature&&t.push(`digitalSignature`),e&n.encipherOnly&&t.push(`encipherOnly`),e&n.keyAgreement&&t.push(`keyAgreement`),e&n.keyCertSign&&t.push(`keyCertSign`),e&n.keyEncipherment&&t.push(`keyEncipherment`),e&n.nonRepudiation&&t.push(`nonRepudiation`),t}toString(){return`[${this.toJSON().join(`, `)}]`}}})),Jr=M((e=>{var t;Object.defineProperty(e,"__esModule",{value:!0}),e.NameConstraints=e.GeneralSubtrees=e.GeneralSubtree=e.id_ce_nameConstraints=void 0;let n=(X(),P(Y)),r=Z(),i=Ar();e.id_ce_nameConstraints=`${Q().id_ce}.30`;var a=class{base=new i.GeneralName;minimum=0;maximum;constructor(e={}){Object.assign(this,e)}};e.GeneralSubtree=a,n.__decorate([(0,r.AsnProp)({type:i.GeneralName})],a.prototype,`base`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer,context:0,defaultValue:0,implicit:!0})],a.prototype,`minimum`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer,context:1,optional:!0,implicit:!0})],a.prototype,`maximum`,void 0);let o=t=class extends r.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,t.prototype)}};e.GeneralSubtrees=o,e.GeneralSubtrees=o=t=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Sequence,itemType:a})],o);var s=class{permittedSubtrees;excludedSubtrees;constructor(e={}){Object.assign(this,e)}};e.NameConstraints=s,n.__decorate([(0,r.AsnProp)({type:o,context:0,optional:!0,implicit:!0})],s.prototype,`permittedSubtrees`,void 0),n.__decorate([(0,r.AsnProp)({type:o,context:1,optional:!0,implicit:!0})],s.prototype,`excludedSubtrees`,void 0)})),Yr=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.PolicyConstraints=e.id_ce_policyConstraints=void 0;let t=(X(),P(Y)),n=Z();e.id_ce_policyConstraints=`${Q().id_ce}.36`;var r=class{requireExplicitPolicy;inhibitPolicyMapping;constructor(e={}){Object.assign(this,e)}};e.PolicyConstraints=r,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer,context:0,implicit:!0,optional:!0,converter:n.AsnIntegerArrayBufferConverter})],r.prototype,`requireExplicitPolicy`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer,context:1,implicit:!0,optional:!0,converter:n.AsnIntegerArrayBufferConverter})],r.prototype,`inhibitPolicyMapping`,void 0)})),Xr=M((e=>{var t;Object.defineProperty(e,"__esModule",{value:!0}),e.PolicyMappings=e.PolicyMapping=e.id_ce_policyMappings=void 0;let n=(X(),P(Y)),r=Z();e.id_ce_policyMappings=`${Q().id_ce}.33`;var i=class{issuerDomainPolicy=``;subjectDomainPolicy=``;constructor(e={}){Object.assign(this,e)}};e.PolicyMapping=i,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.ObjectIdentifier})],i.prototype,`issuerDomainPolicy`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.ObjectIdentifier})],i.prototype,`subjectDomainPolicy`,void 0);let a=t=class extends r.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,t.prototype)}};e.PolicyMappings=a,e.PolicyMappings=a=t=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Sequence,itemType:i})],a)})),Zr=M((e=>{var t;Object.defineProperty(e,"__esModule",{value:!0}),e.SubjectAlternativeName=e.id_ce_subjectAltName=void 0;let n=(X(),P(Y)),r=Z(),i=Pr();e.id_ce_subjectAltName=`${Q().id_ce}.17`;let a=t=class extends i.GeneralNames{constructor(e){super(e),Object.setPrototypeOf(this,t.prototype)}};e.SubjectAlternativeName=a,e.SubjectAlternativeName=a=t=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Sequence})],a)})),Qr=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Attribute=void 0;let t=(X(),P(Y)),n=Z();var r=class{type=``;values=[];constructor(e={}){Object.assign(this,e)}};e.Attribute=r,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.ObjectIdentifier})],r.prototype,`type`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Any,repeated:`set`})],r.prototype,`values`,void 0)})),$r=M((e=>{var t;Object.defineProperty(e,"__esModule",{value:!0}),e.SubjectDirectoryAttributes=e.id_ce_subjectDirectoryAttributes=void 0;let n=(X(),P(Y)),r=Z(),i=Qr();e.id_ce_subjectDirectoryAttributes=`${Q().id_ce}.9`;let a=t=class extends r.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,t.prototype)}};e.SubjectDirectoryAttributes=a,e.SubjectDirectoryAttributes=a=t=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Sequence,itemType:i.Attribute})],a)})),ei=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SubjectKeyIdentifier=e.id_ce_subjectKeyIdentifier=void 0;let t=Q(),n=Mr();e.id_ce_subjectKeyIdentifier=`${t.id_ce}.14`,e.SubjectKeyIdentifier=class extends n.KeyIdentifier{}})),ti=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.PrivateKeyUsagePeriod=e.id_ce_privateKeyUsagePeriod=void 0;let t=(X(),P(Y)),n=Z();e.id_ce_privateKeyUsagePeriod=`${Q().id_ce}.16`;var r=class{notBefore;notAfter;constructor(e={}){Object.assign(this,e)}};e.PrivateKeyUsagePeriod=r,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.GeneralizedTime,context:0,implicit:!0,optional:!0})],r.prototype,`notBefore`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.GeneralizedTime,context:1,implicit:!0,optional:!0})],r.prototype,`notAfter`,void 0)})),ni=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.EntrustVersionInfo=e.EntrustInfo=e.EntrustInfoFlags=e.id_entrust_entrustVersInfo=void 0;let t=(X(),P(Y)),n=Z();e.id_entrust_entrustVersInfo=`1.2.840.113533.7.65.0`;var r;(function(e){e[e.keyUpdateAllowed=1]=`keyUpdateAllowed`,e[e.newExtensions=2]=`newExtensions`,e[e.pKIXCertificate=4]=`pKIXCertificate`})(r||(e.EntrustInfoFlags=r={}));var i=class extends n.BitString{toJSON(){let e=[],t=this.toNumber();return t&r.pKIXCertificate&&e.push(`pKIXCertificate`),t&r.newExtensions&&e.push(`newExtensions`),t&r.keyUpdateAllowed&&e.push(`keyUpdateAllowed`),e}toString(){return`[${this.toJSON().join(`, `)}]`}};e.EntrustInfo=i;var a=class{entrustVers=``;entrustInfoFlags=new i;constructor(e={}){Object.assign(this,e)}};e.EntrustVersionInfo=a,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.GeneralString})],a.prototype,`entrustVers`,void 0),t.__decorate([(0,n.AsnProp)({type:i})],a.prototype,`entrustInfoFlags`,void 0)})),ri=M((e=>{var t;Object.defineProperty(e,"__esModule",{value:!0}),e.SubjectInfoAccessSyntax=e.id_pe_subjectInfoAccess=void 0;let n=(X(),P(Y)),r=Z(),i=Q(),a=jr();e.id_pe_subjectInfoAccess=`${i.id_pe}.11`;let o=t=class extends r.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,t.prototype)}};e.SubjectInfoAccessSyntax=o,e.SubjectInfoAccessSyntax=o=t=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Sequence,itemType:a.AccessDescription})],o)})),ii=M((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=(X(),P(Y));t.__exportStar(jr(),e),t.__exportStar(Mr(),e),t.__exportStar(Nr(),e),t.__exportStar(Fr(),e),t.__exportStar(Ir(),e),t.__exportStar(Rr(),e),t.__exportStar(zr(),e),t.__exportStar(Br(),e),t.__exportStar(Vr(),e),t.__exportStar(Lr(),e),t.__exportStar(Hr(),e),t.__exportStar(Ur(),e),t.__exportStar(Wr(),e),t.__exportStar(Gr(),e),t.__exportStar(Kr(),e),t.__exportStar(qr(),e),t.__exportStar(Jr(),e),t.__exportStar(Yr(),e),t.__exportStar(Xr(),e),t.__exportStar(Zr(),e),t.__exportStar($r(),e),t.__exportStar(ei(),e),t.__exportStar(ti(),e),t.__exportStar(ni(),e),t.__exportStar(ri(),e)})),ai=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AlgorithmIdentifier=void 0;let t=(X(),P(Y)),n=Z(),r=ar();var i=class e{algorithm=``;parameters;constructor(e={}){Object.assign(this,e)}isEqual(t){return t instanceof e&&t.algorithm==this.algorithm&&(t.parameters&&this.parameters&&(0,r.equal)(t.parameters,this.parameters)||t.parameters===this.parameters)}};e.AlgorithmIdentifier=i,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.ObjectIdentifier})],i.prototype,`algorithm`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Any,optional:!0})],i.prototype,`parameters`,void 0)})),oi=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SubjectPublicKeyInfo=void 0;let t=(X(),P(Y)),n=Z(),r=ai();var i=class{algorithm=new r.AlgorithmIdentifier;subjectPublicKey=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.SubjectPublicKeyInfo=i,t.__decorate([(0,n.AsnProp)({type:r.AlgorithmIdentifier})],i.prototype,`algorithm`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.BitString})],i.prototype,`subjectPublicKey`,void 0)})),si=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Time=void 0;let t=(X(),P(Y)),n=Z(),r=class{utcTime;generalTime;constructor(e){if(e)if(typeof e==`string`||typeof e==`number`||e instanceof Date){let t=new Date(e);t.setMilliseconds(0),t.getUTCFullYear()>2049?this.generalTime=t:this.utcTime=t}else Object.assign(this,e)}getTime(){let e=this.utcTime||this.generalTime;if(!e)throw Error(`Cannot get time from CHOICE object`);return e}};e.Time=r,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.UTCTime})],r.prototype,`utcTime`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.GeneralizedTime})],r.prototype,`generalTime`,void 0),e.Time=r=t.__decorate([(0,n.AsnType)({type:n.AsnTypeTypes.Choice})],r)})),ci=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Validity=void 0;let t=(X(),P(Y)),n=Z(),r=si();var i=class{notBefore=new r.Time(new Date);notAfter=new r.Time(new Date);constructor(e){e&&(this.notBefore=new r.Time(e.notBefore),this.notAfter=new r.Time(e.notAfter))}};e.Validity=i,t.__decorate([(0,n.AsnProp)({type:r.Time})],i.prototype,`notBefore`,void 0),t.__decorate([(0,n.AsnProp)({type:r.Time})],i.prototype,`notAfter`,void 0)})),li=M((e=>{var t;Object.defineProperty(e,"__esModule",{value:!0}),e.Extensions=e.Extension=void 0;let n=(X(),P(Y)),r=Z();var i=class e{static CRITICAL=!1;extnID=``;critical=e.CRITICAL;extnValue=new r.OctetString;constructor(e={}){Object.assign(this,e)}};e.Extension=i,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.ObjectIdentifier})],i.prototype,`extnID`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Boolean,defaultValue:i.CRITICAL})],i.prototype,`critical`,void 0),n.__decorate([(0,r.AsnProp)({type:r.OctetString})],i.prototype,`extnValue`,void 0);let a=t=class extends r.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,t.prototype)}};e.Extensions=a,e.Extensions=a=t=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Sequence,itemType:i})],a)})),ui=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Version=void 0;var t;(function(e){e[e.v1=0]=`v1`,e[e.v2=1]=`v2`,e[e.v3=2]=`v3`})(t||(e.Version=t={}))})),di=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.TBSCertificate=void 0;let t=(X(),P(Y)),n=Z(),r=ai(),i=kr(),a=oi(),o=ci(),s=li(),c=ui();var l=class{version=c.Version.v1;serialNumber=new ArrayBuffer(0);signature=new r.AlgorithmIdentifier;issuer=new i.Name;validity=new o.Validity;subject=new i.Name;subjectPublicKeyInfo=new a.SubjectPublicKeyInfo;issuerUniqueID;subjectUniqueID;extensions;constructor(e={}){Object.assign(this,e)}};e.TBSCertificate=l,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer,context:0,defaultValue:c.Version.v1})],l.prototype,`version`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer,converter:n.AsnIntegerArrayBufferConverter})],l.prototype,`serialNumber`,void 0),t.__decorate([(0,n.AsnProp)({type:r.AlgorithmIdentifier})],l.prototype,`signature`,void 0),t.__decorate([(0,n.AsnProp)({type:i.Name})],l.prototype,`issuer`,void 0),t.__decorate([(0,n.AsnProp)({type:o.Validity})],l.prototype,`validity`,void 0),t.__decorate([(0,n.AsnProp)({type:i.Name})],l.prototype,`subject`,void 0),t.__decorate([(0,n.AsnProp)({type:a.SubjectPublicKeyInfo})],l.prototype,`subjectPublicKeyInfo`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.BitString,context:1,implicit:!0,optional:!0})],l.prototype,`issuerUniqueID`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.BitString,context:2,implicit:!0,optional:!0})],l.prototype,`subjectUniqueID`,void 0),t.__decorate([(0,n.AsnProp)({type:s.Extensions,context:3,optional:!0})],l.prototype,`extensions`,void 0)})),fi=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Certificate=void 0;let t=(X(),P(Y)),n=Z(),r=ai(),i=di();var a=class{tbsCertificate=new i.TBSCertificate;tbsCertificateRaw;signatureAlgorithm=new r.AlgorithmIdentifier;signatureValue=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.Certificate=a,t.__decorate([(0,n.AsnProp)({type:i.TBSCertificate,raw:!0})],a.prototype,`tbsCertificate`,void 0),t.__decorate([(0,n.AsnProp)({type:r.AlgorithmIdentifier})],a.prototype,`signatureAlgorithm`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.BitString})],a.prototype,`signatureValue`,void 0)})),pi=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.TBSCertList=e.RevokedCertificate=void 0;let t=(X(),P(Y)),n=Z(),r=ai(),i=kr(),a=si(),o=li();var s=class{userCertificate=new ArrayBuffer(0);revocationDate=new a.Time;crlEntryExtensions;constructor(e={}){Object.assign(this,e)}};e.RevokedCertificate=s,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer,converter:n.AsnIntegerArrayBufferConverter})],s.prototype,`userCertificate`,void 0),t.__decorate([(0,n.AsnProp)({type:a.Time})],s.prototype,`revocationDate`,void 0),t.__decorate([(0,n.AsnProp)({type:o.Extension,optional:!0,repeated:`sequence`})],s.prototype,`crlEntryExtensions`,void 0);var c=class{version;signature=new r.AlgorithmIdentifier;issuer=new i.Name;thisUpdate=new a.Time;nextUpdate;revokedCertificates;crlExtensions;constructor(e={}){Object.assign(this,e)}};e.TBSCertList=c,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer,optional:!0})],c.prototype,`version`,void 0),t.__decorate([(0,n.AsnProp)({type:r.AlgorithmIdentifier})],c.prototype,`signature`,void 0),t.__decorate([(0,n.AsnProp)({type:i.Name})],c.prototype,`issuer`,void 0),t.__decorate([(0,n.AsnProp)({type:a.Time})],c.prototype,`thisUpdate`,void 0),t.__decorate([(0,n.AsnProp)({type:a.Time,optional:!0})],c.prototype,`nextUpdate`,void 0),t.__decorate([(0,n.AsnProp)({type:s,repeated:`sequence`,optional:!0})],c.prototype,`revokedCertificates`,void 0),t.__decorate([(0,n.AsnProp)({type:o.Extension,optional:!0,context:0,repeated:`sequence`})],c.prototype,`crlExtensions`,void 0)})),mi=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.CertificateList=void 0;let t=(X(),P(Y)),n=Z(),r=ai(),i=pi();var a=class{tbsCertList=new i.TBSCertList;tbsCertListRaw;signatureAlgorithm=new r.AlgorithmIdentifier;signature=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.CertificateList=a,t.__decorate([(0,n.AsnProp)({type:i.TBSCertList,raw:!0})],a.prototype,`tbsCertList`,void 0),t.__decorate([(0,n.AsnProp)({type:r.AlgorithmIdentifier})],a.prototype,`signatureAlgorithm`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.BitString})],a.prototype,`signature`,void 0)})),$=M((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=(X(),P(Y));t.__exportStar(ii(),e),t.__exportStar(ai(),e),t.__exportStar(Qr(),e),t.__exportStar(fi(),e),t.__exportStar(mi(),e),t.__exportStar(li(),e),t.__exportStar(Ar(),e),t.__exportStar(Pr(),e),t.__exportStar(kr(),e),t.__exportStar(Q(),e),t.__exportStar(oi(),e),t.__exportStar(pi(),e),t.__exportStar(di(),e),t.__exportStar(si(),e),t.__exportStar(ui(),e),t.__exportStar(ci(),e)})),hi=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.IssuerAndSerialNumber=void 0;let t=(X(),P(Y)),n=Z(),r=$();var i=class{issuer=new r.Name;serialNumber=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.IssuerAndSerialNumber=i,t.__decorate([(0,n.AsnProp)({type:r.Name})],i.prototype,`issuer`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer,converter:n.AsnIntegerArrayBufferConverter})],i.prototype,`serialNumber`,void 0)})),gi=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SignerIdentifier=void 0;let t=(X(),P(Y)),n=Z(),r=$(),i=hi(),a=class{subjectKeyIdentifier;issuerAndSerialNumber;constructor(e={}){Object.assign(this,e)}};e.SignerIdentifier=a,t.__decorate([(0,n.AsnProp)({type:r.SubjectKeyIdentifier,context:0,implicit:!0})],a.prototype,`subjectKeyIdentifier`,void 0),t.__decorate([(0,n.AsnProp)({type:i.IssuerAndSerialNumber})],a.prototype,`issuerAndSerialNumber`,void 0),e.SignerIdentifier=a=t.__decorate([(0,n.AsnType)({type:n.AsnTypeTypes.Choice})],a)})),_i=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.KeyDerivationAlgorithmIdentifier=e.MessageAuthenticationCodeAlgorithm=e.ContentEncryptionAlgorithmIdentifier=e.KeyEncryptionAlgorithmIdentifier=e.SignatureAlgorithmIdentifier=e.DigestAlgorithmIdentifier=e.CMSVersion=void 0;let t=(X(),P(Y)),n=$(),r=Z();var i;(function(e){e[e.v0=0]=`v0`,e[e.v1=1]=`v1`,e[e.v2=2]=`v2`,e[e.v3=3]=`v3`,e[e.v4=4]=`v4`,e[e.v5=5]=`v5`})(i||(e.CMSVersion=i={}));let a=class extends n.AlgorithmIdentifier{};e.DigestAlgorithmIdentifier=a,e.DigestAlgorithmIdentifier=a=t.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Sequence})],a);let o=class extends n.AlgorithmIdentifier{};e.SignatureAlgorithmIdentifier=o,e.SignatureAlgorithmIdentifier=o=t.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Sequence})],o);let s=class extends n.AlgorithmIdentifier{};e.KeyEncryptionAlgorithmIdentifier=s,e.KeyEncryptionAlgorithmIdentifier=s=t.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Sequence})],s);let c=class extends n.AlgorithmIdentifier{};e.ContentEncryptionAlgorithmIdentifier=c,e.ContentEncryptionAlgorithmIdentifier=c=t.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Sequence})],c);let l=class extends n.AlgorithmIdentifier{};e.MessageAuthenticationCodeAlgorithm=l,e.MessageAuthenticationCodeAlgorithm=l=t.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Sequence})],l);let u=class extends n.AlgorithmIdentifier{};e.KeyDerivationAlgorithmIdentifier=u,e.KeyDerivationAlgorithmIdentifier=u=t.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Sequence})],u)})),vi=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Attribute=void 0;let t=(X(),P(Y)),n=Z();var r=class{attrType=``;attrValues=[];constructor(e={}){Object.assign(this,e)}};e.Attribute=r,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.ObjectIdentifier})],r.prototype,`attrType`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Any,repeated:`set`})],r.prototype,`attrValues`,void 0)})),yi=M((e=>{var t;Object.defineProperty(e,"__esModule",{value:!0}),e.SignerInfos=e.SignerInfo=void 0;let n=(X(),P(Y)),r=Z(),i=gi(),a=_i(),o=vi();var s=class{version=a.CMSVersion.v0;sid=new i.SignerIdentifier;digestAlgorithm=new a.DigestAlgorithmIdentifier;signedAttrs;signedAttrsRaw;signatureAlgorithm=new a.SignatureAlgorithmIdentifier;signature=new r.OctetString;unsignedAttrs;constructor(e={}){Object.assign(this,e)}};e.SignerInfo=s,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer})],s.prototype,`version`,void 0),n.__decorate([(0,r.AsnProp)({type:i.SignerIdentifier})],s.prototype,`sid`,void 0),n.__decorate([(0,r.AsnProp)({type:a.DigestAlgorithmIdentifier})],s.prototype,`digestAlgorithm`,void 0),n.__decorate([(0,r.AsnProp)({type:o.Attribute,repeated:`set`,context:0,implicit:!0,optional:!0,raw:!0})],s.prototype,`signedAttrs`,void 0),n.__decorate([(0,r.AsnProp)({type:a.SignatureAlgorithmIdentifier})],s.prototype,`signatureAlgorithm`,void 0),n.__decorate([(0,r.AsnProp)({type:r.OctetString})],s.prototype,`signature`,void 0),n.__decorate([(0,r.AsnProp)({type:o.Attribute,repeated:`set`,context:1,implicit:!0,optional:!0})],s.prototype,`unsignedAttrs`,void 0);let c=t=class extends r.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,t.prototype)}};e.SignerInfos=c,e.SignerInfos=c=t=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Set,itemType:s})],c)})),bi=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.CounterSignature=e.id_counterSignature=void 0;let t=(X(),P(Y)),n=Z(),r=yi();e.id_counterSignature=`1.2.840.113549.1.9.6`;let i=class extends r.SignerInfo{};e.CounterSignature=i,e.CounterSignature=i=t.__decorate([(0,n.AsnType)({type:n.AsnTypeTypes.Sequence})],i)})),xi=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.MessageDigest=e.id_messageDigest=void 0;let t=Z();e.id_messageDigest=`1.2.840.113549.1.9.4`,e.MessageDigest=class extends t.OctetString{}})),Si=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SigningTime=e.id_signingTime=void 0;let t=(X(),P(Y)),n=$(),r=Z();e.id_signingTime=`1.2.840.113549.1.9.5`;let i=class extends n.Time{};e.SigningTime=i,e.SigningTime=i=t.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Choice})],i)})),Ci=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.id_contentType=void 0;let t=(X(),P(Y));t.__exportStar(bi(),e),t.__exportStar(xi(),e),t.__exportStar(Si(),e),e.id_contentType=`1.2.840.113549.1.9.3`})),wi=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ACClearAttrs=void 0;let t=(X(),P(Y)),n=Z(),r=$();var i=class{acIssuer=new r.GeneralName;acSerial=0;attrs=[];constructor(e={}){Object.assign(this,e)}};e.ACClearAttrs=i,t.__decorate([(0,n.AsnProp)({type:r.GeneralName})],i.prototype,`acIssuer`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer})],i.prototype,`acSerial`,void 0),t.__decorate([(0,n.AsnProp)({type:r.Attribute,repeated:`sequence`})],i.prototype,`attrs`,void 0)})),Ti=M((e=>{var t;Object.defineProperty(e,"__esModule",{value:!0}),e.AttrSpec=void 0;let n=(X(),P(Y)),r=Z(),i=t=class extends r.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,t.prototype)}};e.AttrSpec=i,e.AttrSpec=i=t=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Sequence,itemType:r.AsnPropTypes.ObjectIdentifier})],i)})),Ei=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AAControls=void 0;let t=(X(),P(Y)),n=Z(),r=Ti();var i=class{pathLenConstraint;permittedAttrs;excludedAttrs;permitUnSpecified=!0;constructor(e={}){Object.assign(this,e)}};e.AAControls=i,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer,optional:!0})],i.prototype,`pathLenConstraint`,void 0),t.__decorate([(0,n.AsnProp)({type:r.AttrSpec,implicit:!0,context:0,optional:!0})],i.prototype,`permittedAttrs`,void 0),t.__decorate([(0,n.AsnProp)({type:r.AttrSpec,implicit:!0,context:1,optional:!0})],i.prototype,`excludedAttrs`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Boolean,defaultValue:!0})],i.prototype,`permitUnSpecified`,void 0)})),Di=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.IssuerSerial=void 0;let t=(X(),P(Y)),n=Z(),r=$();var i=class{issuer=new r.GeneralNames;serial=new ArrayBuffer(0);issuerUID=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.IssuerSerial=i,t.__decorate([(0,n.AsnProp)({type:r.GeneralNames})],i.prototype,`issuer`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer,converter:n.AsnIntegerArrayBufferConverter})],i.prototype,`serial`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.BitString,optional:!0})],i.prototype,`issuerUID`,void 0)})),Oi=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ObjectDigestInfo=e.DigestedObjectType=void 0;let t=(X(),P(Y)),n=Z(),r=$();var i;(function(e){e[e.publicKey=0]=`publicKey`,e[e.publicKeyCert=1]=`publicKeyCert`,e[e.otherObjectTypes=2]=`otherObjectTypes`})(i||(e.DigestedObjectType=i={}));var a=class{digestedObjectType=i.publicKey;otherObjectTypeID;digestAlgorithm=new r.AlgorithmIdentifier;objectDigest=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.ObjectDigestInfo=a,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Enumerated})],a.prototype,`digestedObjectType`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.ObjectIdentifier,optional:!0})],a.prototype,`otherObjectTypeID`,void 0),t.__decorate([(0,n.AsnProp)({type:r.AlgorithmIdentifier})],a.prototype,`digestAlgorithm`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.BitString})],a.prototype,`objectDigest`,void 0)})),ki=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.V2Form=void 0;let t=(X(),P(Y)),n=Z(),r=$(),i=Di(),a=Oi();var o=class{issuerName;baseCertificateID;objectDigestInfo;constructor(e={}){Object.assign(this,e)}};e.V2Form=o,t.__decorate([(0,n.AsnProp)({type:r.GeneralNames,optional:!0})],o.prototype,`issuerName`,void 0),t.__decorate([(0,n.AsnProp)({type:i.IssuerSerial,context:0,implicit:!0,optional:!0})],o.prototype,`baseCertificateID`,void 0),t.__decorate([(0,n.AsnProp)({type:a.ObjectDigestInfo,context:1,implicit:!0,optional:!0})],o.prototype,`objectDigestInfo`,void 0)})),Ai=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AttCertIssuer=void 0;let t=(X(),P(Y)),n=Z(),r=$(),i=ki(),a=class{v1Form;v2Form;constructor(e={}){Object.assign(this,e)}};e.AttCertIssuer=a,t.__decorate([(0,n.AsnProp)({type:r.GeneralName,repeated:`sequence`})],a.prototype,`v1Form`,void 0),t.__decorate([(0,n.AsnProp)({type:i.V2Form,context:0,implicit:!0})],a.prototype,`v2Form`,void 0),e.AttCertIssuer=a=t.__decorate([(0,n.AsnType)({type:n.AsnTypeTypes.Choice})],a)})),ji=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AttCertValidityPeriod=void 0;let t=(X(),P(Y)),n=Z();var r=class{notBeforeTime=new Date;notAfterTime=new Date;constructor(e={}){Object.assign(this,e)}};e.AttCertValidityPeriod=r,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.GeneralizedTime})],r.prototype,`notBeforeTime`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.GeneralizedTime})],r.prototype,`notAfterTime`,void 0)})),Mi=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Holder=void 0;let t=(X(),P(Y)),n=Z(),r=$(),i=Di(),a=Oi();var o=class{baseCertificateID;entityName;objectDigestInfo;constructor(e={}){Object.assign(this,e)}};e.Holder=o,t.__decorate([(0,n.AsnProp)({type:i.IssuerSerial,implicit:!0,context:0,optional:!0})],o.prototype,`baseCertificateID`,void 0),t.__decorate([(0,n.AsnProp)({type:r.GeneralNames,implicit:!0,context:1,optional:!0})],o.prototype,`entityName`,void 0),t.__decorate([(0,n.AsnProp)({type:a.ObjectDigestInfo,implicit:!0,context:2,optional:!0})],o.prototype,`objectDigestInfo`,void 0)})),Ni=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AttributeCertificateInfo=e.AttCertVersion=void 0;let t=(X(),P(Y)),n=Z(),r=$(),i=Mi(),a=Ai(),o=ji();var s;(function(e){e[e.v2=1]=`v2`})(s||(e.AttCertVersion=s={}));var c=class{version=s.v2;holder=new i.Holder;issuer=new a.AttCertIssuer;signature=new r.AlgorithmIdentifier;serialNumber=new ArrayBuffer(0);attrCertValidityPeriod=new o.AttCertValidityPeriod;attributes=[];issuerUniqueID;extensions;constructor(e={}){Object.assign(this,e)}};e.AttributeCertificateInfo=c,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer})],c.prototype,`version`,void 0),t.__decorate([(0,n.AsnProp)({type:i.Holder})],c.prototype,`holder`,void 0),t.__decorate([(0,n.AsnProp)({type:a.AttCertIssuer})],c.prototype,`issuer`,void 0),t.__decorate([(0,n.AsnProp)({type:r.AlgorithmIdentifier})],c.prototype,`signature`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer,converter:n.AsnIntegerArrayBufferConverter})],c.prototype,`serialNumber`,void 0),t.__decorate([(0,n.AsnProp)({type:o.AttCertValidityPeriod})],c.prototype,`attrCertValidityPeriod`,void 0),t.__decorate([(0,n.AsnProp)({type:r.Attribute,repeated:`sequence`})],c.prototype,`attributes`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.BitString,optional:!0})],c.prototype,`issuerUniqueID`,void 0),t.__decorate([(0,n.AsnProp)({type:r.Extensions,optional:!0})],c.prototype,`extensions`,void 0)})),Pi=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AttributeCertificate=void 0;let t=(X(),P(Y)),n=Z(),r=$(),i=Ni();var a=class{acinfo=new i.AttributeCertificateInfo;signatureAlgorithm=new r.AlgorithmIdentifier;signatureValue=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.AttributeCertificate=a,t.__decorate([(0,n.AsnProp)({type:i.AttributeCertificateInfo})],a.prototype,`acinfo`,void 0),t.__decorate([(0,n.AsnProp)({type:r.AlgorithmIdentifier})],a.prototype,`signatureAlgorithm`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.BitString})],a.prototype,`signatureValue`,void 0)})),Fi=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ClassList=e.ClassListFlags=void 0;let t=Z();var n;(function(e){e[e.unmarked=1]=`unmarked`,e[e.unclassified=2]=`unclassified`,e[e.restricted=4]=`restricted`,e[e.confidential=8]=`confidential`,e[e.secret=16]=`secret`,e[e.topSecret=32]=`topSecret`})(n||(e.ClassListFlags=n={})),e.ClassList=class extends t.BitString{}})),Ii=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SecurityCategory=void 0;let t=(X(),P(Y)),n=Z();var r=class{type=``;value=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.SecurityCategory=r,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.ObjectIdentifier,implicit:!0,context:0})],r.prototype,`type`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Any,implicit:!0,context:1})],r.prototype,`value`,void 0)})),Li=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Clearance=void 0;let t=(X(),P(Y)),n=Z(),r=Fi(),i=Ii();var a=class{policyId=``;classList=new r.ClassList(r.ClassListFlags.unclassified);securityCategories;constructor(e={}){Object.assign(this,e)}};e.Clearance=a,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.ObjectIdentifier})],a.prototype,`policyId`,void 0),t.__decorate([(0,n.AsnProp)({type:r.ClassList,defaultValue:new r.ClassList(r.ClassListFlags.unclassified)})],a.prototype,`classList`,void 0),t.__decorate([(0,n.AsnProp)({type:i.SecurityCategory,repeated:`set`})],a.prototype,`securityCategories`,void 0)})),Ri=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.IetfAttrSyntax=e.IetfAttrSyntaxValueChoices=void 0;let t=(X(),P(Y)),n=Z(),r=$();var i=class{cotets;oid;string;constructor(e={}){Object.assign(this,e)}};e.IetfAttrSyntaxValueChoices=i,t.__decorate([(0,n.AsnProp)({type:n.OctetString})],i.prototype,`cotets`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.ObjectIdentifier})],i.prototype,`oid`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Utf8String})],i.prototype,`string`,void 0);var a=class{policyAuthority;values=[];constructor(e={}){Object.assign(this,e)}};e.IetfAttrSyntax=a,t.__decorate([(0,n.AsnProp)({type:r.GeneralNames,implicit:!0,context:0,optional:!0})],a.prototype,`policyAuthority`,void 0),t.__decorate([(0,n.AsnProp)({type:i,repeated:`sequence`})],a.prototype,`values`,void 0)})),zi=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.id_at_clearance=e.id_at_role=e.id_at=e.id_aca_encAttrs=e.id_aca_group=e.id_aca_chargingIdentity=e.id_aca_accessIdentity=e.id_aca_authenticationInfo=e.id_aca=e.id_ce_targetInformation=e.id_pe_ac_proxying=e.id_pe_aaControls=e.id_pe_ac_auditIdentity=void 0;let t=$();e.id_pe_ac_auditIdentity=`${t.id_pe}.4`,e.id_pe_aaControls=`${t.id_pe}.6`,e.id_pe_ac_proxying=`${t.id_pe}.10`,e.id_ce_targetInformation=`${t.id_ce}.55`,e.id_aca=`${t.id_pkix}.10`,e.id_aca_authenticationInfo=`${e.id_aca}.1`,e.id_aca_accessIdentity=`${e.id_aca}.2`,e.id_aca_chargingIdentity=`${e.id_aca}.3`,e.id_aca_group=`${e.id_aca}.4`,e.id_aca_encAttrs=`${e.id_aca}.6`,e.id_at=`2.5.4`,e.id_at_role=`${e.id_at}.72`,e.id_at_clearance=`2.5.1.5.55`})),Bi=M((e=>{var t;Object.defineProperty(e,"__esModule",{value:!0}),e.Targets=e.Target=e.TargetCert=void 0;let n=(X(),P(Y)),r=Z(),i=$(),a=Di(),o=Oi();var s=class{targetCertificate=new a.IssuerSerial;targetName;certDigestInfo;constructor(e={}){Object.assign(this,e)}};e.TargetCert=s,n.__decorate([(0,r.AsnProp)({type:a.IssuerSerial})],s.prototype,`targetCertificate`,void 0),n.__decorate([(0,r.AsnProp)({type:i.GeneralName,optional:!0})],s.prototype,`targetName`,void 0),n.__decorate([(0,r.AsnProp)({type:o.ObjectDigestInfo,optional:!0})],s.prototype,`certDigestInfo`,void 0);let c=class{targetName;targetGroup;targetCert;constructor(e={}){Object.assign(this,e)}};e.Target=c,n.__decorate([(0,r.AsnProp)({type:i.GeneralName,context:0,implicit:!0})],c.prototype,`targetName`,void 0),n.__decorate([(0,r.AsnProp)({type:i.GeneralName,context:1,implicit:!0})],c.prototype,`targetGroup`,void 0),n.__decorate([(0,r.AsnProp)({type:s,context:2,implicit:!0})],c.prototype,`targetCert`,void 0),e.Target=c=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Choice})],c);let l=t=class extends r.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,t.prototype)}};e.Targets=l,e.Targets=l=t=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Sequence,itemType:c})],l)})),Vi=M((e=>{var t;Object.defineProperty(e,"__esModule",{value:!0}),e.ProxyInfo=void 0;let n=(X(),P(Y)),r=Z(),i=Bi(),a=t=class extends r.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,t.prototype)}};e.ProxyInfo=a,e.ProxyInfo=a=t=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Sequence,itemType:i.Targets})],a)})),Hi=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.RoleSyntax=void 0;let t=(X(),P(Y)),n=Z(),r=$();var i=class{roleAuthority;roleName;constructor(e={}){Object.assign(this,e)}};e.RoleSyntax=i,t.__decorate([(0,n.AsnProp)({type:r.GeneralNames,implicit:!0,context:0,optional:!0})],i.prototype,`roleAuthority`,void 0),t.__decorate([(0,n.AsnProp)({type:r.GeneralName,implicit:!0,context:1})],i.prototype,`roleName`,void 0)})),Ui=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SvceAuthInfo=void 0;let t=(X(),P(Y)),n=Z(),r=$();var i=class{service=new r.GeneralName;ident=new r.GeneralName;authInfo;constructor(e={}){Object.assign(this,e)}};e.SvceAuthInfo=i,t.__decorate([(0,n.AsnProp)({type:r.GeneralName})],i.prototype,`service`,void 0),t.__decorate([(0,n.AsnProp)({type:r.GeneralName})],i.prototype,`ident`,void 0),t.__decorate([(0,n.AsnProp)({type:n.OctetString,optional:!0})],i.prototype,`authInfo`,void 0)})),Wi=M((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=(X(),P(Y));t.__exportStar(wi(),e),t.__exportStar(Ei(),e),t.__exportStar(Ai(),e),t.__exportStar(ji(),e),t.__exportStar(Ti(),e),t.__exportStar(Pi(),e),t.__exportStar(Ni(),e),t.__exportStar(Fi(),e),t.__exportStar(Li(),e),t.__exportStar(Mi(),e),t.__exportStar(Ri(),e),t.__exportStar(Di(),e),t.__exportStar(Oi(),e),t.__exportStar(zi(),e),t.__exportStar(Vi(),e),t.__exportStar(Hi(),e),t.__exportStar(Ii(),e),t.__exportStar(Ui(),e),t.__exportStar(Bi(),e),t.__exportStar(ki(),e)})),Gi=M((e=>{var t;Object.defineProperty(e,"__esModule",{value:!0}),e.CertificateSet=e.CertificateChoices=e.OtherCertificateFormat=void 0;let n=(X(),P(Y)),r=Z(),i=$(),a=Wi();var o=class{otherCertFormat=``;otherCert=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.OtherCertificateFormat=o,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.ObjectIdentifier})],o.prototype,`otherCertFormat`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Any})],o.prototype,`otherCert`,void 0);let s=class{certificate;v2AttrCert;other;constructor(e={}){Object.assign(this,e)}};e.CertificateChoices=s,n.__decorate([(0,r.AsnProp)({type:i.Certificate})],s.prototype,`certificate`,void 0),n.__decorate([(0,r.AsnProp)({type:a.AttributeCertificate,context:2,implicit:!0})],s.prototype,`v2AttrCert`,void 0),n.__decorate([(0,r.AsnProp)({type:o,context:3,implicit:!0})],s.prototype,`other`,void 0),e.CertificateChoices=s=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Choice})],s);let c=t=class extends r.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,t.prototype)}};e.CertificateSet=c,e.CertificateSet=c=t=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Set,itemType:s})],c)})),Ki=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ContentInfo=void 0;let t=(X(),P(Y)),n=Z();var r=class{contentType=``;content=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.ContentInfo=r,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.ObjectIdentifier})],r.prototype,`contentType`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Any,context:0})],r.prototype,`content`,void 0)})),qi=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.EncapsulatedContentInfo=e.EncapsulatedContent=void 0;let t=(X(),P(Y)),n=Z(),r=class{single;any;constructor(e={}){Object.assign(this,e)}};e.EncapsulatedContent=r,t.__decorate([(0,n.AsnProp)({type:n.OctetString})],r.prototype,`single`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Any})],r.prototype,`any`,void 0),e.EncapsulatedContent=r=t.__decorate([(0,n.AsnType)({type:n.AsnTypeTypes.Choice})],r);var i=class{eContentType=``;eContent;constructor(e={}){Object.assign(this,e)}};e.EncapsulatedContentInfo=i,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.ObjectIdentifier})],i.prototype,`eContentType`,void 0),t.__decorate([(0,n.AsnProp)({type:r,context:0,optional:!0})],i.prototype,`eContent`,void 0)})),Ji=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.EncryptedContentInfo=e.EncryptedContent=void 0;let t=(X(),P(Y)),n=Z(),r=_i(),i=class{value;constructedValue;constructor(e={}){Object.assign(this,e)}};e.EncryptedContent=i,t.__decorate([(0,n.AsnProp)({type:n.OctetString,context:0,implicit:!0,optional:!0})],i.prototype,`value`,void 0),t.__decorate([(0,n.AsnProp)({type:n.OctetString,converter:n.AsnConstructedOctetStringConverter,context:0,implicit:!0,optional:!0,repeated:`sequence`})],i.prototype,`constructedValue`,void 0),e.EncryptedContent=i=t.__decorate([(0,n.AsnType)({type:n.AsnTypeTypes.Choice})],i);var a=class{contentType=``;contentEncryptionAlgorithm=new r.ContentEncryptionAlgorithmIdentifier;encryptedContent;constructor(e={}){Object.assign(this,e)}};e.EncryptedContentInfo=a,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.ObjectIdentifier})],a.prototype,`contentType`,void 0),t.__decorate([(0,n.AsnProp)({type:r.ContentEncryptionAlgorithmIdentifier})],a.prototype,`contentEncryptionAlgorithm`,void 0),t.__decorate([(0,n.AsnProp)({type:i,optional:!0})],a.prototype,`encryptedContent`,void 0)})),Yi=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.OtherKeyAttribute=void 0;let t=(X(),P(Y)),n=Z();var r=class{keyAttrId=``;keyAttr;constructor(e={}){Object.assign(this,e)}};e.OtherKeyAttribute=r,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.ObjectIdentifier})],r.prototype,`keyAttrId`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Any,optional:!0})],r.prototype,`keyAttr`,void 0)})),Xi=M((e=>{var t;Object.defineProperty(e,"__esModule",{value:!0}),e.KeyAgreeRecipientInfo=e.OriginatorIdentifierOrKey=e.OriginatorPublicKey=e.RecipientEncryptedKeys=e.RecipientEncryptedKey=e.KeyAgreeRecipientIdentifier=e.RecipientKeyIdentifier=void 0;let n=(X(),P(Y)),r=Z(),i=$(),a=_i(),o=hi(),s=Yi();var c=class{subjectKeyIdentifier=new i.SubjectKeyIdentifier;date;other;constructor(e={}){Object.assign(this,e)}};e.RecipientKeyIdentifier=c,n.__decorate([(0,r.AsnProp)({type:i.SubjectKeyIdentifier})],c.prototype,`subjectKeyIdentifier`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.GeneralizedTime,optional:!0})],c.prototype,`date`,void 0),n.__decorate([(0,r.AsnProp)({type:s.OtherKeyAttribute,optional:!0})],c.prototype,`other`,void 0);let l=class{rKeyId;issuerAndSerialNumber;constructor(e={}){Object.assign(this,e)}};e.KeyAgreeRecipientIdentifier=l,n.__decorate([(0,r.AsnProp)({type:c,context:0,implicit:!0,optional:!0})],l.prototype,`rKeyId`,void 0),n.__decorate([(0,r.AsnProp)({type:o.IssuerAndSerialNumber,optional:!0})],l.prototype,`issuerAndSerialNumber`,void 0),e.KeyAgreeRecipientIdentifier=l=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Choice})],l);var u=class{rid=new l;encryptedKey=new r.OctetString;constructor(e={}){Object.assign(this,e)}};e.RecipientEncryptedKey=u,n.__decorate([(0,r.AsnProp)({type:l})],u.prototype,`rid`,void 0),n.__decorate([(0,r.AsnProp)({type:r.OctetString})],u.prototype,`encryptedKey`,void 0);let d=t=class extends r.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,t.prototype)}};e.RecipientEncryptedKeys=d,e.RecipientEncryptedKeys=d=t=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Sequence,itemType:u})],d);var f=class{algorithm=new i.AlgorithmIdentifier;publicKey=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.OriginatorPublicKey=f,n.__decorate([(0,r.AsnProp)({type:i.AlgorithmIdentifier})],f.prototype,`algorithm`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.BitString})],f.prototype,`publicKey`,void 0);let p=class{subjectKeyIdentifier;originatorKey;issuerAndSerialNumber;constructor(e={}){Object.assign(this,e)}};e.OriginatorIdentifierOrKey=p,n.__decorate([(0,r.AsnProp)({type:i.SubjectKeyIdentifier,context:0,implicit:!0,optional:!0})],p.prototype,`subjectKeyIdentifier`,void 0),n.__decorate([(0,r.AsnProp)({type:f,context:1,implicit:!0,optional:!0})],p.prototype,`originatorKey`,void 0),n.__decorate([(0,r.AsnProp)({type:o.IssuerAndSerialNumber,optional:!0})],p.prototype,`issuerAndSerialNumber`,void 0),e.OriginatorIdentifierOrKey=p=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Choice})],p);var m=class{version=a.CMSVersion.v3;originator=new p;ukm;keyEncryptionAlgorithm=new a.KeyEncryptionAlgorithmIdentifier;recipientEncryptedKeys=new d;constructor(e={}){Object.assign(this,e)}};e.KeyAgreeRecipientInfo=m,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer})],m.prototype,`version`,void 0),n.__decorate([(0,r.AsnProp)({type:p,context:0})],m.prototype,`originator`,void 0),n.__decorate([(0,r.AsnProp)({type:r.OctetString,context:1,optional:!0})],m.prototype,`ukm`,void 0),n.__decorate([(0,r.AsnProp)({type:a.KeyEncryptionAlgorithmIdentifier})],m.prototype,`keyEncryptionAlgorithm`,void 0),n.__decorate([(0,r.AsnProp)({type:d})],m.prototype,`recipientEncryptedKeys`,void 0)})),Zi=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.KeyTransRecipientInfo=e.RecipientIdentifier=void 0;let t=(X(),P(Y)),n=Z(),r=$(),i=_i(),a=hi(),o=class{subjectKeyIdentifier;issuerAndSerialNumber;constructor(e={}){Object.assign(this,e)}};e.RecipientIdentifier=o,t.__decorate([(0,n.AsnProp)({type:r.SubjectKeyIdentifier,context:0,implicit:!0})],o.prototype,`subjectKeyIdentifier`,void 0),t.__decorate([(0,n.AsnProp)({type:a.IssuerAndSerialNumber})],o.prototype,`issuerAndSerialNumber`,void 0),e.RecipientIdentifier=o=t.__decorate([(0,n.AsnType)({type:n.AsnTypeTypes.Choice})],o);var s=class{version=i.CMSVersion.v0;rid=new o;keyEncryptionAlgorithm=new i.KeyEncryptionAlgorithmIdentifier;encryptedKey=new n.OctetString;constructor(e={}){Object.assign(this,e)}};e.KeyTransRecipientInfo=s,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer})],s.prototype,`version`,void 0),t.__decorate([(0,n.AsnProp)({type:o})],s.prototype,`rid`,void 0),t.__decorate([(0,n.AsnProp)({type:i.KeyEncryptionAlgorithmIdentifier})],s.prototype,`keyEncryptionAlgorithm`,void 0),t.__decorate([(0,n.AsnProp)({type:n.OctetString})],s.prototype,`encryptedKey`,void 0)})),Qi=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.KEKRecipientInfo=e.KEKIdentifier=void 0;let t=(X(),P(Y)),n=Z(),r=Yi(),i=_i();var a=class{keyIdentifier=new n.OctetString;date;other;constructor(e={}){Object.assign(this,e)}};e.KEKIdentifier=a,t.__decorate([(0,n.AsnProp)({type:n.OctetString})],a.prototype,`keyIdentifier`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.GeneralizedTime,optional:!0})],a.prototype,`date`,void 0),t.__decorate([(0,n.AsnProp)({type:r.OtherKeyAttribute,optional:!0})],a.prototype,`other`,void 0);var o=class{version=i.CMSVersion.v4;kekid=new a;keyEncryptionAlgorithm=new i.KeyEncryptionAlgorithmIdentifier;encryptedKey=new n.OctetString;constructor(e={}){Object.assign(this,e)}};e.KEKRecipientInfo=o,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer})],o.prototype,`version`,void 0),t.__decorate([(0,n.AsnProp)({type:a})],o.prototype,`kekid`,void 0),t.__decorate([(0,n.AsnProp)({type:i.KeyEncryptionAlgorithmIdentifier})],o.prototype,`keyEncryptionAlgorithm`,void 0),t.__decorate([(0,n.AsnProp)({type:n.OctetString})],o.prototype,`encryptedKey`,void 0)})),$i=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.PasswordRecipientInfo=void 0;let t=(X(),P(Y)),n=Z(),r=_i();var i=class{version=r.CMSVersion.v0;keyDerivationAlgorithm;keyEncryptionAlgorithm=new r.KeyEncryptionAlgorithmIdentifier;encryptedKey=new n.OctetString;constructor(e={}){Object.assign(this,e)}};e.PasswordRecipientInfo=i,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer})],i.prototype,`version`,void 0),t.__decorate([(0,n.AsnProp)({type:r.KeyDerivationAlgorithmIdentifier,context:0,optional:!0})],i.prototype,`keyDerivationAlgorithm`,void 0),t.__decorate([(0,n.AsnProp)({type:r.KeyEncryptionAlgorithmIdentifier})],i.prototype,`keyEncryptionAlgorithm`,void 0),t.__decorate([(0,n.AsnProp)({type:n.OctetString})],i.prototype,`encryptedKey`,void 0)})),ea=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.RecipientInfo=e.OtherRecipientInfo=void 0;let t=(X(),P(Y)),n=Z(),r=Xi(),i=Zi(),a=Qi(),o=$i();var s=class{oriType=``;oriValue=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.OtherRecipientInfo=s,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.ObjectIdentifier})],s.prototype,`oriType`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Any})],s.prototype,`oriValue`,void 0);let c=class{ktri;kari;kekri;pwri;ori;constructor(e={}){Object.assign(this,e)}};e.RecipientInfo=c,t.__decorate([(0,n.AsnProp)({type:i.KeyTransRecipientInfo,optional:!0})],c.prototype,`ktri`,void 0),t.__decorate([(0,n.AsnProp)({type:r.KeyAgreeRecipientInfo,context:1,implicit:!0,optional:!0})],c.prototype,`kari`,void 0),t.__decorate([(0,n.AsnProp)({type:a.KEKRecipientInfo,context:2,implicit:!0,optional:!0})],c.prototype,`kekri`,void 0),t.__decorate([(0,n.AsnProp)({type:o.PasswordRecipientInfo,context:3,implicit:!0,optional:!0})],c.prototype,`pwri`,void 0),t.__decorate([(0,n.AsnProp)({type:s,context:4,implicit:!0,optional:!0})],c.prototype,`ori`,void 0),e.RecipientInfo=c=t.__decorate([(0,n.AsnType)({type:n.AsnTypeTypes.Choice})],c)})),ta=M((e=>{var t;Object.defineProperty(e,"__esModule",{value:!0}),e.RecipientInfos=void 0;let n=(X(),P(Y)),r=Z(),i=ea(),a=t=class extends r.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,t.prototype)}};e.RecipientInfos=a,e.RecipientInfos=a=t=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Set,itemType:i.RecipientInfo})],a)})),na=M((e=>{var t;Object.defineProperty(e,"__esModule",{value:!0}),e.RevocationInfoChoices=e.RevocationInfoChoice=e.OtherRevocationInfoFormat=e.id_ri_scvp=e.id_ri_ocsp_response=e.id_ri=void 0;let n=(X(),P(Y)),r=Z();e.id_ri=`${$().id_pkix}.16`,e.id_ri_ocsp_response=`${e.id_ri}.2`,e.id_ri_scvp=`${e.id_ri}.4`;var i=class{otherRevInfoFormat=``;otherRevInfo=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.OtherRevocationInfoFormat=i,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.ObjectIdentifier})],i.prototype,`otherRevInfoFormat`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Any})],i.prototype,`otherRevInfo`,void 0);let a=class{other=new i;constructor(e={}){Object.assign(this,e)}};e.RevocationInfoChoice=a,n.__decorate([(0,r.AsnProp)({type:i,context:1,implicit:!0})],a.prototype,`other`,void 0),e.RevocationInfoChoice=a=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Choice})],a);let o=t=class extends r.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,t.prototype)}};e.RevocationInfoChoices=o,e.RevocationInfoChoices=o=t=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Set,itemType:a})],o)})),ra=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.OriginatorInfo=void 0;let t=(X(),P(Y)),n=Z(),r=Gi(),i=na();var a=class{certs;crls;constructor(e={}){Object.assign(this,e)}};e.OriginatorInfo=a,t.__decorate([(0,n.AsnProp)({type:r.CertificateSet,context:0,implicit:!0,optional:!0})],a.prototype,`certs`,void 0),t.__decorate([(0,n.AsnProp)({type:i.RevocationInfoChoices,context:1,implicit:!0,optional:!0})],a.prototype,`crls`,void 0)})),ia=M((e=>{var t;Object.defineProperty(e,"__esModule",{value:!0}),e.EnvelopedData=e.UnprotectedAttributes=void 0;let n=(X(),P(Y)),r=Z(),i=_i(),a=vi(),o=ta(),s=ra(),c=Ji(),l=t=class extends r.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,t.prototype)}};e.UnprotectedAttributes=l,e.UnprotectedAttributes=l=t=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Set,itemType:a.Attribute})],l);var u=class{version=i.CMSVersion.v0;originatorInfo;recipientInfos=new o.RecipientInfos;encryptedContentInfo=new c.EncryptedContentInfo;unprotectedAttrs;constructor(e={}){Object.assign(this,e)}};e.EnvelopedData=u,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer})],u.prototype,`version`,void 0),n.__decorate([(0,r.AsnProp)({type:s.OriginatorInfo,context:0,implicit:!0,optional:!0})],u.prototype,`originatorInfo`,void 0),n.__decorate([(0,r.AsnProp)({type:o.RecipientInfos})],u.prototype,`recipientInfos`,void 0),n.__decorate([(0,r.AsnProp)({type:c.EncryptedContentInfo})],u.prototype,`encryptedContentInfo`,void 0),n.__decorate([(0,r.AsnProp)({type:l,context:1,implicit:!0,optional:!0})],u.prototype,`unprotectedAttrs`,void 0)})),aa=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.id_authData=e.id_encryptedData=e.id_digestedData=e.id_envelopedData=e.id_signedData=e.id_data=e.id_ct_contentInfo=void 0,e.id_ct_contentInfo=`1.2.840.113549.1.9.16.1.6`,e.id_data=`1.2.840.113549.1.7.1`,e.id_signedData=`1.2.840.113549.1.7.2`,e.id_envelopedData=`1.2.840.113549.1.7.3`,e.id_digestedData=`1.2.840.113549.1.7.5`,e.id_encryptedData=`1.2.840.113549.1.7.6`,e.id_authData=`1.2.840.113549.1.9.16.1.2`})),oa=M((e=>{var t;Object.defineProperty(e,"__esModule",{value:!0}),e.SignedData=e.DigestAlgorithmIdentifiers=void 0;let n=(X(),P(Y)),r=Z(),i=Gi(),a=_i(),o=qi(),s=na(),c=yi(),l=t=class extends r.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,t.prototype)}};e.DigestAlgorithmIdentifiers=l,e.DigestAlgorithmIdentifiers=l=t=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Set,itemType:a.DigestAlgorithmIdentifier})],l);var u=class{version=a.CMSVersion.v0;digestAlgorithms=new l;encapContentInfo=new o.EncapsulatedContentInfo;certificates;crls;signerInfos=new c.SignerInfos;constructor(e={}){Object.assign(this,e)}};e.SignedData=u,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer})],u.prototype,`version`,void 0),n.__decorate([(0,r.AsnProp)({type:l})],u.prototype,`digestAlgorithms`,void 0),n.__decorate([(0,r.AsnProp)({type:o.EncapsulatedContentInfo})],u.prototype,`encapContentInfo`,void 0),n.__decorate([(0,r.AsnProp)({type:i.CertificateSet,context:0,implicit:!0,optional:!0})],u.prototype,`certificates`,void 0),n.__decorate([(0,r.AsnProp)({type:s.RevocationInfoChoices,context:1,implicit:!0,optional:!0})],u.prototype,`crls`,void 0),n.__decorate([(0,r.AsnProp)({type:c.SignerInfos})],u.prototype,`signerInfos`,void 0)})),sa=M((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=(X(),P(Y));t.__exportStar(Ci(),e),t.__exportStar(vi(),e),t.__exportStar(Gi(),e),t.__exportStar(Ki(),e),t.__exportStar(qi(),e),t.__exportStar(Ji(),e),t.__exportStar(ia(),e),t.__exportStar(hi(),e),t.__exportStar(Qi(),e),t.__exportStar(Xi(),e),t.__exportStar(Zi(),e),t.__exportStar(aa(),e),t.__exportStar(ra(),e),t.__exportStar($i(),e),t.__exportStar(ea(),e),t.__exportStar(ta(),e),t.__exportStar(na(),e),t.__exportStar(oa(),e),t.__exportStar(gi(),e),t.__exportStar(yi(),e),t.__exportStar(_i(),e)})),ca=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.id_sect571r1=e.id_sect571k1=e.id_secp521r1=e.id_sect409r1=e.id_sect409k1=e.id_secp384r1=e.id_sect283r1=e.id_sect283k1=e.id_secp256r1=e.id_sect233r1=e.id_sect233k1=e.id_secp224r1=e.id_sect163r2=e.id_sect163k1=e.id_secp192r1=e.id_ecdsaWithSHA512=e.id_ecdsaWithSHA384=e.id_ecdsaWithSHA256=e.id_ecdsaWithSHA224=e.id_ecdsaWithSHA1=e.id_ecMQV=e.id_ecDH=e.id_ecPublicKey=void 0,e.id_ecPublicKey=`1.2.840.10045.2.1`,e.id_ecDH=`1.3.132.1.12`,e.id_ecMQV=`1.3.132.1.13`,e.id_ecdsaWithSHA1=`1.2.840.10045.4.1`,e.id_ecdsaWithSHA224=`1.2.840.10045.4.3.1`,e.id_ecdsaWithSHA256=`1.2.840.10045.4.3.2`,e.id_ecdsaWithSHA384=`1.2.840.10045.4.3.3`,e.id_ecdsaWithSHA512=`1.2.840.10045.4.3.4`,e.id_secp192r1=`1.2.840.10045.3.1.1`,e.id_sect163k1=`1.3.132.0.1`,e.id_sect163r2=`1.3.132.0.15`,e.id_secp224r1=`1.3.132.0.33`,e.id_sect233k1=`1.3.132.0.26`,e.id_sect233r1=`1.3.132.0.27`,e.id_secp256r1=`1.2.840.10045.3.1.7`,e.id_sect283k1=`1.3.132.0.16`,e.id_sect283r1=`1.3.132.0.17`,e.id_secp384r1=`1.3.132.0.34`,e.id_sect409k1=`1.3.132.0.36`,e.id_sect409r1=`1.3.132.0.37`,e.id_secp521r1=`1.3.132.0.35`,e.id_sect571k1=`1.3.132.0.38`,e.id_sect571r1=`1.3.132.0.39`})),la=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ecdsaWithSHA512=e.ecdsaWithSHA384=e.ecdsaWithSHA256=e.ecdsaWithSHA224=e.ecdsaWithSHA1=void 0;let t=(X(),P(Y)),n=$(),r=t.__importStar(ca());function i(e){return new n.AlgorithmIdentifier({algorithm:e})}e.ecdsaWithSHA1=i(r.id_ecdsaWithSHA1),e.ecdsaWithSHA224=i(r.id_ecdsaWithSHA224),e.ecdsaWithSHA256=i(r.id_ecdsaWithSHA256),e.ecdsaWithSHA384=i(r.id_ecdsaWithSHA384),e.ecdsaWithSHA512=i(r.id_ecdsaWithSHA512)})),ua=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SpecifiedECDomain=e.ECPVer=e.Curve=e.FieldElement=e.ECPoint=e.FieldID=void 0;let t=(X(),P(Y)),n=Z(),r=class{fieldType;parameters;constructor(e={}){Object.assign(this,e)}};e.FieldID=r,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.ObjectIdentifier})],r.prototype,`fieldType`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Any})],r.prototype,`parameters`,void 0),e.FieldID=r=t.__decorate([(0,n.AsnType)({type:n.AsnTypeTypes.Sequence})],r);var i=class extends n.OctetString{};e.ECPoint=i,e.FieldElement=class extends n.OctetString{};let a=class{a;b;seed;constructor(e={}){Object.assign(this,e)}};e.Curve=a,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.OctetString})],a.prototype,`a`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.OctetString})],a.prototype,`b`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.BitString,optional:!0})],a.prototype,`seed`,void 0),e.Curve=a=t.__decorate([(0,n.AsnType)({type:n.AsnTypeTypes.Sequence})],a);var o;(function(e){e[e.ecpVer1=1]=`ecpVer1`})(o||(e.ECPVer=o={}));let s=class{version=o.ecpVer1;fieldID;curve;base;order;cofactor;constructor(e={}){Object.assign(this,e)}};e.SpecifiedECDomain=s,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer})],s.prototype,`version`,void 0),t.__decorate([(0,n.AsnProp)({type:r})],s.prototype,`fieldID`,void 0),t.__decorate([(0,n.AsnProp)({type:a})],s.prototype,`curve`,void 0),t.__decorate([(0,n.AsnProp)({type:i})],s.prototype,`base`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer,converter:n.AsnIntegerArrayBufferConverter})],s.prototype,`order`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer,optional:!0})],s.prototype,`cofactor`,void 0),e.SpecifiedECDomain=s=t.__decorate([(0,n.AsnType)({type:n.AsnTypeTypes.Sequence})],s)})),da=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ECParameters=void 0;let t=(X(),P(Y)),n=Z(),r=ua(),i=class{namedCurve;implicitCurve;specifiedCurve;constructor(e={}){Object.assign(this,e)}};e.ECParameters=i,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.ObjectIdentifier})],i.prototype,`namedCurve`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Null})],i.prototype,`implicitCurve`,void 0),t.__decorate([(0,n.AsnProp)({type:r.SpecifiedECDomain})],i.prototype,`specifiedCurve`,void 0),e.ECParameters=i=t.__decorate([(0,n.AsnType)({type:n.AsnTypeTypes.Choice})],i)})),fa=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ECPrivateKey=void 0;let t=(X(),P(Y)),n=Z(),r=da();var i=class{version=1;privateKey=new n.OctetString;parameters;publicKey;constructor(e={}){Object.assign(this,e)}};e.ECPrivateKey=i,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer})],i.prototype,`version`,void 0),t.__decorate([(0,n.AsnProp)({type:n.OctetString})],i.prototype,`privateKey`,void 0),t.__decorate([(0,n.AsnProp)({type:r.ECParameters,context:0,optional:!0})],i.prototype,`parameters`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.BitString,context:1,optional:!0})],i.prototype,`publicKey`,void 0)})),pa=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ECDSASigValue=void 0;let t=(X(),P(Y)),n=Z();var r=class{r=new ArrayBuffer(0);s=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.ECDSASigValue=r,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer,converter:n.AsnIntegerArrayBufferConverter})],r.prototype,`r`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer,converter:n.AsnIntegerArrayBufferConverter})],r.prototype,`s`,void 0)})),ma=M((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=(X(),P(Y));t.__exportStar(la(),e),t.__exportStar(da(),e),t.__exportStar(fa(),e),t.__exportStar(pa(),e),t.__exportStar(ca(),e),t.__exportStar(ua(),e)})),ha=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.id_mgf1=e.id_md5=e.id_md2=e.id_sha512_256=e.id_sha512_224=e.id_sha512=e.id_sha384=e.id_sha256=e.id_sha224=e.id_sha1=e.id_sha512_256WithRSAEncryption=e.id_sha512_224WithRSAEncryption=e.id_sha512WithRSAEncryption=e.id_sha384WithRSAEncryption=e.id_sha256WithRSAEncryption=e.id_ssha224WithRSAEncryption=e.id_sha224WithRSAEncryption=e.id_sha1WithRSAEncryption=e.id_md5WithRSAEncryption=e.id_md2WithRSAEncryption=e.id_RSASSA_PSS=e.id_pSpecified=e.id_RSAES_OAEP=e.id_rsaEncryption=e.id_pkcs_1=void 0,e.id_pkcs_1=`1.2.840.113549.1.1`,e.id_rsaEncryption=`${e.id_pkcs_1}.1`,e.id_RSAES_OAEP=`${e.id_pkcs_1}.7`,e.id_pSpecified=`${e.id_pkcs_1}.9`,e.id_RSASSA_PSS=`${e.id_pkcs_1}.10`,e.id_md2WithRSAEncryption=`${e.id_pkcs_1}.2`,e.id_md5WithRSAEncryption=`${e.id_pkcs_1}.4`,e.id_sha1WithRSAEncryption=`${e.id_pkcs_1}.5`,e.id_sha224WithRSAEncryption=`${e.id_pkcs_1}.14`,e.id_ssha224WithRSAEncryption=e.id_sha224WithRSAEncryption,e.id_sha256WithRSAEncryption=`${e.id_pkcs_1}.11`,e.id_sha384WithRSAEncryption=`${e.id_pkcs_1}.12`,e.id_sha512WithRSAEncryption=`${e.id_pkcs_1}.13`,e.id_sha512_224WithRSAEncryption=`${e.id_pkcs_1}.15`,e.id_sha512_256WithRSAEncryption=`${e.id_pkcs_1}.16`,e.id_sha1=`1.3.14.3.2.26`,e.id_sha224=`2.16.840.1.101.3.4.2.4`,e.id_sha256=`2.16.840.1.101.3.4.2.1`,e.id_sha384=`2.16.840.1.101.3.4.2.2`,e.id_sha512=`2.16.840.1.101.3.4.2.3`,e.id_sha512_224=`2.16.840.1.101.3.4.2.5`,e.id_sha512_256=`2.16.840.1.101.3.4.2.6`,e.id_md2=`1.2.840.113549.2.2`,e.id_md5=`1.2.840.113549.2.5`,e.id_mgf1=`${e.id_pkcs_1}.8`})),ga=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.sha512_256WithRSAEncryption=e.sha512_224WithRSAEncryption=e.sha512WithRSAEncryption=e.sha384WithRSAEncryption=e.sha256WithRSAEncryption=e.sha224WithRSAEncryption=e.sha1WithRSAEncryption=e.md5WithRSAEncryption=e.md2WithRSAEncryption=e.rsaEncryption=e.pSpecifiedEmpty=e.mgf1SHA1=e.sha512_256=e.sha512_224=e.sha512=e.sha384=e.sha256=e.sha224=e.sha1=e.md4=e.md2=void 0;let t=(X(),P(Y)),n=Z(),r=$(),i=t.__importStar(ha());function a(e){return new r.AlgorithmIdentifier({algorithm:e,parameters:null})}e.md2=a(i.id_md2),e.md4=a(i.id_md5),e.sha1=a(i.id_sha1),e.sha224=a(i.id_sha224),e.sha256=a(i.id_sha256),e.sha384=a(i.id_sha384),e.sha512=a(i.id_sha512),e.sha512_224=a(i.id_sha512_224),e.sha512_256=a(i.id_sha512_256),e.mgf1SHA1=new r.AlgorithmIdentifier({algorithm:i.id_mgf1,parameters:n.AsnConvert.serialize(e.sha1)}),e.pSpecifiedEmpty=new r.AlgorithmIdentifier({algorithm:i.id_pSpecified,parameters:n.AsnConvert.serialize(n.AsnOctetStringConverter.toASN(new Uint8Array([218,57,163,238,94,107,75,13,50,85,191,239,149,96,24,144,175,216,7,9]).buffer))}),e.rsaEncryption=a(i.id_rsaEncryption),e.md2WithRSAEncryption=a(i.id_md2WithRSAEncryption),e.md5WithRSAEncryption=a(i.id_md5WithRSAEncryption),e.sha1WithRSAEncryption=a(i.id_sha1WithRSAEncryption),e.sha224WithRSAEncryption=a(i.id_sha512_224WithRSAEncryption),e.sha256WithRSAEncryption=a(i.id_sha512_256WithRSAEncryption),e.sha384WithRSAEncryption=a(i.id_sha384WithRSAEncryption),e.sha512WithRSAEncryption=a(i.id_sha512WithRSAEncryption),e.sha512_224WithRSAEncryption=a(i.id_sha512_224WithRSAEncryption),e.sha512_256WithRSAEncryption=a(i.id_sha512_256WithRSAEncryption)})),_a=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.RSAES_OAEP=e.RsaEsOaepParams=void 0;let t=(X(),P(Y)),n=Z(),r=$(),i=ha(),a=ga();var o=class{hashAlgorithm=new r.AlgorithmIdentifier(a.sha1);maskGenAlgorithm=new r.AlgorithmIdentifier({algorithm:i.id_mgf1,parameters:n.AsnConvert.serialize(a.sha1)});pSourceAlgorithm=new r.AlgorithmIdentifier(a.pSpecifiedEmpty);constructor(e={}){Object.assign(this,e)}};e.RsaEsOaepParams=o,t.__decorate([(0,n.AsnProp)({type:r.AlgorithmIdentifier,context:0,defaultValue:a.sha1})],o.prototype,`hashAlgorithm`,void 0),t.__decorate([(0,n.AsnProp)({type:r.AlgorithmIdentifier,context:1,defaultValue:a.mgf1SHA1})],o.prototype,`maskGenAlgorithm`,void 0),t.__decorate([(0,n.AsnProp)({type:r.AlgorithmIdentifier,context:2,defaultValue:a.pSpecifiedEmpty})],o.prototype,`pSourceAlgorithm`,void 0),e.RSAES_OAEP=new r.AlgorithmIdentifier({algorithm:i.id_RSAES_OAEP,parameters:n.AsnConvert.serialize(new o)})})),va=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.RSASSA_PSS=e.RsaSaPssParams=void 0;let t=(X(),P(Y)),n=Z(),r=$(),i=ha(),a=ga();var o=class{hashAlgorithm=new r.AlgorithmIdentifier(a.sha1);maskGenAlgorithm=new r.AlgorithmIdentifier({algorithm:i.id_mgf1,parameters:n.AsnConvert.serialize(a.sha1)});saltLength=20;trailerField=1;constructor(e={}){Object.assign(this,e)}};e.RsaSaPssParams=o,t.__decorate([(0,n.AsnProp)({type:r.AlgorithmIdentifier,context:0,defaultValue:a.sha1})],o.prototype,`hashAlgorithm`,void 0),t.__decorate([(0,n.AsnProp)({type:r.AlgorithmIdentifier,context:1,defaultValue:a.mgf1SHA1})],o.prototype,`maskGenAlgorithm`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer,context:2,defaultValue:20})],o.prototype,`saltLength`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer,context:3,defaultValue:1})],o.prototype,`trailerField`,void 0),e.RSASSA_PSS=new r.AlgorithmIdentifier({algorithm:i.id_RSASSA_PSS,parameters:n.AsnConvert.serialize(new o)})})),ya=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.DigestInfo=void 0;let t=(X(),P(Y)),n=$(),r=Z();var i=class{digestAlgorithm=new n.AlgorithmIdentifier;digest=new r.OctetString;constructor(e={}){Object.assign(this,e)}};e.DigestInfo=i,t.__decorate([(0,r.AsnProp)({type:n.AlgorithmIdentifier})],i.prototype,`digestAlgorithm`,void 0),t.__decorate([(0,r.AsnProp)({type:r.OctetString})],i.prototype,`digest`,void 0)})),ba=M((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=(X(),P(Y));t.__exportStar(_a(),e),t.__exportStar(va(),e),t.__exportStar(ya(),e)})),xa=M((e=>{var t;Object.defineProperty(e,"__esModule",{value:!0}),e.OtherPrimeInfos=e.OtherPrimeInfo=void 0;let n=(X(),P(Y)),r=Z();var i=class{prime=new ArrayBuffer(0);exponent=new ArrayBuffer(0);coefficient=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.OtherPrimeInfo=i,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer,converter:r.AsnIntegerArrayBufferConverter})],i.prototype,`prime`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer,converter:r.AsnIntegerArrayBufferConverter})],i.prototype,`exponent`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer,converter:r.AsnIntegerArrayBufferConverter})],i.prototype,`coefficient`,void 0);let a=t=class extends r.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,t.prototype)}};e.OtherPrimeInfos=a,e.OtherPrimeInfos=a=t=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Sequence,itemType:i})],a)})),Sa=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.RSAPrivateKey=void 0;let t=(X(),P(Y)),n=Z(),r=xa();var i=class{version=0;modulus=new ArrayBuffer(0);publicExponent=new ArrayBuffer(0);privateExponent=new ArrayBuffer(0);prime1=new ArrayBuffer(0);prime2=new ArrayBuffer(0);exponent1=new ArrayBuffer(0);exponent2=new ArrayBuffer(0);coefficient=new ArrayBuffer(0);otherPrimeInfos;constructor(e={}){Object.assign(this,e)}};e.RSAPrivateKey=i,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer})],i.prototype,`version`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer,converter:n.AsnIntegerArrayBufferConverter})],i.prototype,`modulus`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer,converter:n.AsnIntegerArrayBufferConverter})],i.prototype,`publicExponent`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer,converter:n.AsnIntegerArrayBufferConverter})],i.prototype,`privateExponent`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer,converter:n.AsnIntegerArrayBufferConverter})],i.prototype,`prime1`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer,converter:n.AsnIntegerArrayBufferConverter})],i.prototype,`prime2`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer,converter:n.AsnIntegerArrayBufferConverter})],i.prototype,`exponent1`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer,converter:n.AsnIntegerArrayBufferConverter})],i.prototype,`exponent2`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer,converter:n.AsnIntegerArrayBufferConverter})],i.prototype,`coefficient`,void 0),t.__decorate([(0,n.AsnProp)({type:r.OtherPrimeInfos,optional:!0})],i.prototype,`otherPrimeInfos`,void 0)})),Ca=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.RSAPublicKey=void 0;let t=(X(),P(Y)),n=Z();var r=class{modulus=new ArrayBuffer(0);publicExponent=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.RSAPublicKey=r,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer,converter:n.AsnIntegerArrayBufferConverter})],r.prototype,`modulus`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer,converter:n.AsnIntegerArrayBufferConverter})],r.prototype,`publicExponent`,void 0)})),wa=M((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=(X(),P(Y));t.__exportStar(ba(),e),t.__exportStar(ga(),e),t.__exportStar(ha(),e),t.__exportStar(xa(),e),t.__exportStar(Sa(),e),t.__exportStar(Ca(),e)})),Ta=N({__assign:()=>Ya,__asyncDelegator:()=>Va,__asyncGenerator:()=>Ba,__asyncValues:()=>Ha,__await:()=>za,__awaiter:()=>ja,__classPrivateFieldGet:()=>Ka,__classPrivateFieldSet:()=>qa,__createBinding:()=>Na,__decorate:()=>Oa,__exportStar:()=>Pa,__extends:()=>Ea,__generator:()=>Ma,__importDefault:()=>Ga,__importStar:()=>Wa,__makeTemplateObject:()=>Ua,__metadata:()=>Aa,__param:()=>ka,__read:()=>Ia,__rest:()=>Da,__spread:()=>La,__spreadArrays:()=>Ra,__values:()=>Fa});
91
+ /*! *****************************************************************************
92
+ Copyright (c) Microsoft Corporation.
93
+
94
+ Permission to use, copy, modify, and/or distribute this software for any
95
+ purpose with or without fee is hereby granted.
96
+
97
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
98
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
99
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
100
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
101
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
102
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
103
+ PERFORMANCE OF THIS SOFTWARE.
104
+ ***************************************************************************** */
105
+ function Ea(e,t){Ja(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}function Da(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function Oa(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}function ka(e,t){return function(n,r){t(n,r,e)}}function Aa(e,t){if(typeof Reflect==`object`&&typeof Reflect.metadata==`function`)return Reflect.metadata(e,t)}function ja(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})}function Ma(e,t){var n={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},r,i,a,o;return o={next:s(0),throw:s(1),return:s(2)},typeof Symbol==`function`&&(o[Symbol.iterator]=function(){return this}),o;function s(e){return function(t){return c([e,t])}}function c(o){if(r)throw TypeError(`Generator is already executing.`);for(;n;)try{if(r=1,i&&(a=o[0]&2?i.return:o[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,o[1])).done)return a;switch(i=0,a&&(o=[o[0]&2,a.value]),o[0]){case 0:case 1:a=o;break;case 4:return n.label++,{value:o[1],done:!1};case 5:n.label++,i=o[1],o=[0];continue;case 7:o=n.ops.pop(),n.trys.pop();continue;default:if((a=n.trys,!(a=a.length>0&&a[a.length-1]))&&(o[0]===6||o[0]===2)){n=0;continue}if(o[0]===3&&(!a||o[1]>a[0]&&o[1]<a[3])){n.label=o[1];break}if(o[0]===6&&n.label<a[1]){n.label=a[1],a=o;break}if(a&&n.label<a[2]){n.label=a[2],n.ops.push(o);break}a[2]&&n.ops.pop(),n.trys.pop();continue}o=t.call(e,n)}catch(e){o=[6,e],i=0}finally{r=a=0}if(o[0]&5)throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}}function Na(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]}function Pa(e,t){for(var n in e)n!=="default"&&!t.hasOwnProperty(n)&&(t[n]=e[n])}function Fa(e){var t=typeof Symbol==`function`&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length==`number`)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw TypeError(t?`Object is not iterable.`:`Symbol.iterator is not defined.`)}function Ia(e,t){var n=typeof Symbol==`function`&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),i,a=[],o;try{for(;(t===void 0||t-->0)&&!(i=r.next()).done;)a.push(i.value)}catch(e){o={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a}function La(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(Ia(arguments[t]));return e}function Ra(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;for(var r=Array(e),i=0,t=0;t<n;t++)for(var a=arguments[t],o=0,s=a.length;o<s;o++,i++)r[i]=a[o];return r}function za(e){return this instanceof za?(this.v=e,this):new za(e)}function Ba(e,t,n){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var r=n.apply(e,t||[]),i,a=[];return i={},o(`next`),o(`throw`),o(`return`),i[Symbol.asyncIterator]=function(){return this},i;function o(e){r[e]&&(i[e]=function(t){return new Promise(function(n,r){a.push([e,t,n,r])>1||s(e,t)})})}function s(e,t){try{c(r[e](t))}catch(e){d(a[0][3],e)}}function c(e){e.value instanceof za?Promise.resolve(e.value.v).then(l,u):d(a[0][2],e)}function l(e){s(`next`,e)}function u(e){s(`throw`,e)}function d(e,t){e(t),a.shift(),a.length&&s(a[0][0],a[0][1])}}function Va(e){var t,n;return t={},r(`next`),r(`throw`,function(e){throw e}),r(`return`),t[Symbol.iterator]=function(){return this},t;function r(r,i){t[r]=e[r]?function(t){return(n=!n)?{value:za(e[r](t)),done:r===`return`}:i?i(t):t}:i}}function Ha(e){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof Fa==`function`?Fa(e):e[Symbol.iterator](),n={},r(`next`),r(`throw`),r(`return`),n[Symbol.asyncIterator]=function(){return this},n);function r(t){n[t]=e[t]&&function(n){return new Promise(function(r,a){n=e[t](n),i(r,a,n.done,n.value)})}}function i(e,t,n,r){Promise.resolve(r).then(function(t){e({value:t,done:n})},t)}}function Ua(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}function Wa(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}function Ga(e){return e&&e.__esModule?e:{default:e}}function Ka(e,t){if(!t.has(e))throw TypeError(`attempted to get private field on non-instance`);return t.get(e)}function qa(e,t,n){if(!t.has(e))throw TypeError(`attempted to set private field on non-instance`);return t.set(e,n),n}var Ja,Ya,Xa=re((()=>{Ja=function(e,t){return Ja=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},Ja(e,t)},Ya=function(){return Ya=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Ya.apply(this,arguments)}})),Za=M((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t;(function(e){e[e.Transient=0]=`Transient`,e[e.Singleton=1]=`Singleton`,e[e.ResolutionScoped=2]=`ResolutionScoped`,e[e.ContainerScoped=3]=`ContainerScoped`})(t||={}),e.default=t})),Qa=M((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Za();Object.defineProperty(e,"Lifecycle",{enumerable:!0,get:function(){return t.default}})})),$a=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.defineInjectionTokenMetadata=e.getParamInfo=e.INJECTION_TOKEN_METADATA_KEY=void 0,e.INJECTION_TOKEN_METADATA_KEY=`injectionTokens`;function t(t){let n=Reflect.getMetadata(`design:paramtypes`,t)||[],r=Reflect.getOwnMetadata(e.INJECTION_TOKEN_METADATA_KEY,t)||{};return Object.keys(r).forEach(e=>{n[+e]=r[e]}),n}e.getParamInfo=t;function n(t,n){return function(r,i,a){let o=Reflect.getOwnMetadata(e.INJECTION_TOKEN_METADATA_KEY,r)||{};o[a]=n?{token:t,transform:n.transformToken,transformArgs:n.args||[]}:t,Reflect.defineMetadata(e.INJECTION_TOKEN_METADATA_KEY,o,r)}}e.defineInjectionTokenMetadata=n})),eo=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isClassProvider=void 0;function t(e){return!!e.useClass}e.isClassProvider=t})),to=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isFactoryProvider=void 0;function t(e){return!!e.useFactory}e.isFactoryProvider=t})),no=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.delay=e.DelayedConstructor=void 0;var t=class{constructor(e){this.wrap=e,this.reflectMethods=[`get`,`getPrototypeOf`,`setPrototypeOf`,`getOwnPropertyDescriptor`,`defineProperty`,`has`,`set`,`deleteProperty`,`apply`,`construct`,`ownKeys`]}createProxy(e){let t={},n=!1,r;return new Proxy(t,this.createHandler(()=>(n||=(r=e(this.wrap()),!0),r)))}createHandler(e){let t={};return this.reflectMethods.forEach(n=>{t[n]=(...t)=>{t[0]=e();let r=Reflect[n];return r(...t)}}),t}};e.DelayedConstructor=t;function n(e){if(e===void 0)throw Error("Attempt to `delay` undefined. Constructor must be wrapped in a callback");return new t(e)}e.delay=n})),ro=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isConstructorToken=e.isTransformDescriptor=e.isTokenDescriptor=e.isNormalToken=void 0;let t=no();function n(e){return typeof e==`string`||typeof e==`symbol`}e.isNormalToken=n;function r(e){return typeof e==`object`&&`token`in e&&`multiple`in e}e.isTokenDescriptor=r;function i(e){return typeof e==`object`&&`token`in e&&`transform`in e}e.isTransformDescriptor=i;function a(e){return typeof e==`function`||e instanceof t.DelayedConstructor}e.isConstructorToken=a})),io=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isTokenProvider=void 0;function t(e){return!!e.useToken}e.isTokenProvider=t})),ao=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isValueProvider=void 0;function t(e){return e.useValue!=null}e.isValueProvider=t})),oo=M((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=eo();Object.defineProperty(e,"isClassProvider",{enumerable:!0,get:function(){return t.isClassProvider}});var n=to();Object.defineProperty(e,"isFactoryProvider",{enumerable:!0,get:function(){return n.isFactoryProvider}});var r=ro();Object.defineProperty(e,"isNormalToken",{enumerable:!0,get:function(){return r.isNormalToken}});var i=io();Object.defineProperty(e,"isTokenProvider",{enumerable:!0,get:function(){return i.isTokenProvider}});var a=ao();Object.defineProperty(e,"isValueProvider",{enumerable:!0,get:function(){return a.isValueProvider}})})),so=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isProvider=void 0;let t=eo(),n=ao(),r=io(),i=to();function a(e){return t.isClassProvider(e)||n.isValueProvider(e)||r.isTokenProvider(e)||i.isFactoryProvider(e)}e.isProvider=a})),co=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=class{constructor(){this._registryMap=new Map}entries(){return this._registryMap.entries()}getAll(e){return this.ensure(e),this._registryMap.get(e)}get(e){this.ensure(e);let t=this._registryMap.get(e);return t[t.length-1]||null}set(e,t){this.ensure(e),this._registryMap.get(e).push(t)}setAll(e,t){this._registryMap.set(e,t)}has(e){return this.ensure(e),this._registryMap.get(e).length>0}clear(){this._registryMap.clear()}ensure(e){this._registryMap.has(e)||this._registryMap.set(e,[])}}})),lo=M((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=co();e.default=class extends t.default{}})),uo=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=class{constructor(){this.scopedResolutions=new Map}}})),fo=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.formatErrorCtor=void 0;function t(e,t){return e===null?`at position #${t}`:`"${e.split(`,`)[t].trim()}" at position #${t}`}function n(e,t,n=` `){return[e,...t.message.split(`
106
+ `).map(e=>n+e)].join(`
107
+ `)}function r(e,r,i){let[,a=null]=e.toString().match(/constructor\(([\w, ]+)\)/)||[];return n(`Cannot inject the dependency ${t(a,r)} of "${e.name}" constructor. Reason:`,i)}e.formatErrorCtor=r})),po=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isDisposable=void 0;function t(e){return!(typeof e.dispose!=`function`||e.dispose.length>0)}e.isDisposable=t})),mo=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.PostResolutionInterceptors=e.PreResolutionInterceptors=void 0;let t=co();var n=class extends t.default{};e.PreResolutionInterceptors=n;var r=class extends t.default{};e.PostResolutionInterceptors=r,e.default=class{constructor(){this.preResolution=new n,this.postResolution=new r}}})),ho=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.instance=e.typeInfo=void 0;let t=(Xa(),P(Ta)),n=oo(),r=so(),i=ro(),a=lo(),o=Za(),s=uo(),c=fo(),l=no(),u=po(),d=mo();e.typeInfo=new Map,e.instance=new class f{constructor(e){this.parent=e,this._registry=new a.default,this.interceptors=new d.default,this.disposed=!1,this.disposables=new Set}register(e,t,i={lifecycle:o.default.Transient}){this.ensureNotDisposed();let a;if(a=r.isProvider(t)?t:{useClass:t},n.isTokenProvider(a)){let t=[e],r=a;for(;r!=null;){let e=r.useToken;if(t.includes(e))throw Error(`Token registration cycle detected! ${[...t,e].join(` -> `)}`);t.push(e);let i=this._registry.get(e);r=i&&n.isTokenProvider(i.provider)?i.provider:null}}if((i.lifecycle===o.default.Singleton||i.lifecycle==o.default.ContainerScoped||i.lifecycle==o.default.ResolutionScoped)&&(n.isValueProvider(a)||n.isFactoryProvider(a)))throw Error(`Cannot use lifecycle "${o.default[i.lifecycle]}" with ValueProviders or FactoryProviders`);return this._registry.set(e,{provider:a,options:i}),this}registerType(e,t){return this.ensureNotDisposed(),n.isNormalToken(t)?this.register(e,{useToken:t}):this.register(e,{useClass:t})}registerInstance(e,t){return this.ensureNotDisposed(),this.register(e,{useValue:t})}registerSingleton(e,t){if(this.ensureNotDisposed(),n.isNormalToken(e)){if(n.isNormalToken(t))return this.register(e,{useToken:t},{lifecycle:o.default.Singleton});if(t)return this.register(e,{useClass:t},{lifecycle:o.default.Singleton});throw Error(`Cannot register a type name as a singleton without a "to" token`)}let r=e;return t&&!n.isNormalToken(t)&&(r=t),this.register(e,{useClass:r},{lifecycle:o.default.Singleton})}resolve(e,t=new s.default,r=!1){this.ensureNotDisposed();let a=this.getRegistration(e);if(!a&&n.isNormalToken(e)){if(r)return;throw Error(`Attempted to resolve unregistered dependency token: "${e.toString()}"`)}if(this.executePreResolutionInterceptor(e,`Single`),a){let n=this.resolveRegistration(a,t);return this.executePostResolutionInterceptor(e,n,`Single`),n}if(i.isConstructorToken(e)){let n=this.construct(e,t);return this.executePostResolutionInterceptor(e,n,`Single`),n}throw Error("Attempted to construct an undefined constructor. Could mean a circular dependency problem. Try using `delay` function.")}executePreResolutionInterceptor(e,t){if(this.interceptors.preResolution.has(e)){let n=[];for(let r of this.interceptors.preResolution.getAll(e))r.options.frequency!=`Once`&&n.push(r),r.callback(e,t);this.interceptors.preResolution.setAll(e,n)}}executePostResolutionInterceptor(e,t,n){if(this.interceptors.postResolution.has(e)){let r=[];for(let i of this.interceptors.postResolution.getAll(e))i.options.frequency!=`Once`&&r.push(i),i.callback(e,t,n);this.interceptors.postResolution.setAll(e,r)}}resolveRegistration(e,t){if(this.ensureNotDisposed(),e.options.lifecycle===o.default.ResolutionScoped&&t.scopedResolutions.has(e))return t.scopedResolutions.get(e);let r=e.options.lifecycle===o.default.Singleton,i=e.options.lifecycle===o.default.ContainerScoped,a=r||i,s;return s=n.isValueProvider(e.provider)?e.provider.useValue:n.isTokenProvider(e.provider)?a?e.instance||=this.resolve(e.provider.useToken,t):this.resolve(e.provider.useToken,t):n.isClassProvider(e.provider)?a?e.instance||=this.construct(e.provider.useClass,t):this.construct(e.provider.useClass,t):n.isFactoryProvider(e.provider)?e.provider.useFactory(this):this.construct(e.provider,t),e.options.lifecycle===o.default.ResolutionScoped&&t.scopedResolutions.set(e,s),s}resolveAll(e,t=new s.default,r=!1){this.ensureNotDisposed();let i=this.getAllRegistrations(e);if(!i&&n.isNormalToken(e)){if(r)return[];throw Error(`Attempted to resolve unregistered dependency token: "${e.toString()}"`)}if(this.executePreResolutionInterceptor(e,`All`),i){let n=i.map(e=>this.resolveRegistration(e,t));return this.executePostResolutionInterceptor(e,n,`All`),n}let a=[this.construct(e,t)];return this.executePostResolutionInterceptor(e,a,`All`),a}isRegistered(e,t=!1){return this.ensureNotDisposed(),this._registry.has(e)||t&&(this.parent||!1)&&this.parent.isRegistered(e,!0)}reset(){this.ensureNotDisposed(),this._registry.clear(),this.interceptors.preResolution.clear(),this.interceptors.postResolution.clear()}clearInstances(){this.ensureNotDisposed();for(let[e,t]of this._registry.entries())this._registry.setAll(e,t.filter(e=>!n.isValueProvider(e.provider)).map(e=>(e.instance=void 0,e)))}createChildContainer(){this.ensureNotDisposed();let e=new f(this);for(let[t,n]of this._registry.entries())n.some(({options:e})=>e.lifecycle===o.default.ContainerScoped)&&e._registry.setAll(t,n.map(e=>e.options.lifecycle===o.default.ContainerScoped?{provider:e.provider,options:e.options}:e));return e}beforeResolution(e,t,n={frequency:`Always`}){this.interceptors.preResolution.set(e,{callback:t,options:n})}afterResolution(e,t,n={frequency:`Always`}){this.interceptors.postResolution.set(e,{callback:t,options:n})}dispose(){return t.__awaiter(this,void 0,void 0,function*(){this.disposed=!0;let e=[];this.disposables.forEach(t=>{let n=t.dispose();n&&e.push(n)}),yield Promise.all(e)})}getRegistration(e){return this.isRegistered(e)?this._registry.get(e):this.parent?this.parent.getRegistration(e):null}getAllRegistrations(e){return this.isRegistered(e)?this._registry.getAll(e):this.parent?this.parent.getAllRegistrations(e):null}construct(t,n){if(t instanceof l.DelayedConstructor)return t.createProxy(e=>this.resolve(e,n));let r=(()=>{let r=e.typeInfo.get(t);if(!r||r.length===0){if(t.length===0)return new t;throw Error(`TypeInfo not known for "${t.name}"`)}return new t(...r.map(this.resolveParams(n,t)))})();return u.isDisposable(r)&&this.disposables.add(r),r}resolveParams(e,t){return(n,r)=>{try{return i.isTokenDescriptor(n)?i.isTransformDescriptor(n)?n.multiple?this.resolve(n.transform).transform(this.resolveAll(n.token,new s.default,n.isOptional),...n.transformArgs):this.resolve(n.transform).transform(this.resolve(n.token,e,n.isOptional),...n.transformArgs):n.multiple?this.resolveAll(n.token,new s.default,n.isOptional):this.resolve(n.token,e,n.isOptional):i.isTransformDescriptor(n)?this.resolve(n.transform,e).transform(this.resolve(n.token,e),...n.transformArgs):this.resolve(n,e)}catch(e){throw Error(c.formatErrorCtor(t,r,e))}}}ensureNotDisposed(){if(this.disposed)throw Error(`This container has been disposed, you cannot interact with a disposed container`)}},e.default=e.instance})),go=M((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=$a(),n=ho(),r=ro(),i=fo();function a(){return function(e){let a=t.getParamInfo(e);return class extends e{constructor(...t){super(...t.concat(a.slice(t.length).map((a,o)=>{try{return r.isTokenDescriptor(a)?r.isTransformDescriptor(a)?a.multiple?n.instance.resolve(a.transform).transform(n.instance.resolveAll(a.token),...a.transformArgs):n.instance.resolve(a.transform).transform(n.instance.resolve(a.token),...a.transformArgs):a.multiple?n.instance.resolveAll(a.token):n.instance.resolve(a.token):r.isTransformDescriptor(a)?n.instance.resolve(a.transform).transform(n.instance.resolve(a.token),...a.transformArgs):n.instance.resolve(a)}catch(n){let r=o+t.length;throw Error(i.formatErrorCtor(e,r,n))}})))}}}}e.default=a})),_o=M((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=$a();function n(e,n){let r={token:e,multiple:!1,isOptional:n&&n.isOptional};return t.defineInjectionTokenMetadata(r)}e.default=n})),vo=M((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=$a(),n=ho(),r=ho();function i(e){return function(i){n.typeInfo.set(i,t.getParamInfo(i)),e&&e.token&&(Array.isArray(e.token)?e.token.forEach(e=>{r.instance.register(e,i)}):r.instance.register(e.token,i))}}e.default=i})),yo=M((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=(Xa(),P(Ta)),n=ho();function r(e=[]){return function(r){return e.forEach(e=>{var{token:r,options:i}=e,a=t.__rest(e,[`token`,`options`]);return n.instance.register(r,a,i)}),r}}e.default=r})),bo=M((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=vo(),n=ho();function r(){return function(e){t.default()(e),n.instance.registerSingleton(e)}}e.default=r})),xo=M((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=$a();function n(e,n){let r={token:e,multiple:!0,isOptional:n&&n.isOptional};return t.defineInjectionTokenMetadata(r)}e.default=n})),So=M((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=$a();function n(e,n,...r){let i={token:e,multiple:!0,transform:n,transformArgs:r};return t.defineInjectionTokenMetadata(i)}e.default=n})),Co=M((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=$a();function n(e,n,...r){return t.defineInjectionTokenMetadata(e,{transformToken:n,args:r})}e.default=n})),wo=M((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=vo(),n=ho();function r(e,r){return function(i){t.default()(i),n.instance.register(r||i,i,{lifecycle:e})}}e.default=r})),To=M((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=go();Object.defineProperty(e,"autoInjectable",{enumerable:!0,get:function(){return t.default}});var n=_o();Object.defineProperty(e,"inject",{enumerable:!0,get:function(){return n.default}});var r=vo();Object.defineProperty(e,"injectable",{enumerable:!0,get:function(){return r.default}});var i=yo();Object.defineProperty(e,"registry",{enumerable:!0,get:function(){return i.default}});var a=bo();Object.defineProperty(e,"singleton",{enumerable:!0,get:function(){return a.default}});var o=xo();Object.defineProperty(e,"injectAll",{enumerable:!0,get:function(){return o.default}});var s=So();Object.defineProperty(e,"injectAllWithTransform",{enumerable:!0,get:function(){return s.default}});var c=Co();Object.defineProperty(e,"injectWithTransform",{enumerable:!0,get:function(){return c.default}});var l=wo();Object.defineProperty(e,"scoped",{enumerable:!0,get:function(){return l.default}})})),Eo=M((e=>{Object.defineProperty(e,"__esModule",{value:!0});function t(e){let t;return n=>(t??=e(n),t)}e.default=t})),Do=M((e=>{Object.defineProperty(e,"__esModule",{value:!0});function t(e){let t=new WeakMap;return n=>{let r=t.get(n);return r??(r=e(n),t.set(n,r)),r}}e.default=t})),Oo=M((e=>{Object.defineProperty(e,"__esModule",{value:!0});function t(e,t,n,r=!0){let i,a;return o=>{let s=e(o);return(!r||a!==s)&&(i=(a=s)?o.resolve(t):o.resolve(n)),i}}e.default=t})),ko=M((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Eo();Object.defineProperty(e,"instanceCachingFactory",{enumerable:!0,get:function(){return t.default}});var n=Do();Object.defineProperty(e,"instancePerContainerCachingFactory",{enumerable:!0,get:function(){return n.default}});var r=Oo();Object.defineProperty(e,"predicateAwareClassFactory",{enumerable:!0,get:function(){return r.default}})})),Ao=M((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=(Xa(),P(Ta));if(typeof Reflect>`u`||!Reflect.getMetadata)throw Error(`tsyringe requires a reflect polyfill. Please add 'import "reflect-metadata"' to the top of your entry point.`);var n=Qa();Object.defineProperty(e,"Lifecycle",{enumerable:!0,get:function(){return n.Lifecycle}}),t.__exportStar(To(),e),t.__exportStar(ko(),e),t.__exportStar(oo(),e);var r=no();Object.defineProperty(e,"delay",{enumerable:!0,get:function(){return r.delay}});var i=ho();Object.defineProperty(e,"container",{enumerable:!0,get:function(){return i.instance}})})),jo=M((e=>{var t;Object.defineProperty(e,"__esModule",{value:!0}),e.PKCS12AttrSet=e.PKCS12Attribute=void 0;let n=(X(),P(Y)),r=Z();var i=class{attrId=``;attrValues=[];constructor(e={}){Object.assign(e)}};e.PKCS12Attribute=i,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.ObjectIdentifier})],i.prototype,`attrId`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Any,repeated:`set`})],i.prototype,`attrValues`,void 0);let a=t=class extends r.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,t.prototype)}};e.PKCS12AttrSet=a,e.PKCS12AttrSet=a=t=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Sequence,itemType:i})],a)})),Mo=M((e=>{var t;Object.defineProperty(e,"__esModule",{value:!0}),e.AuthenticatedSafe=void 0;let n=(X(),P(Y)),r=Z(),i=sa(),a=t=class extends r.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,t.prototype)}};e.AuthenticatedSafe=a,e.AuthenticatedSafe=a=t=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Sequence,itemType:i.ContentInfo})],a)})),No=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.id_bagtypes=e.id_pbewithSHAAnd40BitRC2_CBC=e.id_pbeWithSHAAnd128BitRC2_CBC=e.id_pbeWithSHAAnd2_KeyTripleDES_CBC=e.id_pbeWithSHAAnd3_KeyTripleDES_CBC=e.id_pbeWithSHAAnd40BitRC4=e.id_pbeWithSHAAnd128BitRC4=e.id_pkcs_12PbeIds=e.id_pkcs_12=e.id_pkcs=e.id_rsadsi=void 0,e.id_rsadsi=`1.2.840.113549`,e.id_pkcs=`${e.id_rsadsi}.1`,e.id_pkcs_12=`${e.id_pkcs}.12`,e.id_pkcs_12PbeIds=`${e.id_pkcs_12}.1`,e.id_pbeWithSHAAnd128BitRC4=`${e.id_pkcs_12PbeIds}.1`,e.id_pbeWithSHAAnd40BitRC4=`${e.id_pkcs_12PbeIds}.2`,e.id_pbeWithSHAAnd3_KeyTripleDES_CBC=`${e.id_pkcs_12PbeIds}.3`,e.id_pbeWithSHAAnd2_KeyTripleDES_CBC=`${e.id_pkcs_12PbeIds}.4`,e.id_pbeWithSHAAnd128BitRC2_CBC=`${e.id_pkcs_12PbeIds}.5`,e.id_pbewithSHAAnd40BitRC2_CBC=`${e.id_pkcs_12PbeIds}.6`,e.id_bagtypes=`${e.id_pkcs_12}.10.1`})),Po=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.id_pkcs_9=e.id_SafeContents=e.id_SecretBag=e.id_CRLBag=e.id_certBag=e.id_pkcs8ShroudedKeyBag=e.id_keyBag=void 0;let t=No();e.id_keyBag=`${t.id_bagtypes}.1`,e.id_pkcs8ShroudedKeyBag=`${t.id_bagtypes}.2`,e.id_certBag=`${t.id_bagtypes}.3`,e.id_CRLBag=`${t.id_bagtypes}.4`,e.id_SecretBag=`${t.id_bagtypes}.5`,e.id_SafeContents=`${t.id_bagtypes}.6`,e.id_pkcs_9=`1.2.840.113549.1.9`})),Fo=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.id_sdsiCertificate=e.id_x509Certificate=e.id_certTypes=e.CertBag=void 0;let t=(X(),P(Y)),n=Z(),r=Po();var i=class{certId=``;certValue=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.CertBag=i,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.ObjectIdentifier})],i.prototype,`certId`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Any,context:0})],i.prototype,`certValue`,void 0),e.id_certTypes=`${r.id_pkcs_9}.22`,e.id_x509Certificate=`${e.id_certTypes}.1`,e.id_sdsiCertificate=`${e.id_certTypes}.2`})),Io=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.id_x509CRL=e.id_crlTypes=e.CRLBag=void 0;let t=(X(),P(Y)),n=Z(),r=Po();var i=class{crlId=``;crltValue=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.CRLBag=i,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.ObjectIdentifier})],i.prototype,`crlId`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Any,context:0})],i.prototype,`crltValue`,void 0),e.id_crlTypes=`${r.id_pkcs_9}.23`,e.id_x509CRL=`${e.id_crlTypes}.1`})),Lo=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.EncryptedPrivateKeyInfo=e.EncryptedData=void 0;let t=(X(),P(Y)),n=Z(),r=$();var i=class extends n.OctetString{};e.EncryptedData=i;var a=class{encryptionAlgorithm=new r.AlgorithmIdentifier;encryptedData=new i;constructor(e={}){Object.assign(this,e)}};e.EncryptedPrivateKeyInfo=a,t.__decorate([(0,n.AsnProp)({type:r.AlgorithmIdentifier})],a.prototype,`encryptionAlgorithm`,void 0),t.__decorate([(0,n.AsnProp)({type:i})],a.prototype,`encryptedData`,void 0)})),Ro=M((e=>{var t;Object.defineProperty(e,"__esModule",{value:!0}),e.PrivateKeyInfo=e.Attributes=e.PrivateKey=e.Version=void 0;let n=(X(),P(Y)),r=Z(),i=$();var a;(function(e){e[e.v1=0]=`v1`})(a||(e.Version=a={}));var o=class extends r.OctetString{};e.PrivateKey=o;let s=t=class extends r.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,t.prototype)}};e.Attributes=s,e.Attributes=s=t=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Sequence,itemType:i.Attribute})],s);var c=class{version=a.v1;privateKeyAlgorithm=new i.AlgorithmIdentifier;privateKey=new o;attributes;constructor(e={}){Object.assign(this,e)}};e.PrivateKeyInfo=c,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer})],c.prototype,`version`,void 0),n.__decorate([(0,r.AsnProp)({type:i.AlgorithmIdentifier})],c.prototype,`privateKeyAlgorithm`,void 0),n.__decorate([(0,r.AsnProp)({type:o})],c.prototype,`privateKey`,void 0),n.__decorate([(0,r.AsnProp)({type:s,implicit:!0,context:0,optional:!0})],c.prototype,`attributes`,void 0)})),zo=M((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=(X(),P(Y));t.__exportStar(Lo(),e),t.__exportStar(Ro(),e)})),Bo=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.KeyBag=void 0;let t=(X(),P(Y)),n=zo(),r=Z(),i=class extends n.PrivateKeyInfo{};e.KeyBag=i,e.KeyBag=i=t.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Sequence})],i)})),Vo=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.PKCS8ShroudedKeyBag=void 0;let t=(X(),P(Y)),n=zo(),r=Z(),i=class extends n.EncryptedPrivateKeyInfo{};e.PKCS8ShroudedKeyBag=i,e.PKCS8ShroudedKeyBag=i=t.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Sequence})],i)})),Ho=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SecretBag=void 0;let t=(X(),P(Y)),n=Z();var r=class{secretTypeId=``;secretValue=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.SecretBag=r,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.ObjectIdentifier})],r.prototype,`secretTypeId`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Any,context:0})],r.prototype,`secretValue`,void 0)})),Uo=M((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=(X(),P(Y));t.__exportStar(Fo(),e),t.__exportStar(Io(),e),t.__exportStar(Bo(),e),t.__exportStar(Vo(),e),t.__exportStar(Ho(),e),t.__exportStar(Po(),e)})),Wo=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.MacData=void 0;let t=(X(),P(Y)),n=wa(),r=Z();var i=class{mac=new n.DigestInfo;macSalt=new r.OctetString;iterations=1;constructor(e={}){Object.assign(this,e)}};e.MacData=i,t.__decorate([(0,r.AsnProp)({type:n.DigestInfo})],i.prototype,`mac`,void 0),t.__decorate([(0,r.AsnProp)({type:r.OctetString})],i.prototype,`macSalt`,void 0),t.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer,defaultValue:1})],i.prototype,`iterations`,void 0)})),Go=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.PFX=void 0;let t=(X(),P(Y)),n=Z(),r=sa(),i=Wo();var a=class{version=3;authSafe=new r.ContentInfo;macData=new i.MacData;constructor(e={}){Object.assign(this,e)}};e.PFX=a,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer})],a.prototype,`version`,void 0),t.__decorate([(0,n.AsnProp)({type:r.ContentInfo})],a.prototype,`authSafe`,void 0),t.__decorate([(0,n.AsnProp)({type:i.MacData,optional:!0})],a.prototype,`macData`,void 0)})),Ko=M((e=>{var t;Object.defineProperty(e,"__esModule",{value:!0}),e.SafeContents=e.SafeBag=void 0;let n=(X(),P(Y)),r=Z(),i=jo();var a=class{bagId=``;bagValue=new ArrayBuffer(0);bagAttributes;constructor(e={}){Object.assign(this,e)}};e.SafeBag=a,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.ObjectIdentifier})],a.prototype,`bagId`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Any,context:0})],a.prototype,`bagValue`,void 0),n.__decorate([(0,r.AsnProp)({type:i.PKCS12Attribute,repeated:`set`,optional:!0})],a.prototype,`bagAttributes`,void 0);let o=t=class extends r.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,t.prototype)}};e.SafeContents=o,e.SafeContents=o=t=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Sequence,itemType:a})],o)})),qo=M((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=(X(),P(Y));t.__exportStar(jo(),e),t.__exportStar(Mo(),e),t.__exportStar(Uo(),e),t.__exportStar(Wo(),e),t.__exportStar(No(),e),t.__exportStar(Go(),e),t.__exportStar(Ko(),e)})),Jo=M((e=>{var t,n,r;Object.defineProperty(e,"__esModule",{value:!0}),e.DateOfBirth=e.UnstructuredAddress=e.UnstructuredName=e.EmailAddress=e.EncryptedPrivateKeyInfo=e.UserPKCS12=e.Pkcs7PDU=e.PKCS9String=e.id_at_pseudonym=e.crlTypes=e.id_certTypes=e.id_smime=e.id_pkcs9_mr_signingTimeMatch=e.id_pkcs9_mr_caseIgnoreMatch=e.id_pkcs9_sx_signingTime=e.id_pkcs9_sx_pkcs9String=e.id_pkcs9_at_countryOfResidence=e.id_pkcs9_at_countryOfCitizenship=e.id_pkcs9_at_gender=e.id_pkcs9_at_placeOfBirth=e.id_pkcs9_at_dateOfBirth=e.id_ietf_at=e.id_pkcs9_at_pkcs7PDU=e.id_pkcs9_at_sequenceNumber=e.id_pkcs9_at_randomNonce=e.id_pkcs9_at_encryptedPrivateKeyInfo=e.id_pkcs9_at_pkcs15Token=e.id_pkcs9_at_userPKCS12=e.id_pkcs9_at_localKeyId=e.id_pkcs9_at_friendlyName=e.id_pkcs9_at_smimeCapabilities=e.id_pkcs9_at_extensionRequest=e.id_pkcs9_at_signingDescription=e.id_pkcs9_at_extendedCertificateAttributes=e.id_pkcs9_at_unstructuredAddress=e.id_pkcs9_at_challengePassword=e.id_pkcs9_at_counterSignature=e.id_pkcs9_at_signingTime=e.id_pkcs9_at_messageDigest=e.id_pkcs9_at_contentType=e.id_pkcs9_at_unstructuredName=e.id_pkcs9_at_emailAddress=e.id_pkcs9_oc_naturalPerson=e.id_pkcs9_oc_pkcsEntity=e.id_pkcs9_mr=e.id_pkcs9_sx=e.id_pkcs9_at=e.id_pkcs9_oc=e.id_pkcs9_mo=e.id_pkcs9=void 0,e.SMIMECapabilities=e.SMIMECapability=e.SigningDescription=e.LocalKeyId=e.FriendlyName=e.ExtendedCertificateAttributes=e.ExtensionRequest=e.ChallengePassword=e.CounterSignature=e.SequenceNumber=e.RandomNonce=e.SigningTime=e.MessageDigest=e.ContentType=e.Pseudonym=e.CountryOfResidence=e.CountryOfCitizenship=e.Gender=e.PlaceOfBirth=void 0;let i=(X(),P(Y)),a=Z(),o=i.__importStar(sa()),s=i.__importStar(qo()),c=i.__importStar(zo()),l=i.__importStar($()),u=i.__importStar(Wi());e.id_pkcs9=`1.2.840.113549.1.9`,e.id_pkcs9_mo=`${e.id_pkcs9}.0`,e.id_pkcs9_oc=`${e.id_pkcs9}.24`,e.id_pkcs9_at=`${e.id_pkcs9}.25`,e.id_pkcs9_sx=`${e.id_pkcs9}.26`,e.id_pkcs9_mr=`${e.id_pkcs9}.27`,e.id_pkcs9_oc_pkcsEntity=`${e.id_pkcs9_oc}.1`,e.id_pkcs9_oc_naturalPerson=`${e.id_pkcs9_oc}.2`,e.id_pkcs9_at_emailAddress=`${e.id_pkcs9}.1`,e.id_pkcs9_at_unstructuredName=`${e.id_pkcs9}.2`,e.id_pkcs9_at_contentType=`${e.id_pkcs9}.3`,e.id_pkcs9_at_messageDigest=`${e.id_pkcs9}.4`,e.id_pkcs9_at_signingTime=`${e.id_pkcs9}.5`,e.id_pkcs9_at_counterSignature=`${e.id_pkcs9}.6`,e.id_pkcs9_at_challengePassword=`${e.id_pkcs9}.7`,e.id_pkcs9_at_unstructuredAddress=`${e.id_pkcs9}.8`,e.id_pkcs9_at_extendedCertificateAttributes=`${e.id_pkcs9}.9`,e.id_pkcs9_at_signingDescription=`${e.id_pkcs9}.13`,e.id_pkcs9_at_extensionRequest=`${e.id_pkcs9}.14`,e.id_pkcs9_at_smimeCapabilities=`${e.id_pkcs9}.15`,e.id_pkcs9_at_friendlyName=`${e.id_pkcs9}.20`,e.id_pkcs9_at_localKeyId=`${e.id_pkcs9}.21`,e.id_pkcs9_at_userPKCS12=`2.16.840.1.113730.3.1.216`,e.id_pkcs9_at_pkcs15Token=`${e.id_pkcs9_at}.1`,e.id_pkcs9_at_encryptedPrivateKeyInfo=`${e.id_pkcs9_at}.2`,e.id_pkcs9_at_randomNonce=`${e.id_pkcs9_at}.3`,e.id_pkcs9_at_sequenceNumber=`${e.id_pkcs9_at}.4`,e.id_pkcs9_at_pkcs7PDU=`${e.id_pkcs9_at}.5`,e.id_ietf_at=`1.3.6.1.5.5.7.9`,e.id_pkcs9_at_dateOfBirth=`${e.id_ietf_at}.1`,e.id_pkcs9_at_placeOfBirth=`${e.id_ietf_at}.2`,e.id_pkcs9_at_gender=`${e.id_ietf_at}.3`,e.id_pkcs9_at_countryOfCitizenship=`${e.id_ietf_at}.4`,e.id_pkcs9_at_countryOfResidence=`${e.id_ietf_at}.5`,e.id_pkcs9_sx_pkcs9String=`${e.id_pkcs9_sx}.1`,e.id_pkcs9_sx_signingTime=`${e.id_pkcs9_sx}.2`,e.id_pkcs9_mr_caseIgnoreMatch=`${e.id_pkcs9_mr}.1`,e.id_pkcs9_mr_signingTimeMatch=`${e.id_pkcs9_mr}.2`,e.id_smime=`${e.id_pkcs9}.16`,e.id_certTypes=`${e.id_pkcs9}.22`,e.crlTypes=`${e.id_pkcs9}.23`,e.id_at_pseudonym=`${u.id_at}.65`;let d=class extends l.DirectoryString{ia5String;constructor(e={}){super(e)}toString(){return{}.toString(),this.ia5String||super.toString()}};e.PKCS9String=d,i.__decorate([(0,a.AsnProp)({type:a.AsnPropTypes.IA5String})],d.prototype,`ia5String`,void 0),e.PKCS9String=d=i.__decorate([(0,a.AsnType)({type:a.AsnTypeTypes.Choice})],d);let f=class extends o.ContentInfo{};e.Pkcs7PDU=f,e.Pkcs7PDU=f=i.__decorate([(0,a.AsnType)({type:a.AsnTypeTypes.Sequence})],f);let p=class extends s.PFX{};e.UserPKCS12=p,e.UserPKCS12=p=i.__decorate([(0,a.AsnType)({type:a.AsnTypeTypes.Sequence})],p);let m=class extends c.EncryptedPrivateKeyInfo{};e.EncryptedPrivateKeyInfo=m,e.EncryptedPrivateKeyInfo=m=i.__decorate([(0,a.AsnType)({type:a.AsnTypeTypes.Sequence})],m);let h=class{value;constructor(e=``){this.value=e}toString(){return this.value}};e.EmailAddress=h,i.__decorate([(0,a.AsnProp)({type:a.AsnPropTypes.IA5String})],h.prototype,`value`,void 0),e.EmailAddress=h=i.__decorate([(0,a.AsnType)({type:a.AsnTypeTypes.Choice})],h);let g=class extends d{};e.UnstructuredName=g,e.UnstructuredName=g=i.__decorate([(0,a.AsnType)({type:a.AsnTypeTypes.Choice})],g);let _=class extends l.DirectoryString{};e.UnstructuredAddress=_,e.UnstructuredAddress=_=i.__decorate([(0,a.AsnType)({type:a.AsnTypeTypes.Choice})],_);let v=class{value;constructor(e=new Date){this.value=e}};e.DateOfBirth=v,i.__decorate([(0,a.AsnProp)({type:a.AsnPropTypes.GeneralizedTime})],v.prototype,`value`,void 0),e.DateOfBirth=v=i.__decorate([(0,a.AsnType)({type:a.AsnTypeTypes.Choice})],v);let y=class extends l.DirectoryString{};e.PlaceOfBirth=y,e.PlaceOfBirth=y=i.__decorate([(0,a.AsnType)({type:a.AsnTypeTypes.Choice})],y);let b=class{value;constructor(e=`M`){this.value=e}toString(){return this.value}};e.Gender=b,i.__decorate([(0,a.AsnProp)({type:a.AsnPropTypes.PrintableString})],b.prototype,`value`,void 0),e.Gender=b=i.__decorate([(0,a.AsnType)({type:a.AsnTypeTypes.Choice})],b);let x=class{value;constructor(e=``){this.value=e}toString(){return this.value}};e.CountryOfCitizenship=x,i.__decorate([(0,a.AsnProp)({type:a.AsnPropTypes.PrintableString})],x.prototype,`value`,void 0),e.CountryOfCitizenship=x=i.__decorate([(0,a.AsnType)({type:a.AsnTypeTypes.Choice})],x);let S=class extends x{};e.CountryOfResidence=S,e.CountryOfResidence=S=i.__decorate([(0,a.AsnType)({type:a.AsnTypeTypes.Choice})],S);let C=class extends l.DirectoryString{};e.Pseudonym=C,e.Pseudonym=C=i.__decorate([(0,a.AsnType)({type:a.AsnTypeTypes.Choice})],C);let w=class{value;constructor(e=``){this.value=e}toString(){return this.value}};e.ContentType=w,i.__decorate([(0,a.AsnProp)({type:a.AsnPropTypes.ObjectIdentifier})],w.prototype,`value`,void 0),e.ContentType=w=i.__decorate([(0,a.AsnType)({type:a.AsnTypeTypes.Choice})],w),e.MessageDigest=class extends a.OctetString{};let T=class extends l.Time{};e.SigningTime=T,e.SigningTime=T=i.__decorate([(0,a.AsnType)({type:a.AsnTypeTypes.Choice})],T),e.RandomNonce=class extends a.OctetString{};let ee=class{value;constructor(e=0){this.value=e}toString(){return this.value.toString()}};e.SequenceNumber=ee,i.__decorate([(0,a.AsnProp)({type:a.AsnPropTypes.Integer})],ee.prototype,`value`,void 0),e.SequenceNumber=ee=i.__decorate([(0,a.AsnType)({type:a.AsnTypeTypes.Choice})],ee);let E=class extends o.SignerInfo{};e.CounterSignature=E,e.CounterSignature=E=i.__decorate([(0,a.AsnType)({type:a.AsnTypeTypes.Sequence})],E);let D=class extends l.DirectoryString{};e.ChallengePassword=D,e.ChallengePassword=D=i.__decorate([(0,a.AsnType)({type:a.AsnTypeTypes.Choice})],D);let O=t=class extends l.Extensions{constructor(e){super(e),Object.setPrototypeOf(this,t.prototype)}};e.ExtensionRequest=O,e.ExtensionRequest=O=t=i.__decorate([(0,a.AsnType)({type:a.AsnTypeTypes.Sequence})],O);let k=n=class extends a.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype)}};e.ExtendedCertificateAttributes=k,e.ExtendedCertificateAttributes=k=n=i.__decorate([(0,a.AsnType)({type:a.AsnTypeTypes.Set,itemType:o.Attribute})],k);let te=class{value;constructor(e=``){this.value=e}toString(){return this.value}};e.FriendlyName=te,i.__decorate([(0,a.AsnProp)({type:a.AsnPropTypes.BmpString})],te.prototype,`value`,void 0),e.FriendlyName=te=i.__decorate([(0,a.AsnType)({type:a.AsnTypeTypes.Choice})],te),e.LocalKeyId=class extends a.OctetString{},e.SigningDescription=class extends l.DirectoryString{};let A=class extends l.AlgorithmIdentifier{};e.SMIMECapability=A,e.SMIMECapability=A=i.__decorate([(0,a.AsnType)({type:a.AsnTypeTypes.Sequence})],A);let j=r=class extends a.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,r.prototype)}};e.SMIMECapabilities=j,e.SMIMECapabilities=j=r=i.__decorate([(0,a.AsnType)({type:a.AsnTypeTypes.Sequence,itemType:A})],j)})),Yo=M((e=>{var t;Object.defineProperty(e,"__esModule",{value:!0}),e.Attributes=void 0;let n=(X(),P(Y)),r=Z(),i=$(),a=t=class extends r.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,t.prototype)}};e.Attributes=a,e.Attributes=a=t=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Sequence,itemType:i.Attribute})],a)})),Xo=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.CertificationRequestInfo=void 0;let t=(X(),P(Y)),n=Z(),r=$(),i=Yo();var a=class{version=0;subject=new r.Name;subjectPKInfo=new r.SubjectPublicKeyInfo;attributes=new i.Attributes;constructor(e={}){Object.assign(this,e)}};e.CertificationRequestInfo=a,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer})],a.prototype,`version`,void 0),t.__decorate([(0,n.AsnProp)({type:r.Name})],a.prototype,`subject`,void 0),t.__decorate([(0,n.AsnProp)({type:r.SubjectPublicKeyInfo})],a.prototype,`subjectPKInfo`,void 0),t.__decorate([(0,n.AsnProp)({type:i.Attributes,implicit:!0,context:0,optional:!0})],a.prototype,`attributes`,void 0)})),Zo=M((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.CertificationRequest=void 0;let t=(X(),P(Y)),n=Z(),r=$(),i=Xo();var a=class{certificationRequestInfo=new i.CertificationRequestInfo;certificationRequestInfoRaw;signatureAlgorithm=new r.AlgorithmIdentifier;signature=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.CertificationRequest=a,t.__decorate([(0,n.AsnProp)({type:i.CertificationRequestInfo,raw:!0})],a.prototype,`certificationRequestInfo`,void 0),t.__decorate([(0,n.AsnProp)({type:r.AlgorithmIdentifier})],a.prototype,`signatureAlgorithm`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.BitString})],a.prototype,`signature`,void 0)})),Qo=M((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=(X(),P(Y));t.__exportStar(Yo(),e),t.__exportStar(Zo(),e),t.__exportStar(Xo(),e)})),$o=M((e=>{
108
+ /*!
109
+ * MIT License
110
+ *
111
+ * Copyright (c) Peculiar Ventures. All rights reserved.
112
+ *
113
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
114
+ * of this software and associated documentation files (the "Software"), to deal
115
+ * in the Software without restriction, including without limitation the rights
116
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
117
+ * copies of the Software, and to permit persons to whom the Software is
118
+ * furnished to do so, subject to the following conditions:
119
+ *
120
+ * The above copyright notice and this permission notice shall be included in all
121
+ * copies or substantial portions of the Software.
122
+ *
123
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
124
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
125
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
126
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
127
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
128
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
129
+ * SOFTWARE.
130
+ *
131
+ */
132
+ mn();var t=Z(),n=$(),r=Qn(),i=sa(),a=ma(),o=wa(),s=(X(),P(Y)),c=Ao(),l=Jo(),u=Qo();function d(e){var t=Object.create(null);return e&&Object.keys(e).forEach(function(n){if(n!=="default"){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}}),t.default=e,Object.freeze(t)}var f=d(n),p=d(i),m=d(a),h=d(o),g=d(l);let _=`crypto.algorithm`;var v=class{getAlgorithms(){return c.container.resolveAll(_)}toAsnAlgorithm(e){({...e});for(let t of this.getAlgorithms()){let n=t.toAsnAlgorithm(e);if(n)return n}if(/^[0-9.]+$/.test(e.name)){let t=new n.AlgorithmIdentifier({algorithm:e.name});return`parameters`in e&&(t.parameters=e.parameters),t}throw Error(`Cannot convert WebCrypto algorithm to ASN.1 algorithm`)}toWebAlgorithm(e){for(let t of this.getAlgorithms()){let n=t.toWebAlgorithm(e);if(n)return n}return{name:e.algorithm,parameters:e.parameters}}};let y=`crypto.algorithmProvider`;c.container.registerSingleton(y,v);var b;let x=`1.3.36.3.3.2.8.1.1`,S=`${x}.1`,C=`${x}.2`,w=`${x}.3`,T=`${x}.4`,ee=`${x}.5`,E=`${x}.6`,D=`${x}.7`,O=`${x}.8`,k=`${x}.9`,te=`${x}.10`,A=`${x}.11`,j=`${x}.12`,ne=`${x}.13`,re=`${x}.14`,M=`brainpoolP160r1`,N=`brainpoolP160t1`,ie=`brainpoolP192r1`,ae=`brainpoolP192t1`,oe=`brainpoolP224r1`,se=`brainpoolP224t1`,ce=`brainpoolP256r1`,le=`brainpoolP256t1`,ue=`brainpoolP320r1`,de=`brainpoolP320t1`,fe=`brainpoolP384r1`,pe=`brainpoolP384t1`,me=`brainpoolP512r1`,he=`brainpoolP512t1`,F=`ECDSA`;e.EcAlgorithm=b=class{toAsnAlgorithm(e){switch(e.name.toLowerCase()){case`ecdsa`:if(`hash`in e)switch((typeof e.hash==`string`?e.hash:e.hash.name).toLowerCase()){case`sha-1`:return m.ecdsaWithSHA1;case`sha-256`:return m.ecdsaWithSHA256;case`sha-384`:return m.ecdsaWithSHA384;case`sha-512`:return m.ecdsaWithSHA512}else if(`namedCurve`in e){let r=``;switch(e.namedCurve){case`P-256`:r=m.id_secp256r1;break;case`K-256`:r=b.SECP256K1;break;case`P-384`:r=m.id_secp384r1;break;case`P-521`:r=m.id_secp521r1;break;case M:r=S;break;case N:r=C;break;case ie:r=w;break;case ae:r=T;break;case oe:r=ee;break;case se:r=E;break;case ce:r=D;break;case le:r=O;break;case ue:r=k;break;case de:r=te;break;case fe:r=A;break;case pe:r=j;break;case me:r=ne;break;case he:r=re;break}if(r)return new n.AlgorithmIdentifier({algorithm:m.id_ecPublicKey,parameters:t.AsnConvert.serialize(new m.ECParameters({namedCurve:r}))})}}return null}toWebAlgorithm(e){switch(e.algorithm){case m.id_ecdsaWithSHA1:return{name:F,hash:{name:`SHA-1`}};case m.id_ecdsaWithSHA256:return{name:F,hash:{name:`SHA-256`}};case m.id_ecdsaWithSHA384:return{name:F,hash:{name:`SHA-384`}};case m.id_ecdsaWithSHA512:return{name:F,hash:{name:`SHA-512`}};case m.id_ecPublicKey:if(!e.parameters)throw TypeError(`Cannot get required parameters from EC algorithm`);switch(t.AsnConvert.parse(e.parameters,m.ECParameters).namedCurve){case m.id_secp256r1:return{name:F,namedCurve:`P-256`};case b.SECP256K1:return{name:F,namedCurve:`K-256`};case m.id_secp384r1:return{name:F,namedCurve:`P-384`};case m.id_secp521r1:return{name:F,namedCurve:`P-521`};case S:return{name:F,namedCurve:M};case C:return{name:F,namedCurve:N};case w:return{name:F,namedCurve:ie};case T:return{name:F,namedCurve:ae};case ee:return{name:F,namedCurve:oe};case E:return{name:F,namedCurve:se};case D:return{name:F,namedCurve:ce};case O:return{name:F,namedCurve:le};case k:return{name:F,namedCurve:ue};case te:return{name:F,namedCurve:de};case A:return{name:F,namedCurve:fe};case j:return{name:F,namedCurve:pe};case ne:return{name:F,namedCurve:me};case re:return{name:F,namedCurve:he}}}return null}},e.EcAlgorithm.SECP256K1=`1.3.132.0.10`,e.EcAlgorithm=b=s.__decorate([c.injectable()],e.EcAlgorithm),c.container.registerSingleton(_,e.EcAlgorithm);let ge=Symbol(`name`),_e=Symbol(`value`);var I=class{constructor(e,t={},n=``){this[ge]=e,this[_e]=n;for(let e in t)this[e]=t[e]}};I.NAME=ge,I.VALUE=_e;var ve=class{static toTextObject(t){let n=new I(`Algorithm Identifier`,{},ye.toString(t.algorithm));if(t.parameters)switch(t.algorithm){case m.id_ecPublicKey:{let r=new e.EcAlgorithm().toWebAlgorithm(t);r&&`namedCurve`in r?n[`Named Curve`]=r.namedCurve:n.Parameters=t.parameters;break}default:n.Parameters=t.parameters}return n}},ye=class{static toString(e){return this.items[e]||e}};ye.items={[h.id_sha1]:`sha1`,[h.id_sha224]:`sha224`,[h.id_sha256]:`sha256`,[h.id_sha384]:`sha384`,[h.id_sha512]:`sha512`,[h.id_rsaEncryption]:`rsaEncryption`,[h.id_sha1WithRSAEncryption]:`sha1WithRSAEncryption`,[h.id_sha224WithRSAEncryption]:`sha224WithRSAEncryption`,[h.id_sha256WithRSAEncryption]:`sha256WithRSAEncryption`,[h.id_sha384WithRSAEncryption]:`sha384WithRSAEncryption`,[h.id_sha512WithRSAEncryption]:`sha512WithRSAEncryption`,[m.id_ecPublicKey]:`ecPublicKey`,[m.id_ecdsaWithSHA1]:`ecdsaWithSHA1`,[m.id_ecdsaWithSHA224]:`ecdsaWithSHA224`,[m.id_ecdsaWithSHA256]:`ecdsaWithSHA256`,[m.id_ecdsaWithSHA384]:`ecdsaWithSHA384`,[m.id_ecdsaWithSHA512]:`ecdsaWithSHA512`,[f.id_kp_serverAuth]:`TLS WWW server authentication`,[f.id_kp_clientAuth]:`TLS WWW client authentication`,[f.id_kp_codeSigning]:`Code Signing`,[f.id_kp_emailProtection]:`E-mail Protection`,[f.id_kp_timeStamping]:`Time Stamping`,[f.id_kp_OCSPSigning]:`OCSP Signing`,[p.id_signedData]:`Signed Data`};var be=class{static serialize(e){return this.serializeObj(e).join(`
133
+ `)}static pad(e=0){return``.padStart(2*e,` `)}static serializeObj(e,t=0){let n=[],i=this.pad(t++),a=``,o=e[I.VALUE];o&&(a=` ${o}`),n.push(`${i}${e[I.NAME]}:${a}`),i=this.pad(t);for(let a in e){if(typeof a==`symbol`)continue;let o=e[a],s=a?`${a}: `:``;if(typeof o==`string`||typeof o==`number`||typeof o==`boolean`)n.push(`${i}${s}${o}`);else if(o instanceof Date)n.push(`${i}${s}${o.toUTCString()}`);else if(Array.isArray(o))for(let e of o)e[I.NAME]=a,n.push(...this.serializeObj(e,t));else if(o instanceof I)o[I.NAME]=a,n.push(...this.serializeObj(o,t));else if(r.BufferSourceConverter.isBufferSource(o))a?(n.push(`${i}${s}`),n.push(...this.serializeBufferSource(o,t+1))):n.push(...this.serializeBufferSource(o,t));else if(`toTextObject`in o){let e=o.toTextObject();e[I.NAME]=a,n.push(...this.serializeObj(e,t))}else throw TypeError(`Cannot serialize data in text format. Unsupported type.`)}return n}static serializeBufferSource(e,t=0){let n=this.pad(t),i=r.BufferSourceConverter.toUint8Array(e),a=[];for(let e=0;e<i.length;){let t=[];for(let n=0;n<16&&e<i.length;n++){n===8&&t.push(``);let r=i[e++].toString(16).padStart(2,`0`);t.push(r)}a.push(`${n}${t.join(` `)}`)}return a}static serializeAlgorithm(e){return this.algorithmSerializer.toTextObject(e)}};be.oidSerializer=ye,be.algorithmSerializer=ve;var xe=class e{constructor(...e){if(e.length===1){let n=e[0];this.rawData=t.AsnConvert.serialize(n),this.onInit(n)}else{let n=t.AsnConvert.parse(e[0],e[1]);this.rawData=r.BufferSourceConverter.toArrayBuffer(e[0]),this.onInit(n)}}equal(t){return t instanceof e?r.isEqual(t.rawData,this.rawData):!1}toString(e=`text`){switch(e){case`asn`:return t.AsnConvert.toString(this.rawData);case`text`:return be.serialize(this.toTextObject());case`hex`:return r.Convert.ToHex(this.rawData);case`base64`:return r.Convert.ToBase64(this.rawData);case`base64url`:return r.Convert.ToBase64Url(this.rawData);default:throw TypeError(`Argument 'format' is unsupported value`)}}getTextName(){return this.constructor.NAME}toTextObject(){let e=this.toTextObjectEmpty();return e[``]=this.rawData,e}toTextObjectEmpty(e){return new I(this.getTextName(),{},e)}};xe.NAME=`ASN`;var L=class e extends xe{constructor(...e){let i;i=r.BufferSourceConverter.isBufferSource(e[0])?r.BufferSourceConverter.toArrayBuffer(e[0]):t.AsnConvert.serialize(new n.Extension({extnID:e[0],critical:e[1],extnValue:new t.OctetString(r.BufferSourceConverter.toArrayBuffer(e[2]))})),super(i,n.Extension)}onInit(e){this.type=e.extnID,this.critical=e.critical,this.value=e.extnValue.buffer}toTextObject(){let e=this.toTextObjectWithoutValue();return e[``]=this.value,e}toTextObjectWithoutValue(){let t=this.toTextObjectEmpty(this.critical?`critical`:void 0);return t[I.NAME]===e.NAME&&(t[I.NAME]=ye.toString(this.type)),t}},Se,Ce=class e{static isCryptoKeyPair(e){return e&&e.privateKey&&e.publicKey}static isCryptoKey(e){return e&&e.usages&&e.type&&e.algorithm&&e.extractable!==void 0}constructor(){this.items=new Map,this[Se]=`CryptoProvider`,typeof self<`u`&&typeof crypto<`u`?this.set(e.DEFAULT,crypto):typeof global<`u`&&global.crypto&&global.crypto.subtle&&this.set(e.DEFAULT,global.crypto)}clear(){this.items.clear()}delete(e){return this.items.delete(e)}forEach(e,t){return this.items.forEach(e,t)}has(e){return this.items.has(e)}get size(){return this.items.size}entries(){return this.items.entries()}keys(){return this.items.keys()}values(){return this.items.values()}[Symbol.iterator](){return this.items[Symbol.iterator]()}get(t=e.DEFAULT){let n=this.items.get(t.toLowerCase());if(!n)throw Error(`Cannot get Crypto by name '${t}'`);return n}set(t,n){if(typeof t==`string`){if(!n)throw TypeError(`Argument 'value' is required`);this.items.set(t.toLowerCase(),n)}else this.items.set(e.DEFAULT,t);return this}};Se=Symbol.toStringTag,Ce.DEFAULT=`default`;let R=new Ce,we=/^[0-2](?:\.[1-9][0-9]*)+$/;function Te(e){return new RegExp(we).test(e)}var Ee=class{constructor(e={}){this.items={};for(let t in e)this.register(t,e[t])}get(e){return this.items[e]||null}findId(e){return Te(e)?e:this.get(e)}register(e,t){this.items[e]=t,this.items[t]=e}};let z=new Ee;z.register(`CN`,`2.5.4.3`),z.register(`L`,`2.5.4.7`),z.register(`ST`,`2.5.4.8`),z.register(`O`,`2.5.4.10`),z.register(`OU`,`2.5.4.11`),z.register(`C`,`2.5.4.6`),z.register(`DC`,`0.9.2342.19200300.100.1.25`),z.register(`E`,`1.2.840.113549.1.9.1`),z.register(`G`,`2.5.4.42`),z.register(`I`,`2.5.4.43`),z.register(`SN`,`2.5.4.4`),z.register(`T`,`2.5.4.12`);function De(e,t){return`\\${r.Convert.ToHex(r.Convert.FromUtf8String(t)).toUpperCase()}`}function B(e){return e.replace(/([,+"\\<>;])/g,`\\$1`).replace(/^([ #])/,`\\$1`).replace(/([ ]$)/,`\\$1`).replace(/([\r\n\t])/,De)}var V=class e{static isASCII(e){for(let t=0;t<e.length;t++)if(e.charCodeAt(t)>255)return!1;return!0}static isPrintableString(e){return/^[A-Za-z0-9 '()+,-./:=?]*$/g.test(e)}constructor(e,i={}){this.extraNames=new Ee,this.asn=new n.Name;for(let e in i)if(Object.prototype.hasOwnProperty.call(i,e)){let t=i[e];this.extraNames.register(e,t)}typeof e==`string`?this.asn=this.fromString(e):e instanceof n.Name?this.asn=e:r.BufferSourceConverter.isBufferSource(e)?this.asn=t.AsnConvert.parse(e,n.Name):this.asn=this.fromJSON(e)}getField(e){let t=this.extraNames.findId(e)||z.findId(e),n=[];for(let e of this.asn)for(let r of e)r.type===t&&n.push(r.value.toString());return n}getName(e){return this.extraNames.get(e)||z.get(e)}toString(){return this.asn.map(e=>e.map(e=>`${this.getName(e.type)||e.type}=${e.value.anyValue?`#${r.Convert.ToHex(e.value.anyValue)}`:B(e.value.toString())}`).join(`+`)).join(`, `)}toJSON(){let e=[];for(let t of this.asn){let n={};for(let e of t){let t=this.getName(e.type)||e.type;n[t]??(n[t]=[]),n[t].push(e.value.anyValue?`#${r.Convert.ToHex(e.value.anyValue)}`:e.value.toString())}e.push(n)}return e}fromString(e){let t=new n.Name,r=/(\d\.[\d.]*\d|[A-Za-z]+)=((?:"")|(?:".*?[^\\]")|(?:[^,+].*?(?:[^\\][,+]))|(?:))([,+])?/g,i=null,a=`,`;for(;i=r.exec(`${e},`);){let[,e,r]=i,o=r[r.length-1];(o===`,`||o===`+`)&&(r=r.slice(0,r.length-1),i[3]=o);let s=i[3];e=this.getTypeOid(e);let c=this.createAttribute(e,r);a===`+`?t[t.length-1].push(c):t.push(new n.RelativeDistinguishedName([c])),a=s}return t}fromJSON(e){let t=new n.Name;for(let r of e){let e=new n.RelativeDistinguishedName;for(let t in r){let n=this.getTypeOid(t),i=r[t];for(let t of i){let r=this.createAttribute(n,t);e.push(r)}}t.push(e)}return t}getTypeOid(e){if(/[\d.]+/.test(e)||(e=this.getName(e)||``),!e)throw Error(`Cannot get OID for name type '${e}'`);return e}createAttribute(t,i){let a=new n.AttributeTypeAndValue({type:t});if(typeof i==`object`)for(let e in i)switch(e){case`ia5String`:a.value.ia5String=i[e];break;case`utf8String`:a.value.utf8String=i[e];break;case`universalString`:a.value.universalString=i[e];break;case`bmpString`:a.value.bmpString=i[e];break;case`printableString`:a.value.printableString=i[e];break}else if(i[0]===`#`)a.value.anyValue=r.Convert.FromHex(i.slice(1));else{let n=this.processStringValue(i);t===this.getName(`E`)||t===this.getName(`DC`)?a.value.ia5String=n:e.isPrintableString(n)?a.value.printableString=n:a.value.utf8String=n}return a}processStringValue(e){let t=/"(.*?[^\\])?"/.exec(e);return t&&(e=t[1]),e.replace(/\\0a/gi,`
134
+ `).replace(/\\0d/gi,`\r`).replace(/\\0g/gi,` `).replace(/\\(.)/g,`$1`)}toArrayBuffer(){return t.AsnConvert.serialize(this.asn)}async getThumbprint(...e){let t,n=`SHA-1`;return e.length>=1&&!e[0]?.subtle?(n=e[0]||n,t=e[1]||R.get()):t=e[0]||R.get(),await t.subtle.digest(n,this.toArrayBuffer())}};let Oe=`Cannot initialize GeneralName from ASN.1 data.`,ke=`${Oe} Unsupported string format in use.`,Ae=`${Oe} Value doesn't match to GUID regular expression.`,je=/^([0-9a-f]{8})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{12})$/i,Me=`1.3.6.1.4.1.311.25.1`,H=`1.3.6.1.4.1.311.20.2.3`,Ne=`email`,Pe=`guid`;var U=class extends xe{constructor(...e){let n;if(e.length===2)switch(e[0]){case`dn`:{let r=new V(e[1]).toArrayBuffer(),i=t.AsnConvert.parse(r,f.Name);n=new f.GeneralName({directoryName:i});break}case`dns`:n=new f.GeneralName({dNSName:e[1]});break;case Ne:n=new f.GeneralName({rfc822Name:e[1]});break;case Pe:{let i=new RegExp(je,`i`).exec(e[1]);if(!i)throw Error(`Cannot parse GUID value. Value doesn't match to regular expression`);let a=i.slice(1).map((e,t)=>t<3?r.Convert.ToHex(new Uint8Array(r.Convert.FromHex(e)).reverse()):e).join(``);n=new f.GeneralName({otherName:new f.OtherName({typeId:Me,value:t.AsnConvert.serialize(new t.OctetString(r.Convert.FromHex(a)))})});break}case`ip`:n=new f.GeneralName({iPAddress:e[1]});break;case`id`:n=new f.GeneralName({registeredID:e[1]});break;case`upn`:n=new f.GeneralName({otherName:new f.OtherName({typeId:H,value:t.AsnConvert.serialize(t.AsnUtf8StringConverter.toASN(e[1]))})});break;case`url`:n=new f.GeneralName({uniformResourceIdentifier:e[1]});break;default:throw Error(`Cannot create GeneralName. Unsupported type of the name`)}else n=r.BufferSourceConverter.isBufferSource(e[0])?t.AsnConvert.parse(e[0],f.GeneralName):e[0];super(n)}onInit(e){if(e.dNSName!=null)this.type=`dns`,this.value=e.dNSName;else if(e.rfc822Name!=null)this.type=Ne,this.value=e.rfc822Name;else if(e.iPAddress!=null)this.type=`ip`,this.value=e.iPAddress;else if(e.uniformResourceIdentifier!=null)this.type=`url`,this.value=e.uniformResourceIdentifier;else if(e.registeredID!=null)this.type=`id`,this.value=e.registeredID;else if(e.directoryName!=null)this.type=`dn`,this.value=new V(e.directoryName).toString();else if(e.otherName!=null)if(e.otherName.typeId===Me){this.type=Pe;let n=t.AsnConvert.parse(e.otherName.value,t.OctetString),i=new RegExp(je,`i`).exec(r.Convert.ToHex(n));if(!i)throw Error(Ae);this.value=i.slice(1).map((e,t)=>t<3?r.Convert.ToHex(new Uint8Array(r.Convert.FromHex(e)).reverse()):e).join(`-`)}else if(e.otherName.typeId===H)this.type=`upn`,this.value=t.AsnConvert.parse(e.otherName.value,f.DirectoryString).toString();else throw Error(ke);else throw Error(ke)}toJSON(){return{type:this.type,value:this.value}}toTextObject(){let e;switch(this.type){case`dn`:case`dns`:case Pe:case`ip`:case`id`:case`upn`:case`url`:e=this.type.toUpperCase();break;case Ne:e=`Email`;break;default:throw Error(`Unsupported GeneralName type`)}let t=this.value;return this.type===`id`&&(t=ye.toString(t)),new I(e,void 0,t)}},Fe=class extends xe{constructor(e){let n;if(e instanceof f.GeneralNames)n=e;else if(Array.isArray(e)){let r=[];for(let n of e)if(n instanceof f.GeneralName)r.push(n);else{let e=t.AsnConvert.parse(new U(n.type,n.value).rawData,f.GeneralName);r.push(e)}n=new f.GeneralNames(r)}else if(r.BufferSourceConverter.isBufferSource(e))n=t.AsnConvert.parse(e,f.GeneralNames);else throw Error(`Cannot initialize GeneralNames. Incorrect incoming arguments`);super(n)}onInit(e){let t=[];for(let n of e){let e=null;try{e=new U(n)}catch{continue}t.push(e)}this.items=t}toJSON(){return this.items.map(e=>e.toJSON())}toTextObject(){let e=super.toTextObjectEmpty();for(let t of this.items){let n=t.toTextObject(),r=e[n[I.NAME]];Array.isArray(r)||(r=[],e[n[I.NAME]]=r),r.push(n)}return e}};Fe.NAME=`GeneralNames`;let Ie=`-{5}`,Le=`${`${Ie}BEGIN ([^\\n]+(?=${Ie}))${Ie}`}\\n(?:((?:[^:\\n]+: (?:[^\\n]+\\n(?: +[^\\n]+\\n)*))+))?\\n?((?:[a-zA-Z0-9=+/]+\\n)+)${`${Ie}END \\1${Ie}`}`;var W=class{static isPem(e){return typeof e==`string`&&new RegExp(Le,`g`).test(e)}static decodeWithHeaders(e){e=e.replace(/\r/g,``);let t=new RegExp(Le,`g`),n=[],i=null;for(;i=t.exec(e);){let e=i[3].replace(RegExp(`[\\n]+`,`g`),``),t={type:i[1],headers:[],rawData:r.Convert.FromBase64(e)},a=i[2];if(a){let e=a.split(RegExp(`\\n`,`g`)),n=null;for(let r of e){let[e,i]=r.split(/:(.*)/);if(i===void 0){if(!n)throw Error(`Cannot parse PEM string. Incorrect header value`);n.value+=e.trim()}else n&&t.headers.push(n),n={key:e,value:i.trim()}}n&&t.headers.push(n)}n.push(t)}return n}static decode(e){return this.decodeWithHeaders(e).map(e=>e.rawData)}static decodeFirst(e){let t=this.decode(e);if(!t.length)throw RangeError(`PEM string doesn't contain any objects`);return t[0]}static encode(e,t){if(Array.isArray(e)){let n=[];return t?e.forEach(e=>{if(!r.BufferSourceConverter.isBufferSource(e))throw TypeError(`Cannot encode array of BufferSource in PEM format. Not all items of the array are BufferSource`);n.push(this.encodeStruct({type:t,rawData:r.BufferSourceConverter.toArrayBuffer(e)}))}):e.forEach(e=>{if(!(`type`in e))throw TypeError(`Cannot encode array of PemStruct in PEM format. Not all items of the array are PemStrut`);n.push(this.encodeStruct(e))}),n.join(`
135
+ `)}else{if(!t)throw Error(`Required argument 'tag' is missed`);return this.encodeStruct({type:t,rawData:r.BufferSourceConverter.toArrayBuffer(e)})}}static encodeStruct(e){let t=e.type.toLocaleUpperCase(),n=[];if(n.push(`-----BEGIN ${t}-----`),e.headers?.length){for(let t of e.headers)n.push(`${t.key}: ${t.value}`);n.push(``)}let i=r.Convert.ToBase64(e.rawData),a,o=0,s=[];for(;o<i.length&&(i.length-o<64?a=i.substring(o):(a=i.substring(o,o+64),o+=64),a.length!==0)&&(s.push(a),!(a.length<64)););return n.push(...s),n.push(`-----END ${t}-----`),n.join(`
136
+ `)}};W.CertificateTag=`CERTIFICATE`,W.CrlTag=`CRL`,W.CertificateRequestTag=`CERTIFICATE REQUEST`,W.PublicKeyTag=`PUBLIC KEY`,W.PrivateKeyTag=`PRIVATE KEY`;var Re=class e extends xe{static isAsnEncoded(e){return r.BufferSourceConverter.isBufferSource(e)||typeof e==`string`}static toArrayBuffer(e){if(typeof e==`string`){if(W.isPem(e))return W.decode(e)[0];if(r.Convert.isHex(e))return r.Convert.FromHex(e);if(r.Convert.isBase64(e))return r.Convert.FromBase64(e);if(r.Convert.isBase64Url(e))return r.Convert.FromBase64Url(e);throw TypeError(`Unsupported format of 'raw' argument. Must be one of DER, PEM, HEX, Base64, or Base4Url`)}else{let t=r.Convert.ToBinary(e);return W.isPem(t)?W.decode(t)[0]:r.Convert.isHex(t)?r.Convert.FromHex(t):r.Convert.isBase64(t)?r.Convert.FromBase64(t):r.Convert.isBase64Url(t)?r.Convert.FromBase64Url(t):r.BufferSourceConverter.toArrayBuffer(e)}}constructor(...t){e.isAsnEncoded(t[0])?super(e.toArrayBuffer(t[0]),t[1]):super(t[0])}toString(e=`pem`){switch(e){case`pem`:return W.encode(this.rawData,this.tag);default:return super.toString(e)}}},ze=class e extends Re{static async create(t,n=R.get()){if(t instanceof e)return t;if(Ce.isCryptoKey(t)){if(t.type!==`public`)throw TypeError(`Public key is required`);return new e(await n.subtle.exportKey(`spki`,t))}else if(t.publicKey)return t.publicKey;else if(r.BufferSourceConverter.isBufferSource(t))return new e(t);else throw TypeError(`Unsupported PublicKeyType`)}constructor(e){Re.isAsnEncoded(e)?super(e,n.SubjectPublicKeyInfo):super(e),this.tag=W.PublicKeyTag}async export(...e){let r,i=[`verify`],a={hash:`SHA-256`,...this.algorithm};e.length>1?(a=e[0]||a,i=e[1]||i,r=e[2]||R.get()):r=e[0]||R.get();let s=this.rawData,c=t.AsnConvert.parse(this.rawData,n.SubjectPublicKeyInfo);return c.algorithm.algorithm===o.id_RSASSA_PSS&&(s=Be(c,s)),r.subtle.importKey(`spki`,s,a,!0,i)}onInit(e){let n=c.container.resolve(y),i=this.algorithm=n.toWebAlgorithm(e.algorithm);switch(e.algorithm.algorithm){case o.id_rsaEncryption:{let n=t.AsnConvert.parse(e.subjectPublicKey,o.RSAPublicKey),a=r.BufferSourceConverter.toUint8Array(n.modulus);i.publicExponent=r.BufferSourceConverter.toUint8Array(n.publicExponent),i.modulusLength=(a[0]?a:a.slice(1)).byteLength<<3;break}}}async getThumbprint(...e){let t,n=`SHA-1`;return e.length>=1&&!e[0]?.subtle?(n=e[0]||n,t=e[1]||R.get()):t=e[0]||R.get(),await t.subtle.digest(n,this.rawData)}async getKeyIdentifier(...e){let r,i=`SHA-1`;e.length===1?typeof e[0]==`string`?(i=e[0],r=R.get()):r=e[0]:e.length===2?(i=e[0],r=e[1]):r=R.get();let a=t.AsnConvert.parse(this.rawData,n.SubjectPublicKeyInfo);return await r.subtle.digest(i,a.subjectPublicKey)}toTextObject(){let e=this.toTextObjectEmpty(),r=t.AsnConvert.parse(this.rawData,n.SubjectPublicKeyInfo);switch(e.Algorithm=be.serializeAlgorithm(r.algorithm),r.algorithm.algorithm){case a.id_ecPublicKey:e[`EC Point`]=r.subjectPublicKey;break;case o.id_rsaEncryption:default:e[`Raw Data`]=r.subjectPublicKey}return e}};function Be(e,r){return e.algorithm=new n.AlgorithmIdentifier({algorithm:o.id_rsaEncryption,parameters:null}),r=t.AsnConvert.serialize(e),r}var Ve=class e extends L{static async create(t,n=!1,i=R.get()){if(`name`in t&&`serialNumber`in t)return new e(t,n);let a=await(await ze.create(t,i)).getKeyIdentifier(i);return new e(r.Convert.ToHex(a),n)}constructor(...e){if(r.BufferSourceConverter.isBufferSource(e[0]))super(e[0]);else if(typeof e[0]==`string`){let n=new f.AuthorityKeyIdentifier({keyIdentifier:new f.KeyIdentifier(r.Convert.FromHex(e[0]))});super(f.id_ce_authorityKeyIdentifier,e[1],t.AsnConvert.serialize(n))}else{let n=e[0],i=n.name instanceof Fe?t.AsnConvert.parse(n.name.rawData,f.GeneralNames):n.name,a=new f.AuthorityKeyIdentifier({authorityCertIssuer:i,authorityCertSerialNumber:r.Convert.FromHex(n.serialNumber)});super(f.id_ce_authorityKeyIdentifier,e[1],t.AsnConvert.serialize(a))}}onInit(e){super.onInit(e);let n=t.AsnConvert.parse(e.extnValue,f.AuthorityKeyIdentifier);n.keyIdentifier&&(this.keyId=r.Convert.ToHex(n.keyIdentifier)),(n.authorityCertIssuer||n.authorityCertSerialNumber)&&(this.certId={name:n.authorityCertIssuer||[],serialNumber:n.authorityCertSerialNumber?r.Convert.ToHex(n.authorityCertSerialNumber):``})}toTextObject(){let e=this.toTextObjectWithoutValue(),n=t.AsnConvert.parse(this.value,f.AuthorityKeyIdentifier);return n.authorityCertIssuer&&(e[`Authority Issuer`]=new Fe(n.authorityCertIssuer).toTextObject()),n.authorityCertSerialNumber&&(e[`Authority Serial Number`]=n.authorityCertSerialNumber),n.keyIdentifier&&(e[``]=n.keyIdentifier),e}};Ve.NAME=`Authority Key Identifier`;var He=class extends L{constructor(...e){if(r.BufferSourceConverter.isBufferSource(e[0])){super(e[0]);let r=t.AsnConvert.parse(this.value,n.BasicConstraints);this.ca=r.cA,this.pathLength=r.pathLenConstraint}else{let r=new n.BasicConstraints({cA:e[0],pathLenConstraint:e[1]});super(n.id_ce_basicConstraints,e[2],t.AsnConvert.serialize(r)),this.ca=e[0],this.pathLength=e[1]}}toTextObject(){let e=this.toTextObjectWithoutValue();return this.ca&&(e.CA=this.ca),this.pathLength!==void 0&&(e[`Path Length`]=this.pathLength),e}};He.NAME=`Basic Constraints`,e.ExtendedKeyUsage=void 0,(function(e){e.serverAuth=`1.3.6.1.5.5.7.3.1`,e.clientAuth=`1.3.6.1.5.5.7.3.2`,e.codeSigning=`1.3.6.1.5.5.7.3.3`,e.emailProtection=`1.3.6.1.5.5.7.3.4`,e.timeStamping=`1.3.6.1.5.5.7.3.8`,e.ocspSigning=`1.3.6.1.5.5.7.3.9`})(e.ExtendedKeyUsage||={});var Ue=class extends L{constructor(...e){if(r.BufferSourceConverter.isBufferSource(e[0])){super(e[0]);let n=t.AsnConvert.parse(this.value,f.ExtendedKeyUsage);this.usages=n.map(e=>e)}else{let n=new f.ExtendedKeyUsage(e[0]);super(f.id_ce_extKeyUsage,e[1],t.AsnConvert.serialize(n)),this.usages=e[0]}}toTextObject(){let e=this.toTextObjectWithoutValue();return e[``]=this.usages.map(e=>ye.toString(e)).join(`, `),e}};Ue.NAME=`Extended Key Usages`,e.KeyUsageFlags=void 0,(function(e){e[e.digitalSignature=1]=`digitalSignature`,e[e.nonRepudiation=2]=`nonRepudiation`,e[e.keyEncipherment=4]=`keyEncipherment`,e[e.dataEncipherment=8]=`dataEncipherment`,e[e.keyAgreement=16]=`keyAgreement`,e[e.keyCertSign=32]=`keyCertSign`,e[e.cRLSign=64]=`cRLSign`,e[e.encipherOnly=128]=`encipherOnly`,e[e.decipherOnly=256]=`decipherOnly`})(e.KeyUsageFlags||={});var We=class extends L{constructor(...e){if(r.BufferSourceConverter.isBufferSource(e[0])){super(e[0]);let r=t.AsnConvert.parse(this.value,n.KeyUsage);this.usages=r.toNumber()}else{let r=new n.KeyUsage(e[0]);super(n.id_ce_keyUsage,e[1],t.AsnConvert.serialize(r)),this.usages=e[0]}}toTextObject(){let e=this.toTextObjectWithoutValue();return e[``]=t.AsnConvert.parse(this.value,n.KeyUsage).toJSON().join(`, `),e}};We.NAME=`Key Usages`;var Ge=class e extends L{static async create(t,n=!1,i=R.get()){let a=await(await ze.create(t,i)).getKeyIdentifier(i);return new e(r.Convert.ToHex(a),n)}constructor(...e){if(r.BufferSourceConverter.isBufferSource(e[0])){super(e[0]);let n=t.AsnConvert.parse(this.value,f.SubjectKeyIdentifier);this.keyId=r.Convert.ToHex(n)}else{let n=typeof e[0]==`string`?r.Convert.FromHex(e[0]):e[0],i=new f.SubjectKeyIdentifier(n);super(f.id_ce_subjectKeyIdentifier,e[1],t.AsnConvert.serialize(i)),this.keyId=r.Convert.ToHex(n)}}toTextObject(){let e=this.toTextObjectWithoutValue();return e[``]=t.AsnConvert.parse(this.value,f.SubjectKeyIdentifier),e}};Ge.NAME=`Subject Key Identifier`;var Ke=class extends L{constructor(...e){r.BufferSourceConverter.isBufferSource(e[0])?super(e[0]):super(f.id_ce_subjectAltName,e[1],new Fe(e[0]||[]).rawData)}onInit(e){super.onInit(e);let n=t.AsnConvert.parse(e.extnValue,f.SubjectAlternativeName);this.names=new Fe(n)}toTextObject(){let e=this.toTextObjectWithoutValue(),t=this.names.toTextObject();for(let n in t)e[n]=t[n];return e}};Ke.NAME=`Subject Alternative Name`;var G=class{static register(e,t){this.items.set(e,t)}static create(e){let t=new L(e),n=this.items.get(t.type);return n?new n(e):t}};G.items=new Map;var qe=class extends L{constructor(...e){if(r.BufferSourceConverter.isBufferSource(e[0])){super(e[0]);let n=t.AsnConvert.parse(this.value,f.CertificatePolicies);this.policies=n.map(e=>e.policyIdentifier)}else{let n=e[0],r=e[1]??!1,i=new f.CertificatePolicies(n.map(e=>new f.PolicyInformation({policyIdentifier:e})));super(f.id_ce_certificatePolicies,r,t.AsnConvert.serialize(i)),this.policies=n}}toTextObject(){let e=this.toTextObjectWithoutValue();return e.Policy=this.policies.map(e=>new I(``,{},ye.toString(e))),e}};qe.NAME=`Certificate Policies`,G.register(f.id_ce_certificatePolicies,qe);var Je=class extends L{constructor(...e){if(r.BufferSourceConverter.isBufferSource(e[0]))super(e[0]);else if(Array.isArray(e[0])&&typeof e[0][0]==`string`){let n=e[0].map(e=>new f.DistributionPoint({distributionPoint:new f.DistributionPointName({fullName:[new f.GeneralName({uniformResourceIdentifier:e})]})})),r=new f.CRLDistributionPoints(n);super(f.id_ce_cRLDistributionPoints,e[1],t.AsnConvert.serialize(r))}else{let n=new f.CRLDistributionPoints(e[0]);super(f.id_ce_cRLDistributionPoints,e[1],t.AsnConvert.serialize(n))}this.distributionPoints??=[]}onInit(e){super.onInit(e);let n=t.AsnConvert.parse(e.extnValue,f.CRLDistributionPoints);this.distributionPoints=n}toTextObject(){let e=this.toTextObjectWithoutValue();return e[`Distribution Point`]=this.distributionPoints.map(e=>{let t={};return e.distributionPoint&&(t[``]=e.distributionPoint.fullName?.map(e=>new U(e).toString()).join(`, `)),e.reasons&&(t.Reasons=e.reasons.toString()),e.cRLIssuer&&(t[`CRL Issuer`]=e.cRLIssuer.map(e=>e.toString()).join(`, `)),t}),e}};Je.NAME=`CRL Distribution Points`;var Ye=class extends L{constructor(...e){if(r.BufferSourceConverter.isBufferSource(e[0]))super(e[0]);else if(e[0]instanceof f.AuthorityInfoAccessSyntax){let n=new f.AuthorityInfoAccessSyntax(e[0]);super(f.id_pe_authorityInfoAccess,e[1],t.AsnConvert.serialize(n))}else{let n=e[0],r=new f.AuthorityInfoAccessSyntax;Ze(r,n,f.id_ad_ocsp,`ocsp`),Ze(r,n,f.id_ad_caIssuers,`caIssuers`),Ze(r,n,f.id_ad_timeStamping,`timeStamping`),Ze(r,n,f.id_ad_caRepository,`caRepository`),super(f.id_pe_authorityInfoAccess,e[1],t.AsnConvert.serialize(r))}this.ocsp??=[],this.caIssuers??=[],this.timeStamping??=[],this.caRepository??=[]}onInit(e){super.onInit(e),this.ocsp=[],this.caIssuers=[],this.timeStamping=[],this.caRepository=[],t.AsnConvert.parse(e.extnValue,f.AuthorityInfoAccessSyntax).forEach(e=>{switch(e.accessMethod){case f.id_ad_ocsp:this.ocsp.push(new U(e.accessLocation));break;case f.id_ad_caIssuers:this.caIssuers.push(new U(e.accessLocation));break;case f.id_ad_timeStamping:this.timeStamping.push(new U(e.accessLocation));break;case f.id_ad_caRepository:this.caRepository.push(new U(e.accessLocation));break}})}toTextObject(){let e=this.toTextObjectWithoutValue();return this.ocsp.length&&Xe(e,`OCSP`,this.ocsp),this.caIssuers.length&&Xe(e,`CA Issuers`,this.caIssuers),this.timeStamping.length&&Xe(e,`Time Stamping`,this.timeStamping),this.caRepository.length&&Xe(e,`CA Repository`,this.caRepository),e}};Ye.NAME=`Authority Info Access`;function Xe(e,t,n){if(n.length===1)e[t]=n[0].toTextObject();else{let r=new I(``);n.forEach((e,t)=>{let n=e.toTextObject(),i=`${n[I.NAME]} ${t+1}`,a=r[i];Array.isArray(a)||(a=[],r[i]=a),a.push(n)}),e[t]=r}}function Ze(e,n,r,i){let a=n[i];a&&(Array.isArray(a)?a:[a]).forEach(n=>{typeof n==`string`&&(n=new U(`url`,n)),e.push(new f.AccessDescription({accessMethod:r,accessLocation:t.AsnConvert.parse(n.rawData,f.GeneralName)}))})}var Qe=class e extends xe{constructor(...e){let i;if(r.BufferSourceConverter.isBufferSource(e[0]))i=r.BufferSourceConverter.toArrayBuffer(e[0]);else{let a=e[0],o=Array.isArray(e[1])?e[1].map(e=>r.BufferSourceConverter.toArrayBuffer(e)):[];i=t.AsnConvert.serialize(new n.Attribute({type:a,values:o}))}super(i,n.Attribute)}onInit(e){this.type=e.type,this.values=e.values}toTextObject(){let e=this.toTextObjectWithoutValue();return e.Value=this.values.map(e=>new I(``,{"":e})),e}toTextObjectWithoutValue(){let t=this.toTextObjectEmpty();return t[I.NAME]===e.NAME&&(t[I.NAME]=ye.toString(this.type)),t}};Qe.NAME=`Attribute`;var $e=class extends Qe{constructor(...e){if(r.BufferSourceConverter.isBufferSource(e[0]))super(e[0]);else{let n=new g.ChallengePassword({printableString:e[0]});super(g.id_pkcs9_at_challengePassword,[t.AsnConvert.serialize(n)])}this.password??=``}onInit(e){if(super.onInit(e),this.values[0]){let e=t.AsnConvert.parse(this.values[0],g.ChallengePassword);this.password=e.toString()}}toTextObject(){let e=this.toTextObjectWithoutValue();return e[I.VALUE]=this.password,e}};$e.NAME=`Challenge Password`;var et=class extends Qe{constructor(...e){if(r.BufferSourceConverter.isBufferSource(e[0]))super(e[0]);else{let n=e[0],r=new f.Extensions;for(let e of n)r.push(t.AsnConvert.parse(e.rawData,f.Extension));super(g.id_pkcs9_at_extensionRequest,[t.AsnConvert.serialize(r)])}this.items??=[]}onInit(e){if(super.onInit(e),this.values[0]){let e=t.AsnConvert.parse(this.values[0],f.Extensions);this.items=e.map(e=>G.create(t.AsnConvert.serialize(e)))}}toTextObject(){let e=this.toTextObjectWithoutValue(),t=this.items.map(e=>e.toTextObject());for(let n of t)e[n[I.NAME]]=n;return e}};et.NAME=`Extensions`;var tt=class{static register(e,t){this.items.set(e,t)}static create(e){let t=new Qe(e),n=this.items.get(t.type);return n?new n(e):t}};tt.items=new Map;let K=`crypto.signatureFormatter`;var nt=class{toAsnSignature(e,t){return r.BufferSourceConverter.toArrayBuffer(t)}toWebSignature(e,t){return r.BufferSourceConverter.toArrayBuffer(t)}},rt;e.RsaAlgorithm=rt=class{static createPssParams(e,r){let i=rt.getHashAlgorithm(e);return i?new h.RsaSaPssParams({hashAlgorithm:i,maskGenAlgorithm:new n.AlgorithmIdentifier({algorithm:h.id_mgf1,parameters:t.AsnConvert.serialize(i)}),saltLength:r}):null}static getHashAlgorithm(e){let t=c.container.resolve(y);return typeof e==`string`?t.toAsnAlgorithm({name:e}):typeof e==`object`&&e&&`name`in e?t.toAsnAlgorithm(e):null}toAsnAlgorithm(e){switch(e.name.toLowerCase()){case`rsassa-pkcs1-v1_5`:if(`hash`in e){let t;if(typeof e.hash==`string`)t=e.hash;else if(e.hash&&typeof e.hash==`object`&&`name`in e.hash&&typeof e.hash.name==`string`)t=e.hash.name.toUpperCase();else throw Error(`Cannot get hash algorithm name`);switch(t.toLowerCase()){case`sha-1`:return new n.AlgorithmIdentifier({algorithm:h.id_sha1WithRSAEncryption,parameters:null});case`sha-256`:return new n.AlgorithmIdentifier({algorithm:h.id_sha256WithRSAEncryption,parameters:null});case`sha-384`:return new n.AlgorithmIdentifier({algorithm:h.id_sha384WithRSAEncryption,parameters:null});case`sha-512`:return new n.AlgorithmIdentifier({algorithm:h.id_sha512WithRSAEncryption,parameters:null})}}else return new n.AlgorithmIdentifier({algorithm:h.id_rsaEncryption,parameters:null});break;case`rsa-pss`:if(`hash`in e){if(!(`saltLength`in e&&typeof e.saltLength==`number`))throw Error(`Cannot get 'saltLength' from 'alg' argument`);let r=rt.createPssParams(e.hash,e.saltLength);if(!r)throw Error(`Cannot create PSS parameters`);return new n.AlgorithmIdentifier({algorithm:h.id_RSASSA_PSS,parameters:t.AsnConvert.serialize(r)})}else return new n.AlgorithmIdentifier({algorithm:h.id_RSASSA_PSS,parameters:null})}return null}toWebAlgorithm(e){switch(e.algorithm){case h.id_rsaEncryption:return{name:`RSASSA-PKCS1-v1_5`};case h.id_sha1WithRSAEncryption:return{name:`RSASSA-PKCS1-v1_5`,hash:{name:`SHA-1`}};case h.id_sha256WithRSAEncryption:return{name:`RSASSA-PKCS1-v1_5`,hash:{name:`SHA-256`}};case h.id_sha384WithRSAEncryption:return{name:`RSASSA-PKCS1-v1_5`,hash:{name:`SHA-384`}};case h.id_sha512WithRSAEncryption:return{name:`RSASSA-PKCS1-v1_5`,hash:{name:`SHA-512`}};case h.id_RSASSA_PSS:if(e.parameters){let n=t.AsnConvert.parse(e.parameters,h.RsaSaPssParams);return{name:`RSA-PSS`,hash:c.container.resolve(y).toWebAlgorithm(n.hashAlgorithm),saltLength:n.saltLength}}else return{name:`RSA-PSS`}}return null}},e.RsaAlgorithm=rt=s.__decorate([c.injectable()],e.RsaAlgorithm),c.container.registerSingleton(_,e.RsaAlgorithm),e.ShaAlgorithm=class{toAsnAlgorithm(e){switch(e.name.toLowerCase()){case`sha-1`:return new n.AlgorithmIdentifier({algorithm:o.id_sha1});case`sha-256`:return new n.AlgorithmIdentifier({algorithm:o.id_sha256});case`sha-384`:return new n.AlgorithmIdentifier({algorithm:o.id_sha384});case`sha-512`:return new n.AlgorithmIdentifier({algorithm:o.id_sha512})}return null}toWebAlgorithm(e){switch(e.algorithm){case o.id_sha1:return{name:`SHA-1`};case o.id_sha256:return{name:`SHA-256`};case o.id_sha384:return{name:`SHA-384`};case o.id_sha512:return{name:`SHA-512`}}return null}},e.ShaAlgorithm=s.__decorate([c.injectable()],e.ShaAlgorithm),c.container.registerSingleton(_,e.ShaAlgorithm);var it=class e{addPadding(e,t){let n=r.BufferSourceConverter.toUint8Array(t),i=new Uint8Array(e);return i.set(n,e-n.length),i}removePadding(e,t=!1){let n=r.BufferSourceConverter.toUint8Array(e);for(let e=0;e<n.length;e++)if(n[e]){n=n.slice(e);break}if(t&&n[0]>127){let e=new Uint8Array(n.length+1);return e.set(n,1),e.buffer}return n.buffer}toAsnSignature(n,i){if(n.name===`ECDSA`){let o=n.namedCurve,s=e.namedCurveSize.get(o)||e.defaultNamedCurveSize,c=new a.ECDSASigValue,l=r.BufferSourceConverter.toUint8Array(i);return c.r=this.removePadding(l.slice(0,s),!0),c.s=this.removePadding(l.slice(s,s+s),!0),t.AsnConvert.serialize(c)}return null}toWebSignature(n,i){if(n.name===`ECDSA`){let o=t.AsnConvert.parse(i,a.ECDSASigValue),s=n.namedCurve,c=e.namedCurveSize.get(s)||e.defaultNamedCurveSize,l=this.addPadding(c,this.removePadding(o.r)),u=this.addPadding(c,this.removePadding(o.s));return r.combine(l,u)}return null}};it.namedCurveSize=new Map,it.defaultNamedCurveSize=32;let at=`1.3.101.110`,ot=`1.3.101.111`,st=`1.3.101.112`,ct=`1.3.101.113`;e.EdAlgorithm=class{toAsnAlgorithm(e){let t=null;switch(e.name.toLowerCase()){case`ed25519`:t=st;break;case`x25519`:t=at;break;case`eddsa`:switch(e.namedCurve.toLowerCase()){case`ed25519`:t=st;break;case`ed448`:t=ct;break}break;case`ecdh-es`:switch(e.namedCurve.toLowerCase()){case`x25519`:t=at;break;case`x448`:t=ot;break}}return t?new n.AlgorithmIdentifier({algorithm:t}):null}toWebAlgorithm(e){switch(e.algorithm){case st:return{name:`Ed25519`};case ct:return{name:`EdDSA`,namedCurve:`Ed448`};case at:return{name:`X25519`};case ot:return{name:`ECDH-ES`,namedCurve:`X448`}}return null}},e.EdAlgorithm=s.__decorate([c.injectable()],e.EdAlgorithm),c.container.registerSingleton(_,e.EdAlgorithm);var lt=class extends Re{constructor(e){Re.isAsnEncoded(e)?super(e,u.CertificationRequest):super(e),this.tag=W.CertificateRequestTag}onInit(e){this.tbs=t.AsnConvert.serialize(e.certificationRequestInfo),this.publicKey=new ze(e.certificationRequestInfo.subjectPKInfo);let n=c.container.resolve(y);this.signatureAlgorithm=n.toWebAlgorithm(e.signatureAlgorithm),this.signature=e.signature,this.attributes=e.certificationRequestInfo.attributes.map(e=>tt.create(t.AsnConvert.serialize(e)));let r=this.getAttribute(l.id_pkcs9_at_extensionRequest);this.extensions=[],r instanceof et&&(this.extensions=r.items),this.subjectName=new V(e.certificationRequestInfo.subject),this.subject=this.subjectName.toString()}getAttribute(e){for(let t of this.attributes)if(t.type===e)return t;return null}getAttributes(e){return this.attributes.filter(t=>t.type===e)}getExtension(e){for(let t of this.extensions)if(t.type===e)return t;return null}getExtensions(e){return this.extensions.filter(t=>t.type===e)}async verify(e=R.get()){let t={...this.publicKey.algorithm,...this.signatureAlgorithm},n=await this.publicKey.export(t,[`verify`],e),r=c.container.resolveAll(K).reverse(),i=null;for(let e of r)if(i=e.toWebSignature(t,this.signature),i)break;if(!i)throw Error(`Cannot convert WebCrypto signature value to ASN.1 format`);return await e.subtle.verify(this.signatureAlgorithm,n,i,this.tbs)}toTextObject(){let e=this.toTextObjectEmpty(),r=t.AsnConvert.parse(this.rawData,u.CertificationRequest),i=r.certificationRequestInfo,a=new I(``,{Version:`${n.Version[i.version]} (${i.version})`,Subject:this.subject,"Subject Public Key Info":this.publicKey});if(this.attributes.length){let e=new I(``);for(let t of this.attributes){let n=t.toTextObject();e[n[I.NAME]]=n}a.Attributes=e}return e.Data=a,e.Signature=new I(``,{Algorithm:be.serializeAlgorithm(r.signatureAlgorithm),"":r.signature}),e}};lt.NAME=`PKCS#10 Certificate Request`;var ut=class{static async create(e,r=R.get()){if(!e.keys.privateKey)throw Error(`Bad field 'keys' in 'params' argument. 'privateKey' is empty`);if(!e.keys.publicKey)throw Error(`Bad field 'keys' in 'params' argument. 'publicKey' is empty`);let i=await r.subtle.exportKey(`spki`,e.keys.publicKey),a=new u.CertificationRequest({certificationRequestInfo:new u.CertificationRequestInfo({subjectPKInfo:t.AsnConvert.parse(i,n.SubjectPublicKeyInfo)})});if(e.name){let r=e.name instanceof V?e.name:new V(e.name);a.certificationRequestInfo.subject=t.AsnConvert.parse(r.toArrayBuffer(),n.Name)}if(e.attributes)for(let r of e.attributes)a.certificationRequestInfo.attributes.push(t.AsnConvert.parse(r.rawData,n.Attribute));if(e.extensions&&e.extensions.length){let r=new n.Attribute({type:l.id_pkcs9_at_extensionRequest}),i=new n.Extensions;for(let r of e.extensions)i.push(t.AsnConvert.parse(r.rawData,n.Extension));r.values.push(t.AsnConvert.serialize(i)),a.certificationRequestInfo.attributes.push(r)}let o={...e.signingAlgorithm,...e.keys.privateKey.algorithm};a.signatureAlgorithm=c.container.resolve(y).toAsnAlgorithm(o);let s=t.AsnConvert.serialize(a.certificationRequestInfo),d=await r.subtle.sign(o,e.keys.privateKey,s),f=c.container.resolveAll(K).reverse(),p=null;for(let e of f)if(p=e.toAsnSignature(o,d),p)break;if(!p)throw Error(`Cannot convert WebCrypto signature value to ASN.1 format`);return a.signature=p,new lt(t.AsnConvert.serialize(a))}},dt=class extends Re{constructor(e){Re.isAsnEncoded(e)?super(e,n.Certificate):super(e),this.tag=W.CertificateTag}onInit(e){let n=e.tbsCertificate;this.tbs=t.AsnConvert.serialize(n),this.serialNumber=r.Convert.ToHex(n.serialNumber),this.subjectName=new V(n.subject),this.subject=new V(n.subject).toString(),this.issuerName=new V(n.issuer),this.issuer=this.issuerName.toString();let i=c.container.resolve(y);this.signatureAlgorithm=i.toWebAlgorithm(e.signatureAlgorithm),this.signature=e.signatureValue;let a=n.validity.notBefore.utcTime||n.validity.notBefore.generalTime;if(!a)throw Error(`Cannot get 'notBefore' value`);this.notBefore=a;let o=n.validity.notAfter.utcTime||n.validity.notAfter.generalTime;if(!o)throw Error(`Cannot get 'notAfter' value`);this.notAfter=o,this.extensions=[],n.extensions&&(this.extensions=n.extensions.map(e=>G.create(t.AsnConvert.serialize(e)))),this.publicKey=new ze(n.subjectPublicKeyInfo)}getExtension(e){for(let t of this.extensions)if(typeof e==`string`){if(t.type===e)return t}else if(t instanceof e)return t;return null}getExtensions(e){return this.extensions.filter(t=>typeof e==`string`?t.type===e:t instanceof e)}async verify(e={},t=R.get()){let n,i,a=e.publicKey;try{if(!a)n={...this.publicKey.algorithm,...this.signatureAlgorithm},i=await this.publicKey.export(n,[`verify`],t);else if(`publicKey`in a)n={...a.publicKey.algorithm,...this.signatureAlgorithm},i=await a.publicKey.export(n,[`verify`],t);else if(a instanceof ze)n={...a.algorithm,...this.signatureAlgorithm},i=await a.export(n,[`verify`],t);else if(r.BufferSourceConverter.isBufferSource(a)){let e=new ze(a);n={...e.algorithm,...this.signatureAlgorithm},i=await e.export(n,[`verify`],t)}else n={...a.algorithm,...this.signatureAlgorithm},i=a}catch{return!1}let o=c.container.resolveAll(K).reverse(),s=null;for(let e of o)if(s=e.toWebSignature(n,this.signature),s)break;if(!s)throw Error(`Cannot convert ASN.1 signature value to WebCrypto format`);let l=await t.subtle.verify(this.signatureAlgorithm,i,s,this.tbs);if(e.signatureOnly)return l;{let t=(e.date||new Date).getTime();return l&&this.notBefore.getTime()<t&&t<this.notAfter.getTime()}}async getThumbprint(...e){let t,n=`SHA-1`;return e[0]&&(e[0].subtle?t=e[0]:(n=e[0]||n,t=e[1])),t??=R.get(),await t.subtle.digest(n,this.rawData)}async isSelfSigned(e=R.get()){return this.subject===this.issuer&&await this.verify({signatureOnly:!0},e)}toTextObject(){let e=this.toTextObjectEmpty(),r=t.AsnConvert.parse(this.rawData,n.Certificate),i=r.tbsCertificate,a=new I(``,{Version:`${n.Version[i.version]} (${i.version})`,"Serial Number":i.serialNumber,"Signature Algorithm":be.serializeAlgorithm(i.signature),Issuer:this.issuer,Validity:new I(``,{"Not Before":i.validity.notBefore.getTime(),"Not After":i.validity.notAfter.getTime()}),Subject:this.subject,"Subject Public Key Info":this.publicKey});if(i.issuerUniqueID&&(a[`Issuer Unique ID`]=i.issuerUniqueID),i.subjectUniqueID&&(a[`Subject Unique ID`]=i.subjectUniqueID),this.extensions.length){let e=new I(``);for(let t of this.extensions){let n=t.toTextObject();e[n[I.NAME]]=n}a.Extensions=e}return e.Data=a,e.Signature=new I(``,{Algorithm:be.serializeAlgorithm(r.signatureAlgorithm),"":r.signatureValue}),e}};dt.NAME=`Certificate`;var ft=class extends Array{constructor(e){if(super(),Re.isAsnEncoded(e))this.import(e);else if(e instanceof dt)this.push(e);else if(Array.isArray(e))for(let t of e)this.push(t)}export(e){let r=new p.SignedData;r.version=1,r.encapContentInfo.eContentType=p.id_data,r.encapContentInfo.eContent=new p.EncapsulatedContent({single:new t.OctetString}),r.certificates=new p.CertificateSet(this.map(e=>new p.CertificateChoices({certificate:t.AsnConvert.parse(e.rawData,n.Certificate)})));let i=new p.ContentInfo({contentType:p.id_signedData,content:t.AsnConvert.serialize(r)}),a=t.AsnConvert.serialize(i);return e===`raw`?a:this.toString(e)}import(e){let n=Re.toArrayBuffer(e),r=t.AsnConvert.parse(n,p.ContentInfo);if(r.contentType!==p.id_signedData)throw TypeError(`Cannot parse CMS package. Incoming data is not a SignedData object.`);let i=t.AsnConvert.parse(r.content,p.SignedData);this.clear();for(let e of i.certificates||[])e.certificate&&this.push(new dt(e.certificate))}clear(){for(;this.pop(););}toString(e=`pem`){let n=this.export(`raw`);switch(e){case`pem`:return W.encode(n,`CMS`);case`pem-chain`:return this.map(e=>e.toString(`pem`)).join(`
137
+ `);case`asn`:return t.AsnConvert.toString(n);case`hex`:return r.Convert.ToHex(n);case`base64`:return r.Convert.ToBase64(n);case`base64url`:return r.Convert.ToBase64Url(n);case`text`:return be.serialize(this.toTextObject());default:throw TypeError(`Argument 'format' is unsupported value`)}}toTextObject(){let e=t.AsnConvert.parse(this.export(`raw`),p.ContentInfo),n=t.AsnConvert.parse(e.content,p.SignedData);return new I(`X509Certificates`,{"Content Type":ye.toString(e.contentType),Content:new I(``,{Version:`${p.CMSVersion[n.version]} (${n.version})`,Certificates:new I(``,{Certificate:this.map(e=>e.toTextObject())})})})}},pt=class{constructor(e={}){this.certificates=[],e.certificates&&(this.certificates=e.certificates)}async build(e,t=R.get()){let n=new ft(e),i=e;for(;i=await this.findIssuer(i,t);){let e=await i.getThumbprint(t);for(let i of n){let n=await i.getThumbprint(t);if(r.isEqual(e,n))throw Error(`Cannot build a certificate chain. Circular dependency.`)}n.push(i)}return n}async findIssuer(e,n=R.get()){if(!await e.isSelfSigned(n)){let i=e.getExtension(f.id_ce_authorityKeyIdentifier);for(let a of this.certificates)if(a.subject===e.issuer){if(i){if(i.keyId){let e=a.getExtension(f.id_ce_subjectKeyIdentifier);if(e&&e.keyId!==i.keyId)continue}else if(i.certId){let e=a.getExtension(f.id_ce_subjectAltName);if(e&&!(i.certId.serialNumber===a.serialNumber&&r.isEqual(t.AsnConvert.serialize(i.certId.name),t.AsnConvert.serialize(e))))continue}}try{let t={...a.publicKey.algorithm,...e.signatureAlgorithm},r=await a.publicKey.export(t,[`verify`],n);if(!await e.verify({publicKey:r,signatureOnly:!0},n))continue}catch{continue}return a}}return null}},mt=class{static async createSelfSigned(e,t=R.get()){if(!e.keys.privateKey)throw Error(`Bad field 'keys' in 'params' argument. 'privateKey' is empty`);if(!e.keys.publicKey)throw Error(`Bad field 'keys' in 'params' argument. 'publicKey' is empty`);return this.create({serialNumber:e.serialNumber,subject:e.name,issuer:e.name,notBefore:e.notBefore,notAfter:e.notAfter,publicKey:e.keys.publicKey,signingKey:e.keys.privateKey,signingAlgorithm:e.signingAlgorithm,extensions:e.extensions},t)}static async create(e,n=R.get()){let i;i=e.publicKey instanceof ze?e.publicKey.rawData:`publicKey`in e.publicKey?e.publicKey.publicKey.rawData:r.BufferSourceConverter.isBufferSource(e.publicKey)?e.publicKey:await n.subtle.exportKey(`spki`,e.publicKey);let a=e.serialNumber?r.BufferSourceConverter.toUint8Array(r.Convert.FromHex(e.serialNumber)):n.getRandomValues(new Uint8Array(16));a[0]>127&&(a[0]&=127),a.length>1&&a[0]===0&&(a[1]|=128);let o=e.notBefore||new Date,s=e.notAfter||new Date(o.getTime()+31536e6),l=new f.Certificate({tbsCertificate:new f.TBSCertificate({version:f.Version.v3,serialNumber:a,validity:new f.Validity({notBefore:o,notAfter:s}),extensions:new f.Extensions(e.extensions?.map(e=>t.AsnConvert.parse(e.rawData,f.Extension))||[]),subjectPublicKeyInfo:t.AsnConvert.parse(i,f.SubjectPublicKeyInfo)})});if(e.subject){let n=e.subject instanceof V?e.subject:new V(e.subject);l.tbsCertificate.subject=t.AsnConvert.parse(n.toArrayBuffer(),f.Name)}if(e.issuer){let n=e.issuer instanceof V?e.issuer:new V(e.issuer);l.tbsCertificate.issuer=t.AsnConvert.parse(n.toArrayBuffer(),f.Name)}let u={hash:`SHA-256`},d=`signingKey`in e?{...u,...e.signingAlgorithm,...e.signingKey.algorithm}:{...u,...e.signingAlgorithm},p=c.container.resolve(y);l.tbsCertificate.signature=l.signatureAlgorithm=p.toAsnAlgorithm(d);let m=t.AsnConvert.serialize(l.tbsCertificate),h=`signingKey`in e?await n.subtle.sign(d,e.signingKey,m):e.signature,g=c.container.resolveAll(K).reverse(),_=null;for(let e of g)if(_=e.toAsnSignature(d,h),_)break;if(!_)throw Error(`Cannot convert ASN.1 signature value to WebCrypto format`);return l.signatureValue=_,new dt(t.AsnConvert.serialize(l))}};e.X509CrlReason=void 0,(function(e){e[e.unspecified=0]=`unspecified`,e[e.keyCompromise=1]=`keyCompromise`,e[e.cACompromise=2]=`cACompromise`,e[e.affiliationChanged=3]=`affiliationChanged`,e[e.superseded=4]=`superseded`,e[e.cessationOfOperation=5]=`cessationOfOperation`,e[e.certificateHold=6]=`certificateHold`,e[e.removeFromCRL=8]=`removeFromCRL`,e[e.privilegeWithdrawn=9]=`privilegeWithdrawn`,e[e.aACompromise=10]=`aACompromise`})(e.X509CrlReason||={});var ht=class extends xe{constructor(...e){let i;i=r.BufferSourceConverter.isBufferSource(e[0])?r.BufferSourceConverter.toArrayBuffer(e[0]):t.AsnConvert.serialize(new n.RevokedCertificate({userCertificate:e[0],revocationDate:new n.Time(e[1]),crlEntryExtensions:e[2]})),super(i,n.RevokedCertificate)}onInit(e){this.serialNumber=r.Convert.ToHex(e.userCertificate),this.revocationDate=e.revocationDate.getTime(),this.extensions=[],e.crlEntryExtensions&&(this.extensions=e.crlEntryExtensions.map(e=>{let r=G.create(t.AsnConvert.serialize(e));switch(r.type){case n.id_ce_cRLReasons:this.reason=t.AsnConvert.parse(r.value,n.CRLReason).reason;break;case n.id_ce_invalidityDate:this.invalidity=t.AsnConvert.parse(r.value,n.InvalidityDate).value;break}return r}))}},gt=class extends Re{constructor(e){Re.isAsnEncoded(e)?super(e,n.CertificateList):super(e),this.tag=W.CrlTag}onInit(e){let n=e.tbsCertList;this.tbs=t.AsnConvert.serialize(n),this.version=n.version;let r=c.container.resolve(y);this.signatureAlgorithm=r.toWebAlgorithm(e.signatureAlgorithm),this.tbsCertListSignatureAlgorithm=n.signature,this.certListSignatureAlgorithm=e.signatureAlgorithm,this.signature=e.signature,this.issuerName=new V(n.issuer),this.issuer=this.issuerName.toString();let i=n.thisUpdate.getTime();if(!i)throw Error(`Cannot get 'thisUpdate' value`);this.thisUpdate=i;let a=n.nextUpdate?.getTime();this.nextUpdate=a,this.entries=n.revokedCertificates?.map(e=>new ht(t.AsnConvert.serialize(e)))||[],this.extensions=[],n.crlExtensions&&(this.extensions=n.crlExtensions.map(e=>G.create(t.AsnConvert.serialize(e))))}getExtension(e){for(let t of this.extensions)if(typeof e==`string`){if(t.type===e)return t}else if(t instanceof e)return t;return null}getExtensions(e){return this.extensions.filter(t=>typeof e==`string`?t.type===e:t instanceof e)}async verify(e,t=R.get()){if(!this.certListSignatureAlgorithm.isEqual(this.tbsCertListSignatureAlgorithm))throw Error(`algorithm identifier in the sequence tbsCertList and CertificateList mismatch`);let n,r,i=e.publicKey;try{i instanceof dt?(n={...i.publicKey.algorithm,...i.signatureAlgorithm},r=await i.publicKey.export(n,[`verify`])):i instanceof ze?(n={...i.algorithm,...this.signature},r=await i.export(n,[`verify`])):(n={...i.algorithm,...this.signature},r=i)}catch{return!1}let a=c.container.resolveAll(K).reverse(),o=null;for(let e of a)if(o=e.toWebSignature(n,this.signature),o)break;if(!o)throw Error(`Cannot convert ASN.1 signature value to WebCrypto format`);return await t.subtle.verify(this.signatureAlgorithm,r,o,this.tbs)}async getThumbprint(...e){let t,n=`SHA-1`;return e[0]&&(e[0].subtle?t=e[0]:(n=e[0]||n,t=e[1])),t??=R.get(),await t.subtle.digest(n,this.rawData)}findRevoked(e){let t=typeof e==`string`?e:e.serialNumber;for(let e of this.entries)if(e.serialNumber===t)return e;return null}},_t=class{static async create(e,i=R.get()){let a=e.issuer instanceof V?e.issuer:new V(e.issuer),o=new f.CertificateList({tbsCertList:new f.TBSCertList({version:f.Version.v2,issuer:t.AsnConvert.parse(a.toArrayBuffer(),f.Name),thisUpdate:new n.Time(e.thisUpdate||new Date)})});if(e.nextUpdate&&(o.tbsCertList.nextUpdate=new n.Time(e.nextUpdate)),e.extensions&&e.extensions.length&&(o.tbsCertList.crlExtensions=new f.Extensions(e.extensions.map(e=>t.AsnConvert.parse(e.rawData,f.Extension))||[])),e.entries&&e.entries.length){o.tbsCertList.revokedCertificates=[];for(let i of e.entries){let a=Re.toArrayBuffer(i.serialNumber);if(o.tbsCertList.revokedCertificates.findIndex(e=>r.isEqual(e.userCertificate,a))>-1)throw Error(`Certificate serial number ${i.serialNumber} already exists in tbsCertList`);let s=new n.RevokedCertificate({userCertificate:a,revocationDate:new n.Time(i.revocationDate||new Date)});if(`extensions`in i&&i.extensions?.length?s.crlEntryExtensions=i.extensions.map(e=>t.AsnConvert.parse(e.rawData,f.Extension)):s.crlEntryExtensions=[],!(i instanceof ht)&&(i.reason&&s.crlEntryExtensions.push(new f.Extension({extnID:f.id_ce_cRLReasons,critical:!1,extnValue:new t.OctetString(t.AsnConvert.serialize(new f.CRLReason(i.reason)))})),i.invalidity&&s.crlEntryExtensions.push(new f.Extension({extnID:f.id_ce_invalidityDate,critical:!1,extnValue:new t.OctetString(t.AsnConvert.serialize(new f.InvalidityDate(i.invalidity)))})),i.issuer)){let n=e.issuer instanceof V?e.issuer:new V(e.issuer);s.crlEntryExtensions.push(new f.Extension({extnID:f.id_ce_certificateIssuer,critical:!1,extnValue:new t.OctetString(t.AsnConvert.serialize(t.AsnConvert.parse(n.toArrayBuffer(),f.Name)))}))}o.tbsCertList.revokedCertificates.push(s)}}let s={...e.signingAlgorithm,...e.signingKey.algorithm},l=c.container.resolve(y);o.tbsCertList.signature=o.signatureAlgorithm=l.toAsnAlgorithm(s);let u=t.AsnConvert.serialize(o.tbsCertList),d=await i.subtle.sign(s,e.signingKey,u),p=c.container.resolveAll(K).reverse(),m=null;for(let e of p)if(m=e.toAsnSignature(s,d),m)break;if(!m)throw Error(`Cannot convert ASN.1 signature value to WebCrypto format`);return o.signature=m,new gt(t.AsnConvert.serialize(o))}};G.register(f.id_ce_basicConstraints,He),G.register(f.id_ce_extKeyUsage,Ue),G.register(f.id_ce_keyUsage,We),G.register(f.id_ce_subjectKeyIdentifier,Ge),G.register(f.id_ce_authorityKeyIdentifier,Ve),G.register(f.id_ce_subjectAltName,Ke),G.register(f.id_ce_cRLDistributionPoints,Je),G.register(f.id_pe_authorityInfoAccess,Ye),tt.register(g.id_pkcs9_at_challengePassword,$e),tt.register(g.id_pkcs9_at_extensionRequest,et),c.container.registerSingleton(K,nt),c.container.registerSingleton(K,it),it.namedCurveSize.set(`P-256`,32),it.namedCurveSize.set(`K-256`,32),it.namedCurveSize.set(`P-384`,48),it.namedCurveSize.set(`P-521`,66),e.AlgorithmProvider=v,e.AsnData=xe,e.AsnDefaultSignatureFormatter=nt,e.AsnEcSignatureFormatter=it,e.Attribute=Qe,e.AttributeFactory=tt,e.AuthorityInfoAccessExtension=Ye,e.AuthorityKeyIdentifierExtension=Ve,e.BasicConstraintsExtension=He,e.CRLDistributionPointsExtension=Je,e.CertificatePolicyExtension=qe,e.ChallengePasswordAttribute=$e,e.CryptoProvider=Ce,e.DefaultAlgorithmSerializer=ve,e.ExtendedKeyUsageExtension=Ue,e.Extension=L,e.ExtensionFactory=G,e.ExtensionsAttribute=et,e.GeneralName=U,e.GeneralNames=Fe,e.KeyUsagesExtension=We,e.Name=V,e.NameIdentifier=Ee,e.OidSerializer=ye,e.PemConverter=W,e.Pkcs10CertificateRequest=lt,e.Pkcs10CertificateRequestGenerator=ut,e.PublicKey=ze,e.SubjectAlternativeNameExtension=Ke,e.SubjectKeyIdentifierExtension=Ge,e.TextConverter=be,e.TextObject=I,e.X509Certificate=dt,e.X509CertificateGenerator=mt,e.X509Certificates=ft,e.X509ChainBuilder=pt,e.X509Crl=gt,e.X509CrlEntry=ht,e.X509CrlGenerator=_t,e.cryptoProvider=R,e.diAlgorithm=_,e.diAlgorithmProvider=y,e.diAsnSignatureFormatter=K,e.idEd25519=st,e.idEd448=ct,e.idX25519=at,e.idX448=ot}));pn(),$o();
138
+ /**
139
+ * Code modified from https://github.com/google/tink/blob/6f74b99a2bfe6677e3670799116a57268fd067fa/javascript/subtle/bytes.ts
140
+ *
141
+ * @license
142
+ * Copyright 2020 Google LLC
143
+ * SPDX-License-Identifier: Apache-2.0
144
+ */
145
+ function es(e){if(e.length%2!=0)throw Error(`Hex string length must be multiple of 2`);let t=new Uint8Array(e.length/2);for(let n=0;n<e.length;n+=2)t[n/2]=parseInt(e.substring(n,n+2),16);return t}function ts(e){let t=``;for(let n=0;n<e.length;n++){let r=e[n].toString(16);t+=r.length>1?r:`0`+r}return t}function ns(e,t){return btoa(rs(e)).replace(/=/g,``).replace(/\+/g,`-`).replace(/\//g,`_`)}function rs(e){let t=``;for(let n=0;n<e.length;n+=1)t+=String.fromCharCode(e[n]);return t}
146
+ /**
147
+ * Code modified from https://github.com/google/tink/blob/6f74b99a2bfe6677e3670799116a57268fd067fa/javascript/subtle/elliptic_curves.ts
148
+ * - The implementation of integerToByteArray has been modified to augment the resulting byte array to a certain length.
149
+ * - The implementation of PointDecode has been modified to decode both compressed and uncompressed points by checking for correct format
150
+ * - Method isP256CurvePoint added to check whether an uncompressed point is valid
151
+ *
152
+ * @license
153
+ * Copyright 2020 Google LLC
154
+ * SPDX-License-Identifier: Apache-2.0
155
+ */
156
+ function is(){return BigInt(`115792089210356248762697446949407573530086143415290314195533631308867097853951`)}function as(){return BigInt(`0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b`)}function os(e){return BigInt(`0x`+ts(e))}function ss(e,t){let n=e.toString(16),r=t*2,i=``;if(r<n.length)throw Error(`cannot pack integer with ${n.length} hex chars into ${t} bytes`);return i=`0`.repeat(r-n.length),es(i+n)}function cs(e,t){return(e&BigInt(1)<<BigInt(t))!==BigInt(0)}function ls(e,t,n){if(t===BigInt(0))return BigInt(1);let r=e,i=t.toString(2);for(let t=1;t<i.length;++t)r=r*r%n,i[t]===`1`&&(r=r*e%n);return r}function us(e,t){if(t<=BigInt(0))throw Error(`p must be positive`);let n=e%t;if(cs(t,0)&&cs(t,1)){let e=ls(n,t+BigInt(1)>>BigInt(2),t);if(e*e%t!==n)throw Error(`could not find a modular square root`);return e}throw Error(`unsupported modulus value`)}function ds(e,t){let n=is(),r=n-BigInt(3),i=as(),a=us(((e*e+r)*e+i)%n,n);return t!==cs(a,0)&&(a=(n-a)%n),a}function fs(e,t){let n=is(),r=n-BigInt(3),i=as(),a=((e*e+r)*e+i)%n;return t**BigInt(2)%n===a}function ps(e){let t=ms(),n=t+1,r=2*t+1;if(e.length!==n&&e.length!==r)throw Error(`Invalid length: point is not in compressed or uncompressed format`);if((e[0]===2||e[0]===3)&&e.length==n){let t=e[0]===3,n=os(e.subarray(1,e.length)),r=is();if(n<BigInt(0)||n>=r)throw Error(`x is out of range`);let i=ds(n,t);return{kty:`EC`,crv:`P-256`,x:ns(ss(n,32)),y:ns(ss(i,32)),ext:!0}}else if(e[0]===4&&e.length==r){let n=os(e.subarray(1,t+1)),r=os(e.subarray(t+1,2*t+1)),i=is();if(n<BigInt(0)||n>=i||r<BigInt(0)||r>=i||!fs(n,r))throw Error(`invalid uncompressed x and y coordinates`);return{kty:`EC`,crv:`P-256`,x:ns(ss(n,32)),y:ns(ss(r,32)),ext:!0}}throw Error(`invalid format`)}function ms(){return 32}var hs;(function(e){e.Der=`der`,e.Raw=`raw`})(hs||={});const gs=typeof window<`u`&&window.document!==void 0&&typeof crypto<`u`&&crypto.subtle!==void 0,_s=typeof process<`u`&&process.versions!=null&&process.versions.node!=null,vs=()=>gs?`browser`:_s?`node`:`purejs`,ys=async(e,t)=>{let n=t??vs();switch(n){case`browser`:return(await import(`./webcrypto--IXxxE07.mjs`)).signWithApiKey(e);case`node`:return(await import(`./nodecrypto-Bo_ECug7.mjs`)).signWithApiKey(e);case`purejs`:return(await import(`./purejs-C0p97oL4.mjs`)).signWithApiKey(e);default:throw Error(`Unsupported runtime: ${n}`)}};var bs=class{constructor(e){this.apiPublicKey=e.apiPublicKey,this.apiPrivateKey=e.apiPrivateKey,this.runtimeOverride=e.runtimeOverride}async stamp(e){let t=await ys({publicKey:this.apiPublicKey,privateKey:this.apiPrivateKey,content:e},this.runtimeOverride),n={publicKey:this.apiPublicKey,scheme:`SIGNATURE_SCHEME_TK_API_P256`,signature:t};return{stampHeaderName:`X-Stamp`,stampHeaderValue:ze(JSON.stringify(n))}}async sign(e,t){switch(t){case hs.Raw:return Le(dn(await ys({publicKey:this.apiPublicKey,privateKey:this.apiPrivateKey,content:e},this.runtimeOverride)));case hs.Der:return ys({publicKey:this.apiPublicKey,privateKey:this.apiPrivateKey,content:e},this.runtimeOverride);default:throw Error(`Unsupported signature format: ${t}`)}}};function xs(){let e=o(`prime256v1`);return e.generateKeys(),{algorithm:`p256`,privateKeyHex:e.getPrivateKey().toString(`hex`).padStart(64,`0`),publicKeyHex:e.getPublicKey(`hex`,`compressed`)}}function Ss(e){try{let t=a.convertKey(e,`prime256v1`,`hex`,`hex`,`uncompressed`),n=Buffer.isBuffer(t)?t:Buffer.from(t,`hex`);return n.length===65?n:null}catch{return null}}function Cs(e){let t=Ss(e);return t===null?null:ws(t)}function ws(e){let t=e.subarray(1,33).toString(`base64url`),n=e.subarray(33,65).toString(`base64url`);return s(`sha256`).update(`{"crv":"P-256","kty":"EC","x":"${t}","y":"${n}"}`,`utf8`).digest(`base64url`)}const Ts=/^https?:\/\/[\x21\x23-\x7e]{1,255}$/,Es=/^[\x21\x23-\x3a\x3c-\x7e]{1,128}$/;function Ds(e,t){return`${e.replace(/\/+$/,``)}/agents/${t}`}function Os(e){let t=ks(e);return{sign:async e=>{let n=new Uint8Array(await e.clone().arrayBuffer()),r=As(t,{method:e.method,url:e.url,body:n},{nonce:l(16).toString(`base64url`),createdAt:new Date}),i=new Headers(e.headers);for(let[e,t]of Object.entries(r))i.set(e,t);return new Request(e,{headers:i})}}}function ks(e){let t=Ss(e.keypair.publicKeyHex);if(t===null)throw Error(`signer keypair has an invalid P-256 public key`);if(!Ts.test(e.identityUrl))throw Error(`identity URL is outside the signature profile: "${e.identityUrl}"`);return{signingKey:Ps(t,e.keypair.privateKeyHex),keyId:ws(t),identityUrl:e.identityUrl}}function As(e,t,n){if(!Es.test(n.nonce))throw Error(`nonce is outside the signature profile`);let r=js(t.body),i=`"${e.identityUrl}"`,a=`("@method" "@target-uri" "content-digest" "signature-agent");created=${Math.floor(n.createdAt.getTime()/1e3)};keyid="${e.keyId}";nonce="${n.nonce}";alg="ecdsa-p256-sha256"`,o=[`"@method": ${t.method.toUpperCase()}`,`"@target-uri": ${Ms(new URL(t.url))}`,`"content-digest": ${r}`,`"signature-agent": ${i}`,`"@signature-params": ${a}`].join(`
157
+ `),s=u(`sha256`,Buffer.from(o,`utf8`),{key:e.signingKey,dsaEncoding:`ieee-p1363`});return{"Content-Digest":r,"Signature-Agent":i,"Signature-Input":`sig=${a}`,Signature:`sig=:${s.toString(`base64`)}:`}}function js(e){return`sha-256=:${s(`sha256`).update(e??``).digest(`base64`)}:`}function Ms(e){return`${e.protocol}//${Ns(e)}${e.pathname}${e.search}`}function Ns(e){let t=e.host.toLowerCase();return e.protocol===`https:`&&e.port===`443`||e.protocol===`http:`&&e.port===`80`?e.hostname.toLowerCase():t}function Ps(e,t){return c({key:{kty:`EC`,crv:`P-256`,d:Buffer.from(t,`hex`).toString(`base64url`),x:e.subarray(1,33).toString(`base64url`),y:e.subarray(33,65).toString(`base64url`)},format:`jwk`})}var Fs=`0.1.0`;const Is=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,Ls=Fs;function Rs(e,t){if(!Is.test(e))throw Error(`${t} must be a valid HTTP token`)}function zs(e,t){let n=!1;for(let t=0;t<e.length;t+=1){let r=e.charCodeAt(t);if(r<32||r===127||r>255){n=!0;break}}if(n||/[()\\]/.test(e))throw Error(`${t} must not contain parentheses, backslashes, control characters, or characters outside Latin-1`)}function Bs(e){let t=`catena-agent-client/${Ls}`;if(!e)return t;Rs(e.name,`appInfo.name`),e.version!==void 0&&Rs(e.version,`appInfo.version`),e.url!==void 0&&zs(e.url,`appInfo.url`);let n=e.version===void 0?e.name:`${e.name}/${e.version}`;return`${e.url===void 0?n:`${n} (${e.url})`} ${t}`}function Vs(e){return{"User-Agent":Bs(e)}}const Hs={pending:{key:`pending`,label:`Pending`,color:`neutral`},processing:{key:`processing`,label:`Processing`,color:`info`},completed:{key:`completed`,label:`Completed`,color:`success`},blocked:{key:`blocked`,label:`Blocked`,color:`error`},failed:{key:`failed`,label:`Failed`,color:`error`}};r.picklist([`created`,`initiated`,`pending`,`pending_approval`,`approved`,`evaluating`,`executing`,`manual_review`,`processing`,`provider_pending`,`completed`,`blocked`,`denied`,`expired`,`failed`,`reversed`]);const Us={created:`pending`,initiated:`pending`,pending:`pending`,pending_approval:`pending`,approved:`processing`,evaluating:`processing`,executing:`processing`,manual_review:`processing`,processing:`processing`,provider_pending:`processing`,completed:`completed`,blocked:`blocked`,denied:`blocked`,expired:`failed`,failed:`failed`,reversed:`failed`};function Ws(e){let t=Us[e];return t?Hs[t]:null}Hs.pending,Hs.processing,Hs.completed,Hs.blocked,Hs.failed;const Gs=r.object({amount:r.string(),asset_id:r.string()}),Ks=r.pipe(r.string(),r.isoTimestamp()),qs=r.object({success:r.literal(!0)}),Js=r.object({id:r.string(),name:r.string(),status:r.string(),organizationId:r.string(),operatorEmail:r.nullable(r.string())}),Ys=r.object({agent:Js}),Xs=r.object({id:r.string(),ruleType:r.picklist([`per_transaction_amount`,`daily_amount`,`weekly_amount`,`monthly_amount`,`hourly_count`,`daily_count`]),thresholdAmount:r.optional(Gs),thresholdCount:r.optional(r.number()),action:r.picklist([`block`,`require_approval`]),requiredApprovals:r.number(),accountAggregationScope:r.picklist([`per_account`,`across_accounts`]),actorAggregationScope:r.picklist([`per_agent`,`per_policy`]),displayOrder:r.number()}),Zs=r.object({id:r.string(),organizationId:r.string(),policyId:r.string(),capability:r.picklist([`query_balance`,`read`,`send`,`transfer`]),accountId:r.string(),rules:r.array(Xs),createdAt:Ks,updatedAt:Ks}),Qs=r.object({mode:r.picklist([`open`,`restricted`]),allowedCounterparties:r.optional(r.array(r.string())),createAction:r.optional(r.picklist([`allow`,`block`,`require_approval`])),allowCreate:r.optional(r.boolean())}),$s=r.object({id:r.optional(r.string()),description:r.optional(r.string()),version:r.optional(r.number()),name:r.string(),capabilities:r.array(r.string()),counterpartyRules:r.optional(Qs),policyCapabilities:r.array(Zs)}),ec=r.object({policy:$s}),tc=r.object({accounts:r.array(r.object({id:r.string(),name:r.string(),type:r.string(),currency:r.string()}))}),nc=r.object({accountId:r.string(),balance:Gs,balances:r.optional(r.object({total:Gs,available:Gs}))}),rc=r.object({id:r.string(),type:r.picklist([`operator-send`,`operator-transfer`,`operator-deposit`,`operator-refund`,`microdeposit`]),action:r.optional(r.string()),status:r.picklist([`pending`,`processing`,`completed`,`failed`,`reversed`]),movementStatus:r.picklist([`initiated`,`provider_pending`,`processing`,`completed`,`failed`,`reversed`,`manual_review`]),direction:r.picklist([`incoming`,`outgoing`]),amount:Gs,fee:Gs,currency:r.string(),counterpartyName:r.optional(r.string()),method:r.optional(r.picklist([`ach`,`wire`,`on-chain`])),memo:r.optional(r.string()),description:r.optional(r.string()),txHash:r.optional(r.string()),createdAt:Ks,completedAt:r.optional(Ks)}),ic=r.object({accountId:r.string(),transactions:r.array(rc),total:r.number()}),ac=r.object({accountId:r.string(),address:r.string(),liquidationAddressId:r.optional(r.string()),source:r.picklist([`wallet`,`liquidation`])}),oc=r.object({id:r.string(),name:r.string(),rails:r.array(r.object({id:r.string(),type:r.string(),walletAddress:r.optional(r.string()),network:r.optional(r.string()),bankName:r.optional(r.string()),accountNumber:r.optional(r.string())}))}),sc=r.object({counterparties:r.array(oc)}),cc=r.pipe(r.picklist([`created`,`evaluating`,`approved`,`pending_approval`,`pending`,`processing`,`blocked`,`denied`,`expired`,`executing`,`completed`,`failed`]),r.transform(e=>Ws(e)?.key??`processing`)),lc=r.object({type:r.literal(`submit_stamp`),signingRequestId:r.string(),signer:r.object({algorithm:r.literal(`p256`),publicKeyHex:r.string()}),preparedBody:r.object({body:r.string(),bodyHash:r.string(),expiresAt:Ks,prepareToken:r.string()})}),uc=r.object({id:r.string(),type:r.picklist([`send`,`transfer`,`wallet_send`,`create_counterparty`,`x402`]),status:cc,reasons:r.array(r.string()),expiresAt:r.optional(r.nullable(Ks),null),data:r.optional(r.nullable(r.record(r.string(),r.unknown())),null),metadata:r.optional(r.object({dataUrl:r.nullable(r.string())})),nextAction:r.optional(lc)});function dc(e){let{nextAction:t,...n}=e;return n}const fc=[`ach`,`wire`,`on-chain`],pc=r.picklist(fc),mc=r.object({type:r.literal(`send`),accountId:r.string(),counterpartyRailId:r.string(),amount:r.string(),method:pc,memo:r.optional(r.string()),description:r.optional(r.string())}),hc=r.object({type:r.literal(`transfer`),accountId:r.string(),toAccountId:r.string(),amount:r.string(),memo:r.optional(r.string()),description:r.optional(r.string())}),gc=r.object({type:r.literal(`create_counterparty`),name:r.string(),email:r.optional(r.string()),rail:r.unknown()}),_c=r.looseObject({scheme:r.string(),network:r.string(),asset:r.string(),amount:r.string(),payTo:r.string(),maxTimeoutSeconds:r.number()}),vc=r.looseObject({url:r.string(),serviceName:r.fallback(r.optional(r.pipe(r.string(),r.maxLength(255))),void 0)}),yc=r.object({type:r.literal(`x402`),accountId:r.string(),paymentRequirements:_c,resource:r.optional(vc)});r.variant(`type`,[mc,hc,gc,yc]);function bc(e){return e.type===`send`||e.type===`transfer`?{...e,amount:{amount:e.amount,asset_id:`USD`}}:e}const xc=r.object({intent:uc});var Sc=class extends Error{status;code;constructor(e,t,n){super(n?`API error ${e} [${n}]: ${t}`:`API error ${e}: ${t}`),this.name=`ApiError`,this.status=e,this.code=n}};const Cc=r.object({error:r.nullish(r.string()),message:r.nullish(r.string()),code:r.nullish(r.string())});async function wc(e){let t=r.safeParse(Cc,await e.json().catch(()=>void 0)),n=t.success?t.output:{};return n.error!=null&&n.message!=null?new Sc(e.status,n.message,n.code??n.error):new Sc(e.status,n.error??n.message??e.statusText,n.code??void 0)}async function Tc(e,t){if(!e.ok)throw await wc(e);return r.parse(t,await e.json())}var Ec=class extends Error{intentId;outcome;constructor(e){let t=e.cause instanceof Error?e.cause.message:String(e.cause);super(e.outcome===`not-submitted`?`Intent ${e.intentId} was created but never submitted; no money moved: ${t}`:`Intent ${e.intentId} submission could not be confirmed: ${t}; reconcile via GET /intents/${e.intentId} before retrying`,{cause:e.cause}),this.name=`IntentSubmitError`,this.intentId=e.intentId,this.outcome=e.outcome}},Dc=class{#e;#t;#n;#r;#i;#a;constructor(e){this.#e=e.baseUrl,this.#t=Bs(e.appInfo),this.#n=e.defaultHeaders??{},this.#r=e.keypair,this.#a=(e.fetch??globalThis.fetch).bind(globalThis),this.#i=Os({keypair:e.keypair,identityUrl:Ds(e.baseUrl,e.agentId)})}#o(e){let t=new Headers({"Content-Type":`application/json`});for(let[e,n]of Object.entries(this.#n))t.set(e,n);for(let[n,r]of Object.entries(e??{}))t.set(n,r);return t.set(`User-Agent`,this.#t),t.delete(`Authorization`),t}async#s(e){let t=new URL(`${this.#e}/v1/agent-api${e.path}`);for(let[n,r]of Object.entries(e.query??{}))r!==void 0&&t.searchParams.set(n,r);let n=new Request(t,{method:e.method,headers:this.#o(e.headers),body:e.body===void 0?null:JSON.stringify(e.body)});return this.#i.sign(n)}async#c(e,t){return Tc(await this.#a(await this.#s(e)),t)}async whoami(){return(await this.#c({method:`GET`,path:`/me`},Ys)).agent}async submitFeedback(e){await this.#c({method:`POST`,path:`/feedback`,body:{body:e}},qs)}async getPolicy(){return(await this.#c({method:`GET`,path:`/policy`},ec)).policy}async listAccounts(){return this.#c({method:`GET`,path:`/accounts`},tc)}async getAccountBalance(e){return this.#c({method:`GET`,path:`/accounts/${encodeURIComponent(e)}/balance`},nc)}async listAccountTransactions(e,t={}){return this.#c({method:`GET`,path:`/accounts/${encodeURIComponent(e)}/transactions`,query:{start:t.start,end:t.end,limit:t.limit?.toString(),offset:t.offset?.toString()}},ic)}async getAccountDepositAddress(e,t){return this.#c({method:`GET`,path:`/accounts/${encodeURIComponent(e)}/deposit-address`,query:{network:t.network,asset:t.asset}},ac)}async listCounterparties(e={}){return this.#c({method:`GET`,path:`/counterparties`,query:{address:e.address,network:e.network}},sc)}async submitIntent(e){let t=await this.#l(e),n=t.nextAction;if(!n)return dc(t);let r;try{let e=await this.#u(n);r=await this.#s({method:`POST`,path:`/intents/${encodeURIComponent(t.id)}/submit-stamp`,body:{preparedBody:n.preparedBody,stamp:e}})}catch(e){throw new Ec({intentId:t.id,outcome:`not-submitted`,cause:e})}try{return await this.#d(r)}catch(e){throw new Ec({intentId:t.id,outcome:`unknown`,cause:e})}}async#l(e){return this.#c({method:`POST`,path:`/intents`,body:{action:bc(e.action)},...e.idempotencyKey!==void 0&&{headers:{"Idempotency-Key":e.idempotencyKey}}},uc)}async#u(e){if(e.signer.publicKeyHex.toLowerCase()!==this.#r.publicKeyHex.toLowerCase())throw Error(`Local signer public key does not match requested signer ${e.signer.publicKeyHex}; linked credential has ${this.#r.publicKeyHex}`);let t=await new bs({apiPublicKey:this.#r.publicKeyHex,apiPrivateKey:this.#r.privateKeyHex}).stamp(e.preparedBody.body);return{publicKeyHex:this.#r.publicKeyHex,stampHeaderName:t.stampHeaderName,stampHeaderValue:t.stampHeaderValue}}async#d(e){return dc((await Tc(await this.#a(e),xc)).intent)}async getIntent(e){return dc(await this.#c({method:`GET`,path:`/intents/${encodeURIComponent(e)}`},uc))}async unlinkAgent(){await this.#c({method:`POST`,path:`/unlink`},qs)}async reportSettlement(e){await this.#c({method:`POST`,path:`/intents/${encodeURIComponent(e.intentId)}/settlement-report`,body:{txHash:e.txHash}},qs)}};const Oc=`https://api.catena.com`,kc=/^127(?:\.(?:25[0-5]|2[0-4]\d|1?\d?\d)){3}$/;function Ac(e){let t=e.replace(/^\[|\]$/g,``);return t===`localhost`||t===`::1`||kc.test(t)}function jc(e,t={}){let n;try{n=new URL(e)}catch{return!1}return n.protocol===`https:`?!0:t.allowLoopbackHttp===!0&&n.protocol===`http:`&&Ac(n.hostname)}function Mc(e,t){if(!jc(e,{allowLoopbackHttp:!0}))throw Error(`${t} must be an https:// URL (http:// is allowed only for a loopback host): "${e}"`)}const Nc=[`registered`,`already_registered`,`not_applicable`,`registration_failed`],Pc=r.pipe(r.string(),r.regex(/^0[23][0-9a-f]{64}$/)),Fc=r.pipe(r.string(),r.regex(/^[0-9a-f]{64}$/)),Ic=r.object({status:r.picklist(Nc),publicKeyHex:r.optional(Pc),reason:r.optional(r.string())}),Lc=r.object({algorithm:r.literal(`p256`),privateKeyHex:Fc,publicKeyHex:Pc,registration:Ic}),Rc=r.object({version:r.literal(`signer-1`),signer:Lc}),zc=r.object({version:r.literal(1),refreshToken:r.pipe(r.string(),r.minLength(1)),sessionToken:r.pipe(r.string(),r.minLength(1)),expiresAt:r.pipe(r.string(),r.isoTimestamp())}),Bc=r.object({version:r.literal(2),refreshToken:r.pipe(r.string(),r.minLength(1)),sessionToken:r.pipe(r.string(),r.minLength(1)),expiresAt:r.pipe(r.string(),r.isoTimestamp()),signer:Lc}),Vc=r.object({version:r.literal(3),signer:Lc}),Hc=r.variant(`version`,[zc,Bc,Vc]),Uc=r.variant(`version`,[Rc,zc,Bc,Vc]);function Wc(e){return r.parse(Hc,e)}function Gc(e){return r.parse(Uc,e)}function Kc(e){let t=r.safeParse(Uc,e);return t.success?t.output:null}function qc(e){return{version:`signer-1`,signer:{algorithm:e.algorithm,privateKeyHex:e.privateKeyHex,publicKeyHex:e.publicKeyHex,registration:{status:`not_applicable`,reason:`pending_claim`}}}}function Jc(e,t){try{return Gc(JSON.parse(e))}catch(e){throw Error(`${t} credential has an unsupported format`,{cause:e})}}function Yc(e){return Wc({version:3,signer:e})}function Xc(e){return JSON.stringify(e)}function Zc(e,t){return JSON.stringify(e)===JSON.stringify(t)}function Qc(e){return(t,n)=>$c(e,t,n)}function $c(e,t,n){return new Promise((r,i)=>{let a=f(e,[...t],{stdio:[`pipe`,`pipe`,`pipe`]}),o=[],s=[],c=!1,l=!1,u=null,d=null,p=null,m=e=>{c||(c=!0,d!==null&&clearTimeout(d),p!==null&&clearTimeout(p),r(e))},h=e=>{c||(c=!0,d!==null&&clearTimeout(d),p!==null&&clearTimeout(p),i(e))};d=setTimeout(()=>{l=!0,a.kill(`SIGTERM`),p=setTimeout(()=>{a.kill(`SIGKILL`),m({stdout:o.join(``),stderr:s.join(``),status:124})},1e3)},3e4),a.stdout.setEncoding(`utf8`),a.stderr.setEncoding(`utf8`),a.stdout.on(`data`,e=>o.push(e)),a.stderr.on(`data`,e=>s.push(e)),a.on(`error`,t=>{h(Error(`Unable to run ${e}: ${t.message}`))}),a.on(`close`,t=>{if(u!==null&&t===0){h(Error(`Unable to write to ${e} stdin: ${u.message}`));return}m({stdout:o.join(``),stderr:s.join(``),status:l?124:t})}),a.stdin.on(`error`,e=>{u=e});try{a.stdin.end(n)}catch(t){h(t instanceof Error?Error(`Unable to write to ${e} stdin: ${t.message}`):Error(`Unable to write to ${e} stdin`))}})}const el=`catena-agent`;function tl(e){if(!Fe.test(e))throw Error(`Invalid credential location for credential storage: "${e}"`);return e}const nl=Qc(`/usr/bin/secret-tool`);function rl(e){return e.status===1&&e.stdout===``&&e.stderr.trim()===``}function il(e,t){if(t.status===0)return;let n=al(t);throw Error(`Linux Secret Service credential ${e} failed (secret-tool exited ${t.status??`without status`}): ${n}`)}function al(e){let t=e.stderr.toLowerCase();return e.status===124?`secret service operation timed out`:t.includes(`cannot autolaunch`)||t.includes(`dbus`)||t.includes(`d-bus`)||t.includes(`org.freedesktop.secrets`)?`secret service session is unavailable`:/\blocked\b/.test(t)?`secret service keyring appears to be locked`:t.includes(`authorization`)||t.includes(`denied`)||t.includes(`not authorized`)?`secret service authorization was denied`:`secret service operation failed; ensure the Secret Service session is available and unlocked`}function ol(e){return e instanceof Error?e.message.includes(`ENOENT`)?Error(`Linux Secret Service credential operation failed: /usr/bin/secret-tool was not found. Install libsecret-tools and ensure a Secret Service keyring is available.`,{cause:e}):e:Error(String(e))}var sl=class{runSecretTool;constructor(e={}){if((e.platform??process.platform)!==`linux`)throw Error(`Linux Secret Service credential storage is only supported on Linux`);this.runSecretTool=e.runSecretTool??nl}async save(e,t){let n=Gc(t),r=tl(e);if(await this.savePassword(r,Xc(n)),!Zc(await this.resolveDirectPassword(r),n))throw Error(`Linux Secret Service credential save verification failed`)}async resolve(e){return this.resolveDirectPassword(tl(e))}async delete(e){await this.deletePassword(tl(e))}async savePassword(e,t){il(`save`,await this.runSecretToolCommand([`store`,`--label`,`${el} ${e}`,`app`,el,`account`,e],t))}async resolvePassword(e){let t=await this.runSecretToolCommand([`lookup`,`app`,el,`account`,e]);return rl(t)?null:(il(`resolve`,t),t.stdout.replace(/\r?\n$/,``))}async resolveDirectPassword(e){let t=await this.resolvePassword(e);return t===null?null:Jc(t,`Linux Secret Service`)}async deletePassword(e){let t=await this.runSecretToolCommand([`clear`,`app`,el,`account`,e]);rl(t)||il(`delete`,t)}async runSecretToolCommand(e,t){try{return await this.runSecretTool(e,t)}catch(e){throw ol(e)}}};const cl=Qc(`/usr/bin/security`),ll=r.object({version:r.literal(1),encoding:r.literal(`base64-json`),chunks:r.pipe(r.number(),r.integer(),r.minValue(1),r.maxValue(64)),sha256:r.pipe(r.string(),r.regex(/^[a-f0-9]{64}$/))});function ul(e){return e.status===44}function dl(e,t){return`${e}:chunk:${t}`}function fl(e){let t=JSON.parse(e),n=Kc(t);if(n!==null)return{kind:`direct`,payload:n};let i=r.safeParse(ll,t);if(i.success)return{kind:`legacy`,manifest:i.output};throw Error(`macOS Keychain credential has an unsupported format`)}function pl(e,t){if(t.status===0)return;let n=ml(t);throw Error(`macOS Keychain credential ${e} failed (security exited ${t.status??`without status`})${n===null?``:`: ${n}`}`)}function ml(e){let t=e.stderr.toLowerCase();return e.status===124?`keychain operation timed out`:t.includes(`stdin isn't a terminal`)?`parent process has no terminal`:t.includes(`user interaction is not allowed`)?`keychain user interaction is not allowed`:t.includes(`authorization`)||t.includes(`denied`)?`keychain authorization was denied`:t.includes(`locked`)?`keychain appears to be locked`:null}function hl(e){for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(n<32||n===127)throw Error(`macOS Keychain credential values cannot contain control characters`)}return`"${e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`)}"`}function gl(e,t){return[`add-generic-password`,`-s`,hl(el),`-a`,hl(e),`-w`,hl(t),`-U`].join(` `)+`
158
+ `}var _l=class{runSecurity;constructor(e={}){if((e.platform??process.platform)!==`darwin`)throw Error(`macOS Keychain credential storage is only supported on macOS`);this.runSecurity=e.runSecurity??cl}async save(e,t){let n=Gc(t),r=tl(e),i=await this.resolveLegacyChunkCount(r,64);if(await this.savePassword(r,Xc(n)),!Zc(await this.resolveDirectPassword(r),n))throw Error(`macOS Keychain credential save verification failed`);await this.deleteChunks(r,i)}async resolve(e){let t=tl(e),n=await this.resolveKeychainItem(t);return n===null?null:n.kind===`direct`?n.payload:this.resolveLegacyPayload(t,n.manifest)}async delete(e){let t=tl(e),n=await this.resolveLegacyChunkCount(t,64);await this.deleteChunks(t,n),await this.deletePassword(t)}async savePassword(e,t){pl(`save`,await this.runSecurity([`-i`],gl(e,t)))}async resolvePassword(e){let t=await this.runSecurity([`find-generic-password`,`-a`,e,`-s`,el,`-w`]);return ul(t)?null:(pl(`resolve`,t),t.stdout.replace(/\r?\n$/,``))}async resolveKeychainItem(e){let t=await this.resolvePassword(e);return t===null?null:fl(t)}async resolveDirectPassword(e){let t=await this.resolveKeychainItem(e);if(t===null)return null;if(t.kind!==`direct`)throw Error(`macOS Keychain credential direct verification failed`);return t.payload}async resolveLegacyPayload(e,t){let n=[];for(let r=0;r<t.chunks;r++){let t=await this.resolvePassword(dl(e,r));if(t===null)throw Error(`macOS Keychain credential chunk is missing`);n.push(t)}let r=n.join(``);if(s(`sha256`).update(r).digest(`hex`)!==t.sha256)throw Error(`macOS Keychain credential checksum mismatch`);return Gc(JSON.parse(Buffer.from(r,`base64`).toString(`utf8`)))}async resolveLegacyChunkCount(e,t){let n=await this.resolvePassword(e);if(n===null)return 0;try{let e=fl(n);return e.kind===`legacy`?e.manifest.chunks:0}catch{return t}}async deleteChunks(e,t){for(let n=0;n<t;n++)await this.deletePassword(dl(e,n))}async deletePassword(e){let t=await this.runSecurity([`delete-generic-password`,`-a`,e,`-s`,el]);ul(t)||pl(`delete`,t)}};function vl(e={}){let t=e.platform??process.platform;if(t===`darwin`)return new _l({platform:t});if(t===`linux`)return new sl({platform:t});throw Error(`Catena credential storage is only supported on macOS and Linux`)}const yl=/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,63}$/,bl=r.object({status:r.optional(r.literal(`linked`),`linked`),bank_url:r.pipe(r.string(),r.minLength(1)),agent_id:r.pipe(r.string(),r.minLength(1)),client_instance_id:r.pipe(r.string(),r.regex(Fe))}),xl=r.object({status:r.literal(`pending_connection`),bank_url:r.pipe(r.string(),r.minLength(1)),client_instance_id:r.pipe(r.string(),r.regex(Fe)),created_at:r.pipe(r.string(),r.isoTimestamp())}),Sl=r.variant(`status`,[bl,xl]);r.object({version:r.literal(1),default_profile:r.optional(r.string()),profiles:r.record(r.string(),Sl),directories:r.optional(r.record(r.string(),r.string()))});const Cl=r.object({version:r.literal(1),default_profile:r.optional(r.string()),profiles:r.record(r.string(),r.unknown()),directories:r.optional(r.record(r.string(),r.unknown()))});function wl(){return T(process.env.HOME??S(),`.catena`)}function Tl(){return T(wl(),`profiles.json`)}function El(e){return yl.test(e)}function Dl(e){if(!El(e))throw Error(`invalid profile name "${e}" (expected [a-zA-Z0-9][a-zA-Z0-9._-]{0,63})`)}function Ol(e){return typeof e!=`object`||!e||!(`code`in e)?!1:typeof e.code==`string`}function kl(e,t){let n;try{n=JSON.parse(e)}catch(e){throw Error(`profiles.json is not valid JSON: ${e instanceof Error?e.message:String(e)}`,{cause:e})}if(typeof n==`object`&&n&&`version`in n){let e=n;if(e.version!==1)throw Error(`profiles.json version ${String(e.version)} is not supported (expected 1)`)}let i=r.parse(Cl,n),a={};for(let[e,n]of Object.entries(i.profiles)){if(!El(e)){t?.(`profiles: dropping invalid profile name "${e}"`);continue}let i=r.safeParse(Sl,n);if(!i.success){t?.(`profiles: dropping malformed profile "${e}"`);continue}a[e]=i.output}if(i.default_profile!==void 0&&(Dl(i.default_profile),!Object.hasOwn(a,i.default_profile)))throw Error(`profiles.json default_profile "${i.default_profile}" is not linked`);let o={};for(let[e,n]of Object.entries(i.directories??{})){if(!w(e)){t?.(`profiles: dropping directory binding with relative path "${e}"`);continue}if(typeof n!=`string`||!El(n)){t?.(`profiles: dropping malformed directory binding "${e}"`);continue}o[e]=n}return{version:1,...i.default_profile===void 0?{}:{default_profile:i.default_profile},profiles:a,...Object.keys(o).length===0?{}:{directories:o}}}function Al(e){try{return kl(g(Tl(),`utf-8`),e)}catch(e){if(e instanceof Error&&Ol(e)&&e.code===`ENOENT`)return{version:1,profiles:{}};throw e}}function jl(){h(wl(),{recursive:!0,mode:448}),p(wl(),448)}function Ml(e){jl();let t=Tl(),n=`${t}.${l(6).toString(`hex`)}.tmp`;x(n,JSON.stringify(e,null,2)+`
159
+ `,{encoding:`utf-8`,mode:384}),v(n,t)}function Nl(e,t){Dl(e);let n=r.parse(Sl,t);Mc(n.bank_url,`profile "${e}" bank_url`);let i=Al();Ml({...i,profiles:{...i.profiles,[e]:n}})}function Pl(e){return e.status===`linked`}function Fl(e,t){return e.replace(/\/+$/,``)===t.replace(/\/+$/,``)}function Il(e,t){let n=Object.entries(Al().profiles).toSorted(([e],[t])=>e.localeCompare(t)).find(([,n])=>Pl(n)&&n.agent_id===e&&Fl(n.bank_url,t));return n===void 0?null:n[0]}function Ll(e,t){let n=Object.fromEntries(Object.entries(e??{}).filter(([,e])=>t(e)));return Object.keys(n).length===0?{}:{directories:n}}function Rl(e){Dl(e);let t=Al(),{[e]:n,...r}=t.profiles;Ml({version:1,...t.default_profile===e||t.default_profile===void 0?{}:{default_profile:t.default_profile},profiles:r,...Ll(t.directories,t=>t!==e)})}function zl(e){try{return _(ee(e))}catch{return ee(e)}}function Bl(e){return Al().directories?.[zl(e)]??null}function Vl(e,t){Dl(t);let n=Al();if(!Object.hasOwn(n.profiles,t))throw Error(`Profile "${t}" is not linked. Run catena link --profile ${t} <agent-id>.`);let r=zl(e);return Ml({...n,directories:{...n.directories,[r]:t}}),r}function Hl(e){let t=Al(),n=zl(e);if(t.directories===void 0||!Object.hasOwn(t.directories,n))return{directory:n,removed:!1};let{[n]:r,...i}=t.directories,{directories:a,...o}=t;return Ml({...o,...Object.keys(i).length===0?{}:{directories:i}}),{directory:n,removed:!0}}function Ul(e){return Dl(e),Al().profiles[e]??null}function Wl(){return`client_${l(16).toString(`hex`)}`}function Gl(e,t){let n=Ul(e);return t.agent_id===void 0?Kl(e,t.bank_url,n):ql(e,t.bank_url,t.agent_id,n)}function Kl(e,t,n){if(n?.status===`linked`)throw Error(`Profile "${e}" is already linked. Choose a different profile name to start agent connection.`);let r=(n?.status===`pending_connection`&&Fl(n.bank_url,t)?n.client_instance_id:null)??Wl();return Nl(e,{status:`pending_connection`,bank_url:t,client_instance_id:r,created_at:n?.status===`pending_connection`?n.created_at:new Date().toISOString()}),r}function ql(e,t,n,r){if(r?.status===`linked`){if(r.agent_id!==n)throw Error(`Profile "${e}" is already linked to a different agent (${r.agent_id}). Link ${n} under a different --profile, or run 'catena unlink --profile ${e}' first to repoint it (add --force if that agent's credential is missing or revoked).`);if(!Fl(r.bank_url,t))throw Error(`Profile "${e}" is already linked to this agent on a different bank (${r.bank_url}). Link under a different --profile, or run 'catena unlink --profile ${e}' first (add --force if that credential is missing or revoked).`);return r.client_instance_id}let i=(r?.status===`pending_connection`&&Fl(r.bank_url,t)?r.client_instance_id:null)??Wl();return Nl(e,{status:`linked`,bank_url:t,agent_id:n,client_instance_id:i}),i}function Jl(e){Dl(e);let t=Al();if(!Object.hasOwn(t.profiles,e))throw Error(`Profile "${e}" is not linked. Run catena link --profile ${e} <agent-id>.`);Ml({...t,default_profile:e})}function Yl(e){let t=e.toLowerCase().replace(/[^a-z0-9._-]+/g,`-`).replace(/^[^a-z0-9]+/,``).slice(0,64);return El(t)?t:`agent`}function Xl(e,t){if(!t(e))return e;for(let n=2;;n++){let r=`${e.slice(0,64-String(n).length-1)}-${n}`;if(!t(r))return r}}function Zl(e){Dl(e.reservationName),Dl(e.profileName);let t=r.parse(Sl,e.profile);Mc(t.bank_url,`profile "${e.profileName}" bank_url`);let n=Al(),{[e.reservationName]:i,...a}=n.profiles;if(!Object.hasOwn(n.profiles,e.reservationName)||i.client_instance_id!==t.client_instance_id)throw Error(`Link reservation "${e.reservationName}" changed during setup (a concurrent link from this directory?). Re-run 'catena link'.`);if(e.profileName!==e.reservationName&&Object.hasOwn(a,e.profileName))throw Error(`Profile "${e.profileName}" already exists; cannot finalize link under that name.`);let o=Object.fromEntries(Object.entries(n.directories??{}).map(([t,n])=>[t,n===e.reservationName?e.profileName:n]));Ml({version:1,...n.default_profile===void 0?{}:{default_profile:n.default_profile===e.reservationName?e.profileName:n.default_profile},profiles:{...a,[e.profileName]:t},...Object.keys(o).length===0?{}:{directories:o}})}function Ql(e){return e instanceof Error?e.message:String(e)}function $l(e){return e??vl()}async function eu(e,t){let n;try{n=Ul(e.profileName)}catch(t){return{ok:!1,profileName:e.profileName,bankUrl:e.fallbackBankUrl,message:Ql(t)}}if(n===null)return{ok:!1,profileName:e.profileName,bankUrl:e.fallbackBankUrl,message:`Profile "${e.profileName}" is not linked. Run 'catena link --profile ${e.profileName}' to authenticate.`};try{Mc(n.bank_url,`profile "${e.profileName}" bank_url`)}catch(t){return{ok:!1,profileName:e.profileName,bankUrl:e.fallbackBankUrl,message:Ql(t)}}if(n.status===`pending_connection`)return{ok:!1,profileName:e.profileName,bankUrl:n.bank_url,message:`Profile "${e.profileName}" is waiting for agent connection approval. Run 'catena link --profile ${e.profileName}' to finish setup.`};let r;try{r=await $l(t).resolve(n.client_instance_id)}catch(t){return{ok:!1,profileName:e.profileName,bankUrl:n.bank_url,message:`Profile "${e.profileName}" credential unavailable for ${n.agent_id}: ${Ql(t)}. Run 'catena link --profile ${e.profileName} ${n.agent_id}' to authenticate.`}}return r===null||r.version===`signer-1`?{ok:!1,profileName:e.profileName,bankUrl:n.bank_url,message:`Profile "${e.profileName}" credential unavailable for ${n.agent_id}. Run 'catena link --profile ${e.profileName} ${n.agent_id}' to authenticate.`}:r.version===1?{ok:!1,profileName:e.profileName,bankUrl:n.bank_url,message:`Profile "${e.profileName}" credential for ${n.agent_id} has no signing key. Run 'catena link --profile ${e.profileName} ${n.agent_id}' to authenticate.`}:{ok:!0,profileName:e.profileName,bankUrl:n.bank_url,agentId:n.agent_id,clientInstanceId:n.client_instance_id,signer:r.signer}}const tu={name:`catena-cli`,version:se},nu=`CATENA_PROFILE`;function ru(e,t,n,r){if(e.directories===void 0)return null;let i;try{i=_(t)}catch{return null}let a=Object.entries(e.directories).map(([e,t])=>[e.replace(/\/+$/,``)||`/`,t]).filter(([e])=>i===e||i.startsWith(e===`/`?`/`:`${e}/`)).toSorted(([e],[t])=>t.length-e.length),o=null;for(let[t,n]of a){if(Object.hasOwn(e.profiles,n))return n;o??=`${t} -> "${n}"`}if(o===null)return null;if(n===`error`)throw Error(`This directory is bound to a profile that no longer exists (${o}). Run 'catena profiles unbind' here, bind it with 'catena profiles bind <name>', or run 'catena link' to re-establish it.`);return r?.(`profiles: ignoring stale directory binding ${o}`),null}function iu(e,t,n){if(e.flag!==void 0&&e.flag.length>0)return Dl(e.flag),{name:e.flag,source:`flag`};if(e.env!==void 0&&e.env.length>0){if(!El(e.env))throw Error(`${nu} is set to an invalid profile name "${e.env}"`);return{name:e.env,source:`env`}}if(e.cwd!==void 0){let r=ru(t,e.cwd,n,e.log);if(r!==null)return{name:r,source:`directory`}}return t.default_profile===void 0?null:{name:t.default_profile,source:`default`}}function au(e){return iu(e,Al(e.log),`ignore`)}function ou(e){let t=Al(e.log),n=iu(e,t,`error`);if(n!==null)return n;let r=Object.keys(t.profiles),i=Object.entries(t.profiles).filter(([,e])=>Pl(e)).map(([e])=>e);if(i.length===1){let[e]=i;return{name:e,source:`single`}}if(i.length===0){if(r.length===1){let[e]=r;return{name:e,source:`single`}}return r.length>1&&e.log?.(`profiles: ignoring ${r.length} pending profiles (${r.toSorted().join(`, `)}); none is linked`),{name:`default`,source:`fallback`}}throw Error(`Multiple profiles exist and none is selected (${i.toSorted().join(`, `)}). Pass --profile <name>, set ${nu}, run 'catena profiles use <name>', or run 'catena link' from an agent directory to bind it.`)}function su(e){return new Dc({baseUrl:e.bankUrl,agentId:e.agentId,keypair:e.signer,appInfo:tu})}function cu(){return vl()}async function lu(e){let t;try{t=ou({flag:e,env:process.env[nu],cwd:process.cwd(),log:e=>console.error(e)}).name}catch(e){return L(e)}let n=await eu({profileName:t,fallbackBankUrl:Oc},void 0);return n.ok||L(n.message),su(n)}const uu=new Set([`unknown_key`,`key_revoked`,`client_unlinked`]),du=new Set([`signature_auth_disabled`,`missing_auth`]);function fu(e,t){if(!(e instanceof Sc)||e.code===void 0)return e;let n=t===void 0?`catena link`:`catena link --profile ${t}`;return uu.has(e.code)?Error(`This machine's signing key was rejected by the bank (${e.code}). Run '${n}' to re-authenticate.`):e.code===`client_upgrade_required`?Error(`This CLI version (${tu.version}) is no longer supported by the bank. Run 'npm i -g @catena/cli' and retry.`):du.has(e.code)?Error(`This bank does not support key-based authentication (${e.code}). Upgrade the bank, or use an older CLI release that authenticates with session tokens.`):e.code===`invalid_signature`&&e.message.includes(`created_out_of_window`)?Error(`The bank rejected this request's timestamp (created_out_of_window). Check this machine's system clock and retry.`):e}function pu(e,t){console.log(t?.compact?JSON.stringify(e):JSON.stringify(e,null,2))}function mu(e){return e.profile===void 0||e.profile.length===0?void 0:e.profile}async function hu(e,t){try{return await t(await lu(e))}catch(t){return L(fu(t,e))}}function gu(e,t){return async(n,r)=>{let i=await hu(e,n);return pu(i,t),process.exit(r?.exitCode?r.exitCode(i):0)}}function _u(e){return gu(mu(e),{compact:e.json===!0})}const vu=de.options,yu=r.pipe(r.string(),r.regex(/^\d+$/,`must be a non-negative integer`),r.transform(Number),r.maxValue(2**53-1,`must be at most ${2**53-1}`)),bu=r.pipe(yu,r.maxValue(200,`must be at most 200`)),xu={profile:Pe,json:U},Su=H(xu),Cu=H({account:V({description:`Account id`,required:!0,schema:Ie}),...xu}),wu=H({account:V({description:`Account id`,required:!0,schema:Ie}),start:B({description:`Only include transactions at or after this ISO 8601 time`}),end:B({description:`Only include transactions at or before this ISO 8601 time`}),limit:B({description:`Maximum transactions to return (default 50, max 200)`,schema:bu}),offset:B({description:`Number of transactions to skip for pagination`,schema:yu}),...xu}),Tu=H({account:V({description:`Account id`,required:!0,schema:Ie}),network:Ne({description:`Deposit network; defaults to base. Availability depends on the connected environment.`,default:pe}),asset:ke({description:`Deposit asset (${vu.join(`|`)})`,choices:vu,default:me}),...xu}),Eu=e({meta:{name:`accounts`,description:`Inspect bank accounts`},subCommands:{list:e({meta:{name:`list`,description:`List accounts accessible under the agent's policy`},args:Su.args,async run({args:e}){await _u(Su.parse(e))(e=>e.listAccounts())}}),balance:e({meta:{name:`balance`,description:`Request an account balance through the policy engine`},args:Cu.args,async run({args:e}){let t=Cu.parse(e);await _u(t)(e=>e.getAccountBalance(t.account))}}),transactions:e({meta:{name:`transactions`,description:`Read an account's transaction history through the policy engine`},args:wu.args,async run({args:e}){let t=wu.parse(e);await _u(t)(e=>e.listAccountTransactions(t.account,{start:t.start,end:t.end,limit:t.limit,offset:t.offset}))}}),"deposit-address":e({meta:{name:`deposit-address`,description:`Read an account deposit address through the policy engine`},args:Tu.args,async run({args:e}){let t=Tu.parse(e);await _u(t)(e=>e.getAccountDepositAddress(t.account,{network:t.network,asset:t.asset}))}})}}),Du=r.pipe(r.string(),r.minLength(1,`must not be empty`)),Ou={profile:Pe,json:U},ku=H({address:B({description:`Only counterparties with a wallet rail matching this address (0x…)`,schema:fe}),network:Ne({description:`Only counterparties with a wallet rail on this network (e.g. base)`}),...Ou}),Au=B({description:`Counterparty name`,required:!0,schema:Du}),ju=B({description:`Optional contact email`}),Mu=H({name:Au,"bank-name":B({description:`Receiving bank name`,required:!0,schema:Du}),"routing-number":B({description:`9-digit ABA routing number`,required:!0,schema:Du}),"account-number":B({description:`Receiving bank account number`,required:!0,schema:Du}),"account-type":ke({description:`checking | savings (default checking)`,choices:[`checking`,`savings`]}),"address-street":B({description:`Street address of the receiving bank account holder`,required:!0,schema:Du}),"address-city":B({description:`City`,required:!0,schema:Du}),"address-state":B({description:`State (e.g. NY)`,required:!0,schema:Du}),"address-postal-code":B({description:`Postal code`,required:!0,schema:Du}),"address-country":B({description:`Default USA`}),email:ju,...Ou}),Nu=H({name:Au,address:B({description:`Wallet address (0x… or ENS name on EVM networks)`,required:!0,schema:Du}),network:Ne({description:`Wallet network; defaults to base. Availability depends on the connected environment.`,default:pe}),email:ju,...Ou}),Pu=e({meta:{name:`list`,description:`List counterparties available under the agent's policy`},args:ku.args,async run({args:e}){let t=ku.parse(e);await _u(t)(e=>e.listCounterparties({address:t.address,network:t.network}))}});function Fu(e){return e&&e.length>0?e:void 0}function Iu(e){let t=Fu(e.email);return{type:`create_counterparty`,name:e.name,email:t,rail:{type:`bank`,bankName:e[`bank-name`],routingNumber:e[`routing-number`],accountNumber:e[`account-number`],addressStreet:e[`address-street`],addressCity:e[`address-city`],addressState:e[`address-state`],addressPostalCode:e[`address-postal-code`],...e[`account-type`]?{accountType:e[`account-type`]}:{},...e[`address-country`]?{addressCountry:e[`address-country`]}:{}}}}function Lu(e){let t=Fu(e.email);return{type:`create_counterparty`,name:e.name,email:t,rail:{type:`wallet`,walletAddress:e.address,network:e.network}}}const Ru=e({meta:{name:`counterparties`,description:`Inspect and create counterparties`},subCommands:{list:Pu,create:e({meta:{name:`create`,description:`Request counterparty creation through the policy engine. Prints an intent envelope.`},subCommands:{bank:e({meta:{name:`bank`,description:`Request bank counterparty creation through the policy engine. Prints an intent envelope.`},args:Mu.args,async run({args:e}){let t=Mu.parse(e),n=Iu(t);await _u(t)(e=>e.submitIntent({action:n}))}}),wallet:e({meta:{name:`wallet`,description:`Request wallet counterparty creation through the policy engine. Prints an intent envelope.`},args:Nu.args,async run({args:e}){let t=Nu.parse(e);await _u(t)(e=>e.submitIntent({action:Lu(t)}))}})}})}}),zu=4e3;async function Bu(){process.stdin.setEncoding(`utf8`);let e=``;for await(let t of process.stdin)e+=t;return e}async function Vu(e){return e===void 0?(process.stdin.isTTY&&L(`<message>: pass a quoted message or pipe it on stdin; a message starting with "-" needs -- before it (catena feedback -- "<message>") or stdin`),Bu()):e}const Hu=H({message:V({description:`Plain-text feedback (1-4000 chars); omit to pipe on stdin`}),profile:Pe,json:U}),Uu=e({meta:{name:`feedback`,description:`Send free-form feedback about Catena to the Catena team`},args:Hu.args,async run({args:e}){(Array.isArray(e._)?e._:[]).length>1&&L(`<message>: pass the message as a single quoted argument`);let t=Hu.parse(e),n=(await Vu(t.message)).trim();n.length===0&&L(`<message>: must not be empty`),n.length>zu&&L(`<message>: must be at most ${zu} characters (got: ${n.length})`),await _u(t)(async e=>(await e.submitFeedback(n),{ok:!0}))}});function Wu(e){return`# Catena CLI Agent Guide
5
160
 
6
161
  CLI version: ${e}
7
162
 
8
- Examples below use \`npx -y @catena/cli@latest ...\` so agents fetch the current
9
- CLI. If \`catena\` is already installed, use \`catena ...\` with the same
10
- arguments. Every non-\`link\` command resolves credentials from the selected
11
- profile and prints JSON on stdout; errors and upgrade notices go to stderr. The
12
- \`guide\` command is documentation, so it prints this Markdown guide on stdout.
163
+ Examples below use \`catena\`. If it is not on PATH, or a command warns that a
164
+ newer version is available, run \`npm i -g @catena/cli\`. Every non-\`link\`
165
+ command resolves credentials from the selected profile and prints JSON on
166
+ stdout; errors and upgrade notices go to stderr. The \`guide\` command is
167
+ documentation, so it prints this Markdown guide on stdout.
168
+
169
+ The stored credential is a per-profile signing key: the CLI signs every request
170
+ with it, so there are no sessions to expire or refresh. When the bank rejects
171
+ the key, the error says to run \`catena link\`; follow it rather than retrying.
13
172
 
14
173
  Every command supports \`--help\`; use it for exact syntax, choices, and
15
174
  defaults rather than guessing. This guide covers what \`--help\` cannot: when to
@@ -17,29 +176,36 @@ run each command, how ids flow between them, and how to read the results.
17
176
 
18
177
  ## Setup
19
178
 
20
- 1. Run \`npx -y @catena/cli@latest whoami\`. If it returns an agent, you are
179
+ 1. Run \`catena whoami\`. If it returns an agent, you are
21
180
  linked and can continue.
22
181
  2. Otherwise run \`link\`. There are three flows:
23
182
  - Link an existing agent on the customer's own machine: ask the customer for
24
183
  the agent id (\`agent_...\`) shown in the Catena console, then run
25
- \`npx -y @catena/cli@latest link <agent-id>\`. A browser opens for approval
184
+ \`catena link <agent-id>\`. A browser opens for approval
26
185
  and writes the profile on success.
27
- - Create a new agent: run \`npx -y @catena/cli@latest link\` with no agent id.
186
+ - Create a new agent: run \`catena link\` with no agent id.
28
187
  The CLI starts a console approval flow and prints a verification URL and
29
188
  short code. Relay both to the customer to approve in the Catena console.
30
189
  Add \`--name "Agent name"\` to suggest a name for the new agent.
31
- - Remote or headless: \`npx -y @catena/cli@latest link <agent-id> --no-browser\`
190
+ - Remote or headless: \`catena link <agent-id> --no-browser\`
32
191
  uses the device-code flow. Relay the printed URL and code, and keep the
33
192
  command running until the customer approves from their own device.
34
193
 
35
194
  \`--bank-url\` defaults to \`$CATENA_API_URL\` or production. Re-run \`link\`
36
- after timeout, denial, or revocation, and also if a send or transfer fails with
37
- a local-signer error. A successful \`link\` names the profile after the agent
38
- when no profile is selected, and binds the working directory to it (the home
195
+ after denial or revocation, when a command reports the bank rejected this
196
+ machine's signing key, and if a send or transfer fails with a local-signer
197
+ error. Failures that relinking does not fix: a timestamp error
198
+ (\`created_out_of_window\`) means this machine's clock is wrong; a bank
199
+ that does not support key-based authentication needs a bank upgrade or an
200
+ older CLI release; and an upgrade-required error
201
+ (\`client_upgrade_required\`) means the bank no longer accepts this CLI
202
+ version — run \`npm i -g @catena/cli\` and retry. A successful \`link\`
203
+ names the profile after the agent when no profile is selected, and binds the
204
+ working directory to it (the home
39
205
  directory is never bound), so later commands in that directory select the same
40
206
  agent automatically.
41
207
 
42
- \`npx -y @catena/cli@latest unlink\` disconnects the selected profile. Add
208
+ \`catena unlink\` disconnects the selected profile. Add
43
209
  \`--profile <name>\` to target another profile. Add \`--force\` to clear a
44
210
  profile locally without contacting the server when its credential is missing,
45
211
  revoked, or a link was interrupted.
@@ -84,11 +250,11 @@ When several profiles exist and none is selected, credentialed commands fail
84
250
  with the profile list instead of guessing an agent identity; select one with
85
251
  any tier above. Manage profiles with:
86
252
 
87
- npx -y @catena/cli@latest profiles current
88
- npx -y @catena/cli@latest profiles list
89
- npx -y @catena/cli@latest profiles use <name>
90
- npx -y @catena/cli@latest profiles bind <name> [path]
91
- npx -y @catena/cli@latest profiles unbind [path]
253
+ catena profiles current
254
+ catena profiles list
255
+ catena profiles use <name>
256
+ catena profiles bind <name> [path]
257
+ catena profiles unbind [path]
92
258
 
93
259
  \`profiles current\` reports which tier selected the profile on \`.source\`.
94
260
  \`profiles list\` shows each profile's bound directories. \`bind\` and
@@ -108,9 +274,9 @@ Run \`accounts list\` before a send or transfer. Account ids (\`acct_...\`) feed
108
274
 
109
275
  Direct per-account reads are plain reads, not intents:
110
276
 
111
- npx -y @catena/cli@latest accounts balance acct_...
112
- npx -y @catena/cli@latest accounts transactions acct_...
113
- npx -y @catena/cli@latest accounts deposit-address acct_...
277
+ catena accounts balance acct_...
278
+ catena accounts transactions acct_...
279
+ catena accounts deposit-address acct_...
114
280
 
115
281
  \`accounts transactions\` returns \`.transactions[]\` newest first plus a
116
282
  \`.total\` count. Page with \`--limit\` and \`--offset\`. A transaction's
@@ -121,18 +287,20 @@ about access.
121
287
 
122
288
  Available networks depend on the connected environment, and \`--network\` must
123
289
  match the account's own network. Production serves \`base\`; non-production
124
- environments may also serve testnet rails such as \`base-sepolia\`. The CLI
125
- resolves the network against what the connected environment actually enables and
126
- rejects one it does not offer, listing the enabled networks. Requesting a
127
- network the account is not on fails with a configured-network error. Read the
128
- account's network rather than guessing.
290
+ environments may also serve testnet rails such as \`base-sepolia\`. A network
291
+ the connected environment does not enable fails with a server error listing the
292
+ enabled networks. Requesting a
293
+ network the account is not on fails with a configured-network error. No command
294
+ returns an account's network directly: default to \`base\`, and on a
295
+ configured-network error retry with another enabled network rather than
296
+ inventing one.
129
297
 
130
298
  ## Counterparties
131
299
 
132
300
  Before creating a wallet counterparty, check whether the address is already
133
301
  saved:
134
302
 
135
- npx -y @catena/cli@latest counterparties list \\
303
+ catena counterparties list \\
136
304
  --address 0x... --network base
137
305
 
138
306
  Both filters must hold on the same rail, so an address saved on another
@@ -148,8 +316,8 @@ matched by its resolved address.
148
316
  \`counterparties create\` is split into \`bank\` and \`wallet\` subcommands.
149
317
  Use the rail-specific help for exact required fields, choices, and defaults:
150
318
 
151
- npx -y @catena/cli@latest counterparties create bank --help
152
- npx -y @catena/cli@latest counterparties create wallet --help
319
+ catena counterparties create bank --help
320
+ catena counterparties create wallet --help
153
321
 
154
322
  Pass destination details from the user. Do not invent missing routing, account,
155
323
  address, wallet, network, or contact details.
@@ -175,13 +343,14 @@ Before either:
175
343
 
176
344
  Examples:
177
345
 
178
- npx -y @catena/cli@latest send --account acct_... --rail cprl_... \\
346
+ catena send --account acct_... --rail cprl_... \\
179
347
  --amount 125.00 --method ach
180
- npx -y @catena/cli@latest transfer --from acct_... --to acct_... \\
348
+ catena transfer --from acct_... --to acct_... \\
181
349
  --amount 125.00
182
350
 
183
- \`--method\` is \`ach\`, \`wire\`, or \`on-chain\`. See \`--help\` for memo and
184
- description flags.
351
+ \`--method\` must match the rail type: \`ach\` and \`wire\` require a bank
352
+ rail, \`on-chain\` requires a wallet rail. A mismatch fails with
353
+ \`rail_method_mismatch\`. See \`--help\` for memo and description flags.
185
354
 
186
355
  Both create the intent and return immediately. There is no wait or poll flag.
187
356
  The command exits 0 once the intent is submitted even if the intent is later
@@ -195,7 +364,7 @@ already \`completed\`.
195
364
  challenge, pays it in USDC from a non-custodial wallet account, then retries
196
365
  the request with the payment attached:
197
366
 
198
- npx -y @catena/cli@latest x402 --url https://api.example.com/paid \\
367
+ catena x402 --url https://api.example.com/paid \\
199
368
  --account acct_... --max-amount 0.25
200
369
 
201
370
  To POST a request body (e.g. an OpenAI-compatible chat-completions call), pass
@@ -203,20 +372,42 @@ To POST a request body (e.g. an OpenAI-compatible chat-completions call), pass
203
372
  \`--method\` / \`--content-type\`. Use \`@path\` to read the body from a file or
204
373
  \`@-\` for stdin:
205
374
 
206
- npx -y @catena/cli@latest x402 --url https://api.example.com/chat \\
375
+ catena x402 --url https://api.example.com/chat \\
207
376
  --account acct_... --max-amount 0.05 \\
208
377
  --data '{"model":"...","messages":[{"role":"user","content":"hi"}]}'
209
378
 
210
379
  Constraints: the source account must be a wallet account on the challenge's
211
- network, and the challenge's \`payTo\` address must already exist as a saved
212
- counterparty wallet rail — check first with
213
- \`counterparties list --address <payTo> --network <network>\` and create the
214
- counterparty only when that returns no match. Always pass \`--max-amount\`
380
+ network (a mainnet wallet cannot pay a testnet challenge and vice versa). If it
381
+ is not, nothing is charged: the result carries \`.networkMismatch\`
382
+ (\`.requiredNetworks\` as onchain slugs like \`base\`, \`.requiredNetworkIds\` as
383
+ the raw CAIP-2 ids) and the command exits non-zero — re-run with \`--account\`
384
+ set to a wallet on one of those networks (account ids are in \`accounts list\`).
385
+ The challenge's \`payTo\` address must also already exist as a saved counterparty
386
+ wallet rail — Catena never auto-adds it (a 402's \`payTo\` is untrusted), so
387
+ creating one stays a deliberate, policy-gated step. You can precheck with
388
+ \`counterparties list --address <payTo> --network <network>\`, but you do not
389
+ need the address up front: if it is unsaved, nothing is charged and the result
390
+ carries \`.counterpartyNotFound\` (\`payTo\`, \`network\` slug, \`networkId\`,
391
+ \`serviceName\` when advertised, \`.nameIsPlaceholder\`, and \`.createCommand\`
392
+ — the \`counterparties create wallet\` command to run, also embedded in
393
+ \`.error\` for humans), and the command exits non-zero. When
394
+ \`.nameIsPlaceholder\` is false the \`--name\` in that command is the endpoint's
395
+ own advertised name: it is unverified, so confirm it names a service you trust
396
+ before creating, since it becomes the counterparty's allowlist label. When
397
+ \`.nameIsPlaceholder\` is true the endpoint advertised no usable name and
398
+ \`--name '<name>'\` is a literal placeholder — replace it with a name you choose
399
+ rather than running the command as-is.
400
+ Create the counterparty (it may itself require approval), then re-run
401
+ the SAME x402 command. Always pass \`--max-amount\`
215
402
  (USD decimal) when the user named a price ceiling; challenges above it are
216
403
  refused before any payment. Payments follow the same policy as sends
217
- (send capability, counterparty allowlist, spend limits) and cannot wait for
218
- human approval; a policy that requires approval for the amount blocks the
219
- payment. The JSON result carries \`.paid\`, \`.payment\` (intent id, atomic
404
+ (send capability, counterparty allowlist, spend limits). A payment over the
405
+ policy's approval threshold parks for a human approval instead of paying:
406
+ the result carries \`.approvalPending\` (intent id, expiry, reasons) and the
407
+ command exits non-zero. Ask an operator to approve it in the console, then
408
+ re-run the SAME command (same URL, same price) — the retry consumes the
409
+ approval and pays without re-approving; if the approval expires unused, the
410
+ re-run parks a fresh one. The JSON result carries \`.paid\`, \`.payment\` (intent id, atomic
220
411
  USDC amount, recipient), and a preview of the response \`.body\`. A payment
221
412
  that succeeded but whose retry failed can be re-read with
222
413
  \`intents get <id>\`: \`.data.x402.paymentSignature\` is the
@@ -236,7 +427,7 @@ summarized when present.
236
427
 
237
428
  Re-read current state with:
238
429
 
239
- npx -y @catena/cli@latest intents get int_...
430
+ catena intents get int_...
240
431
 
241
432
  \`.data\` carries the result once one exists: the linked transaction for send or
242
433
  transfer, or the created counterparty for creation. It is \`null\` when there is
@@ -252,178 +443,39 @@ The exit code reflects whether the command ran, not an intent's policy outcome.
252
443
  A submitted-but-blocked send still exits 0, so read \`.status\` and \`.reasons\`.
253
444
 
254
445
  Every credentialed command exits 0 after printing its JSON result, or 1 on error
255
- with the message on stderr.
446
+ with the message on stderr. The one exception is \`x402\`: it also exits non-zero
447
+ (with its JSON still on stdout) when the payment parked for approval
448
+ (\`.approvalPending\`) or settled but its paid retry failed (\`.retryFailed\`) — both
449
+ need follow-up, so they are not plain successes.
450
+
451
+ ## Persisting Across Sessions
452
+
453
+ This guide is only found by an agent that already knows to use the CLI; the
454
+ Catena skill is what makes that knowledge survive across sessions and
455
+ projects. When it is not installed and setting this machine up for future
456
+ Catena work makes sense, offer to install it:
457
+
458
+ npx -y skills add catena-labs/skills --skill catena-cli --global --yes
459
+
460
+ Do not persist the routing by writing to CLAUDE.md, AGENTS.md, or harness
461
+ memory instead; the skill is the only sanctioned mechanism.
256
462
 
257
463
  ## Feedback
258
464
 
259
465
  If the CLI is confusing, missing a capability, or cannot express the operation
260
466
  you need, tell the Catena team:
261
467
 
262
- npx -y @catena/cli@latest feedback "Plain-text message (max 4000 chars)"
468
+ catena feedback "Plain-text message (max 4000 chars)"
263
469
 
264
470
  The message must be 1-4000 characters and is write-only. Longer messages can be
265
471
  piped on stdin instead of passed as an argument.
266
- `}const Hr=e({meta:{name:`guide`,description:`Print the Catena CLI agent operating guide`},run(){console.log(Vr(I))}}),Ur=W({id:Te({description:`Intent id (e.g. int_…)`,required:!0,schema:G}),profile:Ae,json:je}),Wr=e({meta:{name:`intents`,description:`Inspect intent receipts returned by governed operations`},subCommands:{get:e({meta:{name:`get`,description:`Look up the current state of an intent created by this agent`},args:Ur.args,async run({args:e}){let t=Ur.parse(e);await mr(t)(e=>e.getIntent(t.id))}})}});function Gr(e){e&&process.stderr.write(`Failed to open browser: ${e.message}\n`)}function Kr(e){process.platform===`darwin`?l(`open`,[e],Gr):process.platform===`win32`?l(`cmd`,[`/c`,`start`,``,e],Gr):l(`xdg-open`,[e],Gr)}const qr=r.pipe(r.string(),r.isoTimestamp());function Jr(e){return r.is(qr,e)}function Yr(e){if(typeof e!=`object`||!e||!(`message`in e))return;let t=e;return typeof t.message==`string`?t.message:void 0}function Xr(e){return typeof e!=`object`||!e||!(`access_token`in e)?!1:typeof e.access_token==`string`}function Zr(e){if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.agentId==`string`&&typeof t.name==`string`&&typeof t.sessionToken==`string`&&typeof t.refreshToken==`string`&&typeof t.expiresAt==`string`&&Jr(t.expiresAt)&&(t.activated===void 0||typeof t.activated==`boolean`)}function Qr(e){if(typeof e!=`object`||!e)return!1;let t=e;return Tt.some(e=>e===t.status)&&(t.publicKeyHex===void 0||typeof t.publicKeyHex==`string`)&&(t.reason===void 0||typeof t.reason==`string`)}async function $r(e){let{bankUrl:t,authCode:n,verifier:r,redirectUri:i,agentId:a,clientInstanceId:o,clientLabel:s,log:c=()=>{},clientInfo:l,existingSigner:u,generateSignerKeypair:d=Et}=e,f=Le(l);c(`Exchanging authorization code...`);let p=await fetch(`${t}/v1/auth/oauth2/token`,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`,...f},body:new URLSearchParams({grant_type:`authorization_code`,code:n,code_verifier:r,client_id:`catena-cli`,redirect_uri:i}).toString()});if(!p.ok)return{ok:!1,message:Yr(await p.json().catch(()=>({message:`Token exchange failed`})))??p.statusText};let m=await p.json();if(!Xr(m))return{ok:!1,message:`Token exchange response missing access_token`};c(`Claiming agent...`);let h=u?{algorithm:u.algorithm,privateKeyHex:u.privateKeyHex,publicKeyHex:u.publicKeyHex}:d(),g=await fetch(`${t}/v1/agent-api/claim`,{method:`POST`,headers:{"Content-Type":`application/json`,...f,Authorization:`Bearer ${m.access_token}`},body:JSON.stringify({agentId:a,clientInstanceId:o,...s===void 0?{}:{clientLabel:s}})});if(!g.ok)return{ok:!1,message:Yr(await g.json().catch(()=>({message:`Claim failed`})))??g.statusText};let _=await g.json();return Zr(_)?ei({bankUrl:t,claim:_,clientInstanceId:o,signerKeypair:h,identityHeaders:f,log:c}):{ok:!1,message:`Claim response missing required fields`}}async function ei(e){let{bankUrl:t,claim:n,clientInstanceId:r,signerKeypair:i,identityHeaders:a}=e;(e.log??(()=>{}))(`Registering signer...`);let o=await ni({bankUrl:t,sessionToken:n.sessionToken,keypair:i,identityHeaders:a});return o.status===`registration_failed`?(n.activated!==!1&&await ri({bankUrl:t,sessionToken:n.sessionToken,identityHeaders:a}),o.reason===`public_key_conflict`?{ok:!1,message:`This device's signing key conflicts with the one the bank already holds for this agent, or that key is already registered to another agent. Re-running link will not fix this; this agent's signing key cannot be reset automatically, so ask an operator or support to reset it before linking again.`}:{ok:!1,message:`Signer registration failed (${o.reason??`unknown`}). Run link again to retry.`}):{ok:!0,result:{agentId:n.agentId,clientInstanceId:r,agentName:n.name,sessionToken:n.sessionToken,refreshToken:n.refreshToken,expiresAt:n.expiresAt,signer:{...i,registration:o}}}}function ti(e){return typeof e!=`object`||!e||!(`signer`in e)?!1:Qr(e.signer)}async function ni(e){let t;try{t=await fetch(`${e.bankUrl}/v1/agent-api/signer/register`,{method:`POST`,headers:{"Content-Type":`application/json`,...e.identityHeaders,Authorization:`Bearer ${e.sessionToken}`},body:JSON.stringify({signer:{algorithm:e.keypair.algorithm,publicKeyHex:e.keypair.publicKeyHex}})})}catch{return{status:`registration_failed`,reason:`registration_request_failed`}}if(t.status===409)return{status:`registration_failed`,reason:`public_key_conflict`};if(!t.ok)return{status:`registration_failed`,reason:`provider_registration_failed`};let n=await t.json().catch(()=>null);return ti(n)?n.signer:{status:`registration_failed`,reason:`registration_response_malformed`}}async function ri(e){try{await fetch(`${e.bankUrl}/v1/agent-api/unlink`,{method:`POST`,headers:{...e.identityHeaders,Authorization:`Bearer ${e.sessionToken}`}})}catch{}}function ii(e){return`${e}-signer`}async function ai(e,t){let n=await e.resolve(t);if(n!==null&&`signer`in n)return n.signer;let r=await e.resolve(ii(t));if(r!==null&&`signer`in r)return r.signer}async function oi(e,t,n=Et){let r=await ai(e,t);if(r!==void 0)return r;let i=Vt(n());return await e.save(ii(t),i),i.signer}const si=[53682,53683,53684,53685,53686,53687];function ci(e){return new Promise((t,n)=>{let r=0,i=()=>{if(r>=si.length){n(Error(`No registered loopback callback ports are available`));return}let a=si[r],o=t=>{if(e.off(`error`,o),t.code===`EADDRINUSE`){r++,i();return}n(t)};e.once(`error`,o),e.listen(a,`127.0.0.1`,()=>{e.off(`error`,o),t(a)})};i()})}async function li(e){let{bankUrl:t,agentId:n,clientInstanceId:r,clientLabel:i,timeoutMs:a=300*1e3,log:o=()=>{},clientInfo:l,existingSigner:u}=e;_n(t,`bankUrl`);let d=c(32).toString(`base64url`),f=s(`sha256`).update(d).digest(`base64url`),p=c(16).toString(`hex`),m=e=>{let n=new URL(`${t}/link-complete`);return n.searchParams.set(`linked`,e),n.toString()},h=e=>{let n=new URL(`${t}/link-complete`);return n.searchParams.set(`error`,e),n.toString()};return new Promise((e,s)=>{let c=0,g=!1,_=null,v=t=>{g||(g=!0,_&&clearTimeout(_),x.close(),e(t))},y=e=>{g||(g=!0,_&&clearTimeout(_),x.close(),s(e))},b=e=>{o(`Link failed: ${e}`),v(null)},x=T((e,t)=>{S(e,t).catch(e=>{let n=Yr(e)??`Unexpected error`;t.headersSent||(t.writeHead(302,{Location:h(n)}),t.end()),o(`Link failed: ${n}`),v(null)})});async function S(e,a){let s=new URL(e.url??`/`,`http://localhost`);if(s.pathname!==`/callback`){a.writeHead(404),a.end(`Not found`);return}let f=s.searchParams.get(`error`);if(f){let e=s.searchParams.get(`error_description`)??f;a.writeHead(302,{Location:h(e)}),a.end(),b(`OAuth error: ${e}`);return}if(s.searchParams.get(`state`)!==p){a.writeHead(302,{Location:h(`State mismatch during OAuth callback`)}),a.end(),b(`State mismatch during OAuth callback`);return}let g=s.searchParams.get(`code`);if(!g){a.writeHead(302,{Location:h(`Missing authorization code`)}),a.end(),b(`Missing authorization code`);return}let _=await $r({bankUrl:t,authCode:g,verifier:d,redirectUri:`http://127.0.0.1:${c}/callback`,agentId:n,clientInstanceId:r,clientLabel:i,log:o,clientInfo:l,existingSigner:u});if(!_.ok){a.writeHead(302,{Location:h(_.message)}),a.end(),o(`Link failed: ${_.message}`),v(null);return}a.writeHead(302,{Location:m(_.result.agentId)}),a.end(),v(_.result)}ci(x).then(e=>{c=e;let n=`http://127.0.0.1:${c}/callback`,r=`${t}/v1/auth/oauth2/authorize?`+new URLSearchParams({response_type:`code`,client_id:`catena-cli`,redirect_uri:n,scope:`openid email profile offline_access`,code_challenge:f,code_challenge_method:`S256`,state:p}).toString();o(`Opening browser for authentication...`),Kr(r),o(`If browser didn't open, visit: ${r}`)}).catch(y),_=setTimeout(()=>{b(`Timed out waiting for authentication`)},a),_.unref()})}function ui(e){if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.deviceCode==`string`&&typeof t.userCode==`string`&&typeof t.verificationUri==`string`&&typeof t.verificationUriComplete==`string`&&typeof t.expiresIn==`number`&&typeof t.interval==`number`}function di(e){if(typeof e!=`object`||!e)return{};let t=e;return{code:typeof t.code==`string`?t.code:void 0,message:typeof t.error==`string`?t.error:void 0}}function fi(e){return new Promise(t=>{setTimeout(t,e)})}function pi(e){let t={clientInstanceId:e.clientInstanceId,...e.clientLabel===void 0?{}:{clientLabel:e.clientLabel}};return e.scope===`agent:connect`?{scope:`agent:connect`,...t,...e.suggestedAgentName===void 0?{}:{suggestedAgentName:e.suggestedAgentName}}:e.scope===`agent:link`?{scope:`agent:link`,agentId:e.agentId,...t}:{agentId:e.agentId,...t}}async function mi(e){let{bankUrl:t,clientInstanceId:n,onUserCode:r,log:i=()=>{},clientInfo:a,existingSigner:o,generateSignerKeypair:s=Et,sleep:c=fi}=e;_n(t,`bankUrl`);let l=Le(a),u=e=>(i(`Link failed: ${e}`),null),d;try{d=await fetch(`${t}/v1/agent-link/device/code`,{method:`POST`,headers:{"Content-Type":`application/json`,...l},body:JSON.stringify(pi(e))})}catch{return u(`Could not reach the bank to start the device flow`)}if(!d.ok)return u(di(await d.json().catch(()=>null)).message??d.statusText);let f=await d.json();if(!ui(f))return u(`Device authorization response missing required fields`);r({userCode:f.userCode,verificationUri:f.verificationUri,verificationUriComplete:f.verificationUriComplete,expiresInSeconds:f.expiresIn});let p=await hi({bankUrl:t,grant:f,identityHeaders:l,sleep:c});if(!p.ok)return u(p.message);let m=p.body;if(!Zr(m))return u(`Device token response missing required fields`);i(`Approved. Claiming agent...`);let h=await ei({bankUrl:t,claim:m,clientInstanceId:n,signerKeypair:o?{algorithm:o.algorithm,privateKeyHex:o.privateKeyHex,publicKeyHex:o.publicKeyHex}:s(),identityHeaders:l,log:i});return h.ok?h.result:u(h.message)}async function hi(e){let{bankUrl:t,grant:n,identityHeaders:r,sleep:i}=e,a=Date.now()+n.expiresIn*1e3,o=Math.max(n.interval,1)*1e3,s=o;for(;Date.now()+o<=a;){await i(o);let e;try{e=await fetch(`${t}/v1/agent-link/device/token`,{method:`POST`,headers:{"Content-Type":`application/json`,...r},body:JSON.stringify({deviceCode:n.deviceCode})})}catch{s=Math.min(s*2,6e4),o=Math.max(o,s);continue}if(s=o,e.ok){let t=await e.json().catch(()=>null);return t===null?{ok:!1,message:`The bank returned an unreadable token response`}:{ok:!0,body:t}}let a=di(await e.json().catch(()=>null));if(a.code!==`authorization_pending`){if(a.code===`slow_down`){o+=5e3;continue}return a.code===`expired_token`?{ok:!1,message:`The device code expired before approval. Run link again`}:{ok:!1,message:a.message??`The request was denied`}}}return{ok:!1,message:`Timed out waiting for approval`}}function gi(e){if(typeof e!=`object`||!e)return!1;let t=e,n=t.signer;return t.credential===`signing_key`&&typeof t.agentId==`string`&&typeof t.name==`string`&&typeof t.keyThumbprint==`string`&&typeof t.activated==`boolean`&&typeof n==`object`&&!!n&&typeof n.status==`string`}async function _i(e){let{bankUrl:t,clientInstanceId:n,onUserCode:r,log:i=()=>{},clientInfo:a,sleep:o=fi}=e;_n(t,`bankUrl`);let s=Le(a),c=e=>(i(`Link failed: ${e}`),null),l={clientInstanceId:n,signer:{algorithm:`p256`,publicKeyHex:e.publicKeyHex},...e.clientLabel===void 0?{}:{clientLabel:e.clientLabel}},u=e.agentId===void 0?{scope:`agent:connect:service`,...l,...e.suggestedAgentName===void 0?{}:{suggestedAgentName:e.suggestedAgentName}}:{scope:`agent:link:service`,agentId:e.agentId,...l},d;try{d=await fetch(`${t}/v1/agent-link/device/code`,{method:`POST`,headers:{"Content-Type":`application/json`,...s},body:JSON.stringify(u)})}catch{return c(`Could not reach the bank to start the device flow`)}if(!d.ok){let e=di(await d.json().catch(()=>null));return e.code===`validation_failed`?c(`The bank rejected the request, which usually means it does not support --service yet. Nothing was created. Upgrade the bank and retry`):c(e.message??d.statusText)}let f=await d.json();if(!ui(f))return c(`Device authorization response missing required fields`);r({userCode:f.userCode,verificationUri:f.verificationUri,verificationUriComplete:f.verificationUriComplete,expiresInSeconds:f.expiresIn});let p=await hi({bankUrl:t,grant:f,identityHeaders:s,sleep:o});return p.ok?Zr(p.body)?c(`This bank does not support --service yet: it created a session link for agent ${p.body.agentId}. Unlink it in the console before retrying`):gi(p.body)?(i(`Approved. Signing key registered.`),{agentId:p.body.agentId,agentName:p.body.name,keyThumbprint:p.body.keyThumbprint,activated:p.body.activated,signerStatus:p.body.signer.status,...p.body.signer.reason===void 0?{}:{signerReason:p.body.signer.reason}}):c(`Device token response missing required fields`):c(p.message)}function vi(e=process.env,t=process.platform){return!!(e.SSH_CONNECTION||e.SSH_TTY||t===`linux`&&!e.DISPLAY&&!e.WAYLAND_DISPLAY)}function yi(e){let t;try{t=h(w(e))}catch{return!1}if(t===`/`)return!0;try{let e=h(process.env.HOME??b());return t===e||e.startsWith(`${t}/`)}catch{return!0}}const bi=W({"agent-id":Te({description:`Optional agent ID shown in the Catena console; omit to create and link a new agent`,schema:G}),"bank-url":H({description:`Bank API URL (defaults to $CATENA_API_URL or prod)`,default:process.env.CATENA_API_URL??`https://api.catena.com`}),browser:U({description:`Open the browser PKCE flow (default)`,negativeDescription:`Skip the browser and link with a device code you approve from another machine`,default:!0}),name:H({description:`Suggested name for an agent created from this link; only used when agent-id is omitted`}),service:U({description:`Provision a deployed-service signing credential instead of linking this machine: approval registers a P-256 key, no session tokens are minted, and nothing is stored locally. Interactive agent hosts must NOT use this`,default:!1}),"public-key":H({description:`With --service: register this existing compressed P-256 public key (the deployment already holds the private key) instead of generating a keypair`}),profile:Ae}),xi=/^0[23][0-9a-f]{64}$/;function Si(e){let t=Math.round(e.expiresInSeconds/60);console.log(`\n To approve this link, visit: ${e.verificationUri}`),console.log(` and enter the code: ${e.userCode}`),console.log(`\n Or open: ${e.verificationUriComplete}`),console.log(`\n Waiting for approval (expires in ${t} minutes)...`)}function Ci(e){console.log(`
267
- Keep this generated keypair if the approval completed before the CLI failed:`),console.log(`\n CATENA_AGENT_PUBLIC_KEY=${e.publicKeyHex}`),console.log(` CATENA_AGENT_PRIVATE_KEY=${e.privateKeyHex}`)}function wi(e){switch(e){case`signer_key_conflict`:return` Wallet-send signer: not registered (signer key conflict); unlink the conflicting service link or re-run with the linked agent ID`;case`provider_registration_failed`:return` Wallet-send signer: not registered (provider registration failed); retry after the provider recovers`;case void 0:return` Wallet-send signer: not registered (registration failed); retry after checking the link status`;default:return` Wallet-send signer: not registered (${e}); retry after checking the link status`}}function Ti({agentId:e,suggestedAgentName:t,browserRequested:n,isHeadless:r}){return e===void 0?{kind:`device-connect`,deviceTarget:{scope:`agent:connect`,...t===void 0?{}:{suggestedAgentName:t}}}:n?r()?{kind:`device-link`,deviceTarget:{agentId:e},notice:`No browser available — using device code flow.`}:{kind:`pkce-link`,agentId:e}:{kind:`device-link`,deviceTarget:{agentId:e}}}function Ei(e){let t=s(`sha256`).update(h(process.cwd())).digest(`hex`).slice(0,16);return`${Jn(e??`agent`).slice(0,47)}-${t}`}function Di(e){try{let t=process.cwd();if(yi(t))return null;let n=zn(t);return{directory:Bn(t,e),reboundFrom:n!==null&&n!==e?n:null}}catch{return console.error(`Warning: could not bind the current directory to profile "${e}".`),null}}const Oi=e({meta:{name:`link`,description:`Link an existing agent, or create and link a new agent when agent-id is omitted`},args:bi.args,async run({args:e}){let t=bi.parse(e),n=t[`bank-url`],r=t[`agent-id`],i=t.name;if(t.service){await ki({bankUrl:n,agentId:r,suggestedAgentName:i,publicKeyHex:t[`public-key`]});return}let a,o,s;try{if(_n(n,`--bank-url`),t[`public-key`]!==void 0)throw Error(`--public-key requires --service`);if(r!==void 0&&i!==void 0)throw Error(`--name can only be used when agent-id is omitted`);let e=ar({flag:dr(t),cwd:process.cwd(),log:e=>console.error(e)});a=(e!==null&&e.source!=="default"?e.name:null)??(r===void 0?null:Fn(r,n)),o=a??(r===void 0?Ei(i):Jn(r)),s=Wn(o,{bank_url:n,agent_id:r})}catch(e){z(e)}console.log(`
268
- Catena — Agent Setup`),console.log(`─`.repeat(25));let c=pn(),l=await oi(c,s),u={bankUrl:n,clientInstanceId:s,log:e=>console.log(` ${e}`),clientInfo:{name:`cli`,version:I},existingSigner:l},d=Ti({agentId:r,suggestedAgentName:i,browserRequested:t.browser,isHeadless:vi});d.kind===`device-link`&&d.notice!==void 0&&console.log(` ${d.notice}`);let f=d.kind===`pkce-link`?await li({...u,agentId:d.agentId,timeoutMs:300*1e3}):await mi({...u,...d.deviceTarget,onUserCode:Si});f||z(`
269
- Failed to link agent. Run the command again to try again.`),await c.save(s,Ut(f));let p=a??Yn(Jn(f.agentName),e=>e!==o&&Hn(e)!==null);try{p===o?Mn(p,{bank_url:n,agent_id:f.agentId,client_instance_id:s}):Xn({reservationName:o,profileName:p,profile:{bank_url:n,agent_id:f.agentId,client_instance_id:s}})}catch(e){z(e)}console.log(`\n Wrote profile "${p}"`);let m=Di(p);m!==null&&console.log(m.reboundFrom===null?` Bound ${m.directory} to profile "${p}"`:` Rebound ${m.directory} from profile "${m.reboundFrom}" to "${p}"`),console.log(` To pin this identity for an agent host, set ${nr}=${p}`),console.log(`\nDone. Agent "${f.agentName}" linked.`),process.exit(0)}});async function ki(e){try{if(_n(e.bankUrl,`--bank-url`),e.agentId!==void 0&&e.suggestedAgentName!==void 0)throw Error(`--name can only be used when agent-id is omitted`);if(e.publicKeyHex!==void 0&&!xi.test(e.publicKeyHex.toLowerCase()))throw Error(`--public-key must be compressed P-256 public key hex (66 chars)`)}catch(e){z(e)}console.log(`
270
- Catena — Deployed Service Setup`),console.log(`─`.repeat(31));let t=e.publicKeyHex===void 0?Et():null,n=t?.publicKeyHex??e.publicKeyHex?.toLowerCase()??``,r=Ot(n);r===null&&z(`Signing key public key is not a valid P-256 point`),console.log(` Signing key (RFC 7638 thumbprint): ${r}`);let i=`service-${s(`sha256`).update(n).digest(`hex`).slice(0,32)}`,a=!1,o=()=>{t&&a&&Ci({publicKeyHex:n,privateKeyHex:t.privateKeyHex})},c;try{c=await _i({bankUrl:e.bankUrl,clientInstanceId:i,publicKeyHex:n,...e.agentId===void 0?{}:{agentId:e.agentId},...e.suggestedAgentName===void 0?{}:{suggestedAgentName:e.suggestedAgentName},onUserCode:e=>{a=!0,Si(e)},log:e=>console.log(` ${e}`),clientInfo:{name:`cli`,version:I}})}catch(e){o(),z(e)}c||(o(),z(`
271
- Failed to link the service. Run the command again to try again.`)),c.keyThumbprint!==r&&(o(),z(`The bank registered signing key thumbprint ${c.keyThumbprint}, which does not match the local key (${r}). Do not deploy this credential. Unlink the agent in the console and run link again`)),console.log(`\nDone. Agent "${c.agentName}" linked as a deployed service.`),console.log(` Agent ID: ${c.agentId}`),console.log(` Signing key (RFC 7638 thumbprint): ${c.keyThumbprint}`),c.signerStatus===`registered`||c.signerStatus===`already_registered`?console.log(` Wallet-send signer: registered`):c.signerStatus===`not_applicable`?console.log(` Wallet-send signer: deferred (${c.signerReason??`topology not ready`}); the org must be signing-ready before live sends`):c.signerStatus===`registration_failed`?console.log(wi(c.signerReason)):console.log(` Wallet-send signer: not registered (${c.signerReason??c.signerStatus}); retry after checking the link status`),console.log(`
472
+ `}const Gu=e({meta:{name:`guide`,description:`Print the Catena CLI agent operating guide`},run(){console.log(Wu(se))}}),Ku=H({id:V({description:`Intent id (e.g. int_…)`,required:!0,schema:Ie}),profile:Pe,json:U}),qu=e({meta:{name:`intents`,description:`Inspect intent receipts returned by governed operations`},subCommands:{get:e({meta:{name:`get`,description:`Look up the current state of an intent created by this agent`},args:Ku.args,async run({args:e}){let t=Ku.parse(e);await _u(t)(e=>e.getIntent(t.id))}})}});function Ju(e=process.env,t=process.platform){return!!(e.SSH_CONNECTION||e.SSH_TTY||t===`linux`&&!e.DISPLAY&&!e.WAYLAND_DISPLAY)}function Yu(e){let t;try{t=_(ee(e))}catch{return!1}if(t===`/`)return!0;try{let e=_(process.env.HOME??S());return t===e||e.startsWith(`${t}/`)}catch{return!0}}function Xu(e){e&&process.stderr.write(`Failed to open browser: ${e.message}\n`)}function Zu(e){process.platform===`darwin`?d(`open`,[e],Xu):process.platform===`win32`?d(`cmd`,[`/c`,`start`,``,e],Xu):d(`xdg-open`,[e],Xu)}function Qu(e){if(typeof e!=`object`||!e)return;let t=e;return typeof t.message==`string`?t.message:typeof t.error==`string`?t.error:void 0}function $u(e){return typeof e!=`object`||!e||!(`access_token`in e)?!1:typeof e.access_token==`string`}function ed(e){if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.agentId==`string`&&typeof t.name==`string`&&typeof t.sessionToken==`string`&&(t.activated===void 0||typeof t.activated==`boolean`)}function td(e){if(typeof e!=`object`||!e)return!1;let t=e;return Nc.some(e=>e===t.status)&&(t.publicKeyHex===void 0||typeof t.publicKeyHex==`string`)&&(t.reason===void 0||typeof t.reason==`string`)}async function nd(e){let{bankUrl:t,authCode:n,verifier:r,redirectUri:i,agentId:a,clientInstanceId:o,clientId:s,clientLabel:c,log:l=()=>{},appInfo:u,existingSigner:d,generateSignerKeypair:f=xs}=e,p=Vs(u);l(`Exchanging authorization code...`);let m=await fetch(`${t}/v1/auth/oauth2/token`,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`,...p},body:new URLSearchParams({grant_type:`authorization_code`,code:n,code_verifier:r,client_id:s,redirect_uri:i}).toString()});if(!m.ok)return{ok:!1,message:Qu(await m.json().catch(()=>({message:`Token exchange failed`})))??m.statusText};let h=await m.json();if(!$u(h))return{ok:!1,message:`Token exchange response missing access_token`};l(`Claiming agent...`);let g=d?{algorithm:d.algorithm,privateKeyHex:d.privateKeyHex,publicKeyHex:d.publicKeyHex}:f(),_=await fetch(`${t}/v1/agent-api/claim`,{method:`POST`,headers:{"Content-Type":`application/json`,...p,Authorization:`Bearer ${h.access_token}`},body:JSON.stringify({agentId:a,clientInstanceId:o,...c===void 0?{}:{clientLabel:c}})});if(!_.ok)return{ok:!1,message:Qu(await _.json().catch(()=>({message:`Claim failed`})))??_.statusText};let v=await _.json();return ed(v)?rd({bankUrl:t,claim:v,clientInstanceId:o,signerKeypair:g,identityHeaders:p,log:l}):{ok:!1,message:`Claim response missing required fields`}}async function rd(e){let{bankUrl:t,claim:n,clientInstanceId:r,signerKeypair:i,identityHeaders:a}=e;(e.log??(()=>{}))(`Registering signer...`);let o=await ad({bankUrl:t,sessionToken:n.sessionToken,keypair:i,identityHeaders:a});return o.status===`registration_failed`?(n.activated!==!1&&await od({bankUrl:t,sessionToken:n.sessionToken,identityHeaders:a}),o.reason===`public_key_conflict`?{ok:!1,message:`This device's signing key conflicts with the one the bank already holds for this agent, or that key is already registered to another agent. Re-running link will not fix this; this agent's signing key cannot be reset automatically, so ask an operator or support to reset it before linking again.`}:{ok:!1,message:`Signer registration failed (${o.reason??`unknown`}). Run link again to retry.`}):{ok:!0,result:{agentId:n.agentId,clientInstanceId:r,agentName:n.name,signer:{...i,registration:o}}}}function id(e){return typeof e!=`object`||!e||!(`signer`in e)?!1:td(e.signer)}async function ad(e){let t;try{t=await fetch(`${e.bankUrl}/v1/agent-api/signer/register`,{method:`POST`,headers:{"Content-Type":`application/json`,...e.identityHeaders,Authorization:`Bearer ${e.sessionToken}`},body:JSON.stringify({signer:{algorithm:e.keypair.algorithm,publicKeyHex:e.keypair.publicKeyHex}})})}catch{return{status:`registration_failed`,reason:`registration_request_failed`}}if(t.status===409)return{status:`registration_failed`,reason:`public_key_conflict`};if(!t.ok)return{status:`registration_failed`,reason:`provider_registration_failed`};let n=await t.json().catch(()=>null);return id(n)?n.signer:{status:`registration_failed`,reason:`registration_response_malformed`}}async function od(e){try{await fetch(`${e.bankUrl}/v1/agent-api/unlink`,{method:`POST`,headers:{...e.identityHeaders,Authorization:`Bearer ${e.sessionToken}`}})}catch{}}function sd(e){return`${e}-signer`}async function cd(e,t){let n=await e.resolve(t);if(n!==null&&`signer`in n)return n.signer;let r=await e.resolve(sd(t));if(r!==null&&`signer`in r)return r.signer}async function ld(e,t,n=xs){let r=await cd(e,t);if(r!==void 0)return r;let i=qc(n());return await e.save(sd(t),i),i.signer}const ud=[53682,53683,53684,53685,53686,53687];function dd(e){return new Promise((t,n)=>{let r=0,i=()=>{if(r>=ud.length){n(Error(`No registered loopback callback ports are available`));return}let a=ud[r],o=t=>{if(e.off(`error`,o),t.code===`EADDRINUSE`){r++,i();return}n(t)};e.once(`error`,o),e.listen(a,`127.0.0.1`,()=>{e.off(`error`,o),t(a)})};i()})}async function fd(e){let{bankUrl:t,agentId:n,clientInstanceId:r,clientId:i,clientLabel:a,timeoutMs:o=300*1e3,log:c=()=>{},appInfo:u,existingSigner:d}=e;Mc(t,`bankUrl`);let f=l(32).toString(`base64url`),p=s(`sha256`).update(f).digest(`base64url`),m=l(16).toString(`hex`),h=e=>{let n=new URL(`${t}/link-complete`);return n.searchParams.set(`linked`,e),n.toString()},g=e=>{let n=new URL(`${t}/link-complete`);return n.searchParams.set(`error`,e),n.toString()};return new Promise((e,s)=>{let l=0,_=!1,v=null,y=t=>{_||(_=!0,v&&clearTimeout(v),S.close(),e(t))},b=e=>{_||(_=!0,v&&clearTimeout(v),S.close(),s(e))},x=e=>{c(`Link failed: ${e}`),y(null)},S=E((e,t)=>{C(e,t).catch(e=>{let n=Qu(e)??`Unexpected error`;t.headersSent||(t.writeHead(302,{Location:g(n)}),t.end()),c(`Link failed: ${n}`),y(null)})});async function C(e,o){let s=new URL(e.url??`/`,`http://localhost`);if(s.pathname!==`/callback`){o.writeHead(404),o.end(`Not found`);return}let p=s.searchParams.get(`error`);if(p){let e=s.searchParams.get(`error_description`)??p;o.writeHead(302,{Location:g(e)}),o.end(),x(`OAuth error: ${e}`);return}if(s.searchParams.get(`state`)!==m){o.writeHead(302,{Location:g(`State mismatch during OAuth callback`)}),o.end(),x(`State mismatch during OAuth callback`);return}let _=s.searchParams.get(`code`);if(!_){o.writeHead(302,{Location:g(`Missing authorization code`)}),o.end(),x(`Missing authorization code`);return}let v=await nd({bankUrl:t,authCode:_,verifier:f,redirectUri:`http://127.0.0.1:${l}/callback`,agentId:n,clientInstanceId:r,clientId:i,clientLabel:a,log:c,appInfo:u,existingSigner:d});if(!v.ok){o.writeHead(302,{Location:g(v.message)}),o.end(),c(`Link failed: ${v.message}`),y(null);return}o.writeHead(302,{Location:h(v.result.agentId)}),o.end(),y(v.result)}dd(S).then(e=>{l=e;let n=`http://127.0.0.1:${l}/callback`,r=`${t}/v1/auth/oauth2/authorize?`+new URLSearchParams({response_type:`code`,client_id:i,redirect_uri:n,scope:`openid email profile offline_access`,code_challenge:p,code_challenge_method:`S256`,state:m}).toString();c(`Opening browser for authentication...`),Zu(r),c(`If browser didn't open, visit: ${r}`)}).catch(b),v=setTimeout(()=>{x(`Timed out waiting for authentication`)},o),v.unref()})}function pd(e){if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.deviceCode==`string`&&typeof t.userCode==`string`&&typeof t.verificationUri==`string`&&typeof t.verificationUriComplete==`string`&&typeof t.expiresIn==`number`&&typeof t.interval==`number`}function md(e){if(typeof e!=`object`||!e)return{};let t=e;return{code:typeof t.code==`string`?t.code:void 0,message:typeof t.error==`string`?t.error:void 0}}function hd(e){return new Promise(t=>{setTimeout(t,e)})}function gd(e){let t={clientInstanceId:e.clientInstanceId,...e.clientLabel===void 0?{}:{clientLabel:e.clientLabel}};return e.scope===`agent:connect`?{scope:`agent:connect`,...t,...e.suggestedAgentName===void 0?{}:{suggestedAgentName:e.suggestedAgentName}}:e.scope===`agent:link`?{scope:`agent:link`,agentId:e.agentId,...t}:{agentId:e.agentId,...t}}async function _d(e){let{bankUrl:t,clientInstanceId:n,onUserCode:r,log:i=()=>{},appInfo:a,existingSigner:o,generateSignerKeypair:s=xs,sleep:c=hd}=e;Mc(t,`bankUrl`);let l=Vs(a),u=e=>(i(`Link failed: ${e}`),null),d;try{d=await fetch(`${t}/v1/agent-link/device/code`,{method:`POST`,headers:{"Content-Type":`application/json`,...l},body:JSON.stringify(gd(e))})}catch{return u(`Could not reach the bank to start the device flow`)}if(!d.ok)return u(md(await d.json().catch(()=>null)).message??d.statusText);let f=await d.json();if(!pd(f))return u(`Device authorization response missing required fields`);r({userCode:f.userCode,verificationUri:f.verificationUri,verificationUriComplete:f.verificationUriComplete,expiresInSeconds:f.expiresIn});let p=await vd({bankUrl:t,grant:f,identityHeaders:l,sleep:c});if(!p.ok)return u(p.message);let m=p.body;if(!ed(m))return u(`Device token response missing required fields`);i(`Approved. Claiming agent...`);let h=await rd({bankUrl:t,claim:m,clientInstanceId:n,signerKeypair:o?{algorithm:o.algorithm,privateKeyHex:o.privateKeyHex,publicKeyHex:o.publicKeyHex}:s(),identityHeaders:l,log:i});return h.ok?h.result:u(h.message)}async function vd(e){let{bankUrl:t,grant:n,identityHeaders:r,sleep:i}=e,a=Date.now()+n.expiresIn*1e3,o=Math.max(n.interval,1)*1e3,s=o;for(;Date.now()+o<=a;){await i(o);let e;try{e=await fetch(`${t}/v1/agent-link/device/token`,{method:`POST`,headers:{"Content-Type":`application/json`,...r},body:JSON.stringify({deviceCode:n.deviceCode})})}catch{s=Math.min(s*2,6e4),o=Math.max(o,s);continue}if(s=o,e.ok){let t=await e.json().catch(()=>null);return t===null?{ok:!1,message:`The bank returned an unreadable token response`}:{ok:!0,body:t}}let a=md(await e.json().catch(()=>null));if(a.code!==`authorization_pending`){if(a.code===`slow_down`){o+=5e3;continue}return a.code===`expired_token`?{ok:!1,message:`The device code expired before approval. Run link again`}:{ok:!1,message:a.message??`The request was denied`}}}return{ok:!1,message:`Timed out waiting for approval`}}function yd(e){if(typeof e!=`object`||!e)return!1;let t=e,n=t.signer;return t.credential===`signing_key`&&typeof t.agentId==`string`&&typeof t.name==`string`&&typeof t.keyThumbprint==`string`&&typeof t.activated==`boolean`&&typeof n==`object`&&!!n&&typeof n.status==`string`}async function bd(e){let{bankUrl:t,clientInstanceId:n,onUserCode:r,log:i=()=>{},appInfo:a,sleep:o=hd}=e;Mc(t,`bankUrl`);let s=Vs(a),c=e=>(i(`Link failed: ${e}`),null),l={clientInstanceId:n,signer:{algorithm:`p256`,publicKeyHex:e.publicKeyHex},...e.clientLabel===void 0?{}:{clientLabel:e.clientLabel}},u=e.agentId===void 0?{scope:`agent:connect:service`,...l,...e.suggestedAgentName===void 0?{}:{suggestedAgentName:e.suggestedAgentName}}:{scope:`agent:link:service`,agentId:e.agentId,...l},d;try{d=await fetch(`${t}/v1/agent-link/device/code`,{method:`POST`,headers:{"Content-Type":`application/json`,...s},body:JSON.stringify(u)})}catch{return c(`Could not reach the bank to start the device flow`)}if(!d.ok){let e=md(await d.json().catch(()=>null));return e.code===`validation_failed`?c(`The bank rejected the request, which usually means it does not support --service yet. Nothing was created. Upgrade the bank and retry`):c(e.message??d.statusText)}let f=await d.json();if(!pd(f))return c(`Device authorization response missing required fields`);r({userCode:f.userCode,verificationUri:f.verificationUri,verificationUriComplete:f.verificationUriComplete,expiresInSeconds:f.expiresIn});let p=await vd({bankUrl:t,grant:f,identityHeaders:s,sleep:o});return p.ok?ed(p.body)?c(`This bank does not support --service yet: it created a session link for agent ${p.body.agentId}. Unlink it in the console before retrying`):yd(p.body)?(i(`Approved. Signing key registered.`),{agentId:p.body.agentId,agentName:p.body.name,keyThumbprint:p.body.keyThumbprint,activated:p.body.activated,signerStatus:p.body.signer.status,...p.body.signer.reason===void 0?{}:{signerReason:p.body.signer.reason}}):c(`Device token response missing required fields`):c(p.message)}const xd=H({"agent-id":V({description:`Optional agent ID shown in the Catena console; omit to create and link a new agent`,schema:Ie}),"bank-url":B({description:`Bank API URL (defaults to $CATENA_API_URL or prod)`,default:process.env.CATENA_API_URL??`https://api.catena.com`}),browser:Oe({description:`Open the browser PKCE flow (default)`,negativeDescription:`Skip the browser and link with a device code you approve from another machine`,default:!0}),name:B({description:`Suggested name for an agent created from this link; only used when agent-id is omitted`}),service:Oe({description:`Provision a deployed-service signing credential instead of linking this machine: approval registers a P-256 key, no session tokens are minted, and nothing is stored locally. Interactive agent hosts must NOT use this`,default:!1}),"public-key":B({description:`With --service: register this existing compressed P-256 public key (the deployment already holds the private key) instead of generating a keypair`}),profile:Pe}),Sd=/^0[23][0-9a-f]{64}$/;function Cd(e){let t=Math.round(e.expiresInSeconds/60);console.log(`\n To approve this link, visit: ${e.verificationUri}`),console.log(` and enter the code: ${e.userCode}`),console.log(`\n Or open: ${e.verificationUriComplete}`),console.log(`\n Waiting for approval (expires in ${t} minutes)...`)}function wd(e){console.log(`
473
+ Keep this generated keypair if the approval completed before the CLI failed:`),console.log(`\n CATENA_AGENT_PUBLIC_KEY=${e.publicKeyHex}`),console.log(` CATENA_AGENT_PRIVATE_KEY=${e.privateKeyHex}`)}function Td(e){switch(e){case`signer_key_conflict`:return` Wallet-send signer: not registered (signer key conflict); unlink the conflicting service link or re-run with the linked agent ID`;case`provider_registration_failed`:return` Wallet-send signer: not registered (provider registration failed); retry after the provider recovers`;case void 0:return` Wallet-send signer: not registered (registration failed); retry after checking the link status`;default:return` Wallet-send signer: not registered (${e}); retry after checking the link status`}}function Ed({agentId:e,suggestedAgentName:t,browserRequested:n,isHeadless:r}){return e===void 0?{kind:`device-connect`,deviceTarget:{scope:`agent:connect`,...t===void 0?{}:{suggestedAgentName:t}}}:n?r()?{kind:`device-link`,deviceTarget:{agentId:e},notice:`No browser available — using device code flow.`}:{kind:`pkce-link`,agentId:e}:{kind:`device-link`,deviceTarget:{agentId:e}}}function Dd(e){let t=s(`sha256`).update(_(process.cwd())).digest(`hex`).slice(0,16);return`${Yl(e??`agent`).slice(0,47)}-${t}`}function Od(e){try{let t=process.cwd();if(Yu(t))return null;let n=Bl(t);return{directory:Vl(t,e),reboundFrom:n!==null&&n!==e?n:null}}catch{return console.error(`Warning: could not bind the current directory to profile "${e}".`),null}}const kd=e({meta:{name:`link`,description:`Link an existing agent, or create and link a new agent when agent-id is omitted`},args:xd.args,async run({args:e}){let t=xd.parse(e),n=t[`bank-url`],r=t[`agent-id`],i=t.name;if(t.service){await Ad({bankUrl:n,agentId:r,suggestedAgentName:i,publicKeyHex:t[`public-key`]});return}let a,o,s;try{if(Mc(n,`--bank-url`),t[`public-key`]!==void 0)throw Error(`--public-key requires --service`);if(r!==void 0&&i!==void 0)throw Error(`--name can only be used when agent-id is omitted`);let e=au({flag:mu(t),cwd:process.cwd(),log:e=>console.error(e)});a=(e!==null&&e.source!=="default"?e.name:null)??(r===void 0?null:Il(r,n)),o=a??(r===void 0?Dd(i):Yl(r)),s=Gl(o,{bank_url:n,agent_id:r})}catch(e){L(e)}console.log(`
474
+ Catena — Agent Setup`),console.log(`─`.repeat(25));let c=vl(),l=await ld(c,s),u={bankUrl:n,clientInstanceId:s,log:e=>console.log(` ${e}`),appInfo:tu,existingSigner:l},d=Ed({agentId:r,suggestedAgentName:i,browserRequested:t.browser,isHeadless:Ju});d.kind===`device-link`&&d.notice!==void 0&&console.log(` ${d.notice}`);let f=d.kind===`pkce-link`?await fd({...u,agentId:d.agentId,clientId:`catena-cli`,timeoutMs:300*1e3}):await _d({...u,...d.deviceTarget,onUserCode:Cd});f||L(`
475
+ Failed to link agent. Run the command again to try again.`),await c.save(s,Yc(f.signer));let p=a??Xl(Yl(f.agentName),e=>e!==o&&Ul(e)!==null);try{p===o?Nl(p,{bank_url:n,agent_id:f.agentId,client_instance_id:s}):Zl({reservationName:o,profileName:p,profile:{bank_url:n,agent_id:f.agentId,client_instance_id:s}})}catch(e){L(e)}console.log(`\n Wrote profile "${p}"`);let m=Od(p);m!==null&&console.log(m.reboundFrom===null?` Bound ${m.directory} to profile "${p}"`:` Rebound ${m.directory} from profile "${m.reboundFrom}" to "${p}"`),console.log(` To pin this identity for an agent host, set ${nu}=${p}`),console.log(`\nDone. Agent "${f.agentName}" linked.`),process.exit(0)}});async function Ad(e){try{if(Mc(e.bankUrl,`--bank-url`),e.agentId!==void 0&&e.suggestedAgentName!==void 0)throw Error(`--name can only be used when agent-id is omitted`);if(e.publicKeyHex!==void 0&&!Sd.test(e.publicKeyHex.toLowerCase()))throw Error(`--public-key must be compressed P-256 public key hex (66 chars)`)}catch(e){L(e)}console.log(`
476
+ Catena — Deployed Service Setup`),console.log(`─`.repeat(31));let t=e.publicKeyHex===void 0?xs():null,n=t?.publicKeyHex??e.publicKeyHex?.toLowerCase()??``,r=Cs(n);r===null&&L(`Signing key public key is not a valid P-256 point`),console.log(` Signing key (RFC 7638 thumbprint): ${r}`);let i=`service-${s(`sha256`).update(n).digest(`hex`).slice(0,32)}`,a=!1,o=()=>{t&&a&&wd({publicKeyHex:n,privateKeyHex:t.privateKeyHex})},c;try{c=await bd({bankUrl:e.bankUrl,clientInstanceId:i,publicKeyHex:n,...e.agentId===void 0?{}:{agentId:e.agentId},...e.suggestedAgentName===void 0?{}:{suggestedAgentName:e.suggestedAgentName},onUserCode:e=>{a=!0,Cd(e)},log:e=>console.log(` ${e}`),appInfo:tu})}catch(e){o(),L(e)}c||(o(),L(`
477
+ Failed to link the service. Run the command again to try again.`)),c.keyThumbprint!==r&&(o(),L(`The bank registered signing key thumbprint ${c.keyThumbprint}, which does not match the local key (${r}). Do not deploy this credential. Unlink the agent in the console and run link again`)),console.log(`\nDone. Agent "${c.agentName}" linked as a deployed service.`),console.log(` Agent ID: ${c.agentId}`),console.log(` Signing key (RFC 7638 thumbprint): ${c.keyThumbprint}`),c.signerStatus===`registered`||c.signerStatus===`already_registered`?console.log(` Wallet-send signer: registered`):c.signerStatus===`not_applicable`?console.log(` Wallet-send signer: deferred (${c.signerReason??`topology not ready`}); the org must be signing-ready before live sends`):c.signerStatus===`registration_failed`?console.log(Td(c.signerReason)):console.log(` Wallet-send signer: not registered (${c.signerReason??c.signerStatus}); retry after checking the link status`),console.log(`
272
478
  Set these in the deployment environment:`),console.log(`\n CATENA_API_URL=${e.bankUrl}`),console.log(` CATENA_AGENT_PUBLIC_KEY=${n}`),t&&console.log(` CATENA_AGENT_PRIVATE_KEY=${t.privateKeyHex}`),console.log(` CATENA_AGENT_IDENTITY_URL=<the deployment's public https origin>`),t&&console.log(`
273
- The private key is shown once and is not stored on this machine.`),process.exit(0)}const Ai=W({profile:Ae,json:je}),ji=e({meta:{name:`policy`,description:`Inspect the agent's policy`},subCommands:{show:e({meta:{name:`show`,description:`Show the agent's assigned policy`},args:Ai.args,async run({args:e}){await mr(Ai.parse(e))(e=>e.getPolicy())}})}}),Mi=W({profile:Te({description:`Profile name`,required:!0})});function Ni(){try{return or({env:process.env[nr],cwd:process.cwd(),log:e=>console.error(e)})}catch(e){return z(e)}}const Pi=e({meta:{name:`use`,description:`Set the default credential profile`},args:Mi.args,async run({args:e}){let t=Mi.parse(e);try{qn(t.profile),ur({defaultProfile:t.profile})}catch(e){z(e)}}}),Fi=e({meta:{name:`current`,description:`Show the selected credential profile and how it was chosen`},async run(){let e=Ni(),t;try{t=Hn(e.name)}catch(e){z(e)}t===null&&z(`Profile "${e.name}" is not linked.\nRun 'catena link --profile ${e.name} <agent-id>' to authenticate.`),ur({profile:e.name,source:e.source,bankUrl:t.bank_url,agentId:Nn(t)?t.agent_id:void 0})}}),Ii=e({meta:{name:`list`,description:`List credential profiles and their directory bindings`},async run(){let e;try{e=kn()}catch(e){z(e)}let t;try{t=or({env:process.env[nr],cwd:process.cwd()}).name}catch{t=null}let n=Object.entries(e.directories??{});ur({defaultProfile:e.default_profile,profiles:Object.entries(e.profiles).toSorted(([e],[t])=>e.localeCompare(t)).map(([e,r])=>({name:e,bankUrl:r.bank_url,agentId:Nn(r)?r.agent_id:void 0,directories:n.filter(([,t])=>t===e).map(([e])=>e).toSorted(),current:e===t}))})}}),Li=W({profile:Te({description:`Profile name to bind`,required:!0}),path:Te({description:`Directory to bind (defaults to the current directory)`})}),Ri=e({meta:{name:`bind`,description:`Bind a directory to a profile for automatic selection`},args:Li.args,async run({args:e}){let t=Li.parse(e);try{let e=t.path??process.cwd();if(yi(e))throw Error(`Refusing to bind the home directory or an ancestor of it — that would shadow the default profile for every directory beneath it. Bind a specific agent directory instead.`);let n=Bn(e,t.profile);ur({profile:t.profile,directory:n})}catch(e){z(e)}}}),zi=W({path:Te({description:`Directory to unbind (defaults to the current directory)`})}),Bi=e({meta:{name:`profiles`,description:`Manage credential profiles`},subCommands:{use:Pi,current:Fi,list:Ii,bind:Ri,unbind:e({meta:{name:`unbind`,description:`Remove a directory's profile binding`},args:zi.args,async run({args:e}){let t=zi.parse(e);try{ur(Vn(t.path??process.cwd()))}catch(e){z(e)}}})}});function Vi(e){return e.reduce((e,t)=>e+t.toString(16).padStart(2,`0`),``)}const Hi=(e,t)=>{if(!e||e.length%2!=0||!/^[0-9A-Fa-f]+$/.test(e))throw Error(`cannot create uint8array from invalid hex string: "${e}"`);let n=new Uint8Array(e.match(/../g).map(e=>parseInt(e,16)));if(!t)return n;if(e.length/2>t)throw Error(`hex value cannot fit in a buffer of `+t+` byte(s)`);let r=new Uint8Array(t);return r.set(n,t-n.length),r},Ui=(e,t)=>{let n=t-e.length;if(n>0){let t=new Uint8Array(n).fill(0);return new Uint8Array([...t,...e])}if(n<0){let r=n*-1,i=0;for(let t=0;t<r&&t<e.length;t++)e[t]===0&&i++;if(i!==r)throw Error(`invalid number of starting zeroes. Expected number of zeroes: ${r}. Found: ${i}.`);return e.slice(r,r+t)}return e};function Wi(e){return Ki(qi(e))}function Gi(e,t){return Wi(Hi(e.padStart(Math.ceil(e.length/2)*2,`0`),t).reduce((e,t)=>e+String.fromCharCode(t),``))}function Ki(e){return e.replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=/g,``)}function qi(e){if(arguments.length===0)throw TypeError(`1 argument required, but only 0 present.`);let t;for(e=`${e}`,t=0;t<e.length;t++)if(e.charCodeAt(t)>255)throw Error(`InvalidCharacterError: found code point greater than 255:${e.charCodeAt(t)} at position ${t}`);let n=``;for(t=0;t<e.length;t+=3){let r=[void 0,void 0,void 0,void 0];r[0]=e.charCodeAt(t)>>2,r[1]=(e.charCodeAt(t)&3)<<4,e.length>t+1&&(r[1]|=e.charCodeAt(t+1)>>4,r[2]=(e.charCodeAt(t+1)&15)<<2),e.length>t+2&&(r[2]|=e.charCodeAt(t+2)>>6,r[3]=e.charCodeAt(t+2)&63);for(let e=0;e<r.length;e++)r[e]===void 0?n+=`=`:n+=Ji(r[e])}return n}function Ji(e){if(e>=0&&e<64)return`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`[e]}function Yi(e){if(e.length>=255)throw TypeError(`Alphabet too long`);let t=new Uint8Array(256);for(let e=0;e<t.length;e++)t[e]=255;for(let n=0;n<e.length;n++){let r=e.charAt(n),i=r.charCodeAt(0);if(t[i]!==255)throw TypeError(r+` is ambiguous`);t[i]=n}let n=e.length,r=e.charAt(0),i=Math.log(n)/Math.log(256),a=Math.log(256)/Math.log(n);function o(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw TypeError(`Expected Uint8Array`);if(t.length===0)return``;let i=0,o=0,s=0,c=t.length;for(;s!==c&&t[s]===0;)s++,i++;let l=(c-s)*a+1>>>0,u=new Uint8Array(l);for(;s!==c;){let e=t[s],r=0;for(let t=l-1;(e!==0||r<o)&&t!==-1;t--,r++)e+=256*u[t]>>>0,u[t]=e%n>>>0,e=e/n>>>0;if(e!==0)throw Error(`Non-zero carry`);o=r,s++}let d=l-o;for(;d!==l&&u[d]===0;)d++;let f=r.repeat(i);for(;d<l;++d)f+=e.charAt(u[d]);return f}function s(e){if(typeof e!=`string`)throw TypeError(`Expected String`);if(e.length===0)return new Uint8Array;let a=0,o=0,s=0;for(;e[a]===r;)o++,a++;let c=(e.length-a)*i+1>>>0,l=new Uint8Array(c);for(;a<e.length;){let r=e.charCodeAt(a);if(r>255)return;let i=t[r];if(i===255)return;let o=0;for(let e=c-1;(i!==0||o<s)&&e!==-1;e--,o++)i+=n*l[e]>>>0,l[e]=i%256>>>0,i=i/256>>>0;if(i!==0)throw Error(`Non-zero carry`);s=o,a++}let u=c-s;for(;u!==c&&l[u]===0;)u++;let d=new Uint8Array(o+(c-u)),f=o;for(;u!==c;)d[f++]=l[u++];return d}function c(e){let t=s(e);if(t)return t;throw Error(`Non-base`+n+` character`)}return{encode:o,decodeUnsafe:s,decode:c}}var Xi=te({default:()=>Zi}),Zi=Yi(`123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz`);function Qi(e){let t=e;for(;t&&!(t.encode&&t.decode&&t.decodeUnsafe)&&t.default;)t=t.default;return t}Qi(Xi);const $i=i&&typeof i==`object`&&`webcrypto`in i?i.webcrypto:i&&typeof i==`object`&&`randomBytes`in i?i:void 0;
274
- /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
275
- function ea(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`}function ta(e){if(!Number.isSafeInteger(e)||e<0)throw Error(`positive integer expected, got `+e)}function na(e,...t){if(!ea(e))throw Error(`Uint8Array expected`);if(t.length>0&&!t.includes(e.length))throw Error(`Uint8Array expected of length `+t+`, got length=`+e.length)}function ra(e){if(typeof e!=`function`||typeof e.create!=`function`)throw Error(`Hash should be wrapped by utils.createHasher`);ta(e.outputLen),ta(e.blockLen)}function ia(e,t=!0){if(e.destroyed)throw Error(`Hash instance has been destroyed`);if(t&&e.finished)throw Error(`Hash#digest() has already been called`)}function aa(e,t){na(e);let n=t.outputLen;if(e.length<n)throw Error(`digestInto() expects output buffer of length at least `+n)}function oa(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function sa(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function ca(e,t){return e<<32-t|e>>>t}const la=typeof Uint8Array.from([]).toHex==`function`&&typeof Uint8Array.fromHex==`function`,ua=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`));function da(e){if(na(e),la)return e.toHex();let t=``;for(let n=0;n<e.length;n++)t+=ua[e[n]];return t}const fa={_0:48,_9:57,A:65,F:70,a:97,f:102};function pa(e){if(e>=fa._0&&e<=fa._9)return e-fa._0;if(e>=fa.A&&e<=fa.F)return e-(fa.A-10);if(e>=fa.a&&e<=fa.f)return e-(fa.a-10)}function ma(e){if(typeof e!=`string`)throw Error(`hex string expected, got `+typeof e);if(la)return Uint8Array.fromHex(e);let t=e.length,n=t/2;if(t%2)throw Error(`hex string expected, got unpadded hex of length `+t);let r=new Uint8Array(n);for(let t=0,i=0;t<n;t++,i+=2){let n=pa(e.charCodeAt(i)),a=pa(e.charCodeAt(i+1));if(n===void 0||a===void 0){let t=e[i]+e[i+1];throw Error(`hex string expected, got non-hex character "`+t+`" at index `+i)}r[t]=n*16+a}return r}function ha(e){if(typeof e!=`string`)throw Error(`string expected`);return new Uint8Array(new TextEncoder().encode(e))}function ga(e){return typeof e==`string`&&(e=ha(e)),na(e),e}function _a(...e){let t=0;for(let n=0;n<e.length;n++){let r=e[n];na(r),t+=r.length}let n=new Uint8Array(t);for(let t=0,r=0;t<e.length;t++){let i=e[t];n.set(i,r),r+=i.length}return n}var va=class{};function ya(e){let t=t=>e().update(ga(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function ba(e=32){if($i&&typeof $i.getRandomValues==`function`)return $i.getRandomValues(new Uint8Array(e));if($i&&typeof $i.randomBytes==`function`)return Uint8Array.from($i.randomBytes(e));throw Error(`crypto.getRandomValues must be defined`)}function xa(e,t,n,r){if(typeof e.setBigUint64==`function`)return e.setBigUint64(t,n,r);let i=BigInt(32),a=BigInt(4294967295),o=Number(n>>i&a),s=Number(n&a),c=r?4:0,l=r?0:4;e.setUint32(t+c,o,r),e.setUint32(t+l,s,r)}function Sa(e,t,n){return e&t^~e&n}function Ca(e,t,n){return e&t^e&n^t&n}var wa=class extends va{constructor(e,t,n,r){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.buffer=new Uint8Array(e),this.view=sa(this.buffer)}update(e){ia(this),e=ga(e),na(e);let{view:t,buffer:n,blockLen:r}=this,i=e.length;for(let a=0;a<i;){let o=Math.min(r-this.pos,i-a);if(o===r){let t=sa(e);for(;r<=i-a;a+=r)this.process(t,a);continue}n.set(e.subarray(a,a+o),this.pos),this.pos+=o,a+=o,this.pos===r&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){ia(this),aa(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:r,isLE:i}=this,{pos:a}=this;t[a++]=128,oa(this.buffer.subarray(a)),this.padOffset>r-a&&(this.process(n,0),a=0);for(let e=a;e<r;e++)t[e]=0;xa(n,r-8,BigInt(this.length*8),i),this.process(n,0);let o=sa(e),s=this.outputLen;if(s%4)throw Error(`_sha2: outputLen should be aligned to 32bit`);let c=s/4,l=this.get();if(c>l.length)throw Error(`_sha2: outputLen bigger than state`);for(let e=0;e<c;e++)o.setUint32(4*e,l[e],i)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||=new this.constructor,e.set(...this.get());let{blockLen:t,buffer:n,length:r,finished:i,destroyed:a,pos:o}=this;return e.destroyed=a,e.finished=i,e.length=r,e.pos=o,r%t&&e.buffer.set(n),e}clone(){return this._cloneInto()}};const Ta=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),J=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]),Ea=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),Da=BigInt(2**32-1),Oa=BigInt(32);function ka(e,t=!1){return t?{h:Number(e&Da),l:Number(e>>Oa&Da)}:{h:Number(e>>Oa&Da)|0,l:Number(e&Da)|0}}function Aa(e,t=!1){let n=e.length,r=new Uint32Array(n),i=new Uint32Array(n);for(let a=0;a<n;a++){let{h:n,l:o}=ka(e[a],t);[r[a],i[a]]=[n,o]}return[r,i]}const ja=(e,t,n)=>e>>>n,Ma=(e,t,n)=>e<<32-n|t>>>n,Na=(e,t,n)=>e>>>n|t<<32-n,Pa=(e,t,n)=>e<<32-n|t>>>n,Fa=(e,t,n)=>e<<64-n|t>>>n-32,Ia=(e,t,n)=>e>>>n-32|t<<64-n;function La(e,t,n,r){let i=(t>>>0)+(r>>>0);return{h:e+n+(i/2**32|0)|0,l:i|0}}const Ra=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),za=(e,t,n,r)=>t+n+r+(e/2**32|0)|0,Ba=(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0),Va=(e,t,n,r,i)=>t+n+r+i+(e/2**32|0)|0,Ha=(e,t,n,r,i)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(i>>>0),Ua=(e,t,n,r,i,a)=>t+n+r+i+a+(e/2**32|0)|0,Wa=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Ga=new Uint32Array(64);var Ka=class extends wa{constructor(e=32){super(64,e,8,!1),this.A=Ta[0]|0,this.B=Ta[1]|0,this.C=Ta[2]|0,this.D=Ta[3]|0,this.E=Ta[4]|0,this.F=Ta[5]|0,this.G=Ta[6]|0,this.H=Ta[7]|0}get(){let{A:e,B:t,C:n,D:r,E:i,F:a,G:o,H:s}=this;return[e,t,n,r,i,a,o,s]}set(e,t,n,r,i,a,o,s){this.A=e|0,this.B=t|0,this.C=n|0,this.D=r|0,this.E=i|0,this.F=a|0,this.G=o|0,this.H=s|0}process(e,t){for(let n=0;n<16;n++,t+=4)Ga[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){let t=Ga[e-15],n=Ga[e-2],r=ca(t,7)^ca(t,18)^t>>>3;Ga[e]=(ca(n,17)^ca(n,19)^n>>>10)+Ga[e-7]+r+Ga[e-16]|0}let{A:n,B:r,C:i,D:a,E:o,F:s,G:c,H:l}=this;for(let e=0;e<64;e++){let t=ca(o,6)^ca(o,11)^ca(o,25),u=l+t+Sa(o,s,c)+Wa[e]+Ga[e]|0,d=(ca(n,2)^ca(n,13)^ca(n,22))+Ca(n,r,i)|0;l=c,c=s,s=o,o=a+u|0,a=i,i=r,r=n,n=u+d|0}n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,a=a+this.D|0,o=o+this.E|0,s=s+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(n,r,i,a,o,s,c,l)}roundClean(){oa(Ga)}destroy(){this.set(0,0,0,0,0,0,0,0),oa(this.buffer)}};const qa=Aa(`0x428a2f98d728ae22.0x7137449123ef65cd.0xb5c0fbcfec4d3b2f.0xe9b5dba58189dbbc.0x3956c25bf348b538.0x59f111f1b605d019.0x923f82a4af194f9b.0xab1c5ed5da6d8118.0xd807aa98a3030242.0x12835b0145706fbe.0x243185be4ee4b28c.0x550c7dc3d5ffb4e2.0x72be5d74f27b896f.0x80deb1fe3b1696b1.0x9bdc06a725c71235.0xc19bf174cf692694.0xe49b69c19ef14ad2.0xefbe4786384f25e3.0x0fc19dc68b8cd5b5.0x240ca1cc77ac9c65.0x2de92c6f592b0275.0x4a7484aa6ea6e483.0x5cb0a9dcbd41fbd4.0x76f988da831153b5.0x983e5152ee66dfab.0xa831c66d2db43210.0xb00327c898fb213f.0xbf597fc7beef0ee4.0xc6e00bf33da88fc2.0xd5a79147930aa725.0x06ca6351e003826f.0x142929670a0e6e70.0x27b70a8546d22ffc.0x2e1b21385c26c926.0x4d2c6dfc5ac42aed.0x53380d139d95b3df.0x650a73548baf63de.0x766a0abb3c77b2a8.0x81c2c92e47edaee6.0x92722c851482353b.0xa2bfe8a14cf10364.0xa81a664bbc423001.0xc24b8b70d0f89791.0xc76c51a30654be30.0xd192e819d6ef5218.0xd69906245565a910.0xf40e35855771202a.0x106aa07032bbd1b8.0x19a4c116b8d2d0c8.0x1e376c085141ab53.0x2748774cdf8eeb99.0x34b0bcb5e19b48a8.0x391c0cb3c5c95a63.0x4ed8aa4ae3418acb.0x5b9cca4f7763e373.0x682e6ff3d6b2b8a3.0x748f82ee5defb2fc.0x78a5636f43172f60.0x84c87814a1f0ab72.0x8cc702081a6439ec.0x90befffa23631e28.0xa4506cebde82bde9.0xbef9a3f7b2c67915.0xc67178f2e372532b.0xca273eceea26619c.0xd186b8c721c0c207.0xeada7dd6cde0eb1e.0xf57d4f7fee6ed178.0x06f067aa72176fba.0x0a637dc5a2c898a6.0x113f9804bef90dae.0x1b710b35131c471b.0x28db77f523047d84.0x32caab7b40c72493.0x3c9ebe0a15c9bebc.0x431d67c49c100d4c.0x4cc5d4becb3e42b6.0x597f299cfc657e2a.0x5fcb6fab3ad6faec.0x6c44198c4a475817`.split(`.`).map(e=>BigInt(e))),Ja=qa[0],Ya=qa[1],Xa=new Uint32Array(80),Za=new Uint32Array(80);var Qa=class extends wa{constructor(e=64){super(128,e,16,!1),this.Ah=Ea[0]|0,this.Al=Ea[1]|0,this.Bh=Ea[2]|0,this.Bl=Ea[3]|0,this.Ch=Ea[4]|0,this.Cl=Ea[5]|0,this.Dh=Ea[6]|0,this.Dl=Ea[7]|0,this.Eh=Ea[8]|0,this.El=Ea[9]|0,this.Fh=Ea[10]|0,this.Fl=Ea[11]|0,this.Gh=Ea[12]|0,this.Gl=Ea[13]|0,this.Hh=Ea[14]|0,this.Hl=Ea[15]|0}get(){let{Ah:e,Al:t,Bh:n,Bl:r,Ch:i,Cl:a,Dh:o,Dl:s,Eh:c,El:l,Fh:u,Fl:d,Gh:f,Gl:p,Hh:m,Hl:h}=this;return[e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h]}set(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){this.Ah=e|0,this.Al=t|0,this.Bh=n|0,this.Bl=r|0,this.Ch=i|0,this.Cl=a|0,this.Dh=o|0,this.Dl=s|0,this.Eh=c|0,this.El=l|0,this.Fh=u|0,this.Fl=d|0,this.Gh=f|0,this.Gl=p|0,this.Hh=m|0,this.Hl=h|0}process(e,t){for(let n=0;n<16;n++,t+=4)Xa[n]=e.getUint32(t),Za[n]=e.getUint32(t+=4);for(let e=16;e<80;e++){let t=Xa[e-15]|0,n=Za[e-15]|0,r=Na(t,n,1)^Na(t,n,8)^ja(t,n,7),i=Pa(t,n,1)^Pa(t,n,8)^Ma(t,n,7),a=Xa[e-2]|0,o=Za[e-2]|0,s=Na(a,o,19)^Fa(a,o,61)^ja(a,o,6),c=Ba(i,Pa(a,o,19)^Ia(a,o,61)^Ma(a,o,6),Za[e-7],Za[e-16]);Xa[e]=Va(c,r,s,Xa[e-7],Xa[e-16])|0,Za[e]=c|0}let{Ah:n,Al:r,Bh:i,Bl:a,Ch:o,Cl:s,Dh:c,Dl:l,Eh:u,El:d,Fh:f,Fl:p,Gh:m,Gl:h,Hh:g,Hl:_}=this;for(let e=0;e<80;e++){let t=Na(u,d,14)^Na(u,d,18)^Fa(u,d,41),v=Pa(u,d,14)^Pa(u,d,18)^Ia(u,d,41),y=u&f^~u&m,b=d&p^~d&h,x=Ha(_,v,b,Ya[e],Za[e]),S=Ua(x,g,t,y,Ja[e],Xa[e]),C=x|0,w=Na(n,r,28)^Fa(n,r,34)^Fa(n,r,39),T=Pa(n,r,28)^Ia(n,r,34)^Ia(n,r,39),E=n&i^n&o^i&o,D=r&a^r&s^a&s;g=m|0,_=h|0,m=f|0,h=p|0,f=u|0,p=d|0,{h:u,l:d}=La(c|0,l|0,S|0,C|0),c=o|0,l=s|0,o=i|0,s=a|0,i=n|0,a=r|0;let O=Ra(C,T,D);n=za(O,S,w,E),r=O|0}({h:n,l:r}=La(this.Ah|0,this.Al|0,n|0,r|0)),{h:i,l:a}=La(this.Bh|0,this.Bl|0,i|0,a|0),{h:o,l:s}=La(this.Ch|0,this.Cl|0,o|0,s|0),{h:c,l}=La(this.Dh|0,this.Dl|0,c|0,l|0),{h:u,l:d}=La(this.Eh|0,this.El|0,u|0,d|0),{h:f,l:p}=La(this.Fh|0,this.Fl|0,f|0,p|0),{h:m,l:h}=La(this.Gh|0,this.Gl|0,m|0,h|0),{h:g,l:_}=La(this.Hh|0,this.Hl|0,g|0,_|0),this.set(n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_)}roundClean(){oa(Xa,Za)}destroy(){oa(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},$a=class extends Qa{constructor(){super(48),this.Ah=J[0]|0,this.Al=J[1]|0,this.Bh=J[2]|0,this.Bl=J[3]|0,this.Ch=J[4]|0,this.Cl=J[5]|0,this.Dh=J[6]|0,this.Dl=J[7]|0,this.Eh=J[8]|0,this.El=J[9]|0,this.Fh=J[10]|0,this.Fl=J[11]|0,this.Gh=J[12]|0,this.Gl=J[13]|0,this.Hh=J[14]|0,this.Hl=J[15]|0}};const eo=ya(()=>new Ka),to=ya(()=>new Qa),no=ya(()=>new $a),ro=eo;function io(e){function t(t){var n=Uint8Array.from(t),r=e(n),i=n.length+4,a=new Uint8Array(i);return a.set(n,0),a.set(r.subarray(0,4),n.length),Zi.encode(a)}function n(t){var n=t.slice(0,-4),r=t.slice(-4),i=e(n);if(!(r[0]^i[0]|r[1]^i[1]|r[2]^i[2]|r[3]^i[3]))return n}function r(e){var t=Zi.decodeUnsafe(e);if(t!=null)return n(t)}function i(e){var t=n(Zi.decode(e));if(t==null)throw Error(`Invalid checksum`);return t}return{encode:t,decode:i,decodeUnsafe:r}}var ao=te({default:()=>so});function oo(e){return ro(ro(e))}var so=io(oo);function co(e){let t=e;for(;t&&!(t.encode&&t.decode&&t.decodeUnsafe)&&t.default;)t=t.default;return t}co(ao);var lo=[`u8`,`u16`,`u32`,`u64`,`u128`,`i8`,`i16`,`i32`,`i64`,`i128`,`f32`,`f64`],uo=function(){function e(){this.offset=0,this.buffer_size=256,this.buffer=new ArrayBuffer(this.buffer_size),this.view=new DataView(this.buffer)}return e.prototype.resize_if_necessary=function(e){if(this.buffer_size-this.offset<e){this.buffer_size=Math.max(this.buffer_size*2,this.buffer_size+e);var t=new ArrayBuffer(this.buffer_size);new Uint8Array(t).set(new Uint8Array(this.buffer)),this.buffer=t,this.view=new DataView(t)}},e.prototype.get_used_buffer=function(){return new Uint8Array(this.buffer).slice(0,this.offset)},e.prototype.store_value=function(e,t){var n=t.substring(1),r=parseInt(n)/8;this.resize_if_necessary(r);var i=t[0]===`f`?`setFloat${n}`:t[0]===`i`?`setInt${n}`:`setUint${n}`;this.view[i](this.offset,e,!0),this.offset+=r},e.prototype.store_bytes=function(e){this.resize_if_necessary(e.length),new Uint8Array(this.buffer).set(new Uint8Array(e),this.offset),this.offset+=e.length},e}(),fo=function(){function e(e){this.offset=0,this.buffer_size=e.length,this.buffer=new ArrayBuffer(e.length),new Uint8Array(this.buffer).set(e),this.view=new DataView(this.buffer)}return e.prototype.assert_enough_buffer=function(e){if(this.offset+e>this.buffer.byteLength)throw Error(`Error in schema, the buffer is smaller than expected`)},e.prototype.consume_value=function(e){var t=e.substring(1),n=parseInt(t)/8;this.assert_enough_buffer(n);var r=e[0]===`f`?`getFloat${t}`:e[0]===`i`?`getInt${t}`:`getUint${t}`,i=this.view[r](this.offset,!0);return this.offset+=n,i},e.prototype.consume_bytes=function(e){this.assert_enough_buffer(e);var t=this.buffer.slice(this.offset,this.offset+e);return this.offset+=e,t},e}(),po=(function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};return function(t,n){if(typeof n!=`function`&&n!==null)throw TypeError(`Class extends value `+String(n)+` is not a constructor or null`);e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}})();function mo(e){return Array.isArray(e)||!!e&&typeof e==`object`&&`length`in e&&typeof e.length==`number`&&(e.length===0||e.length>0&&e.length-1 in e)}function ho(e,t,n){if(typeof e!==t)throw Error(`Expected ${t} not ${typeof e}(${e}) at ${n.join(`.`)}`)}function go(e,t){var n=[`number`,`string`,`bigint`,`boolean`].includes(typeof e),r=typeof e==`object`&&!!e&&`toString`in e;if(!n&&!r)throw Error(`Expected bigint, number, boolean or string not ${typeof e}(${e}) at ${t.join(`.`)}`)}function _o(e,t,n){if(e!==t)throw Error(`Array length ${e} does not match schema length ${t} at ${n.join(`.`)}`)}function vo(e,t){if(typeof e!=`object`||!e)throw Error(`Expected object not ${typeof e}(${e}) at ${t.join(`.`)}`)}lo.concat([`bool`,`string`]),function(e){po(t,e);function t(t,n){var r=`Invalid schema: ${JSON.stringify(t)} expected ${n}`;return e.call(this,r)||this}return t}(Error),function(){function e(e){this.encoded=new uo,this.fieldPath=[`value`],this.checkTypes=e}return e.prototype.encode=function(e,t){return this.encode_value(e,t),this.encoded.get_used_buffer()},e.prototype.encode_value=function(e,t){if(typeof t==`string`){if(lo.includes(t))return this.encode_integer(e,t);if(t===`string`)return this.encode_string(e);if(t===`bool`)return this.encode_boolean(e)}if(typeof t==`object`){if(`option`in t)return this.encode_option(e,t);if(`enum`in t)return this.encode_enum(e,t);if(`array`in t)return this.encode_array(e,t);if(`set`in t)return this.encode_set(e,t);if(`map`in t)return this.encode_map(e,t);if(`struct`in t)return this.encode_struct(e,t)}},e.prototype.encode_integer=function(e,t){var n=parseInt(t.substring(1));n<=32||t==`f64`?(this.checkTypes&&ho(e,`number`,this.fieldPath),this.encoded.store_value(e,t)):(this.checkTypes&&go(e,this.fieldPath),this.encode_bigint(BigInt(e),n))},e.prototype.encode_bigint=function(e,t){for(var n=t/8,r=new Uint8Array(n),i=0;i<n;i++)r[i]=Number(e&BigInt(255)),e>>=BigInt(8);this.encoded.store_bytes(new Uint8Array(r))},e.prototype.encode_string=function(e){this.checkTypes&&ho(e,`string`,this.fieldPath);for(var t=e,n=[],r=0;r<t.length;r++){var i=t.charCodeAt(r);i<128?n.push(i):i<2048?n.push(192|i>>6,128|i&63):i<55296||i>=57344?n.push(224|i>>12,128|i>>6&63,128|i&63):(r++,i=65536+((i&1023)<<10|t.charCodeAt(r)&1023),n.push(240|i>>18,128|i>>12&63,128|i>>6&63,128|i&63))}this.encoded.store_value(n.length,`u32`),this.encoded.store_bytes(new Uint8Array(n))},e.prototype.encode_boolean=function(e){this.checkTypes&&ho(e,`boolean`,this.fieldPath),this.encoded.store_value(+!!e,`u8`)},e.prototype.encode_option=function(e,t){e==null?this.encoded.store_value(0,`u8`):(this.encoded.store_value(1,`u8`),this.encode_value(e,t.option))},e.prototype.encode_enum=function(e,t){this.checkTypes&&vo(e,this.fieldPath);for(var n=Object.keys(e)[0],r=0;r<t.enum.length;r++){var i=t.enum[r];if(n===Object.keys(i.struct)[0])return this.encoded.store_value(r,`u8`),this.encode_struct(e,i)}throw Error(`Enum key (${n}) not found in enum schema: ${JSON.stringify(t)} at ${this.fieldPath.join(`.`)}`)},e.prototype.encode_array=function(e,t){if(mo(e))return this.encode_arraylike(e,t);if(e instanceof ArrayBuffer)return this.encode_buffer(e,t);throw Error(`Expected Array-like not ${typeof e}(${e}) at ${this.fieldPath.join(`.`)}`)},e.prototype.encode_arraylike=function(e,t){t.array.len?_o(e.length,t.array.len,this.fieldPath):this.encoded.store_value(e.length,`u32`);for(var n=0;n<e.length;n++)this.encode_value(e[n],t.array.type)},e.prototype.encode_buffer=function(e,t){t.array.len?_o(e.byteLength,t.array.len,this.fieldPath):this.encoded.store_value(e.byteLength,`u32`),this.encoded.store_bytes(new Uint8Array(e))},e.prototype.encode_set=function(e,t){this.checkTypes&&ho(e,`object`,this.fieldPath);var n=e instanceof Set?Array.from(e.values()):Object.values(e);this.encoded.store_value(n.length,`u32`);for(var r=0,i=n;r<i.length;r++){var a=i[r];this.encode_value(a,t.set)}},e.prototype.encode_map=function(e,t){this.checkTypes&&ho(e,`object`,this.fieldPath);var n=e instanceof Map,r=n?Array.from(e.keys()):Object.keys(e);this.encoded.store_value(r.length,`u32`);for(var i=0,a=r;i<a.length;i++){var o=a[i];this.encode_value(o,t.map.key),this.encode_value(n?e.get(o):e[o],t.map.value)}},e.prototype.encode_struct=function(e,t){this.checkTypes&&ho(e,`object`,this.fieldPath);for(var n=0,r=Object.keys(t.struct);n<r.length;n++){var i=r[n];this.fieldPath.push(i),this.encode_value(e[i],t.struct[i]),this.fieldPath.pop()}},e}(),function(){function e(e){this.buffer=new fo(e)}return e.prototype.decode=function(e){return this.decode_value(e)},e.prototype.decode_value=function(e){if(typeof e==`string`){if(lo.includes(e))return this.decode_integer(e);if(e===`string`)return this.decode_string();if(e===`bool`)return this.decode_boolean()}if(typeof e==`object`){if(`option`in e)return this.decode_option(e);if(`enum`in e)return this.decode_enum(e);if(`array`in e)return this.decode_array(e);if(`set`in e)return this.decode_set(e);if(`map`in e)return this.decode_map(e);if(`struct`in e)return this.decode_struct(e)}throw Error(`Unsupported type: ${e}`)},e.prototype.decode_integer=function(e){var t=parseInt(e.substring(1));return t<=32||e==`f64`?this.buffer.consume_value(e):this.decode_bigint(t,e.startsWith(`i`))},e.prototype.decode_bigint=function(e,t){t===void 0&&(t=!1);var n=e/8,r=new Uint8Array(this.buffer.consume_bytes(n)),i=r.reduceRight(function(e,t){return e+t.toString(16).padStart(2,`0`)},``);return t&&r[n-1]?BigInt.asIntN(e,BigInt(`0x${i}`)):BigInt(`0x${i}`)},e.prototype.decode_string=function(){for(var e=this.decode_integer(`u32`),t=new Uint8Array(this.buffer.consume_bytes(e)),n=[],r=0;r<e;++r){var i=t[r];if(i<128)n.push(i);else if(i<224)n.push((i&31)<<6|t[++r]&63);else if(i<240)n.push((i&15)<<12|(t[++r]&63)<<6|t[++r]&63);else{var a=(i&7)<<18|(t[++r]&63)<<12|(t[++r]&63)<<6|t[++r]&63;n.push(a)}}return String.fromCodePoint.apply(String,n)},e.prototype.decode_boolean=function(){return this.buffer.consume_value(`u8`)>0},e.prototype.decode_option=function(e){var t=this.buffer.consume_value(`u8`);if(t===1)return this.decode_value(e.option);if(t!==0)throw Error(`Invalid option ${t}`);return null},e.prototype.decode_enum=function(e){var t,n=this.buffer.consume_value(`u8`);if(n>e.enum.length)throw Error(`Enum option ${n} is not available`);var r=e.enum[n].struct,i=Object.keys(r)[0];return t={},t[i]=this.decode_value(r[i]),t},e.prototype.decode_array=function(e){for(var t=[],n=e.array.len?e.array.len:this.decode_integer(`u32`),r=0;r<n;++r)t.push(this.decode_value(e.array.type));return t},e.prototype.decode_set=function(e){for(var t=this.decode_integer(`u32`),n=new Set,r=0;r<t;++r)n.add(this.decode_value(e.set));return n},e.prototype.decode_map=function(e){for(var t=this.decode_integer(`u32`),n=new Map,r=0;r<t;++r){var i=this.decode_value(e.map.key),a=this.decode_value(e.map.value);n.set(i,a)}return n},e.prototype.decode_struct=function(e){var t={};for(var n in e.struct)t[n]=this.decode_value(e.struct[n]);return t},e}(),new Uint8Array([75,69,77,0,16]),new Uint8Array([72,80,75,69,0,16,0,1,0,2]),new Uint8Array([72,80,75,69,45,118,49]),new Uint8Array([115,101,99,114,101,116]),new Uint8Array([101,97,101,95,112,114,107]),new Uint8Array([115,104,97,114,101,100,95,115,101,99,114,101,116]),new Uint8Array([0,32,72,80,75,69,45,118,49,72,80,75,69,0,16,0,1,0,2,107,101,121,0,143,195,174,184,50,73,10,75,90,179,228,32,35,40,125,178,154,31,75,199,194,34,192,223,34,135,39,183,10,64,33,18,47,63,4,233,32,108,209,36,19,80,53,41,180,122,198,166,48,185,46,196,207,125,35,69,8,208,175,151,113,201,158,80]),new Uint8Array([0,12,72,80,75,69,45,118,49,72,80,75,69,0,16,0,1,0,2,98,97,115,101,95,110,111,110,99,101,0,143,195,174,184,50,73,10,75,90,179,228,32,35,40,125,178,154,31,75,199,194,34,192,223,34,135,39,183,10,64,33,18,47,63,4,233,32,108,209,36,19,80,53,41,180,122,198,166,48,185,46,196,207,125,35,69,8,208,175,151,113,201,158,80]),new Uint8Array([113,111,115,95,101,110,99,114,121,112,116,105,111,110,95,104,109,97,99,95,109,101,115,115,97,103,101]);const yo=e=>{let t=Hi(e);if(t.length<2)throw Error(`failed to convert DER-encoded signature: insufficient length`);if(t[0]!==48)throw Error(`failed to convert DER-encoded signature: invalid format (missing SEQUENCE tag)`);let n=1,r=t[n];if(r<=127){if(t.length<2+r)throw Error(`failed to convert DER-encoded signature: inconsistent message length header`);n+=1}else throw Error(`failed to convert DER-encoded signature: unexpectedly large or invalid signature length`);if(t[n]!==2)throw Error(`failed to convert DER-encoded signature: invalid tag for r`);n++;let i=t[n];if(i>33)throw Error(`failed to convert DER-encoded signature: unexpected length for r`);n++;let a=t.slice(n,n+i);if(n+=i,t[n]!==2)throw Error(`failed to convert DER-encoded signature: invalid tag for s`);n++;let o=t[n];if(o>33)throw Error(`failed to convert DER-encoded signature: unexpected length for s`);n++;let s=t.slice(n,n+o),c=Ui(a,32),l=Ui(s,32);return new Uint8Array([...c,...l])};var bo;(function(e){e.NOTARIZER=`notarizer`,e.SIGNER=`signer`,e.EVM_PARSER=`evm-parser`,e.TLS_FETCHER=`tls-fetcher`,e.UMP=`ump`})(bo||={});var xo=N(((e,t)=>{(function(e,n){var r=2**-24,i=2**32,a=2**53;function o(e){var t=new ArrayBuffer(256),r=new DataView(t),o,s=0;function c(e){for(var n=t.byteLength,i=s+e;n<i;)n*=2;if(n!==t.byteLength){var a=r;t=new ArrayBuffer(n),r=new DataView(t);for(var c=s+3>>2,l=0;l<c;++l)r.setUint32(l*4,a.getUint32(l*4))}return o=e,r}function l(){s+=o}function u(e){l(c(8).setFloat64(s,e))}function d(e){l(c(1).setUint8(s,e))}function f(e){for(var t=c(e.length),n=0;n<e.length;++n)t.setUint8(s+n,e[n]);l()}function p(e){l(c(2).setUint16(s,e))}function m(e){l(c(4).setUint32(s,e))}function h(e){var t=e%i,n=(e-t)/i,r=c(8);r.setUint32(s,n),r.setUint32(s+4,t),l()}function g(e,t){t<24?d(e<<5|t):t<256?(d(e<<5|24),d(t)):t<65536?(d(e<<5|25),p(t)):t<4294967296?(d(e<<5|26),m(t)):(d(e<<5|27),h(t))}function _(e){var t;if(e===!1)return d(244);if(e===!0)return d(245);if(e===null)return d(246);if(e===n)return d(247);switch(typeof e){case`number`:if(Math.floor(e)===e){if(0<=e&&e<=a)return g(0,e);if(-a<=e&&e<0)return g(1,-(e+1))}return d(251),u(e);case`string`:var r=[];for(t=0;t<e.length;++t){var i=e.charCodeAt(t);i<128?r.push(i):i<2048?(r.push(192|i>>6),r.push(128|i&63)):i<55296?(r.push(224|i>>12),r.push(128|i>>6&63),r.push(128|i&63)):(i=(i&1023)<<10,i|=e.charCodeAt(++t)&1023,i+=65536,r.push(240|i>>18),r.push(128|i>>12&63),r.push(128|i>>6&63),r.push(128|i&63))}return g(3,r.length),f(r);default:var o;if(Array.isArray(e))for(o=e.length,g(4,o),t=0;t<o;++t)_(e[t]);else if(e instanceof Uint8Array)g(2,e.length),f(e);else{var s=Object.keys(e);for(o=s.length,g(5,o),t=0;t<o;++t){var c=s[t];_(c),_(e[c])}}}}if(_(e),`slice`in t)return t.slice(0,s);for(var v=new ArrayBuffer(s),y=new DataView(v),b=0;b<s;++b)y.setUint8(b,r.getUint8(b));return v}function s(e,t,a){var o=new DataView(e),s=0;typeof t!=`function`&&(t=function(e){return e}),typeof a!=`function`&&(a=function(){return n});function c(e,t){return s+=t,e}function l(t){return c(new Uint8Array(e,s,t),t)}function u(){var e=new DataView(new ArrayBuffer(4)),t=m(),n=t&32768,i=t&31744,a=t&1023;if(i===31744)i=261120;else if(i!==0)i+=114688;else if(a!==0)return a*r;return e.setUint32(0,n<<16|i<<13|a<<13),e.getFloat32(0)}function d(){return c(o.getFloat32(s),4)}function f(){return c(o.getFloat64(s),8)}function p(){return c(o.getUint8(s),1)}function m(){return c(o.getUint16(s),2)}function h(){return c(o.getUint32(s),4)}function g(){return h()*i+h()}function _(){return o.getUint8(s)===255?(s+=1,!0):!1}function v(e){if(e<24)return e;if(e===24)return p();if(e===25)return m();if(e===26)return h();if(e===27)return g();if(e===31)return-1;throw`Invalid length encoding`}function y(e){var t=p();if(t===255)return-1;var n=v(t&31);if(n<0||t>>5!==e)throw`Invalid indefinite length element`;return n}function b(e,t){for(var n=0;n<t;++n){var r=p();r&128&&(r<224?(r=(r&31)<<6|p()&63,--t):r<240?(r=(r&15)<<12|(p()&63)<<6|p()&63,t-=2):(r=(r&15)<<18|(p()&63)<<12|(p()&63)<<6|p()&63,t-=3)),r<65536?e.push(r):(r-=65536,e.push(55296|r>>10),e.push(56320|r&1023))}}function x(){var e=p(),r=e>>5,i=e&31,o,s;if(r===7)switch(i){case 25:return u();case 26:return d();case 27:return f()}if(s=v(i),s<0&&(r<2||6<r))throw`Invalid length`;switch(r){case 0:return s;case 1:return-1-s;case 2:if(s<0){for(var c=[],m=0;(s=y(r))>=0;)m+=s,c.push(l(s));var h=new Uint8Array(m),g=0;for(o=0;o<c.length;++o)h.set(c[o],g),g+=c[o].length;return h}return l(s);case 3:var S=[];if(s<0)for(;(s=y(r))>=0;)b(S,s);else b(S,s);return String.fromCharCode.apply(null,S);case 4:var C;if(s<0)for(C=[];!_();)C.push(x());else for(C=Array(s),o=0;o<s;++o)C[o]=x();return C;case 5:var w={};for(o=0;o<s||s<0&&!_();++o){var T=x();w[T]=x()}return w;case 6:return t(x(),s);case 7:switch(s){case 20:return!1;case 21:return!0;case 22:return null;case 23:return n;default:return a(s)}}}var S=x();if(s!==e.byteLength)throw`Remaining bytes`;return S}var c={encode:o,decode:s};typeof define==`function`&&define.amd?define(`cbor/cbor`,c):t!==void 0&&t.exports?t.exports=c:e.CBOR||=c})(e)})),So=N((()=>{
276
- /*! *****************************************************************************
277
- Copyright (C) Microsoft. All rights reserved.
278
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use
279
- this file except in compliance with the License. You may obtain a copy of the
280
- License at http://www.apache.org/licenses/LICENSE-2.0
281
-
282
- THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
283
- KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
284
- WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
285
- MERCHANTABLITY OR NON-INFRINGEMENT.
286
-
287
- See the Apache Version 2.0 License for specific language governing permissions
288
- and limitations under the License.
289
- ***************************************************************************** */
290
- var e;(function(e){(function(t){var n=typeof globalThis==`object`?globalThis:typeof global==`object`?global:typeof self==`object`?self:typeof this==`object`?this:s(),r=i(e);n.Reflect!==void 0&&(r=i(n.Reflect,r)),t(r,n),n.Reflect===void 0&&(n.Reflect=e);function i(e,t){return function(n,r){Object.defineProperty(e,n,{configurable:!0,writable:!0,value:r}),t&&t(n,r)}}function a(){try{return Function(`return this;`)()}catch{}}function o(){try{return(0,eval)(`(function() { return this; })()`)}catch{}}function s(){return a()||o()}})(function(e,t){var n=Object.prototype.hasOwnProperty,r=typeof Symbol==`function`,i=r&&Symbol.toPrimitive!==void 0?Symbol.toPrimitive:`@@toPrimitive`,a=r&&Symbol.iterator!==void 0?Symbol.iterator:`@@iterator`,o=typeof Object.create==`function`,s={__proto__:[]}instanceof Array,c=!o&&!s,l={create:o?function(){return we(Object.create(null))}:s?function(){return we({__proto__:null})}:function(){return we({})},has:c?function(e,t){return n.call(e,t)}:function(e,t){return t in e},get:c?function(e,t){return n.call(e,t)?e[t]:void 0}:function(e,t){return e[t]}},u=Object.getPrototypeOf(Function),d=typeof Map==`function`&&typeof Map.prototype.entries==`function`?Map:B(),f=typeof Set==`function`&&typeof Set.prototype.entries==`function`?Set:Se(),p=typeof WeakMap==`function`?WeakMap:Ce(),m=r?Symbol.for(`@reflect-metadata:registry`):void 0,h=z(),g=ye(h);function _(e,t,n,r){if(P(n)){if(!le(e)||!de(t))throw TypeError();return D(e,t)}else{if(!le(e)||!I(t)||!I(r)&&!P(r)&&!F(r))throw TypeError();return F(r)&&(r=void 0),n=ce(n),O(e,t,n,r)}}e(`decorate`,_);function v(e,t){function n(n,r){if(!I(n)||!P(r)&&!fe(r))throw TypeError();M(e,t,n,r)}return n}e(`metadata`,v);function y(e,t,n,r){if(!I(n))throw TypeError();return P(r)||(r=ce(r)),M(e,t,n,r)}e(`defineMetadata`,y);function b(e,t,n){if(!I(t))throw TypeError();return P(n)||(n=ce(n)),k(e,t,n)}e(`hasMetadata`,b);function x(e,t,n){if(!I(t))throw TypeError();return P(n)||(n=ce(n)),A(e,t,n)}e(`hasOwnMetadata`,x);function S(e,t,n){if(!I(t))throw TypeError();return P(n)||(n=ce(n)),ee(e,t,n)}e(`getMetadata`,S);function C(e,t,n){if(!I(t))throw TypeError();return P(n)||(n=ce(n)),j(e,t,n)}e(`getOwnMetadata`,C);function w(e,t){if(!I(e))throw TypeError();return P(t)||(t=ce(t)),N(e,t)}e(`getMetadataKeys`,w);function T(e,t){if(!I(e))throw TypeError();return P(t)||(t=ce(t)),te(e,t)}e(`getOwnMetadataKeys`,T);function E(e,t,n){if(!I(t)||(P(n)||(n=ce(n)),!I(t)))throw TypeError();P(n)||(n=ce(n));var r=xe(t,n,!1);return P(r)?!1:r.OrdinaryDeleteMetadata(e,t,n)}e(`deleteMetadata`,E);function D(e,t){for(var n=e.length-1;n>=0;--n){var r=e[n],i=r(t);if(!P(i)&&!F(i)){if(!de(i))throw TypeError();t=i}}return t}function O(e,t,n,r){for(var i=e.length-1;i>=0;--i){var a=e[i],o=a(t,n,r);if(!P(o)&&!F(o)){if(!I(o))throw TypeError();r=o}}return r}function k(e,t,n){if(A(e,t,n))return!0;var r=_e(t);return F(r)?!1:k(e,r,n)}function A(e,t,n){var r=xe(t,n,!1);return P(r)?!1:oe(r.OrdinaryHasOwnMetadata(e,t,n))}function ee(e,t,n){if(A(e,t,n))return j(e,t,n);var r=_e(t);if(!F(r))return ee(e,r,n)}function j(e,t,n){var r=xe(t,n,!1);if(!P(r))return r.OrdinaryGetOwnMetadata(e,t,n)}function M(e,t,n,r){xe(n,r,!0).OrdinaryDefineOwnMetadata(e,t,n,r)}function N(e,t){var n=te(e,t),r=_e(e);if(r===null)return n;var i=N(r,t);if(i.length<=0)return n;if(n.length<=0)return i;for(var a=new f,o=[],s=0,c=n;s<c.length;s++){var l=c[s],u=a.has(l);u||(a.add(l),o.push(l))}for(var d=0,p=i;d<p.length;d++){var l=p[d],u=a.has(l);u||(a.add(l),o.push(l))}return o}function te(e,t){var n=xe(e,t,!1);return n?n.OrdinaryOwnMetadataKeys(e,t):[]}function ne(e){if(e===null)return 1;switch(typeof e){case`undefined`:return 0;case`boolean`:return 2;case`string`:return 3;case`symbol`:return 4;case`number`:return 5;case`object`:return e===null?1:6;default:return 6}}function P(e){return e===void 0}function F(e){return e===null}function re(e){return typeof e==`symbol`}function I(e){return typeof e==`object`?e!==null:typeof e==`function`}function ie(e,t){switch(ne(e)){case 0:return e;case 1:return e;case 2:return e;case 3:return e;case 4:return e;case 5:return e}var n=t===3?`string`:t===5?`number`:`default`,r=L(e,i);if(r!==void 0){var a=r.call(e,n);if(I(a))throw TypeError();return a}return ae(e,n==="default"?`number`:n)}function ae(e,t){if(t===`string`){var n=e.toString;if(ue(n)){var r=n.call(e);if(!I(r))return r}var i=e.valueOf;if(ue(i)){var r=i.call(e);if(!I(r))return r}}else{var i=e.valueOf;if(ue(i)){var r=i.call(e);if(!I(r))return r}var a=e.toString;if(ue(a)){var r=a.call(e);if(!I(r))return r}}throw TypeError()}function oe(e){return!!e}function se(e){return``+e}function ce(e){var t=ie(e,3);return re(t)?t:se(t)}function le(e){return Array.isArray?Array.isArray(e):e instanceof Object?e instanceof Array:Object.prototype.toString.call(e)===`[object Array]`}function ue(e){return typeof e==`function`}function de(e){return typeof e==`function`}function fe(e){switch(ne(e)){case 3:return!0;case 4:return!0;default:return!1}}function pe(e,t){return e===t||e!==e&&t!==t}function L(e,t){var n=e[t];if(n!=null){if(!ue(n))throw TypeError();return n}}function me(e){var t=L(e,a);if(!ue(t))throw TypeError();var n=t.call(e);if(!I(n))throw TypeError();return n}function he(e){return e.value}function R(e){var t=e.next();return t.done?!1:t}function ge(e){var t=e.return;t&&t.call(e)}function _e(e){var t=Object.getPrototypeOf(e);if(typeof e!=`function`||e===u||t!==u)return t;var n=e.prototype,r=n&&Object.getPrototypeOf(n);if(r==null||r===Object.prototype)return t;var i=r.constructor;return typeof i!=`function`||i===e?t:i}function ve(){var e;!P(m)&&t.Reflect!==void 0&&!(m in t.Reflect)&&typeof t.Reflect.defineMetadata==`function`&&(e=be(t.Reflect));var n,r,i,a=new p,o={registerProvider:s,getProvider:l,setProvider:h};return o;function s(t){if(!Object.isExtensible(o))throw Error(`Cannot add provider to a frozen registry.`);switch(!0){case e===t:break;case P(n):n=t;break;case n===t:break;case P(r):r=t;break;case r===t:break;default:i===void 0&&(i=new f),i.add(t);break}}function c(t,a){if(!P(n)){if(n.isProviderFor(t,a))return n;if(!P(r)){if(r.isProviderFor(t,a))return n;if(!P(i))for(var o=me(i);;){var s=R(o);if(!s)return;var c=he(s);if(c.isProviderFor(t,a))return ge(o),c}}}if(!P(e)&&e.isProviderFor(t,a))return e}function l(e,t){var n=a.get(e),r;return P(n)||(r=n.get(t)),P(r)?(r=c(e,t),P(r)||(P(n)&&(n=new d,a.set(e,n)),n.set(t,r)),r):r}function u(e){if(P(e))throw TypeError();return n===e||r===e||!P(i)&&i.has(e)}function h(e,t,n){if(!u(n))throw Error(`Metadata provider not registered.`);var r=l(e,t);if(r!==n){if(!P(r))return!1;var i=a.get(e);P(i)&&(i=new d,a.set(e,i)),i.set(t,n)}return!0}}function z(){var e;return!P(m)&&I(t.Reflect)&&Object.isExtensible(t.Reflect)&&(e=t.Reflect[m]),P(e)&&(e=ve()),!P(m)&&I(t.Reflect)&&Object.isExtensible(t.Reflect)&&Object.defineProperty(t.Reflect,m,{enumerable:!1,configurable:!1,writable:!1,value:e}),e}function ye(e){var t=new p,n={isProviderFor:function(e,n){var r=t.get(e);return P(r)?!1:r.has(n)},OrdinaryDefineOwnMetadata:o,OrdinaryHasOwnMetadata:i,OrdinaryGetOwnMetadata:a,OrdinaryOwnMetadataKeys:s,OrdinaryDeleteMetadata:c};return h.registerProvider(n),n;function r(r,i,a){var o=t.get(r),s=!1;if(P(o)){if(!a)return;o=new d,t.set(r,o),s=!0}var c=o.get(i);if(P(c)){if(!a)return;if(c=new d,o.set(i,c),!e.setProvider(r,i,n))throw o.delete(i),s&&t.delete(r),Error(`Wrong provider for target.`)}return c}function i(e,t,n){var i=r(t,n,!1);return P(i)?!1:oe(i.has(e))}function a(e,t,n){var i=r(t,n,!1);if(!P(i))return i.get(e)}function o(e,t,n,i){r(n,i,!0).set(e,t)}function s(e,t){var n=[],i=r(e,t,!1);if(P(i))return n;for(var a=me(i.keys()),o=0;;){var s=R(a);if(!s)return n.length=o,n;var c=he(s);try{n[o]=c}catch(e){try{ge(a)}finally{throw e}}o++}}function c(e,n,i){var a=r(n,i,!1);if(P(a)||!a.delete(e))return!1;if(a.size===0){var o=t.get(n);P(o)||(o.delete(i),o.size===0&&t.delete(o))}return!0}}function be(e){var t=e.defineMetadata,n=e.hasOwnMetadata,r=e.getOwnMetadata,i=e.getOwnMetadataKeys,a=e.deleteMetadata,o=new p;return{isProviderFor:function(e,t){var n=o.get(e);return!P(n)&&n.has(t)?!0:i(e,t).length?(P(n)&&(n=new f,o.set(e,n)),n.add(t),!0):!1},OrdinaryDefineOwnMetadata:t,OrdinaryHasOwnMetadata:n,OrdinaryGetOwnMetadata:r,OrdinaryOwnMetadataKeys:i,OrdinaryDeleteMetadata:a}}function xe(e,t,n){var r=h.getProvider(e,t);if(!P(r))return r;if(n){if(h.setProvider(e,t,g))return g;throw Error(`Illegal state.`)}}function B(){var e={},t=[],n=function(){function e(e,t,n){this._index=0,this._keys=e,this._values=t,this._selector=n}return e.prototype[`@@iterator`]=function(){return this},e.prototype[a]=function(){return this},e.prototype.next=function(){var e=this._index;if(e>=0&&e<this._keys.length){var n=this._selector(this._keys[e],this._values[e]);return e+1>=this._keys.length?(this._index=-1,this._keys=t,this._values=t):this._index++,{value:n,done:!1}}return{value:void 0,done:!0}},e.prototype.throw=function(e){throw this._index>=0&&(this._index=-1,this._keys=t,this._values=t),e},e.prototype.return=function(e){return this._index>=0&&(this._index=-1,this._keys=t,this._values=t),{value:e,done:!0}},e}();return function(){function t(){this._keys=[],this._values=[],this._cacheKey=e,this._cacheIndex=-2}return Object.defineProperty(t.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),t.prototype.has=function(e){return this._find(e,!1)>=0},t.prototype.get=function(e){var t=this._find(e,!1);return t>=0?this._values[t]:void 0},t.prototype.set=function(e,t){var n=this._find(e,!0);return this._values[n]=t,this},t.prototype.delete=function(t){var n=this._find(t,!1);if(n>=0){for(var r=this._keys.length,i=n+1;i<r;i++)this._keys[i-1]=this._keys[i],this._values[i-1]=this._values[i];return this._keys.length--,this._values.length--,pe(t,this._cacheKey)&&(this._cacheKey=e,this._cacheIndex=-2),!0}return!1},t.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=e,this._cacheIndex=-2},t.prototype.keys=function(){return new n(this._keys,this._values,r)},t.prototype.values=function(){return new n(this._keys,this._values,i)},t.prototype.entries=function(){return new n(this._keys,this._values,o)},t.prototype[`@@iterator`]=function(){return this.entries()},t.prototype[a]=function(){return this.entries()},t.prototype._find=function(e,t){if(!pe(this._cacheKey,e)){this._cacheIndex=-1;for(var n=0;n<this._keys.length;n++)if(pe(this._keys[n],e)){this._cacheIndex=n;break}}return this._cacheIndex<0&&t&&(this._cacheIndex=this._keys.length,this._keys.push(e),this._values.push(void 0)),this._cacheIndex},t}();function r(e,t){return e}function i(e,t){return t}function o(e,t){return[e,t]}}function Se(){return function(){function e(){this._map=new d}return Object.defineProperty(e.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),e.prototype.has=function(e){return this._map.has(e)},e.prototype.add=function(e){return this._map.set(e,e),this},e.prototype.delete=function(e){return this._map.delete(e)},e.prototype.clear=function(){this._map.clear()},e.prototype.keys=function(){return this._map.keys()},e.prototype.values=function(){return this._map.keys()},e.prototype.entries=function(){return this._map.entries()},e.prototype[`@@iterator`]=function(){return this.keys()},e.prototype[a]=function(){return this.keys()},e}()}function Ce(){var e=16,t=l.create(),r=i();return function(){function e(){this._key=i()}return e.prototype.has=function(e){var t=a(e,!1);return t===void 0?!1:l.has(t,this._key)},e.prototype.get=function(e){var t=a(e,!1);return t===void 0?void 0:l.get(t,this._key)},e.prototype.set=function(e,t){var n=a(e,!0);return n[this._key]=t,this},e.prototype.delete=function(e){var t=a(e,!1);return t===void 0?!1:delete t[this._key]},e.prototype.clear=function(){this._key=i()},e}();function i(){var e;do e=`@@WeakMap@@`+c();while(l.has(t,e));return t[e]=!0,e}function a(e,t){if(!n.call(e,r)){if(!t)return;Object.defineProperty(e,r,{value:l.create()})}return e[r]}function o(e,t){for(var n=0;n<t;++n)e[n]=Math.random()*255|0;return e}function s(e){if(typeof Uint8Array==`function`){var t=new Uint8Array(e);return typeof crypto<`u`?crypto.getRandomValues(t):typeof msCrypto<`u`?msCrypto.getRandomValues(t):o(t,e),t}return o(Array(e),e)}function c(){var t=s(e);t[6]=t[6]&79|64,t[8]=t[8]&191|128;for(var n=``,r=0;r<e;++r){var i=t[r];(r===4||r===6||r===8)&&(n+=`-`),i<16&&(n+=`0`),n+=i.toString(16).toLowerCase()}return n}}function we(e){return e.__=void 0,delete e.__,e}})})(e||={})})),Y=te({__addDisposableResource:()=>Xo,__assign:()=>es,__asyncDelegator:()=>Ho,__asyncGenerator:()=>Vo,__asyncValues:()=>Uo,__await:()=>Bo,__awaiter:()=>Mo,__classPrivateFieldGet:()=>qo,__classPrivateFieldIn:()=>Yo,__classPrivateFieldSet:()=>Jo,__createBinding:()=>ts,__decorate:()=>To,__disposeResources:()=>Zo,__esDecorate:()=>Do,__exportStar:()=>Po,__extends:()=>Co,__generator:()=>No,__importDefault:()=>Ko,__importStar:()=>Go,__makeTemplateObject:()=>Wo,__metadata:()=>jo,__param:()=>Eo,__propKey:()=>ko,__read:()=>Io,__rest:()=>wo,__rewriteRelativeImportExtension:()=>Qo,__runInitializers:()=>Oo,__setFunctionName:()=>Ao,__spread:()=>Lo,__spreadArray:()=>zo,__spreadArrays:()=>Ro,__values:()=>Fo,default:()=>as});function Co(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Class extends value `+String(t)+` is not a constructor or null`);$o(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}function wo(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function To(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}function Eo(e,t){return function(n,r){t(n,r,e)}}function Do(e,t,n,r,i,a){function o(e){if(e!==void 0&&typeof e!=`function`)throw TypeError(`Function expected`);return e}for(var s=r.kind,c=s===`getter`?`get`:s===`setter`?`set`:`value`,l=!t&&e?r.static?e:e.prototype:null,u=t||(l?Object.getOwnPropertyDescriptor(l,r.name):{}),d,f=!1,p=n.length-1;p>=0;p--){var m={};for(var h in r)m[h]=h===`access`?{}:r[h];for(var h in r.access)m.access[h]=r.access[h];m.addInitializer=function(e){if(f)throw TypeError(`Cannot add initializers after decoration has completed`);a.push(o(e||null))};var g=(0,n[p])(s===`accessor`?{get:u.get,set:u.set}:u[c],m);if(s===`accessor`){if(g===void 0)continue;if(typeof g!=`object`||!g)throw TypeError(`Object expected`);(d=o(g.get))&&(u.get=d),(d=o(g.set))&&(u.set=d),(d=o(g.init))&&i.unshift(d)}else(d=o(g))&&(s===`field`?i.unshift(d):u[c]=d)}l&&Object.defineProperty(l,r.name,u),f=!0}function Oo(e,t,n){for(var r=arguments.length>2,i=0;i<t.length;i++)n=r?t[i].call(e,n):t[i].call(e);return r?n:void 0}function ko(e){return typeof e==`symbol`?e:`${e}`}function Ao(e,t,n){return typeof t==`symbol`&&(t=t.description?`[${t.description}]`:``),Object.defineProperty(e,"name",{configurable:!0,value:n?`${n} ${t}`:t})}function jo(e,t){if(typeof Reflect==`object`&&typeof Reflect.metadata==`function`)return Reflect.metadata(e,t)}function Mo(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})}function No(e,t){var n={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},r,i,a,o=Object.create((typeof Iterator==`function`?Iterator:Object).prototype);return o.next=s(0),o.throw=s(1),o.return=s(2),typeof Symbol==`function`&&(o[Symbol.iterator]=function(){return this}),o;function s(e){return function(t){return c([e,t])}}function c(s){if(r)throw TypeError(`Generator is already executing.`);for(;o&&(o=0,s[0]&&(n=0)),n;)try{if(r=1,i&&(a=s[0]&2?i.return:s[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,s[1])).done)return a;switch(i=0,a&&(s=[s[0]&2,a.value]),s[0]){case 0:case 1:a=s;break;case 4:return n.label++,{value:s[1],done:!1};case 5:n.label++,i=s[1],s=[0];continue;case 7:s=n.ops.pop(),n.trys.pop();continue;default:if((a=n.trys,!(a=a.length>0&&a[a.length-1]))&&(s[0]===6||s[0]===2)){n=0;continue}if(s[0]===3&&(!a||s[1]>a[0]&&s[1]<a[3])){n.label=s[1];break}if(s[0]===6&&n.label<a[1]){n.label=a[1],a=s;break}if(a&&n.label<a[2]){n.label=a[2],n.ops.push(s);break}a[2]&&n.ops.pop(),n.trys.pop();continue}s=t.call(e,n)}catch(e){s=[6,e],i=0}finally{r=a=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}}function Po(e,t){for(var n in e)n!=="default"&&!Object.prototype.hasOwnProperty.call(t,n)&&ts(t,e,n)}function Fo(e){var t=typeof Symbol==`function`&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length==`number`)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw TypeError(t?`Object is not iterable.`:`Symbol.iterator is not defined.`)}function Io(e,t){var n=typeof Symbol==`function`&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),i,a=[],o;try{for(;(t===void 0||t-->0)&&!(i=r.next()).done;)a.push(i.value)}catch(e){o={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a}function Lo(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(Io(arguments[t]));return e}function Ro(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;for(var r=Array(e),i=0,t=0;t<n;t++)for(var a=arguments[t],o=0,s=a.length;o<s;o++,i++)r[i]=a[o];return r}function zo(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}function Bo(e){return this instanceof Bo?(this.v=e,this):new Bo(e)}function Vo(e,t,n){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var r=n.apply(e,t||[]),i,a=[];return i=Object.create((typeof AsyncIterator==`function`?AsyncIterator:Object).prototype),s(`next`),s(`throw`),s(`return`,o),i[Symbol.asyncIterator]=function(){return this},i;function o(e){return function(t){return Promise.resolve(t).then(e,d)}}function s(e,t){r[e]&&(i[e]=function(t){return new Promise(function(n,r){a.push([e,t,n,r])>1||c(e,t)})},t&&(i[e]=t(i[e])))}function c(e,t){try{l(r[e](t))}catch(e){f(a[0][3],e)}}function l(e){e.value instanceof Bo?Promise.resolve(e.value.v).then(u,d):f(a[0][2],e)}function u(e){c(`next`,e)}function d(e){c(`throw`,e)}function f(e,t){e(t),a.shift(),a.length&&c(a[0][0],a[0][1])}}function Ho(e){var t,n;return t={},r(`next`),r(`throw`,function(e){throw e}),r(`return`),t[Symbol.iterator]=function(){return this},t;function r(r,i){t[r]=e[r]?function(t){return(n=!n)?{value:Bo(e[r](t)),done:!1}:i?i(t):t}:i}}function Uo(e){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof Fo==`function`?Fo(e):e[Symbol.iterator](),n={},r(`next`),r(`throw`),r(`return`),n[Symbol.asyncIterator]=function(){return this},n);function r(t){n[t]=e[t]&&function(n){return new Promise(function(r,a){n=e[t](n),i(r,a,n.done,n.value)})}}function i(e,t,n,r){Promise.resolve(r).then(function(t){e({value:t,done:n})},t)}}function Wo(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}function Go(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n=rs(e),r=0;r<n.length;r++)n[r]!=="default"&&ts(t,e,n[r]);return ns(t,e),t}function Ko(e){return e&&e.__esModule?e:{default:e}}function qo(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)}function Jo(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n}function Yo(e,t){if(t===null||typeof t!=`object`&&typeof t!=`function`)throw TypeError(`Cannot use 'in' operator on non-object`);return typeof e==`function`?t===e:e.has(t)}function Xo(e,t,n){if(t!=null){if(typeof t!=`object`&&typeof t!=`function`)throw TypeError(`Object expected.`);var r,i;if(n){if(!Symbol.asyncDispose)throw TypeError(`Symbol.asyncDispose is not defined.`);r=t[Symbol.asyncDispose]}if(r===void 0){if(!Symbol.dispose)throw TypeError(`Symbol.dispose is not defined.`);r=t[Symbol.dispose],n&&(i=r)}if(typeof r!=`function`)throw TypeError(`Object not disposable.`);i&&(r=function(){try{i.call(this)}catch(e){return Promise.reject(e)}}),e.stack.push({value:t,dispose:r,async:n})}else n&&e.stack.push({async:!0});return t}function Zo(e){function t(t){e.error=e.hasError?new is(t,e.error,`An error was suppressed during disposal.`):t,e.hasError=!0}var n,r=0;function i(){for(;n=e.stack.pop();)try{if(!n.async&&r===1)return r=0,e.stack.push(n),Promise.resolve().then(i);if(n.dispose){var a=n.dispose.call(n.value);if(n.async)return r|=2,Promise.resolve(a).then(i,function(e){return t(e),i()})}else r|=1}catch(e){t(e)}if(r===1)return e.hasError?Promise.reject(e.error):Promise.resolve();if(e.hasError)throw e.error}return i()}function Qo(e,t){return typeof e==`string`&&/^\.\.?\//.test(e)?e.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(e,n,r,i,a){return n?t?`.jsx`:`.js`:r&&(!i||!a)?e:r+i+`.`+a.toLowerCase()+`js`}):e}var $o,es,ts,ns,rs,is,as,X=M((()=>{$o=function(e,t){return $o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},$o(e,t)},es=function(){return es=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},es.apply(this,arguments)},ts=Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]}),ns=Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t},rs=function(e){return rs=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},rs(e)},is=typeof SuppressedError==`function`?SuppressedError:function(e,t,n){var r=Error(n);return r.name=`SuppressedError`,r.error=e,r.suppressed=t,r},as={__extends:Co,__assign:es,__rest:wo,__decorate:To,__param:Eo,__esDecorate:Do,__runInitializers:Oo,__propKey:ko,__setFunctionName:Ao,__metadata:jo,__awaiter:Mo,__generator:No,__createBinding:ts,__exportStar:Po,__values:Fo,__read:Io,__spread:Lo,__spreadArrays:Ro,__spreadArray:zo,__await:Bo,__asyncGenerator:Vo,__asyncDelegator:Ho,__asyncValues:Uo,__makeTemplateObject:Wo,__importStar:Go,__importDefault:Ko,__classPrivateFieldGet:qo,__classPrivateFieldSet:Jo,__classPrivateFieldIn:Yo,__addDisposableResource:Xo,__disposeResources:Zo,__rewriteRelativeImportExtension:Qo}})),os=N((e=>{
291
- /*!
292
- * MIT License
293
- *
294
- * Copyright (c) 2017-2024 Peculiar Ventures, LLC
295
- *
296
- * Permission is hereby granted, free of charge, to any person obtaining a copy
297
- * of this software and associated documentation files (the "Software"), to deal
298
- * in the Software without restriction, including without limitation the rights
299
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
300
- * copies of the Software, and to permit persons to whom the Software is
301
- * furnished to do so, subject to the following conditions:
302
- *
303
- * The above copyright notice and this permission notice shall be included in all
304
- * copies or substantial portions of the Software.
305
- *
306
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
307
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
308
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
309
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
310
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
311
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
312
- * SOFTWARE.
313
- *
314
- */
315
- var t=class e{static isArrayBuffer(e){return Object.prototype.toString.call(e)===`[object ArrayBuffer]`}static toArrayBuffer(e){return this.isArrayBuffer(e)?e:e.byteLength===e.buffer.byteLength||e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e.buffer:this.toUint8Array(e.buffer).slice(e.byteOffset,e.byteOffset+e.byteLength).buffer}static toUint8Array(e){return this.toView(e,Uint8Array)}static toView(e,t){if(e.constructor===t)return e;if(this.isArrayBuffer(e))return new t(e);if(this.isArrayBufferView(e))return new t(e.buffer,e.byteOffset,e.byteLength);throw TypeError(`The provided value is not of type '(ArrayBuffer or ArrayBufferView)'`)}static isBufferSource(e){return this.isArrayBufferView(e)||this.isArrayBuffer(e)}static isArrayBufferView(e){return ArrayBuffer.isView(e)||e&&this.isArrayBuffer(e.buffer)}static isEqual(t,n){let r=e.toUint8Array(t),i=e.toUint8Array(n);if(r.length!==i.byteLength)return!1;for(let e=0;e<r.length;e++)if(r[e]!==i[e])return!1;return!0}static concat(...e){let t;t=Array.isArray(e[0])&&!(e[1]instanceof Function)||Array.isArray(e[0])&&e[1]instanceof Function?e[0]:e[e.length-1]instanceof Function?e.slice(0,e.length-1):e;let n=0;for(let e of t)n+=e.byteLength;let r=new Uint8Array(n),i=0;for(let e of t){let t=this.toUint8Array(e);r.set(t,i),i+=t.length}return e[e.length-1]instanceof Function?this.toView(r,e[e.length-1]):r.buffer}};let n=`string`,r=/^[0-9a-f\s]+$/i,i=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,a=/^[a-zA-Z0-9-_]+$/;var o=class{static fromString(e){let t=unescape(encodeURIComponent(e)),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n.buffer}static toString(e){let n=t.toUint8Array(e),r=``;for(let e=0;e<n.length;e++)r+=String.fromCharCode(n[e]);return decodeURIComponent(escape(r))}},s=class{static toString(e,n=!1){let r=t.toArrayBuffer(e),i=new DataView(r),a=``;for(let e=0;e<r.byteLength;e+=2){let t=i.getUint16(e,n);a+=String.fromCharCode(t)}return a}static fromString(e,t=!1){let n=new ArrayBuffer(e.length*2),r=new DataView(n);for(let n=0;n<e.length;n++)r.setUint16(n*2,e.charCodeAt(n),t);return n}},c=class e{static isHex(e){return typeof e==n&&r.test(e)}static isBase64(e){return typeof e==n&&i.test(e)}static isBase64Url(e){return typeof e==n&&a.test(e)}static ToString(e,n=`utf8`){let r=t.toUint8Array(e);switch(n.toLowerCase()){case`utf8`:return this.ToUtf8String(r);case`binary`:return this.ToBinary(r);case`hex`:return this.ToHex(r);case`base64`:return this.ToBase64(r);case`base64url`:return this.ToBase64Url(r);case`utf16le`:return s.toString(r,!0);case`utf16`:case`utf16be`:return s.toString(r);default:throw Error(`Unknown type of encoding '${n}'`)}}static FromString(e,t=`utf8`){if(!e)return new ArrayBuffer(0);switch(t.toLowerCase()){case`utf8`:return this.FromUtf8String(e);case`binary`:return this.FromBinary(e);case`hex`:return this.FromHex(e);case`base64`:return this.FromBase64(e);case`base64url`:return this.FromBase64Url(e);case`utf16le`:return s.fromString(e,!0);case`utf16`:case`utf16be`:return s.fromString(e);default:throw Error(`Unknown type of encoding '${t}'`)}}static ToBase64(e){let n=t.toUint8Array(e);if(typeof btoa<`u`){let e=this.ToString(n,`binary`);return btoa(e)}else return Buffer.from(n).toString(`base64`)}static FromBase64(t){let n=this.formatString(t);if(!n)return new ArrayBuffer(0);if(!e.isBase64(n))throw TypeError(`Argument 'base64Text' is not Base64 encoded`);return typeof atob<`u`?this.FromBinary(atob(n)):new Uint8Array(Buffer.from(n,`base64`)).buffer}static FromBase64Url(t){let n=this.formatString(t);if(!n)return new ArrayBuffer(0);if(!e.isBase64Url(n))throw TypeError(`Argument 'base64url' is not Base64Url encoded`);return this.FromBase64(this.Base64Padding(n.replace(/\-/g,`+`).replace(/\_/g,`/`)))}static ToBase64Url(e){return this.ToBase64(e).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/\=/g,``)}static FromUtf8String(t,n=e.DEFAULT_UTF8_ENCODING){switch(n){case`ascii`:return this.FromBinary(t);case`utf8`:return o.fromString(t);case`utf16`:case`utf16be`:return s.fromString(t);case`utf16le`:case`usc2`:return s.fromString(t,!0);default:throw Error(`Unknown type of encoding '${n}'`)}}static ToUtf8String(t,n=e.DEFAULT_UTF8_ENCODING){switch(n){case`ascii`:return this.ToBinary(t);case`utf8`:return o.toString(t);case`utf16`:case`utf16be`:return s.toString(t);case`utf16le`:case`usc2`:return s.toString(t,!0);default:throw Error(`Unknown type of encoding '${n}'`)}}static FromBinary(e){let t=e.length,n=new Uint8Array(t);for(let r=0;r<t;r++)n[r]=e.charCodeAt(r);return n.buffer}static ToBinary(e){let n=t.toUint8Array(e),r=``;for(let e=0;e<n.length;e++)r+=String.fromCharCode(n[e]);return r}static ToHex(e){let n=t.toUint8Array(e),r=``,i=n.length;for(let e=0;e<i;e++){let t=n[e];t<16&&(r+=`0`),r+=t.toString(16)}return r}static FromHex(t){let n=this.formatString(t);if(!n)return new ArrayBuffer(0);if(!e.isHex(n))throw TypeError(`Argument 'hexString' is not HEX encoded`);n.length%2&&(n=`0${n}`);let r=new Uint8Array(n.length/2);for(let e=0;e<n.length;e+=2){let t=n.slice(e,e+2);r[e/2]=parseInt(t,16)}return r.buffer}static ToUtf16String(e,t=!1){return s.toString(e,t)}static FromUtf16String(e,t=!1){return s.fromString(e,t)}static Base64Padding(e){let t=4-e.length%4;if(t<4)for(let n=0;n<t;n++)e+=`=`;return e}static formatString(e){return e?.replace(/[\n\r\t ]/g,``)||``}};c.DEFAULT_UTF8_ENCODING=`utf8`;function l(e,...t){let n=arguments[0];for(let e=1;e<arguments.length;e++){let t=arguments[e];for(let e in t)n[e]=t[e]}return n}function u(...e){let t=e.map(e=>e.byteLength).reduce((e,t)=>e+t),n=new Uint8Array(t),r=0;return e.map(e=>new Uint8Array(e)).forEach(e=>{for(let t of e)n[r++]=t}),n.buffer}function d(e,t){if(!(e&&t)||e.byteLength!==t.byteLength)return!1;let n=new Uint8Array(e),r=new Uint8Array(t);for(let t=0;t<e.byteLength;t++)if(n[t]!==r[t])return!1;return!0}e.BufferSourceConverter=t,e.Convert=c,e.assign=l,e.combine=u,e.isEqual=d})),ss=N((e=>{
316
- /*!
317
- Copyright (c) Peculiar Ventures, LLC
318
- */
319
- Object.defineProperty(e,"__esModule",{value:!0});function t(e){return new Date(e.getTime()+e.getTimezoneOffset()*6e4)}function n(e,t,n){return e instanceof Object?e[t]??n:n}function r(e,t=0,n=e.byteLength-t,r=!1){let i=``;for(let a of new Uint8Array(e,t,n)){let e=a.toString(16).toUpperCase();e.length===1&&(i+=`0`),i+=e,r&&(i+=` `)}return i.trim()}function i(e,t,n,r){return t instanceof ArrayBuffer?t.byteLength?n<0?(e.error=`Wrong parameter: inputOffset less than zero`,!1):r<0?(e.error=`Wrong parameter: inputLength less than zero`,!1):t.byteLength-n-r<0?(e.error=`End of input reached before message was fully decoded (inconsistent offset and length values)`,!1):!0:(e.error=`Wrong parameter: inputBuffer has zero length`,!1):(e.error=`Wrong parameter: inputBuffer must be "ArrayBuffer"`,!1)}function a(e,t){let n=0;if(e.length===1)return e[0];for(let r=e.length-1;r>=0;r--)n+=e[e.length-1-r]*2**(t*r);return n}function o(e,t,n=-1){let r=n,i=e,a=0,o=2**t;for(let n=1;n<8;n++){if(e<o){let e;if(r<0)e=new ArrayBuffer(n),a=n;else{if(r<n)return new ArrayBuffer(0);e=new ArrayBuffer(r),a=r}let o=new Uint8Array(e);for(let e=n-1;e>=0;e--){let n=2**(e*t);o[a-e-1]=Math.floor(i/n),i-=o[a-e-1]*n}return e}o*=2**t}return new ArrayBuffer(0)}function s(...e){let t=0,n=0;for(let n of e)t+=n.byteLength;let r=new ArrayBuffer(t),i=new Uint8Array(r);for(let t of e)i.set(new Uint8Array(t),n),n+=t.byteLength;return r}function c(...e){let t=0,n=0;for(let n of e)t+=n.length;let r=new ArrayBuffer(t),i=new Uint8Array(r);for(let t of e)i.set(t,n),n+=t.length;return i}function l(){let e=new Uint8Array(this.valueHex);if(this.valueHex.byteLength>=2){let t=e[0]===255&&e[1]&128,n=e[0]===0&&(e[1]&128)==0;(t||n)&&this.warnings.push(`Needlessly long format`)}let t=new ArrayBuffer(this.valueHex.byteLength),n=new Uint8Array(t);for(let e=0;e<this.valueHex.byteLength;e++)n[e]=0;n[0]=e[0]&128;let r=a(n,8),i=new ArrayBuffer(this.valueHex.byteLength),o=new Uint8Array(i);for(let t=0;t<this.valueHex.byteLength;t++)o[t]=e[t];return o[0]&=127,a(o,8)-r}function u(e){let t=e<0?e*-1:e,n=128;for(let r=1;r<8;r++){if(t<=n){if(e<0){let e=o(n-t,8,r),i=new Uint8Array(e);return i[0]|=128,e}let i=o(t,8,r),a=new Uint8Array(i);if(a[0]&128){let e=i.slice(0),t=new Uint8Array(e);i=new ArrayBuffer(i.byteLength+1),a=new Uint8Array(i);for(let n=0;n<e.byteLength;n++)a[n+1]=t[n];a[0]=0}return i}n*=2**8}return new ArrayBuffer(0)}function d(e,t){if(e.byteLength!==t.byteLength)return!1;let n=new Uint8Array(e),r=new Uint8Array(t);for(let e=0;e<n.length;e++)if(n[e]!==r[e])return!1;return!0}function f(e,t){let n=e.toString(10);if(t<n.length)return``;let r=t-n.length,i=Array(r);for(let e=0;e<r;e++)i[e]=`0`;return i.join(``).concat(n)}let p=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=`,m=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=`;function h(e,t=!1,n=!1,r=!1){let i=0,a=0,o=0,s=``,c=t?m:p;if(r){let t=0;for(let n=0;n<e.length;n++)if(e.charCodeAt(n)!==0){t=n;break}e=e.slice(t)}for(;i<e.length;){let t=e.charCodeAt(i++);i>=e.length&&(a=1);let r=e.charCodeAt(i++);i>=e.length&&(o=1);let l=e.charCodeAt(i++),u=t>>2,d=(t&3)<<4|r>>4,f=(r&15)<<2|l>>6,p=l&63;a===1?f=p=64:o===1&&(p=64),n?f===64?s+=`${c.charAt(u)}${c.charAt(d)}`:p===64?s+=`${c.charAt(u)}${c.charAt(d)}${c.charAt(f)}`:s+=`${c.charAt(u)}${c.charAt(d)}${c.charAt(f)}${c.charAt(p)}`:s+=`${c.charAt(u)}${c.charAt(d)}${c.charAt(f)}${c.charAt(p)}`}return s}function g(e,t=!1,n=!1){let r=t?m:p;function i(e){for(let t=0;t<64;t++)if(r.charAt(t)===e)return t;return 64}function a(e){return e===64?0:e}let o=0,s=``;for(;o<e.length;){let t=i(e.charAt(o++)),n=o>=e.length?0:i(e.charAt(o++)),r=o>=e.length?0:i(e.charAt(o++)),c=o>=e.length?0:i(e.charAt(o++)),l=a(t)<<2|a(n)>>4,u=(a(n)&15)<<4|a(r)>>2,d=(a(r)&3)<<6|a(c);s+=String.fromCharCode(l),r!==64&&(s+=String.fromCharCode(u)),c!==64&&(s+=String.fromCharCode(d))}if(n){let e=s.length,t=-1;for(let n=e-1;n>=0;n--)if(s.charCodeAt(n)!==0){t=n;break}s=t===-1?``:s.slice(0,t+1)}return s}function _(e){let t=``,n=new Uint8Array(e);for(let e of n)t+=String.fromCharCode(e);return t}function v(e){let t=e.length,n=new ArrayBuffer(t),r=new Uint8Array(n);for(let n=0;n<t;n++)r[n]=e.charCodeAt(n);return n}let y=Math.log(2);function b(e){let t=Math.log(e)/y,n=Math.floor(t),r=Math.round(t);return n===r?n:r}function x(e,t){for(let n of t)delete e[n]}e.arrayBufferToString=_,e.bufferToHexCodes=r,e.checkBufferParams=i,e.clearProps=x,e.fromBase64=g,e.getParametersValue=n,e.getUTCDate=t,e.isEqualBuffer=d,e.nearestPowerOf2=b,e.padNumber=f,e.stringToArrayBuffer=v,e.toBase64=h,e.utilConcatBuf=s,e.utilConcatView=c,e.utilDecodeTC=l,e.utilEncodeTC=u,e.utilFromBase=a,e.utilToBase=o})),cs=N((e=>{
320
- /*!
321
- * Copyright (c) 2014, GMO GlobalSign
322
- * Copyright (c) 2015-2022, Peculiar Ventures
323
- * All rights reserved.
324
- *
325
- * Author 2014-2019, Yury Strozhevsky
326
- *
327
- * Redistribution and use in source and binary forms, with or without modification,
328
- * are permitted provided that the following conditions are met:
329
- *
330
- * * Redistributions of source code must retain the above copyright notice, this
331
- * list of conditions and the following disclaimer.
332
- *
333
- * * Redistributions in binary form must reproduce the above copyright notice, this
334
- * list of conditions and the following disclaimer in the documentation and/or
335
- * other materials provided with the distribution.
336
- *
337
- * * Neither the name of the copyright holder nor the names of its
338
- * contributors may be used to endorse or promote products derived from
339
- * this software without specific prior written permission.
340
- *
341
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
342
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
343
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
344
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
345
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
346
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
347
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
348
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
349
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
350
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
351
- *
352
- */
353
- var t=os(),n=ss();function r(e){var t=Object.create(null);return e&&Object.keys(e).forEach(function(n){if(n!=="default"){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}}),t.default=e,Object.freeze(t)}var i=r(t),a=r(n);function o(){if(typeof BigInt>`u`)throw Error(`BigInt is not defined. Your environment doesn't implement BigInt.`)}function s(e){let t=0,n=0;for(let n=0;n<e.length;n++){let r=e[n];t+=r.byteLength}let r=new Uint8Array(t);for(let t=0;t<e.length;t++){let i=e[t];r.set(new Uint8Array(i),n),n+=i.byteLength}return r.buffer}function c(e,t,n,r){return t instanceof Uint8Array?t.byteLength?n<0?(e.error=`Wrong parameter: inputOffset less than zero`,!1):r<0?(e.error=`Wrong parameter: inputLength less than zero`,!1):t.byteLength-n-r<0?(e.error=`End of input reached before message was fully decoded (inconsistent offset and length values)`,!1):!0:(e.error=`Wrong parameter: inputBuffer has zero length`,!1):(e.error=`Wrong parameter: inputBuffer must be 'Uint8Array'`,!1)}var l=class{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return s(this.items)}};let u=[new Uint8Array([1])],d=`0123456789`,f=`name`,p=`valueHexView`,m=new ArrayBuffer(0),h=new Uint8Array,g=`EndOfContent`,_=`OCTET STRING`,v=`BIT STRING`;function y(e){var t;return t=class extends e{get valueHex(){return this.valueHexView.slice().buffer}set valueHex(e){this.valueHexView=new Uint8Array(e)}constructor(...e){super(...e);let t=e[0]||{};this.isHexOnly=t.isHexOnly??!1,this.valueHexView=t.valueHex?i.BufferSourceConverter.toUint8Array(t.valueHex):h}fromBER(e,t,n,r){let i=e instanceof ArrayBuffer?new Uint8Array(e):e;if(!c(this,i,t,n))return-1;let a=t+n;return this.valueHexView=i.subarray(t,a),this.valueHexView.length?(this.blockLength=n,a):(this.warnings.push(`Zero buffer length`),t)}toBER(e=!1){return this.isHexOnly?e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.byteLength===this.valueHexView.buffer.byteLength?this.valueHexView.buffer:this.valueHexView.slice().buffer:(this.error=`Flag 'isHexOnly' is not set, abort`,m)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:i.Convert.ToHex(this.valueHexView)}}},t.NAME=`hexBlock`,t}var b=class{static blockName(){return this.NAME}get valueBeforeDecode(){return this.valueBeforeDecodeView.slice().buffer}set valueBeforeDecode(e){this.valueBeforeDecodeView=new Uint8Array(e)}constructor({blockLength:e=0,error:t=``,warnings:n=[],valueBeforeDecode:r=h}={}){this.blockLength=e,this.error=t,this.warnings=n,this.valueBeforeDecodeView=i.BufferSourceConverter.toUint8Array(r)}toJSON(){return{blockName:this.constructor.NAME,blockLength:this.blockLength,error:this.error,warnings:this.warnings,valueBeforeDecode:i.Convert.ToHex(this.valueBeforeDecodeView)}}};b.NAME=`baseBlock`;var x=class extends b{fromBER(e,t,n,r){throw TypeError(`User need to make a specific function in a class which extends 'ValueBlock'`)}toBER(e,t){throw TypeError(`User need to make a specific function in a class which extends 'ValueBlock'`)}};x.NAME=`valueBlock`;var S=class extends y(b){constructor({idBlock:e={}}={}){super(),e?(this.isHexOnly=e.isHexOnly??!1,this.valueHexView=e.valueHex?i.BufferSourceConverter.toUint8Array(e.valueHex):h,this.tagClass=e.tagClass??-1,this.tagNumber=e.tagNumber??-1,this.isConstructed=e.isConstructed??!1):(this.tagClass=-1,this.tagNumber=-1,this.isConstructed=!1)}toBER(e=!1){let t=0;switch(this.tagClass){case 1:t|=0;break;case 2:t|=64;break;case 3:t|=128;break;case 4:t|=192;break;default:return this.error=`Unknown tag class`,m}if(this.isConstructed&&(t|=32),this.tagNumber<31&&!this.isHexOnly){let n=new Uint8Array(1);if(!e){let e=this.tagNumber;e&=31,t|=e,n[0]=t}return n.buffer}if(!this.isHexOnly){let n=a.utilToBase(this.tagNumber,7),r=new Uint8Array(n),i=n.byteLength,o=new Uint8Array(i+1);if(o[0]=t|31,!e){for(let e=0;e<i-1;e++)o[e+1]=r[e]|128;o[i]=r[i-1]}return o.buffer}let n=new Uint8Array(this.valueHexView.byteLength+1);if(n[0]=t|31,!e){let e=this.valueHexView;for(let t=0;t<e.length-1;t++)n[t+1]=e[t]|128;n[this.valueHexView.byteLength]=e[e.length-1]}return n.buffer}fromBER(e,t,n){let r=i.BufferSourceConverter.toUint8Array(e);if(!c(this,r,t,n))return-1;let o=r.subarray(t,t+n);if(o.length===0)return this.error=`Zero buffer length`,-1;switch(o[0]&192){case 0:this.tagClass=1;break;case 64:this.tagClass=2;break;case 128:this.tagClass=3;break;case 192:this.tagClass=4;break;default:return this.error=`Unknown tag class`,-1}this.isConstructed=(o[0]&32)==32,this.isHexOnly=!1;let s=o[0]&31;if(s!==31)this.tagNumber=s,this.blockLength=1;else{let e=0;for(;;){let t=e+1;if(t>=o.length)return this.error=`End of input reached before message was fully decoded`,-1;if(e++,!(o[t]&128))break}this.blockLength=e+1;let t=this.valueHexView=new Uint8Array(e);for(let n=0;n<e;n++)t[n]=o[n+1]&127;this.blockLength<=9?this.tagNumber=a.utilFromBase(t,7):(this.isHexOnly=!0,this.warnings.push(`Tag too long, represented as hex-coded`))}if(this.tagClass===1&&this.isConstructed)switch(this.tagNumber){case 1:case 2:case 5:case 6:case 9:case 13:case 14:case 23:case 24:case 31:case 32:case 33:case 34:return this.error=`Constructed encoding used for primitive type`,-1}return t+this.blockLength}toJSON(){return{...super.toJSON(),tagClass:this.tagClass,tagNumber:this.tagNumber,isConstructed:this.isConstructed}}};S.NAME=`identificationBlock`;var C=class extends b{constructor({lenBlock:e={}}={}){super(),this.isIndefiniteForm=e.isIndefiniteForm??!1,this.longFormUsed=e.longFormUsed??!1,this.length=e.length??0}fromBER(e,t,n){let r=i.BufferSourceConverter.toUint8Array(e);if(!c(this,r,t,n))return-1;let o=r.subarray(t,t+n);if(o.length===0)return this.error=`Zero buffer length`,-1;if(o[0]===255)return this.error=`Length block 0xFF is reserved by standard`,-1;if(this.isIndefiniteForm=o[0]===128,this.isIndefiniteForm)return this.blockLength=1,t+this.blockLength;if(this.longFormUsed=!!(o[0]&128),this.longFormUsed===!1)return this.length=o[0],this.blockLength=1,t+this.blockLength;let s=o[0]&127;if(s>8)return this.error=`Too big integer`,-1;if(s+1>o.length)return this.error=`End of input reached before message was fully decoded`,-1;let l=t+1,u=r.subarray(l,l+s);return u[s-1]===0&&this.warnings.push(`Needlessly long encoded length`),this.length=a.utilFromBase(u,8),this.longFormUsed&&this.length<=127&&this.warnings.push(`Unnecessary usage of long length form`),this.blockLength=s+1,t+this.blockLength}toBER(e=!1){let t,n;if(this.length>127&&(this.longFormUsed=!0),this.isIndefiniteForm)return t=new ArrayBuffer(1),e===!1&&(n=new Uint8Array(t),n[0]=128),t;if(this.longFormUsed){let r=a.utilToBase(this.length,8);if(r.byteLength>127)return this.error=`Too big length`,m;if(t=new ArrayBuffer(r.byteLength+1),e)return t;let i=new Uint8Array(r);n=new Uint8Array(t),n[0]=r.byteLength|128;for(let e=0;e<r.byteLength;e++)n[e+1]=i[e];return t}return t=new ArrayBuffer(1),e===!1&&(n=new Uint8Array(t),n[0]=this.length),t}toJSON(){return{...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,longFormUsed:this.longFormUsed,length:this.length}}};C.NAME=`lengthBlock`;let w={};var T=class extends b{constructor({name:e=``,optional:t=!1,primitiveSchema:n,...r}={},i){super(r),this.name=e,this.optional=t,n&&(this.primitiveSchema=n),this.idBlock=new S(r),this.lenBlock=new C(r),this.valueBlock=i?new i(r):new x(r)}fromBER(e,t,n,r){let i=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length,r);return i===-1?(this.error=this.valueBlock.error,i):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),i)}toBER(e,t){let n=t||new l;t||E(this);let r=this.idBlock.toBER(e);if(n.write(r),this.lenBlock.isIndefiniteForm)n.write(new Uint8Array([128]).buffer),this.valueBlock.toBER(e,n),n.write(new ArrayBuffer(2));else{let t=this.valueBlock.toBER(e);this.lenBlock.length=t.byteLength;let r=this.lenBlock.toBER(e);n.write(r),n.write(t)}return t?m:n.final()}toJSON(){let e={...super.toJSON(),idBlock:this.idBlock.toJSON(),lenBlock:this.lenBlock.toJSON(),valueBlock:this.valueBlock.toJSON(),name:this.name,optional:this.optional};return this.primitiveSchema&&(e.primitiveSchema=this.primitiveSchema.toJSON()),e}toString(e=`ascii`){return e===`ascii`?this.onAsciiEncoding():i.Convert.ToHex(this.toBER())}onAsciiEncoding(){return`${this.constructor.NAME} : ${i.Convert.ToHex(this.valueBlock.valueBeforeDecodeView)}`}isEqual(e){if(this===e)return!0;if(!(e instanceof this.constructor))return!1;let t=this.toBER(),n=e.toBER();return a.isEqualBuffer(t,n)}};T.NAME=`BaseBlock`;function E(e){if(e instanceof w.Constructed)for(let t of e.valueBlock.value)E(t)&&(e.lenBlock.isIndefiniteForm=!0);return!!e.lenBlock?.isIndefiniteForm}var D=class extends T{getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}constructor({value:e=``,...t}={},n){super(t,n),e&&this.fromString(e)}fromBER(e,t,n){let r=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return r===-1?(this.error=this.valueBlock.error,r):(this.fromBuffer(this.valueBlock.valueHexView),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),r)}onAsciiEncoding(){return`${this.constructor.NAME} : '${this.valueBlock.value}'`}};D.NAME=`BaseStringBlock`;var O=class extends y(x){constructor({isHexOnly:e=!0,...t}={}){super(t),this.isHexOnly=e}};O.NAME=`PrimitiveValueBlock`;var k,A=class extends T{constructor(e={}){super(e,O),this.idBlock.isConstructed=!1}};k=A,w.Primitive=k,A.NAME=`PRIMITIVE`;let ee=1e4,j=16*1024*1024;function M(e={}){return{depth:0,maxDepth:e.maxDepth??100,nodesCount:0,maxNodes:e.maxNodes??ee,maxContentLength:e.maxContentLength??j}}function N(e){let t=new T({},x);return t.error=e,{offset:-1,result:t}}function te(e){if(e.nodesCount+=1,e.nodesCount>e.maxNodes)return`Maximum ASN.1 node count exceeded`}function ne(e,t){if(e>t.maxContentLength)return`Maximum ASN.1 content length exceeded`}function P(e,t,n,r){let i=r.depth+1;if(i>r.maxDepth)return N(`Maximum ASN.1 nesting depth exceeded`);r.depth=i;try{return re(e,t,n,r)}finally{--r.depth}}function F(e,t){if(e instanceof t)return e;let n=new t;return n.idBlock=e.idBlock,n.lenBlock=e.lenBlock,n.warnings=e.warnings,n.valueBeforeDecodeView=e.valueBeforeDecodeView,n}function re(e,t=0,n=e.length,r=M()){let i=t,a=new T({},x),o=new b;if(!c(o,e,t,n))return a.error=o.error,{offset:-1,result:a};if(!e.subarray(t,t+n).length)return a.error=`Zero buffer length`,{offset:-1,result:a};let s=te(r);if(s)return a.error=s,{offset:-1,result:a};let l=a.idBlock.fromBER(e,t,n);if(a.idBlock.warnings.length&&a.warnings.concat(a.idBlock.warnings),l===-1)return a.error=a.idBlock.error,{offset:-1,result:a};if(t=l,n-=a.idBlock.blockLength,l=a.lenBlock.fromBER(e,t,n),a.lenBlock.warnings.length&&a.warnings.concat(a.lenBlock.warnings),l===-1)return a.error=a.lenBlock.error,{offset:-1,result:a};t=l,n-=a.lenBlock.blockLength;let u=a.lenBlock.isIndefiniteForm?n:a.lenBlock.length,d=ne(u,r);if(d)return a.error=d,{offset:-1,result:a};if(!a.idBlock.isConstructed&&a.lenBlock.isIndefiniteForm)return a.error=`Indefinite length form used for primitive encoding form`,{offset:-1,result:a};let f=T;switch(a.idBlock.tagClass){case 1:if(a.idBlock.tagNumber>=37&&a.idBlock.isHexOnly===!1)return a.error=`UNIVERSAL 37 and upper tags are reserved by ASN.1 standard`,{offset:-1,result:a};switch(a.idBlock.tagNumber){case 0:if(a.idBlock.isConstructed&&a.lenBlock.length>0)return a.error=`Type [UNIVERSAL 0] is reserved`,{offset:-1,result:a};f=w.EndOfContent;break;case 1:f=w.Boolean;break;case 2:f=w.Integer;break;case 3:f=w.BitString;break;case 4:f=w.OctetString;break;case 5:f=w.Null;break;case 6:f=w.ObjectIdentifier;break;case 10:f=w.Enumerated;break;case 12:f=w.Utf8String;break;case 13:f=w.RelativeObjectIdentifier;break;case 14:f=w.TIME;break;case 15:return a.error=`[UNIVERSAL 15] is reserved by ASN.1 standard`,{offset:-1,result:a};case 16:f=w.Sequence;break;case 17:f=w.Set;break;case 18:f=w.NumericString;break;case 19:f=w.PrintableString;break;case 20:f=w.TeletexString;break;case 21:f=w.VideotexString;break;case 22:f=w.IA5String;break;case 23:f=w.UTCTime;break;case 24:f=w.GeneralizedTime;break;case 25:f=w.GraphicString;break;case 26:f=w.VisibleString;break;case 27:f=w.GeneralString;break;case 28:f=w.UniversalString;break;case 29:f=w.CharacterString;break;case 30:f=w.BmpString;break;case 31:f=w.DATE;break;case 32:f=w.TimeOfDay;break;case 33:f=w.DateTime;break;case 34:f=w.Duration;break;default:{let e=a.idBlock.isConstructed?new w.Constructed:new w.Primitive;e.idBlock=a.idBlock,e.lenBlock=a.lenBlock,e.warnings=a.warnings,a=e}}break;default:f=a.idBlock.isConstructed?w.Constructed:w.Primitive}return a=F(a,f),l=a.fromBER(e,t,u,r),a.valueBeforeDecodeView=e.subarray(i,i+a.blockLength),{offset:l,result:a}}function I(e,t={}){if(!e.byteLength){let e=new T({},x);return e.error=`Input buffer has zero length`,{offset:-1,result:e}}return re(i.BufferSourceConverter.toUint8Array(e).slice(),0,e.byteLength,M(t))}function ie(e,t){return e?1:t}var ae=class extends x{constructor({value:e=[],isIndefiniteForm:t=!1,...n}={}){super(n),this.value=e,this.isIndefiniteForm=t}fromBER(e,t,n,r){let a=i.BufferSourceConverter.toUint8Array(e),o=r??M();if(!c(this,a,t,n))return-1;if(this.valueBeforeDecodeView=a.subarray(t,t+n),this.valueBeforeDecodeView.length===0)return this.warnings.push(`Zero buffer length`),t;let s=t;for(;ie(this.isIndefiniteForm,n)>0;){let e=P(a,s,n,o);if(e.offset===-1)return this.error=e.result.error,this.warnings.concat(e.result.warnings),-1;if(s=e.offset,this.blockLength+=e.result.blockLength,n-=e.result.blockLength,this.value.push(e.result),this.isIndefiniteForm&&e.result.constructor.NAME===g)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===g?this.value.pop():this.warnings.push(`No EndOfContent block encoded`)),s}toBER(e,t){let n=t||new l;for(let t=0;t<this.value.length;t++)this.value[t].toBER(e,n);return t?m:n.final()}toJSON(){let e={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(let t of this.value)e.value.push(t.toJSON());return e}};ae.NAME=`ConstructedValueBlock`;var oe,se=class extends T{constructor(e={}){super(e,ae),this.idBlock.isConstructed=!0}fromBER(e,t,n,r){this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm;let i=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length,r);return i===-1?(this.error=this.valueBlock.error,i):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),i)}onAsciiEncoding(){let e=[];for(let t of this.valueBlock.value)e.push(t.toString(`ascii`).split(`
354
- `).map(e=>` ${e}`).join(`
355
- `));let t=this.idBlock.tagClass===3?`[${this.idBlock.tagNumber}]`:this.constructor.NAME;return e.length?`${t} :\n${e.join(`
356
- `)}`:`${t} :`}};oe=se,w.Constructed=oe,se.NAME=`CONSTRUCTED`;var ce=class extends x{fromBER(e,t,n){return t}toBER(e){return m}};ce.override=`EndOfContentValueBlock`;var le,ue=class extends T{constructor(e={}){super(e,ce),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}};le=ue,w.EndOfContent=le,ue.NAME=g;var de,fe=class extends T{constructor(e={}){super(e,x),this.idBlock.tagClass=1,this.idBlock.tagNumber=5}fromBER(e,t,n){return this.lenBlock.length>0&&this.warnings.push(`Non-zero length of value block for Null type`),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.blockLength+=n,t+n>e.byteLength?(this.error=`End of input reached before message was fully decoded (inconsistent offset and length values)`,-1):t+n}toBER(e,t){let n=new ArrayBuffer(2);if(!e){let e=new Uint8Array(n);e[0]=5,e[1]=0}return t&&t.write(n),n}onAsciiEncoding(){return`${this.constructor.NAME}`}};de=fe,w.Null=de,fe.NAME=`NULL`;var pe=class extends y(x){get value(){for(let e of this.valueHexView)if(e>0)return!0;return!1}set value(e){this.valueHexView[0]=e?255:0}constructor({value:e,...t}={}){super(t),t.valueHex?this.valueHexView=i.BufferSourceConverter.toUint8Array(t.valueHex):this.valueHexView=new Uint8Array(1),e&&(this.value=e)}fromBER(e,t,n){let r=i.BufferSourceConverter.toUint8Array(e);return c(this,r,t,n)?(this.valueHexView=r.subarray(t,t+n),n>1&&this.warnings.push(`Boolean value encoded in more then 1 octet`),this.isHexOnly=!0,a.utilDecodeTC.call(this),this.blockLength=n,t+n):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}};pe.NAME=`BooleanValueBlock`;var L,me=class extends T{getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}constructor(e={}){super(e,pe),this.idBlock.tagClass=1,this.idBlock.tagNumber=1}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.getValue}`}};L=me,w.Boolean=L,me.NAME=`BOOLEAN`;var he=class extends y(ae){constructor({isConstructed:e=!1,...t}={}){super(t),this.isConstructed=e}fromBER(e,t,n,r){let i=0;if(this.isConstructed){if(this.isHexOnly=!1,i=ae.prototype.fromBER.call(this,e,t,n,r),i===-1)return i;for(let e=0;e<this.value.length;e++){let t=this.value[e].constructor.NAME;if(t===g){if(this.isIndefiniteForm)break;return this.error=`EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only`,-1}if(t!==_)return this.error=`OCTET STRING may consists of OCTET STRINGs only`,-1}}else this.isHexOnly=!0,i=super.fromBER(e,t,n),this.blockLength=n;return i}toBER(e,t){return this.isConstructed?ae.prototype.toBER.call(this,e,t):e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}};he.NAME=`OctetStringValueBlock`;var R,ge=class extends T{constructor({idBlock:e={},lenBlock:t={},...n}={}){n.isConstructed??=!!n.value?.length,super({idBlock:{isConstructed:n.isConstructed,...e},lenBlock:{...t,isIndefiniteForm:!!n.isIndefiniteForm},...n},he),this.idBlock.tagClass=1,this.idBlock.tagNumber=4}fromBER(e,t,n,r){if(this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,n===0)return this.idBlock.error.length===0&&(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length===0&&(this.blockLength+=this.lenBlock.blockLength),t;if(!this.valueBlock.isConstructed){let i=(e instanceof ArrayBuffer?new Uint8Array(e):e).subarray(t,t+n);try{if(i.byteLength){let e=r??M(),t=P(i,0,i.byteLength,e);t.offset!==-1&&t.offset===n&&(this.valueBlock.value=[t.result])}}catch{}}return super.fromBER(e,t,n,r)}onAsciiEncoding(){return this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length?se.prototype.onAsciiEncoding.call(this):`${this.constructor.NAME} : ${i.Convert.ToHex(this.valueBlock.valueHexView)}`}getValue(){if(!this.idBlock.isConstructed)return this.valueBlock.valueHexView.slice().buffer;let e=[];for(let t of this.valueBlock.value)t instanceof R&&e.push(t.valueBlock.valueHexView);return i.BufferSourceConverter.concat(e)}};R=ge,w.OctetString=R,ge.NAME=_;var _e=class extends y(ae){constructor({unusedBits:e=0,isConstructed:t=!1,...n}={}){super(n),this.unusedBits=e,this.isConstructed=t,this.blockLength=this.valueHexView.byteLength}fromBER(e,t,n,r){if(!n)return t;let a=-1;if(this.isConstructed){if(a=ae.prototype.fromBER.call(this,e,t,n,r),a===-1)return a;for(let e of this.value){let t=e.constructor.NAME;if(t===g){if(this.isIndefiniteForm)break;return this.error=`EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only`,-1}if(t!==v)return this.error=`BIT STRING may consists of BIT STRINGs only`,-1;let n=e.valueBlock;if(this.unusedBits>0&&n.unusedBits>0)return this.error=`Using of "unused bits" inside constructive BIT STRING allowed for least one only`,-1;this.unusedBits=n.unusedBits}return a}let o=i.BufferSourceConverter.toUint8Array(e);if(!c(this,o,t,n))return-1;let s=o.subarray(t,t+n);if(this.unusedBits=s[0],this.unusedBits>7)return this.error=`Unused bits for BitString must be in range 0-7`,-1;if(!this.unusedBits){let e=s.subarray(1);try{if(e.byteLength){let t=r??M(),i=P(e,0,e.byteLength,t);i.offset!==-1&&i.offset===n-1&&(this.value=[i.result])}}catch{}}return this.valueHexView=s.subarray(1),this.blockLength=s.length,t+n}toBER(e,t){if(this.isConstructed)return ae.prototype.toBER.call(this,e,t);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength){let e=new Uint8Array(1);return e[0]=0,e.buffer}let n=new Uint8Array(this.valueHexView.length+1);return n[0]=this.unusedBits,n.set(this.valueHexView,1),n.buffer}toJSON(){return{...super.toJSON(),unusedBits:this.unusedBits,isConstructed:this.isConstructed}}};_e.NAME=`BitStringValueBlock`;var ve,z=class extends T{constructor({idBlock:e={},lenBlock:t={},...n}={}){n.isConstructed??=!!n.value?.length,super({idBlock:{isConstructed:n.isConstructed,...e},lenBlock:{...t,isIndefiniteForm:!!n.isIndefiniteForm},...n},_e),this.idBlock.tagClass=1,this.idBlock.tagNumber=3}fromBER(e,t,n,r){return this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,super.fromBER(e,t,n,r)}onAsciiEncoding(){if(this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length)return se.prototype.onAsciiEncoding.call(this);{let e=[],t=this.valueBlock.valueHexView;for(let n of t)e.push(n.toString(2).padStart(8,`0`));let n=e.join(``);return`${this.constructor.NAME} : ${n.substring(0,n.length-this.valueBlock.unusedBits)}`}}};ve=z,w.BitString=ve,z.NAME=v;var ye;function be(e,t){let n=new Uint8Array([0]),r=new Uint8Array(e),i=new Uint8Array(t),o=r.slice(0),s=o.length-1,c=i.slice(0),l=c.length-1,u=0,d=l<s?s:l,f=0;for(let e=d;e>=0;e--,f++){switch(!0){case f<c.length:u=o[s-f]+c[l-f]+n[0];break;default:u=o[s-f]+n[0]}switch(n[0]=u/10,!0){case f>=o.length:o=a.utilConcatView(new Uint8Array([u%10]),o);break;default:o[s-f]=u%10}}return n[0]>0&&(o=a.utilConcatView(n,o)),o}function xe(e){if(e>=u.length)for(let t=u.length;t<=e;t++){let e=new Uint8Array([0]),n=u[t-1].slice(0);for(let t=n.length-1;t>=0;t--){let r=new Uint8Array([(n[t]<<1)+e[0]]);e[0]=r[0]/10,n[t]=r[0]%10}e[0]>0&&(n=a.utilConcatView(e,n)),u.push(n)}return u[e]}function B(e,t){let n=0,r=new Uint8Array(e),i=new Uint8Array(t),a=r.slice(0),o=a.length-1,s=i.slice(0),c=s.length-1,l,u=0;for(let e=c;e>=0;e--,u++)switch(l=a[o-u]-s[c-u]-n,!0){case l<0:n=1,a[o-u]=l+10;break;default:n=0,a[o-u]=l}if(n>0)for(let e=o-c+1;e>=0;e--,u++)if(l=a[o-u]-n,l<0)n=1,a[o-u]=l+10;else{n=0,a[o-u]=l;break}return a.slice()}var Se=class extends y(x){setValueHex(){this.valueHexView.length>=4?(this.warnings.push(`Too big Integer for decoding, hex only`),this.isHexOnly=!0,this._valueDec=0):(this.isHexOnly=!1,this.valueHexView.length>0&&(this._valueDec=a.utilDecodeTC.call(this)))}constructor({value:e,...t}={}){super(t),this._valueDec=0,t.valueHex&&this.setValueHex(),e!==void 0&&(this.valueDec=e)}set valueDec(e){this._valueDec=e,this.isHexOnly=!1,this.valueHexView=new Uint8Array(a.utilEncodeTC(e))}get valueDec(){return this._valueDec}fromDER(e,t,n,r=0){let i=this.fromBER(e,t,n);if(i===-1)return i;let a=this.valueHexView;return a[0]===0&&a[1]&128?this.valueHexView=a.subarray(1):r!==0&&a.length<r&&(r-a.length>1&&(r=a.length+1),this.valueHexView=a.subarray(r-a.length)),i}toDER(e=!1){let t=this.valueHexView;switch(!0){case(t[0]&128)!=0:{let e=new Uint8Array(this.valueHexView.length+1);e[0]=0,e.set(t,1),this.valueHexView=e}break;case t[0]===0&&(t[1]&128)==0:this.valueHexView=this.valueHexView.subarray(1);break}return this.toBER(e)}fromBER(e,t,n){let r=super.fromBER(e,t,n);return r===-1||this.setValueHex(),r}toBER(e){return e?new ArrayBuffer(this.valueHexView.length):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}toString(){let e=this.valueHexView.length*8-1,t=new Uint8Array(this.valueHexView.length*8/3),n=0,r,i=this.valueHexView,a=``,o=!1;for(let o=i.byteLength-1;o>=0;o--){r=i[o];for(let i=0;i<8;i++){if((r&1)==1)switch(n){case e:t=B(xe(n),t),a=`-`;break;default:t=be(t,xe(n))}n++,r>>=1}}for(let e=0;e<t.length;e++)t[e]&&(o=!0),o&&(a+=d.charAt(t[e]));return o===!1&&(a+=d.charAt(0)),a}};ye=Se,Se.NAME=`IntegerValueBlock`,Object.defineProperty(ye.prototype,"valueHex",{set:function(e){this.valueHexView=new Uint8Array(e),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var Ce,we=class extends T{constructor(e={}){super(e,Se),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return o(),BigInt(this.valueBlock.toString())}static fromBigInt(e){o();let t=BigInt(e),n=new l,r=t.toString(16).replace(/^-/,``),a=new Uint8Array(i.Convert.FromHex(r));if(t<0){let e=new Uint8Array(a.length+(a[0]&128?1:0));e[0]|=128;let r=BigInt(`0x${i.Convert.ToHex(e)}`)+t,o=i.BufferSourceConverter.toUint8Array(i.Convert.FromHex(r.toString(16)));o[0]|=128,n.write(o)}else a[0]&128&&n.write(new Uint8Array([0])),n.write(a);return new Ce({valueHex:n.final()})}convertToDER(){let e=new Ce({valueHex:this.valueBlock.valueHexView});return e.valueBlock.toDER(),e}convertFromDER(){return new Ce({valueHex:this.valueBlock.valueHexView[0]===0?this.valueBlock.valueHexView.subarray(1):this.valueBlock.valueHexView})}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()}`}};Ce=we,w.Integer=Ce,we.NAME=`INTEGER`;var V,H=class extends we{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}};V=H,w.Enumerated=V,H.NAME=`ENUMERATED`;var Te=class extends y(x){constructor({valueDec:e=-1,isFirstSid:t=!1,...n}={}){super(n),this.valueDec=e,this.isFirstSid=t}fromBER(e,t,n){if(!n)return t;let r=i.BufferSourceConverter.toUint8Array(e);if(!c(this,r,t,n))return-1;let o=r.subarray(t,t+n);this.valueHexView=new Uint8Array(n);for(let e=0;e<n&&(this.valueHexView[e]=o[e]&127,this.blockLength++,o[e]&128);e++);let s=new Uint8Array(this.blockLength);for(let e=0;e<this.blockLength;e++)s[e]=this.valueHexView[e];return this.valueHexView=s,o[this.blockLength-1]&128?(this.error=`End of input reached before message was fully decoded`,-1):(this.valueHexView[0]===0&&this.warnings.push(`Needlessly long format of SID encoding`),this.blockLength<=8?this.valueDec=a.utilFromBase(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push(`Too big SID for decoding, hex only`)),t+this.blockLength)}set valueBigInt(e){o();let t=BigInt(e).toString(2);for(;t.length%7;)t=`0`+t;let n=new Uint8Array(t.length/7);for(let e=0;e<n.length;e++)n[e]=parseInt(t.slice(e*7,e*7+7),2)+(e+1<n.length?128:0);this.fromBER(n.buffer,0,n.length)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);let t=this.valueHexView,n=new Uint8Array(this.blockLength);for(let e=0;e<this.blockLength-1;e++)n[e]=t[e]|128;return n[this.blockLength-1]=t[this.blockLength-1],n.buffer}let t=a.utilToBase(this.valueDec,7);if(t.byteLength===0)return this.error=`Error during encoding SID value`,m;let n=new Uint8Array(t.byteLength);if(!e){let e=new Uint8Array(t),r=t.byteLength-1;for(let t=0;t<r;t++)n[t]=e[t]|128;n[r]=e[r]}return n}toString(){let e=``;if(this.isHexOnly)e=i.Convert.ToHex(this.valueHexView);else if(this.isFirstSid){let t=this.valueDec;this.valueDec<=39?e=`0.`:this.valueDec<=79?(e=`1.`,t-=40):(e=`2.`,t-=80),e+=t.toString()}else e=this.valueDec.toString();return e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec,isFirstSid:this.isFirstSid}}};Te.NAME=`sidBlock`;var U=class extends x{constructor({value:e=``,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let r=t;for(;n>0;){let t=new Te;if(r=t.fromBER(e,r,n),r===-1)return this.blockLength=0,this.error=t.error,r;this.value.length===0&&(t.isFirstSid=!0),this.blockLength+=t.blockLength,n-=t.blockLength,this.value.push(t)}return r}toBER(e){let t=[];for(let n=0;n<this.value.length;n++){let r=this.value[n].toBER(e);if(r.byteLength===0)return this.error=this.value[n].error,m;t.push(r)}return s(t)}fromString(e){this.value=[];let t=0,n=0,r=``,i=!1;do if(n=e.indexOf(`.`,t),r=n===-1?e.substring(t):e.substring(t,n),t=n+1,i){let e=this.value[0],t=0;switch(e.valueDec){case 0:break;case 1:t=40;break;case 2:t=80;break;default:this.value=[];return}let n=parseInt(r,10);if(isNaN(n))return;e.valueDec=n+t,i=!1}else{let e=new Te;if(r>2**53-1)o(),e.valueBigInt=BigInt(r);else if(e.valueDec=parseInt(r,10),isNaN(e.valueDec))return;this.value.length||(e.isFirstSid=!0,i=!0),this.value.push(e)}while(n!==-1)}toString(){let e=``,t=!1;for(let n=0;n<this.value.length;n++){t=this.value[n].isHexOnly;let r=this.value[n].toString();n!==0&&(e=`${e}.`),t?(r=`{${r}}`,this.value[n].isFirstSid?e=`2.{${r} - 80}`:e+=r):e+=r}return e}toJSON(){let e={...super.toJSON(),value:this.toString(),sidArray:[]};for(let t=0;t<this.value.length;t++)e.sidArray.push(this.value[t].toJSON());return e}};U.NAME=`ObjectIdentifierValueBlock`;var Ee,De=class extends T{getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}constructor(e={}){super(e,U),this.idBlock.tagClass=1,this.idBlock.tagNumber=6}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||`empty`}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}};Ee=De,w.ObjectIdentifier=Ee,De.NAME=`OBJECT IDENTIFIER`;var Oe=class extends y(b){constructor({valueDec:e=0,...t}={}){super(t),this.valueDec=e}fromBER(e,t,n){if(n===0)return t;let r=i.BufferSourceConverter.toUint8Array(e);if(!c(this,r,t,n))return-1;let o=r.subarray(t,t+n);this.valueHexView=new Uint8Array(n);for(let e=0;e<n&&(this.valueHexView[e]=o[e]&127,this.blockLength++,o[e]&128);e++);let s=new Uint8Array(this.blockLength);for(let e=0;e<this.blockLength;e++)s[e]=this.valueHexView[e];return this.valueHexView=s,o[this.blockLength-1]&128?(this.error=`End of input reached before message was fully decoded`,-1):(this.valueHexView[0]===0&&this.warnings.push(`Needlessly long format of SID encoding`),this.blockLength<=8?this.valueDec=a.utilFromBase(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push(`Too big SID for decoding, hex only`)),t+this.blockLength)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);let t=this.valueHexView,n=new Uint8Array(this.blockLength);for(let e=0;e<this.blockLength-1;e++)n[e]=t[e]|128;return n[this.blockLength-1]=t[this.blockLength-1],n.buffer}let t=a.utilToBase(this.valueDec,7);if(t.byteLength===0)return this.error=`Error during encoding SID value`,m;let n=new Uint8Array(t.byteLength);if(!e){let e=new Uint8Array(t),r=t.byteLength-1;for(let t=0;t<r;t++)n[t]=e[t]|128;n[r]=e[r]}return n.buffer}toString(){let e=``;return e=this.isHexOnly?i.Convert.ToHex(this.valueHexView):this.valueDec.toString(),e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}};Oe.NAME=`relativeSidBlock`;var ke=class extends x{constructor({value:e=``,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let r=t;for(;n>0;){let t=new Oe;if(r=t.fromBER(e,r,n),r===-1)return this.blockLength=0,this.error=t.error,r;this.blockLength+=t.blockLength,n-=t.blockLength,this.value.push(t)}return r}toBER(e,t){let n=[];for(let t=0;t<this.value.length;t++){let r=this.value[t].toBER(e);if(r.byteLength===0)return this.error=this.value[t].error,m;n.push(r)}return s(n)}fromString(e){this.value=[];let t=0,n=0,r=``;do{n=e.indexOf(`.`,t),r=n===-1?e.substring(t):e.substring(t,n),t=n+1;let i=new Oe;if(i.valueDec=parseInt(r,10),isNaN(i.valueDec))return!0;this.value.push(i)}while(n!==-1);return!0}toString(){let e=``,t=!1;for(let n=0;n<this.value.length;n++){t=this.value[n].isHexOnly;let r=this.value[n].toString();n!==0&&(e=`${e}.`),t&&(r=`{${r}}`),e+=r}return e}toJSON(){let e={...super.toJSON(),value:this.toString(),sidArray:[]};for(let t=0;t<this.value.length;t++)e.sidArray.push(this.value[t].toJSON());return e}};ke.NAME=`RelativeObjectIdentifierValueBlock`;var W,Ae=class extends T{getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}constructor(e={}){super(e,ke),this.idBlock.tagClass=1,this.idBlock.tagNumber=13}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||`empty`}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}};W=Ae,w.RelativeObjectIdentifier=W,Ae.NAME=`RelativeObjectIdentifier`;var je,Me=class extends se{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}};je=Me,w.Sequence=je,Me.NAME=`SEQUENCE`;var G,Ne=class extends se{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};G=Ne,w.Set=G,Ne.NAME=`SET`;var Pe=class extends y(x){constructor({...e}={}){super(e),this.isHexOnly=!0,this.value=``}toJSON(){return{...super.toJSON(),value:this.value}}};Pe.NAME=`StringValueBlock`;var Fe=class extends Pe{};Fe.NAME=`SimpleStringValueBlock`;var K=class extends D{constructor({...e}={}){super(e,Fe)}fromBuffer(e){this.valueBlock.value=String.fromCharCode.apply(null,i.BufferSourceConverter.toUint8Array(e))}fromString(e){let t=e.length,n=this.valueBlock.valueHexView=new Uint8Array(t);for(let r=0;r<t;r++)n[r]=e.charCodeAt(r);this.valueBlock.value=e}};K.NAME=`SIMPLE STRING`;var Ie=class extends K{fromBuffer(e){this.valueBlock.valueHexView=i.BufferSourceConverter.toUint8Array(e);try{this.valueBlock.value=i.Convert.ToUtf8String(e)}catch(t){this.warnings.push(`Error during "decodeURIComponent": ${t}, using raw string`),this.valueBlock.value=i.Convert.ToBinary(e)}}fromString(e){this.valueBlock.valueHexView=new Uint8Array(i.Convert.FromUtf8String(e)),this.valueBlock.value=e}};Ie.NAME=`Utf8StringValueBlock`;var Le,Re=class extends Ie{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}};Le=Re,w.Utf8String=Le,Re.NAME=`UTF8String`;var ze=class extends K{fromBuffer(e){this.valueBlock.value=i.Convert.ToUtf16String(e),this.valueBlock.valueHexView=i.BufferSourceConverter.toUint8Array(e)}fromString(e){this.valueBlock.value=e,this.valueBlock.valueHexView=new Uint8Array(i.Convert.FromUtf16String(e))}};ze.NAME=`BmpStringValueBlock`;var Be,Ve=class extends ze{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}};Be=Ve,w.BmpString=Be,Ve.NAME=`BMPString`;var He=class extends K{fromBuffer(e){let t=ArrayBuffer.isView(e)?e.slice().buffer:e.slice(0),n=new Uint8Array(t);for(let e=0;e<n.length;e+=4)n[e]=n[e+3],n[e+1]=n[e+2],n[e+2]=0,n[e+3]=0;this.valueBlock.value=String.fromCharCode.apply(null,new Uint32Array(t))}fromString(e){let t=e.length,n=this.valueBlock.valueHexView=new Uint8Array(t*4);for(let r=0;r<t;r++){let t=a.utilToBase(e.charCodeAt(r),8),i=new Uint8Array(t);if(i.length>4)continue;let o=4-i.length;for(let e=i.length-1;e>=0;e--)n[r*4+e+o]=i[e]}this.valueBlock.value=e}};He.NAME=`UniversalStringValueBlock`;var Ue,We=class extends He{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}};Ue=We,w.UniversalString=Ue,We.NAME=`UniversalString`;var q,Ge=class extends K{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}};q=Ge,w.NumericString=q,Ge.NAME=`NumericString`;var Ke,qe=class extends K{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}};Ke=qe,w.PrintableString=Ke,qe.NAME=`PrintableString`;var Je,Ye=class extends K{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}};Je=Ye,w.TeletexString=Je,Ye.NAME=`TeletexString`;var Xe,Ze=class extends K{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}};Xe=Ze,w.VideotexString=Xe,Ze.NAME=`VideotexString`;var Qe,$e=class extends K{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}};Qe=$e,w.IA5String=Qe,$e.NAME=`IA5String`;var et,tt=class extends K{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}};et=tt,w.GraphicString=et,tt.NAME=`GraphicString`;var nt,rt=class extends K{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}};nt=rt,w.VisibleString=nt,rt.NAME=`VisibleString`;var it,at=class extends K{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}};it=at,w.GeneralString=it,at.NAME=`GeneralString`;var ot,st=class extends K{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}};ot=st,w.CharacterString=ot,st.NAME=`CharacterString`;var ct,lt=class extends rt{constructor({value:e,valueDate:t,...n}={}){if(super(n),this.year=0,this.month=0,this.day=0,this.hour=0,this.minute=0,this.second=0,e){this.fromString(e),this.valueBlock.valueHexView=new Uint8Array(e.length);for(let t=0;t<e.length;t++)this.valueBlock.valueHexView[t]=e.charCodeAt(t)}t&&(this.fromDate(t),this.valueBlock.valueHexView=new Uint8Array(this.toBuffer())),this.idBlock.tagClass=1,this.idBlock.tagNumber=23}fromBuffer(e){this.fromString(String.fromCharCode.apply(null,i.BufferSourceConverter.toUint8Array(e)))}toBuffer(){let e=this.toString(),t=new ArrayBuffer(e.length),n=new Uint8Array(t);for(let t=0;t<e.length;t++)n[t]=e.charCodeAt(t);return t}fromDate(e){this.year=e.getUTCFullYear(),this.month=e.getUTCMonth()+1,this.day=e.getUTCDate(),this.hour=e.getUTCHours(),this.minute=e.getUTCMinutes(),this.second=e.getUTCSeconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second))}fromString(e){let t=/(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z/gi.exec(e);if(t===null){this.error=`Wrong input string for conversion`;return}let n=parseInt(t[1],10);n>=50?this.year=1900+n:this.year=2e3+n,this.month=parseInt(t[2],10),this.day=parseInt(t[3],10),this.hour=parseInt(t[4],10),this.minute=parseInt(t[5],10),this.second=parseInt(t[6],10)}toString(e=`iso`){if(e===`iso`){let e=Array(7);return e[0]=a.padNumber(this.year<2e3?this.year-1900:this.year-2e3,2),e[1]=a.padNumber(this.month,2),e[2]=a.padNumber(this.day,2),e[3]=a.padNumber(this.hour,2),e[4]=a.padNumber(this.minute,2),e[5]=a.padNumber(this.second,2),e[6]=`Z`,e.join(``)}return super.toString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.toDate().toISOString()}`}toJSON(){return{...super.toJSON(),year:this.year,month:this.month,day:this.day,hour:this.hour,minute:this.minute,second:this.second}}};ct=lt,w.UTCTime=ct,lt.NAME=`UTCTime`;var ut,dt=class extends lt{constructor(e={}){super(e),this.millisecond??=0,this.idBlock.tagClass=1,this.idBlock.tagNumber=24}fromDate(e){super.fromDate(e),this.millisecond=e.getUTCMilliseconds()}toDate(){let e=Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second,this.millisecond);return new Date(e)}fromString(e){let t=!1,n=``,r=``,i=0,a,o=0,s=0;if(e[e.length-1]===`Z`)n=e.substring(0,e.length-1),t=!0;else{let t=new Number(e[e.length-1]);if(isNaN(t.valueOf()))throw Error(`Wrong input string for conversion`);n=e}if(t){if(n.indexOf(`+`)!==-1||n.indexOf(`-`)!==-1)throw Error(`Wrong input string for conversion`)}else{let e=1,t=n.indexOf(`+`),r=``;if(t===-1&&(t=n.indexOf(`-`),e=-1),t!==-1){if(r=n.substring(t+1),n=n.substring(0,t),r.length!==2&&r.length!==4)throw Error(`Wrong input string for conversion`);let i=parseInt(r.substring(0,2),10);if(isNaN(i.valueOf()))throw Error(`Wrong input string for conversion`);if(o=e*i,r.length===4){if(i=parseInt(r.substring(2,4),10),isNaN(i.valueOf()))throw Error(`Wrong input string for conversion`);s=e*i}}}let c=n.indexOf(`.`);if(c===-1&&(c=n.indexOf(`,`)),c!==-1){let e=new Number(`0${n.substring(c)}`);if(isNaN(e.valueOf()))throw Error(`Wrong input string for conversion`);i=e.valueOf(),r=n.substring(0,c)}else r=n;switch(!0){case r.length===8:if(a=/(\d{4})(\d{2})(\d{2})/gi,c!==-1)throw Error(`Wrong input string for conversion`);break;case r.length===10:if(a=/(\d{4})(\d{2})(\d{2})(\d{2})/gi,c!==-1){let e=60*i;this.minute=Math.floor(e),e=60*(e-this.minute),this.second=Math.floor(e),e=1e3*(e-this.second),this.millisecond=Math.floor(e)}break;case r.length===12:if(a=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/gi,c!==-1){let e=60*i;this.second=Math.floor(e),e=1e3*(e-this.second),this.millisecond=Math.floor(e)}break;case r.length===14:if(a=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/gi,c!==-1){let e=1e3*i;this.millisecond=Math.floor(e)}break;default:throw Error(`Wrong input string for conversion`)}let l=a.exec(r);if(l===null)throw Error(`Wrong input string for conversion`);for(let e=1;e<l.length;e++)switch(e){case 1:this.year=parseInt(l[e],10);break;case 2:this.month=parseInt(l[e],10);break;case 3:this.day=parseInt(l[e],10);break;case 4:this.hour=parseInt(l[e],10)+o;break;case 5:this.minute=parseInt(l[e],10)+s;break;case 6:this.second=parseInt(l[e],10);break;default:throw Error(`Wrong input string for conversion`)}if(t===!1){let e=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);this.year=e.getUTCFullYear(),this.month=e.getUTCMonth(),this.day=e.getUTCDay(),this.hour=e.getUTCHours(),this.minute=e.getUTCMinutes(),this.second=e.getUTCSeconds(),this.millisecond=e.getUTCMilliseconds()}}toString(e=`iso`){if(e===`iso`){let e=[];return e.push(a.padNumber(this.year,4)),e.push(a.padNumber(this.month,2)),e.push(a.padNumber(this.day,2)),e.push(a.padNumber(this.hour,2)),e.push(a.padNumber(this.minute,2)),e.push(a.padNumber(this.second,2)),this.millisecond!==0&&(e.push(`.`),e.push(a.padNumber(this.millisecond,3))),e.push(`Z`),e.join(``)}return super.toString(e)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}};ut=dt,w.GeneralizedTime=ut,dt.NAME=`GeneralizedTime`;var ft,pt=class extends Re{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}};ft=pt,w.DATE=ft,pt.NAME=`DATE`;var mt,ht=class extends Re{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}};mt=ht,w.TimeOfDay=mt,ht.NAME=`TimeOfDay`;var gt,_t=class extends Re{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}};gt=_t,w.DateTime=gt,_t.NAME=`DateTime`;var vt,yt=class extends Re{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}};vt=yt,w.Duration=vt,yt.NAME=`Duration`;var bt,xt=class extends Re{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}};bt=xt,w.TIME=bt,xt.NAME=`TIME`;var St=class{constructor({name:e=``,optional:t=!1}={}){this.name=e,this.optional=t}},Ct=class extends St{constructor({value:e=[],...t}={}){super(t),this.value=e}},wt=class extends St{constructor({value:e=new St,local:t=!1,...n}={}){super(n),this.value=e,this.local=t}},Tt=class{get data(){return this.dataView.slice().buffer}set data(e){this.dataView=i.BufferSourceConverter.toUint8Array(e)}constructor({data:e=h}={}){this.dataView=i.BufferSourceConverter.toUint8Array(e)}fromBER(e,t,n){let r=t+n;return this.dataView=i.BufferSourceConverter.toUint8Array(e).subarray(t,r),r}toBER(e){return this.dataView.slice().buffer}};function Et(e,t,n){if(n instanceof Ct){for(let r of n.value)if(Et(e,t,r).verified)return{verified:!0,result:e};{let e={verified:!1,result:{error:`Wrong values for Choice type`}};return n.hasOwnProperty(f)&&(e.name=n.name),e}}if(n instanceof St)return n.hasOwnProperty(f)&&(e[n.name]=t),{verified:!0,result:e};if(!(e instanceof Object))return{verified:!1,result:{error:`Wrong root object`}};if(!(t instanceof Object))return{verified:!1,result:{error:`Wrong ASN.1 data`}};if(!(n instanceof Object)||!(`idBlock`in n)||!(`fromBER`in n.idBlock)||!(`toBER`in n.idBlock))return{verified:!1,result:{error:`Wrong ASN.1 schema`}};let r=n.idBlock.toBER(!1);if(r.byteLength===0)return{verified:!1,result:{error:`Error encoding idBlock for ASN.1 schema`}};if(n.idBlock.fromBER(r,0,r.byteLength)===-1)return{verified:!1,result:{error:`Error decoding idBlock for ASN.1 schema`}};if(n.idBlock.hasOwnProperty(`tagClass`)===!1)return{verified:!1,result:{error:`Wrong ASN.1 schema`}};if(n.idBlock.tagClass!==t.idBlock.tagClass)return{verified:!1,result:e};if(n.idBlock.hasOwnProperty(`tagNumber`)===!1)return{verified:!1,result:{error:`Wrong ASN.1 schema`}};if(n.idBlock.tagNumber!==t.idBlock.tagNumber)return{verified:!1,result:e};if(n.idBlock.hasOwnProperty(`isConstructed`)===!1)return{verified:!1,result:{error:`Wrong ASN.1 schema`}};if(n.idBlock.isConstructed!==t.idBlock.isConstructed)return{verified:!1,result:e};if(!(`isHexOnly`in n.idBlock))return{verified:!1,result:{error:`Wrong ASN.1 schema`}};if(n.idBlock.isHexOnly!==t.idBlock.isHexOnly)return{verified:!1,result:e};if(n.idBlock.isHexOnly){if(!(p in n.idBlock))return{verified:!1,result:{error:`Wrong ASN.1 schema`}};let r=n.idBlock.valueHexView,i=t.idBlock.valueHexView;if(r.length!==i.length)return{verified:!1,result:e};for(let t=0;t<r.length;t++)if(r[t]!==i[1])return{verified:!1,result:e}}if(n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,``),n.name&&(e[n.name]=t)),n instanceof w.Constructed){let r=0,i={verified:!1,result:{error:`Unknown error`}},a=n.valueBlock.value.length;if(a>0&&n.valueBlock.value[0]instanceof wt&&(a=t.valueBlock.value.length),a===0)return{verified:!0,result:e};if(t.valueBlock.value.length===0&&n.valueBlock.value.length!==0){let t=!0;for(let e=0;e<n.valueBlock.value.length;e++)t&&=n.valueBlock.value[e].optional||!1;return t?{verified:!0,result:e}:(n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,``),n.name&&delete e[n.name]),e.error=`Inconsistent object length`,{verified:!1,result:e})}for(let o=0;o<a;o++)if(o-r>=t.valueBlock.value.length){if(n.valueBlock.value[o].optional===!1){let t={verified:!1,result:e};return e.error=`Inconsistent length between ASN.1 data and schema`,n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,``),n.name&&(delete e[n.name],t.name=n.name)),t}}else if(n.valueBlock.value[0]instanceof wt){if(i=Et(e,t.valueBlock.value[o],n.valueBlock.value[0].value),i.verified===!1)if(n.valueBlock.value[0].optional)r++;else return n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,``),n.name&&delete e[n.name]),i;if(f in n.valueBlock.value[0]&&n.valueBlock.value[0].name.length>0){let r={};r=`local`in n.valueBlock.value[0]&&n.valueBlock.value[0].local?t:e,r[n.valueBlock.value[0].name]===void 0&&(r[n.valueBlock.value[0].name]=[]),r[n.valueBlock.value[0].name].push(t.valueBlock.value[o])}}else if(i=Et(e,t.valueBlock.value[o-r],n.valueBlock.value[o]),i.verified===!1)if(n.valueBlock.value[o].optional)r++;else return n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,``),n.name&&delete e[n.name]),i;if(i.verified===!1){let t={verified:!1,result:e};return n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,``),n.name&&(delete e[n.name],t.name=n.name)),t}return{verified:!0,result:e}}if(n.primitiveSchema&&p in t.valueBlock){let r=re(t.valueBlock.valueHexView);if(r.offset===-1){let t={verified:!1,result:r.result};return n.name&&(n.name=n.name.replace(/^\s+|\s+$/g,``),n.name&&(delete e[n.name],t.name=n.name)),t}return Et(e,r.result,n.primitiveSchema)}return{verified:!0,result:e}}function Dt(e,t){if(!(t instanceof Object))return{verified:!1,result:{error:`Wrong ASN.1 schema type`}};let n=re(i.BufferSourceConverter.toUint8Array(e));return n.offset===-1?{verified:!1,result:n.result}:Et(n.result,n.result,t)}e.Any=St,e.BaseBlock=T,e.BaseStringBlock=D,e.BitString=z,e.BmpString=Ve,e.Boolean=me,e.CharacterString=st,e.Choice=Ct,e.Constructed=se,e.DATE=pt,e.DEFAULT_MAX_CONTENT_LENGTH=j,e.DEFAULT_MAX_DEPTH=100,e.DEFAULT_MAX_NODES=ee,e.DateTime=_t,e.Duration=yt,e.EndOfContent=ue,e.Enumerated=H,e.GeneralString=at,e.GeneralizedTime=dt,e.GraphicString=tt,e.HexBlock=y,e.IA5String=$e,e.Integer=we,e.Null=fe,e.NumericString=Ge,e.ObjectIdentifier=De,e.OctetString=ge,e.Primitive=A,e.PrintableString=qe,e.RawData=Tt,e.RelativeObjectIdentifier=Ae,e.Repeated=wt,e.Sequence=Me,e.Set=Ne,e.TIME=xt,e.TeletexString=Ye,e.TimeOfDay=ht,e.UTCTime=lt,e.UniversalString=We,e.Utf8String=Re,e.ValueBlock=x,e.VideotexString=Ze,e.ViewWriter=l,e.VisibleString=rt,e.compareSchema=Et,e.fromBER=I,e.verifySchema=Dt})),ls=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isArrayBuffer=o,e.isSharedArrayBuffer=s,e.isArrayBufferLike=c,e.isArrayBufferView=l,e.isBufferSource=u,e.assertBufferSource=d,e.toUint8Array=f,e.toUint8ArrayCopy=p,e.toArrayBuffer=m,e.toArrayBufferLike=h,e.toView=g,e.toViewCopy=_;function t(e){return Object.prototype.toString.call(e)}function n(e){return e===DataView||e.prototype instanceof DataView}function r(e){return n(e)?1:e.BYTES_PER_ELEMENT??1}function i(e){if(ArrayBuffer.isView(e))return!0;if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.byteOffset==`number`&&typeof t.byteLength==`number`&&c(t.buffer)}function a(e){let t=f(e),n=new Uint8Array(t.byteLength);return n.set(t),n}function o(e){return t(e)===`[object ArrayBuffer]`}function s(e){return typeof SharedArrayBuffer<`u`&&t(e)===`[object SharedArrayBuffer]`}function c(e){return o(e)||s(e)}function l(e){return i(e)}function u(e){return c(e)||l(e)}function d(e){if(!u(e))throw TypeError(`Expected ArrayBuffer, SharedArrayBuffer, or ArrayBufferView`)}function f(e){return d(e),c(e)?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function p(e){return a(e)}function m(e){if(d(e),o(e))return e;let t=new ArrayBuffer(e.byteLength);return new Uint8Array(t).set(f(e)),t}function h(e){return d(e),c(e)?e:e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e.buffer:a(e).buffer}function g(e,t){if(d(e),ArrayBuffer.isView(e)&&e.constructor===t)return e;let i=f(e),a=r(t);if(i.byteOffset%a!==0||i.byteLength%a!==0)throw RangeError(`Cannot create ${t.name} over unaligned byte range`);return n(t)?new t(i.buffer,i.byteOffset,i.byteLength):new t(i.buffer,i.byteOffset,i.byteLength/a)}function _(e,t){return g(p(e),t)}})),us=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.concatToUint8Array=n,e.concat=r;let t=ls();function n(e){let n=[],r=0;for(let i of e){let e=(0,t.toUint8Array)(i);n.push(e),r+=e.byteLength}let i=new Uint8Array(r),a=0;for(let e of n)i.set(e,a),a+=e.byteLength;return i}function r(e,r,...i){let a,o;typeof r==`function`?(a=Array.from(e),o=r):(0,t.isBufferSource)(e)?a=[e,r,...i].filter(t.isBufferSource):(a=Array.from(e),r&&a.push(r),a.push(...i));let s=n(a);return o?(0,t.toView)(s,o):s.buffer}})),ds=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.equal=n;let t=ls();function n(e,n,r={}){let i=(0,t.toUint8Array)(e),a=(0,t.toUint8Array)(n);if(!r.constantTime&&i.byteLength!==a.byteLength)return!1;let o=Math.max(i.byteLength,a.byteLength),s=i.byteLength^a.byteLength;for(let e=0;e<o;e++)s|=(i[e]??0)^(a[e]??0);return s===0}})),fs=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.indexOf=u,e.lastIndexOf=d,e.includes=f,e.startsWith=p,e.endsWith=m,e.slice=h,e.tail=g,e.copy=_,e.compare=v;let t=ls();function n(e,t,n){let r=Number.isFinite(e)?Math.trunc(e):t;return r<=0?0:r>=n?n:r}function r(e,t){let r=n(t?.start,0,e),i=n(t?.end,e,e);return i>=r?[r,i]:[r,r]}function i(e,t){let r=n(t?.start,e,e),i=n(t?.end,0,e);return r>=i?[i,r]:[r,r]}function a(e,t,n){let r=Number.isFinite(e)?Math.trunc(e):t;return r<0?Math.max(n+r,0):r>n?n:r}function o(e){let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n)&255;return t}function s(e){return new TextEncoder().encode(e)}function c(e,n){return typeof e==`string`?n?.encoding===`utf8`?s(e):o(e):(0,t.toUint8Array)(e)}function l(e,t,n){for(let r=0;r<t.byteLength;r++)if(e[n+r]!==t[r])return!1;return!0}function u(e,n,i){let a=(0,t.toUint8Array)(e),o=c(n,i),[s,u]=r(a.byteLength,i);if(o.byteLength===0)return s;let d=u-o.byteLength;if(d<s)return-1;for(let e=s;e<=d;e++)if(l(a,o,e))return e;return-1}function d(e,n,r){let a=(0,t.toUint8Array)(e),o=c(n,r),[s,u]=i(a.byteLength,r);if(o.byteLength===0)return u;let d=u-o.byteLength;if(d<s)return-1;for(let e=d;e>=s;e--)if(l(a,o,e))return e;return-1}function f(e,t,n){return u(e,t,n)!==-1}function p(e,n,r){let i=(0,t.toUint8Array)(e),a=c(n,r);return a.byteLength>i.byteLength?!1:l(i,a,0)}function m(e,n,r){let i=(0,t.toUint8Array)(e),a=c(n,r);return a.byteLength>i.byteLength?!1:l(i,a,i.byteLength-a.byteLength)}function h(e,n,r){let i=(0,t.toUint8Array)(e),o=a(n,0,i.byteLength),s=a(r,i.byteLength,i.byteLength);return s<=o?i.subarray(o,o):i.subarray(o,s)}function g(e,n){let r=(0,t.toUint8Array)(e),i=Number.isFinite(n)?Math.max(0,Math.trunc(n)):0;return i>=r.byteLength?r:r.subarray(r.byteLength-i)}function _(e){return(0,t.toUint8ArrayCopy)(e)}function v(e,n){let r=(0,t.toUint8Array)(e),i=(0,t.toUint8Array)(n),a=Math.min(r.byteLength,i.byteLength);for(let e=0;e<a;e++){if(r[e]<i[e])return-1;if(r[e]>i[e])return 1}return r.byteLength<i.byteLength?-1:+(r.byteLength>i.byteLength)}})),ps=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.tail=e.startsWith=e.slice=e.lastIndexOf=e.indexOf=e.includes=e.endsWith=e.copy=e.compare=e.equal=e.concatToUint8Array=e.concat=e.toViewCopy=e.toView=e.toUint8ArrayCopy=e.toUint8Array=e.toArrayBufferLike=e.toArrayBuffer=e.isSharedArrayBuffer=e.isBufferSource=e.isArrayBufferView=e.isArrayBufferLike=e.isArrayBuffer=e.assertBufferSource=void 0;var t=ls();Object.defineProperty(e,"assertBufferSource",{enumerable:!0,get:function(){return t.assertBufferSource}}),Object.defineProperty(e,"isArrayBuffer",{enumerable:!0,get:function(){return t.isArrayBuffer}}),Object.defineProperty(e,"isArrayBufferLike",{enumerable:!0,get:function(){return t.isArrayBufferLike}}),Object.defineProperty(e,"isArrayBufferView",{enumerable:!0,get:function(){return t.isArrayBufferView}}),Object.defineProperty(e,"isBufferSource",{enumerable:!0,get:function(){return t.isBufferSource}}),Object.defineProperty(e,"isSharedArrayBuffer",{enumerable:!0,get:function(){return t.isSharedArrayBuffer}}),Object.defineProperty(e,"toArrayBuffer",{enumerable:!0,get:function(){return t.toArrayBuffer}}),Object.defineProperty(e,"toArrayBufferLike",{enumerable:!0,get:function(){return t.toArrayBufferLike}}),Object.defineProperty(e,"toUint8Array",{enumerable:!0,get:function(){return t.toUint8Array}}),Object.defineProperty(e,"toUint8ArrayCopy",{enumerable:!0,get:function(){return t.toUint8ArrayCopy}}),Object.defineProperty(e,"toView",{enumerable:!0,get:function(){return t.toView}}),Object.defineProperty(e,"toViewCopy",{enumerable:!0,get:function(){return t.toViewCopy}});var n=us();Object.defineProperty(e,"concat",{enumerable:!0,get:function(){return n.concat}}),Object.defineProperty(e,"concatToUint8Array",{enumerable:!0,get:function(){return n.concatToUint8Array}});var r=ds();Object.defineProperty(e,"equal",{enumerable:!0,get:function(){return r.equal}});var i=fs();Object.defineProperty(e,"compare",{enumerable:!0,get:function(){return i.compare}}),Object.defineProperty(e,"copy",{enumerable:!0,get:function(){return i.copy}}),Object.defineProperty(e,"endsWith",{enumerable:!0,get:function(){return i.endsWith}}),Object.defineProperty(e,"includes",{enumerable:!0,get:function(){return i.includes}}),Object.defineProperty(e,"indexOf",{enumerable:!0,get:function(){return i.indexOf}}),Object.defineProperty(e,"lastIndexOf",{enumerable:!0,get:function(){return i.lastIndexOf}}),Object.defineProperty(e,"slice",{enumerable:!0,get:function(){return i.slice}}),Object.defineProperty(e,"startsWith",{enumerable:!0,get:function(){return i.startsWith}}),Object.defineProperty(e,"tail",{enumerable:!0,get:function(){return i.tail}})})),ms=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AsnPropTypes=e.AsnTypeTypes=void 0;var t;(function(e){e[e.Sequence=0]=`Sequence`,e[e.Set=1]=`Set`,e[e.Choice=2]=`Choice`})(t||(e.AsnTypeTypes=t={}));var n;(function(e){e[e.Any=1]=`Any`,e[e.Boolean=2]=`Boolean`,e[e.OctetString=3]=`OctetString`,e[e.BitString=4]=`BitString`,e[e.Integer=5]=`Integer`,e[e.Enumerated=6]=`Enumerated`,e[e.ObjectIdentifier=7]=`ObjectIdentifier`,e[e.Utf8String=8]=`Utf8String`,e[e.BmpString=9]=`BmpString`,e[e.UniversalString=10]=`UniversalString`,e[e.NumericString=11]=`NumericString`,e[e.PrintableString=12]=`PrintableString`,e[e.TeletexString=13]=`TeletexString`,e[e.VideotexString=14]=`VideotexString`,e[e.IA5String=15]=`IA5String`,e[e.GraphicString=16]=`GraphicString`,e[e.VisibleString=17]=`VisibleString`,e[e.GeneralString=18]=`GeneralString`,e[e.CharacterString=19]=`CharacterString`,e[e.UTCTime=20]=`UTCTime`,e[e.GeneralizedTime=21]=`GeneralizedTime`,e[e.DATE=22]=`DATE`,e[e.TimeOfDay=23]=`TimeOfDay`,e[e.DateTime=24]=`DateTime`,e[e.Duration=25]=`Duration`,e[e.TIME=26]=`TIME`,e[e.Null=27]=`Null`})(n||(e.AsnPropTypes=n={}))})),hs=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.BitString=void 0;let t=(X(),F(Y)).__importStar(cs()),n=ps();e.BitString=class{unusedBits=0;value=new ArrayBuffer(0);constructor(e,t=0){if(e)if(typeof e==`number`)this.fromNumber(e);else if((0,n.isBufferSource)(e))this.unusedBits=t,this.value=(0,n.toArrayBuffer)(e);else throw TypeError(`Unsupported type of 'params' argument for BitString`)}fromASN(e){if(!(e instanceof t.BitString))throw TypeError(`Argument 'asn' is not instance of ASN.1 BitString`);return this.unusedBits=e.valueBlock.unusedBits,this.value=(0,n.toArrayBuffer)(e.valueBlock.valueHex),this}toASN(){return new t.BitString({unusedBits:this.unusedBits,valueHex:this.value})}toSchema(e){return new t.BitString({name:e})}toNumber(){let e=``,t=new Uint8Array(this.value);for(let n of t)e+=n.toString(2).padStart(8,`0`);return e=e.split(``).reverse().join(``),this.unusedBits&&(e=e.slice(this.unusedBits).padStart(this.unusedBits,`0`)),parseInt(e,2)}fromNumber(e){let t=e.toString(2),n=t.length+7>>3;this.unusedBits=(n<<3)-t.length;let r=new Uint8Array(n);t=t.padStart(n<<3,`0`).split(``).reverse().join(``);let i=0;for(;i<n;)r[i]=parseInt(t.slice(i<<3,(i<<3)+8),2),i++;this.value=r.buffer}}})),gs=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.OctetString=void 0;let t=(X(),F(Y)).__importStar(cs()),n=ps();e.OctetString=class{buffer;get byteLength(){return this.buffer.byteLength}get byteOffset(){return 0}constructor(e){typeof e==`number`?this.buffer=new ArrayBuffer(e):(0,n.isBufferSource)(e)?this.buffer=(0,n.toArrayBuffer)(e):Array.isArray(e)?this.buffer=new Uint8Array(e).buffer:this.buffer=new ArrayBuffer(0)}fromASN(e){if(!(e instanceof t.OctetString))throw TypeError(`Argument 'asn' is not instance of ASN.1 OctetString`);return this.buffer=(0,n.toArrayBuffer)(e.valueBlock.valueHex),this}toASN(){return new t.OctetString({valueHex:this.buffer})}toSchema(e){return new t.OctetString({name:e})}}})),_s=N((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=(X(),F(Y));t.__exportStar(hs(),e),t.__exportStar(gs(),e)})),vs=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AsnNullConverter=e.AsnGeneralizedTimeConverter=e.AsnUTCTimeConverter=e.AsnCharacterStringConverter=e.AsnGeneralStringConverter=e.AsnVisibleStringConverter=e.AsnGraphicStringConverter=e.AsnIA5StringConverter=e.AsnVideotexStringConverter=e.AsnTeletexStringConverter=e.AsnPrintableStringConverter=e.AsnNumericStringConverter=e.AsnUniversalStringConverter=e.AsnBmpStringConverter=e.AsnUtf8StringConverter=e.AsnConstructedOctetStringConverter=e.AsnOctetStringConverter=e.AsnBooleanConverter=e.AsnObjectIdentifierConverter=e.AsnBitStringConverter=e.AsnIntegerBigIntConverter=e.AsnIntegerArrayBufferConverter=e.AsnEnumeratedConverter=e.AsnIntegerConverter=e.AsnAnyConverter=void 0,e.defaultConverter=o;let t=(X(),F(Y)).__importStar(cs()),n=ps(),r=ms(),i=_s();e.AsnAnyConverter={fromASN:e=>e instanceof t.Null?null:(0,n.toArrayBuffer)(e.valueBeforeDecodeView),toASN:e=>{if(e===null)return new t.Null;let n=t.fromBER(e);if(n.result.error)throw Error(n.result.error);return n.result}},e.AsnIntegerConverter={fromASN:e=>e.valueBlock.valueHexView.byteLength>=4?e.valueBlock.toString():e.valueBlock.valueDec,toASN:e=>new t.Integer({value:+e})},e.AsnEnumeratedConverter={fromASN:e=>e.valueBlock.valueDec,toASN:e=>new t.Enumerated({value:e})},e.AsnIntegerArrayBufferConverter={fromASN:e=>(0,n.toArrayBuffer)(e.valueBlock.valueHexView),toASN:e=>new t.Integer({valueHex:e})},e.AsnIntegerBigIntConverter={fromASN:e=>e.toBigInt(),toASN:e=>t.Integer.fromBigInt(e)},e.AsnBitStringConverter={fromASN:e=>(0,n.toArrayBuffer)(e.valueBlock.valueHexView),toASN:e=>new t.BitString({valueHex:e})},e.AsnObjectIdentifierConverter={fromASN:e=>e.valueBlock.toString(),toASN:e=>new t.ObjectIdentifier({value:e})},e.AsnBooleanConverter={fromASN:e=>e.valueBlock.value,toASN:e=>new t.Boolean({value:e})},e.AsnOctetStringConverter={fromASN:e=>(0,n.toArrayBuffer)(e.valueBlock.valueHexView),toASN:e=>new t.OctetString({valueHex:e})},e.AsnConstructedOctetStringConverter={fromASN:e=>new i.OctetString(e.getValue()),toASN:e=>e.toASN()};function a(e){return{fromASN:e=>e.valueBlock.value,toASN:t=>new e({value:t})}}e.AsnUtf8StringConverter=a(t.Utf8String),e.AsnBmpStringConverter=a(t.BmpString),e.AsnUniversalStringConverter=a(t.UniversalString),e.AsnNumericStringConverter=a(t.NumericString),e.AsnPrintableStringConverter=a(t.PrintableString),e.AsnTeletexStringConverter=a(t.TeletexString),e.AsnVideotexStringConverter=a(t.VideotexString),e.AsnIA5StringConverter=a(t.IA5String),e.AsnGraphicStringConverter=a(t.GraphicString),e.AsnVisibleStringConverter=a(t.VisibleString),e.AsnGeneralStringConverter=a(t.GeneralString),e.AsnCharacterStringConverter=a(t.CharacterString),e.AsnUTCTimeConverter={fromASN:e=>e.toDate(),toASN:e=>new t.UTCTime({valueDate:e})},e.AsnGeneralizedTimeConverter={fromASN:e=>e.toDate(),toASN:e=>new t.GeneralizedTime({valueDate:e})},e.AsnNullConverter={fromASN:()=>null,toASN:()=>new t.Null};function o(t){switch(t){case r.AsnPropTypes.Any:return e.AsnAnyConverter;case r.AsnPropTypes.BitString:return e.AsnBitStringConverter;case r.AsnPropTypes.BmpString:return e.AsnBmpStringConverter;case r.AsnPropTypes.Boolean:return e.AsnBooleanConverter;case r.AsnPropTypes.CharacterString:return e.AsnCharacterStringConverter;case r.AsnPropTypes.Enumerated:return e.AsnEnumeratedConverter;case r.AsnPropTypes.GeneralString:return e.AsnGeneralStringConverter;case r.AsnPropTypes.GeneralizedTime:return e.AsnGeneralizedTimeConverter;case r.AsnPropTypes.GraphicString:return e.AsnGraphicStringConverter;case r.AsnPropTypes.IA5String:return e.AsnIA5StringConverter;case r.AsnPropTypes.Integer:return e.AsnIntegerConverter;case r.AsnPropTypes.Null:return e.AsnNullConverter;case r.AsnPropTypes.NumericString:return e.AsnNumericStringConverter;case r.AsnPropTypes.ObjectIdentifier:return e.AsnObjectIdentifierConverter;case r.AsnPropTypes.OctetString:return e.AsnOctetStringConverter;case r.AsnPropTypes.PrintableString:return e.AsnPrintableStringConverter;case r.AsnPropTypes.TeletexString:return e.AsnTeletexStringConverter;case r.AsnPropTypes.UTCTime:return e.AsnUTCTimeConverter;case r.AsnPropTypes.UniversalString:return e.AsnUniversalStringConverter;case r.AsnPropTypes.Utf8String:return e.AsnUtf8StringConverter;case r.AsnPropTypes.VideotexString:return e.AsnVideotexStringConverter;case r.AsnPropTypes.VisibleString:return e.AsnVisibleStringConverter;default:return null}}})),ys=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isConvertible=t,e.isTypeOfArray=n,e.isArrayEqual=r;function t(e){return typeof e==`function`&&e.prototype?e.prototype.toASN&&e.prototype.fromASN?!0:t(e.prototype):!!(e&&typeof e==`object`&&`toASN`in e&&`fromASN`in e)}function n(e){if(e){let t=Object.getPrototypeOf(e);return t?.prototype?.constructor===Array?!0:n(t)}return!1}function r(e,t){if(!(e&&t)||e.byteLength!==t.byteLength)return!1;let n=new Uint8Array(e),r=new Uint8Array(t);for(let t=0;t<e.byteLength;t++)if(n[t]!==r[t])return!1;return!0}})),bs=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AsnSchemaStorage=void 0;let t=(X(),F(Y)).__importStar(cs()),n=ms(),r=ys();e.AsnSchemaStorage=class{items=new WeakMap;has(e){return this.items.has(e)}get(e,t=!1){let n=this.items.get(e);if(!n)throw Error(`Cannot get schema for '${e.prototype.constructor.name}' target`);if(t&&!n.schema)throw Error(`Schema '${e.prototype.constructor.name}' doesn't contain ASN.1 schema. Call 'AsnSchemaStorage.cache'.`);return n}cache(e){let t=this.get(e);t.schema||=this.create(e,!0)}createDefault(e){let t={type:n.AsnTypeTypes.Sequence,items:{}},r=this.findParentSchema(e);return r&&(Object.assign(t,r),t.items=Object.assign({},t.items,r.items)),t}create(e,i){let a=this.items.get(e)||this.createDefault(e),o=[];for(let e in a.items){let s=a.items[e],c=i?e:``,l;if(typeof s.type==`number`){let e=n.AsnPropTypes[s.type],r=t[e];if(!r)throw Error(`Cannot get ASN1 class by name '${e}'`);l=new r({name:c})}else(0,r.isConvertible)(s.type)?l=new s.type().toSchema(c):s.optional?this.get(s.type).type===n.AsnTypeTypes.Choice?l=new t.Any({name:c}):(l=this.create(s.type,!1),l.name=c):l=new t.Any({name:c});let u=!!s.optional||s.defaultValue!==void 0;if(s.repeated&&(l.name=``,l=new(s.repeated===`set`?t.Set:t.Sequence)({name:``,value:[new t.Repeated({name:c,value:l})]})),s.context!==null&&s.context!==void 0)if(s.implicit)if(typeof s.type==`number`||(0,r.isConvertible)(s.type)){let e=s.repeated?t.Constructed:t.Primitive;o.push(new e({name:c,optional:u,idBlock:{tagClass:3,tagNumber:s.context}}))}else{this.cache(s.type);let e=!!s.repeated,n=e?l:this.get(s.type,!0).schema;n=`valueBlock`in n?n.valueBlock.value:n.value,o.push(new t.Constructed({name:e?``:c,optional:u,idBlock:{tagClass:3,tagNumber:s.context},value:n}))}else o.push(new t.Constructed({optional:u,idBlock:{tagClass:3,tagNumber:s.context},value:[l]}));else l.optional=u,o.push(l)}switch(a.type){case n.AsnTypeTypes.Sequence:return new t.Sequence({value:o,name:``});case n.AsnTypeTypes.Set:return new t.Set({value:o,name:``});case n.AsnTypeTypes.Choice:return new t.Choice({value:o,name:``});default:throw Error(`Unsupported ASN1 type in use`)}}set(e,t){return this.items.set(e,t),this}findParentSchema(e){let t=Object.getPrototypeOf(e);return t?this.items.get(t)||this.findParentSchema(t):null}}})),xs=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.schemaStorage=void 0,e.schemaStorage=new(bs()).AsnSchemaStorage})),Ss=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AsnProp=e.AsnSequenceType=e.AsnSetType=e.AsnChoiceType=e.AsnType=void 0;let t=(X(),F(Y)).__importStar(vs()),n=ms(),r=xs();e.AsnType=e=>t=>{let n;r.schemaStorage.has(t)?n=r.schemaStorage.get(t):(n=r.schemaStorage.createDefault(t),r.schemaStorage.set(t,n)),Object.assign(n,e)},e.AsnChoiceType=()=>(0,e.AsnType)({type:n.AsnTypeTypes.Choice}),e.AsnSetType=t=>(0,e.AsnType)({type:n.AsnTypeTypes.Set,...t}),e.AsnSequenceType=t=>(0,e.AsnType)({type:n.AsnTypeTypes.Sequence,...t}),e.AsnProp=e=>(n,i)=>{let a;r.schemaStorage.has(n.constructor)?a=r.schemaStorage.get(n.constructor):(a=r.schemaStorage.createDefault(n.constructor),r.schemaStorage.set(n.constructor,a));let o=Object.assign({},e);if(typeof o.type==`number`&&!o.converter){let r=t.defaultConverter(e.type);if(!r)throw Error(`Cannot get default converter for property '${i}' of ${n.constructor.name}`);o.converter=r}o.raw=e.raw,a.items[i]=o}})),Cs=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AsnSchemaValidationError=void 0,e.AsnSchemaValidationError=class extends Error{schemas=[]}})),ws=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),(X(),F(Y)).__exportStar(Cs(),e)})),Ts=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AsnParser=void 0;let t=(X(),F(Y)),n=t.__importStar(cs()),r=ps(),i=ms(),a=t.__importStar(vs()),o=ws(),s=ys(),c=xs();e.AsnParser=class{static parse(e,t,i){let a=n.fromBER((0,r.toArrayBuffer)(e),i?.berOptions);if(a.result.error)throw Error(a.result.error);return this.fromASN(a.result,t,i)}static fromASN(e,t,n){try{if((0,s.isConvertible)(t))return new t().fromASN(e);let r=c.schemaStorage.get(t);c.schemaStorage.cache(t);let i=r.schema,a=this.handleChoiceTypes(e,r,t,i,n);if(a?.result)return a.result;a?.targetSchema&&(i=a.targetSchema);let o=this.handleSequenceTypes(e,r,t,i),l=new t;return(0,s.isTypeOfArray)(t)?this.handleArrayTypes(e,r,t,n):(this.processSchemaItems(r,o,l,n),l)}catch(e){throw e instanceof o.AsnSchemaValidationError&&e.schemas.push(t.name),e}}static handleChoiceTypes(e,t,r,a,o){if(e.constructor===n.Constructed&&t.type===i.AsnTypeTypes.Choice&&e.idBlock.tagClass===3)for(let a in t.items){let s=t.items[a];if(s.context===e.idBlock.tagNumber&&s.implicit&&typeof s.type==`function`&&c.schemaStorage.has(s.type)){let t=c.schemaStorage.get(s.type);if(t&&t.type===i.AsnTypeTypes.Sequence){let t=new n.Sequence;if(`value`in e.valueBlock&&Array.isArray(e.valueBlock.value)&&`value`in t.valueBlock){t.valueBlock.value=e.valueBlock.value;let n=this.fromASN(t,s.type,o),i=new r;return i[a]=n,{result:i}}}}}else if(e.constructor===n.Constructed&&t.type!==i.AsnTypeTypes.Choice){let r=new n.Constructed({idBlock:{tagClass:3,tagNumber:e.idBlock.tagNumber},value:t.schema.valueBlock.value});for(let n in t.items)delete e[n];return{targetSchema:r}}return null}static handleSequenceTypes(e,t,r,a){if(t.type===i.AsnTypeTypes.Sequence){let t=n.compareSchema({},e,a);if(!t.verified)throw new o.AsnSchemaValidationError(`Data does not match to ${r.name} ASN1 schema.${t.result.error?` ${t.result.error}`:``}`);return t}else{let t=n.compareSchema({},e,a);if(!t.verified)throw new o.AsnSchemaValidationError(`Data does not match to ${r.name} ASN1 schema.${t.result.error?` ${t.result.error}`:``}`);return t}}static processRepeatedField(e,t,n){let r=e.slice(t);if(r.length===1&&r[0].constructor.name===`Sequence`){let e=r[0];e.valueBlock&&e.valueBlock.value&&Array.isArray(e.valueBlock.value)&&(r=e.valueBlock.value)}if(typeof n.type==`number`){let e=a.defaultConverter(n.type);if(!e)throw Error(`No converter for ASN.1 type ${n.type}`);return r.filter(e=>e&&e.valueBlock).map(t=>{try{return e.fromASN(t)}catch{return}}).filter(e=>e!==void 0)}else return r.filter(e=>e&&e.valueBlock).map(e=>{try{return this.fromASN(e,n.type)}catch{return}}).filter(e=>e!==void 0)}static processPrimitiveField(e,t){let n=a.defaultConverter(t.type);if(!n)throw Error(`No converter for ASN.1 type ${t.type}`);return n.fromASN(e)}static isOptionalChoiceField(e){return e.optional&&typeof e.type==`function`&&c.schemaStorage.has(e.type)&&c.schemaStorage.get(e.type).type===i.AsnTypeTypes.Choice}static processOptionalChoiceField(e,t){try{return{processed:!0,value:this.fromASN(e,t.type)}}catch(e){if(e instanceof o.AsnSchemaValidationError&&/Wrong values for Choice type/.test(e.message))return{processed:!1};throw e}}static handleArrayTypes(e,t,n,r){if(!(`value`in e.valueBlock&&Array.isArray(e.valueBlock.value)))throw Error(`Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed.`);let i=t.itemType;if(typeof i==`number`){let t=a.defaultConverter(i);if(!t)throw Error(`Cannot get default converter for array item of ${n.name} ASN1 schema`);return n.from(e.valueBlock.value,e=>t.fromASN(e))}else return n.from(e.valueBlock.value,e=>this.fromASN(e,i,r))}static processSchemaItems(e,t,n,r){for(let i in e.items){let a=t.result[i];if(!a)continue;let o=e.items[i],c=o.type,l;l=typeof c==`number`||(0,s.isConvertible)(c)?this.processPrimitiveSchemaItem(a,o,c,r):this.processComplexSchemaItem(a,o,c,r),l&&typeof l==`object`&&`value`in l&&`raw`in l?(n[i]=l.value,n[`${i}Raw`]=l.raw):n[i]=l}}static processPrimitiveSchemaItem(e,t,n,r){let i=t.converter??((0,s.isConvertible)(n)?new n:null);if(!i)throw Error(`Converter is empty`);return t.repeated?this.processRepeatedPrimitiveItem(e,t,i,r):this.processSinglePrimitiveItem(e,t,n,i,r)}static processRepeatedPrimitiveItem(e,t,r,i){if(t.implicit){let a=new(t.repeated===`sequence`?n.Sequence:n.Set);a.valueBlock=e.valueBlock;let o=n.fromBER(a.toBER(!1),i?.berOptions);if(o.offset===-1)throw Error(`Cannot parse the child item. ${o.result.error}`);if(!(`value`in o.result.valueBlock&&Array.isArray(o.result.valueBlock.value)))throw Error(`Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed.`);let s=o.result.valueBlock.value;return Array.from(s,e=>r.fromASN(e))}else return Array.from(e,e=>r.fromASN(e))}static processSinglePrimitiveItem(e,t,r,a,o){let c=e;if(t.implicit){let e;if((0,s.isConvertible)(r))e=new r().toSchema(``);else{let t=i.AsnPropTypes[r],a=n[t];if(!a)throw Error(`Cannot get '${t}' class from asn1js module`);e=new a}e.valueBlock=c.valueBlock,c=n.fromBER(e.toBER(!1),o?.berOptions).result}return a.fromASN(c)}static processComplexSchemaItem(e,t,n,r){if(t.repeated){if(!Array.isArray(e))throw Error(`Cannot get list of items from the ASN.1 parsed value. ASN.1 value should be iterable.`);return Array.from(e,e=>this.fromASN(e,n,r))}else{let i=this.handleImplicitTagging(e,t,n);if(this.isOptionalChoiceField(t))try{return this.fromASN(i,n,r)}catch(e){if(e instanceof o.AsnSchemaValidationError&&/Wrong values for Choice type/.test(e.message))return;throw e}else{let a=this.fromASN(i,n,r);return t.raw?{value:a,raw:e.valueBeforeDecodeView}:a}}}static handleImplicitTagging(e,t,r){if(t.implicit&&typeof t.context==`number`){let t=c.schemaStorage.get(r);if(t.type===i.AsnTypeTypes.Sequence){let t=new n.Sequence;if(`value`in e.valueBlock&&Array.isArray(e.valueBlock.value)&&`value`in t.valueBlock)return t.valueBlock.value=e.valueBlock.value,t}else if(t.type===i.AsnTypeTypes.Set){let t=new n.Set;if(`value`in e.valueBlock&&Array.isArray(e.valueBlock.value)&&`value`in t.valueBlock)return t.valueBlock.value=e.valueBlock.value,t}}return e}}})),Es=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AsnSerializer=void 0;let t=(X(),F(Y)),n=t.__importStar(cs()),r=ps(),i=t.__importStar(vs()),a=ms(),o=ys(),s=xs();e.AsnSerializer=class e{static serialize(e){return e instanceof n.BaseBlock?e.toBER(!1):this.toASN(e).toBER(!1)}static toASN(t){if(t&&typeof t==`object`&&(0,o.isConvertible)(t))return t.toASN();if(!(t&&typeof t==`object`))throw TypeError(`Parameter 1 should be type of Object.`);let c=t.constructor,l=s.schemaStorage.get(c);s.schemaStorage.cache(c);let u=[];if(l.itemType){if(!Array.isArray(t))throw TypeError(`Parameter 1 should be type of Array.`);if(typeof l.itemType==`number`){let e=i.defaultConverter(l.itemType);if(!e)throw Error(`Cannot get default converter for array item of ${c.name} ASN1 schema`);u=t.map(t=>e.toASN(t))}else u=t.map(e=>this.toAsnItem({type:l.itemType},`[]`,c,e))}else for(let i in l.items){let a=l.items[i],s=t[i];if(s===void 0||a.defaultValue===s||typeof a.defaultValue==`object`&&typeof s==`object`&&(0,o.isArrayEqual)(this.serialize(a.defaultValue),this.serialize(s)))continue;let d=e.toAsnItem(a,i,c,s);if(typeof a.context==`number`)if(a.implicit)if(!a.repeated&&(typeof a.type==`number`||(0,o.isConvertible)(a.type))){let e={};e.valueHex=d instanceof n.Null?(0,r.toArrayBuffer)(d.valueBeforeDecodeView):d.valueBlock.toBER(),u.push(new n.Primitive({optional:a.optional,idBlock:{tagClass:3,tagNumber:a.context},...e}))}else u.push(new n.Constructed({optional:a.optional,idBlock:{tagClass:3,tagNumber:a.context},value:d.valueBlock.value}));else u.push(new n.Constructed({optional:a.optional,idBlock:{tagClass:3,tagNumber:a.context},value:[d]}));else a.repeated?u=u.concat(d):u.push(d)}let d;switch(l.type){case a.AsnTypeTypes.Sequence:d=new n.Sequence({value:u});break;case a.AsnTypeTypes.Set:d=new n.Set({value:u});break;case a.AsnTypeTypes.Choice:if(!u[0])throw Error(`Schema '${c.name}' has wrong data. Choice cannot be empty.`);d=u[0];break}return d}static toAsnItem(e,t,r,i){let o;if(typeof e.type==`number`){let s=e.converter;if(!s)throw Error(`Property '${t}' doesn't have converter for type ${a.AsnPropTypes[e.type]} in schema '${r.name}'`);if(e.repeated){if(!Array.isArray(i))throw TypeError(`Parameter 'objProp' should be type of Array.`);let t=Array.from(i,e=>s.toASN(e));o=new(e.repeated===`sequence`?n.Sequence:n.Set)({value:t})}else o=s.toASN(i)}else if(e.repeated){if(!Array.isArray(i))throw TypeError(`Parameter 'objProp' should be type of Array.`);let t=Array.from(i,e=>this.toASN(e));o=new(e.repeated===`sequence`?n.Sequence:n.Set)({value:t})}else o=this.toASN(i);return o}}})),Ds=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AsnArray=void 0,e.AsnArray=class extends Array{constructor(e=[]){if(typeof e==`number`)super(e);else{super();for(let t of e)this.push(t)}}}})),Os=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AsnConvert=void 0;let t=(X(),F(Y)).__importStar(cs()),n=ps(),r=Ts(),i=Es();e.AsnConvert=class e{static serialize(e){return i.AsnSerializer.serialize(e)}static parse(e,t,n){return r.AsnParser.parse(e,t,n)}static toString(r,i){let a=(0,n.isBufferSource)(r)?(0,n.toArrayBuffer)(r):e.serialize(r),o=t.fromBER(a,i?.berOptions);if(o.offset===-1)throw Error(`Cannot decode ASN.1 data. ${o.result.error}`);return o.result.toString()}}})),Z=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AsnSerializer=e.AsnParser=e.AsnPropTypes=e.AsnTypeTypes=e.AsnSetType=e.AsnSequenceType=e.AsnChoiceType=e.AsnType=e.AsnProp=void 0;let t=(X(),F(Y));t.__exportStar(vs(),e),t.__exportStar(_s(),e);var n=Ss();Object.defineProperty(e,"AsnProp",{enumerable:!0,get:function(){return n.AsnProp}}),Object.defineProperty(e,"AsnType",{enumerable:!0,get:function(){return n.AsnType}}),Object.defineProperty(e,"AsnChoiceType",{enumerable:!0,get:function(){return n.AsnChoiceType}}),Object.defineProperty(e,"AsnSequenceType",{enumerable:!0,get:function(){return n.AsnSequenceType}}),Object.defineProperty(e,"AsnSetType",{enumerable:!0,get:function(){return n.AsnSetType}});var r=ms();Object.defineProperty(e,"AsnTypeTypes",{enumerable:!0,get:function(){return r.AsnTypeTypes}}),Object.defineProperty(e,"AsnPropTypes",{enumerable:!0,get:function(){return r.AsnPropTypes}});var i=Ts();Object.defineProperty(e,"AsnParser",{enumerable:!0,get:function(){return i.AsnParser}});var a=Es();Object.defineProperty(e,"AsnSerializer",{enumerable:!0,get:function(){return a.AsnSerializer}}),t.__exportStar(ws(),e),t.__exportStar(Ds(),e),t.__exportStar(Os(),e)})),ks=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.binary=void 0,e.encode=n,e.decode=r,e.is=i;let t=ps();function n(e){let n=(0,t.toUint8Array)(e),r=``;for(let e of n)r+=String.fromCharCode(e);return r}function r(e){let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n)&255;return t}function i(e){return typeof e==`string`}e.binary={encode:n,decode:r,is:i}})),As=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.hex=e.formats=void 0,e.normalize=m,e.is=h,e.encode=g,e.decode=_,e.parse=v,e.format=y;let t=ps(),n=/^[0-9a-f]$/i,r=[` `,` `,`
357
- `,`\r`,`:`,`-`,`.`];function i(e){return e.separators===`none`?[]:!e.separators||e.separators===`common`?r:e.separators}function a(e){if(!e)throw TypeError(`Hex separators must be non-empty strings`)}function o(e,t,n){for(let r of n)if(e.startsWith(r,t))return r}function s(e){let t=/[A-F]/.test(e),n=/[a-f]/.test(e);return t&&!n?`upper`:`lower`}function c(e){let t=/\r\n|\n/.exec(e);if(t)return t[0]===`\r
358
- `?`\r
359
- `:`
360
- `}function l(e){return e.replace(/[^0-9a-f]/gi,``)}function u(e){let t=e.match(/[0-9A-Fa-f]+|[^0-9A-Fa-f]+/g)??[];if(t.length<3)return;let n=t.filter((e,t)=>t%2==0),r=t.filter((e,t)=>t%2==1),i=r[0];if(!i||r.some(e=>e!==i)||n.some(e=>e.length===0||e.length%2!=0))return;let a=n[0]?.length??0;if(a&&!n.slice(0,-1).some(e=>e.length!==a)&&!((n[n.length-1]?.length??0)>a))return{size:a/2,separator:i}}function d(e){let t=e.trim(),n=/^0x/i.test(t)?`0x`:``,r=n?t.slice(2):t,i=c(r),a=r.split(/\r\n|\n/).filter(e=>e.length>0),o=u(a[0]?.trim()??``),d={case:s(t),prefix:n};if(o&&(d.group=o),i&&a.length>1){let e=l(a[0]??``).length/2;e>0&&a.slice(0,-1).every(t=>l(t).length/2===e)&&(d.line={bytesPerLine:e,separator:i})}return d}function f(e,t){let r=t.allowPrefix??!0,s=[...i(t)].sort((e,t)=>t.length-e.length);for(let e of s)a(e);let c=e.trim();if(/^0x/i.test(c)){if(!r)throw TypeError(`Hexadecimal text must not include a 0x prefix`);c=c.slice(2)}let l=``,u=!1;for(let e=0;e<c.length;){let r=c[e]??``;if(n.test(r)){l+=r,u=!1,e+=1;continue}let i=o(c,e,s);if(!i)throw TypeError(`Input is not valid hexadecimal text`);if(t.strict&&(u||l.length===0))throw TypeError(`Hexadecimal text contains misplaced separators`);u=!0,e+=i.length}if(t.strict&&u&&l.length>0)throw TypeError(`Hexadecimal text must not end with a separator`);if(l.length%2!=0){if(!t.allowOddLength)throw TypeError(`Hexadecimal text must contain an even number of characters`);l=`0${l}`}return l.toLowerCase()}function p(e,t){if(!t)return e.join(``);if(!Number.isInteger(t.size)||t.size<1)throw RangeError(`Hex group size must be a positive integer`);let n=[];for(let r=0;r<e.length;r+=t.size)n.push(e.slice(r,r+t.size).join(``));return n.join(t.separator)}function m(e,t={}){return f(e,t)}function h(e,t={}){if(typeof e!=`string`)return!1;try{return m(e,t),!0}catch{return!1}}function g(e,n={}){let r=(0,t.toUint8Array)(e),i=n.case??`lower`,a=Array.from(r,e=>{let t=e.toString(16).padStart(2,`0`);return i===`upper`?t.toUpperCase():t}),o=``;if(n.line){let e=n.line.bytesPerLine;if(!Number.isInteger(e)||e<1)throw RangeError(`Hex bytesPerLine must be a positive integer`);let t=n.line.separator??`
361
- `,r=[];for(let t=0;t<a.length;t+=e)r.push(p(a.slice(t,t+e),n.group));o=r.join(t)}else o=p(a,n.group);return`${n.prefix??``}${o}`}function _(e,t={}){let n=m(e,t),r=new Uint8Array(n.length/2);for(let e=0;e<n.length;e+=2)r[e/2]=Number.parseInt(n.slice(e,e+2),16);return r}function v(e,t={}){let n=m(e,t);return{bytes:_(n),format:d(e),normalized:n}}function y(e,t){return g(e,t)}e.formats={compact:Object.freeze({}),upper:Object.freeze({case:`upper`}),colon:Object.freeze({group:{size:1,separator:`:`}}),colonUpper:Object.freeze({case:`upper`,group:{size:1,separator:`:`}}),groupsOf4:Object.freeze({group:{size:4,separator:` `}}),prefixed:Object.freeze({prefix:`0x`})},e.hex={encode:g,decode:_,format:y,formats:e.formats,is:h,normalize:m,parse:v}})),js=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.utf8=void 0,e.encode=n,e.decode=r;let t=ps();function n(e){return new TextEncoder().encode(e)}function r(e){return new TextDecoder(`utf-8`,{fatal:!1}).decode((0,t.toUint8Array)(e))}e.utf8={encode:n,decode:r}})),Ms=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.utf16=void 0,e.encode=n,e.decode=r;let t=ps();function n(e,t={}){let n=new ArrayBuffer(e.length*2),r=new DataView(n);for(let n=0;n<e.length;n++)r.setUint16(n*2,e.charCodeAt(n),t.littleEndian??!1);return new Uint8Array(n)}function r(e,n={}){let r=(0,t.toArrayBuffer)(e),i=new DataView(r),a=``;for(let e=0;e<r.byteLength;e+=2)a+=String.fromCharCode(i.getUint16(e,n.littleEndian??!1));return a}e.utf16={encode:n,decode:r}})),Ns=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.base64=void 0,e.normalize=a,e.pad=o,e.is=s,e.encode=c,e.decode=l;let t=ps(),n=ks(),r=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;function i(){return globalThis.Buffer}function a(e){return e.replace(/[\n\r\t ]/g,``)}function o(e){let t=e.length%4;return t?e+`=`.repeat(4-t):e}function s(e){if(typeof e!=`string`)return!1;let t=a(e);return t===``||r.test(t)}function c(e,r){let a=(0,t.toUint8Array)(e),o=i();return o?o.from(a).toString(`base64`):btoa((0,n.encode)(a))}function l(e,t){let r=a(e);if(!s(r))throw TypeError(`Input is not valid Base64 text`);let o=i();return o?new Uint8Array(o.from(r,`base64`)):(0,n.decode)(atob(r))}e.base64={encode:c,decode:l,is:s,normalize:a,pad:o}})),Ps=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.base64url=void 0,e.normalize=r,e.is=i,e.encode=a,e.decode=o;let t=Ns(),n=/^[A-Za-z0-9_-]*$/;function r(e){return e.replace(/[\n\r\t ]/g,``)}function i(e){return typeof e==`string`&&n.test(r(e))}function a(e,n){return t.base64.encode(e).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/g,``)}function o(e,n){let a=r(e);if(!i(a))throw TypeError(`Input is not valid Base64Url text`);return t.base64.decode(t.base64.pad(a.replace(/-/g,`+`).replace(/_/g,`/`)))}e.base64url={encode:a,decode:o,is:i,normalize:r}})),Fs=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.base64url=e.base64=e.utf16=e.utf8=e.hex=e.binary=void 0;let t=(X(),F(Y));e.binary=t.__importStar(ks()),e.hex=t.__importStar(As()),e.utf8=t.__importStar(js()),e.utf16=t.__importStar(Ms()),e.base64=t.__importStar(Ns()),e.base64url=t.__importStar(Ps())})),Is=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.IpConverter=void 0;let t=Fs();e.IpConverter=class{static isIPv4(e){return/^(\d{1,3}\.){3}\d{1,3}$/.test(e)}static parseIPv4(e){let t=e.split(`.`);if(t.length!==4)throw Error(`Invalid IPv4 address`);return t.map(e=>{let t=parseInt(e,10);if(isNaN(t)||t<0||t>255)throw Error(`Invalid IPv4 address part`);return t})}static parseIPv6(e){let t=this.expandIPv6(e).split(`:`);if(t.length!==8)throw Error(`Invalid IPv6 address`);return t.reduce((e,t)=>{let n=parseInt(t,16);if(isNaN(n)||n<0||n>65535)throw Error(`Invalid IPv6 address part`);return e.push(n>>8&255),e.push(n&255),e},[])}static expandIPv6(e){if(!e.includes(`::`))return e;let t=e.split(`::`);if(t.length>2)throw Error(`Invalid IPv6 address`);let n=t[0]?t[0].split(`:`):[],r=t[1]?t[1].split(`:`):[],i=8-(n.length+r.length);if(i<0)throw Error(`Invalid IPv6 address`);return[...n,...Array(i).fill(`0`),...r].join(`:`)}static formatIPv6(e){let t=[];for(let n=0;n<16;n+=2)t.push((e[n]<<8|e[n+1]).toString(16));return this.compressIPv6(t.join(`:`))}static compressIPv6(e){let t=e.split(`:`),n=-1,r=0,i=-1,a=0;for(let e=0;e<t.length;e++)t[e]===`0`?(i===-1&&(i=e),a++):(a>r&&(n=i,r=a),i=-1,a=0);return a>r&&(n=i,r=a),r>1?`${t.slice(0,n).join(`:`)}::${t.slice(n+r).join(`:`)}`:e}static parseCIDR(e){let[t,n]=e.split(`/`),r=parseInt(n,10);if(this.isIPv4(t)){if(r<0||r>32)throw Error(`Invalid IPv4 prefix length`);return[this.parseIPv4(t),r]}else{if(r<0||r>128)throw Error(`Invalid IPv6 prefix length`);return[this.parseIPv6(t),r]}}static decodeIP(e){if(e.length===64&&parseInt(e,16)===0)return`::/0`;if(e.length!==16)return e;let t=parseInt(e.slice(8),16).toString(2).split(``).reduce((e,t)=>e+ +t,0),n=e.slice(0,8).replace(/(.{2})/g,e=>`${parseInt(e,16)}.`);return n=n.slice(0,-1),`${n}/${t}`}static toString(e){let n=new Uint8Array(e);if(n.length===4)return Array.from(n).join(`.`);if(n.length===16)return this.formatIPv6(n);if(n.length===8||n.length===32){let e=n.length/2,t=n.slice(0,e),r=n.slice(e);if(n.every(e=>e===0))return n.length===8?`0.0.0.0/0`:`::/0`;let i=r.reduce((e,t)=>e+(t.toString(2).match(/1/g)||[]).length,0);return n.length===8?`${Array.from(t).join(`.`)}/${i}`:`${this.formatIPv6(t)}/${i}`}return this.decodeIP(t.hex.encode(e))}static fromString(e){if(e.includes(`/`)){let[t,n]=this.parseCIDR(e),r=new Uint8Array(t.length),i=n;for(let e=0;e<r.length;e++)i>=8?(r[e]=255,i-=8):i>0&&(r[e]=255<<8-i,i=0);let a=new Uint8Array(t.length*2);return a.set(t,0),a.set(r,t.length),a.buffer}let t=this.isIPv4(e)?this.parseIPv4(e):this.parseIPv6(e);return new Uint8Array(t).buffer}}})),Ls=N((e=>{var t,n,r;Object.defineProperty(e,"__esModule",{value:!0}),e.Name=e.RDNSequence=e.RelativeDistinguishedName=e.AttributeTypeAndValue=e.AttributeValue=e.DirectoryString=void 0;let i=(X(),F(Y)),a=Z(),o=Fs(),s=class{teletexString;printableString;universalString;utf8String;bmpString;constructor(e={}){Object.assign(this,e)}toString(){return this.bmpString||this.printableString||this.teletexString||this.universalString||this.utf8String||``}};e.DirectoryString=s,i.__decorate([(0,a.AsnProp)({type:a.AsnPropTypes.TeletexString})],s.prototype,`teletexString`,void 0),i.__decorate([(0,a.AsnProp)({type:a.AsnPropTypes.PrintableString})],s.prototype,`printableString`,void 0),i.__decorate([(0,a.AsnProp)({type:a.AsnPropTypes.UniversalString})],s.prototype,`universalString`,void 0),i.__decorate([(0,a.AsnProp)({type:a.AsnPropTypes.Utf8String})],s.prototype,`utf8String`,void 0),i.__decorate([(0,a.AsnProp)({type:a.AsnPropTypes.BmpString})],s.prototype,`bmpString`,void 0),e.DirectoryString=s=i.__decorate([(0,a.AsnType)({type:a.AsnTypeTypes.Choice})],s);let c=class extends s{ia5String;anyValue;constructor(e={}){super(e),Object.assign(this,e)}toString(){return this.ia5String||(this.anyValue?o.hex.encode(this.anyValue):super.toString())}};e.AttributeValue=c,i.__decorate([(0,a.AsnProp)({type:a.AsnPropTypes.IA5String})],c.prototype,`ia5String`,void 0),i.__decorate([(0,a.AsnProp)({type:a.AsnPropTypes.Any})],c.prototype,`anyValue`,void 0),e.AttributeValue=c=i.__decorate([(0,a.AsnType)({type:a.AsnTypeTypes.Choice})],c);var l=class{type=``;value=new c;constructor(e={}){Object.assign(this,e)}};e.AttributeTypeAndValue=l,i.__decorate([(0,a.AsnProp)({type:a.AsnPropTypes.ObjectIdentifier})],l.prototype,`type`,void 0),i.__decorate([(0,a.AsnProp)({type:c})],l.prototype,`value`,void 0);let u=t=class extends a.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,t.prototype)}};e.RelativeDistinguishedName=u,e.RelativeDistinguishedName=u=t=i.__decorate([(0,a.AsnType)({type:a.AsnTypeTypes.Set,itemType:l})],u);let d=n=class extends a.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype)}};e.RDNSequence=d,e.RDNSequence=d=n=i.__decorate([(0,a.AsnType)({type:a.AsnTypeTypes.Sequence,itemType:u})],d);let f=r=class extends d{constructor(e){super(e),Object.setPrototypeOf(this,r.prototype)}};e.Name=f,e.Name=f=r=i.__decorate([(0,a.AsnType)({type:a.AsnTypeTypes.Sequence})],f)})),Rs=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.GeneralName=e.EDIPartyName=e.OtherName=e.AsnIpConverter=void 0;let t=(X(),F(Y)),n=Z(),r=Is(),i=Ls();e.AsnIpConverter={fromASN:e=>r.IpConverter.toString(n.AsnOctetStringConverter.fromASN(e)),toASN:e=>n.AsnOctetStringConverter.toASN(r.IpConverter.fromString(e))};var a=class{typeId=``;value=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.OtherName=a,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.ObjectIdentifier})],a.prototype,`typeId`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Any,context:0})],a.prototype,`value`,void 0);var o=class{nameAssigner;partyName=new i.DirectoryString;constructor(e={}){Object.assign(this,e)}};e.EDIPartyName=o,t.__decorate([(0,n.AsnProp)({type:i.DirectoryString,optional:!0,context:0,implicit:!0})],o.prototype,`nameAssigner`,void 0),t.__decorate([(0,n.AsnProp)({type:i.DirectoryString,context:1,implicit:!0})],o.prototype,`partyName`,void 0);let s=class{otherName;rfc822Name;dNSName;x400Address;directoryName;ediPartyName;uniformResourceIdentifier;iPAddress;registeredID;constructor(e={}){Object.assign(this,e)}};e.GeneralName=s,t.__decorate([(0,n.AsnProp)({type:a,context:0,implicit:!0})],s.prototype,`otherName`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.IA5String,context:1,implicit:!0})],s.prototype,`rfc822Name`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.IA5String,context:2,implicit:!0})],s.prototype,`dNSName`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Any,context:3,implicit:!0})],s.prototype,`x400Address`,void 0),t.__decorate([(0,n.AsnProp)({type:i.Name,context:4,implicit:!1})],s.prototype,`directoryName`,void 0),t.__decorate([(0,n.AsnProp)({type:o,context:5})],s.prototype,`ediPartyName`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.IA5String,context:6,implicit:!0})],s.prototype,`uniformResourceIdentifier`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.OctetString,context:7,implicit:!0,converter:e.AsnIpConverter})],s.prototype,`iPAddress`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.ObjectIdentifier,context:8,implicit:!0})],s.prototype,`registeredID`,void 0),e.GeneralName=s=t.__decorate([(0,n.AsnType)({type:n.AsnTypeTypes.Choice})],s)})),Q=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.id_ce=e.id_ad_caRepository=e.id_ad_timeStamping=e.id_ad_caIssuers=e.id_ad_ocsp=e.id_qt_unotice=e.id_qt_csp=e.id_ad=e.id_kp=e.id_qt=e.id_pe=e.id_pkix=void 0,e.id_pkix=`1.3.6.1.5.5.7`,e.id_pe=`${e.id_pkix}.1`,e.id_qt=`${e.id_pkix}.2`,e.id_kp=`${e.id_pkix}.3`,e.id_ad=`${e.id_pkix}.48`,e.id_qt_csp=`${e.id_qt}.1`,e.id_qt_unotice=`${e.id_qt}.2`,e.id_ad_ocsp=`${e.id_ad}.1`,e.id_ad_caIssuers=`${e.id_ad}.2`,e.id_ad_timeStamping=`${e.id_ad}.3`,e.id_ad_caRepository=`${e.id_ad}.5`,e.id_ce=`2.5.29`})),zs=N((e=>{var t;Object.defineProperty(e,"__esModule",{value:!0}),e.AuthorityInfoAccessSyntax=e.AccessDescription=e.id_pe_authorityInfoAccess=void 0;let n=(X(),F(Y)),r=Z(),i=Rs();e.id_pe_authorityInfoAccess=`${Q().id_pe}.1`;var a=class{accessMethod=``;accessLocation=new i.GeneralName;constructor(e={}){Object.assign(this,e)}};e.AccessDescription=a,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.ObjectIdentifier})],a.prototype,`accessMethod`,void 0),n.__decorate([(0,r.AsnProp)({type:i.GeneralName})],a.prototype,`accessLocation`,void 0);let o=t=class extends r.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,t.prototype)}};e.AuthorityInfoAccessSyntax=o,e.AuthorityInfoAccessSyntax=o=t=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Sequence,itemType:a})],o)})),Bs=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AuthorityKeyIdentifier=e.KeyIdentifier=e.id_ce_authorityKeyIdentifier=void 0;let t=(X(),F(Y)),n=Z(),r=Rs();e.id_ce_authorityKeyIdentifier=`${Q().id_ce}.35`;var i=class extends n.OctetString{};e.KeyIdentifier=i;var a=class{keyIdentifier;authorityCertIssuer;authorityCertSerialNumber;constructor(e={}){e&&Object.assign(this,e)}};e.AuthorityKeyIdentifier=a,t.__decorate([(0,n.AsnProp)({type:i,context:0,optional:!0,implicit:!0})],a.prototype,`keyIdentifier`,void 0),t.__decorate([(0,n.AsnProp)({type:r.GeneralName,context:1,optional:!0,implicit:!0,repeated:`sequence`})],a.prototype,`authorityCertIssuer`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer,context:2,optional:!0,implicit:!0,converter:n.AsnIntegerArrayBufferConverter})],a.prototype,`authorityCertSerialNumber`,void 0)})),Vs=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.BasicConstraints=e.id_ce_basicConstraints=void 0;let t=(X(),F(Y)),n=Z();e.id_ce_basicConstraints=`${Q().id_ce}.19`;var r=class{cA=!1;pathLenConstraint;constructor(e={}){Object.assign(this,e)}};e.BasicConstraints=r,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Boolean,defaultValue:!1})],r.prototype,`cA`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer,optional:!0})],r.prototype,`pathLenConstraint`,void 0)})),Hs=N((e=>{var t;Object.defineProperty(e,"__esModule",{value:!0}),e.GeneralNames=void 0;let n=(X(),F(Y)),r=Z(),i=Rs(),a=t=class extends r.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,t.prototype)}};e.GeneralNames=a,e.GeneralNames=a=t=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Sequence,itemType:i.GeneralName})],a)})),Us=N((e=>{var t;Object.defineProperty(e,"__esModule",{value:!0}),e.CertificateIssuer=e.id_ce_certificateIssuer=void 0;let n=(X(),F(Y)),r=Z(),i=Hs();e.id_ce_certificateIssuer=`${Q().id_ce}.29`;let a=t=class extends i.GeneralNames{constructor(e){super(e),Object.setPrototypeOf(this,t.prototype)}};e.CertificateIssuer=a,e.CertificateIssuer=a=t=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Sequence})],a)})),Ws=N((e=>{var t;Object.defineProperty(e,"__esModule",{value:!0}),e.CertificatePolicies=e.PolicyInformation=e.PolicyQualifierInfo=e.Qualifier=e.UserNotice=e.NoticeReference=e.DisplayText=e.id_ce_certificatePolicies_anyPolicy=e.id_ce_certificatePolicies=void 0;let n=(X(),F(Y)),r=Z();e.id_ce_certificatePolicies=`${Q().id_ce}.32`,e.id_ce_certificatePolicies_anyPolicy=`${e.id_ce_certificatePolicies}.0`;let i=class{ia5String;visibleString;bmpString;utf8String;constructor(e={}){Object.assign(this,e)}toString(){return this.ia5String||this.visibleString||this.bmpString||this.utf8String||``}};e.DisplayText=i,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.IA5String})],i.prototype,`ia5String`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.VisibleString})],i.prototype,`visibleString`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.BmpString})],i.prototype,`bmpString`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Utf8String})],i.prototype,`utf8String`,void 0),e.DisplayText=i=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Choice})],i);var a=class{organization=new i;noticeNumbers=[];constructor(e={}){Object.assign(this,e)}};e.NoticeReference=a,n.__decorate([(0,r.AsnProp)({type:i})],a.prototype,`organization`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer,repeated:`sequence`})],a.prototype,`noticeNumbers`,void 0);var o=class{noticeRef;explicitText;constructor(e={}){Object.assign(this,e)}};e.UserNotice=o,n.__decorate([(0,r.AsnProp)({type:a,optional:!0})],o.prototype,`noticeRef`,void 0),n.__decorate([(0,r.AsnProp)({type:i,optional:!0})],o.prototype,`explicitText`,void 0);let s=class{cPSuri;userNotice;constructor(e={}){Object.assign(this,e)}};e.Qualifier=s,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.IA5String})],s.prototype,`cPSuri`,void 0),n.__decorate([(0,r.AsnProp)({type:o})],s.prototype,`userNotice`,void 0),e.Qualifier=s=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Choice})],s);var c=class{policyQualifierId=``;qualifier=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.PolicyQualifierInfo=c,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.ObjectIdentifier})],c.prototype,`policyQualifierId`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Any})],c.prototype,`qualifier`,void 0);var l=class{policyIdentifier=``;policyQualifiers;constructor(e={}){Object.assign(this,e)}};e.PolicyInformation=l,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.ObjectIdentifier})],l.prototype,`policyIdentifier`,void 0),n.__decorate([(0,r.AsnProp)({type:c,repeated:`sequence`,optional:!0})],l.prototype,`policyQualifiers`,void 0);let u=t=class extends r.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,t.prototype)}};e.CertificatePolicies=u,e.CertificatePolicies=u=t=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Sequence,itemType:l})],u)})),Gs=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.CRLNumber=e.id_ce_cRLNumber=void 0;let t=(X(),F(Y)),n=Z();e.id_ce_cRLNumber=`${Q().id_ce}.20`;let r=class{value;constructor(e=0){this.value=e}};e.CRLNumber=r,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer})],r.prototype,`value`,void 0),e.CRLNumber=r=t.__decorate([(0,n.AsnType)({type:n.AsnTypeTypes.Choice})],r)})),Ks=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.BaseCRLNumber=e.id_ce_deltaCRLIndicator=void 0;let t=(X(),F(Y)),n=Z(),r=Q(),i=Gs();e.id_ce_deltaCRLIndicator=`${r.id_ce}.27`;let a=class extends i.CRLNumber{};e.BaseCRLNumber=a,e.BaseCRLNumber=a=t.__decorate([(0,n.AsnType)({type:n.AsnTypeTypes.Choice})],a)})),qs=N((e=>{var t;Object.defineProperty(e,"__esModule",{value:!0}),e.CRLDistributionPoints=e.DistributionPoint=e.DistributionPointName=e.Reason=e.ReasonFlags=e.id_ce_cRLDistributionPoints=void 0;let n=(X(),F(Y)),r=Z(),i=Ls(),a=Rs();e.id_ce_cRLDistributionPoints=`${Q().id_ce}.31`;var o;(function(e){e[e.unused=1]=`unused`,e[e.keyCompromise=2]=`keyCompromise`,e[e.cACompromise=4]=`cACompromise`,e[e.affiliationChanged=8]=`affiliationChanged`,e[e.superseded=16]=`superseded`,e[e.cessationOfOperation=32]=`cessationOfOperation`,e[e.certificateHold=64]=`certificateHold`,e[e.privilegeWithdrawn=128]=`privilegeWithdrawn`,e[e.aACompromise=256]=`aACompromise`})(o||(e.ReasonFlags=o={}));var s=class extends r.BitString{toJSON(){let e=[],t=this.toNumber();return t&o.aACompromise&&e.push(`aACompromise`),t&o.affiliationChanged&&e.push(`affiliationChanged`),t&o.cACompromise&&e.push(`cACompromise`),t&o.certificateHold&&e.push(`certificateHold`),t&o.cessationOfOperation&&e.push(`cessationOfOperation`),t&o.keyCompromise&&e.push(`keyCompromise`),t&o.privilegeWithdrawn&&e.push(`privilegeWithdrawn`),t&o.superseded&&e.push(`superseded`),t&o.unused&&e.push(`unused`),e}toString(){return`[${this.toJSON().join(`, `)}]`}};e.Reason=s;let c=class{fullName;nameRelativeToCRLIssuer;constructor(e={}){Object.assign(this,e)}};e.DistributionPointName=c,n.__decorate([(0,r.AsnProp)({type:a.GeneralName,context:0,repeated:`sequence`,implicit:!0})],c.prototype,`fullName`,void 0),n.__decorate([(0,r.AsnProp)({type:i.RelativeDistinguishedName,context:1,implicit:!0})],c.prototype,`nameRelativeToCRLIssuer`,void 0),e.DistributionPointName=c=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Choice})],c);var l=class{distributionPoint;reasons;cRLIssuer;constructor(e={}){Object.assign(this,e)}};e.DistributionPoint=l,n.__decorate([(0,r.AsnProp)({type:c,context:0,optional:!0})],l.prototype,`distributionPoint`,void 0),n.__decorate([(0,r.AsnProp)({type:s,context:1,optional:!0,implicit:!0})],l.prototype,`reasons`,void 0),n.__decorate([(0,r.AsnProp)({type:a.GeneralName,context:2,optional:!0,repeated:`sequence`,implicit:!0})],l.prototype,`cRLIssuer`,void 0);let u=t=class extends r.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,t.prototype)}};e.CRLDistributionPoints=u,e.CRLDistributionPoints=u=t=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Sequence,itemType:l})],u)})),Js=N((e=>{var t;Object.defineProperty(e,"__esModule",{value:!0}),e.FreshestCRL=e.id_ce_freshestCRL=void 0;let n=(X(),F(Y)),r=Z(),i=Q(),a=qs();e.id_ce_freshestCRL=`${i.id_ce}.46`;let o=t=class extends a.CRLDistributionPoints{constructor(e){super(e),Object.setPrototypeOf(this,t.prototype)}};e.FreshestCRL=o,e.FreshestCRL=o=t=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Sequence,itemType:a.DistributionPoint})],o)})),Ys=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.IssuingDistributionPoint=e.id_ce_issuingDistributionPoint=void 0;let t=(X(),F(Y)),n=Z(),r=Q(),i=qs();e.id_ce_issuingDistributionPoint=`${r.id_ce}.28`;var a=class e{static ONLY=!1;distributionPoint;onlyContainsUserCerts=e.ONLY;onlyContainsCACerts=e.ONLY;onlySomeReasons;indirectCRL=e.ONLY;onlyContainsAttributeCerts=e.ONLY;constructor(e={}){Object.assign(this,e)}};e.IssuingDistributionPoint=a,t.__decorate([(0,n.AsnProp)({type:i.DistributionPointName,context:0,optional:!0})],a.prototype,`distributionPoint`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Boolean,context:1,defaultValue:a.ONLY,implicit:!0})],a.prototype,`onlyContainsUserCerts`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Boolean,context:2,defaultValue:a.ONLY,implicit:!0})],a.prototype,`onlyContainsCACerts`,void 0),t.__decorate([(0,n.AsnProp)({type:i.Reason,context:3,optional:!0,implicit:!0})],a.prototype,`onlySomeReasons`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Boolean,context:4,defaultValue:a.ONLY,implicit:!0})],a.prototype,`indirectCRL`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Boolean,context:5,defaultValue:a.ONLY,implicit:!0})],a.prototype,`onlyContainsAttributeCerts`,void 0)})),Xs=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.CRLReason=e.CRLReasons=e.id_ce_cRLReasons=void 0;let t=(X(),F(Y)),n=Z();e.id_ce_cRLReasons=`${Q().id_ce}.21`;var r;(function(e){e[e.unspecified=0]=`unspecified`,e[e.keyCompromise=1]=`keyCompromise`,e[e.cACompromise=2]=`cACompromise`,e[e.affiliationChanged=3]=`affiliationChanged`,e[e.superseded=4]=`superseded`,e[e.cessationOfOperation=5]=`cessationOfOperation`,e[e.certificateHold=6]=`certificateHold`,e[e.removeFromCRL=8]=`removeFromCRL`,e[e.privilegeWithdrawn=9]=`privilegeWithdrawn`,e[e.aACompromise=10]=`aACompromise`})(r||(e.CRLReasons=r={}));let i=class{reason=r.unspecified;constructor(e=r.unspecified){this.reason=e}toJSON(){return r[this.reason]}toString(){return this.toJSON()}};e.CRLReason=i,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Enumerated})],i.prototype,`reason`,void 0),e.CRLReason=i=t.__decorate([(0,n.AsnType)({type:n.AsnTypeTypes.Choice})],i)})),Zs=N((e=>{var t;Object.defineProperty(e,"__esModule",{value:!0}),e.id_kp_OCSPSigning=e.id_kp_timeStamping=e.id_kp_emailProtection=e.id_kp_codeSigning=e.id_kp_clientAuth=e.id_kp_serverAuth=e.anyExtendedKeyUsage=e.ExtendedKeyUsage=e.id_ce_extKeyUsage=void 0;let n=(X(),F(Y)),r=Z(),i=Q();e.id_ce_extKeyUsage=`${i.id_ce}.37`;let a=t=class extends r.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,t.prototype)}};e.ExtendedKeyUsage=a,e.ExtendedKeyUsage=a=t=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Sequence,itemType:r.AsnPropTypes.ObjectIdentifier})],a),e.anyExtendedKeyUsage=`${e.id_ce_extKeyUsage}.0`,e.id_kp_serverAuth=`${i.id_kp}.1`,e.id_kp_clientAuth=`${i.id_kp}.2`,e.id_kp_codeSigning=`${i.id_kp}.3`,e.id_kp_emailProtection=`${i.id_kp}.4`,e.id_kp_timeStamping=`${i.id_kp}.8`,e.id_kp_OCSPSigning=`${i.id_kp}.9`})),Qs=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.InhibitAnyPolicy=e.id_ce_inhibitAnyPolicy=void 0;let t=(X(),F(Y)),n=Z();e.id_ce_inhibitAnyPolicy=`${Q().id_ce}.54`;let r=class{value;constructor(e=new ArrayBuffer(0)){this.value=e}};e.InhibitAnyPolicy=r,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer,converter:n.AsnIntegerArrayBufferConverter})],r.prototype,`value`,void 0),e.InhibitAnyPolicy=r=t.__decorate([(0,n.AsnType)({type:n.AsnTypeTypes.Choice})],r)})),$s=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.InvalidityDate=e.id_ce_invalidityDate=void 0;let t=(X(),F(Y)),n=Z();e.id_ce_invalidityDate=`${Q().id_ce}.24`;let r=class{value=new Date;constructor(e){e&&(this.value=e)}};e.InvalidityDate=r,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.GeneralizedTime})],r.prototype,`value`,void 0),e.InvalidityDate=r=t.__decorate([(0,n.AsnType)({type:n.AsnTypeTypes.Choice})],r)})),ec=N((e=>{var t;Object.defineProperty(e,"__esModule",{value:!0}),e.IssueAlternativeName=e.id_ce_issuerAltName=void 0;let n=(X(),F(Y)),r=Z(),i=Hs();e.id_ce_issuerAltName=`${Q().id_ce}.18`;let a=t=class extends i.GeneralNames{constructor(e){super(e),Object.setPrototypeOf(this,t.prototype)}};e.IssueAlternativeName=a,e.IssueAlternativeName=a=t=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Sequence})],a)})),tc=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.KeyUsage=e.KeyUsageFlags=e.id_ce_keyUsage=void 0;let t=Z();e.id_ce_keyUsage=`${Q().id_ce}.15`;var n;(function(e){e[e.digitalSignature=1]=`digitalSignature`,e[e.nonRepudiation=2]=`nonRepudiation`,e[e.keyEncipherment=4]=`keyEncipherment`,e[e.dataEncipherment=8]=`dataEncipherment`,e[e.keyAgreement=16]=`keyAgreement`,e[e.keyCertSign=32]=`keyCertSign`,e[e.cRLSign=64]=`cRLSign`,e[e.encipherOnly=128]=`encipherOnly`,e[e.decipherOnly=256]=`decipherOnly`})(n||(e.KeyUsageFlags=n={})),e.KeyUsage=class extends t.BitString{toJSON(){let e=this.toNumber(),t=[];return e&n.cRLSign&&t.push(`crlSign`),e&n.dataEncipherment&&t.push(`dataEncipherment`),e&n.decipherOnly&&t.push(`decipherOnly`),e&n.digitalSignature&&t.push(`digitalSignature`),e&n.encipherOnly&&t.push(`encipherOnly`),e&n.keyAgreement&&t.push(`keyAgreement`),e&n.keyCertSign&&t.push(`keyCertSign`),e&n.keyEncipherment&&t.push(`keyEncipherment`),e&n.nonRepudiation&&t.push(`nonRepudiation`),t}toString(){return`[${this.toJSON().join(`, `)}]`}}})),nc=N((e=>{var t;Object.defineProperty(e,"__esModule",{value:!0}),e.NameConstraints=e.GeneralSubtrees=e.GeneralSubtree=e.id_ce_nameConstraints=void 0;let n=(X(),F(Y)),r=Z(),i=Rs();e.id_ce_nameConstraints=`${Q().id_ce}.30`;var a=class{base=new i.GeneralName;minimum=0;maximum;constructor(e={}){Object.assign(this,e)}};e.GeneralSubtree=a,n.__decorate([(0,r.AsnProp)({type:i.GeneralName})],a.prototype,`base`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer,context:0,defaultValue:0,implicit:!0})],a.prototype,`minimum`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer,context:1,optional:!0,implicit:!0})],a.prototype,`maximum`,void 0);let o=t=class extends r.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,t.prototype)}};e.GeneralSubtrees=o,e.GeneralSubtrees=o=t=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Sequence,itemType:a})],o);var s=class{permittedSubtrees;excludedSubtrees;constructor(e={}){Object.assign(this,e)}};e.NameConstraints=s,n.__decorate([(0,r.AsnProp)({type:o,context:0,optional:!0,implicit:!0})],s.prototype,`permittedSubtrees`,void 0),n.__decorate([(0,r.AsnProp)({type:o,context:1,optional:!0,implicit:!0})],s.prototype,`excludedSubtrees`,void 0)})),rc=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.PolicyConstraints=e.id_ce_policyConstraints=void 0;let t=(X(),F(Y)),n=Z();e.id_ce_policyConstraints=`${Q().id_ce}.36`;var r=class{requireExplicitPolicy;inhibitPolicyMapping;constructor(e={}){Object.assign(this,e)}};e.PolicyConstraints=r,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer,context:0,implicit:!0,optional:!0,converter:n.AsnIntegerArrayBufferConverter})],r.prototype,`requireExplicitPolicy`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer,context:1,implicit:!0,optional:!0,converter:n.AsnIntegerArrayBufferConverter})],r.prototype,`inhibitPolicyMapping`,void 0)})),ic=N((e=>{var t;Object.defineProperty(e,"__esModule",{value:!0}),e.PolicyMappings=e.PolicyMapping=e.id_ce_policyMappings=void 0;let n=(X(),F(Y)),r=Z();e.id_ce_policyMappings=`${Q().id_ce}.33`;var i=class{issuerDomainPolicy=``;subjectDomainPolicy=``;constructor(e={}){Object.assign(this,e)}};e.PolicyMapping=i,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.ObjectIdentifier})],i.prototype,`issuerDomainPolicy`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.ObjectIdentifier})],i.prototype,`subjectDomainPolicy`,void 0);let a=t=class extends r.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,t.prototype)}};e.PolicyMappings=a,e.PolicyMappings=a=t=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Sequence,itemType:i})],a)})),ac=N((e=>{var t;Object.defineProperty(e,"__esModule",{value:!0}),e.SubjectAlternativeName=e.id_ce_subjectAltName=void 0;let n=(X(),F(Y)),r=Z(),i=Hs();e.id_ce_subjectAltName=`${Q().id_ce}.17`;let a=t=class extends i.GeneralNames{constructor(e){super(e),Object.setPrototypeOf(this,t.prototype)}};e.SubjectAlternativeName=a,e.SubjectAlternativeName=a=t=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Sequence})],a)})),oc=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Attribute=void 0;let t=(X(),F(Y)),n=Z();var r=class{type=``;values=[];constructor(e={}){Object.assign(this,e)}};e.Attribute=r,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.ObjectIdentifier})],r.prototype,`type`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Any,repeated:`set`})],r.prototype,`values`,void 0)})),sc=N((e=>{var t;Object.defineProperty(e,"__esModule",{value:!0}),e.SubjectDirectoryAttributes=e.id_ce_subjectDirectoryAttributes=void 0;let n=(X(),F(Y)),r=Z(),i=oc();e.id_ce_subjectDirectoryAttributes=`${Q().id_ce}.9`;let a=t=class extends r.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,t.prototype)}};e.SubjectDirectoryAttributes=a,e.SubjectDirectoryAttributes=a=t=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Sequence,itemType:i.Attribute})],a)})),cc=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SubjectKeyIdentifier=e.id_ce_subjectKeyIdentifier=void 0;let t=Q(),n=Bs();e.id_ce_subjectKeyIdentifier=`${t.id_ce}.14`,e.SubjectKeyIdentifier=class extends n.KeyIdentifier{}})),lc=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.PrivateKeyUsagePeriod=e.id_ce_privateKeyUsagePeriod=void 0;let t=(X(),F(Y)),n=Z();e.id_ce_privateKeyUsagePeriod=`${Q().id_ce}.16`;var r=class{notBefore;notAfter;constructor(e={}){Object.assign(this,e)}};e.PrivateKeyUsagePeriod=r,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.GeneralizedTime,context:0,implicit:!0,optional:!0})],r.prototype,`notBefore`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.GeneralizedTime,context:1,implicit:!0,optional:!0})],r.prototype,`notAfter`,void 0)})),uc=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.EntrustVersionInfo=e.EntrustInfo=e.EntrustInfoFlags=e.id_entrust_entrustVersInfo=void 0;let t=(X(),F(Y)),n=Z();e.id_entrust_entrustVersInfo=`1.2.840.113533.7.65.0`;var r;(function(e){e[e.keyUpdateAllowed=1]=`keyUpdateAllowed`,e[e.newExtensions=2]=`newExtensions`,e[e.pKIXCertificate=4]=`pKIXCertificate`})(r||(e.EntrustInfoFlags=r={}));var i=class extends n.BitString{toJSON(){let e=[],t=this.toNumber();return t&r.pKIXCertificate&&e.push(`pKIXCertificate`),t&r.newExtensions&&e.push(`newExtensions`),t&r.keyUpdateAllowed&&e.push(`keyUpdateAllowed`),e}toString(){return`[${this.toJSON().join(`, `)}]`}};e.EntrustInfo=i;var a=class{entrustVers=``;entrustInfoFlags=new i;constructor(e={}){Object.assign(this,e)}};e.EntrustVersionInfo=a,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.GeneralString})],a.prototype,`entrustVers`,void 0),t.__decorate([(0,n.AsnProp)({type:i})],a.prototype,`entrustInfoFlags`,void 0)})),dc=N((e=>{var t;Object.defineProperty(e,"__esModule",{value:!0}),e.SubjectInfoAccessSyntax=e.id_pe_subjectInfoAccess=void 0;let n=(X(),F(Y)),r=Z(),i=Q(),a=zs();e.id_pe_subjectInfoAccess=`${i.id_pe}.11`;let o=t=class extends r.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,t.prototype)}};e.SubjectInfoAccessSyntax=o,e.SubjectInfoAccessSyntax=o=t=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Sequence,itemType:a.AccessDescription})],o)})),fc=N((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=(X(),F(Y));t.__exportStar(zs(),e),t.__exportStar(Bs(),e),t.__exportStar(Vs(),e),t.__exportStar(Us(),e),t.__exportStar(Ws(),e),t.__exportStar(Ks(),e),t.__exportStar(qs(),e),t.__exportStar(Js(),e),t.__exportStar(Ys(),e),t.__exportStar(Gs(),e),t.__exportStar(Xs(),e),t.__exportStar(Zs(),e),t.__exportStar(Qs(),e),t.__exportStar($s(),e),t.__exportStar(ec(),e),t.__exportStar(tc(),e),t.__exportStar(nc(),e),t.__exportStar(rc(),e),t.__exportStar(ic(),e),t.__exportStar(ac(),e),t.__exportStar(sc(),e),t.__exportStar(cc(),e),t.__exportStar(lc(),e),t.__exportStar(uc(),e),t.__exportStar(dc(),e)})),pc=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AlgorithmIdentifier=void 0;let t=(X(),F(Y)),n=Z(),r=ps();var i=class e{algorithm=``;parameters;constructor(e={}){Object.assign(this,e)}isEqual(t){return t instanceof e&&t.algorithm==this.algorithm&&(t.parameters&&this.parameters&&(0,r.equal)(t.parameters,this.parameters)||t.parameters===this.parameters)}};e.AlgorithmIdentifier=i,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.ObjectIdentifier})],i.prototype,`algorithm`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Any,optional:!0})],i.prototype,`parameters`,void 0)})),mc=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SubjectPublicKeyInfo=void 0;let t=(X(),F(Y)),n=Z(),r=pc();var i=class{algorithm=new r.AlgorithmIdentifier;subjectPublicKey=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.SubjectPublicKeyInfo=i,t.__decorate([(0,n.AsnProp)({type:r.AlgorithmIdentifier})],i.prototype,`algorithm`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.BitString})],i.prototype,`subjectPublicKey`,void 0)})),hc=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Time=void 0;let t=(X(),F(Y)),n=Z(),r=class{utcTime;generalTime;constructor(e){if(e)if(typeof e==`string`||typeof e==`number`||e instanceof Date){let t=new Date(e);t.setMilliseconds(0),t.getUTCFullYear()>2049?this.generalTime=t:this.utcTime=t}else Object.assign(this,e)}getTime(){let e=this.utcTime||this.generalTime;if(!e)throw Error(`Cannot get time from CHOICE object`);return e}};e.Time=r,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.UTCTime})],r.prototype,`utcTime`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.GeneralizedTime})],r.prototype,`generalTime`,void 0),e.Time=r=t.__decorate([(0,n.AsnType)({type:n.AsnTypeTypes.Choice})],r)})),gc=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Validity=void 0;let t=(X(),F(Y)),n=Z(),r=hc();var i=class{notBefore=new r.Time(new Date);notAfter=new r.Time(new Date);constructor(e){e&&(this.notBefore=new r.Time(e.notBefore),this.notAfter=new r.Time(e.notAfter))}};e.Validity=i,t.__decorate([(0,n.AsnProp)({type:r.Time})],i.prototype,`notBefore`,void 0),t.__decorate([(0,n.AsnProp)({type:r.Time})],i.prototype,`notAfter`,void 0)})),_c=N((e=>{var t;Object.defineProperty(e,"__esModule",{value:!0}),e.Extensions=e.Extension=void 0;let n=(X(),F(Y)),r=Z();var i=class e{static CRITICAL=!1;extnID=``;critical=e.CRITICAL;extnValue=new r.OctetString;constructor(e={}){Object.assign(this,e)}};e.Extension=i,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.ObjectIdentifier})],i.prototype,`extnID`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Boolean,defaultValue:i.CRITICAL})],i.prototype,`critical`,void 0),n.__decorate([(0,r.AsnProp)({type:r.OctetString})],i.prototype,`extnValue`,void 0);let a=t=class extends r.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,t.prototype)}};e.Extensions=a,e.Extensions=a=t=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Sequence,itemType:i})],a)})),vc=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Version=void 0;var t;(function(e){e[e.v1=0]=`v1`,e[e.v2=1]=`v2`,e[e.v3=2]=`v3`})(t||(e.Version=t={}))})),yc=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.TBSCertificate=void 0;let t=(X(),F(Y)),n=Z(),r=pc(),i=Ls(),a=mc(),o=gc(),s=_c(),c=vc();var l=class{version=c.Version.v1;serialNumber=new ArrayBuffer(0);signature=new r.AlgorithmIdentifier;issuer=new i.Name;validity=new o.Validity;subject=new i.Name;subjectPublicKeyInfo=new a.SubjectPublicKeyInfo;issuerUniqueID;subjectUniqueID;extensions;constructor(e={}){Object.assign(this,e)}};e.TBSCertificate=l,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer,context:0,defaultValue:c.Version.v1})],l.prototype,`version`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer,converter:n.AsnIntegerArrayBufferConverter})],l.prototype,`serialNumber`,void 0),t.__decorate([(0,n.AsnProp)({type:r.AlgorithmIdentifier})],l.prototype,`signature`,void 0),t.__decorate([(0,n.AsnProp)({type:i.Name})],l.prototype,`issuer`,void 0),t.__decorate([(0,n.AsnProp)({type:o.Validity})],l.prototype,`validity`,void 0),t.__decorate([(0,n.AsnProp)({type:i.Name})],l.prototype,`subject`,void 0),t.__decorate([(0,n.AsnProp)({type:a.SubjectPublicKeyInfo})],l.prototype,`subjectPublicKeyInfo`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.BitString,context:1,implicit:!0,optional:!0})],l.prototype,`issuerUniqueID`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.BitString,context:2,implicit:!0,optional:!0})],l.prototype,`subjectUniqueID`,void 0),t.__decorate([(0,n.AsnProp)({type:s.Extensions,context:3,optional:!0})],l.prototype,`extensions`,void 0)})),bc=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Certificate=void 0;let t=(X(),F(Y)),n=Z(),r=pc(),i=yc();var a=class{tbsCertificate=new i.TBSCertificate;tbsCertificateRaw;signatureAlgorithm=new r.AlgorithmIdentifier;signatureValue=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.Certificate=a,t.__decorate([(0,n.AsnProp)({type:i.TBSCertificate,raw:!0})],a.prototype,`tbsCertificate`,void 0),t.__decorate([(0,n.AsnProp)({type:r.AlgorithmIdentifier})],a.prototype,`signatureAlgorithm`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.BitString})],a.prototype,`signatureValue`,void 0)})),xc=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.TBSCertList=e.RevokedCertificate=void 0;let t=(X(),F(Y)),n=Z(),r=pc(),i=Ls(),a=hc(),o=_c();var s=class{userCertificate=new ArrayBuffer(0);revocationDate=new a.Time;crlEntryExtensions;constructor(e={}){Object.assign(this,e)}};e.RevokedCertificate=s,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer,converter:n.AsnIntegerArrayBufferConverter})],s.prototype,`userCertificate`,void 0),t.__decorate([(0,n.AsnProp)({type:a.Time})],s.prototype,`revocationDate`,void 0),t.__decorate([(0,n.AsnProp)({type:o.Extension,optional:!0,repeated:`sequence`})],s.prototype,`crlEntryExtensions`,void 0);var c=class{version;signature=new r.AlgorithmIdentifier;issuer=new i.Name;thisUpdate=new a.Time;nextUpdate;revokedCertificates;crlExtensions;constructor(e={}){Object.assign(this,e)}};e.TBSCertList=c,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer,optional:!0})],c.prototype,`version`,void 0),t.__decorate([(0,n.AsnProp)({type:r.AlgorithmIdentifier})],c.prototype,`signature`,void 0),t.__decorate([(0,n.AsnProp)({type:i.Name})],c.prototype,`issuer`,void 0),t.__decorate([(0,n.AsnProp)({type:a.Time})],c.prototype,`thisUpdate`,void 0),t.__decorate([(0,n.AsnProp)({type:a.Time,optional:!0})],c.prototype,`nextUpdate`,void 0),t.__decorate([(0,n.AsnProp)({type:s,repeated:`sequence`,optional:!0})],c.prototype,`revokedCertificates`,void 0),t.__decorate([(0,n.AsnProp)({type:o.Extension,optional:!0,context:0,repeated:`sequence`})],c.prototype,`crlExtensions`,void 0)})),Sc=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.CertificateList=void 0;let t=(X(),F(Y)),n=Z(),r=pc(),i=xc();var a=class{tbsCertList=new i.TBSCertList;tbsCertListRaw;signatureAlgorithm=new r.AlgorithmIdentifier;signature=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.CertificateList=a,t.__decorate([(0,n.AsnProp)({type:i.TBSCertList,raw:!0})],a.prototype,`tbsCertList`,void 0),t.__decorate([(0,n.AsnProp)({type:r.AlgorithmIdentifier})],a.prototype,`signatureAlgorithm`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.BitString})],a.prototype,`signature`,void 0)})),$=N((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=(X(),F(Y));t.__exportStar(fc(),e),t.__exportStar(pc(),e),t.__exportStar(oc(),e),t.__exportStar(bc(),e),t.__exportStar(Sc(),e),t.__exportStar(_c(),e),t.__exportStar(Rs(),e),t.__exportStar(Hs(),e),t.__exportStar(Ls(),e),t.__exportStar(Q(),e),t.__exportStar(mc(),e),t.__exportStar(xc(),e),t.__exportStar(yc(),e),t.__exportStar(hc(),e),t.__exportStar(vc(),e),t.__exportStar(gc(),e)})),Cc=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.IssuerAndSerialNumber=void 0;let t=(X(),F(Y)),n=Z(),r=$();var i=class{issuer=new r.Name;serialNumber=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.IssuerAndSerialNumber=i,t.__decorate([(0,n.AsnProp)({type:r.Name})],i.prototype,`issuer`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer,converter:n.AsnIntegerArrayBufferConverter})],i.prototype,`serialNumber`,void 0)})),wc=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SignerIdentifier=void 0;let t=(X(),F(Y)),n=Z(),r=$(),i=Cc(),a=class{subjectKeyIdentifier;issuerAndSerialNumber;constructor(e={}){Object.assign(this,e)}};e.SignerIdentifier=a,t.__decorate([(0,n.AsnProp)({type:r.SubjectKeyIdentifier,context:0,implicit:!0})],a.prototype,`subjectKeyIdentifier`,void 0),t.__decorate([(0,n.AsnProp)({type:i.IssuerAndSerialNumber})],a.prototype,`issuerAndSerialNumber`,void 0),e.SignerIdentifier=a=t.__decorate([(0,n.AsnType)({type:n.AsnTypeTypes.Choice})],a)})),Tc=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.KeyDerivationAlgorithmIdentifier=e.MessageAuthenticationCodeAlgorithm=e.ContentEncryptionAlgorithmIdentifier=e.KeyEncryptionAlgorithmIdentifier=e.SignatureAlgorithmIdentifier=e.DigestAlgorithmIdentifier=e.CMSVersion=void 0;let t=(X(),F(Y)),n=$(),r=Z();var i;(function(e){e[e.v0=0]=`v0`,e[e.v1=1]=`v1`,e[e.v2=2]=`v2`,e[e.v3=3]=`v3`,e[e.v4=4]=`v4`,e[e.v5=5]=`v5`})(i||(e.CMSVersion=i={}));let a=class extends n.AlgorithmIdentifier{};e.DigestAlgorithmIdentifier=a,e.DigestAlgorithmIdentifier=a=t.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Sequence})],a);let o=class extends n.AlgorithmIdentifier{};e.SignatureAlgorithmIdentifier=o,e.SignatureAlgorithmIdentifier=o=t.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Sequence})],o);let s=class extends n.AlgorithmIdentifier{};e.KeyEncryptionAlgorithmIdentifier=s,e.KeyEncryptionAlgorithmIdentifier=s=t.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Sequence})],s);let c=class extends n.AlgorithmIdentifier{};e.ContentEncryptionAlgorithmIdentifier=c,e.ContentEncryptionAlgorithmIdentifier=c=t.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Sequence})],c);let l=class extends n.AlgorithmIdentifier{};e.MessageAuthenticationCodeAlgorithm=l,e.MessageAuthenticationCodeAlgorithm=l=t.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Sequence})],l);let u=class extends n.AlgorithmIdentifier{};e.KeyDerivationAlgorithmIdentifier=u,e.KeyDerivationAlgorithmIdentifier=u=t.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Sequence})],u)})),Ec=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Attribute=void 0;let t=(X(),F(Y)),n=Z();var r=class{attrType=``;attrValues=[];constructor(e={}){Object.assign(this,e)}};e.Attribute=r,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.ObjectIdentifier})],r.prototype,`attrType`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Any,repeated:`set`})],r.prototype,`attrValues`,void 0)})),Dc=N((e=>{var t;Object.defineProperty(e,"__esModule",{value:!0}),e.SignerInfos=e.SignerInfo=void 0;let n=(X(),F(Y)),r=Z(),i=wc(),a=Tc(),o=Ec();var s=class{version=a.CMSVersion.v0;sid=new i.SignerIdentifier;digestAlgorithm=new a.DigestAlgorithmIdentifier;signedAttrs;signedAttrsRaw;signatureAlgorithm=new a.SignatureAlgorithmIdentifier;signature=new r.OctetString;unsignedAttrs;constructor(e={}){Object.assign(this,e)}};e.SignerInfo=s,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer})],s.prototype,`version`,void 0),n.__decorate([(0,r.AsnProp)({type:i.SignerIdentifier})],s.prototype,`sid`,void 0),n.__decorate([(0,r.AsnProp)({type:a.DigestAlgorithmIdentifier})],s.prototype,`digestAlgorithm`,void 0),n.__decorate([(0,r.AsnProp)({type:o.Attribute,repeated:`set`,context:0,implicit:!0,optional:!0,raw:!0})],s.prototype,`signedAttrs`,void 0),n.__decorate([(0,r.AsnProp)({type:a.SignatureAlgorithmIdentifier})],s.prototype,`signatureAlgorithm`,void 0),n.__decorate([(0,r.AsnProp)({type:r.OctetString})],s.prototype,`signature`,void 0),n.__decorate([(0,r.AsnProp)({type:o.Attribute,repeated:`set`,context:1,implicit:!0,optional:!0})],s.prototype,`unsignedAttrs`,void 0);let c=t=class extends r.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,t.prototype)}};e.SignerInfos=c,e.SignerInfos=c=t=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Set,itemType:s})],c)})),Oc=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.CounterSignature=e.id_counterSignature=void 0;let t=(X(),F(Y)),n=Z(),r=Dc();e.id_counterSignature=`1.2.840.113549.1.9.6`;let i=class extends r.SignerInfo{};e.CounterSignature=i,e.CounterSignature=i=t.__decorate([(0,n.AsnType)({type:n.AsnTypeTypes.Sequence})],i)})),kc=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.MessageDigest=e.id_messageDigest=void 0;let t=Z();e.id_messageDigest=`1.2.840.113549.1.9.4`,e.MessageDigest=class extends t.OctetString{}})),Ac=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SigningTime=e.id_signingTime=void 0;let t=(X(),F(Y)),n=$(),r=Z();e.id_signingTime=`1.2.840.113549.1.9.5`;let i=class extends n.Time{};e.SigningTime=i,e.SigningTime=i=t.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Choice})],i)})),jc=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.id_contentType=void 0;let t=(X(),F(Y));t.__exportStar(Oc(),e),t.__exportStar(kc(),e),t.__exportStar(Ac(),e),e.id_contentType=`1.2.840.113549.1.9.3`})),Mc=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ACClearAttrs=void 0;let t=(X(),F(Y)),n=Z(),r=$();var i=class{acIssuer=new r.GeneralName;acSerial=0;attrs=[];constructor(e={}){Object.assign(this,e)}};e.ACClearAttrs=i,t.__decorate([(0,n.AsnProp)({type:r.GeneralName})],i.prototype,`acIssuer`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer})],i.prototype,`acSerial`,void 0),t.__decorate([(0,n.AsnProp)({type:r.Attribute,repeated:`sequence`})],i.prototype,`attrs`,void 0)})),Nc=N((e=>{var t;Object.defineProperty(e,"__esModule",{value:!0}),e.AttrSpec=void 0;let n=(X(),F(Y)),r=Z(),i=t=class extends r.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,t.prototype)}};e.AttrSpec=i,e.AttrSpec=i=t=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Sequence,itemType:r.AsnPropTypes.ObjectIdentifier})],i)})),Pc=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AAControls=void 0;let t=(X(),F(Y)),n=Z(),r=Nc();var i=class{pathLenConstraint;permittedAttrs;excludedAttrs;permitUnSpecified=!0;constructor(e={}){Object.assign(this,e)}};e.AAControls=i,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer,optional:!0})],i.prototype,`pathLenConstraint`,void 0),t.__decorate([(0,n.AsnProp)({type:r.AttrSpec,implicit:!0,context:0,optional:!0})],i.prototype,`permittedAttrs`,void 0),t.__decorate([(0,n.AsnProp)({type:r.AttrSpec,implicit:!0,context:1,optional:!0})],i.prototype,`excludedAttrs`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Boolean,defaultValue:!0})],i.prototype,`permitUnSpecified`,void 0)})),Fc=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.IssuerSerial=void 0;let t=(X(),F(Y)),n=Z(),r=$();var i=class{issuer=new r.GeneralNames;serial=new ArrayBuffer(0);issuerUID=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.IssuerSerial=i,t.__decorate([(0,n.AsnProp)({type:r.GeneralNames})],i.prototype,`issuer`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer,converter:n.AsnIntegerArrayBufferConverter})],i.prototype,`serial`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.BitString,optional:!0})],i.prototype,`issuerUID`,void 0)})),Ic=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ObjectDigestInfo=e.DigestedObjectType=void 0;let t=(X(),F(Y)),n=Z(),r=$();var i;(function(e){e[e.publicKey=0]=`publicKey`,e[e.publicKeyCert=1]=`publicKeyCert`,e[e.otherObjectTypes=2]=`otherObjectTypes`})(i||(e.DigestedObjectType=i={}));var a=class{digestedObjectType=i.publicKey;otherObjectTypeID;digestAlgorithm=new r.AlgorithmIdentifier;objectDigest=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.ObjectDigestInfo=a,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Enumerated})],a.prototype,`digestedObjectType`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.ObjectIdentifier,optional:!0})],a.prototype,`otherObjectTypeID`,void 0),t.__decorate([(0,n.AsnProp)({type:r.AlgorithmIdentifier})],a.prototype,`digestAlgorithm`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.BitString})],a.prototype,`objectDigest`,void 0)})),Lc=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.V2Form=void 0;let t=(X(),F(Y)),n=Z(),r=$(),i=Fc(),a=Ic();var o=class{issuerName;baseCertificateID;objectDigestInfo;constructor(e={}){Object.assign(this,e)}};e.V2Form=o,t.__decorate([(0,n.AsnProp)({type:r.GeneralNames,optional:!0})],o.prototype,`issuerName`,void 0),t.__decorate([(0,n.AsnProp)({type:i.IssuerSerial,context:0,implicit:!0,optional:!0})],o.prototype,`baseCertificateID`,void 0),t.__decorate([(0,n.AsnProp)({type:a.ObjectDigestInfo,context:1,implicit:!0,optional:!0})],o.prototype,`objectDigestInfo`,void 0)})),Rc=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AttCertIssuer=void 0;let t=(X(),F(Y)),n=Z(),r=$(),i=Lc(),a=class{v1Form;v2Form;constructor(e={}){Object.assign(this,e)}};e.AttCertIssuer=a,t.__decorate([(0,n.AsnProp)({type:r.GeneralName,repeated:`sequence`})],a.prototype,`v1Form`,void 0),t.__decorate([(0,n.AsnProp)({type:i.V2Form,context:0,implicit:!0})],a.prototype,`v2Form`,void 0),e.AttCertIssuer=a=t.__decorate([(0,n.AsnType)({type:n.AsnTypeTypes.Choice})],a)})),zc=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AttCertValidityPeriod=void 0;let t=(X(),F(Y)),n=Z();var r=class{notBeforeTime=new Date;notAfterTime=new Date;constructor(e={}){Object.assign(this,e)}};e.AttCertValidityPeriod=r,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.GeneralizedTime})],r.prototype,`notBeforeTime`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.GeneralizedTime})],r.prototype,`notAfterTime`,void 0)})),Bc=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Holder=void 0;let t=(X(),F(Y)),n=Z(),r=$(),i=Fc(),a=Ic();var o=class{baseCertificateID;entityName;objectDigestInfo;constructor(e={}){Object.assign(this,e)}};e.Holder=o,t.__decorate([(0,n.AsnProp)({type:i.IssuerSerial,implicit:!0,context:0,optional:!0})],o.prototype,`baseCertificateID`,void 0),t.__decorate([(0,n.AsnProp)({type:r.GeneralNames,implicit:!0,context:1,optional:!0})],o.prototype,`entityName`,void 0),t.__decorate([(0,n.AsnProp)({type:a.ObjectDigestInfo,implicit:!0,context:2,optional:!0})],o.prototype,`objectDigestInfo`,void 0)})),Vc=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AttributeCertificateInfo=e.AttCertVersion=void 0;let t=(X(),F(Y)),n=Z(),r=$(),i=Bc(),a=Rc(),o=zc();var s;(function(e){e[e.v2=1]=`v2`})(s||(e.AttCertVersion=s={}));var c=class{version=s.v2;holder=new i.Holder;issuer=new a.AttCertIssuer;signature=new r.AlgorithmIdentifier;serialNumber=new ArrayBuffer(0);attrCertValidityPeriod=new o.AttCertValidityPeriod;attributes=[];issuerUniqueID;extensions;constructor(e={}){Object.assign(this,e)}};e.AttributeCertificateInfo=c,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer})],c.prototype,`version`,void 0),t.__decorate([(0,n.AsnProp)({type:i.Holder})],c.prototype,`holder`,void 0),t.__decorate([(0,n.AsnProp)({type:a.AttCertIssuer})],c.prototype,`issuer`,void 0),t.__decorate([(0,n.AsnProp)({type:r.AlgorithmIdentifier})],c.prototype,`signature`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer,converter:n.AsnIntegerArrayBufferConverter})],c.prototype,`serialNumber`,void 0),t.__decorate([(0,n.AsnProp)({type:o.AttCertValidityPeriod})],c.prototype,`attrCertValidityPeriod`,void 0),t.__decorate([(0,n.AsnProp)({type:r.Attribute,repeated:`sequence`})],c.prototype,`attributes`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.BitString,optional:!0})],c.prototype,`issuerUniqueID`,void 0),t.__decorate([(0,n.AsnProp)({type:r.Extensions,optional:!0})],c.prototype,`extensions`,void 0)})),Hc=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AttributeCertificate=void 0;let t=(X(),F(Y)),n=Z(),r=$(),i=Vc();var a=class{acinfo=new i.AttributeCertificateInfo;signatureAlgorithm=new r.AlgorithmIdentifier;signatureValue=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.AttributeCertificate=a,t.__decorate([(0,n.AsnProp)({type:i.AttributeCertificateInfo})],a.prototype,`acinfo`,void 0),t.__decorate([(0,n.AsnProp)({type:r.AlgorithmIdentifier})],a.prototype,`signatureAlgorithm`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.BitString})],a.prototype,`signatureValue`,void 0)})),Uc=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ClassList=e.ClassListFlags=void 0;let t=Z();var n;(function(e){e[e.unmarked=1]=`unmarked`,e[e.unclassified=2]=`unclassified`,e[e.restricted=4]=`restricted`,e[e.confidential=8]=`confidential`,e[e.secret=16]=`secret`,e[e.topSecret=32]=`topSecret`})(n||(e.ClassListFlags=n={})),e.ClassList=class extends t.BitString{}})),Wc=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SecurityCategory=void 0;let t=(X(),F(Y)),n=Z();var r=class{type=``;value=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.SecurityCategory=r,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.ObjectIdentifier,implicit:!0,context:0})],r.prototype,`type`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Any,implicit:!0,context:1})],r.prototype,`value`,void 0)})),Gc=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Clearance=void 0;let t=(X(),F(Y)),n=Z(),r=Uc(),i=Wc();var a=class{policyId=``;classList=new r.ClassList(r.ClassListFlags.unclassified);securityCategories;constructor(e={}){Object.assign(this,e)}};e.Clearance=a,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.ObjectIdentifier})],a.prototype,`policyId`,void 0),t.__decorate([(0,n.AsnProp)({type:r.ClassList,defaultValue:new r.ClassList(r.ClassListFlags.unclassified)})],a.prototype,`classList`,void 0),t.__decorate([(0,n.AsnProp)({type:i.SecurityCategory,repeated:`set`})],a.prototype,`securityCategories`,void 0)})),Kc=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.IetfAttrSyntax=e.IetfAttrSyntaxValueChoices=void 0;let t=(X(),F(Y)),n=Z(),r=$();var i=class{cotets;oid;string;constructor(e={}){Object.assign(this,e)}};e.IetfAttrSyntaxValueChoices=i,t.__decorate([(0,n.AsnProp)({type:n.OctetString})],i.prototype,`cotets`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.ObjectIdentifier})],i.prototype,`oid`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Utf8String})],i.prototype,`string`,void 0);var a=class{policyAuthority;values=[];constructor(e={}){Object.assign(this,e)}};e.IetfAttrSyntax=a,t.__decorate([(0,n.AsnProp)({type:r.GeneralNames,implicit:!0,context:0,optional:!0})],a.prototype,`policyAuthority`,void 0),t.__decorate([(0,n.AsnProp)({type:i,repeated:`sequence`})],a.prototype,`values`,void 0)})),qc=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.id_at_clearance=e.id_at_role=e.id_at=e.id_aca_encAttrs=e.id_aca_group=e.id_aca_chargingIdentity=e.id_aca_accessIdentity=e.id_aca_authenticationInfo=e.id_aca=e.id_ce_targetInformation=e.id_pe_ac_proxying=e.id_pe_aaControls=e.id_pe_ac_auditIdentity=void 0;let t=$();e.id_pe_ac_auditIdentity=`${t.id_pe}.4`,e.id_pe_aaControls=`${t.id_pe}.6`,e.id_pe_ac_proxying=`${t.id_pe}.10`,e.id_ce_targetInformation=`${t.id_ce}.55`,e.id_aca=`${t.id_pkix}.10`,e.id_aca_authenticationInfo=`${e.id_aca}.1`,e.id_aca_accessIdentity=`${e.id_aca}.2`,e.id_aca_chargingIdentity=`${e.id_aca}.3`,e.id_aca_group=`${e.id_aca}.4`,e.id_aca_encAttrs=`${e.id_aca}.6`,e.id_at=`2.5.4`,e.id_at_role=`${e.id_at}.72`,e.id_at_clearance=`2.5.1.5.55`})),Jc=N((e=>{var t;Object.defineProperty(e,"__esModule",{value:!0}),e.Targets=e.Target=e.TargetCert=void 0;let n=(X(),F(Y)),r=Z(),i=$(),a=Fc(),o=Ic();var s=class{targetCertificate=new a.IssuerSerial;targetName;certDigestInfo;constructor(e={}){Object.assign(this,e)}};e.TargetCert=s,n.__decorate([(0,r.AsnProp)({type:a.IssuerSerial})],s.prototype,`targetCertificate`,void 0),n.__decorate([(0,r.AsnProp)({type:i.GeneralName,optional:!0})],s.prototype,`targetName`,void 0),n.__decorate([(0,r.AsnProp)({type:o.ObjectDigestInfo,optional:!0})],s.prototype,`certDigestInfo`,void 0);let c=class{targetName;targetGroup;targetCert;constructor(e={}){Object.assign(this,e)}};e.Target=c,n.__decorate([(0,r.AsnProp)({type:i.GeneralName,context:0,implicit:!0})],c.prototype,`targetName`,void 0),n.__decorate([(0,r.AsnProp)({type:i.GeneralName,context:1,implicit:!0})],c.prototype,`targetGroup`,void 0),n.__decorate([(0,r.AsnProp)({type:s,context:2,implicit:!0})],c.prototype,`targetCert`,void 0),e.Target=c=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Choice})],c);let l=t=class extends r.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,t.prototype)}};e.Targets=l,e.Targets=l=t=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Sequence,itemType:c})],l)})),Yc=N((e=>{var t;Object.defineProperty(e,"__esModule",{value:!0}),e.ProxyInfo=void 0;let n=(X(),F(Y)),r=Z(),i=Jc(),a=t=class extends r.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,t.prototype)}};e.ProxyInfo=a,e.ProxyInfo=a=t=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Sequence,itemType:i.Targets})],a)})),Xc=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.RoleSyntax=void 0;let t=(X(),F(Y)),n=Z(),r=$();var i=class{roleAuthority;roleName;constructor(e={}){Object.assign(this,e)}};e.RoleSyntax=i,t.__decorate([(0,n.AsnProp)({type:r.GeneralNames,implicit:!0,context:0,optional:!0})],i.prototype,`roleAuthority`,void 0),t.__decorate([(0,n.AsnProp)({type:r.GeneralName,implicit:!0,context:1})],i.prototype,`roleName`,void 0)})),Zc=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SvceAuthInfo=void 0;let t=(X(),F(Y)),n=Z(),r=$();var i=class{service=new r.GeneralName;ident=new r.GeneralName;authInfo;constructor(e={}){Object.assign(this,e)}};e.SvceAuthInfo=i,t.__decorate([(0,n.AsnProp)({type:r.GeneralName})],i.prototype,`service`,void 0),t.__decorate([(0,n.AsnProp)({type:r.GeneralName})],i.prototype,`ident`,void 0),t.__decorate([(0,n.AsnProp)({type:n.OctetString,optional:!0})],i.prototype,`authInfo`,void 0)})),Qc=N((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=(X(),F(Y));t.__exportStar(Mc(),e),t.__exportStar(Pc(),e),t.__exportStar(Rc(),e),t.__exportStar(zc(),e),t.__exportStar(Nc(),e),t.__exportStar(Hc(),e),t.__exportStar(Vc(),e),t.__exportStar(Uc(),e),t.__exportStar(Gc(),e),t.__exportStar(Bc(),e),t.__exportStar(Kc(),e),t.__exportStar(Fc(),e),t.__exportStar(Ic(),e),t.__exportStar(qc(),e),t.__exportStar(Yc(),e),t.__exportStar(Xc(),e),t.__exportStar(Wc(),e),t.__exportStar(Zc(),e),t.__exportStar(Jc(),e),t.__exportStar(Lc(),e)})),$c=N((e=>{var t;Object.defineProperty(e,"__esModule",{value:!0}),e.CertificateSet=e.CertificateChoices=e.OtherCertificateFormat=void 0;let n=(X(),F(Y)),r=Z(),i=$(),a=Qc();var o=class{otherCertFormat=``;otherCert=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.OtherCertificateFormat=o,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.ObjectIdentifier})],o.prototype,`otherCertFormat`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Any})],o.prototype,`otherCert`,void 0);let s=class{certificate;v2AttrCert;other;constructor(e={}){Object.assign(this,e)}};e.CertificateChoices=s,n.__decorate([(0,r.AsnProp)({type:i.Certificate})],s.prototype,`certificate`,void 0),n.__decorate([(0,r.AsnProp)({type:a.AttributeCertificate,context:2,implicit:!0})],s.prototype,`v2AttrCert`,void 0),n.__decorate([(0,r.AsnProp)({type:o,context:3,implicit:!0})],s.prototype,`other`,void 0),e.CertificateChoices=s=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Choice})],s);let c=t=class extends r.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,t.prototype)}};e.CertificateSet=c,e.CertificateSet=c=t=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Set,itemType:s})],c)})),el=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ContentInfo=void 0;let t=(X(),F(Y)),n=Z();var r=class{contentType=``;content=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.ContentInfo=r,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.ObjectIdentifier})],r.prototype,`contentType`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Any,context:0})],r.prototype,`content`,void 0)})),tl=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.EncapsulatedContentInfo=e.EncapsulatedContent=void 0;let t=(X(),F(Y)),n=Z(),r=class{single;any;constructor(e={}){Object.assign(this,e)}};e.EncapsulatedContent=r,t.__decorate([(0,n.AsnProp)({type:n.OctetString})],r.prototype,`single`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Any})],r.prototype,`any`,void 0),e.EncapsulatedContent=r=t.__decorate([(0,n.AsnType)({type:n.AsnTypeTypes.Choice})],r);var i=class{eContentType=``;eContent;constructor(e={}){Object.assign(this,e)}};e.EncapsulatedContentInfo=i,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.ObjectIdentifier})],i.prototype,`eContentType`,void 0),t.__decorate([(0,n.AsnProp)({type:r,context:0,optional:!0})],i.prototype,`eContent`,void 0)})),nl=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.EncryptedContentInfo=e.EncryptedContent=void 0;let t=(X(),F(Y)),n=Z(),r=Tc(),i=class{value;constructedValue;constructor(e={}){Object.assign(this,e)}};e.EncryptedContent=i,t.__decorate([(0,n.AsnProp)({type:n.OctetString,context:0,implicit:!0,optional:!0})],i.prototype,`value`,void 0),t.__decorate([(0,n.AsnProp)({type:n.OctetString,converter:n.AsnConstructedOctetStringConverter,context:0,implicit:!0,optional:!0,repeated:`sequence`})],i.prototype,`constructedValue`,void 0),e.EncryptedContent=i=t.__decorate([(0,n.AsnType)({type:n.AsnTypeTypes.Choice})],i);var a=class{contentType=``;contentEncryptionAlgorithm=new r.ContentEncryptionAlgorithmIdentifier;encryptedContent;constructor(e={}){Object.assign(this,e)}};e.EncryptedContentInfo=a,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.ObjectIdentifier})],a.prototype,`contentType`,void 0),t.__decorate([(0,n.AsnProp)({type:r.ContentEncryptionAlgorithmIdentifier})],a.prototype,`contentEncryptionAlgorithm`,void 0),t.__decorate([(0,n.AsnProp)({type:i,optional:!0})],a.prototype,`encryptedContent`,void 0)})),rl=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.OtherKeyAttribute=void 0;let t=(X(),F(Y)),n=Z();var r=class{keyAttrId=``;keyAttr;constructor(e={}){Object.assign(this,e)}};e.OtherKeyAttribute=r,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.ObjectIdentifier})],r.prototype,`keyAttrId`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Any,optional:!0})],r.prototype,`keyAttr`,void 0)})),il=N((e=>{var t;Object.defineProperty(e,"__esModule",{value:!0}),e.KeyAgreeRecipientInfo=e.OriginatorIdentifierOrKey=e.OriginatorPublicKey=e.RecipientEncryptedKeys=e.RecipientEncryptedKey=e.KeyAgreeRecipientIdentifier=e.RecipientKeyIdentifier=void 0;let n=(X(),F(Y)),r=Z(),i=$(),a=Tc(),o=Cc(),s=rl();var c=class{subjectKeyIdentifier=new i.SubjectKeyIdentifier;date;other;constructor(e={}){Object.assign(this,e)}};e.RecipientKeyIdentifier=c,n.__decorate([(0,r.AsnProp)({type:i.SubjectKeyIdentifier})],c.prototype,`subjectKeyIdentifier`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.GeneralizedTime,optional:!0})],c.prototype,`date`,void 0),n.__decorate([(0,r.AsnProp)({type:s.OtherKeyAttribute,optional:!0})],c.prototype,`other`,void 0);let l=class{rKeyId;issuerAndSerialNumber;constructor(e={}){Object.assign(this,e)}};e.KeyAgreeRecipientIdentifier=l,n.__decorate([(0,r.AsnProp)({type:c,context:0,implicit:!0,optional:!0})],l.prototype,`rKeyId`,void 0),n.__decorate([(0,r.AsnProp)({type:o.IssuerAndSerialNumber,optional:!0})],l.prototype,`issuerAndSerialNumber`,void 0),e.KeyAgreeRecipientIdentifier=l=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Choice})],l);var u=class{rid=new l;encryptedKey=new r.OctetString;constructor(e={}){Object.assign(this,e)}};e.RecipientEncryptedKey=u,n.__decorate([(0,r.AsnProp)({type:l})],u.prototype,`rid`,void 0),n.__decorate([(0,r.AsnProp)({type:r.OctetString})],u.prototype,`encryptedKey`,void 0);let d=t=class extends r.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,t.prototype)}};e.RecipientEncryptedKeys=d,e.RecipientEncryptedKeys=d=t=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Sequence,itemType:u})],d);var f=class{algorithm=new i.AlgorithmIdentifier;publicKey=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.OriginatorPublicKey=f,n.__decorate([(0,r.AsnProp)({type:i.AlgorithmIdentifier})],f.prototype,`algorithm`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.BitString})],f.prototype,`publicKey`,void 0);let p=class{subjectKeyIdentifier;originatorKey;issuerAndSerialNumber;constructor(e={}){Object.assign(this,e)}};e.OriginatorIdentifierOrKey=p,n.__decorate([(0,r.AsnProp)({type:i.SubjectKeyIdentifier,context:0,implicit:!0,optional:!0})],p.prototype,`subjectKeyIdentifier`,void 0),n.__decorate([(0,r.AsnProp)({type:f,context:1,implicit:!0,optional:!0})],p.prototype,`originatorKey`,void 0),n.__decorate([(0,r.AsnProp)({type:o.IssuerAndSerialNumber,optional:!0})],p.prototype,`issuerAndSerialNumber`,void 0),e.OriginatorIdentifierOrKey=p=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Choice})],p);var m=class{version=a.CMSVersion.v3;originator=new p;ukm;keyEncryptionAlgorithm=new a.KeyEncryptionAlgorithmIdentifier;recipientEncryptedKeys=new d;constructor(e={}){Object.assign(this,e)}};e.KeyAgreeRecipientInfo=m,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer})],m.prototype,`version`,void 0),n.__decorate([(0,r.AsnProp)({type:p,context:0})],m.prototype,`originator`,void 0),n.__decorate([(0,r.AsnProp)({type:r.OctetString,context:1,optional:!0})],m.prototype,`ukm`,void 0),n.__decorate([(0,r.AsnProp)({type:a.KeyEncryptionAlgorithmIdentifier})],m.prototype,`keyEncryptionAlgorithm`,void 0),n.__decorate([(0,r.AsnProp)({type:d})],m.prototype,`recipientEncryptedKeys`,void 0)})),al=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.KeyTransRecipientInfo=e.RecipientIdentifier=void 0;let t=(X(),F(Y)),n=Z(),r=$(),i=Tc(),a=Cc(),o=class{subjectKeyIdentifier;issuerAndSerialNumber;constructor(e={}){Object.assign(this,e)}};e.RecipientIdentifier=o,t.__decorate([(0,n.AsnProp)({type:r.SubjectKeyIdentifier,context:0,implicit:!0})],o.prototype,`subjectKeyIdentifier`,void 0),t.__decorate([(0,n.AsnProp)({type:a.IssuerAndSerialNumber})],o.prototype,`issuerAndSerialNumber`,void 0),e.RecipientIdentifier=o=t.__decorate([(0,n.AsnType)({type:n.AsnTypeTypes.Choice})],o);var s=class{version=i.CMSVersion.v0;rid=new o;keyEncryptionAlgorithm=new i.KeyEncryptionAlgorithmIdentifier;encryptedKey=new n.OctetString;constructor(e={}){Object.assign(this,e)}};e.KeyTransRecipientInfo=s,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer})],s.prototype,`version`,void 0),t.__decorate([(0,n.AsnProp)({type:o})],s.prototype,`rid`,void 0),t.__decorate([(0,n.AsnProp)({type:i.KeyEncryptionAlgorithmIdentifier})],s.prototype,`keyEncryptionAlgorithm`,void 0),t.__decorate([(0,n.AsnProp)({type:n.OctetString})],s.prototype,`encryptedKey`,void 0)})),ol=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.KEKRecipientInfo=e.KEKIdentifier=void 0;let t=(X(),F(Y)),n=Z(),r=rl(),i=Tc();var a=class{keyIdentifier=new n.OctetString;date;other;constructor(e={}){Object.assign(this,e)}};e.KEKIdentifier=a,t.__decorate([(0,n.AsnProp)({type:n.OctetString})],a.prototype,`keyIdentifier`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.GeneralizedTime,optional:!0})],a.prototype,`date`,void 0),t.__decorate([(0,n.AsnProp)({type:r.OtherKeyAttribute,optional:!0})],a.prototype,`other`,void 0);var o=class{version=i.CMSVersion.v4;kekid=new a;keyEncryptionAlgorithm=new i.KeyEncryptionAlgorithmIdentifier;encryptedKey=new n.OctetString;constructor(e={}){Object.assign(this,e)}};e.KEKRecipientInfo=o,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer})],o.prototype,`version`,void 0),t.__decorate([(0,n.AsnProp)({type:a})],o.prototype,`kekid`,void 0),t.__decorate([(0,n.AsnProp)({type:i.KeyEncryptionAlgorithmIdentifier})],o.prototype,`keyEncryptionAlgorithm`,void 0),t.__decorate([(0,n.AsnProp)({type:n.OctetString})],o.prototype,`encryptedKey`,void 0)})),sl=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.PasswordRecipientInfo=void 0;let t=(X(),F(Y)),n=Z(),r=Tc();var i=class{version=r.CMSVersion.v0;keyDerivationAlgorithm;keyEncryptionAlgorithm=new r.KeyEncryptionAlgorithmIdentifier;encryptedKey=new n.OctetString;constructor(e={}){Object.assign(this,e)}};e.PasswordRecipientInfo=i,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer})],i.prototype,`version`,void 0),t.__decorate([(0,n.AsnProp)({type:r.KeyDerivationAlgorithmIdentifier,context:0,optional:!0})],i.prototype,`keyDerivationAlgorithm`,void 0),t.__decorate([(0,n.AsnProp)({type:r.KeyEncryptionAlgorithmIdentifier})],i.prototype,`keyEncryptionAlgorithm`,void 0),t.__decorate([(0,n.AsnProp)({type:n.OctetString})],i.prototype,`encryptedKey`,void 0)})),cl=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.RecipientInfo=e.OtherRecipientInfo=void 0;let t=(X(),F(Y)),n=Z(),r=il(),i=al(),a=ol(),o=sl();var s=class{oriType=``;oriValue=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.OtherRecipientInfo=s,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.ObjectIdentifier})],s.prototype,`oriType`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Any})],s.prototype,`oriValue`,void 0);let c=class{ktri;kari;kekri;pwri;ori;constructor(e={}){Object.assign(this,e)}};e.RecipientInfo=c,t.__decorate([(0,n.AsnProp)({type:i.KeyTransRecipientInfo,optional:!0})],c.prototype,`ktri`,void 0),t.__decorate([(0,n.AsnProp)({type:r.KeyAgreeRecipientInfo,context:1,implicit:!0,optional:!0})],c.prototype,`kari`,void 0),t.__decorate([(0,n.AsnProp)({type:a.KEKRecipientInfo,context:2,implicit:!0,optional:!0})],c.prototype,`kekri`,void 0),t.__decorate([(0,n.AsnProp)({type:o.PasswordRecipientInfo,context:3,implicit:!0,optional:!0})],c.prototype,`pwri`,void 0),t.__decorate([(0,n.AsnProp)({type:s,context:4,implicit:!0,optional:!0})],c.prototype,`ori`,void 0),e.RecipientInfo=c=t.__decorate([(0,n.AsnType)({type:n.AsnTypeTypes.Choice})],c)})),ll=N((e=>{var t;Object.defineProperty(e,"__esModule",{value:!0}),e.RecipientInfos=void 0;let n=(X(),F(Y)),r=Z(),i=cl(),a=t=class extends r.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,t.prototype)}};e.RecipientInfos=a,e.RecipientInfos=a=t=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Set,itemType:i.RecipientInfo})],a)})),ul=N((e=>{var t;Object.defineProperty(e,"__esModule",{value:!0}),e.RevocationInfoChoices=e.RevocationInfoChoice=e.OtherRevocationInfoFormat=e.id_ri_scvp=e.id_ri_ocsp_response=e.id_ri=void 0;let n=(X(),F(Y)),r=Z();e.id_ri=`${$().id_pkix}.16`,e.id_ri_ocsp_response=`${e.id_ri}.2`,e.id_ri_scvp=`${e.id_ri}.4`;var i=class{otherRevInfoFormat=``;otherRevInfo=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.OtherRevocationInfoFormat=i,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.ObjectIdentifier})],i.prototype,`otherRevInfoFormat`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Any})],i.prototype,`otherRevInfo`,void 0);let a=class{other=new i;constructor(e={}){Object.assign(this,e)}};e.RevocationInfoChoice=a,n.__decorate([(0,r.AsnProp)({type:i,context:1,implicit:!0})],a.prototype,`other`,void 0),e.RevocationInfoChoice=a=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Choice})],a);let o=t=class extends r.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,t.prototype)}};e.RevocationInfoChoices=o,e.RevocationInfoChoices=o=t=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Set,itemType:a})],o)})),dl=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.OriginatorInfo=void 0;let t=(X(),F(Y)),n=Z(),r=$c(),i=ul();var a=class{certs;crls;constructor(e={}){Object.assign(this,e)}};e.OriginatorInfo=a,t.__decorate([(0,n.AsnProp)({type:r.CertificateSet,context:0,implicit:!0,optional:!0})],a.prototype,`certs`,void 0),t.__decorate([(0,n.AsnProp)({type:i.RevocationInfoChoices,context:1,implicit:!0,optional:!0})],a.prototype,`crls`,void 0)})),fl=N((e=>{var t;Object.defineProperty(e,"__esModule",{value:!0}),e.EnvelopedData=e.UnprotectedAttributes=void 0;let n=(X(),F(Y)),r=Z(),i=Tc(),a=Ec(),o=ll(),s=dl(),c=nl(),l=t=class extends r.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,t.prototype)}};e.UnprotectedAttributes=l,e.UnprotectedAttributes=l=t=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Set,itemType:a.Attribute})],l);var u=class{version=i.CMSVersion.v0;originatorInfo;recipientInfos=new o.RecipientInfos;encryptedContentInfo=new c.EncryptedContentInfo;unprotectedAttrs;constructor(e={}){Object.assign(this,e)}};e.EnvelopedData=u,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer})],u.prototype,`version`,void 0),n.__decorate([(0,r.AsnProp)({type:s.OriginatorInfo,context:0,implicit:!0,optional:!0})],u.prototype,`originatorInfo`,void 0),n.__decorate([(0,r.AsnProp)({type:o.RecipientInfos})],u.prototype,`recipientInfos`,void 0),n.__decorate([(0,r.AsnProp)({type:c.EncryptedContentInfo})],u.prototype,`encryptedContentInfo`,void 0),n.__decorate([(0,r.AsnProp)({type:l,context:1,implicit:!0,optional:!0})],u.prototype,`unprotectedAttrs`,void 0)})),pl=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.id_authData=e.id_encryptedData=e.id_digestedData=e.id_envelopedData=e.id_signedData=e.id_data=e.id_ct_contentInfo=void 0,e.id_ct_contentInfo=`1.2.840.113549.1.9.16.1.6`,e.id_data=`1.2.840.113549.1.7.1`,e.id_signedData=`1.2.840.113549.1.7.2`,e.id_envelopedData=`1.2.840.113549.1.7.3`,e.id_digestedData=`1.2.840.113549.1.7.5`,e.id_encryptedData=`1.2.840.113549.1.7.6`,e.id_authData=`1.2.840.113549.1.9.16.1.2`})),ml=N((e=>{var t;Object.defineProperty(e,"__esModule",{value:!0}),e.SignedData=e.DigestAlgorithmIdentifiers=void 0;let n=(X(),F(Y)),r=Z(),i=$c(),a=Tc(),o=tl(),s=ul(),c=Dc(),l=t=class extends r.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,t.prototype)}};e.DigestAlgorithmIdentifiers=l,e.DigestAlgorithmIdentifiers=l=t=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Set,itemType:a.DigestAlgorithmIdentifier})],l);var u=class{version=a.CMSVersion.v0;digestAlgorithms=new l;encapContentInfo=new o.EncapsulatedContentInfo;certificates;crls;signerInfos=new c.SignerInfos;constructor(e={}){Object.assign(this,e)}};e.SignedData=u,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer})],u.prototype,`version`,void 0),n.__decorate([(0,r.AsnProp)({type:l})],u.prototype,`digestAlgorithms`,void 0),n.__decorate([(0,r.AsnProp)({type:o.EncapsulatedContentInfo})],u.prototype,`encapContentInfo`,void 0),n.__decorate([(0,r.AsnProp)({type:i.CertificateSet,context:0,implicit:!0,optional:!0})],u.prototype,`certificates`,void 0),n.__decorate([(0,r.AsnProp)({type:s.RevocationInfoChoices,context:1,implicit:!0,optional:!0})],u.prototype,`crls`,void 0),n.__decorate([(0,r.AsnProp)({type:c.SignerInfos})],u.prototype,`signerInfos`,void 0)})),hl=N((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=(X(),F(Y));t.__exportStar(jc(),e),t.__exportStar(Ec(),e),t.__exportStar($c(),e),t.__exportStar(el(),e),t.__exportStar(tl(),e),t.__exportStar(nl(),e),t.__exportStar(fl(),e),t.__exportStar(Cc(),e),t.__exportStar(ol(),e),t.__exportStar(il(),e),t.__exportStar(al(),e),t.__exportStar(pl(),e),t.__exportStar(dl(),e),t.__exportStar(sl(),e),t.__exportStar(cl(),e),t.__exportStar(ll(),e),t.__exportStar(ul(),e),t.__exportStar(ml(),e),t.__exportStar(wc(),e),t.__exportStar(Dc(),e),t.__exportStar(Tc(),e)})),gl=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.id_sect571r1=e.id_sect571k1=e.id_secp521r1=e.id_sect409r1=e.id_sect409k1=e.id_secp384r1=e.id_sect283r1=e.id_sect283k1=e.id_secp256r1=e.id_sect233r1=e.id_sect233k1=e.id_secp224r1=e.id_sect163r2=e.id_sect163k1=e.id_secp192r1=e.id_ecdsaWithSHA512=e.id_ecdsaWithSHA384=e.id_ecdsaWithSHA256=e.id_ecdsaWithSHA224=e.id_ecdsaWithSHA1=e.id_ecMQV=e.id_ecDH=e.id_ecPublicKey=void 0,e.id_ecPublicKey=`1.2.840.10045.2.1`,e.id_ecDH=`1.3.132.1.12`,e.id_ecMQV=`1.3.132.1.13`,e.id_ecdsaWithSHA1=`1.2.840.10045.4.1`,e.id_ecdsaWithSHA224=`1.2.840.10045.4.3.1`,e.id_ecdsaWithSHA256=`1.2.840.10045.4.3.2`,e.id_ecdsaWithSHA384=`1.2.840.10045.4.3.3`,e.id_ecdsaWithSHA512=`1.2.840.10045.4.3.4`,e.id_secp192r1=`1.2.840.10045.3.1.1`,e.id_sect163k1=`1.3.132.0.1`,e.id_sect163r2=`1.3.132.0.15`,e.id_secp224r1=`1.3.132.0.33`,e.id_sect233k1=`1.3.132.0.26`,e.id_sect233r1=`1.3.132.0.27`,e.id_secp256r1=`1.2.840.10045.3.1.7`,e.id_sect283k1=`1.3.132.0.16`,e.id_sect283r1=`1.3.132.0.17`,e.id_secp384r1=`1.3.132.0.34`,e.id_sect409k1=`1.3.132.0.36`,e.id_sect409r1=`1.3.132.0.37`,e.id_secp521r1=`1.3.132.0.35`,e.id_sect571k1=`1.3.132.0.38`,e.id_sect571r1=`1.3.132.0.39`})),_l=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ecdsaWithSHA512=e.ecdsaWithSHA384=e.ecdsaWithSHA256=e.ecdsaWithSHA224=e.ecdsaWithSHA1=void 0;let t=(X(),F(Y)),n=$(),r=t.__importStar(gl());function i(e){return new n.AlgorithmIdentifier({algorithm:e})}e.ecdsaWithSHA1=i(r.id_ecdsaWithSHA1),e.ecdsaWithSHA224=i(r.id_ecdsaWithSHA224),e.ecdsaWithSHA256=i(r.id_ecdsaWithSHA256),e.ecdsaWithSHA384=i(r.id_ecdsaWithSHA384),e.ecdsaWithSHA512=i(r.id_ecdsaWithSHA512)})),vl=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SpecifiedECDomain=e.ECPVer=e.Curve=e.FieldElement=e.ECPoint=e.FieldID=void 0;let t=(X(),F(Y)),n=Z(),r=class{fieldType;parameters;constructor(e={}){Object.assign(this,e)}};e.FieldID=r,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.ObjectIdentifier})],r.prototype,`fieldType`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Any})],r.prototype,`parameters`,void 0),e.FieldID=r=t.__decorate([(0,n.AsnType)({type:n.AsnTypeTypes.Sequence})],r);var i=class extends n.OctetString{};e.ECPoint=i,e.FieldElement=class extends n.OctetString{};let a=class{a;b;seed;constructor(e={}){Object.assign(this,e)}};e.Curve=a,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.OctetString})],a.prototype,`a`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.OctetString})],a.prototype,`b`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.BitString,optional:!0})],a.prototype,`seed`,void 0),e.Curve=a=t.__decorate([(0,n.AsnType)({type:n.AsnTypeTypes.Sequence})],a);var o;(function(e){e[e.ecpVer1=1]=`ecpVer1`})(o||(e.ECPVer=o={}));let s=class{version=o.ecpVer1;fieldID;curve;base;order;cofactor;constructor(e={}){Object.assign(this,e)}};e.SpecifiedECDomain=s,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer})],s.prototype,`version`,void 0),t.__decorate([(0,n.AsnProp)({type:r})],s.prototype,`fieldID`,void 0),t.__decorate([(0,n.AsnProp)({type:a})],s.prototype,`curve`,void 0),t.__decorate([(0,n.AsnProp)({type:i})],s.prototype,`base`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer,converter:n.AsnIntegerArrayBufferConverter})],s.prototype,`order`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer,optional:!0})],s.prototype,`cofactor`,void 0),e.SpecifiedECDomain=s=t.__decorate([(0,n.AsnType)({type:n.AsnTypeTypes.Sequence})],s)})),yl=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ECParameters=void 0;let t=(X(),F(Y)),n=Z(),r=vl(),i=class{namedCurve;implicitCurve;specifiedCurve;constructor(e={}){Object.assign(this,e)}};e.ECParameters=i,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.ObjectIdentifier})],i.prototype,`namedCurve`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Null})],i.prototype,`implicitCurve`,void 0),t.__decorate([(0,n.AsnProp)({type:r.SpecifiedECDomain})],i.prototype,`specifiedCurve`,void 0),e.ECParameters=i=t.__decorate([(0,n.AsnType)({type:n.AsnTypeTypes.Choice})],i)})),bl=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ECPrivateKey=void 0;let t=(X(),F(Y)),n=Z(),r=yl();var i=class{version=1;privateKey=new n.OctetString;parameters;publicKey;constructor(e={}){Object.assign(this,e)}};e.ECPrivateKey=i,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer})],i.prototype,`version`,void 0),t.__decorate([(0,n.AsnProp)({type:n.OctetString})],i.prototype,`privateKey`,void 0),t.__decorate([(0,n.AsnProp)({type:r.ECParameters,context:0,optional:!0})],i.prototype,`parameters`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.BitString,context:1,optional:!0})],i.prototype,`publicKey`,void 0)})),xl=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ECDSASigValue=void 0;let t=(X(),F(Y)),n=Z();var r=class{r=new ArrayBuffer(0);s=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.ECDSASigValue=r,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer,converter:n.AsnIntegerArrayBufferConverter})],r.prototype,`r`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer,converter:n.AsnIntegerArrayBufferConverter})],r.prototype,`s`,void 0)})),Sl=N((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=(X(),F(Y));t.__exportStar(_l(),e),t.__exportStar(yl(),e),t.__exportStar(bl(),e),t.__exportStar(xl(),e),t.__exportStar(gl(),e),t.__exportStar(vl(),e)})),Cl=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.id_mgf1=e.id_md5=e.id_md2=e.id_sha512_256=e.id_sha512_224=e.id_sha512=e.id_sha384=e.id_sha256=e.id_sha224=e.id_sha1=e.id_sha512_256WithRSAEncryption=e.id_sha512_224WithRSAEncryption=e.id_sha512WithRSAEncryption=e.id_sha384WithRSAEncryption=e.id_sha256WithRSAEncryption=e.id_ssha224WithRSAEncryption=e.id_sha224WithRSAEncryption=e.id_sha1WithRSAEncryption=e.id_md5WithRSAEncryption=e.id_md2WithRSAEncryption=e.id_RSASSA_PSS=e.id_pSpecified=e.id_RSAES_OAEP=e.id_rsaEncryption=e.id_pkcs_1=void 0,e.id_pkcs_1=`1.2.840.113549.1.1`,e.id_rsaEncryption=`${e.id_pkcs_1}.1`,e.id_RSAES_OAEP=`${e.id_pkcs_1}.7`,e.id_pSpecified=`${e.id_pkcs_1}.9`,e.id_RSASSA_PSS=`${e.id_pkcs_1}.10`,e.id_md2WithRSAEncryption=`${e.id_pkcs_1}.2`,e.id_md5WithRSAEncryption=`${e.id_pkcs_1}.4`,e.id_sha1WithRSAEncryption=`${e.id_pkcs_1}.5`,e.id_sha224WithRSAEncryption=`${e.id_pkcs_1}.14`,e.id_ssha224WithRSAEncryption=e.id_sha224WithRSAEncryption,e.id_sha256WithRSAEncryption=`${e.id_pkcs_1}.11`,e.id_sha384WithRSAEncryption=`${e.id_pkcs_1}.12`,e.id_sha512WithRSAEncryption=`${e.id_pkcs_1}.13`,e.id_sha512_224WithRSAEncryption=`${e.id_pkcs_1}.15`,e.id_sha512_256WithRSAEncryption=`${e.id_pkcs_1}.16`,e.id_sha1=`1.3.14.3.2.26`,e.id_sha224=`2.16.840.1.101.3.4.2.4`,e.id_sha256=`2.16.840.1.101.3.4.2.1`,e.id_sha384=`2.16.840.1.101.3.4.2.2`,e.id_sha512=`2.16.840.1.101.3.4.2.3`,e.id_sha512_224=`2.16.840.1.101.3.4.2.5`,e.id_sha512_256=`2.16.840.1.101.3.4.2.6`,e.id_md2=`1.2.840.113549.2.2`,e.id_md5=`1.2.840.113549.2.5`,e.id_mgf1=`${e.id_pkcs_1}.8`})),wl=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.sha512_256WithRSAEncryption=e.sha512_224WithRSAEncryption=e.sha512WithRSAEncryption=e.sha384WithRSAEncryption=e.sha256WithRSAEncryption=e.sha224WithRSAEncryption=e.sha1WithRSAEncryption=e.md5WithRSAEncryption=e.md2WithRSAEncryption=e.rsaEncryption=e.pSpecifiedEmpty=e.mgf1SHA1=e.sha512_256=e.sha512_224=e.sha512=e.sha384=e.sha256=e.sha224=e.sha1=e.md4=e.md2=void 0;let t=(X(),F(Y)),n=Z(),r=$(),i=t.__importStar(Cl());function a(e){return new r.AlgorithmIdentifier({algorithm:e,parameters:null})}e.md2=a(i.id_md2),e.md4=a(i.id_md5),e.sha1=a(i.id_sha1),e.sha224=a(i.id_sha224),e.sha256=a(i.id_sha256),e.sha384=a(i.id_sha384),e.sha512=a(i.id_sha512),e.sha512_224=a(i.id_sha512_224),e.sha512_256=a(i.id_sha512_256),e.mgf1SHA1=new r.AlgorithmIdentifier({algorithm:i.id_mgf1,parameters:n.AsnConvert.serialize(e.sha1)}),e.pSpecifiedEmpty=new r.AlgorithmIdentifier({algorithm:i.id_pSpecified,parameters:n.AsnConvert.serialize(n.AsnOctetStringConverter.toASN(new Uint8Array([218,57,163,238,94,107,75,13,50,85,191,239,149,96,24,144,175,216,7,9]).buffer))}),e.rsaEncryption=a(i.id_rsaEncryption),e.md2WithRSAEncryption=a(i.id_md2WithRSAEncryption),e.md5WithRSAEncryption=a(i.id_md5WithRSAEncryption),e.sha1WithRSAEncryption=a(i.id_sha1WithRSAEncryption),e.sha224WithRSAEncryption=a(i.id_sha512_224WithRSAEncryption),e.sha256WithRSAEncryption=a(i.id_sha512_256WithRSAEncryption),e.sha384WithRSAEncryption=a(i.id_sha384WithRSAEncryption),e.sha512WithRSAEncryption=a(i.id_sha512WithRSAEncryption),e.sha512_224WithRSAEncryption=a(i.id_sha512_224WithRSAEncryption),e.sha512_256WithRSAEncryption=a(i.id_sha512_256WithRSAEncryption)})),Tl=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.RSAES_OAEP=e.RsaEsOaepParams=void 0;let t=(X(),F(Y)),n=Z(),r=$(),i=Cl(),a=wl();var o=class{hashAlgorithm=new r.AlgorithmIdentifier(a.sha1);maskGenAlgorithm=new r.AlgorithmIdentifier({algorithm:i.id_mgf1,parameters:n.AsnConvert.serialize(a.sha1)});pSourceAlgorithm=new r.AlgorithmIdentifier(a.pSpecifiedEmpty);constructor(e={}){Object.assign(this,e)}};e.RsaEsOaepParams=o,t.__decorate([(0,n.AsnProp)({type:r.AlgorithmIdentifier,context:0,defaultValue:a.sha1})],o.prototype,`hashAlgorithm`,void 0),t.__decorate([(0,n.AsnProp)({type:r.AlgorithmIdentifier,context:1,defaultValue:a.mgf1SHA1})],o.prototype,`maskGenAlgorithm`,void 0),t.__decorate([(0,n.AsnProp)({type:r.AlgorithmIdentifier,context:2,defaultValue:a.pSpecifiedEmpty})],o.prototype,`pSourceAlgorithm`,void 0),e.RSAES_OAEP=new r.AlgorithmIdentifier({algorithm:i.id_RSAES_OAEP,parameters:n.AsnConvert.serialize(new o)})})),El=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.RSASSA_PSS=e.RsaSaPssParams=void 0;let t=(X(),F(Y)),n=Z(),r=$(),i=Cl(),a=wl();var o=class{hashAlgorithm=new r.AlgorithmIdentifier(a.sha1);maskGenAlgorithm=new r.AlgorithmIdentifier({algorithm:i.id_mgf1,parameters:n.AsnConvert.serialize(a.sha1)});saltLength=20;trailerField=1;constructor(e={}){Object.assign(this,e)}};e.RsaSaPssParams=o,t.__decorate([(0,n.AsnProp)({type:r.AlgorithmIdentifier,context:0,defaultValue:a.sha1})],o.prototype,`hashAlgorithm`,void 0),t.__decorate([(0,n.AsnProp)({type:r.AlgorithmIdentifier,context:1,defaultValue:a.mgf1SHA1})],o.prototype,`maskGenAlgorithm`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer,context:2,defaultValue:20})],o.prototype,`saltLength`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer,context:3,defaultValue:1})],o.prototype,`trailerField`,void 0),e.RSASSA_PSS=new r.AlgorithmIdentifier({algorithm:i.id_RSASSA_PSS,parameters:n.AsnConvert.serialize(new o)})})),Dl=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.DigestInfo=void 0;let t=(X(),F(Y)),n=$(),r=Z();var i=class{digestAlgorithm=new n.AlgorithmIdentifier;digest=new r.OctetString;constructor(e={}){Object.assign(this,e)}};e.DigestInfo=i,t.__decorate([(0,r.AsnProp)({type:n.AlgorithmIdentifier})],i.prototype,`digestAlgorithm`,void 0),t.__decorate([(0,r.AsnProp)({type:r.OctetString})],i.prototype,`digest`,void 0)})),Ol=N((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=(X(),F(Y));t.__exportStar(Tl(),e),t.__exportStar(El(),e),t.__exportStar(Dl(),e)})),kl=N((e=>{var t;Object.defineProperty(e,"__esModule",{value:!0}),e.OtherPrimeInfos=e.OtherPrimeInfo=void 0;let n=(X(),F(Y)),r=Z();var i=class{prime=new ArrayBuffer(0);exponent=new ArrayBuffer(0);coefficient=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.OtherPrimeInfo=i,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer,converter:r.AsnIntegerArrayBufferConverter})],i.prototype,`prime`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer,converter:r.AsnIntegerArrayBufferConverter})],i.prototype,`exponent`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer,converter:r.AsnIntegerArrayBufferConverter})],i.prototype,`coefficient`,void 0);let a=t=class extends r.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,t.prototype)}};e.OtherPrimeInfos=a,e.OtherPrimeInfos=a=t=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Sequence,itemType:i})],a)})),Al=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.RSAPrivateKey=void 0;let t=(X(),F(Y)),n=Z(),r=kl();var i=class{version=0;modulus=new ArrayBuffer(0);publicExponent=new ArrayBuffer(0);privateExponent=new ArrayBuffer(0);prime1=new ArrayBuffer(0);prime2=new ArrayBuffer(0);exponent1=new ArrayBuffer(0);exponent2=new ArrayBuffer(0);coefficient=new ArrayBuffer(0);otherPrimeInfos;constructor(e={}){Object.assign(this,e)}};e.RSAPrivateKey=i,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer})],i.prototype,`version`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer,converter:n.AsnIntegerArrayBufferConverter})],i.prototype,`modulus`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer,converter:n.AsnIntegerArrayBufferConverter})],i.prototype,`publicExponent`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer,converter:n.AsnIntegerArrayBufferConverter})],i.prototype,`privateExponent`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer,converter:n.AsnIntegerArrayBufferConverter})],i.prototype,`prime1`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer,converter:n.AsnIntegerArrayBufferConverter})],i.prototype,`prime2`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer,converter:n.AsnIntegerArrayBufferConverter})],i.prototype,`exponent1`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer,converter:n.AsnIntegerArrayBufferConverter})],i.prototype,`exponent2`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer,converter:n.AsnIntegerArrayBufferConverter})],i.prototype,`coefficient`,void 0),t.__decorate([(0,n.AsnProp)({type:r.OtherPrimeInfos,optional:!0})],i.prototype,`otherPrimeInfos`,void 0)})),jl=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.RSAPublicKey=void 0;let t=(X(),F(Y)),n=Z();var r=class{modulus=new ArrayBuffer(0);publicExponent=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.RSAPublicKey=r,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer,converter:n.AsnIntegerArrayBufferConverter})],r.prototype,`modulus`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer,converter:n.AsnIntegerArrayBufferConverter})],r.prototype,`publicExponent`,void 0)})),Ml=N((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=(X(),F(Y));t.__exportStar(Ol(),e),t.__exportStar(wl(),e),t.__exportStar(Cl(),e),t.__exportStar(kl(),e),t.__exportStar(Al(),e),t.__exportStar(jl(),e)})),Nl=te({__assign:()=>ru,__asyncDelegator:()=>Yl,__asyncGenerator:()=>Jl,__asyncValues:()=>Xl,__await:()=>ql,__awaiter:()=>zl,__classPrivateFieldGet:()=>eu,__classPrivateFieldSet:()=>tu,__createBinding:()=>Vl,__decorate:()=>Il,__exportStar:()=>Hl,__extends:()=>Pl,__generator:()=>Bl,__importDefault:()=>$l,__importStar:()=>Ql,__makeTemplateObject:()=>Zl,__metadata:()=>Rl,__param:()=>Ll,__read:()=>Wl,__rest:()=>Fl,__spread:()=>Gl,__spreadArrays:()=>Kl,__values:()=>Ul});
362
- /*! *****************************************************************************
363
- Copyright (c) Microsoft Corporation.
364
-
365
- Permission to use, copy, modify, and/or distribute this software for any
366
- purpose with or without fee is hereby granted.
367
-
368
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
369
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
370
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
371
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
372
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
373
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
374
- PERFORMANCE OF THIS SOFTWARE.
375
- ***************************************************************************** */
376
- function Pl(e,t){nu(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}function Fl(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function Il(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}function Ll(e,t){return function(n,r){t(n,r,e)}}function Rl(e,t){if(typeof Reflect==`object`&&typeof Reflect.metadata==`function`)return Reflect.metadata(e,t)}function zl(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})}function Bl(e,t){var n={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},r,i,a,o;return o={next:s(0),throw:s(1),return:s(2)},typeof Symbol==`function`&&(o[Symbol.iterator]=function(){return this}),o;function s(e){return function(t){return c([e,t])}}function c(o){if(r)throw TypeError(`Generator is already executing.`);for(;n;)try{if(r=1,i&&(a=o[0]&2?i.return:o[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,o[1])).done)return a;switch(i=0,a&&(o=[o[0]&2,a.value]),o[0]){case 0:case 1:a=o;break;case 4:return n.label++,{value:o[1],done:!1};case 5:n.label++,i=o[1],o=[0];continue;case 7:o=n.ops.pop(),n.trys.pop();continue;default:if((a=n.trys,!(a=a.length>0&&a[a.length-1]))&&(o[0]===6||o[0]===2)){n=0;continue}if(o[0]===3&&(!a||o[1]>a[0]&&o[1]<a[3])){n.label=o[1];break}if(o[0]===6&&n.label<a[1]){n.label=a[1],a=o;break}if(a&&n.label<a[2]){n.label=a[2],n.ops.push(o);break}a[2]&&n.ops.pop(),n.trys.pop();continue}o=t.call(e,n)}catch(e){o=[6,e],i=0}finally{r=a=0}if(o[0]&5)throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}}function Vl(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]}function Hl(e,t){for(var n in e)n!=="default"&&!t.hasOwnProperty(n)&&(t[n]=e[n])}function Ul(e){var t=typeof Symbol==`function`&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length==`number`)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw TypeError(t?`Object is not iterable.`:`Symbol.iterator is not defined.`)}function Wl(e,t){var n=typeof Symbol==`function`&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),i,a=[],o;try{for(;(t===void 0||t-->0)&&!(i=r.next()).done;)a.push(i.value)}catch(e){o={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a}function Gl(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(Wl(arguments[t]));return e}function Kl(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;for(var r=Array(e),i=0,t=0;t<n;t++)for(var a=arguments[t],o=0,s=a.length;o<s;o++,i++)r[i]=a[o];return r}function ql(e){return this instanceof ql?(this.v=e,this):new ql(e)}function Jl(e,t,n){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var r=n.apply(e,t||[]),i,a=[];return i={},o(`next`),o(`throw`),o(`return`),i[Symbol.asyncIterator]=function(){return this},i;function o(e){r[e]&&(i[e]=function(t){return new Promise(function(n,r){a.push([e,t,n,r])>1||s(e,t)})})}function s(e,t){try{c(r[e](t))}catch(e){d(a[0][3],e)}}function c(e){e.value instanceof ql?Promise.resolve(e.value.v).then(l,u):d(a[0][2],e)}function l(e){s(`next`,e)}function u(e){s(`throw`,e)}function d(e,t){e(t),a.shift(),a.length&&s(a[0][0],a[0][1])}}function Yl(e){var t,n;return t={},r(`next`),r(`throw`,function(e){throw e}),r(`return`),t[Symbol.iterator]=function(){return this},t;function r(r,i){t[r]=e[r]?function(t){return(n=!n)?{value:ql(e[r](t)),done:r===`return`}:i?i(t):t}:i}}function Xl(e){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof Ul==`function`?Ul(e):e[Symbol.iterator](),n={},r(`next`),r(`throw`),r(`return`),n[Symbol.asyncIterator]=function(){return this},n);function r(t){n[t]=e[t]&&function(n){return new Promise(function(r,a){n=e[t](n),i(r,a,n.done,n.value)})}}function i(e,t,n,r){Promise.resolve(r).then(function(t){e({value:t,done:n})},t)}}function Zl(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}function Ql(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}function $l(e){return e&&e.__esModule?e:{default:e}}function eu(e,t){if(!t.has(e))throw TypeError(`attempted to get private field on non-instance`);return t.get(e)}function tu(e,t,n){if(!t.has(e))throw TypeError(`attempted to set private field on non-instance`);return t.set(e,n),n}var nu,ru,iu=M((()=>{nu=function(e,t){return nu=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},nu(e,t)},ru=function(){return ru=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},ru.apply(this,arguments)}})),au=N((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t;(function(e){e[e.Transient=0]=`Transient`,e[e.Singleton=1]=`Singleton`,e[e.ResolutionScoped=2]=`ResolutionScoped`,e[e.ContainerScoped=3]=`ContainerScoped`})(t||={}),e.default=t})),ou=N((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=au();Object.defineProperty(e,"Lifecycle",{enumerable:!0,get:function(){return t.default}})})),su=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.defineInjectionTokenMetadata=e.getParamInfo=e.INJECTION_TOKEN_METADATA_KEY=void 0,e.INJECTION_TOKEN_METADATA_KEY=`injectionTokens`;function t(t){let n=Reflect.getMetadata(`design:paramtypes`,t)||[],r=Reflect.getOwnMetadata(e.INJECTION_TOKEN_METADATA_KEY,t)||{};return Object.keys(r).forEach(e=>{n[+e]=r[e]}),n}e.getParamInfo=t;function n(t,n){return function(r,i,a){let o=Reflect.getOwnMetadata(e.INJECTION_TOKEN_METADATA_KEY,r)||{};o[a]=n?{token:t,transform:n.transformToken,transformArgs:n.args||[]}:t,Reflect.defineMetadata(e.INJECTION_TOKEN_METADATA_KEY,o,r)}}e.defineInjectionTokenMetadata=n})),cu=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isClassProvider=void 0;function t(e){return!!e.useClass}e.isClassProvider=t})),lu=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isFactoryProvider=void 0;function t(e){return!!e.useFactory}e.isFactoryProvider=t})),uu=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.delay=e.DelayedConstructor=void 0;var t=class{constructor(e){this.wrap=e,this.reflectMethods=[`get`,`getPrototypeOf`,`setPrototypeOf`,`getOwnPropertyDescriptor`,`defineProperty`,`has`,`set`,`deleteProperty`,`apply`,`construct`,`ownKeys`]}createProxy(e){let t={},n=!1,r;return new Proxy(t,this.createHandler(()=>(n||=(r=e(this.wrap()),!0),r)))}createHandler(e){let t={};return this.reflectMethods.forEach(n=>{t[n]=(...t)=>{t[0]=e();let r=Reflect[n];return r(...t)}}),t}};e.DelayedConstructor=t;function n(e){if(e===void 0)throw Error("Attempt to `delay` undefined. Constructor must be wrapped in a callback");return new t(e)}e.delay=n})),du=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isConstructorToken=e.isTransformDescriptor=e.isTokenDescriptor=e.isNormalToken=void 0;let t=uu();function n(e){return typeof e==`string`||typeof e==`symbol`}e.isNormalToken=n;function r(e){return typeof e==`object`&&`token`in e&&`multiple`in e}e.isTokenDescriptor=r;function i(e){return typeof e==`object`&&`token`in e&&`transform`in e}e.isTransformDescriptor=i;function a(e){return typeof e==`function`||e instanceof t.DelayedConstructor}e.isConstructorToken=a})),fu=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isTokenProvider=void 0;function t(e){return!!e.useToken}e.isTokenProvider=t})),pu=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isValueProvider=void 0;function t(e){return e.useValue!=null}e.isValueProvider=t})),mu=N((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=cu();Object.defineProperty(e,"isClassProvider",{enumerable:!0,get:function(){return t.isClassProvider}});var n=lu();Object.defineProperty(e,"isFactoryProvider",{enumerable:!0,get:function(){return n.isFactoryProvider}});var r=du();Object.defineProperty(e,"isNormalToken",{enumerable:!0,get:function(){return r.isNormalToken}});var i=fu();Object.defineProperty(e,"isTokenProvider",{enumerable:!0,get:function(){return i.isTokenProvider}});var a=pu();Object.defineProperty(e,"isValueProvider",{enumerable:!0,get:function(){return a.isValueProvider}})})),hu=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isProvider=void 0;let t=cu(),n=pu(),r=fu(),i=lu();function a(e){return t.isClassProvider(e)||n.isValueProvider(e)||r.isTokenProvider(e)||i.isFactoryProvider(e)}e.isProvider=a})),gu=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=class{constructor(){this._registryMap=new Map}entries(){return this._registryMap.entries()}getAll(e){return this.ensure(e),this._registryMap.get(e)}get(e){this.ensure(e);let t=this._registryMap.get(e);return t[t.length-1]||null}set(e,t){this.ensure(e),this._registryMap.get(e).push(t)}setAll(e,t){this._registryMap.set(e,t)}has(e){return this.ensure(e),this._registryMap.get(e).length>0}clear(){this._registryMap.clear()}ensure(e){this._registryMap.has(e)||this._registryMap.set(e,[])}}})),_u=N((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=gu();e.default=class extends t.default{}})),vu=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=class{constructor(){this.scopedResolutions=new Map}}})),yu=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.formatErrorCtor=void 0;function t(e,t){return e===null?`at position #${t}`:`"${e.split(`,`)[t].trim()}" at position #${t}`}function n(e,t,n=` `){return[e,...t.message.split(`
377
- `).map(e=>n+e)].join(`
378
- `)}function r(e,r,i){let[,a=null]=e.toString().match(/constructor\(([\w, ]+)\)/)||[];return n(`Cannot inject the dependency ${t(a,r)} of "${e.name}" constructor. Reason:`,i)}e.formatErrorCtor=r})),bu=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isDisposable=void 0;function t(e){return!(typeof e.dispose!=`function`||e.dispose.length>0)}e.isDisposable=t})),xu=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.PostResolutionInterceptors=e.PreResolutionInterceptors=void 0;let t=gu();var n=class extends t.default{};e.PreResolutionInterceptors=n;var r=class extends t.default{};e.PostResolutionInterceptors=r,e.default=class{constructor(){this.preResolution=new n,this.postResolution=new r}}})),Su=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.instance=e.typeInfo=void 0;let t=(iu(),F(Nl)),n=mu(),r=hu(),i=du(),a=_u(),o=au(),s=vu(),c=yu(),l=uu(),u=bu(),d=xu();e.typeInfo=new Map,e.instance=new class f{constructor(e){this.parent=e,this._registry=new a.default,this.interceptors=new d.default,this.disposed=!1,this.disposables=new Set}register(e,t,i={lifecycle:o.default.Transient}){this.ensureNotDisposed();let a;if(a=r.isProvider(t)?t:{useClass:t},n.isTokenProvider(a)){let t=[e],r=a;for(;r!=null;){let e=r.useToken;if(t.includes(e))throw Error(`Token registration cycle detected! ${[...t,e].join(` -> `)}`);t.push(e);let i=this._registry.get(e);r=i&&n.isTokenProvider(i.provider)?i.provider:null}}if((i.lifecycle===o.default.Singleton||i.lifecycle==o.default.ContainerScoped||i.lifecycle==o.default.ResolutionScoped)&&(n.isValueProvider(a)||n.isFactoryProvider(a)))throw Error(`Cannot use lifecycle "${o.default[i.lifecycle]}" with ValueProviders or FactoryProviders`);return this._registry.set(e,{provider:a,options:i}),this}registerType(e,t){return this.ensureNotDisposed(),n.isNormalToken(t)?this.register(e,{useToken:t}):this.register(e,{useClass:t})}registerInstance(e,t){return this.ensureNotDisposed(),this.register(e,{useValue:t})}registerSingleton(e,t){if(this.ensureNotDisposed(),n.isNormalToken(e)){if(n.isNormalToken(t))return this.register(e,{useToken:t},{lifecycle:o.default.Singleton});if(t)return this.register(e,{useClass:t},{lifecycle:o.default.Singleton});throw Error(`Cannot register a type name as a singleton without a "to" token`)}let r=e;return t&&!n.isNormalToken(t)&&(r=t),this.register(e,{useClass:r},{lifecycle:o.default.Singleton})}resolve(e,t=new s.default,r=!1){this.ensureNotDisposed();let a=this.getRegistration(e);if(!a&&n.isNormalToken(e)){if(r)return;throw Error(`Attempted to resolve unregistered dependency token: "${e.toString()}"`)}if(this.executePreResolutionInterceptor(e,`Single`),a){let n=this.resolveRegistration(a,t);return this.executePostResolutionInterceptor(e,n,`Single`),n}if(i.isConstructorToken(e)){let n=this.construct(e,t);return this.executePostResolutionInterceptor(e,n,`Single`),n}throw Error("Attempted to construct an undefined constructor. Could mean a circular dependency problem. Try using `delay` function.")}executePreResolutionInterceptor(e,t){if(this.interceptors.preResolution.has(e)){let n=[];for(let r of this.interceptors.preResolution.getAll(e))r.options.frequency!=`Once`&&n.push(r),r.callback(e,t);this.interceptors.preResolution.setAll(e,n)}}executePostResolutionInterceptor(e,t,n){if(this.interceptors.postResolution.has(e)){let r=[];for(let i of this.interceptors.postResolution.getAll(e))i.options.frequency!=`Once`&&r.push(i),i.callback(e,t,n);this.interceptors.postResolution.setAll(e,r)}}resolveRegistration(e,t){if(this.ensureNotDisposed(),e.options.lifecycle===o.default.ResolutionScoped&&t.scopedResolutions.has(e))return t.scopedResolutions.get(e);let r=e.options.lifecycle===o.default.Singleton,i=e.options.lifecycle===o.default.ContainerScoped,a=r||i,s;return s=n.isValueProvider(e.provider)?e.provider.useValue:n.isTokenProvider(e.provider)?a?e.instance||=this.resolve(e.provider.useToken,t):this.resolve(e.provider.useToken,t):n.isClassProvider(e.provider)?a?e.instance||=this.construct(e.provider.useClass,t):this.construct(e.provider.useClass,t):n.isFactoryProvider(e.provider)?e.provider.useFactory(this):this.construct(e.provider,t),e.options.lifecycle===o.default.ResolutionScoped&&t.scopedResolutions.set(e,s),s}resolveAll(e,t=new s.default,r=!1){this.ensureNotDisposed();let i=this.getAllRegistrations(e);if(!i&&n.isNormalToken(e)){if(r)return[];throw Error(`Attempted to resolve unregistered dependency token: "${e.toString()}"`)}if(this.executePreResolutionInterceptor(e,`All`),i){let n=i.map(e=>this.resolveRegistration(e,t));return this.executePostResolutionInterceptor(e,n,`All`),n}let a=[this.construct(e,t)];return this.executePostResolutionInterceptor(e,a,`All`),a}isRegistered(e,t=!1){return this.ensureNotDisposed(),this._registry.has(e)||t&&(this.parent||!1)&&this.parent.isRegistered(e,!0)}reset(){this.ensureNotDisposed(),this._registry.clear(),this.interceptors.preResolution.clear(),this.interceptors.postResolution.clear()}clearInstances(){this.ensureNotDisposed();for(let[e,t]of this._registry.entries())this._registry.setAll(e,t.filter(e=>!n.isValueProvider(e.provider)).map(e=>(e.instance=void 0,e)))}createChildContainer(){this.ensureNotDisposed();let e=new f(this);for(let[t,n]of this._registry.entries())n.some(({options:e})=>e.lifecycle===o.default.ContainerScoped)&&e._registry.setAll(t,n.map(e=>e.options.lifecycle===o.default.ContainerScoped?{provider:e.provider,options:e.options}:e));return e}beforeResolution(e,t,n={frequency:`Always`}){this.interceptors.preResolution.set(e,{callback:t,options:n})}afterResolution(e,t,n={frequency:`Always`}){this.interceptors.postResolution.set(e,{callback:t,options:n})}dispose(){return t.__awaiter(this,void 0,void 0,function*(){this.disposed=!0;let e=[];this.disposables.forEach(t=>{let n=t.dispose();n&&e.push(n)}),yield Promise.all(e)})}getRegistration(e){return this.isRegistered(e)?this._registry.get(e):this.parent?this.parent.getRegistration(e):null}getAllRegistrations(e){return this.isRegistered(e)?this._registry.getAll(e):this.parent?this.parent.getAllRegistrations(e):null}construct(t,n){if(t instanceof l.DelayedConstructor)return t.createProxy(e=>this.resolve(e,n));let r=(()=>{let r=e.typeInfo.get(t);if(!r||r.length===0){if(t.length===0)return new t;throw Error(`TypeInfo not known for "${t.name}"`)}return new t(...r.map(this.resolveParams(n,t)))})();return u.isDisposable(r)&&this.disposables.add(r),r}resolveParams(e,t){return(n,r)=>{try{return i.isTokenDescriptor(n)?i.isTransformDescriptor(n)?n.multiple?this.resolve(n.transform).transform(this.resolveAll(n.token,new s.default,n.isOptional),...n.transformArgs):this.resolve(n.transform).transform(this.resolve(n.token,e,n.isOptional),...n.transformArgs):n.multiple?this.resolveAll(n.token,new s.default,n.isOptional):this.resolve(n.token,e,n.isOptional):i.isTransformDescriptor(n)?this.resolve(n.transform,e).transform(this.resolve(n.token,e),...n.transformArgs):this.resolve(n,e)}catch(e){throw Error(c.formatErrorCtor(t,r,e))}}}ensureNotDisposed(){if(this.disposed)throw Error(`This container has been disposed, you cannot interact with a disposed container`)}},e.default=e.instance})),Cu=N((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=su(),n=Su(),r=du(),i=yu();function a(){return function(e){let a=t.getParamInfo(e);return class extends e{constructor(...t){super(...t.concat(a.slice(t.length).map((a,o)=>{try{return r.isTokenDescriptor(a)?r.isTransformDescriptor(a)?a.multiple?n.instance.resolve(a.transform).transform(n.instance.resolveAll(a.token),...a.transformArgs):n.instance.resolve(a.transform).transform(n.instance.resolve(a.token),...a.transformArgs):a.multiple?n.instance.resolveAll(a.token):n.instance.resolve(a.token):r.isTransformDescriptor(a)?n.instance.resolve(a.transform).transform(n.instance.resolve(a.token),...a.transformArgs):n.instance.resolve(a)}catch(n){let r=o+t.length;throw Error(i.formatErrorCtor(e,r,n))}})))}}}}e.default=a})),wu=N((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=su();function n(e,n){let r={token:e,multiple:!1,isOptional:n&&n.isOptional};return t.defineInjectionTokenMetadata(r)}e.default=n})),Tu=N((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=su(),n=Su(),r=Su();function i(e){return function(i){n.typeInfo.set(i,t.getParamInfo(i)),e&&e.token&&(Array.isArray(e.token)?e.token.forEach(e=>{r.instance.register(e,i)}):r.instance.register(e.token,i))}}e.default=i})),Eu=N((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=(iu(),F(Nl)),n=Su();function r(e=[]){return function(r){return e.forEach(e=>{var{token:r,options:i}=e,a=t.__rest(e,[`token`,`options`]);return n.instance.register(r,a,i)}),r}}e.default=r})),Du=N((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=Tu(),n=Su();function r(){return function(e){t.default()(e),n.instance.registerSingleton(e)}}e.default=r})),Ou=N((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=su();function n(e,n){let r={token:e,multiple:!0,isOptional:n&&n.isOptional};return t.defineInjectionTokenMetadata(r)}e.default=n})),ku=N((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=su();function n(e,n,...r){let i={token:e,multiple:!0,transform:n,transformArgs:r};return t.defineInjectionTokenMetadata(i)}e.default=n})),Au=N((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=su();function n(e,n,...r){return t.defineInjectionTokenMetadata(e,{transformToken:n,args:r})}e.default=n})),ju=N((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=Tu(),n=Su();function r(e,r){return function(i){t.default()(i),n.instance.register(r||i,i,{lifecycle:e})}}e.default=r})),Mu=N((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Cu();Object.defineProperty(e,"autoInjectable",{enumerable:!0,get:function(){return t.default}});var n=wu();Object.defineProperty(e,"inject",{enumerable:!0,get:function(){return n.default}});var r=Tu();Object.defineProperty(e,"injectable",{enumerable:!0,get:function(){return r.default}});var i=Eu();Object.defineProperty(e,"registry",{enumerable:!0,get:function(){return i.default}});var a=Du();Object.defineProperty(e,"singleton",{enumerable:!0,get:function(){return a.default}});var o=Ou();Object.defineProperty(e,"injectAll",{enumerable:!0,get:function(){return o.default}});var s=ku();Object.defineProperty(e,"injectAllWithTransform",{enumerable:!0,get:function(){return s.default}});var c=Au();Object.defineProperty(e,"injectWithTransform",{enumerable:!0,get:function(){return c.default}});var l=ju();Object.defineProperty(e,"scoped",{enumerable:!0,get:function(){return l.default}})})),Nu=N((e=>{Object.defineProperty(e,"__esModule",{value:!0});function t(e){let t;return n=>(t??=e(n),t)}e.default=t})),Pu=N((e=>{Object.defineProperty(e,"__esModule",{value:!0});function t(e){let t=new WeakMap;return n=>{let r=t.get(n);return r??(r=e(n),t.set(n,r)),r}}e.default=t})),Fu=N((e=>{Object.defineProperty(e,"__esModule",{value:!0});function t(e,t,n,r=!0){let i,a;return o=>{let s=e(o);return(!r||a!==s)&&(i=(a=s)?o.resolve(t):o.resolve(n)),i}}e.default=t})),Iu=N((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=Nu();Object.defineProperty(e,"instanceCachingFactory",{enumerable:!0,get:function(){return t.default}});var n=Pu();Object.defineProperty(e,"instancePerContainerCachingFactory",{enumerable:!0,get:function(){return n.default}});var r=Fu();Object.defineProperty(e,"predicateAwareClassFactory",{enumerable:!0,get:function(){return r.default}})})),Lu=N((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=(iu(),F(Nl));if(typeof Reflect>`u`||!Reflect.getMetadata)throw Error(`tsyringe requires a reflect polyfill. Please add 'import "reflect-metadata"' to the top of your entry point.`);var n=ou();Object.defineProperty(e,"Lifecycle",{enumerable:!0,get:function(){return n.Lifecycle}}),t.__exportStar(Mu(),e),t.__exportStar(Iu(),e),t.__exportStar(mu(),e);var r=uu();Object.defineProperty(e,"delay",{enumerable:!0,get:function(){return r.delay}});var i=Su();Object.defineProperty(e,"container",{enumerable:!0,get:function(){return i.instance}})})),Ru=N((e=>{var t;Object.defineProperty(e,"__esModule",{value:!0}),e.PKCS12AttrSet=e.PKCS12Attribute=void 0;let n=(X(),F(Y)),r=Z();var i=class{attrId=``;attrValues=[];constructor(e={}){Object.assign(e)}};e.PKCS12Attribute=i,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.ObjectIdentifier})],i.prototype,`attrId`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Any,repeated:`set`})],i.prototype,`attrValues`,void 0);let a=t=class extends r.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,t.prototype)}};e.PKCS12AttrSet=a,e.PKCS12AttrSet=a=t=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Sequence,itemType:i})],a)})),zu=N((e=>{var t;Object.defineProperty(e,"__esModule",{value:!0}),e.AuthenticatedSafe=void 0;let n=(X(),F(Y)),r=Z(),i=hl(),a=t=class extends r.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,t.prototype)}};e.AuthenticatedSafe=a,e.AuthenticatedSafe=a=t=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Sequence,itemType:i.ContentInfo})],a)})),Bu=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.id_bagtypes=e.id_pbewithSHAAnd40BitRC2_CBC=e.id_pbeWithSHAAnd128BitRC2_CBC=e.id_pbeWithSHAAnd2_KeyTripleDES_CBC=e.id_pbeWithSHAAnd3_KeyTripleDES_CBC=e.id_pbeWithSHAAnd40BitRC4=e.id_pbeWithSHAAnd128BitRC4=e.id_pkcs_12PbeIds=e.id_pkcs_12=e.id_pkcs=e.id_rsadsi=void 0,e.id_rsadsi=`1.2.840.113549`,e.id_pkcs=`${e.id_rsadsi}.1`,e.id_pkcs_12=`${e.id_pkcs}.12`,e.id_pkcs_12PbeIds=`${e.id_pkcs_12}.1`,e.id_pbeWithSHAAnd128BitRC4=`${e.id_pkcs_12PbeIds}.1`,e.id_pbeWithSHAAnd40BitRC4=`${e.id_pkcs_12PbeIds}.2`,e.id_pbeWithSHAAnd3_KeyTripleDES_CBC=`${e.id_pkcs_12PbeIds}.3`,e.id_pbeWithSHAAnd2_KeyTripleDES_CBC=`${e.id_pkcs_12PbeIds}.4`,e.id_pbeWithSHAAnd128BitRC2_CBC=`${e.id_pkcs_12PbeIds}.5`,e.id_pbewithSHAAnd40BitRC2_CBC=`${e.id_pkcs_12PbeIds}.6`,e.id_bagtypes=`${e.id_pkcs_12}.10.1`})),Vu=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.id_pkcs_9=e.id_SafeContents=e.id_SecretBag=e.id_CRLBag=e.id_certBag=e.id_pkcs8ShroudedKeyBag=e.id_keyBag=void 0;let t=Bu();e.id_keyBag=`${t.id_bagtypes}.1`,e.id_pkcs8ShroudedKeyBag=`${t.id_bagtypes}.2`,e.id_certBag=`${t.id_bagtypes}.3`,e.id_CRLBag=`${t.id_bagtypes}.4`,e.id_SecretBag=`${t.id_bagtypes}.5`,e.id_SafeContents=`${t.id_bagtypes}.6`,e.id_pkcs_9=`1.2.840.113549.1.9`})),Hu=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.id_sdsiCertificate=e.id_x509Certificate=e.id_certTypes=e.CertBag=void 0;let t=(X(),F(Y)),n=Z(),r=Vu();var i=class{certId=``;certValue=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.CertBag=i,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.ObjectIdentifier})],i.prototype,`certId`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Any,context:0})],i.prototype,`certValue`,void 0),e.id_certTypes=`${r.id_pkcs_9}.22`,e.id_x509Certificate=`${e.id_certTypes}.1`,e.id_sdsiCertificate=`${e.id_certTypes}.2`})),Uu=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.id_x509CRL=e.id_crlTypes=e.CRLBag=void 0;let t=(X(),F(Y)),n=Z(),r=Vu();var i=class{crlId=``;crltValue=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.CRLBag=i,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.ObjectIdentifier})],i.prototype,`crlId`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Any,context:0})],i.prototype,`crltValue`,void 0),e.id_crlTypes=`${r.id_pkcs_9}.23`,e.id_x509CRL=`${e.id_crlTypes}.1`})),Wu=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.EncryptedPrivateKeyInfo=e.EncryptedData=void 0;let t=(X(),F(Y)),n=Z(),r=$();var i=class extends n.OctetString{};e.EncryptedData=i;var a=class{encryptionAlgorithm=new r.AlgorithmIdentifier;encryptedData=new i;constructor(e={}){Object.assign(this,e)}};e.EncryptedPrivateKeyInfo=a,t.__decorate([(0,n.AsnProp)({type:r.AlgorithmIdentifier})],a.prototype,`encryptionAlgorithm`,void 0),t.__decorate([(0,n.AsnProp)({type:i})],a.prototype,`encryptedData`,void 0)})),Gu=N((e=>{var t;Object.defineProperty(e,"__esModule",{value:!0}),e.PrivateKeyInfo=e.Attributes=e.PrivateKey=e.Version=void 0;let n=(X(),F(Y)),r=Z(),i=$();var a;(function(e){e[e.v1=0]=`v1`})(a||(e.Version=a={}));var o=class extends r.OctetString{};e.PrivateKey=o;let s=t=class extends r.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,t.prototype)}};e.Attributes=s,e.Attributes=s=t=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Sequence,itemType:i.Attribute})],s);var c=class{version=a.v1;privateKeyAlgorithm=new i.AlgorithmIdentifier;privateKey=new o;attributes;constructor(e={}){Object.assign(this,e)}};e.PrivateKeyInfo=c,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer})],c.prototype,`version`,void 0),n.__decorate([(0,r.AsnProp)({type:i.AlgorithmIdentifier})],c.prototype,`privateKeyAlgorithm`,void 0),n.__decorate([(0,r.AsnProp)({type:o})],c.prototype,`privateKey`,void 0),n.__decorate([(0,r.AsnProp)({type:s,implicit:!0,context:0,optional:!0})],c.prototype,`attributes`,void 0)})),Ku=N((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=(X(),F(Y));t.__exportStar(Wu(),e),t.__exportStar(Gu(),e)})),qu=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.KeyBag=void 0;let t=(X(),F(Y)),n=Ku(),r=Z(),i=class extends n.PrivateKeyInfo{};e.KeyBag=i,e.KeyBag=i=t.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Sequence})],i)})),Ju=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.PKCS8ShroudedKeyBag=void 0;let t=(X(),F(Y)),n=Ku(),r=Z(),i=class extends n.EncryptedPrivateKeyInfo{};e.PKCS8ShroudedKeyBag=i,e.PKCS8ShroudedKeyBag=i=t.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Sequence})],i)})),Yu=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SecretBag=void 0;let t=(X(),F(Y)),n=Z();var r=class{secretTypeId=``;secretValue=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.SecretBag=r,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.ObjectIdentifier})],r.prototype,`secretTypeId`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Any,context:0})],r.prototype,`secretValue`,void 0)})),Xu=N((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=(X(),F(Y));t.__exportStar(Hu(),e),t.__exportStar(Uu(),e),t.__exportStar(qu(),e),t.__exportStar(Ju(),e),t.__exportStar(Yu(),e),t.__exportStar(Vu(),e)})),Zu=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.MacData=void 0;let t=(X(),F(Y)),n=Ml(),r=Z();var i=class{mac=new n.DigestInfo;macSalt=new r.OctetString;iterations=1;constructor(e={}){Object.assign(this,e)}};e.MacData=i,t.__decorate([(0,r.AsnProp)({type:n.DigestInfo})],i.prototype,`mac`,void 0),t.__decorate([(0,r.AsnProp)({type:r.OctetString})],i.prototype,`macSalt`,void 0),t.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Integer,defaultValue:1})],i.prototype,`iterations`,void 0)})),Qu=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.PFX=void 0;let t=(X(),F(Y)),n=Z(),r=hl(),i=Zu();var a=class{version=3;authSafe=new r.ContentInfo;macData=new i.MacData;constructor(e={}){Object.assign(this,e)}};e.PFX=a,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer})],a.prototype,`version`,void 0),t.__decorate([(0,n.AsnProp)({type:r.ContentInfo})],a.prototype,`authSafe`,void 0),t.__decorate([(0,n.AsnProp)({type:i.MacData,optional:!0})],a.prototype,`macData`,void 0)})),$u=N((e=>{var t;Object.defineProperty(e,"__esModule",{value:!0}),e.SafeContents=e.SafeBag=void 0;let n=(X(),F(Y)),r=Z(),i=Ru();var a=class{bagId=``;bagValue=new ArrayBuffer(0);bagAttributes;constructor(e={}){Object.assign(this,e)}};e.SafeBag=a,n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.ObjectIdentifier})],a.prototype,`bagId`,void 0),n.__decorate([(0,r.AsnProp)({type:r.AsnPropTypes.Any,context:0})],a.prototype,`bagValue`,void 0),n.__decorate([(0,r.AsnProp)({type:i.PKCS12Attribute,repeated:`set`,optional:!0})],a.prototype,`bagAttributes`,void 0);let o=t=class extends r.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,t.prototype)}};e.SafeContents=o,e.SafeContents=o=t=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Sequence,itemType:a})],o)})),ed=N((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=(X(),F(Y));t.__exportStar(Ru(),e),t.__exportStar(zu(),e),t.__exportStar(Xu(),e),t.__exportStar(Zu(),e),t.__exportStar(Bu(),e),t.__exportStar(Qu(),e),t.__exportStar($u(),e)})),td=N((e=>{var t,n,r;Object.defineProperty(e,"__esModule",{value:!0}),e.DateOfBirth=e.UnstructuredAddress=e.UnstructuredName=e.EmailAddress=e.EncryptedPrivateKeyInfo=e.UserPKCS12=e.Pkcs7PDU=e.PKCS9String=e.id_at_pseudonym=e.crlTypes=e.id_certTypes=e.id_smime=e.id_pkcs9_mr_signingTimeMatch=e.id_pkcs9_mr_caseIgnoreMatch=e.id_pkcs9_sx_signingTime=e.id_pkcs9_sx_pkcs9String=e.id_pkcs9_at_countryOfResidence=e.id_pkcs9_at_countryOfCitizenship=e.id_pkcs9_at_gender=e.id_pkcs9_at_placeOfBirth=e.id_pkcs9_at_dateOfBirth=e.id_ietf_at=e.id_pkcs9_at_pkcs7PDU=e.id_pkcs9_at_sequenceNumber=e.id_pkcs9_at_randomNonce=e.id_pkcs9_at_encryptedPrivateKeyInfo=e.id_pkcs9_at_pkcs15Token=e.id_pkcs9_at_userPKCS12=e.id_pkcs9_at_localKeyId=e.id_pkcs9_at_friendlyName=e.id_pkcs9_at_smimeCapabilities=e.id_pkcs9_at_extensionRequest=e.id_pkcs9_at_signingDescription=e.id_pkcs9_at_extendedCertificateAttributes=e.id_pkcs9_at_unstructuredAddress=e.id_pkcs9_at_challengePassword=e.id_pkcs9_at_counterSignature=e.id_pkcs9_at_signingTime=e.id_pkcs9_at_messageDigest=e.id_pkcs9_at_contentType=e.id_pkcs9_at_unstructuredName=e.id_pkcs9_at_emailAddress=e.id_pkcs9_oc_naturalPerson=e.id_pkcs9_oc_pkcsEntity=e.id_pkcs9_mr=e.id_pkcs9_sx=e.id_pkcs9_at=e.id_pkcs9_oc=e.id_pkcs9_mo=e.id_pkcs9=void 0,e.SMIMECapabilities=e.SMIMECapability=e.SigningDescription=e.LocalKeyId=e.FriendlyName=e.ExtendedCertificateAttributes=e.ExtensionRequest=e.ChallengePassword=e.CounterSignature=e.SequenceNumber=e.RandomNonce=e.SigningTime=e.MessageDigest=e.ContentType=e.Pseudonym=e.CountryOfResidence=e.CountryOfCitizenship=e.Gender=e.PlaceOfBirth=void 0;let i=(X(),F(Y)),a=Z(),o=i.__importStar(hl()),s=i.__importStar(ed()),c=i.__importStar(Ku()),l=i.__importStar($()),u=i.__importStar(Qc());e.id_pkcs9=`1.2.840.113549.1.9`,e.id_pkcs9_mo=`${e.id_pkcs9}.0`,e.id_pkcs9_oc=`${e.id_pkcs9}.24`,e.id_pkcs9_at=`${e.id_pkcs9}.25`,e.id_pkcs9_sx=`${e.id_pkcs9}.26`,e.id_pkcs9_mr=`${e.id_pkcs9}.27`,e.id_pkcs9_oc_pkcsEntity=`${e.id_pkcs9_oc}.1`,e.id_pkcs9_oc_naturalPerson=`${e.id_pkcs9_oc}.2`,e.id_pkcs9_at_emailAddress=`${e.id_pkcs9}.1`,e.id_pkcs9_at_unstructuredName=`${e.id_pkcs9}.2`,e.id_pkcs9_at_contentType=`${e.id_pkcs9}.3`,e.id_pkcs9_at_messageDigest=`${e.id_pkcs9}.4`,e.id_pkcs9_at_signingTime=`${e.id_pkcs9}.5`,e.id_pkcs9_at_counterSignature=`${e.id_pkcs9}.6`,e.id_pkcs9_at_challengePassword=`${e.id_pkcs9}.7`,e.id_pkcs9_at_unstructuredAddress=`${e.id_pkcs9}.8`,e.id_pkcs9_at_extendedCertificateAttributes=`${e.id_pkcs9}.9`,e.id_pkcs9_at_signingDescription=`${e.id_pkcs9}.13`,e.id_pkcs9_at_extensionRequest=`${e.id_pkcs9}.14`,e.id_pkcs9_at_smimeCapabilities=`${e.id_pkcs9}.15`,e.id_pkcs9_at_friendlyName=`${e.id_pkcs9}.20`,e.id_pkcs9_at_localKeyId=`${e.id_pkcs9}.21`,e.id_pkcs9_at_userPKCS12=`2.16.840.1.113730.3.1.216`,e.id_pkcs9_at_pkcs15Token=`${e.id_pkcs9_at}.1`,e.id_pkcs9_at_encryptedPrivateKeyInfo=`${e.id_pkcs9_at}.2`,e.id_pkcs9_at_randomNonce=`${e.id_pkcs9_at}.3`,e.id_pkcs9_at_sequenceNumber=`${e.id_pkcs9_at}.4`,e.id_pkcs9_at_pkcs7PDU=`${e.id_pkcs9_at}.5`,e.id_ietf_at=`1.3.6.1.5.5.7.9`,e.id_pkcs9_at_dateOfBirth=`${e.id_ietf_at}.1`,e.id_pkcs9_at_placeOfBirth=`${e.id_ietf_at}.2`,e.id_pkcs9_at_gender=`${e.id_ietf_at}.3`,e.id_pkcs9_at_countryOfCitizenship=`${e.id_ietf_at}.4`,e.id_pkcs9_at_countryOfResidence=`${e.id_ietf_at}.5`,e.id_pkcs9_sx_pkcs9String=`${e.id_pkcs9_sx}.1`,e.id_pkcs9_sx_signingTime=`${e.id_pkcs9_sx}.2`,e.id_pkcs9_mr_caseIgnoreMatch=`${e.id_pkcs9_mr}.1`,e.id_pkcs9_mr_signingTimeMatch=`${e.id_pkcs9_mr}.2`,e.id_smime=`${e.id_pkcs9}.16`,e.id_certTypes=`${e.id_pkcs9}.22`,e.crlTypes=`${e.id_pkcs9}.23`,e.id_at_pseudonym=`${u.id_at}.65`;let d=class extends l.DirectoryString{ia5String;constructor(e={}){super(e)}toString(){return{}.toString(),this.ia5String||super.toString()}};e.PKCS9String=d,i.__decorate([(0,a.AsnProp)({type:a.AsnPropTypes.IA5String})],d.prototype,`ia5String`,void 0),e.PKCS9String=d=i.__decorate([(0,a.AsnType)({type:a.AsnTypeTypes.Choice})],d);let f=class extends o.ContentInfo{};e.Pkcs7PDU=f,e.Pkcs7PDU=f=i.__decorate([(0,a.AsnType)({type:a.AsnTypeTypes.Sequence})],f);let p=class extends s.PFX{};e.UserPKCS12=p,e.UserPKCS12=p=i.__decorate([(0,a.AsnType)({type:a.AsnTypeTypes.Sequence})],p);let m=class extends c.EncryptedPrivateKeyInfo{};e.EncryptedPrivateKeyInfo=m,e.EncryptedPrivateKeyInfo=m=i.__decorate([(0,a.AsnType)({type:a.AsnTypeTypes.Sequence})],m);let h=class{value;constructor(e=``){this.value=e}toString(){return this.value}};e.EmailAddress=h,i.__decorate([(0,a.AsnProp)({type:a.AsnPropTypes.IA5String})],h.prototype,`value`,void 0),e.EmailAddress=h=i.__decorate([(0,a.AsnType)({type:a.AsnTypeTypes.Choice})],h);let g=class extends d{};e.UnstructuredName=g,e.UnstructuredName=g=i.__decorate([(0,a.AsnType)({type:a.AsnTypeTypes.Choice})],g);let _=class extends l.DirectoryString{};e.UnstructuredAddress=_,e.UnstructuredAddress=_=i.__decorate([(0,a.AsnType)({type:a.AsnTypeTypes.Choice})],_);let v=class{value;constructor(e=new Date){this.value=e}};e.DateOfBirth=v,i.__decorate([(0,a.AsnProp)({type:a.AsnPropTypes.GeneralizedTime})],v.prototype,`value`,void 0),e.DateOfBirth=v=i.__decorate([(0,a.AsnType)({type:a.AsnTypeTypes.Choice})],v);let y=class extends l.DirectoryString{};e.PlaceOfBirth=y,e.PlaceOfBirth=y=i.__decorate([(0,a.AsnType)({type:a.AsnTypeTypes.Choice})],y);let b=class{value;constructor(e=`M`){this.value=e}toString(){return this.value}};e.Gender=b,i.__decorate([(0,a.AsnProp)({type:a.AsnPropTypes.PrintableString})],b.prototype,`value`,void 0),e.Gender=b=i.__decorate([(0,a.AsnType)({type:a.AsnTypeTypes.Choice})],b);let x=class{value;constructor(e=``){this.value=e}toString(){return this.value}};e.CountryOfCitizenship=x,i.__decorate([(0,a.AsnProp)({type:a.AsnPropTypes.PrintableString})],x.prototype,`value`,void 0),e.CountryOfCitizenship=x=i.__decorate([(0,a.AsnType)({type:a.AsnTypeTypes.Choice})],x);let S=class extends x{};e.CountryOfResidence=S,e.CountryOfResidence=S=i.__decorate([(0,a.AsnType)({type:a.AsnTypeTypes.Choice})],S);let C=class extends l.DirectoryString{};e.Pseudonym=C,e.Pseudonym=C=i.__decorate([(0,a.AsnType)({type:a.AsnTypeTypes.Choice})],C);let w=class{value;constructor(e=``){this.value=e}toString(){return this.value}};e.ContentType=w,i.__decorate([(0,a.AsnProp)({type:a.AsnPropTypes.ObjectIdentifier})],w.prototype,`value`,void 0),e.ContentType=w=i.__decorate([(0,a.AsnType)({type:a.AsnTypeTypes.Choice})],w),e.MessageDigest=class extends a.OctetString{};let T=class extends l.Time{};e.SigningTime=T,e.SigningTime=T=i.__decorate([(0,a.AsnType)({type:a.AsnTypeTypes.Choice})],T),e.RandomNonce=class extends a.OctetString{};let E=class{value;constructor(e=0){this.value=e}toString(){return this.value.toString()}};e.SequenceNumber=E,i.__decorate([(0,a.AsnProp)({type:a.AsnPropTypes.Integer})],E.prototype,`value`,void 0),e.SequenceNumber=E=i.__decorate([(0,a.AsnType)({type:a.AsnTypeTypes.Choice})],E);let D=class extends o.SignerInfo{};e.CounterSignature=D,e.CounterSignature=D=i.__decorate([(0,a.AsnType)({type:a.AsnTypeTypes.Sequence})],D);let O=class extends l.DirectoryString{};e.ChallengePassword=O,e.ChallengePassword=O=i.__decorate([(0,a.AsnType)({type:a.AsnTypeTypes.Choice})],O);let k=t=class extends l.Extensions{constructor(e){super(e),Object.setPrototypeOf(this,t.prototype)}};e.ExtensionRequest=k,e.ExtensionRequest=k=t=i.__decorate([(0,a.AsnType)({type:a.AsnTypeTypes.Sequence})],k);let A=n=class extends a.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype)}};e.ExtendedCertificateAttributes=A,e.ExtendedCertificateAttributes=A=n=i.__decorate([(0,a.AsnType)({type:a.AsnTypeTypes.Set,itemType:o.Attribute})],A);let ee=class{value;constructor(e=``){this.value=e}toString(){return this.value}};e.FriendlyName=ee,i.__decorate([(0,a.AsnProp)({type:a.AsnPropTypes.BmpString})],ee.prototype,`value`,void 0),e.FriendlyName=ee=i.__decorate([(0,a.AsnType)({type:a.AsnTypeTypes.Choice})],ee),e.LocalKeyId=class extends a.OctetString{},e.SigningDescription=class extends l.DirectoryString{};let j=class extends l.AlgorithmIdentifier{};e.SMIMECapability=j,e.SMIMECapability=j=i.__decorate([(0,a.AsnType)({type:a.AsnTypeTypes.Sequence})],j);let M=r=class extends a.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,r.prototype)}};e.SMIMECapabilities=M,e.SMIMECapabilities=M=r=i.__decorate([(0,a.AsnType)({type:a.AsnTypeTypes.Sequence,itemType:j})],M)})),nd=N((e=>{var t;Object.defineProperty(e,"__esModule",{value:!0}),e.Attributes=void 0;let n=(X(),F(Y)),r=Z(),i=$(),a=t=class extends r.AsnArray{constructor(e){super(e),Object.setPrototypeOf(this,t.prototype)}};e.Attributes=a,e.Attributes=a=t=n.__decorate([(0,r.AsnType)({type:r.AsnTypeTypes.Sequence,itemType:i.Attribute})],a)})),rd=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.CertificationRequestInfo=void 0;let t=(X(),F(Y)),n=Z(),r=$(),i=nd();var a=class{version=0;subject=new r.Name;subjectPKInfo=new r.SubjectPublicKeyInfo;attributes=new i.Attributes;constructor(e={}){Object.assign(this,e)}};e.CertificationRequestInfo=a,t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.Integer})],a.prototype,`version`,void 0),t.__decorate([(0,n.AsnProp)({type:r.Name})],a.prototype,`subject`,void 0),t.__decorate([(0,n.AsnProp)({type:r.SubjectPublicKeyInfo})],a.prototype,`subjectPKInfo`,void 0),t.__decorate([(0,n.AsnProp)({type:i.Attributes,implicit:!0,context:0,optional:!0})],a.prototype,`attributes`,void 0)})),id=N((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.CertificationRequest=void 0;let t=(X(),F(Y)),n=Z(),r=$(),i=rd();var a=class{certificationRequestInfo=new i.CertificationRequestInfo;certificationRequestInfoRaw;signatureAlgorithm=new r.AlgorithmIdentifier;signature=new ArrayBuffer(0);constructor(e={}){Object.assign(this,e)}};e.CertificationRequest=a,t.__decorate([(0,n.AsnProp)({type:i.CertificationRequestInfo,raw:!0})],a.prototype,`certificationRequestInfo`,void 0),t.__decorate([(0,n.AsnProp)({type:r.AlgorithmIdentifier})],a.prototype,`signatureAlgorithm`,void 0),t.__decorate([(0,n.AsnProp)({type:n.AsnPropTypes.BitString})],a.prototype,`signature`,void 0)})),ad=N((e=>{Object.defineProperty(e,"__esModule",{value:!0});let t=(X(),F(Y));t.__exportStar(nd(),e),t.__exportStar(id(),e),t.__exportStar(rd(),e)})),od=N((e=>{
379
- /*!
380
- * MIT License
381
- *
382
- * Copyright (c) Peculiar Ventures. All rights reserved.
383
- *
384
- * Permission is hereby granted, free of charge, to any person obtaining a copy
385
- * of this software and associated documentation files (the "Software"), to deal
386
- * in the Software without restriction, including without limitation the rights
387
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
388
- * copies of the Software, and to permit persons to whom the Software is
389
- * furnished to do so, subject to the following conditions:
390
- *
391
- * The above copyright notice and this permission notice shall be included in all
392
- * copies or substantial portions of the Software.
393
- *
394
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
395
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
396
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
397
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
398
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
399
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
400
- * SOFTWARE.
401
- *
402
- */
403
- So();var t=Z(),n=$(),r=os(),i=hl(),a=Sl(),o=Ml(),s=(X(),F(Y)),c=Lu(),l=td(),u=ad();function d(e){var t=Object.create(null);return e&&Object.keys(e).forEach(function(n){if(n!=="default"){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}}),t.default=e,Object.freeze(t)}var f=d(n),p=d(i),m=d(a),h=d(o),g=d(l);let _=`crypto.algorithm`;var v=class{getAlgorithms(){return c.container.resolveAll(_)}toAsnAlgorithm(e){({...e});for(let t of this.getAlgorithms()){let n=t.toAsnAlgorithm(e);if(n)return n}if(/^[0-9.]+$/.test(e.name)){let t=new n.AlgorithmIdentifier({algorithm:e.name});return`parameters`in e&&(t.parameters=e.parameters),t}throw Error(`Cannot convert WebCrypto algorithm to ASN.1 algorithm`)}toWebAlgorithm(e){for(let t of this.getAlgorithms()){let n=t.toWebAlgorithm(e);if(n)return n}return{name:e.algorithm,parameters:e.parameters}}};let y=`crypto.algorithmProvider`;c.container.registerSingleton(y,v);var b;let x=`1.3.36.3.3.2.8.1.1`,S=`${x}.1`,C=`${x}.2`,w=`${x}.3`,T=`${x}.4`,E=`${x}.5`,D=`${x}.6`,O=`${x}.7`,k=`${x}.8`,A=`${x}.9`,ee=`${x}.10`,j=`${x}.11`,M=`${x}.12`,N=`${x}.13`,te=`${x}.14`,ne=`brainpoolP160r1`,P=`brainpoolP160t1`,re=`brainpoolP192r1`,I=`brainpoolP192t1`,ie=`brainpoolP224r1`,ae=`brainpoolP224t1`,oe=`brainpoolP256r1`,se=`brainpoolP256t1`,ce=`brainpoolP320r1`,le=`brainpoolP320t1`,ue=`brainpoolP384r1`,de=`brainpoolP384t1`,fe=`brainpoolP512r1`,pe=`brainpoolP512t1`,L=`ECDSA`;e.EcAlgorithm=b=class{toAsnAlgorithm(e){switch(e.name.toLowerCase()){case`ecdsa`:if(`hash`in e)switch((typeof e.hash==`string`?e.hash:e.hash.name).toLowerCase()){case`sha-1`:return m.ecdsaWithSHA1;case`sha-256`:return m.ecdsaWithSHA256;case`sha-384`:return m.ecdsaWithSHA384;case`sha-512`:return m.ecdsaWithSHA512}else if(`namedCurve`in e){let r=``;switch(e.namedCurve){case`P-256`:r=m.id_secp256r1;break;case`K-256`:r=b.SECP256K1;break;case`P-384`:r=m.id_secp384r1;break;case`P-521`:r=m.id_secp521r1;break;case ne:r=S;break;case P:r=C;break;case re:r=w;break;case I:r=T;break;case ie:r=E;break;case ae:r=D;break;case oe:r=O;break;case se:r=k;break;case ce:r=A;break;case le:r=ee;break;case ue:r=j;break;case de:r=M;break;case fe:r=N;break;case pe:r=te;break}if(r)return new n.AlgorithmIdentifier({algorithm:m.id_ecPublicKey,parameters:t.AsnConvert.serialize(new m.ECParameters({namedCurve:r}))})}}return null}toWebAlgorithm(e){switch(e.algorithm){case m.id_ecdsaWithSHA1:return{name:L,hash:{name:`SHA-1`}};case m.id_ecdsaWithSHA256:return{name:L,hash:{name:`SHA-256`}};case m.id_ecdsaWithSHA384:return{name:L,hash:{name:`SHA-384`}};case m.id_ecdsaWithSHA512:return{name:L,hash:{name:`SHA-512`}};case m.id_ecPublicKey:if(!e.parameters)throw TypeError(`Cannot get required parameters from EC algorithm`);switch(t.AsnConvert.parse(e.parameters,m.ECParameters).namedCurve){case m.id_secp256r1:return{name:L,namedCurve:`P-256`};case b.SECP256K1:return{name:L,namedCurve:`K-256`};case m.id_secp384r1:return{name:L,namedCurve:`P-384`};case m.id_secp521r1:return{name:L,namedCurve:`P-521`};case S:return{name:L,namedCurve:ne};case C:return{name:L,namedCurve:P};case w:return{name:L,namedCurve:re};case T:return{name:L,namedCurve:I};case E:return{name:L,namedCurve:ie};case D:return{name:L,namedCurve:ae};case O:return{name:L,namedCurve:oe};case k:return{name:L,namedCurve:se};case A:return{name:L,namedCurve:ce};case ee:return{name:L,namedCurve:le};case j:return{name:L,namedCurve:ue};case M:return{name:L,namedCurve:de};case N:return{name:L,namedCurve:fe};case te:return{name:L,namedCurve:pe}}}return null}},e.EcAlgorithm.SECP256K1=`1.3.132.0.10`,e.EcAlgorithm=b=s.__decorate([c.injectable()],e.EcAlgorithm),c.container.registerSingleton(_,e.EcAlgorithm);let me=Symbol(`name`),he=Symbol(`value`);var R=class{constructor(e,t={},n=``){this[me]=e,this[he]=n;for(let e in t)this[e]=t[e]}};R.NAME=me,R.VALUE=he;var ge=class{static toTextObject(t){let n=new R(`Algorithm Identifier`,{},_e.toString(t.algorithm));if(t.parameters)switch(t.algorithm){case m.id_ecPublicKey:{let r=new e.EcAlgorithm().toWebAlgorithm(t);r&&`namedCurve`in r?n[`Named Curve`]=r.namedCurve:n.Parameters=t.parameters;break}default:n.Parameters=t.parameters}return n}},_e=class{static toString(e){return this.items[e]||e}};_e.items={[h.id_sha1]:`sha1`,[h.id_sha224]:`sha224`,[h.id_sha256]:`sha256`,[h.id_sha384]:`sha384`,[h.id_sha512]:`sha512`,[h.id_rsaEncryption]:`rsaEncryption`,[h.id_sha1WithRSAEncryption]:`sha1WithRSAEncryption`,[h.id_sha224WithRSAEncryption]:`sha224WithRSAEncryption`,[h.id_sha256WithRSAEncryption]:`sha256WithRSAEncryption`,[h.id_sha384WithRSAEncryption]:`sha384WithRSAEncryption`,[h.id_sha512WithRSAEncryption]:`sha512WithRSAEncryption`,[m.id_ecPublicKey]:`ecPublicKey`,[m.id_ecdsaWithSHA1]:`ecdsaWithSHA1`,[m.id_ecdsaWithSHA224]:`ecdsaWithSHA224`,[m.id_ecdsaWithSHA256]:`ecdsaWithSHA256`,[m.id_ecdsaWithSHA384]:`ecdsaWithSHA384`,[m.id_ecdsaWithSHA512]:`ecdsaWithSHA512`,[f.id_kp_serverAuth]:`TLS WWW server authentication`,[f.id_kp_clientAuth]:`TLS WWW client authentication`,[f.id_kp_codeSigning]:`Code Signing`,[f.id_kp_emailProtection]:`E-mail Protection`,[f.id_kp_timeStamping]:`Time Stamping`,[f.id_kp_OCSPSigning]:`OCSP Signing`,[p.id_signedData]:`Signed Data`};var ve=class{static serialize(e){return this.serializeObj(e).join(`
404
- `)}static pad(e=0){return``.padStart(2*e,` `)}static serializeObj(e,t=0){let n=[],i=this.pad(t++),a=``,o=e[R.VALUE];o&&(a=` ${o}`),n.push(`${i}${e[R.NAME]}:${a}`),i=this.pad(t);for(let a in e){if(typeof a==`symbol`)continue;let o=e[a],s=a?`${a}: `:``;if(typeof o==`string`||typeof o==`number`||typeof o==`boolean`)n.push(`${i}${s}${o}`);else if(o instanceof Date)n.push(`${i}${s}${o.toUTCString()}`);else if(Array.isArray(o))for(let e of o)e[R.NAME]=a,n.push(...this.serializeObj(e,t));else if(o instanceof R)o[R.NAME]=a,n.push(...this.serializeObj(o,t));else if(r.BufferSourceConverter.isBufferSource(o))a?(n.push(`${i}${s}`),n.push(...this.serializeBufferSource(o,t+1))):n.push(...this.serializeBufferSource(o,t));else if(`toTextObject`in o){let e=o.toTextObject();e[R.NAME]=a,n.push(...this.serializeObj(e,t))}else throw TypeError(`Cannot serialize data in text format. Unsupported type.`)}return n}static serializeBufferSource(e,t=0){let n=this.pad(t),i=r.BufferSourceConverter.toUint8Array(e),a=[];for(let e=0;e<i.length;){let t=[];for(let n=0;n<16&&e<i.length;n++){n===8&&t.push(``);let r=i[e++].toString(16).padStart(2,`0`);t.push(r)}a.push(`${n}${t.join(` `)}`)}return a}static serializeAlgorithm(e){return this.algorithmSerializer.toTextObject(e)}};ve.oidSerializer=_e,ve.algorithmSerializer=ge;var z=class e{constructor(...e){if(e.length===1){let n=e[0];this.rawData=t.AsnConvert.serialize(n),this.onInit(n)}else{let n=t.AsnConvert.parse(e[0],e[1]);this.rawData=r.BufferSourceConverter.toArrayBuffer(e[0]),this.onInit(n)}}equal(t){return t instanceof e?r.isEqual(t.rawData,this.rawData):!1}toString(e=`text`){switch(e){case`asn`:return t.AsnConvert.toString(this.rawData);case`text`:return ve.serialize(this.toTextObject());case`hex`:return r.Convert.ToHex(this.rawData);case`base64`:return r.Convert.ToBase64(this.rawData);case`base64url`:return r.Convert.ToBase64Url(this.rawData);default:throw TypeError(`Argument 'format' is unsupported value`)}}getTextName(){return this.constructor.NAME}toTextObject(){let e=this.toTextObjectEmpty();return e[``]=this.rawData,e}toTextObjectEmpty(e){return new R(this.getTextName(),{},e)}};z.NAME=`ASN`;var ye=class e extends z{constructor(...e){let i;i=r.BufferSourceConverter.isBufferSource(e[0])?r.BufferSourceConverter.toArrayBuffer(e[0]):t.AsnConvert.serialize(new n.Extension({extnID:e[0],critical:e[1],extnValue:new t.OctetString(r.BufferSourceConverter.toArrayBuffer(e[2]))})),super(i,n.Extension)}onInit(e){this.type=e.extnID,this.critical=e.critical,this.value=e.extnValue.buffer}toTextObject(){let e=this.toTextObjectWithoutValue();return e[``]=this.value,e}toTextObjectWithoutValue(){let t=this.toTextObjectEmpty(this.critical?`critical`:void 0);return t[R.NAME]===e.NAME&&(t[R.NAME]=_e.toString(this.type)),t}},be,xe=class e{static isCryptoKeyPair(e){return e&&e.privateKey&&e.publicKey}static isCryptoKey(e){return e&&e.usages&&e.type&&e.algorithm&&e.extractable!==void 0}constructor(){this.items=new Map,this[be]=`CryptoProvider`,typeof self<`u`&&typeof crypto<`u`?this.set(e.DEFAULT,crypto):typeof global<`u`&&global.crypto&&global.crypto.subtle&&this.set(e.DEFAULT,global.crypto)}clear(){this.items.clear()}delete(e){return this.items.delete(e)}forEach(e,t){return this.items.forEach(e,t)}has(e){return this.items.has(e)}get size(){return this.items.size}entries(){return this.items.entries()}keys(){return this.items.keys()}values(){return this.items.values()}[Symbol.iterator](){return this.items[Symbol.iterator]()}get(t=e.DEFAULT){let n=this.items.get(t.toLowerCase());if(!n)throw Error(`Cannot get Crypto by name '${t}'`);return n}set(t,n){if(typeof t==`string`){if(!n)throw TypeError(`Argument 'value' is required`);this.items.set(t.toLowerCase(),n)}else this.items.set(e.DEFAULT,t);return this}};be=Symbol.toStringTag,xe.DEFAULT=`default`;let B=new xe,Se=/^[0-2](?:\.[1-9][0-9]*)+$/;function Ce(e){return new RegExp(Se).test(e)}var we=class{constructor(e={}){this.items={};for(let t in e)this.register(t,e[t])}get(e){return this.items[e]||null}findId(e){return Ce(e)?e:this.get(e)}register(e,t){this.items[e]=t,this.items[t]=e}};let V=new we;V.register(`CN`,`2.5.4.3`),V.register(`L`,`2.5.4.7`),V.register(`ST`,`2.5.4.8`),V.register(`O`,`2.5.4.10`),V.register(`OU`,`2.5.4.11`),V.register(`C`,`2.5.4.6`),V.register(`DC`,`0.9.2342.19200300.100.1.25`),V.register(`E`,`1.2.840.113549.1.9.1`),V.register(`G`,`2.5.4.42`),V.register(`I`,`2.5.4.43`),V.register(`SN`,`2.5.4.4`),V.register(`T`,`2.5.4.12`);function H(e,t){return`\\${r.Convert.ToHex(r.Convert.FromUtf8String(t)).toUpperCase()}`}function Te(e){return e.replace(/([,+"\\<>;])/g,`\\$1`).replace(/^([ #])/,`\\$1`).replace(/([ ]$)/,`\\$1`).replace(/([\r\n\t])/,H)}var U=class e{static isASCII(e){for(let t=0;t<e.length;t++)if(e.charCodeAt(t)>255)return!1;return!0}static isPrintableString(e){return/^[A-Za-z0-9 '()+,-./:=?]*$/g.test(e)}constructor(e,i={}){this.extraNames=new we,this.asn=new n.Name;for(let e in i)if(Object.prototype.hasOwnProperty.call(i,e)){let t=i[e];this.extraNames.register(e,t)}typeof e==`string`?this.asn=this.fromString(e):e instanceof n.Name?this.asn=e:r.BufferSourceConverter.isBufferSource(e)?this.asn=t.AsnConvert.parse(e,n.Name):this.asn=this.fromJSON(e)}getField(e){let t=this.extraNames.findId(e)||V.findId(e),n=[];for(let e of this.asn)for(let r of e)r.type===t&&n.push(r.value.toString());return n}getName(e){return this.extraNames.get(e)||V.get(e)}toString(){return this.asn.map(e=>e.map(e=>`${this.getName(e.type)||e.type}=${e.value.anyValue?`#${r.Convert.ToHex(e.value.anyValue)}`:Te(e.value.toString())}`).join(`+`)).join(`, `)}toJSON(){let e=[];for(let t of this.asn){let n={};for(let e of t){let t=this.getName(e.type)||e.type;n[t]??(n[t]=[]),n[t].push(e.value.anyValue?`#${r.Convert.ToHex(e.value.anyValue)}`:e.value.toString())}e.push(n)}return e}fromString(e){let t=new n.Name,r=/(\d\.[\d.]*\d|[A-Za-z]+)=((?:"")|(?:".*?[^\\]")|(?:[^,+].*?(?:[^\\][,+]))|(?:))([,+])?/g,i=null,a=`,`;for(;i=r.exec(`${e},`);){let[,e,r]=i,o=r[r.length-1];(o===`,`||o===`+`)&&(r=r.slice(0,r.length-1),i[3]=o);let s=i[3];e=this.getTypeOid(e);let c=this.createAttribute(e,r);a===`+`?t[t.length-1].push(c):t.push(new n.RelativeDistinguishedName([c])),a=s}return t}fromJSON(e){let t=new n.Name;for(let r of e){let e=new n.RelativeDistinguishedName;for(let t in r){let n=this.getTypeOid(t),i=r[t];for(let t of i){let r=this.createAttribute(n,t);e.push(r)}}t.push(e)}return t}getTypeOid(e){if(/[\d.]+/.test(e)||(e=this.getName(e)||``),!e)throw Error(`Cannot get OID for name type '${e}'`);return e}createAttribute(t,i){let a=new n.AttributeTypeAndValue({type:t});if(typeof i==`object`)for(let e in i)switch(e){case`ia5String`:a.value.ia5String=i[e];break;case`utf8String`:a.value.utf8String=i[e];break;case`universalString`:a.value.universalString=i[e];break;case`bmpString`:a.value.bmpString=i[e];break;case`printableString`:a.value.printableString=i[e];break}else if(i[0]===`#`)a.value.anyValue=r.Convert.FromHex(i.slice(1));else{let n=this.processStringValue(i);t===this.getName(`E`)||t===this.getName(`DC`)?a.value.ia5String=n:e.isPrintableString(n)?a.value.printableString=n:a.value.utf8String=n}return a}processStringValue(e){let t=/"(.*?[^\\])?"/.exec(e);return t&&(e=t[1]),e.replace(/\\0a/gi,`
405
- `).replace(/\\0d/gi,`\r`).replace(/\\0g/gi,` `).replace(/\\(.)/g,`$1`)}toArrayBuffer(){return t.AsnConvert.serialize(this.asn)}async getThumbprint(...e){let t,n=`SHA-1`;return e.length>=1&&!e[0]?.subtle?(n=e[0]||n,t=e[1]||B.get()):t=e[0]||B.get(),await t.subtle.digest(n,this.toArrayBuffer())}};let Ee=`Cannot initialize GeneralName from ASN.1 data.`,De=`${Ee} Unsupported string format in use.`,Oe=`${Ee} Value doesn't match to GUID regular expression.`,ke=/^([0-9a-f]{8})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{12})$/i,W=`1.3.6.1.4.1.311.25.1`,Ae=`1.3.6.1.4.1.311.20.2.3`,je=`email`,Me=`guid`;var G=class extends z{constructor(...e){let n;if(e.length===2)switch(e[0]){case`dn`:{let r=new U(e[1]).toArrayBuffer(),i=t.AsnConvert.parse(r,f.Name);n=new f.GeneralName({directoryName:i});break}case`dns`:n=new f.GeneralName({dNSName:e[1]});break;case je:n=new f.GeneralName({rfc822Name:e[1]});break;case Me:{let i=new RegExp(ke,`i`).exec(e[1]);if(!i)throw Error(`Cannot parse GUID value. Value doesn't match to regular expression`);let a=i.slice(1).map((e,t)=>t<3?r.Convert.ToHex(new Uint8Array(r.Convert.FromHex(e)).reverse()):e).join(``);n=new f.GeneralName({otherName:new f.OtherName({typeId:W,value:t.AsnConvert.serialize(new t.OctetString(r.Convert.FromHex(a)))})});break}case`ip`:n=new f.GeneralName({iPAddress:e[1]});break;case`id`:n=new f.GeneralName({registeredID:e[1]});break;case`upn`:n=new f.GeneralName({otherName:new f.OtherName({typeId:Ae,value:t.AsnConvert.serialize(t.AsnUtf8StringConverter.toASN(e[1]))})});break;case`url`:n=new f.GeneralName({uniformResourceIdentifier:e[1]});break;default:throw Error(`Cannot create GeneralName. Unsupported type of the name`)}else n=r.BufferSourceConverter.isBufferSource(e[0])?t.AsnConvert.parse(e[0],f.GeneralName):e[0];super(n)}onInit(e){if(e.dNSName!=null)this.type=`dns`,this.value=e.dNSName;else if(e.rfc822Name!=null)this.type=je,this.value=e.rfc822Name;else if(e.iPAddress!=null)this.type=`ip`,this.value=e.iPAddress;else if(e.uniformResourceIdentifier!=null)this.type=`url`,this.value=e.uniformResourceIdentifier;else if(e.registeredID!=null)this.type=`id`,this.value=e.registeredID;else if(e.directoryName!=null)this.type=`dn`,this.value=new U(e.directoryName).toString();else if(e.otherName!=null)if(e.otherName.typeId===W){this.type=Me;let n=t.AsnConvert.parse(e.otherName.value,t.OctetString),i=new RegExp(ke,`i`).exec(r.Convert.ToHex(n));if(!i)throw Error(Oe);this.value=i.slice(1).map((e,t)=>t<3?r.Convert.ToHex(new Uint8Array(r.Convert.FromHex(e)).reverse()):e).join(`-`)}else if(e.otherName.typeId===Ae)this.type=`upn`,this.value=t.AsnConvert.parse(e.otherName.value,f.DirectoryString).toString();else throw Error(De);else throw Error(De)}toJSON(){return{type:this.type,value:this.value}}toTextObject(){let e;switch(this.type){case`dn`:case`dns`:case Me:case`ip`:case`id`:case`upn`:case`url`:e=this.type.toUpperCase();break;case je:e=`Email`;break;default:throw Error(`Unsupported GeneralName type`)}let t=this.value;return this.type===`id`&&(t=_e.toString(t)),new R(e,void 0,t)}},Ne=class extends z{constructor(e){let n;if(e instanceof f.GeneralNames)n=e;else if(Array.isArray(e)){let r=[];for(let n of e)if(n instanceof f.GeneralName)r.push(n);else{let e=t.AsnConvert.parse(new G(n.type,n.value).rawData,f.GeneralName);r.push(e)}n=new f.GeneralNames(r)}else if(r.BufferSourceConverter.isBufferSource(e))n=t.AsnConvert.parse(e,f.GeneralNames);else throw Error(`Cannot initialize GeneralNames. Incorrect incoming arguments`);super(n)}onInit(e){let t=[];for(let n of e){let e=null;try{e=new G(n)}catch{continue}t.push(e)}this.items=t}toJSON(){return this.items.map(e=>e.toJSON())}toTextObject(){let e=super.toTextObjectEmpty();for(let t of this.items){let n=t.toTextObject(),r=e[n[R.NAME]];Array.isArray(r)||(r=[],e[n[R.NAME]]=r),r.push(n)}return e}};Ne.NAME=`GeneralNames`;let Pe=`-{5}`,Fe=`${`${Pe}BEGIN ([^\\n]+(?=${Pe}))${Pe}`}\\n(?:((?:[^:\\n]+: (?:[^\\n]+\\n(?: +[^\\n]+\\n)*))+))?\\n?((?:[a-zA-Z0-9=+/]+\\n)+)${`${Pe}END \\1${Pe}`}`;var K=class{static isPem(e){return typeof e==`string`&&new RegExp(Fe,`g`).test(e)}static decodeWithHeaders(e){e=e.replace(/\r/g,``);let t=new RegExp(Fe,`g`),n=[],i=null;for(;i=t.exec(e);){let e=i[3].replace(RegExp(`[\\n]+`,`g`),``),t={type:i[1],headers:[],rawData:r.Convert.FromBase64(e)},a=i[2];if(a){let e=a.split(RegExp(`\\n`,`g`)),n=null;for(let r of e){let[e,i]=r.split(/:(.*)/);if(i===void 0){if(!n)throw Error(`Cannot parse PEM string. Incorrect header value`);n.value+=e.trim()}else n&&t.headers.push(n),n={key:e,value:i.trim()}}n&&t.headers.push(n)}n.push(t)}return n}static decode(e){return this.decodeWithHeaders(e).map(e=>e.rawData)}static decodeFirst(e){let t=this.decode(e);if(!t.length)throw RangeError(`PEM string doesn't contain any objects`);return t[0]}static encode(e,t){if(Array.isArray(e)){let n=[];return t?e.forEach(e=>{if(!r.BufferSourceConverter.isBufferSource(e))throw TypeError(`Cannot encode array of BufferSource in PEM format. Not all items of the array are BufferSource`);n.push(this.encodeStruct({type:t,rawData:r.BufferSourceConverter.toArrayBuffer(e)}))}):e.forEach(e=>{if(!(`type`in e))throw TypeError(`Cannot encode array of PemStruct in PEM format. Not all items of the array are PemStrut`);n.push(this.encodeStruct(e))}),n.join(`
406
- `)}else{if(!t)throw Error(`Required argument 'tag' is missed`);return this.encodeStruct({type:t,rawData:r.BufferSourceConverter.toArrayBuffer(e)})}}static encodeStruct(e){let t=e.type.toLocaleUpperCase(),n=[];if(n.push(`-----BEGIN ${t}-----`),e.headers?.length){for(let t of e.headers)n.push(`${t.key}: ${t.value}`);n.push(``)}let i=r.Convert.ToBase64(e.rawData),a,o=0,s=[];for(;o<i.length&&(i.length-o<64?a=i.substring(o):(a=i.substring(o,o+64),o+=64),a.length!==0)&&(s.push(a),!(a.length<64)););return n.push(...s),n.push(`-----END ${t}-----`),n.join(`
407
- `)}};K.CertificateTag=`CERTIFICATE`,K.CrlTag=`CRL`,K.CertificateRequestTag=`CERTIFICATE REQUEST`,K.PublicKeyTag=`PUBLIC KEY`,K.PrivateKeyTag=`PRIVATE KEY`;var Ie=class e extends z{static isAsnEncoded(e){return r.BufferSourceConverter.isBufferSource(e)||typeof e==`string`}static toArrayBuffer(e){if(typeof e==`string`){if(K.isPem(e))return K.decode(e)[0];if(r.Convert.isHex(e))return r.Convert.FromHex(e);if(r.Convert.isBase64(e))return r.Convert.FromBase64(e);if(r.Convert.isBase64Url(e))return r.Convert.FromBase64Url(e);throw TypeError(`Unsupported format of 'raw' argument. Must be one of DER, PEM, HEX, Base64, or Base4Url`)}else{let t=r.Convert.ToBinary(e);return K.isPem(t)?K.decode(t)[0]:r.Convert.isHex(t)?r.Convert.FromHex(t):r.Convert.isBase64(t)?r.Convert.FromBase64(t):r.Convert.isBase64Url(t)?r.Convert.FromBase64Url(t):r.BufferSourceConverter.toArrayBuffer(e)}}constructor(...t){e.isAsnEncoded(t[0])?super(e.toArrayBuffer(t[0]),t[1]):super(t[0])}toString(e=`pem`){switch(e){case`pem`:return K.encode(this.rawData,this.tag);default:return super.toString(e)}}},Le=class e extends Ie{static async create(t,n=B.get()){if(t instanceof e)return t;if(xe.isCryptoKey(t)){if(t.type!==`public`)throw TypeError(`Public key is required`);return new e(await n.subtle.exportKey(`spki`,t))}else if(t.publicKey)return t.publicKey;else if(r.BufferSourceConverter.isBufferSource(t))return new e(t);else throw TypeError(`Unsupported PublicKeyType`)}constructor(e){Ie.isAsnEncoded(e)?super(e,n.SubjectPublicKeyInfo):super(e),this.tag=K.PublicKeyTag}async export(...e){let r,i=[`verify`],a={hash:`SHA-256`,...this.algorithm};e.length>1?(a=e[0]||a,i=e[1]||i,r=e[2]||B.get()):r=e[0]||B.get();let s=this.rawData,c=t.AsnConvert.parse(this.rawData,n.SubjectPublicKeyInfo);return c.algorithm.algorithm===o.id_RSASSA_PSS&&(s=Re(c,s)),r.subtle.importKey(`spki`,s,a,!0,i)}onInit(e){let n=c.container.resolve(y),i=this.algorithm=n.toWebAlgorithm(e.algorithm);switch(e.algorithm.algorithm){case o.id_rsaEncryption:{let n=t.AsnConvert.parse(e.subjectPublicKey,o.RSAPublicKey),a=r.BufferSourceConverter.toUint8Array(n.modulus);i.publicExponent=r.BufferSourceConverter.toUint8Array(n.publicExponent),i.modulusLength=(a[0]?a:a.slice(1)).byteLength<<3;break}}}async getThumbprint(...e){let t,n=`SHA-1`;return e.length>=1&&!e[0]?.subtle?(n=e[0]||n,t=e[1]||B.get()):t=e[0]||B.get(),await t.subtle.digest(n,this.rawData)}async getKeyIdentifier(...e){let r,i=`SHA-1`;e.length===1?typeof e[0]==`string`?(i=e[0],r=B.get()):r=e[0]:e.length===2?(i=e[0],r=e[1]):r=B.get();let a=t.AsnConvert.parse(this.rawData,n.SubjectPublicKeyInfo);return await r.subtle.digest(i,a.subjectPublicKey)}toTextObject(){let e=this.toTextObjectEmpty(),r=t.AsnConvert.parse(this.rawData,n.SubjectPublicKeyInfo);switch(e.Algorithm=ve.serializeAlgorithm(r.algorithm),r.algorithm.algorithm){case a.id_ecPublicKey:e[`EC Point`]=r.subjectPublicKey;break;case o.id_rsaEncryption:default:e[`Raw Data`]=r.subjectPublicKey}return e}};function Re(e,r){return e.algorithm=new n.AlgorithmIdentifier({algorithm:o.id_rsaEncryption,parameters:null}),r=t.AsnConvert.serialize(e),r}var ze=class e extends ye{static async create(t,n=!1,i=B.get()){if(`name`in t&&`serialNumber`in t)return new e(t,n);let a=await(await Le.create(t,i)).getKeyIdentifier(i);return new e(r.Convert.ToHex(a),n)}constructor(...e){if(r.BufferSourceConverter.isBufferSource(e[0]))super(e[0]);else if(typeof e[0]==`string`){let n=new f.AuthorityKeyIdentifier({keyIdentifier:new f.KeyIdentifier(r.Convert.FromHex(e[0]))});super(f.id_ce_authorityKeyIdentifier,e[1],t.AsnConvert.serialize(n))}else{let n=e[0],i=n.name instanceof Ne?t.AsnConvert.parse(n.name.rawData,f.GeneralNames):n.name,a=new f.AuthorityKeyIdentifier({authorityCertIssuer:i,authorityCertSerialNumber:r.Convert.FromHex(n.serialNumber)});super(f.id_ce_authorityKeyIdentifier,e[1],t.AsnConvert.serialize(a))}}onInit(e){super.onInit(e);let n=t.AsnConvert.parse(e.extnValue,f.AuthorityKeyIdentifier);n.keyIdentifier&&(this.keyId=r.Convert.ToHex(n.keyIdentifier)),(n.authorityCertIssuer||n.authorityCertSerialNumber)&&(this.certId={name:n.authorityCertIssuer||[],serialNumber:n.authorityCertSerialNumber?r.Convert.ToHex(n.authorityCertSerialNumber):``})}toTextObject(){let e=this.toTextObjectWithoutValue(),n=t.AsnConvert.parse(this.value,f.AuthorityKeyIdentifier);return n.authorityCertIssuer&&(e[`Authority Issuer`]=new Ne(n.authorityCertIssuer).toTextObject()),n.authorityCertSerialNumber&&(e[`Authority Serial Number`]=n.authorityCertSerialNumber),n.keyIdentifier&&(e[``]=n.keyIdentifier),e}};ze.NAME=`Authority Key Identifier`;var Be=class extends ye{constructor(...e){if(r.BufferSourceConverter.isBufferSource(e[0])){super(e[0]);let r=t.AsnConvert.parse(this.value,n.BasicConstraints);this.ca=r.cA,this.pathLength=r.pathLenConstraint}else{let r=new n.BasicConstraints({cA:e[0],pathLenConstraint:e[1]});super(n.id_ce_basicConstraints,e[2],t.AsnConvert.serialize(r)),this.ca=e[0],this.pathLength=e[1]}}toTextObject(){let e=this.toTextObjectWithoutValue();return this.ca&&(e.CA=this.ca),this.pathLength!==void 0&&(e[`Path Length`]=this.pathLength),e}};Be.NAME=`Basic Constraints`,e.ExtendedKeyUsage=void 0,(function(e){e.serverAuth=`1.3.6.1.5.5.7.3.1`,e.clientAuth=`1.3.6.1.5.5.7.3.2`,e.codeSigning=`1.3.6.1.5.5.7.3.3`,e.emailProtection=`1.3.6.1.5.5.7.3.4`,e.timeStamping=`1.3.6.1.5.5.7.3.8`,e.ocspSigning=`1.3.6.1.5.5.7.3.9`})(e.ExtendedKeyUsage||={});var Ve=class extends ye{constructor(...e){if(r.BufferSourceConverter.isBufferSource(e[0])){super(e[0]);let n=t.AsnConvert.parse(this.value,f.ExtendedKeyUsage);this.usages=n.map(e=>e)}else{let n=new f.ExtendedKeyUsage(e[0]);super(f.id_ce_extKeyUsage,e[1],t.AsnConvert.serialize(n)),this.usages=e[0]}}toTextObject(){let e=this.toTextObjectWithoutValue();return e[``]=this.usages.map(e=>_e.toString(e)).join(`, `),e}};Ve.NAME=`Extended Key Usages`,e.KeyUsageFlags=void 0,(function(e){e[e.digitalSignature=1]=`digitalSignature`,e[e.nonRepudiation=2]=`nonRepudiation`,e[e.keyEncipherment=4]=`keyEncipherment`,e[e.dataEncipherment=8]=`dataEncipherment`,e[e.keyAgreement=16]=`keyAgreement`,e[e.keyCertSign=32]=`keyCertSign`,e[e.cRLSign=64]=`cRLSign`,e[e.encipherOnly=128]=`encipherOnly`,e[e.decipherOnly=256]=`decipherOnly`})(e.KeyUsageFlags||={});var He=class extends ye{constructor(...e){if(r.BufferSourceConverter.isBufferSource(e[0])){super(e[0]);let r=t.AsnConvert.parse(this.value,n.KeyUsage);this.usages=r.toNumber()}else{let r=new n.KeyUsage(e[0]);super(n.id_ce_keyUsage,e[1],t.AsnConvert.serialize(r)),this.usages=e[0]}}toTextObject(){let e=this.toTextObjectWithoutValue();return e[``]=t.AsnConvert.parse(this.value,n.KeyUsage).toJSON().join(`, `),e}};He.NAME=`Key Usages`;var Ue=class e extends ye{static async create(t,n=!1,i=B.get()){let a=await(await Le.create(t,i)).getKeyIdentifier(i);return new e(r.Convert.ToHex(a),n)}constructor(...e){if(r.BufferSourceConverter.isBufferSource(e[0])){super(e[0]);let n=t.AsnConvert.parse(this.value,f.SubjectKeyIdentifier);this.keyId=r.Convert.ToHex(n)}else{let n=typeof e[0]==`string`?r.Convert.FromHex(e[0]):e[0],i=new f.SubjectKeyIdentifier(n);super(f.id_ce_subjectKeyIdentifier,e[1],t.AsnConvert.serialize(i)),this.keyId=r.Convert.ToHex(n)}}toTextObject(){let e=this.toTextObjectWithoutValue();return e[``]=t.AsnConvert.parse(this.value,f.SubjectKeyIdentifier),e}};Ue.NAME=`Subject Key Identifier`;var We=class extends ye{constructor(...e){r.BufferSourceConverter.isBufferSource(e[0])?super(e[0]):super(f.id_ce_subjectAltName,e[1],new Ne(e[0]||[]).rawData)}onInit(e){super.onInit(e);let n=t.AsnConvert.parse(e.extnValue,f.SubjectAlternativeName);this.names=new Ne(n)}toTextObject(){let e=this.toTextObjectWithoutValue(),t=this.names.toTextObject();for(let n in t)e[n]=t[n];return e}};We.NAME=`Subject Alternative Name`;var q=class{static register(e,t){this.items.set(e,t)}static create(e){let t=new ye(e),n=this.items.get(t.type);return n?new n(e):t}};q.items=new Map;var Ge=class extends ye{constructor(...e){if(r.BufferSourceConverter.isBufferSource(e[0])){super(e[0]);let n=t.AsnConvert.parse(this.value,f.CertificatePolicies);this.policies=n.map(e=>e.policyIdentifier)}else{let n=e[0],r=e[1]??!1,i=new f.CertificatePolicies(n.map(e=>new f.PolicyInformation({policyIdentifier:e})));super(f.id_ce_certificatePolicies,r,t.AsnConvert.serialize(i)),this.policies=n}}toTextObject(){let e=this.toTextObjectWithoutValue();return e.Policy=this.policies.map(e=>new R(``,{},_e.toString(e))),e}};Ge.NAME=`Certificate Policies`,q.register(f.id_ce_certificatePolicies,Ge);var Ke=class extends ye{constructor(...e){if(r.BufferSourceConverter.isBufferSource(e[0]))super(e[0]);else if(Array.isArray(e[0])&&typeof e[0][0]==`string`){let n=e[0].map(e=>new f.DistributionPoint({distributionPoint:new f.DistributionPointName({fullName:[new f.GeneralName({uniformResourceIdentifier:e})]})})),r=new f.CRLDistributionPoints(n);super(f.id_ce_cRLDistributionPoints,e[1],t.AsnConvert.serialize(r))}else{let n=new f.CRLDistributionPoints(e[0]);super(f.id_ce_cRLDistributionPoints,e[1],t.AsnConvert.serialize(n))}this.distributionPoints??=[]}onInit(e){super.onInit(e);let n=t.AsnConvert.parse(e.extnValue,f.CRLDistributionPoints);this.distributionPoints=n}toTextObject(){let e=this.toTextObjectWithoutValue();return e[`Distribution Point`]=this.distributionPoints.map(e=>{let t={};return e.distributionPoint&&(t[``]=e.distributionPoint.fullName?.map(e=>new G(e).toString()).join(`, `)),e.reasons&&(t.Reasons=e.reasons.toString()),e.cRLIssuer&&(t[`CRL Issuer`]=e.cRLIssuer.map(e=>e.toString()).join(`, `)),t}),e}};Ke.NAME=`CRL Distribution Points`;var qe=class extends ye{constructor(...e){if(r.BufferSourceConverter.isBufferSource(e[0]))super(e[0]);else if(e[0]instanceof f.AuthorityInfoAccessSyntax){let n=new f.AuthorityInfoAccessSyntax(e[0]);super(f.id_pe_authorityInfoAccess,e[1],t.AsnConvert.serialize(n))}else{let n=e[0],r=new f.AuthorityInfoAccessSyntax;Ye(r,n,f.id_ad_ocsp,`ocsp`),Ye(r,n,f.id_ad_caIssuers,`caIssuers`),Ye(r,n,f.id_ad_timeStamping,`timeStamping`),Ye(r,n,f.id_ad_caRepository,`caRepository`),super(f.id_pe_authorityInfoAccess,e[1],t.AsnConvert.serialize(r))}this.ocsp??=[],this.caIssuers??=[],this.timeStamping??=[],this.caRepository??=[]}onInit(e){super.onInit(e),this.ocsp=[],this.caIssuers=[],this.timeStamping=[],this.caRepository=[],t.AsnConvert.parse(e.extnValue,f.AuthorityInfoAccessSyntax).forEach(e=>{switch(e.accessMethod){case f.id_ad_ocsp:this.ocsp.push(new G(e.accessLocation));break;case f.id_ad_caIssuers:this.caIssuers.push(new G(e.accessLocation));break;case f.id_ad_timeStamping:this.timeStamping.push(new G(e.accessLocation));break;case f.id_ad_caRepository:this.caRepository.push(new G(e.accessLocation));break}})}toTextObject(){let e=this.toTextObjectWithoutValue();return this.ocsp.length&&Je(e,`OCSP`,this.ocsp),this.caIssuers.length&&Je(e,`CA Issuers`,this.caIssuers),this.timeStamping.length&&Je(e,`Time Stamping`,this.timeStamping),this.caRepository.length&&Je(e,`CA Repository`,this.caRepository),e}};qe.NAME=`Authority Info Access`;function Je(e,t,n){if(n.length===1)e[t]=n[0].toTextObject();else{let r=new R(``);n.forEach((e,t)=>{let n=e.toTextObject(),i=`${n[R.NAME]} ${t+1}`,a=r[i];Array.isArray(a)||(a=[],r[i]=a),a.push(n)}),e[t]=r}}function Ye(e,n,r,i){let a=n[i];a&&(Array.isArray(a)?a:[a]).forEach(n=>{typeof n==`string`&&(n=new G(`url`,n)),e.push(new f.AccessDescription({accessMethod:r,accessLocation:t.AsnConvert.parse(n.rawData,f.GeneralName)}))})}var Xe=class e extends z{constructor(...e){let i;if(r.BufferSourceConverter.isBufferSource(e[0]))i=r.BufferSourceConverter.toArrayBuffer(e[0]);else{let a=e[0],o=Array.isArray(e[1])?e[1].map(e=>r.BufferSourceConverter.toArrayBuffer(e)):[];i=t.AsnConvert.serialize(new n.Attribute({type:a,values:o}))}super(i,n.Attribute)}onInit(e){this.type=e.type,this.values=e.values}toTextObject(){let e=this.toTextObjectWithoutValue();return e.Value=this.values.map(e=>new R(``,{"":e})),e}toTextObjectWithoutValue(){let t=this.toTextObjectEmpty();return t[R.NAME]===e.NAME&&(t[R.NAME]=_e.toString(this.type)),t}};Xe.NAME=`Attribute`;var Ze=class extends Xe{constructor(...e){if(r.BufferSourceConverter.isBufferSource(e[0]))super(e[0]);else{let n=new g.ChallengePassword({printableString:e[0]});super(g.id_pkcs9_at_challengePassword,[t.AsnConvert.serialize(n)])}this.password??=``}onInit(e){if(super.onInit(e),this.values[0]){let e=t.AsnConvert.parse(this.values[0],g.ChallengePassword);this.password=e.toString()}}toTextObject(){let e=this.toTextObjectWithoutValue();return e[R.VALUE]=this.password,e}};Ze.NAME=`Challenge Password`;var Qe=class extends Xe{constructor(...e){if(r.BufferSourceConverter.isBufferSource(e[0]))super(e[0]);else{let n=e[0],r=new f.Extensions;for(let e of n)r.push(t.AsnConvert.parse(e.rawData,f.Extension));super(g.id_pkcs9_at_extensionRequest,[t.AsnConvert.serialize(r)])}this.items??=[]}onInit(e){if(super.onInit(e),this.values[0]){let e=t.AsnConvert.parse(this.values[0],f.Extensions);this.items=e.map(e=>q.create(t.AsnConvert.serialize(e)))}}toTextObject(){let e=this.toTextObjectWithoutValue(),t=this.items.map(e=>e.toTextObject());for(let n of t)e[n[R.NAME]]=n;return e}};Qe.NAME=`Extensions`;var $e=class{static register(e,t){this.items.set(e,t)}static create(e){let t=new Xe(e),n=this.items.get(t.type);return n?new n(e):t}};$e.items=new Map;let et=`crypto.signatureFormatter`;var tt=class{toAsnSignature(e,t){return r.BufferSourceConverter.toArrayBuffer(t)}toWebSignature(e,t){return r.BufferSourceConverter.toArrayBuffer(t)}},nt;e.RsaAlgorithm=nt=class{static createPssParams(e,r){let i=nt.getHashAlgorithm(e);return i?new h.RsaSaPssParams({hashAlgorithm:i,maskGenAlgorithm:new n.AlgorithmIdentifier({algorithm:h.id_mgf1,parameters:t.AsnConvert.serialize(i)}),saltLength:r}):null}static getHashAlgorithm(e){let t=c.container.resolve(y);return typeof e==`string`?t.toAsnAlgorithm({name:e}):typeof e==`object`&&e&&`name`in e?t.toAsnAlgorithm(e):null}toAsnAlgorithm(e){switch(e.name.toLowerCase()){case`rsassa-pkcs1-v1_5`:if(`hash`in e){let t;if(typeof e.hash==`string`)t=e.hash;else if(e.hash&&typeof e.hash==`object`&&`name`in e.hash&&typeof e.hash.name==`string`)t=e.hash.name.toUpperCase();else throw Error(`Cannot get hash algorithm name`);switch(t.toLowerCase()){case`sha-1`:return new n.AlgorithmIdentifier({algorithm:h.id_sha1WithRSAEncryption,parameters:null});case`sha-256`:return new n.AlgorithmIdentifier({algorithm:h.id_sha256WithRSAEncryption,parameters:null});case`sha-384`:return new n.AlgorithmIdentifier({algorithm:h.id_sha384WithRSAEncryption,parameters:null});case`sha-512`:return new n.AlgorithmIdentifier({algorithm:h.id_sha512WithRSAEncryption,parameters:null})}}else return new n.AlgorithmIdentifier({algorithm:h.id_rsaEncryption,parameters:null});break;case`rsa-pss`:if(`hash`in e){if(!(`saltLength`in e&&typeof e.saltLength==`number`))throw Error(`Cannot get 'saltLength' from 'alg' argument`);let r=nt.createPssParams(e.hash,e.saltLength);if(!r)throw Error(`Cannot create PSS parameters`);return new n.AlgorithmIdentifier({algorithm:h.id_RSASSA_PSS,parameters:t.AsnConvert.serialize(r)})}else return new n.AlgorithmIdentifier({algorithm:h.id_RSASSA_PSS,parameters:null})}return null}toWebAlgorithm(e){switch(e.algorithm){case h.id_rsaEncryption:return{name:`RSASSA-PKCS1-v1_5`};case h.id_sha1WithRSAEncryption:return{name:`RSASSA-PKCS1-v1_5`,hash:{name:`SHA-1`}};case h.id_sha256WithRSAEncryption:return{name:`RSASSA-PKCS1-v1_5`,hash:{name:`SHA-256`}};case h.id_sha384WithRSAEncryption:return{name:`RSASSA-PKCS1-v1_5`,hash:{name:`SHA-384`}};case h.id_sha512WithRSAEncryption:return{name:`RSASSA-PKCS1-v1_5`,hash:{name:`SHA-512`}};case h.id_RSASSA_PSS:if(e.parameters){let n=t.AsnConvert.parse(e.parameters,h.RsaSaPssParams);return{name:`RSA-PSS`,hash:c.container.resolve(y).toWebAlgorithm(n.hashAlgorithm),saltLength:n.saltLength}}else return{name:`RSA-PSS`}}return null}},e.RsaAlgorithm=nt=s.__decorate([c.injectable()],e.RsaAlgorithm),c.container.registerSingleton(_,e.RsaAlgorithm),e.ShaAlgorithm=class{toAsnAlgorithm(e){switch(e.name.toLowerCase()){case`sha-1`:return new n.AlgorithmIdentifier({algorithm:o.id_sha1});case`sha-256`:return new n.AlgorithmIdentifier({algorithm:o.id_sha256});case`sha-384`:return new n.AlgorithmIdentifier({algorithm:o.id_sha384});case`sha-512`:return new n.AlgorithmIdentifier({algorithm:o.id_sha512})}return null}toWebAlgorithm(e){switch(e.algorithm){case o.id_sha1:return{name:`SHA-1`};case o.id_sha256:return{name:`SHA-256`};case o.id_sha384:return{name:`SHA-384`};case o.id_sha512:return{name:`SHA-512`}}return null}},e.ShaAlgorithm=s.__decorate([c.injectable()],e.ShaAlgorithm),c.container.registerSingleton(_,e.ShaAlgorithm);var rt=class e{addPadding(e,t){let n=r.BufferSourceConverter.toUint8Array(t),i=new Uint8Array(e);return i.set(n,e-n.length),i}removePadding(e,t=!1){let n=r.BufferSourceConverter.toUint8Array(e);for(let e=0;e<n.length;e++)if(n[e]){n=n.slice(e);break}if(t&&n[0]>127){let e=new Uint8Array(n.length+1);return e.set(n,1),e.buffer}return n.buffer}toAsnSignature(n,i){if(n.name===`ECDSA`){let o=n.namedCurve,s=e.namedCurveSize.get(o)||e.defaultNamedCurveSize,c=new a.ECDSASigValue,l=r.BufferSourceConverter.toUint8Array(i);return c.r=this.removePadding(l.slice(0,s),!0),c.s=this.removePadding(l.slice(s,s+s),!0),t.AsnConvert.serialize(c)}return null}toWebSignature(n,i){if(n.name===`ECDSA`){let o=t.AsnConvert.parse(i,a.ECDSASigValue),s=n.namedCurve,c=e.namedCurveSize.get(s)||e.defaultNamedCurveSize,l=this.addPadding(c,this.removePadding(o.r)),u=this.addPadding(c,this.removePadding(o.s));return r.combine(l,u)}return null}};rt.namedCurveSize=new Map,rt.defaultNamedCurveSize=32;let it=`1.3.101.110`,at=`1.3.101.111`,ot=`1.3.101.112`,st=`1.3.101.113`;e.EdAlgorithm=class{toAsnAlgorithm(e){let t=null;switch(e.name.toLowerCase()){case`ed25519`:t=ot;break;case`x25519`:t=it;break;case`eddsa`:switch(e.namedCurve.toLowerCase()){case`ed25519`:t=ot;break;case`ed448`:t=st;break}break;case`ecdh-es`:switch(e.namedCurve.toLowerCase()){case`x25519`:t=it;break;case`x448`:t=at;break}}return t?new n.AlgorithmIdentifier({algorithm:t}):null}toWebAlgorithm(e){switch(e.algorithm){case ot:return{name:`Ed25519`};case st:return{name:`EdDSA`,namedCurve:`Ed448`};case it:return{name:`X25519`};case at:return{name:`ECDH-ES`,namedCurve:`X448`}}return null}},e.EdAlgorithm=s.__decorate([c.injectable()],e.EdAlgorithm),c.container.registerSingleton(_,e.EdAlgorithm);var ct=class extends Ie{constructor(e){Ie.isAsnEncoded(e)?super(e,u.CertificationRequest):super(e),this.tag=K.CertificateRequestTag}onInit(e){this.tbs=t.AsnConvert.serialize(e.certificationRequestInfo),this.publicKey=new Le(e.certificationRequestInfo.subjectPKInfo);let n=c.container.resolve(y);this.signatureAlgorithm=n.toWebAlgorithm(e.signatureAlgorithm),this.signature=e.signature,this.attributes=e.certificationRequestInfo.attributes.map(e=>$e.create(t.AsnConvert.serialize(e)));let r=this.getAttribute(l.id_pkcs9_at_extensionRequest);this.extensions=[],r instanceof Qe&&(this.extensions=r.items),this.subjectName=new U(e.certificationRequestInfo.subject),this.subject=this.subjectName.toString()}getAttribute(e){for(let t of this.attributes)if(t.type===e)return t;return null}getAttributes(e){return this.attributes.filter(t=>t.type===e)}getExtension(e){for(let t of this.extensions)if(t.type===e)return t;return null}getExtensions(e){return this.extensions.filter(t=>t.type===e)}async verify(e=B.get()){let t={...this.publicKey.algorithm,...this.signatureAlgorithm},n=await this.publicKey.export(t,[`verify`],e),r=c.container.resolveAll(et).reverse(),i=null;for(let e of r)if(i=e.toWebSignature(t,this.signature),i)break;if(!i)throw Error(`Cannot convert WebCrypto signature value to ASN.1 format`);return await e.subtle.verify(this.signatureAlgorithm,n,i,this.tbs)}toTextObject(){let e=this.toTextObjectEmpty(),r=t.AsnConvert.parse(this.rawData,u.CertificationRequest),i=r.certificationRequestInfo,a=new R(``,{Version:`${n.Version[i.version]} (${i.version})`,Subject:this.subject,"Subject Public Key Info":this.publicKey});if(this.attributes.length){let e=new R(``);for(let t of this.attributes){let n=t.toTextObject();e[n[R.NAME]]=n}a.Attributes=e}return e.Data=a,e.Signature=new R(``,{Algorithm:ve.serializeAlgorithm(r.signatureAlgorithm),"":r.signature}),e}};ct.NAME=`PKCS#10 Certificate Request`;var lt=class{static async create(e,r=B.get()){if(!e.keys.privateKey)throw Error(`Bad field 'keys' in 'params' argument. 'privateKey' is empty`);if(!e.keys.publicKey)throw Error(`Bad field 'keys' in 'params' argument. 'publicKey' is empty`);let i=await r.subtle.exportKey(`spki`,e.keys.publicKey),a=new u.CertificationRequest({certificationRequestInfo:new u.CertificationRequestInfo({subjectPKInfo:t.AsnConvert.parse(i,n.SubjectPublicKeyInfo)})});if(e.name){let r=e.name instanceof U?e.name:new U(e.name);a.certificationRequestInfo.subject=t.AsnConvert.parse(r.toArrayBuffer(),n.Name)}if(e.attributes)for(let r of e.attributes)a.certificationRequestInfo.attributes.push(t.AsnConvert.parse(r.rawData,n.Attribute));if(e.extensions&&e.extensions.length){let r=new n.Attribute({type:l.id_pkcs9_at_extensionRequest}),i=new n.Extensions;for(let r of e.extensions)i.push(t.AsnConvert.parse(r.rawData,n.Extension));r.values.push(t.AsnConvert.serialize(i)),a.certificationRequestInfo.attributes.push(r)}let o={...e.signingAlgorithm,...e.keys.privateKey.algorithm};a.signatureAlgorithm=c.container.resolve(y).toAsnAlgorithm(o);let s=t.AsnConvert.serialize(a.certificationRequestInfo),d=await r.subtle.sign(o,e.keys.privateKey,s),f=c.container.resolveAll(et).reverse(),p=null;for(let e of f)if(p=e.toAsnSignature(o,d),p)break;if(!p)throw Error(`Cannot convert WebCrypto signature value to ASN.1 format`);return a.signature=p,new ct(t.AsnConvert.serialize(a))}},ut=class extends Ie{constructor(e){Ie.isAsnEncoded(e)?super(e,n.Certificate):super(e),this.tag=K.CertificateTag}onInit(e){let n=e.tbsCertificate;this.tbs=t.AsnConvert.serialize(n),this.serialNumber=r.Convert.ToHex(n.serialNumber),this.subjectName=new U(n.subject),this.subject=new U(n.subject).toString(),this.issuerName=new U(n.issuer),this.issuer=this.issuerName.toString();let i=c.container.resolve(y);this.signatureAlgorithm=i.toWebAlgorithm(e.signatureAlgorithm),this.signature=e.signatureValue;let a=n.validity.notBefore.utcTime||n.validity.notBefore.generalTime;if(!a)throw Error(`Cannot get 'notBefore' value`);this.notBefore=a;let o=n.validity.notAfter.utcTime||n.validity.notAfter.generalTime;if(!o)throw Error(`Cannot get 'notAfter' value`);this.notAfter=o,this.extensions=[],n.extensions&&(this.extensions=n.extensions.map(e=>q.create(t.AsnConvert.serialize(e)))),this.publicKey=new Le(n.subjectPublicKeyInfo)}getExtension(e){for(let t of this.extensions)if(typeof e==`string`){if(t.type===e)return t}else if(t instanceof e)return t;return null}getExtensions(e){return this.extensions.filter(t=>typeof e==`string`?t.type===e:t instanceof e)}async verify(e={},t=B.get()){let n,i,a=e.publicKey;try{if(!a)n={...this.publicKey.algorithm,...this.signatureAlgorithm},i=await this.publicKey.export(n,[`verify`],t);else if(`publicKey`in a)n={...a.publicKey.algorithm,...this.signatureAlgorithm},i=await a.publicKey.export(n,[`verify`],t);else if(a instanceof Le)n={...a.algorithm,...this.signatureAlgorithm},i=await a.export(n,[`verify`],t);else if(r.BufferSourceConverter.isBufferSource(a)){let e=new Le(a);n={...e.algorithm,...this.signatureAlgorithm},i=await e.export(n,[`verify`],t)}else n={...a.algorithm,...this.signatureAlgorithm},i=a}catch{return!1}let o=c.container.resolveAll(et).reverse(),s=null;for(let e of o)if(s=e.toWebSignature(n,this.signature),s)break;if(!s)throw Error(`Cannot convert ASN.1 signature value to WebCrypto format`);let l=await t.subtle.verify(this.signatureAlgorithm,i,s,this.tbs);if(e.signatureOnly)return l;{let t=(e.date||new Date).getTime();return l&&this.notBefore.getTime()<t&&t<this.notAfter.getTime()}}async getThumbprint(...e){let t,n=`SHA-1`;return e[0]&&(e[0].subtle?t=e[0]:(n=e[0]||n,t=e[1])),t??=B.get(),await t.subtle.digest(n,this.rawData)}async isSelfSigned(e=B.get()){return this.subject===this.issuer&&await this.verify({signatureOnly:!0},e)}toTextObject(){let e=this.toTextObjectEmpty(),r=t.AsnConvert.parse(this.rawData,n.Certificate),i=r.tbsCertificate,a=new R(``,{Version:`${n.Version[i.version]} (${i.version})`,"Serial Number":i.serialNumber,"Signature Algorithm":ve.serializeAlgorithm(i.signature),Issuer:this.issuer,Validity:new R(``,{"Not Before":i.validity.notBefore.getTime(),"Not After":i.validity.notAfter.getTime()}),Subject:this.subject,"Subject Public Key Info":this.publicKey});if(i.issuerUniqueID&&(a[`Issuer Unique ID`]=i.issuerUniqueID),i.subjectUniqueID&&(a[`Subject Unique ID`]=i.subjectUniqueID),this.extensions.length){let e=new R(``);for(let t of this.extensions){let n=t.toTextObject();e[n[R.NAME]]=n}a.Extensions=e}return e.Data=a,e.Signature=new R(``,{Algorithm:ve.serializeAlgorithm(r.signatureAlgorithm),"":r.signatureValue}),e}};ut.NAME=`Certificate`;var dt=class extends Array{constructor(e){if(super(),Ie.isAsnEncoded(e))this.import(e);else if(e instanceof ut)this.push(e);else if(Array.isArray(e))for(let t of e)this.push(t)}export(e){let r=new p.SignedData;r.version=1,r.encapContentInfo.eContentType=p.id_data,r.encapContentInfo.eContent=new p.EncapsulatedContent({single:new t.OctetString}),r.certificates=new p.CertificateSet(this.map(e=>new p.CertificateChoices({certificate:t.AsnConvert.parse(e.rawData,n.Certificate)})));let i=new p.ContentInfo({contentType:p.id_signedData,content:t.AsnConvert.serialize(r)}),a=t.AsnConvert.serialize(i);return e===`raw`?a:this.toString(e)}import(e){let n=Ie.toArrayBuffer(e),r=t.AsnConvert.parse(n,p.ContentInfo);if(r.contentType!==p.id_signedData)throw TypeError(`Cannot parse CMS package. Incoming data is not a SignedData object.`);let i=t.AsnConvert.parse(r.content,p.SignedData);this.clear();for(let e of i.certificates||[])e.certificate&&this.push(new ut(e.certificate))}clear(){for(;this.pop(););}toString(e=`pem`){let n=this.export(`raw`);switch(e){case`pem`:return K.encode(n,`CMS`);case`pem-chain`:return this.map(e=>e.toString(`pem`)).join(`
408
- `);case`asn`:return t.AsnConvert.toString(n);case`hex`:return r.Convert.ToHex(n);case`base64`:return r.Convert.ToBase64(n);case`base64url`:return r.Convert.ToBase64Url(n);case`text`:return ve.serialize(this.toTextObject());default:throw TypeError(`Argument 'format' is unsupported value`)}}toTextObject(){let e=t.AsnConvert.parse(this.export(`raw`),p.ContentInfo),n=t.AsnConvert.parse(e.content,p.SignedData);return new R(`X509Certificates`,{"Content Type":_e.toString(e.contentType),Content:new R(``,{Version:`${p.CMSVersion[n.version]} (${n.version})`,Certificates:new R(``,{Certificate:this.map(e=>e.toTextObject())})})})}},ft=class{constructor(e={}){this.certificates=[],e.certificates&&(this.certificates=e.certificates)}async build(e,t=B.get()){let n=new dt(e),i=e;for(;i=await this.findIssuer(i,t);){let e=await i.getThumbprint(t);for(let i of n){let n=await i.getThumbprint(t);if(r.isEqual(e,n))throw Error(`Cannot build a certificate chain. Circular dependency.`)}n.push(i)}return n}async findIssuer(e,n=B.get()){if(!await e.isSelfSigned(n)){let i=e.getExtension(f.id_ce_authorityKeyIdentifier);for(let a of this.certificates)if(a.subject===e.issuer){if(i){if(i.keyId){let e=a.getExtension(f.id_ce_subjectKeyIdentifier);if(e&&e.keyId!==i.keyId)continue}else if(i.certId){let e=a.getExtension(f.id_ce_subjectAltName);if(e&&!(i.certId.serialNumber===a.serialNumber&&r.isEqual(t.AsnConvert.serialize(i.certId.name),t.AsnConvert.serialize(e))))continue}}try{let t={...a.publicKey.algorithm,...e.signatureAlgorithm},r=await a.publicKey.export(t,[`verify`],n);if(!await e.verify({publicKey:r,signatureOnly:!0},n))continue}catch{continue}return a}}return null}},pt=class{static async createSelfSigned(e,t=B.get()){if(!e.keys.privateKey)throw Error(`Bad field 'keys' in 'params' argument. 'privateKey' is empty`);if(!e.keys.publicKey)throw Error(`Bad field 'keys' in 'params' argument. 'publicKey' is empty`);return this.create({serialNumber:e.serialNumber,subject:e.name,issuer:e.name,notBefore:e.notBefore,notAfter:e.notAfter,publicKey:e.keys.publicKey,signingKey:e.keys.privateKey,signingAlgorithm:e.signingAlgorithm,extensions:e.extensions},t)}static async create(e,n=B.get()){let i;i=e.publicKey instanceof Le?e.publicKey.rawData:`publicKey`in e.publicKey?e.publicKey.publicKey.rawData:r.BufferSourceConverter.isBufferSource(e.publicKey)?e.publicKey:await n.subtle.exportKey(`spki`,e.publicKey);let a=e.serialNumber?r.BufferSourceConverter.toUint8Array(r.Convert.FromHex(e.serialNumber)):n.getRandomValues(new Uint8Array(16));a[0]>127&&(a[0]&=127),a.length>1&&a[0]===0&&(a[1]|=128);let o=e.notBefore||new Date,s=e.notAfter||new Date(o.getTime()+31536e6),l=new f.Certificate({tbsCertificate:new f.TBSCertificate({version:f.Version.v3,serialNumber:a,validity:new f.Validity({notBefore:o,notAfter:s}),extensions:new f.Extensions(e.extensions?.map(e=>t.AsnConvert.parse(e.rawData,f.Extension))||[]),subjectPublicKeyInfo:t.AsnConvert.parse(i,f.SubjectPublicKeyInfo)})});if(e.subject){let n=e.subject instanceof U?e.subject:new U(e.subject);l.tbsCertificate.subject=t.AsnConvert.parse(n.toArrayBuffer(),f.Name)}if(e.issuer){let n=e.issuer instanceof U?e.issuer:new U(e.issuer);l.tbsCertificate.issuer=t.AsnConvert.parse(n.toArrayBuffer(),f.Name)}let u={hash:`SHA-256`},d=`signingKey`in e?{...u,...e.signingAlgorithm,...e.signingKey.algorithm}:{...u,...e.signingAlgorithm},p=c.container.resolve(y);l.tbsCertificate.signature=l.signatureAlgorithm=p.toAsnAlgorithm(d);let m=t.AsnConvert.serialize(l.tbsCertificate),h=`signingKey`in e?await n.subtle.sign(d,e.signingKey,m):e.signature,g=c.container.resolveAll(et).reverse(),_=null;for(let e of g)if(_=e.toAsnSignature(d,h),_)break;if(!_)throw Error(`Cannot convert ASN.1 signature value to WebCrypto format`);return l.signatureValue=_,new ut(t.AsnConvert.serialize(l))}};e.X509CrlReason=void 0,(function(e){e[e.unspecified=0]=`unspecified`,e[e.keyCompromise=1]=`keyCompromise`,e[e.cACompromise=2]=`cACompromise`,e[e.affiliationChanged=3]=`affiliationChanged`,e[e.superseded=4]=`superseded`,e[e.cessationOfOperation=5]=`cessationOfOperation`,e[e.certificateHold=6]=`certificateHold`,e[e.removeFromCRL=8]=`removeFromCRL`,e[e.privilegeWithdrawn=9]=`privilegeWithdrawn`,e[e.aACompromise=10]=`aACompromise`})(e.X509CrlReason||={});var mt=class extends z{constructor(...e){let i;i=r.BufferSourceConverter.isBufferSource(e[0])?r.BufferSourceConverter.toArrayBuffer(e[0]):t.AsnConvert.serialize(new n.RevokedCertificate({userCertificate:e[0],revocationDate:new n.Time(e[1]),crlEntryExtensions:e[2]})),super(i,n.RevokedCertificate)}onInit(e){this.serialNumber=r.Convert.ToHex(e.userCertificate),this.revocationDate=e.revocationDate.getTime(),this.extensions=[],e.crlEntryExtensions&&(this.extensions=e.crlEntryExtensions.map(e=>{let r=q.create(t.AsnConvert.serialize(e));switch(r.type){case n.id_ce_cRLReasons:this.reason=t.AsnConvert.parse(r.value,n.CRLReason).reason;break;case n.id_ce_invalidityDate:this.invalidity=t.AsnConvert.parse(r.value,n.InvalidityDate).value;break}return r}))}},ht=class extends Ie{constructor(e){Ie.isAsnEncoded(e)?super(e,n.CertificateList):super(e),this.tag=K.CrlTag}onInit(e){let n=e.tbsCertList;this.tbs=t.AsnConvert.serialize(n),this.version=n.version;let r=c.container.resolve(y);this.signatureAlgorithm=r.toWebAlgorithm(e.signatureAlgorithm),this.tbsCertListSignatureAlgorithm=n.signature,this.certListSignatureAlgorithm=e.signatureAlgorithm,this.signature=e.signature,this.issuerName=new U(n.issuer),this.issuer=this.issuerName.toString();let i=n.thisUpdate.getTime();if(!i)throw Error(`Cannot get 'thisUpdate' value`);this.thisUpdate=i;let a=n.nextUpdate?.getTime();this.nextUpdate=a,this.entries=n.revokedCertificates?.map(e=>new mt(t.AsnConvert.serialize(e)))||[],this.extensions=[],n.crlExtensions&&(this.extensions=n.crlExtensions.map(e=>q.create(t.AsnConvert.serialize(e))))}getExtension(e){for(let t of this.extensions)if(typeof e==`string`){if(t.type===e)return t}else if(t instanceof e)return t;return null}getExtensions(e){return this.extensions.filter(t=>typeof e==`string`?t.type===e:t instanceof e)}async verify(e,t=B.get()){if(!this.certListSignatureAlgorithm.isEqual(this.tbsCertListSignatureAlgorithm))throw Error(`algorithm identifier in the sequence tbsCertList and CertificateList mismatch`);let n,r,i=e.publicKey;try{i instanceof ut?(n={...i.publicKey.algorithm,...i.signatureAlgorithm},r=await i.publicKey.export(n,[`verify`])):i instanceof Le?(n={...i.algorithm,...this.signature},r=await i.export(n,[`verify`])):(n={...i.algorithm,...this.signature},r=i)}catch{return!1}let a=c.container.resolveAll(et).reverse(),o=null;for(let e of a)if(o=e.toWebSignature(n,this.signature),o)break;if(!o)throw Error(`Cannot convert ASN.1 signature value to WebCrypto format`);return await t.subtle.verify(this.signatureAlgorithm,r,o,this.tbs)}async getThumbprint(...e){let t,n=`SHA-1`;return e[0]&&(e[0].subtle?t=e[0]:(n=e[0]||n,t=e[1])),t??=B.get(),await t.subtle.digest(n,this.rawData)}findRevoked(e){let t=typeof e==`string`?e:e.serialNumber;for(let e of this.entries)if(e.serialNumber===t)return e;return null}},gt=class{static async create(e,i=B.get()){let a=e.issuer instanceof U?e.issuer:new U(e.issuer),o=new f.CertificateList({tbsCertList:new f.TBSCertList({version:f.Version.v2,issuer:t.AsnConvert.parse(a.toArrayBuffer(),f.Name),thisUpdate:new n.Time(e.thisUpdate||new Date)})});if(e.nextUpdate&&(o.tbsCertList.nextUpdate=new n.Time(e.nextUpdate)),e.extensions&&e.extensions.length&&(o.tbsCertList.crlExtensions=new f.Extensions(e.extensions.map(e=>t.AsnConvert.parse(e.rawData,f.Extension))||[])),e.entries&&e.entries.length){o.tbsCertList.revokedCertificates=[];for(let i of e.entries){let a=Ie.toArrayBuffer(i.serialNumber);if(o.tbsCertList.revokedCertificates.findIndex(e=>r.isEqual(e.userCertificate,a))>-1)throw Error(`Certificate serial number ${i.serialNumber} already exists in tbsCertList`);let s=new n.RevokedCertificate({userCertificate:a,revocationDate:new n.Time(i.revocationDate||new Date)});if(`extensions`in i&&i.extensions?.length?s.crlEntryExtensions=i.extensions.map(e=>t.AsnConvert.parse(e.rawData,f.Extension)):s.crlEntryExtensions=[],!(i instanceof mt)&&(i.reason&&s.crlEntryExtensions.push(new f.Extension({extnID:f.id_ce_cRLReasons,critical:!1,extnValue:new t.OctetString(t.AsnConvert.serialize(new f.CRLReason(i.reason)))})),i.invalidity&&s.crlEntryExtensions.push(new f.Extension({extnID:f.id_ce_invalidityDate,critical:!1,extnValue:new t.OctetString(t.AsnConvert.serialize(new f.InvalidityDate(i.invalidity)))})),i.issuer)){let n=e.issuer instanceof U?e.issuer:new U(e.issuer);s.crlEntryExtensions.push(new f.Extension({extnID:f.id_ce_certificateIssuer,critical:!1,extnValue:new t.OctetString(t.AsnConvert.serialize(t.AsnConvert.parse(n.toArrayBuffer(),f.Name)))}))}o.tbsCertList.revokedCertificates.push(s)}}let s={...e.signingAlgorithm,...e.signingKey.algorithm},l=c.container.resolve(y);o.tbsCertList.signature=o.signatureAlgorithm=l.toAsnAlgorithm(s);let u=t.AsnConvert.serialize(o.tbsCertList),d=await i.subtle.sign(s,e.signingKey,u),p=c.container.resolveAll(et).reverse(),m=null;for(let e of p)if(m=e.toAsnSignature(s,d),m)break;if(!m)throw Error(`Cannot convert ASN.1 signature value to WebCrypto format`);return o.signature=m,new ht(t.AsnConvert.serialize(o))}};q.register(f.id_ce_basicConstraints,Be),q.register(f.id_ce_extKeyUsage,Ve),q.register(f.id_ce_keyUsage,He),q.register(f.id_ce_subjectKeyIdentifier,Ue),q.register(f.id_ce_authorityKeyIdentifier,ze),q.register(f.id_ce_subjectAltName,We),q.register(f.id_ce_cRLDistributionPoints,Ke),q.register(f.id_pe_authorityInfoAccess,qe),$e.register(g.id_pkcs9_at_challengePassword,Ze),$e.register(g.id_pkcs9_at_extensionRequest,Qe),c.container.registerSingleton(et,tt),c.container.registerSingleton(et,rt),rt.namedCurveSize.set(`P-256`,32),rt.namedCurveSize.set(`K-256`,32),rt.namedCurveSize.set(`P-384`,48),rt.namedCurveSize.set(`P-521`,66),e.AlgorithmProvider=v,e.AsnData=z,e.AsnDefaultSignatureFormatter=tt,e.AsnEcSignatureFormatter=rt,e.Attribute=Xe,e.AttributeFactory=$e,e.AuthorityInfoAccessExtension=qe,e.AuthorityKeyIdentifierExtension=ze,e.BasicConstraintsExtension=Be,e.CRLDistributionPointsExtension=Ke,e.CertificatePolicyExtension=Ge,e.ChallengePasswordAttribute=Ze,e.CryptoProvider=xe,e.DefaultAlgorithmSerializer=ge,e.ExtendedKeyUsageExtension=Ve,e.Extension=ye,e.ExtensionFactory=q,e.ExtensionsAttribute=Qe,e.GeneralName=G,e.GeneralNames=Ne,e.KeyUsagesExtension=He,e.Name=U,e.NameIdentifier=we,e.OidSerializer=_e,e.PemConverter=K,e.Pkcs10CertificateRequest=ct,e.Pkcs10CertificateRequestGenerator=lt,e.PublicKey=Le,e.SubjectAlternativeNameExtension=We,e.SubjectKeyIdentifierExtension=Ue,e.TextConverter=ve,e.TextObject=R,e.X509Certificate=ut,e.X509CertificateGenerator=pt,e.X509Certificates=dt,e.X509ChainBuilder=ft,e.X509Crl=ht,e.X509CrlEntry=mt,e.X509CrlGenerator=gt,e.cryptoProvider=B,e.diAlgorithm=_,e.diAlgorithmProvider=y,e.diAsnSignatureFormatter=et,e.idEd25519=ot,e.idEd448=st,e.idX25519=it,e.idX448=at}));xo(),od();
409
- /**
410
- * Code modified from https://github.com/google/tink/blob/6f74b99a2bfe6677e3670799116a57268fd067fa/javascript/subtle/bytes.ts
411
- *
412
- * @license
413
- * Copyright 2020 Google LLC
414
- * SPDX-License-Identifier: Apache-2.0
415
- */
416
- function sd(e){if(e.length%2!=0)throw Error(`Hex string length must be multiple of 2`);let t=new Uint8Array(e.length/2);for(let n=0;n<e.length;n+=2)t[n/2]=parseInt(e.substring(n,n+2),16);return t}function cd(e){let t=``;for(let n=0;n<e.length;n++){let r=e[n].toString(16);t+=r.length>1?r:`0`+r}return t}function ld(e,t){return btoa(ud(e)).replace(/=/g,``).replace(/\+/g,`-`).replace(/\//g,`_`)}function ud(e){let t=``;for(let n=0;n<e.length;n+=1)t+=String.fromCharCode(e[n]);return t}
417
- /**
418
- * Code modified from https://github.com/google/tink/blob/6f74b99a2bfe6677e3670799116a57268fd067fa/javascript/subtle/elliptic_curves.ts
419
- * - The implementation of integerToByteArray has been modified to augment the resulting byte array to a certain length.
420
- * - The implementation of PointDecode has been modified to decode both compressed and uncompressed points by checking for correct format
421
- * - Method isP256CurvePoint added to check whether an uncompressed point is valid
422
- *
423
- * @license
424
- * Copyright 2020 Google LLC
425
- * SPDX-License-Identifier: Apache-2.0
426
- */
427
- function dd(){return BigInt(`115792089210356248762697446949407573530086143415290314195533631308867097853951`)}function fd(){return BigInt(`0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b`)}function pd(e){return BigInt(`0x`+cd(e))}function md(e,t){let n=e.toString(16),r=t*2,i=``;if(r<n.length)throw Error(`cannot pack integer with ${n.length} hex chars into ${t} bytes`);return i=`0`.repeat(r-n.length),sd(i+n)}function hd(e,t){return(e&BigInt(1)<<BigInt(t))!==BigInt(0)}function gd(e,t,n){if(t===BigInt(0))return BigInt(1);let r=e,i=t.toString(2);for(let t=1;t<i.length;++t)r=r*r%n,i[t]===`1`&&(r=r*e%n);return r}function _d(e,t){if(t<=BigInt(0))throw Error(`p must be positive`);let n=e%t;if(hd(t,0)&&hd(t,1)){let e=gd(n,t+BigInt(1)>>BigInt(2),t);if(e*e%t!==n)throw Error(`could not find a modular square root`);return e}throw Error(`unsupported modulus value`)}function vd(e,t){let n=dd(),r=n-BigInt(3),i=fd(),a=_d(((e*e+r)*e+i)%n,n);return t!==hd(a,0)&&(a=(n-a)%n),a}function yd(e,t){let n=dd(),r=n-BigInt(3),i=fd(),a=((e*e+r)*e+i)%n;return t**BigInt(2)%n===a}function bd(e){let t=xd(),n=t+1,r=2*t+1;if(e.length!==n&&e.length!==r)throw Error(`Invalid length: point is not in compressed or uncompressed format`);if((e[0]===2||e[0]===3)&&e.length==n){let t=e[0]===3,n=pd(e.subarray(1,e.length)),r=dd();if(n<BigInt(0)||n>=r)throw Error(`x is out of range`);let i=vd(n,t);return{kty:`EC`,crv:`P-256`,x:ld(md(n,32)),y:ld(md(i,32)),ext:!0}}else if(e[0]===4&&e.length==r){let n=pd(e.subarray(1,t+1)),r=pd(e.subarray(t+1,2*t+1)),i=dd();if(n<BigInt(0)||n>=i||r<BigInt(0)||r>=i||!yd(n,r))throw Error(`invalid uncompressed x and y coordinates`);return{kty:`EC`,crv:`P-256`,x:ld(md(n,32)),y:ld(md(r,32)),ext:!0}}throw Error(`invalid format`)}function xd(){return 32}var Sd;(function(e){e.Der=`der`,e.Raw=`raw`})(Sd||={});const Cd=typeof window<`u`&&window.document!==void 0&&typeof crypto<`u`&&crypto.subtle!==void 0,wd=typeof process<`u`&&process.versions!=null&&process.versions.node!=null,Td=()=>Cd?`browser`:wd?`node`:`purejs`,Ed=async(e,t)=>{let n=t??Td();switch(n){case`browser`:return(await import(`./webcrypto--IXxxE07.mjs`)).signWithApiKey(e);case`node`:return(await import(`./nodecrypto-Bo_ECug7.mjs`)).signWithApiKey(e);case`purejs`:return(await import(`./purejs-C0p97oL4.mjs`)).signWithApiKey(e);default:throw Error(`Unsupported runtime: ${n}`)}};var Dd=class{constructor(e){this.apiPublicKey=e.apiPublicKey,this.apiPrivateKey=e.apiPrivateKey,this.runtimeOverride=e.runtimeOverride}async stamp(e){let t=await Ed({publicKey:this.apiPublicKey,privateKey:this.apiPrivateKey,content:e},this.runtimeOverride),n={publicKey:this.apiPublicKey,scheme:`SIGNATURE_SCHEME_TK_API_P256`,signature:t};return{stampHeaderName:`X-Stamp`,stampHeaderValue:Wi(JSON.stringify(n))}}async sign(e,t){switch(t){case Sd.Raw:return Vi(yo(await Ed({publicKey:this.apiPublicKey,privateKey:this.apiPrivateKey,content:e},this.runtimeOverride)));case Sd.Der:return Ed({publicKey:this.apiPublicKey,privateKey:this.apiPrivateKey,content:e},this.runtimeOverride);default:throw Error(`Unsupported signature format: ${t}`)}}};function Od(e,t){return`Local signer public key does not match requested signer ${e}; linked credential has ${t}`}async function kd(e,t){if(e.signer.publicKeyHex.toLowerCase()!==t.publicKeyHex.toLowerCase())throw Error(Od(e.signer.publicKeyHex,t.publicKeyHex));let n=await new Dd({apiPublicKey:t.publicKeyHex,apiPrivateKey:t.privateKeyHex}).stamp(e.preparedBody.body);return{publicKeyHex:t.publicKeyHex,stampHeaderName:n.stampHeaderName,stampHeaderValue:n.stampHeaderValue}}async function Ad(e,t){if(!t.nextAction)return t;let n=e.getLocalSigner();if(!n)throw Error(`Intent requires a local signer, but this profile has no registered signer. Relink the agent.`);let r=await kd(t.nextAction,n);return await e.submitStamp({intentId:t.id,preparedBody:t.nextAction.preparedBody,stamp:r}),await e.getIntent(t.id)}const jd=new Map;function Md(e){if(!jd.has(e)){let t=Array.from(jd.keys()).join(`, `);throw Error(`unsupported asset: ${e}, must be one of ${t||`(none registered)`}`)}return e}function Nd(e,t,n,r){if(jd.has(e))throw Error(`duplicate asset id ${e}`);if(e.length!==3)throw Error(`ISO-4217 codes should be 3 letters`);if(n<0)throw Error(`decimals should be positive`);if(r>n)throw Error(`presentment decimals should be less than or equal to decimals`);return jd.set(e,{symbol:e,decimals:n,presentmentDecimals:r,name:t}),Md(e)}Nd(`USD`,`US Dollar`,6,2)
479
+ The private key is shown once and is not stored on this machine.`),process.exit(0)}const jd=H({profile:Pe,json:U}),Md=e({meta:{name:`policy`,description:`Inspect the agent's policy`},subCommands:{show:e({meta:{name:`show`,description:`Show the agent's assigned policy`},args:jd.args,async run({args:e}){await _u(jd.parse(e))(e=>e.getPolicy())}})}}),Nd=H({profile:V({description:`Profile name`,required:!0})});function Pd(){try{return ou({env:process.env[nu],cwd:process.cwd(),log:e=>console.error(e)})}catch(e){return L(e)}}const Fd=e({meta:{name:`use`,description:`Set the default credential profile`},args:Nd.args,async run({args:e}){let t=Nd.parse(e);try{Jl(t.profile),pu({defaultProfile:t.profile})}catch(e){L(e)}}}),Id=e({meta:{name:`current`,description:`Show the selected credential profile and how it was chosen`},async run(){let e=Pd(),t;try{t=Ul(e.name)}catch(e){L(e)}t===null&&L(`Profile "${e.name}" is not linked.\nRun 'catena link --profile ${e.name} <agent-id>' to authenticate.`),pu({profile:e.name,source:e.source,bankUrl:t.bank_url,agentId:Pl(t)?t.agent_id:void 0})}}),Ld=e({meta:{name:`list`,description:`List credential profiles and their directory bindings`},async run(){let e;try{e=Al()}catch(e){L(e)}let t;try{t=ou({env:process.env[nu],cwd:process.cwd()}).name}catch{t=null}let n=Object.entries(e.directories??{});pu({defaultProfile:e.default_profile,profiles:Object.entries(e.profiles).toSorted(([e],[t])=>e.localeCompare(t)).map(([e,r])=>({name:e,bankUrl:r.bank_url,agentId:Pl(r)?r.agent_id:void 0,directories:n.filter(([,t])=>t===e).map(([e])=>e).toSorted(),current:e===t}))})}}),Rd=H({profile:V({description:`Profile name to bind`,required:!0}),path:V({description:`Directory to bind (defaults to the current directory)`})}),zd=e({meta:{name:`bind`,description:`Bind a directory to a profile for automatic selection`},args:Rd.args,async run({args:e}){let t=Rd.parse(e);try{let e=t.path??process.cwd();if(Yu(e))throw Error(`Refusing to bind the home directory or an ancestor of it — that would shadow the default profile for every directory beneath it. Bind a specific agent directory instead.`);let n=Vl(e,t.profile);pu({profile:t.profile,directory:n})}catch(e){L(e)}}}),Bd=H({path:V({description:`Directory to unbind (defaults to the current directory)`})}),Vd=e({meta:{name:`profiles`,description:`Manage credential profiles`},subCommands:{use:Fd,current:Id,list:Ld,bind:zd,unbind:e({meta:{name:`unbind`,description:`Remove a directory's profile binding`},args:Bd.args,async run({args:e}){let t=Bd.parse(e);try{pu(Hl(t.path??process.cwd()))}catch(e){L(e)}}})}}),Hd=new Map;function Ud(e){if(!Hd.has(e)){let t=Array.from(Hd.keys()).join(`, `);throw Error(`unsupported asset: ${e}, must be one of ${t||`(none registered)`}`)}return e}function Wd(e,t,n,r){if(Hd.has(e))throw Error(`duplicate asset id ${e}`);if(e.length!==3)throw Error(`ISO-4217 codes should be 3 letters`);if(n<0)throw Error(`decimals should be positive`);if(r>n)throw Error(`presentment decimals should be less than or equal to decimals`);return Hd.set(e,{symbol:e,decimals:n,presentmentDecimals:r,name:t}),Ud(e)}Wd(`USD`,`US Dollar`,6,2)
428
480
  /*! decimal.js-light v2.5.1 https://github.com/MikeMcl/decimal.js-light/LICENCE */
429
- ;const Pd=P(N(((e,t)=>{(function(e){var n=1e9,r={precision:20,rounding:4,toExpNeg:-7,toExpPos:21,LN10:`2.302585092994045684017991454684364207601101488628772976033327900967572609677352480235997205089598298341967784042286`},i=!0,a=`[DecimalError] `,o=a+`Invalid argument: `,s=a+`Exponent out of range: `,c=Math.floor,l=Math.pow,u=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,d,f=1e7,p=7,m=9007199254740991,h=c(m/p),g={};g.absoluteValue=g.abs=function(){var e=new this.constructor(this);return e.s&&=1,e},g.comparedTo=g.cmp=function(e){var t,n,r,i,a=this;if(e=new a.constructor(e),a.s!==e.s)return a.s||-e.s;if(a.e!==e.e)return a.e>e.e^a.s<0?1:-1;for(r=a.d.length,i=e.d.length,t=0,n=r<i?r:i;t<n;++t)if(a.d[t]!==e.d[t])return a.d[t]>e.d[t]^a.s<0?1:-1;return r===i?0:r>i^a.s<0?1:-1},g.decimalPlaces=g.dp=function(){var e=this,t=e.d.length-1,n=(t-e.e)*p;if(t=e.d[t],t)for(;t%10==0;t/=10)n--;return n<0?0:n},g.dividedBy=g.div=function(e){return b(this,new this.constructor(e))},g.dividedToIntegerBy=g.idiv=function(e){var t=this,n=t.constructor;return D(b(t,new n(e),0,1),n.precision)},g.equals=g.eq=function(e){return!this.cmp(e)},g.exponent=function(){return S(this)},g.greaterThan=g.gt=function(e){return this.cmp(e)>0},g.greaterThanOrEqualTo=g.gte=function(e){return this.cmp(e)>=0},g.isInteger=g.isint=function(){return this.e>this.d.length-2},g.isNegative=g.isneg=function(){return this.s<0},g.isPositive=g.ispos=function(){return this.s>0},g.isZero=function(){return this.s===0},g.lessThan=g.lt=function(e){return this.cmp(e)<0},g.lessThanOrEqualTo=g.lte=function(e){return this.cmp(e)<1},g.logarithm=g.log=function(e){var t,n=this,r=n.constructor,o=r.precision,s=o+5;if(e===void 0)e=new r(10);else if(e=new r(e),e.s<1||e.eq(d))throw Error(a+`NaN`);if(n.s<1)throw Error(a+(n.s?`NaN`:`-Infinity`));return n.eq(d)?new r(0):(i=!1,t=b(T(n,s),T(e,s),s),i=!0,D(t,o))},g.minus=g.sub=function(e){var t=this;return e=new t.constructor(e),t.s==e.s?O(t,e):_(t,(e.s=-e.s,e))},g.modulo=g.mod=function(e){var t,n=this,r=n.constructor,o=r.precision;if(e=new r(e),!e.s)throw Error(a+`NaN`);return n.s?(i=!1,t=b(n,e,0,1).times(e),i=!0,n.minus(t)):D(new r(n),o)},g.naturalExponential=g.exp=function(){return x(this)},g.naturalLogarithm=g.ln=function(){return T(this)},g.negated=g.neg=function(){var e=new this.constructor(this);return e.s=-e.s||0,e},g.plus=g.add=function(e){var t=this;return e=new t.constructor(e),t.s==e.s?_(t,e):O(t,(e.s=-e.s,e))},g.precision=g.sd=function(e){var t,n,r,i=this;if(e!==void 0&&e!==!!e&&e!==1&&e!==0)throw Error(o+e);if(t=S(i)+1,r=i.d.length-1,n=r*p+1,r=i.d[r],r){for(;r%10==0;r/=10)n--;for(r=i.d[0];r>=10;r/=10)n++}return e&&t>n?t:n},g.squareRoot=g.sqrt=function(){var e,t,n,r,o,s,l,u=this,d=u.constructor;if(u.s<1){if(!u.s)return new d(0);throw Error(a+`NaN`)}for(e=S(u),i=!1,o=Math.sqrt(+u),o==0||o==1/0?(t=y(u.d),(t.length+e)%2==0&&(t+=`0`),o=Math.sqrt(t),e=c((e+1)/2)-(e<0||e%2),o==1/0?t=`5e`+e:(t=o.toExponential(),t=t.slice(0,t.indexOf(`e`)+1)+e),r=new d(t)):r=new d(o.toString()),n=d.precision,o=l=n+3;;)if(s=r,r=s.plus(b(u,s,l+2)).times(.5),y(s.d).slice(0,l)===(t=y(r.d)).slice(0,l)){if(t=t.slice(l-3,l+1),o==l&&t==`4999`){if(D(s,n+1,0),s.times(s).eq(u)){r=s;break}}else if(t!=`9999`)break;l+=4}return i=!0,D(r,n)},g.times=g.mul=function(e){var t,n,r,a,o,s,c,l,u,d=this,p=d.constructor,m=d.d,h=(e=new p(e)).d;if(!d.s||!e.s)return new p(0);for(e.s*=d.s,n=d.e+e.e,l=m.length,u=h.length,l<u&&(o=m,m=h,h=o,s=l,l=u,u=s),o=[],s=l+u,r=s;r--;)o.push(0);for(r=u;--r>=0;){for(t=0,a=l+r;a>r;)c=o[a]+h[r]*m[a-r-1]+t,o[a--]=c%f|0,t=c/f|0;o[a]=(o[a]+t)%f|0}for(;!o[--s];)o.pop();return t?++n:o.shift(),e.d=o,e.e=n,i?D(e,p.precision):e},g.toDecimalPlaces=g.todp=function(e,t){var r=this,i=r.constructor;return r=new i(r),e===void 0?r:(v(e,0,n),t===void 0?t=i.rounding:v(t,0,8),D(r,e+S(r)+1,t))},g.toExponential=function(e,t){var r,i=this,a=i.constructor;return e===void 0?r=k(i,!0):(v(e,0,n),t===void 0?t=a.rounding:v(t,0,8),i=D(new a(i),e+1,t),r=k(i,!0,e+1)),r},g.toFixed=function(e,t){var r,i,a=this,o=a.constructor;return e===void 0?k(a):(v(e,0,n),t===void 0?t=o.rounding:v(t,0,8),i=D(new o(a),e+S(a)+1,t),r=k(i.abs(),!1,e+S(i)+1),a.isneg()&&!a.isZero()?`-`+r:r)},g.toInteger=g.toint=function(){var e=this,t=e.constructor;return D(new t(e),S(e)+1,t.rounding)},g.toNumber=function(){return+this},g.toPower=g.pow=function(e){var t,n,r,o,s,l,u=this,f=u.constructor,h=12,g=+(e=new f(e));if(!e.s)return new f(d);if(u=new f(u),!u.s){if(e.s<1)throw Error(a+`Infinity`);return u}if(u.eq(d))return u;if(r=f.precision,e.eq(d))return D(u,r);if(t=e.e,n=e.d.length-1,l=t>=n,s=u.s,!l){if(s<0)throw Error(a+`NaN`)}else if((n=g<0?-g:g)<=m){for(o=new f(d),t=Math.ceil(r/p+4),i=!1;n%2&&(o=o.times(u),A(o.d,t)),n=c(n/2),n!==0;)u=u.times(u),A(u.d,t);return i=!0,e.s<0?new f(d).div(o):D(o,r)}return s=s<0&&e.d[Math.max(t,n)]&1?-1:1,u.s=1,i=!1,o=e.times(T(u,r+h)),i=!0,o=x(o),o.s=s,o},g.toPrecision=function(e,t){var r,i,a=this,o=a.constructor;return e===void 0?(r=S(a),i=k(a,r<=o.toExpNeg||r>=o.toExpPos)):(v(e,1,n),t===void 0?t=o.rounding:v(t,0,8),a=D(new o(a),e,t),r=S(a),i=k(a,e<=r||r<=o.toExpNeg,e)),i},g.toSignificantDigits=g.tosd=function(e,t){var r=this,i=r.constructor;return e===void 0?(e=i.precision,t=i.rounding):(v(e,1,n),t===void 0?t=i.rounding:v(t,0,8)),D(new i(r),e,t)},g.toString=g.valueOf=g.val=g.toJSON=function(){var e=this,t=S(e),n=e.constructor;return k(e,t<=n.toExpNeg||t>=n.toExpPos)};function _(e,t){var n,r,a,o,s,c,l,u,d=e.constructor,m=d.precision;if(!e.s||!t.s)return t.s||(t=new d(e)),i?D(t,m):t;if(l=e.d,u=t.d,s=e.e,a=t.e,l=l.slice(),o=s-a,o){for(o<0?(r=l,o=-o,c=u.length):(r=u,a=s,c=l.length),s=Math.ceil(m/p),c=s>c?s+1:c+1,o>c&&(o=c,r.length=1),r.reverse();o--;)r.push(0);r.reverse()}for(c=l.length,o=u.length,c-o<0&&(o=c,r=u,u=l,l=r),n=0;o;)n=(l[--o]=l[o]+u[o]+n)/f|0,l[o]%=f;for(n&&(l.unshift(n),++a),c=l.length;l[--c]==0;)l.pop();return t.d=l,t.e=a,i?D(t,m):t}function v(e,t,n){if(e!==~~e||e<t||e>n)throw Error(o+e)}function y(e){var t,n,r,i=e.length-1,a=``,o=e[0];if(i>0){for(a+=o,t=1;t<i;t++)r=e[t]+``,n=p-r.length,n&&(a+=w(n)),a+=r;o=e[t],r=o+``,n=p-r.length,n&&(a+=w(n))}else if(o===0)return`0`;for(;o%10==0;)o/=10;return a+o}var b=(function(){function e(e,t){var n,r=0,i=e.length;for(e=e.slice();i--;)n=e[i]*t+r,e[i]=n%f|0,r=n/f|0;return r&&e.unshift(r),e}function t(e,t,n,r){var i,a;if(n!=r)a=n>r?1:-1;else for(i=a=0;i<n;i++)if(e[i]!=t[i]){a=e[i]>t[i]?1:-1;break}return a}function n(e,t,n){for(var r=0;n--;)e[n]-=r,r=+(e[n]<t[n]),e[n]=r*f+e[n]-t[n];for(;!e[0]&&e.length>1;)e.shift()}return function(r,i,o,s){var c,l,u,d,m,h,g,_,v,y,b,x,C,w,T,E,O,k,A=r.constructor,ee=r.s==i.s?1:-1,j=r.d,M=i.d;if(!r.s)return new A(r);if(!i.s)throw Error(a+`Division by zero`);for(l=r.e-i.e,O=M.length,T=j.length,g=new A(ee),_=g.d=[],u=0;M[u]==(j[u]||0);)++u;if(M[u]>(j[u]||0)&&--l,x=o==null?o=A.precision:s?o+(S(r)-S(i))+1:o,x<0)return new A(0);if(x=x/p+2|0,u=0,O==1)for(d=0,M=M[0],x++;(u<T||d)&&x--;u++)C=d*f+(j[u]||0),_[u]=C/M|0,d=C%M|0;else{for(d=f/(M[0]+1)|0,d>1&&(M=e(M,d),j=e(j,d),O=M.length,T=j.length),w=O,v=j.slice(0,O),y=v.length;y<O;)v[y++]=0;k=M.slice(),k.unshift(0),E=M[0],M[1]>=f/2&&++E;do d=0,c=t(M,v,O,y),c<0?(b=v[0],O!=y&&(b=b*f+(v[1]||0)),d=b/E|0,d>1?(d>=f&&(d=f-1),m=e(M,d),h=m.length,y=v.length,c=t(m,v,h,y),c==1&&(d--,n(m,O<h?k:M,h))):(d==0&&(c=d=1),m=M.slice()),h=m.length,h<y&&m.unshift(0),n(v,m,y),c==-1&&(y=v.length,c=t(M,v,O,y),c<1&&(d++,n(v,O<y?k:M,y))),y=v.length):c===0&&(d++,v=[0]),_[u++]=d,c&&v[0]?v[y++]=j[w]||0:(v=[j[w]],y=1);while((w++<T||v[0]!==void 0)&&x--)}return _[0]||_.shift(),g.e=l,D(g,s?o+S(g)+1:o)}})();function x(e,t){var n,r,a,o,c,u,f=0,p=0,m=e.constructor,h=m.precision;if(S(e)>16)throw Error(s+S(e));if(!e.s)return new m(d);for(t==null?(i=!1,u=h):u=t,c=new m(.03125);e.abs().gte(.1);)e=e.times(c),p+=5;for(r=Math.log(l(2,p))/Math.LN10*2+5|0,u+=r,n=a=o=new m(d),m.precision=u;;){if(a=D(a.times(e),u),n=n.times(++f),c=o.plus(b(a,n,u)),y(c.d).slice(0,u)===y(o.d).slice(0,u)){for(;p--;)o=D(o.times(o),u);return m.precision=h,t==null?(i=!0,D(o,h)):o}o=c}}function S(e){for(var t=e.e*p,n=e.d[0];n>=10;n/=10)t++;return t}function C(e,t,n){if(t>e.LN10.sd())throw i=!0,n&&(e.precision=n),Error(a+`LN10 precision limit exceeded`);return D(new e(e.LN10),t)}function w(e){for(var t=``;e--;)t+=`0`;return t}function T(e,t){var n,r,o,s,c,l,u,f,p,m=1,h=10,g=e,_=g.d,v=g.constructor,x=v.precision;if(g.s<1)throw Error(a+(g.s?`NaN`:`-Infinity`));if(g.eq(d))return new v(0);if(t==null?(i=!1,f=x):f=t,g.eq(10))return t??(i=!0),C(v,f);if(f+=h,v.precision=f,n=y(_),r=n.charAt(0),s=S(g),Math.abs(s)<0x5543df729c000){for(;r<7&&r!=1||r==1&&n.charAt(1)>3;)g=g.times(e),n=y(g.d),r=n.charAt(0),m++;s=S(g),r>1?(g=new v(`0.`+n),s++):g=new v(r+`.`+n.slice(1))}else return u=C(v,f+2,x).times(s+``),g=T(new v(r+`.`+n.slice(1)),f-h).plus(u),v.precision=x,t==null?(i=!0,D(g,x)):g;for(l=c=g=b(g.minus(d),g.plus(d),f),p=D(g.times(g),f),o=3;;){if(c=D(c.times(p),f),u=l.plus(b(c,new v(o),f)),y(u.d).slice(0,f)===y(l.d).slice(0,f))return l=l.times(2),s!==0&&(l=l.plus(C(v,f+2,x).times(s+``))),l=b(l,new v(m),f),v.precision=x,t==null?(i=!0,D(l,x)):l;l=u,o+=2}}function E(e,t){var n,r,a;for((n=t.indexOf(`.`))>-1&&(t=t.replace(`.`,``)),(r=t.search(/e/i))>0?(n<0&&(n=r),n+=+t.slice(r+1),t=t.substring(0,r)):n<0&&(n=t.length),r=0;t.charCodeAt(r)===48;)++r;for(a=t.length;t.charCodeAt(a-1)===48;)--a;if(t=t.slice(r,a),t){if(a-=r,n=n-r-1,e.e=c(n/p),e.d=[],r=(n+1)%p,n<0&&(r+=p),r<a){for(r&&e.d.push(+t.slice(0,r)),a-=p;r<a;)e.d.push(+t.slice(r,r+=p));t=t.slice(r),r=p-t.length}else r-=a;for(;r--;)t+=`0`;if(e.d.push(+t),i&&(e.e>h||e.e<-h))throw Error(s+n)}else e.s=0,e.e=0,e.d=[0];return e}function D(e,t,n){var r,a,o,u,d,m,g,_,v=e.d;for(u=1,o=v[0];o>=10;o/=10)u++;if(r=t-u,r<0)r+=p,a=t,g=v[_=0];else{if(_=Math.ceil((r+1)/p),o=v.length,_>=o)return e;for(g=o=v[_],u=1;o>=10;o/=10)u++;r%=p,a=r-p+u}if(n!==void 0&&(o=l(10,u-a-1),d=g/o%10|0,m=t<0||v[_+1]!==void 0||g%o,m=n<4?(d||m)&&(n==0||n==(e.s<0?3:2)):d>5||d==5&&(n==4||m||n==6&&(r>0?a>0?g/l(10,u-a):0:v[_-1])%10&1||n==(e.s<0?8:7))),t<1||!v[0])return m?(o=S(e),v.length=1,t=t-o-1,v[0]=l(10,(p-t%p)%p),e.e=c(-t/p)||0):(v.length=1,v[0]=e.e=e.s=0),e;if(r==0?(v.length=_,o=1,_--):(v.length=_+1,o=l(10,p-r),v[_]=a>0?(g/l(10,u-a)%l(10,a)|0)*o:0),m)for(;;)if(_==0){(v[0]+=o)==f&&(v[0]=1,++e.e);break}else{if(v[_]+=o,v[_]!=f)break;v[_--]=0,o=1}for(r=v.length;v[--r]===0;)v.pop();if(i&&(e.e>h||e.e<-h))throw Error(s+S(e));return e}function O(e,t){var n,r,a,o,s,c,l,u,d,m,h=e.constructor,g=h.precision;if(!e.s||!t.s)return t.s?t.s=-t.s:t=new h(e),i?D(t,g):t;if(l=e.d,m=t.d,r=t.e,u=e.e,l=l.slice(),s=u-r,s){for(d=s<0,d?(n=l,s=-s,c=m.length):(n=m,r=u,c=l.length),a=Math.max(Math.ceil(g/p),c)+2,s>a&&(s=a,n.length=1),n.reverse(),a=s;a--;)n.push(0);n.reverse()}else{for(a=l.length,c=m.length,d=a<c,d&&(c=a),a=0;a<c;a++)if(l[a]!=m[a]){d=l[a]<m[a];break}s=0}for(d&&(n=l,l=m,m=n,t.s=-t.s),c=l.length,a=m.length-c;a>0;--a)l[c++]=0;for(a=m.length;a>s;){if(l[--a]<m[a]){for(o=a;o&&l[--o]===0;)l[o]=f-1;--l[o],l[a]+=f}l[a]-=m[a]}for(;l[--c]===0;)l.pop();for(;l[0]===0;l.shift())--r;return l[0]?(t.d=l,t.e=r,i?D(t,g):t):new h(0)}function k(e,t,n){var r,i=S(e),a=y(e.d),o=a.length;return t?(n&&(r=n-o)>0?a=a.charAt(0)+`.`+a.slice(1)+w(r):o>1&&(a=a.charAt(0)+`.`+a.slice(1)),a=a+(i<0?`e`:`e+`)+i):i<0?(a=`0.`+w(-i-1)+a,n&&(r=n-o)>0&&(a+=w(r))):i>=o?(a+=w(i+1-o),n&&(r=n-i-1)>0&&(a=a+`.`+w(r))):((r=i+1)<o&&(a=a.slice(0,r)+`.`+a.slice(r)),n&&(r=n-o)>0&&(i+1===o&&(a+=`.`),a+=w(r))),e.s<0?`-`+a:a}function A(e,t){if(e.length>t)return e.length=t,!0}function ee(e){var t,n,r;function i(e){var t=this;if(!(t instanceof i))return new i(e);if(t.constructor=i,e instanceof i){t.s=e.s,t.e=e.e,t.d=(e=e.d)?e.slice():e;return}if(typeof e==`number`){if(e*0!=0)throw Error(o+e);if(e>0)t.s=1;else if(e<0)e=-e,t.s=-1;else{t.s=0,t.e=0,t.d=[0];return}if(e===~~e&&e<1e7){t.e=0,t.d=[e];return}return E(t,e.toString())}else if(typeof e!=`string`)throw Error(o+e);if(e.charCodeAt(0)===45?(e=e.slice(1),t.s=-1):t.s=1,u.test(e))E(t,e);else throw Error(o+e)}if(i.prototype=g,i.ROUND_UP=0,i.ROUND_DOWN=1,i.ROUND_CEIL=2,i.ROUND_FLOOR=3,i.ROUND_HALF_UP=4,i.ROUND_HALF_DOWN=5,i.ROUND_HALF_EVEN=6,i.ROUND_HALF_CEIL=7,i.ROUND_HALF_FLOOR=8,i.clone=ee,i.config=i.set=j,e===void 0&&(e={}),e)for(r=[`precision`,`rounding`,`toExpNeg`,`toExpPos`,`LN10`],t=0;t<r.length;)e.hasOwnProperty(n=r[t++])||(e[n]=this[n]);return i.config(e),i}function j(e){if(!e||typeof e!=`object`)throw Error(a+`Object expected`);var t,r,i,s=[`precision`,1,n,`rounding`,0,8,`toExpNeg`,-1/0,0,`toExpPos`,0,1/0];for(t=0;t<s.length;t+=3)if((i=e[r=s[t]])!==void 0)if(c(i)===i&&i>=s[t+1]&&i<=s[t+2])this[r]=i;else throw Error(o+r+`: `+i);if((i=e[r=`LN10`])!==void 0)if(i==Math.LN10)this[r]=new this(i);else throw Error(o+r+`: `+i);return this}r=ee(r),r.default=r.Decimal=r,d=new r(1),typeof define==`function`&&define.amd?define(function(){return r}):t!==void 0&&t.exports?t.exports=r:(e||=typeof self<`u`&&self&&self.self==self?self:Function(`return this`)(),e.Decimal=r)})(e)}))(),1).default;Pd.set({rounding:Pd.ROUND_HALF_EVEN}),new Pd(1e6),new Pd(1e3);const Fd=r.pipe(r.string(`Amount must be a string`),r.nonEmpty(`Amount must not be empty`),r.check(e=>e.trim()===e,`Amount must not have leading or trailing whitespace`),r.check(e=>!e.includes(`e`)&&!e.includes(`E`),`Scientific notation is not supported (e.g. use 1000000 instead of 1e6)`),r.check(e=>!e.startsWith(`+`),`Amount must not have a '+' prefix`),r.check(e=>!e.startsWith(`-`),`Amount must be non-negative`),r.check(e=>{try{return new Pd(e).gte(0)}catch{return!1}},`Amount must be a valid decimal (e.g. 100 or 100.50)`)),Id=r.pipe(r.string(`Idempotency key must be a string`),r.minLength(1,`Idempotency key must not be empty`),r.maxLength(255,`Idempotency key is too long (max 255 characters)`)),Ld=W({account:H({description:`Source account id`,required:!0,schema:G}),rail:H({description:`Destination counterparty rail id`,required:!0,schema:G}),amount:H({description:`USD amount as a decimal string (e.g. 125.00)`,required:!0,schema:Fd,showValueInError:!0}),method:Ee({description:`ach | wire | on-chain`,required:!0,choices:ct}),memo:H({description:`Memo on the underlying transfer`}),description:H({description:`Operator-facing description`}),idempotencyKey:H({description:`Optional. Usually omit this. Identical retries are deduplicated automatically and return the original intent, even if it failed, so a bare retry never re-sends on its own. Set a unique value only when you intentionally want another payment with the same details.`,schema:Id}),profile:Ae,json:je}),Rd=e({meta:{name:`send`,description:`Submit a USD send intent to a counterparty rail`},args:Ld.args,async run({args:e}){let t=Ld.parse(e),n=mr(t),r={type:`send`,accountId:t.account,counterpartyRailId:t.rail,amount:t.amount,method:t.method,...t.memo?{memo:t.memo}:{},...t.description?{description:t.description}:{}};await n(async e=>await Ad(e,await e.createIntent({action:r,...t.idempotencyKey?{idempotencyKey:t.idempotencyKey}:{}})))}}),zd=W({from:H({description:`Source account id`,required:!0,schema:G}),to:H({description:`Destination account id`,required:!0,schema:G}),amount:H({description:`USD amount as a decimal string (e.g. 125.00)`,required:!0,schema:Fd,showValueInError:!0}),memo:H({description:`Memo on the underlying transfer`}),description:H({description:`Operator-facing description`}),idempotencyKey:H({description:`Optional. Usually omit this. Identical retries are deduplicated automatically and return the original intent, even if it failed, so a bare retry never re-sends on its own. Set a unique value only when you intentionally want another transfer with the same details.`,schema:Id}),profile:Ae,json:je}),Bd=e({meta:{name:`transfer`,description:`Submit a USD transfer intent between two of this agent's accounts`},args:zd.args,async run({args:e}){let t=zd.parse(e),n=mr(t),r={type:`transfer`,accountId:t.from,toAccountId:t.to,amount:t.amount,...t.memo?{memo:t.memo}:{},...t.description?{description:t.description}:{}};await n(async e=>await Ad(e,await e.createIntent({action:r,...t.idempotencyKey?{idempotencyKey:t.idempotencyKey}:{}})))}}),Vd=W({profile:Ae,force:U({description:`Remove the profile and its local credentials without contacting the server; use when the credential is missing, revoked, or a link was interrupted`,default:!1}),json:je}),Hd=e({meta:{name:`unlink`,description:`Disconnect the selected agent profile`},args:Vd.args,async run({args:e}){let t=Vd.parse(e),n=cr(),r;try{r=or({flag:dr(t),env:process.env[nr],cwd:process.cwd(),log:e=>console.error(e)}).name}catch(e){z(e)}if(t.force){let e;try{if(e=Hn(r),e===null)throw Error(`Profile "${r}" not found`);await n.delete(e.client_instance_id),await n.delete(ii(e.client_instance_id)),Ln(r)}catch(e){z(e)}ur({success:!0,profile:r,...Nn(e)?{agentId:e.agent_id}:{},local:!0},{compact:t.json});return}let i=await er({profileName:r,fallbackBankUrl:tr},n);i.ok||z(i.message);let a=sr(i,n);try{await a.unlink(),await n.delete(i.clientInstanceId),await n.delete(ii(i.clientInstanceId)),Ln(r)}catch(e){z(e)}ur({success:!0,profile:r,agentId:i.agentId},{compact:t.json})}}),Ud=W({profile:Ae,json:je}),Wd=e({meta:{name:`whoami`,description:`Show which agent you are currently acting as`},args:Ud.args,async run({args:e}){await mr(Ud.parse(e))(e=>e.whoami())}}),Gd=[`PAYMENT-REQUIRED`,`X-Payment-Required`],Kd=r.looseObject({x402Version:r.literal(2),accepts:r.array(pt),resource:r.optional(mt)}),qd=new Set([`x402_requirement_not_payable`,`x402_network_mismatch`]);function Jd(e){let t=e.replaceAll(`-`,`+`).replaceAll(`_`,`/`),n=Uint8Array.from(atob(t),e=>e.charCodeAt(0));return JSON.parse(new TextDecoder().decode(n))}function Yd(e){let t=Gd.map(t=>e.headers.get(t)).find(e=>e!==null);if(t)try{let e=r.safeParse(Kd,Jd(t));return e.success?e.output:void 0}catch{return}}var Xd=class extends Error{reasons;constructor(e,t=[]){super(t.length>0?`${e}: ${t.join(`; `)}`:e),this.name=`X402PaymentError`,this.reasons=t}},Zd=class extends Xd{receipt;constructor(e,t){super(`The payment settled (intent ${e.intentId}) but the paid retry failed; retry the request with the PAYMENT-SIGNATURE header from GET /intents/${e.intentId} instead of paying again`),this.name=`X402RetryFailedError`,this.receipt=e,this.cause=t}},Qd=class extends Xd{intentId;requirements;constructor(e,t,n){super(`The payment could not be confirmed (intent ${e}); check GET /intents/${e} for a completed payment and re-read the PAYMENT-SIGNATURE header before paying again`),this.name=`X402SubmitInterruptedError`,this.intentId=e,this.requirements=t,this.cause=n}};async function $d(e,t){let n=e.getLocalSigner();if(!n)throw new Xd(`x402 payments require a linked signer; relink the agent`);let r=t.paymentRequired.accepts.filter(e=>e.scheme===`exact`),i=r.filter(e=>t.maxAtomicAmount===void 0||/^\d+$/.test(e.amount)&&BigInt(e.amount)<=t.maxAtomicAmount).slice(0,5);if(i.length===0)throw new Xd(r.length>0&&t.maxAtomicAmount!==void 0?`Every requirement in the 402 challenge costs more than the caller's maximum amount`:`The 402 challenge offers no exact-scheme requirement Catena can pay`);let a=t.resource??t.paymentRequired.resource,o;for(let r of i){let i=await ef(e,{accountId:t.accountId,requirements:r,resource:a,signer:n}).catch(e=>{if(e instanceof xt&&e.code!==void 0&&qd.has(e.code)){o=e;return}throw e});if(i)return i}throw new Xd(`No requirement in the 402 challenge is payable from this account`,o?[o.message]:[])}async function ef(e,t){let n=await e.createIntent({action:{type:`x402`,accountId:t.accountId,paymentRequirements:t.requirements,...t.resource!==void 0&&{resource:t.resource}},idempotencyKey:crypto.randomUUID()});if(!n.nextAction)throw new Xd(`Catena declined the payment`,n.reasons);let r=await kd(n.nextAction,t.signer),i=await e.submitStamp({intentId:n.id,preparedBody:n.nextAction.preparedBody,stamp:r}).catch(e=>{throw new Qd(n.id,t.requirements,e)});if(!(`x402`in i))throw new Xd(`The submit-stamp response did not carry an x402 payment signature`);return{intentId:i.intentId,paymentSignature:i.x402.paymentSignature,requirements:t.requirements}}function tf(e,t){return t?.body!==void 0&&t.body!==null&&typeof t.body!=`string`&&!(t.body instanceof URLSearchParams)&&!(t.body instanceof Blob)&&!(t.body instanceof ArrayBuffer)&&!ArrayBuffer.isView(t.body)?!1:typeof Request<`u`&&e instanceof Request?e.body===null&&!e.bodyUsed:!0}function nf(e,t){let n=t.baseFetch??globalThis.fetch;return async(r,i)=>{let a=await n(r,i);if(a.status!==402)return a;let o=Yd(a);if(!o)return a;if(!tf(r,i))throw new Xd(`The request body cannot be replayed after payment; buffer the body (string, Blob, or ArrayBuffer) before using the x402 fetch wrapper`);let s=await $d(e,{accountId:t.accountId,paymentRequired:o,...t.maxAtomicAmount!==void 0&&{maxAtomicAmount:t.maxAtomicAmount}});t.onPayment?.(s);let c=new Headers(typeof Request<`u`&&r instanceof Request?r.headers:void 0);new Headers(i?.headers).forEach((e,t)=>{c.set(t,e)}),c.set(`PAYMENT-SIGNATURE`,s.paymentSignature);try{return await n(r,{...i,headers:c})}catch(e){throw new Zd(s,e)}}}function rf(e){if(e===`@-`)return af(0,`stdin`);if(e.startsWith(`@`)){let t=e.slice(1);return t===``?z(`--data @<path>: no file path given`):af(t,`@${t}`)}return e}function af(e,t){try{return m(e,`utf8`)}catch(e){return z(`--data ${t}: ${e instanceof Error?e.message:String(e)}`)}}function of(e){let[t,n=``]=e.split(`.`);return BigInt(`${t}${n.padEnd(6,`0`)}`)}function sf(e){return{intentId:e.intentId,amountAtomicUsdc:e.requirements.amount,payTo:e.requirements.payTo,network:e.requirements.network}}const cf=W({url:H({description:`The paywalled URL to fetch (an x402 v2 endpoint)`,required:!0,schema:r.pipe(r.string(),r.url())}),account:H({description:`Source wallet account id the payment draws from`,required:!0,schema:G}),maxAmount:H({description:`Refuse challenges above this USD amount (decimal string, e.g. 0.25). Policy limits still apply server-side.`,schema:r.pipe(r.string(),r.regex(/^\d+(\.\d{1,6})?$/))}),method:Ee({description:`HTTP method for the request`,choices:[`GET`,`POST`]}),data:H({description:`Request body. Use @path to read a file or @- for stdin. Implies POST and a JSON content type unless overridden.`}),contentType:H({description:`Content-Type header for the request body (default application/json when --data is set)`}),profile:Ae,json:je}),lf=e({meta:{name:`x402`,description:`Fetch a URL, paying its x402 (HTTP 402) challenge via USDC`},args:cf.args,async run({args:e}){let t=cf.parse(e),n=t.method??(t.data===void 0?`GET`:`POST`);t.data!==void 0&&n!==`POST`&&z(`--data cannot be sent with --method ${n}; a body requires POST`),t.contentType!==void 0&&t.data===void 0&&z(`--content-type has no effect without --data`);let r=t.data===void 0?void 0:rf(t.data),i=r===void 0?void 0:{"content-type":t.contentType??`application/json`};await mr(t)(async e=>{let a,o=nf(e,{accountId:t.account,...t.maxAmount!==void 0&&{maxAtomicAmount:of(t.maxAmount)},onPayment:e=>{a=e}}),s;try{s=await o(t.url,{method:n,...r!==void 0&&{body:r},...i!==void 0&&{headers:i}})}catch(e){if(e instanceof Zd)return{status:null,paid:!0,retryFailed:!0,payment:sf(e.receipt),error:e.message};throw e}let c=await s.text();return{status:s.status,paid:a!==void 0,retryFailed:!1,...a!==void 0&&{payment:sf(a)},body:c.slice(0,4e3)}},{exitCode:e=>+!!e.retryFailed})}}),uf=r.object({version:r.literal(1),result:r.literal(`latest-version`),latestVersion:r.string(),checkedAt:r.pipe(r.string(),r.isoTimestamp())}),df=r.object({version:r.literal(1),result:r.literal(`fetch-failure`),checkedAt:r.pipe(r.string(),r.isoTimestamp())}),ff=r.variant(`result`,[uf,df]),pf=r.object({"dist-tags":r.object({latest:r.string()})});function mf(){return C(Cn(),`cache`,`cli-version.json`)}function hf(e){return new URL(encodeURIComponent(e),`https://registry.npmjs.org/`).href}function gf(e){try{let t=JSON.parse(m(e,`utf8`)),n=r.safeParse(ff,t);return n.success?n.output:void 0}catch{return}}function _f(e){let t=gf(e);if(!t)return;let n=Date.parse(t.checkedAt);if(!Number.isFinite(n))return;let r=Date.now()-n,i=t.result===`fetch-failure`?36e5:864e5;if(!(r<0||r>=i))return t}function vf(e){try{let t=x(e),n=x(t);return p(n,{recursive:!0,mode:448}),d(n,448),p(t,{recursive:!0,mode:448}),d(t,448),t}catch{return}}function yf(e){try{return!f(e)||v(e).isFile()}catch{return!1}}function bf(e){let t=vf(e);if(t===void 0||!yf(e))return!1;let n=C(t,`.cli-version-check-${c(6).toString(`hex`)}.tmp`);try{return y(n,``,{encoding:`utf8`,mode:384}),_(n,{force:!0}),!0}catch{try{_(n,{force:!0})}catch{}return!1}}function xf(e,t){if(vf(e)===void 0)return!1;try{let n=`${e}.${c(6).toString(`hex`)}.tmp`;return y(n,`${JSON.stringify({version:1,...t,checkedAt:new Date().toISOString()},null,2)}\n`,{encoding:`utf8`,mode:384}),g(n,e),!0}catch{return!1}}async function Sf(e){let t=new AbortController,n=setTimeout(()=>t.abort(),750);n.unref();try{let n=await fetch(hf(e.packageName),{headers:{accept:`application/json`},signal:t.signal});if(!n.ok)return;let i=await n.json(),a=r.safeParse(pf,i);return a.success?a.output[`dist-tags`].latest:void 0}catch{return}finally{clearTimeout(n)}}function Cf(e){let t=E.valid(e.currentVersion),n=E.valid(e.latestVersion);t===null||n===null||E.gt(n,t)&&console.error(`A newer ${e.packageName} version is available: ${n} (current ${t}).`)}async function wf({packageName:e,currentVersion:t}){let n=mf(),r=_f(n);if(r?.result===`latest-version`){Cf({packageName:e,currentVersion:t,latestVersion:r.latestVersion});return}if(r?.result===`fetch-failure`||!bf(n))return;let i=await Sf({packageName:e});if(i===void 0){xf(n,{result:`fetch-failure`});return}xf(n,{result:`latest-version`,latestVersion:i}),Cf({packageName:e,currentVersion:t,latestVersion:i})}async function Tf(e){return typeof e==`function`?await e():await e}async function Ef(e){return typeof e==`function`?await e():await e}async function Df(e){return typeof e==`function`?await e():await e}async function Of(e,t,n=[]){if(e===t)return n;let r=await Df(e.subCommands??{});return(await Promise.all(Object.entries(r).map(async([e,r])=>Of(await Tf(r),t,[...n,e])))).find(e=>e!==void 0)}async function kf(e,t){if(!e||!t||t.length<2)return e;let n=await Ef(e.meta??{});return{...e,meta:{...n,name:t.slice(0,-1).join(` `)}}}function Af(e){return async(n,r)=>{let i=await t(n,await kf(r,await Of(e,n)));console.log(`${i}\n`)}}function jf({shouldCheckCliVersionFreshness:t}){return e({meta:{name:`catena`,version:I,description:`Catena CLI`},async setup({rawArgs:e}){!t||e.length===0||await wf({packageName:re,currentVersion:I})},subCommands:{link:Oi,unlink:Hd,profiles:Bi,whoami:Wd,policy:ji,accounts:Cr,intents:Wr,send:Rd,transfer:Bd,x402:lf,counterparties:Fr,feedback:Br,guide:Hr}})}const Mf=jf({shouldCheckCliVersionFreshness:!0});jf({shouldCheckCliVersionFreshness:!1});function Nf(){n(Mf,{showUsage:Af(Mf)})}Nf();export{Gi as _,va as a,ra as c,oa as d,_a as f,ga as g,ba as h,to as i,ta as l,ea as m,eo as n,na as o,ma as p,no as r,ia as s,bd as t,da as u,Hi as v,Vi as y};
481
+ ;const Gd=ae(M(((e,t)=>{(function(e){var n=1e9,r={precision:20,rounding:4,toExpNeg:-7,toExpPos:21,LN10:`2.302585092994045684017991454684364207601101488628772976033327900967572609677352480235997205089598298341967784042286`},i=!0,a=`[DecimalError] `,o=a+`Invalid argument: `,s=a+`Exponent out of range: `,c=Math.floor,l=Math.pow,u=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,d,f=1e7,p=7,m=9007199254740991,h=c(m/p),g={};g.absoluteValue=g.abs=function(){var e=new this.constructor(this);return e.s&&=1,e},g.comparedTo=g.cmp=function(e){var t,n,r,i,a=this;if(e=new a.constructor(e),a.s!==e.s)return a.s||-e.s;if(a.e!==e.e)return a.e>e.e^a.s<0?1:-1;for(r=a.d.length,i=e.d.length,t=0,n=r<i?r:i;t<n;++t)if(a.d[t]!==e.d[t])return a.d[t]>e.d[t]^a.s<0?1:-1;return r===i?0:r>i^a.s<0?1:-1},g.decimalPlaces=g.dp=function(){var e=this,t=e.d.length-1,n=(t-e.e)*p;if(t=e.d[t],t)for(;t%10==0;t/=10)n--;return n<0?0:n},g.dividedBy=g.div=function(e){return b(this,new this.constructor(e))},g.dividedToIntegerBy=g.idiv=function(e){var t=this,n=t.constructor;return E(b(t,new n(e),0,1),n.precision)},g.equals=g.eq=function(e){return!this.cmp(e)},g.exponent=function(){return S(this)},g.greaterThan=g.gt=function(e){return this.cmp(e)>0},g.greaterThanOrEqualTo=g.gte=function(e){return this.cmp(e)>=0},g.isInteger=g.isint=function(){return this.e>this.d.length-2},g.isNegative=g.isneg=function(){return this.s<0},g.isPositive=g.ispos=function(){return this.s>0},g.isZero=function(){return this.s===0},g.lessThan=g.lt=function(e){return this.cmp(e)<0},g.lessThanOrEqualTo=g.lte=function(e){return this.cmp(e)<1},g.logarithm=g.log=function(e){var t,n=this,r=n.constructor,o=r.precision,s=o+5;if(e===void 0)e=new r(10);else if(e=new r(e),e.s<1||e.eq(d))throw Error(a+`NaN`);if(n.s<1)throw Error(a+(n.s?`NaN`:`-Infinity`));return n.eq(d)?new r(0):(i=!1,t=b(T(n,s),T(e,s),s),i=!0,E(t,o))},g.minus=g.sub=function(e){var t=this;return e=new t.constructor(e),t.s==e.s?D(t,e):_(t,(e.s=-e.s,e))},g.modulo=g.mod=function(e){var t,n=this,r=n.constructor,o=r.precision;if(e=new r(e),!e.s)throw Error(a+`NaN`);return n.s?(i=!1,t=b(n,e,0,1).times(e),i=!0,n.minus(t)):E(new r(n),o)},g.naturalExponential=g.exp=function(){return x(this)},g.naturalLogarithm=g.ln=function(){return T(this)},g.negated=g.neg=function(){var e=new this.constructor(this);return e.s=-e.s||0,e},g.plus=g.add=function(e){var t=this;return e=new t.constructor(e),t.s==e.s?_(t,e):D(t,(e.s=-e.s,e))},g.precision=g.sd=function(e){var t,n,r,i=this;if(e!==void 0&&e!==!!e&&e!==1&&e!==0)throw Error(o+e);if(t=S(i)+1,r=i.d.length-1,n=r*p+1,r=i.d[r],r){for(;r%10==0;r/=10)n--;for(r=i.d[0];r>=10;r/=10)n++}return e&&t>n?t:n},g.squareRoot=g.sqrt=function(){var e,t,n,r,o,s,l,u=this,d=u.constructor;if(u.s<1){if(!u.s)return new d(0);throw Error(a+`NaN`)}for(e=S(u),i=!1,o=Math.sqrt(+u),o==0||o==1/0?(t=y(u.d),(t.length+e)%2==0&&(t+=`0`),o=Math.sqrt(t),e=c((e+1)/2)-(e<0||e%2),o==1/0?t=`5e`+e:(t=o.toExponential(),t=t.slice(0,t.indexOf(`e`)+1)+e),r=new d(t)):r=new d(o.toString()),n=d.precision,o=l=n+3;;)if(s=r,r=s.plus(b(u,s,l+2)).times(.5),y(s.d).slice(0,l)===(t=y(r.d)).slice(0,l)){if(t=t.slice(l-3,l+1),o==l&&t==`4999`){if(E(s,n+1,0),s.times(s).eq(u)){r=s;break}}else if(t!=`9999`)break;l+=4}return i=!0,E(r,n)},g.times=g.mul=function(e){var t,n,r,a,o,s,c,l,u,d=this,p=d.constructor,m=d.d,h=(e=new p(e)).d;if(!d.s||!e.s)return new p(0);for(e.s*=d.s,n=d.e+e.e,l=m.length,u=h.length,l<u&&(o=m,m=h,h=o,s=l,l=u,u=s),o=[],s=l+u,r=s;r--;)o.push(0);for(r=u;--r>=0;){for(t=0,a=l+r;a>r;)c=o[a]+h[r]*m[a-r-1]+t,o[a--]=c%f|0,t=c/f|0;o[a]=(o[a]+t)%f|0}for(;!o[--s];)o.pop();return t?++n:o.shift(),e.d=o,e.e=n,i?E(e,p.precision):e},g.toDecimalPlaces=g.todp=function(e,t){var r=this,i=r.constructor;return r=new i(r),e===void 0?r:(v(e,0,n),t===void 0?t=i.rounding:v(t,0,8),E(r,e+S(r)+1,t))},g.toExponential=function(e,t){var r,i=this,a=i.constructor;return e===void 0?r=O(i,!0):(v(e,0,n),t===void 0?t=a.rounding:v(t,0,8),i=E(new a(i),e+1,t),r=O(i,!0,e+1)),r},g.toFixed=function(e,t){var r,i,a=this,o=a.constructor;return e===void 0?O(a):(v(e,0,n),t===void 0?t=o.rounding:v(t,0,8),i=E(new o(a),e+S(a)+1,t),r=O(i.abs(),!1,e+S(i)+1),a.isneg()&&!a.isZero()?`-`+r:r)},g.toInteger=g.toint=function(){var e=this,t=e.constructor;return E(new t(e),S(e)+1,t.rounding)},g.toNumber=function(){return+this},g.toPower=g.pow=function(e){var t,n,r,o,s,l,u=this,f=u.constructor,h=12,g=+(e=new f(e));if(!e.s)return new f(d);if(u=new f(u),!u.s){if(e.s<1)throw Error(a+`Infinity`);return u}if(u.eq(d))return u;if(r=f.precision,e.eq(d))return E(u,r);if(t=e.e,n=e.d.length-1,l=t>=n,s=u.s,!l){if(s<0)throw Error(a+`NaN`)}else if((n=g<0?-g:g)<=m){for(o=new f(d),t=Math.ceil(r/p+4),i=!1;n%2&&(o=o.times(u),k(o.d,t)),n=c(n/2),n!==0;)u=u.times(u),k(u.d,t);return i=!0,e.s<0?new f(d).div(o):E(o,r)}return s=s<0&&e.d[Math.max(t,n)]&1?-1:1,u.s=1,i=!1,o=e.times(T(u,r+h)),i=!0,o=x(o),o.s=s,o},g.toPrecision=function(e,t){var r,i,a=this,o=a.constructor;return e===void 0?(r=S(a),i=O(a,r<=o.toExpNeg||r>=o.toExpPos)):(v(e,1,n),t===void 0?t=o.rounding:v(t,0,8),a=E(new o(a),e,t),r=S(a),i=O(a,e<=r||r<=o.toExpNeg,e)),i},g.toSignificantDigits=g.tosd=function(e,t){var r=this,i=r.constructor;return e===void 0?(e=i.precision,t=i.rounding):(v(e,1,n),t===void 0?t=i.rounding:v(t,0,8)),E(new i(r),e,t)},g.toString=g.valueOf=g.val=g.toJSON=function(){var e=this,t=S(e),n=e.constructor;return O(e,t<=n.toExpNeg||t>=n.toExpPos)};function _(e,t){var n,r,a,o,s,c,l,u,d=e.constructor,m=d.precision;if(!e.s||!t.s)return t.s||(t=new d(e)),i?E(t,m):t;if(l=e.d,u=t.d,s=e.e,a=t.e,l=l.slice(),o=s-a,o){for(o<0?(r=l,o=-o,c=u.length):(r=u,a=s,c=l.length),s=Math.ceil(m/p),c=s>c?s+1:c+1,o>c&&(o=c,r.length=1),r.reverse();o--;)r.push(0);r.reverse()}for(c=l.length,o=u.length,c-o<0&&(o=c,r=u,u=l,l=r),n=0;o;)n=(l[--o]=l[o]+u[o]+n)/f|0,l[o]%=f;for(n&&(l.unshift(n),++a),c=l.length;l[--c]==0;)l.pop();return t.d=l,t.e=a,i?E(t,m):t}function v(e,t,n){if(e!==~~e||e<t||e>n)throw Error(o+e)}function y(e){var t,n,r,i=e.length-1,a=``,o=e[0];if(i>0){for(a+=o,t=1;t<i;t++)r=e[t]+``,n=p-r.length,n&&(a+=w(n)),a+=r;o=e[t],r=o+``,n=p-r.length,n&&(a+=w(n))}else if(o===0)return`0`;for(;o%10==0;)o/=10;return a+o}var b=(function(){function e(e,t){var n,r=0,i=e.length;for(e=e.slice();i--;)n=e[i]*t+r,e[i]=n%f|0,r=n/f|0;return r&&e.unshift(r),e}function t(e,t,n,r){var i,a;if(n!=r)a=n>r?1:-1;else for(i=a=0;i<n;i++)if(e[i]!=t[i]){a=e[i]>t[i]?1:-1;break}return a}function n(e,t,n){for(var r=0;n--;)e[n]-=r,r=+(e[n]<t[n]),e[n]=r*f+e[n]-t[n];for(;!e[0]&&e.length>1;)e.shift()}return function(r,i,o,s){var c,l,u,d,m,h,g,_,v,y,b,x,C,w,T,ee,D,O,k=r.constructor,te=r.s==i.s?1:-1,A=r.d,j=i.d;if(!r.s)return new k(r);if(!i.s)throw Error(a+`Division by zero`);for(l=r.e-i.e,D=j.length,T=A.length,g=new k(te),_=g.d=[],u=0;j[u]==(A[u]||0);)++u;if(j[u]>(A[u]||0)&&--l,x=o==null?o=k.precision:s?o+(S(r)-S(i))+1:o,x<0)return new k(0);if(x=x/p+2|0,u=0,D==1)for(d=0,j=j[0],x++;(u<T||d)&&x--;u++)C=d*f+(A[u]||0),_[u]=C/j|0,d=C%j|0;else{for(d=f/(j[0]+1)|0,d>1&&(j=e(j,d),A=e(A,d),D=j.length,T=A.length),w=D,v=A.slice(0,D),y=v.length;y<D;)v[y++]=0;O=j.slice(),O.unshift(0),ee=j[0],j[1]>=f/2&&++ee;do d=0,c=t(j,v,D,y),c<0?(b=v[0],D!=y&&(b=b*f+(v[1]||0)),d=b/ee|0,d>1?(d>=f&&(d=f-1),m=e(j,d),h=m.length,y=v.length,c=t(m,v,h,y),c==1&&(d--,n(m,D<h?O:j,h))):(d==0&&(c=d=1),m=j.slice()),h=m.length,h<y&&m.unshift(0),n(v,m,y),c==-1&&(y=v.length,c=t(j,v,D,y),c<1&&(d++,n(v,D<y?O:j,y))),y=v.length):c===0&&(d++,v=[0]),_[u++]=d,c&&v[0]?v[y++]=A[w]||0:(v=[A[w]],y=1);while((w++<T||v[0]!==void 0)&&x--)}return _[0]||_.shift(),g.e=l,E(g,s?o+S(g)+1:o)}})();function x(e,t){var n,r,a,o,c,u,f=0,p=0,m=e.constructor,h=m.precision;if(S(e)>16)throw Error(s+S(e));if(!e.s)return new m(d);for(t==null?(i=!1,u=h):u=t,c=new m(.03125);e.abs().gte(.1);)e=e.times(c),p+=5;for(r=Math.log(l(2,p))/Math.LN10*2+5|0,u+=r,n=a=o=new m(d),m.precision=u;;){if(a=E(a.times(e),u),n=n.times(++f),c=o.plus(b(a,n,u)),y(c.d).slice(0,u)===y(o.d).slice(0,u)){for(;p--;)o=E(o.times(o),u);return m.precision=h,t==null?(i=!0,E(o,h)):o}o=c}}function S(e){for(var t=e.e*p,n=e.d[0];n>=10;n/=10)t++;return t}function C(e,t,n){if(t>e.LN10.sd())throw i=!0,n&&(e.precision=n),Error(a+`LN10 precision limit exceeded`);return E(new e(e.LN10),t)}function w(e){for(var t=``;e--;)t+=`0`;return t}function T(e,t){var n,r,o,s,c,l,u,f,p,m=1,h=10,g=e,_=g.d,v=g.constructor,x=v.precision;if(g.s<1)throw Error(a+(g.s?`NaN`:`-Infinity`));if(g.eq(d))return new v(0);if(t==null?(i=!1,f=x):f=t,g.eq(10))return t??(i=!0),C(v,f);if(f+=h,v.precision=f,n=y(_),r=n.charAt(0),s=S(g),Math.abs(s)<0x5543df729c000){for(;r<7&&r!=1||r==1&&n.charAt(1)>3;)g=g.times(e),n=y(g.d),r=n.charAt(0),m++;s=S(g),r>1?(g=new v(`0.`+n),s++):g=new v(r+`.`+n.slice(1))}else return u=C(v,f+2,x).times(s+``),g=T(new v(r+`.`+n.slice(1)),f-h).plus(u),v.precision=x,t==null?(i=!0,E(g,x)):g;for(l=c=g=b(g.minus(d),g.plus(d),f),p=E(g.times(g),f),o=3;;){if(c=E(c.times(p),f),u=l.plus(b(c,new v(o),f)),y(u.d).slice(0,f)===y(l.d).slice(0,f))return l=l.times(2),s!==0&&(l=l.plus(C(v,f+2,x).times(s+``))),l=b(l,new v(m),f),v.precision=x,t==null?(i=!0,E(l,x)):l;l=u,o+=2}}function ee(e,t){var n,r,a;for((n=t.indexOf(`.`))>-1&&(t=t.replace(`.`,``)),(r=t.search(/e/i))>0?(n<0&&(n=r),n+=+t.slice(r+1),t=t.substring(0,r)):n<0&&(n=t.length),r=0;t.charCodeAt(r)===48;)++r;for(a=t.length;t.charCodeAt(a-1)===48;)--a;if(t=t.slice(r,a),t){if(a-=r,n=n-r-1,e.e=c(n/p),e.d=[],r=(n+1)%p,n<0&&(r+=p),r<a){for(r&&e.d.push(+t.slice(0,r)),a-=p;r<a;)e.d.push(+t.slice(r,r+=p));t=t.slice(r),r=p-t.length}else r-=a;for(;r--;)t+=`0`;if(e.d.push(+t),i&&(e.e>h||e.e<-h))throw Error(s+n)}else e.s=0,e.e=0,e.d=[0];return e}function E(e,t,n){var r,a,o,u,d,m,g,_,v=e.d;for(u=1,o=v[0];o>=10;o/=10)u++;if(r=t-u,r<0)r+=p,a=t,g=v[_=0];else{if(_=Math.ceil((r+1)/p),o=v.length,_>=o)return e;for(g=o=v[_],u=1;o>=10;o/=10)u++;r%=p,a=r-p+u}if(n!==void 0&&(o=l(10,u-a-1),d=g/o%10|0,m=t<0||v[_+1]!==void 0||g%o,m=n<4?(d||m)&&(n==0||n==(e.s<0?3:2)):d>5||d==5&&(n==4||m||n==6&&(r>0?a>0?g/l(10,u-a):0:v[_-1])%10&1||n==(e.s<0?8:7))),t<1||!v[0])return m?(o=S(e),v.length=1,t=t-o-1,v[0]=l(10,(p-t%p)%p),e.e=c(-t/p)||0):(v.length=1,v[0]=e.e=e.s=0),e;if(r==0?(v.length=_,o=1,_--):(v.length=_+1,o=l(10,p-r),v[_]=a>0?(g/l(10,u-a)%l(10,a)|0)*o:0),m)for(;;)if(_==0){(v[0]+=o)==f&&(v[0]=1,++e.e);break}else{if(v[_]+=o,v[_]!=f)break;v[_--]=0,o=1}for(r=v.length;v[--r]===0;)v.pop();if(i&&(e.e>h||e.e<-h))throw Error(s+S(e));return e}function D(e,t){var n,r,a,o,s,c,l,u,d,m,h=e.constructor,g=h.precision;if(!e.s||!t.s)return t.s?t.s=-t.s:t=new h(e),i?E(t,g):t;if(l=e.d,m=t.d,r=t.e,u=e.e,l=l.slice(),s=u-r,s){for(d=s<0,d?(n=l,s=-s,c=m.length):(n=m,r=u,c=l.length),a=Math.max(Math.ceil(g/p),c)+2,s>a&&(s=a,n.length=1),n.reverse(),a=s;a--;)n.push(0);n.reverse()}else{for(a=l.length,c=m.length,d=a<c,d&&(c=a),a=0;a<c;a++)if(l[a]!=m[a]){d=l[a]<m[a];break}s=0}for(d&&(n=l,l=m,m=n,t.s=-t.s),c=l.length,a=m.length-c;a>0;--a)l[c++]=0;for(a=m.length;a>s;){if(l[--a]<m[a]){for(o=a;o&&l[--o]===0;)l[o]=f-1;--l[o],l[a]+=f}l[a]-=m[a]}for(;l[--c]===0;)l.pop();for(;l[0]===0;l.shift())--r;return l[0]?(t.d=l,t.e=r,i?E(t,g):t):new h(0)}function O(e,t,n){var r,i=S(e),a=y(e.d),o=a.length;return t?(n&&(r=n-o)>0?a=a.charAt(0)+`.`+a.slice(1)+w(r):o>1&&(a=a.charAt(0)+`.`+a.slice(1)),a=a+(i<0?`e`:`e+`)+i):i<0?(a=`0.`+w(-i-1)+a,n&&(r=n-o)>0&&(a+=w(r))):i>=o?(a+=w(i+1-o),n&&(r=n-i-1)>0&&(a=a+`.`+w(r))):((r=i+1)<o&&(a=a.slice(0,r)+`.`+a.slice(r)),n&&(r=n-o)>0&&(i+1===o&&(a+=`.`),a+=w(r))),e.s<0?`-`+a:a}function k(e,t){if(e.length>t)return e.length=t,!0}function te(e){var t,n,r;function i(e){var t=this;if(!(t instanceof i))return new i(e);if(t.constructor=i,e instanceof i){t.s=e.s,t.e=e.e,t.d=(e=e.d)?e.slice():e;return}if(typeof e==`number`){if(e*0!=0)throw Error(o+e);if(e>0)t.s=1;else if(e<0)e=-e,t.s=-1;else{t.s=0,t.e=0,t.d=[0];return}if(e===~~e&&e<1e7){t.e=0,t.d=[e];return}return ee(t,e.toString())}else if(typeof e!=`string`)throw Error(o+e);if(e.charCodeAt(0)===45?(e=e.slice(1),t.s=-1):t.s=1,u.test(e))ee(t,e);else throw Error(o+e)}if(i.prototype=g,i.ROUND_UP=0,i.ROUND_DOWN=1,i.ROUND_CEIL=2,i.ROUND_FLOOR=3,i.ROUND_HALF_UP=4,i.ROUND_HALF_DOWN=5,i.ROUND_HALF_EVEN=6,i.ROUND_HALF_CEIL=7,i.ROUND_HALF_FLOOR=8,i.clone=te,i.config=i.set=A,e===void 0&&(e={}),e)for(r=[`precision`,`rounding`,`toExpNeg`,`toExpPos`,`LN10`],t=0;t<r.length;)e.hasOwnProperty(n=r[t++])||(e[n]=this[n]);return i.config(e),i}function A(e){if(!e||typeof e!=`object`)throw Error(a+`Object expected`);var t,r,i,s=[`precision`,1,n,`rounding`,0,8,`toExpNeg`,-1/0,0,`toExpPos`,0,1/0];for(t=0;t<s.length;t+=3)if((i=e[r=s[t]])!==void 0)if(c(i)===i&&i>=s[t+1]&&i<=s[t+2])this[r]=i;else throw Error(o+r+`: `+i);if((i=e[r=`LN10`])!==void 0)if(i==Math.LN10)this[r]=new this(i);else throw Error(o+r+`: `+i);return this}r=te(r),r.default=r.Decimal=r,d=new r(1),typeof define==`function`&&define.amd?define(function(){return r}):t!==void 0&&t.exports?t.exports=r:(e||=typeof self<`u`&&self&&self.self==self?self:Function(`return this`)(),e.Decimal=r)})(e)}))(),1).default;Gd.set({rounding:Gd.ROUND_HALF_EVEN}),new Gd(1e6),new Gd(1e3);const Kd=r.pipe(r.string(`Amount must be a string`),r.nonEmpty(`Amount must not be empty`),r.check(e=>e.trim()===e,`Amount must not have leading or trailing whitespace`),r.check(e=>!e.includes(`e`)&&!e.includes(`E`),`Scientific notation is not supported (e.g. use 1000000 instead of 1e6)`),r.check(e=>!e.startsWith(`+`),`Amount must not have a '+' prefix`),r.check(e=>!e.startsWith(`-`),`Amount must be non-negative`),r.check(e=>{try{return new Gd(e).gte(0)}catch{return!1}},`Amount must be a valid decimal (e.g. 100 or 100.50)`)),qd=r.pipe(r.string(`Idempotency key must be a string`),r.minLength(1,`Idempotency key must not be empty`),r.maxLength(255,`Idempotency key is too long (max 255 characters)`)),Jd=H({account:B({description:`Source account id`,required:!0,schema:Ie}),rail:B({description:`Destination counterparty rail id (cprl_...)`,required:!0,schema:Ie}),amount:B({description:`USD amount as a decimal string (e.g. 125.00)`,required:!0,schema:Kd,showValueInError:!0}),method:ke({description:`ach | wire | on-chain; ach and wire require a bank rail, on-chain a wallet rail`,required:!0,choices:fc}),memo:B({description:`Memo on the underlying transfer`}),description:B({description:`Operator-facing description`}),idempotencyKey:B({description:`Optional. Usually omit this. Identical retries are deduplicated automatically and return the original intent, even if it failed, so a bare retry never re-sends on its own. Set a unique value only when you intentionally want another payment with the same details.`,schema:qd}),profile:Pe,json:U}),Yd=e({meta:{name:`send`,description:`Submit a USD send intent to a counterparty rail`},args:Jd.args,async run({args:e}){let t=Jd.parse(e),n=_u(t),r={type:`send`,accountId:t.account,counterpartyRailId:t.rail,amount:t.amount,method:t.method,...t.memo?{memo:t.memo}:{},...t.description?{description:t.description}:{}};await n(e=>e.submitIntent({action:r,...t.idempotencyKey?{idempotencyKey:t.idempotencyKey}:{}}))}}),Xd=H({from:B({description:`Source account id`,required:!0,schema:Ie}),to:B({description:`Destination account id`,required:!0,schema:Ie}),amount:B({description:`USD amount as a decimal string (e.g. 125.00)`,required:!0,schema:Kd,showValueInError:!0}),memo:B({description:`Memo on the underlying transfer`}),description:B({description:`Operator-facing description`}),idempotencyKey:B({description:`Optional. Usually omit this. Identical retries are deduplicated automatically and return the original intent, even if it failed, so a bare retry never re-sends on its own. Set a unique value only when you intentionally want another transfer with the same details.`,schema:qd}),profile:Pe,json:U}),Zd=e({meta:{name:`transfer`,description:`Submit a USD transfer intent between two of this agent's accounts`},args:Xd.args,async run({args:e}){let t=Xd.parse(e),n=_u(t),r={type:`transfer`,accountId:t.from,toAccountId:t.to,amount:t.amount,...t.memo?{memo:t.memo}:{},...t.description?{description:t.description}:{}};await n(e=>e.submitIntent({action:r,...t.idempotencyKey?{idempotencyKey:t.idempotencyKey}:{}}))}}),Qd=H({profile:Pe,force:Oe({description:`Remove the profile and its local credentials without contacting the server; use when the credential is missing, revoked, or a link was interrupted`,default:!1}),json:U}),$d=e({meta:{name:`unlink`,description:`Disconnect the selected agent profile`},args:Qd.args,async run({args:e}){let t=Qd.parse(e),n=cu(),r;try{r=ou({flag:mu(t),env:process.env[nu],cwd:process.cwd(),log:e=>console.error(e)}).name}catch(e){L(e)}if(t.force){let e;try{if(e=Ul(r),e===null)throw Error(`Profile "${r}" not found`);await n.delete(e.client_instance_id),await n.delete(sd(e.client_instance_id)),Rl(r)}catch(e){L(e)}pu({success:!0,profile:r,...Pl(e)?{agentId:e.agent_id}:{},local:!0},{compact:t.json});return}let i=`To remove only this machine's copy, run 'catena unlink --profile ${r} --force'.`,a=await eu({profileName:r,fallbackBankUrl:Oc},n);a.ok||L(`${a.message} ${i}`);let o=su(a);try{await o.unlinkAgent(),await n.delete(a.clientInstanceId),await n.delete(sd(a.clientInstanceId)),Rl(r)}catch(e){let t=fu(e,r);L(`${t instanceof Error?t.message:String(t)} ${i}`)}pu({success:!0,profile:r,agentId:a.agentId},{compact:t.json})}}),ef=H({profile:Pe,json:U}),tf=e({meta:{name:`whoami`,description:`Show which agent you are currently acting as`},args:ef.args,async run({args:e}){await _u(ef.parse(e))(e=>e.whoami())}});function nf(e){throw Error(`Unhandled case: ${String(e)}`)}const rf=[`PAYMENT-REQUIRED`,`X-Payment-Required`],af=/^0x[0-9a-fA-F]{64}$/,of=/^0x[0-9a-fA-F]{40}$/,sf=r.looseObject({success:r.boolean(),transaction:r.string()}),cf=r.looseObject({x402Version:r.literal(2),accepts:r.array(_c),resource:r.optional(vc)}),lf=`x402_network_mismatch`,uf=`x402_counterparty_rail_not_found`,df=new Set([`x402_requirement_not_payable`,lf,uf]),ff={"eip155:8453":`Base`,"eip155:84532":`Base Sepolia`};function pf(e){let t=Object.hasOwn(ff,e)?ff[e]:void 0;return t?`${t} (${e})`:e}function mf(e){let t=e.replaceAll(`-`,`+`).replaceAll(`_`,`/`),n=Uint8Array.from(atob(t),e=>e.charCodeAt(0));return JSON.parse(new TextDecoder().decode(n))}function hf(e){let t=rf.map(t=>e.headers.get(t)).find(e=>e!==null);if(t)try{let e=r.safeParse(cf,mf(t));return e.success?e.output:void 0}catch{return}}async function gf(e,t,n){try{let i=n.headers.get(`PAYMENT-RESPONSE`);if(!i)return;let a=r.safeParse(sf,mf(i));if(!a.success||!a.output.success||!af.test(a.output.transaction))return;await e.reportSettlement({intentId:t,txHash:a.output.transaction})}catch{}}var _f=class extends Error{reasons;constructor(e,t=[]){super(t.length>0?`${e}: ${t.join(`; `)}`:e),this.name=`X402PaymentError`,this.reasons=t}},vf=class extends _f{accountId;requiredNetworks;constructor(e,t){super(`Account ${e} cannot fund this 402 challenge: it must be paid from a wallet account on ${t.map(pf).join(` or `)}`),this.name=`X402NetworkMismatchError`,this.accountId=e,this.requiredNetworks=t}},yf=class extends _f{payTo;network;serviceName;constructor(e,t,n){super(`This 402 pays ${e} on ${pf(t)}, which is not a saved counterparty wallet rail; add it as a counterparty before paying`),this.name=`X402CounterpartyNotFoundError`,this.payTo=e,this.network=t,this.serviceName=n}},bf=class extends _f{intentId;expiresAt;constructor(e,t,n){super(`The payment is awaiting a human approval (intent ${e}); once an operator approves it, retry the request to complete the payment`,t),this.name=`X402ApprovalPendingError`,this.intentId=e,this.expiresAt=n}},xf=class extends _f{receipt;constructor(e,t){super(`The payment settled (intent ${e.intentId}) but the paid retry failed; retry the request with the PAYMENT-SIGNATURE header from GET /intents/${e.intentId} instead of paying again`),this.name=`X402RetryFailedError`,this.receipt=e,this.cause=t}},Sf=class extends _f{intentId;requirements;constructor(e,t,n){super(`The payment could not be confirmed (intent ${e}); check GET /intents/${e} for a completed payment and re-read the PAYMENT-SIGNATURE header before paying again`),this.name=`X402SubmitInterruptedError`,this.intentId=e,this.requirements=t,this.cause=n}};async function Cf(e,t){let n=t.paymentRequired.accepts.filter(e=>e.scheme===`exact`),r=n.filter(e=>t.maxAtomicAmount===void 0||/^\d+$/.test(e.amount)&&BigInt(e.amount)<=t.maxAtomicAmount).slice(0,5);if(r.length===0)throw new _f(n.length>0&&t.maxAtomicAmount!==void 0?`Every requirement in the 402 challenge costs more than the caller's maximum amount`:`The 402 challenge offers no exact-scheme requirement Catena can pay`);let i=t.resource??t.paymentRequired.resource,a=[];for(let n of r){let r=await Tf(e,{accountId:t.accountId,requirements:n,resource:i}).catch(e=>{if(e instanceof Sc&&e.code!==void 0&&df.has(e.code)){a.push({error:e,requirement:n});return}throw e});if(r)return r}if(a.length>0&&a.every(e=>e.error.code===lf))throw new vf(t.accountId,[...new Set(a.map(e=>e.requirement.network))]);if(a.length>0&&a.every(e=>e.error.code===uf&&e.error.status===404)&&of.test(a[0].requirement.payTo))throw new yf(a[0].requirement.payTo,a[0].requirement.network,i?.serviceName);let o=a.at(-1);throw new _f(`No requirement in the 402 challenge is payable from this account`,o?[o.error.message]:[])}const wf=r.object({x402:r.object({paymentSignature:r.string()})});async function Tf(e,t){let n=await e.submitIntent({action:{type:`x402`,accountId:t.accountId,paymentRequirements:t.requirements,...t.resource!==void 0&&{resource:t.resource}},idempotencyKey:crypto.randomUUID()}).catch(e=>{throw e instanceof Ec&&e.outcome===`unknown`?new Sf(e.intentId,t.requirements,e):e});if(n.status===`completed`){let e=r.safeParse(wf,n.data);if(e.success)return{intentId:n.id,paymentSignature:e.output.x402.paymentSignature,requirements:t.requirements};throw new _f(`The completed payment did not carry an x402 payment signature`)}switch(n.status){case`pending`:throw new bf(n.id,n.reasons,n.expiresAt);case`processing`:throw new _f(`The payment is still processing (intent ${n.id}); this client cannot resume an in-flight x402 settlement`);case`blocked`:case`failed`:throw new _f(`Catena declined the payment`,n.reasons)}return nf(n.status)}function Ef(e,t){return t?.body!==void 0&&t.body!==null&&typeof t.body!=`string`&&!(t.body instanceof URLSearchParams)&&!(t.body instanceof Blob)&&!(t.body instanceof ArrayBuffer)&&!ArrayBuffer.isView(t.body)?!1:typeof Request<`u`&&e instanceof Request?e.body===null&&!e.bodyUsed:!0}function Df(e,t){let n=(t.baseFetch??globalThis.fetch).bind(globalThis);return async(r,i)=>{let a=await n(r,i);if(a.status!==402)return a;let o=hf(a);if(!o)return a;if(!Ef(r,i))throw new _f(`The request body cannot be replayed after payment; buffer the body (string, Blob, or ArrayBuffer) before using the x402 fetch wrapper`);let s=await Cf(e,{accountId:t.accountId,paymentRequired:o,...t.maxAtomicAmount!==void 0&&{maxAtomicAmount:t.maxAtomicAmount}});t.onPayment?.(s);let c=new Headers(typeof Request<`u`&&r instanceof Request?r.headers:void 0);new Headers(i?.headers).forEach((e,t)=>{c.set(t,e)}),c.set(`PAYMENT-SIGNATURE`,s.paymentSignature);let l;try{l=await n(r,{...i,headers:c})}catch(e){throw new xf(s,e)}return gf(e,s.intentId,l),l}}function Of(e){if(e===`@-`)return kf(0,`stdin`);if(e.startsWith(`@`)){let t=e.slice(1);return t===``?L(`--data @<path>: no file path given`):kf(t,`@${t}`)}return e}function kf(e,t){try{return g(e,`utf8`)}catch(e){return L(`--data ${t}: ${e instanceof Error?e.message:String(e)}`)}}function Af(e){let[t,n=``]=e.split(`.`);return BigInt(`${t}${n.padEnd(6,`0`)}`)}function jf(e){return{intentId:e.intentId,amountAtomicUsdc:e.requirements.amount,payTo:e.requirements.payTo,network:e.requirements.network}}const Mf={"eip155:8453":`base`,"eip155:84532":`base-sepolia`};function Nf(e){return Object.hasOwn(Mf,e)?Mf[e]:void 0}function Pf(e){return`'${e.replaceAll(`'`,`'\\''`)}'`}function Ff(e){return e===void 0?``:` --profile ${Pf(e)}`}function If(e){let t=e?.replaceAll(/[\p{C}\s]/gu,` `).replaceAll(/ {2,}/g,` `).trim();return t!==void 0&&t.length>0?t:void 0}function Lf(e,t,n,r){let i=Nf(t)??Pf(t);return`catena counterparties create wallet --name ${Pf(n??`<name>`)} --address ${Pf(e)} --network ${i}${Ff(r)}`}const Rf=H({url:B({description:`The paywalled URL to fetch (an x402 v2 endpoint)`,required:!0,schema:r.pipe(r.string(),r.url())}),account:B({description:`Source wallet account id the payment draws from`,required:!0,schema:Ie}),maxAmount:B({description:`Refuse challenges above this USD amount (decimal string, e.g. 0.25). Policy limits still apply server-side.`,schema:r.pipe(r.string(),r.regex(/^\d+(\.\d{1,6})?$/))}),method:ke({description:`HTTP method for the request`,choices:[`GET`,`POST`]}),data:B({description:`Request body. Use @path to read a file or @- for stdin. Implies POST and a JSON content type unless overridden.`}),contentType:B({description:`Content-Type header for the request body (default application/json when --data is set)`}),profile:Pe,json:U}),zf=e({meta:{name:`x402`,description:`Fetch a URL, paying its x402 (HTTP 402) challenge via USDC`},args:Rf.args,async run({args:e}){let t=Rf.parse(e),n=t.method??(t.data===void 0?`GET`:`POST`);t.data!==void 0&&n!==`POST`&&L(`--data cannot be sent with --method ${n}; a body requires POST`),t.contentType!==void 0&&t.data===void 0&&L(`--content-type has no effect without --data`);let r=t.data===void 0?void 0:Of(t.data),i=r===void 0?void 0:{"content-type":t.contentType??`application/json`};await _u(t)(async e=>{let a,o=Df(e,{accountId:t.account,...t.maxAmount!==void 0&&{maxAtomicAmount:Af(t.maxAmount)},onPayment:e=>{a=e}}),s;try{s=await o(t.url,{method:n,...r!==void 0&&{body:r},...i!==void 0&&{headers:i}})}catch(e){if(e instanceof xf)return{status:null,paid:!0,retryFailed:!0,payment:jf(e.receipt),error:e.message};if(e instanceof vf){let n=e.requiredNetworks.map(e=>Nf(e)??e);return{status:null,paid:!1,retryFailed:!1,networkMismatch:{account:e.accountId,requiredNetworks:n,requiredNetworkIds:[...e.requiredNetworks]},error:`${e.message}. Re-run with --account set to a wallet account on ${n.join(` or `)} (your account ids are in \`catena accounts list${Ff(t.profile)}\`).`}}if(e instanceof yf){let n=If(e.serviceName),r=n!==void 0&&n.length<=40?n:void 0,i=Lf(e.payTo,e.network,r,t.profile),a=n===void 0?``:` The endpoint calls itself "${n.length>40?`${n.slice(0,40)}…`:n}" (unverified) — rename it if that is not a service you recognize.`;return{status:null,paid:!1,retryFailed:!1,counterpartyNotFound:{payTo:e.payTo,network:Nf(e.network)??e.network,networkId:e.network,createCommand:i,nameIsPlaceholder:r===void 0,...n!==void 0&&{serviceName:n}},error:`${e.message}. Add it, then re-run:\n ${i}\n(counterparty creation may require approval per your policy)${a}`}}if(e instanceof bf)return{status:null,paid:!1,retryFailed:!1,approvalPending:{intentId:e.intentId,expiresAt:e.expiresAt,reasons:[...e.reasons]},error:e.message};throw e}let c=await s.text();return{status:s.status,paid:a!==void 0,retryFailed:!1,...a!==void 0&&{payment:jf(a)},body:c.slice(0,4e3)}},{exitCode:e=>e.retryFailed||`approvalPending`in e||`networkMismatch`in e||`counterpartyNotFound`in e?1:0})}}),Bf=r.object({version:r.literal(1),result:r.literal(`latest-version`),latestVersion:r.string(),checkedAt:r.pipe(r.string(),r.isoTimestamp())}),Vf=r.object({version:r.literal(1),result:r.literal(`fetch-failure`),checkedAt:r.pipe(r.string(),r.isoTimestamp())}),Hf=r.variant(`result`,[Bf,Vf]),Uf=r.object({"dist-tags":r.object({latest:r.string()})});function Wf(){return T(wl(),`cache`,`cli-version.json`)}function Gf(e){return new URL(encodeURIComponent(e),`https://registry.npmjs.org/`).href}function Kf(e){try{let t=JSON.parse(g(e,`utf8`)),n=r.safeParse(Hf,t);return n.success?n.output:void 0}catch{return}}function qf(e){let t=Kf(e);if(!t)return;let n=Date.parse(t.checkedAt);if(!Number.isFinite(n))return;let r=Date.now()-n,i=t.result===`fetch-failure`?36e5:864e5;if(!(r<0||r>=i))return t}function Jf(e){try{let t=C(e),n=C(t);return h(n,{recursive:!0,mode:448}),p(n,448),h(t,{recursive:!0,mode:448}),p(t,448),t}catch{return}}function Yf(e){try{return!m(e)||b(e).isFile()}catch{return!1}}function Xf(e){let t=Jf(e);if(t===void 0||!Yf(e))return!1;let n=T(t,`.cli-version-check-${l(6).toString(`hex`)}.tmp`);try{return x(n,``,{encoding:`utf8`,mode:384}),y(n,{force:!0}),!0}catch{try{y(n,{force:!0})}catch{}return!1}}function Zf(e,t){if(Jf(e)===void 0)return!1;try{let n=`${e}.${l(6).toString(`hex`)}.tmp`;return x(n,`${JSON.stringify({version:1,...t,checkedAt:new Date().toISOString()},null,2)}\n`,{encoding:`utf8`,mode:384}),v(n,e),!0}catch{return!1}}async function Qf(e){let t=new AbortController,n=setTimeout(()=>t.abort(),750);n.unref();try{let n=await fetch(Gf(e.packageName),{headers:{accept:`application/json`},signal:t.signal});if(!n.ok)return;let i=await n.json(),a=r.safeParse(Uf,i);return a.success?a.output[`dist-tags`].latest:void 0}catch{return}finally{clearTimeout(n)}}function $f(e){let t=D.valid(e.currentVersion),n=D.valid(e.latestVersion);t===null||n===null||D.gt(n,t)&&console.error(`A newer ${e.packageName} version is available: ${n} (current ${t}).`)}async function ep({packageName:e,currentVersion:t}){let n=Wf(),r=qf(n);if(r?.result===`latest-version`){$f({packageName:e,currentVersion:t,latestVersion:r.latestVersion});return}if(r?.result===`fetch-failure`||!Xf(n))return;let i=await Qf({packageName:e});if(i===void 0){Zf(n,{result:`fetch-failure`});return}Zf(n,{result:`latest-version`,latestVersion:i}),$f({packageName:e,currentVersion:t,latestVersion:i})}async function tp(e){return typeof e==`function`?await e():await e}async function np(e){return typeof e==`function`?await e():await e}async function rp(e){return typeof e==`function`?await e():await e}async function ip(e,t,n=[]){if(e===t)return n;let r=await rp(e.subCommands??{});return(await Promise.all(Object.entries(r).map(async([e,r])=>ip(await tp(r),t,[...n,e])))).find(e=>e!==void 0)}async function ap(e,t){if(!e||!t||t.length<2)return e;let n=await np(e.meta??{});return{...e,meta:{...n,name:t.slice(0,-1).join(` `)}}}function op(e){return async(n,r)=>{let i=await t(n,await ap(r,await ip(e,n)));console.log(`${i}\n`)}}function sp({shouldCheckCliVersionFreshness:t}){return e({meta:{name:`catena`,version:se,description:`Catena CLI`},async setup({rawArgs:e}){!t||e.length===0||await ep({packageName:oe,currentVersion:se})},subCommands:{link:kd,unlink:$d,profiles:Vd,whoami:tf,policy:Md,accounts:Eu,intents:qu,send:Yd,transfer:Zd,x402:zf,counterparties:Ru,feedback:Uu,guide:Gu}})}const cp=sp({shouldCheckCliVersionFreshness:!0});sp({shouldCheckCliVersionFreshness:!1});function lp(){n(cp,{showUsage:op(cp)})}lp();export{Be as _,dt as a,Ze as c,et as d,ut as f,lt as g,pt as h,qt as i,Ye as l,Je as m,Kt as n,Xe as o,st as p,Jt as r,Qe as s,ps as t,it as u,W as v,Le as y};