@canton-network/wallet-gateway-remote 0.5.0 → 0.5.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 (28) hide show
  1. package/dist/config/Config.d.ts +7 -7
  2. package/dist/config/Config.d.ts.map +1 -1
  3. package/dist/dapp-api/controller.js +1 -1
  4. package/dist/dapp-api/rpc-gen/typings.d.ts +4 -4
  5. package/dist/dapp-api/rpc-gen/typings.d.ts.map +1 -1
  6. package/dist/ledger/party-allocation-service.test.js +1 -1
  7. package/dist/ledger/wallet-sync-service.js +1 -1
  8. package/dist/user-api/controller.d.ts.map +1 -1
  9. package/dist/user-api/controller.js +7 -21
  10. package/dist/user-api/rpc-gen/typings.d.ts +12 -12
  11. package/dist/user-api/rpc-gen/typings.d.ts.map +1 -1
  12. package/dist/web/frontend/404/index.html +2 -2
  13. package/dist/web/frontend/approve/index.html +4 -4
  14. package/dist/web/frontend/assets/{404-BJiXCpwg.js → 404-C4ltj2Y3.js} +1 -1
  15. package/dist/web/frontend/assets/{approve-hB6irrWF.js → approve-Drc1zW1z.js} +1 -1
  16. package/dist/web/frontend/assets/{callback-DHz7ggNR.js → callback-BBgKxZBh.js} +1 -1
  17. package/dist/web/frontend/assets/{handle-errors-DT2Go5Ch.js → handle-errors-C_r_-A1k.js} +1 -1
  18. package/dist/web/frontend/assets/{index-YpAHEASq.js → index-_AVK9fEz.js} +5 -5
  19. package/dist/web/frontend/assets/{login-Dw5jymys.js → login-x46HxVRr.js} +1 -1
  20. package/dist/web/frontend/assets/{networks-CaAXx7MG.js → networks-DSlcKT60.js} +2 -2
  21. package/dist/web/frontend/assets/{state-BTqOtYLt.js → state-BahUv9dS.js} +1 -1
  22. package/dist/web/frontend/assets/{wallets-fk9mMhcI.js → wallets-BXR4V066.js} +5 -5
  23. package/dist/web/frontend/callback/index.html +2 -2
  24. package/dist/web/frontend/index.html +1 -1
  25. package/dist/web/frontend/login/index.html +3 -3
  26. package/dist/web/frontend/networks/index.html +4 -4
  27. package/dist/web/frontend/wallets/index.html +4 -4
  28. package/package.json +6 -6
@@ -1 +1 @@
1
- import{i as y,s as u,b as C,x as P,t as O}from"./index-YpAHEASq.js";var L=Object.create,f=Object.defineProperty,z=Object.getOwnPropertyDescriptor,g=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),k=e=>{throw TypeError(e)},I=(e,t,o)=>t in e?f(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,R=(e,t)=>f(e,"name",{value:t,configurable:!0}),j=e=>[,,,L((e==null?void 0:e[g("metadata")])??null)],D=["class","method","getter","setter","accessor","field","value","get","set"],b=e=>e!==void 0&&typeof e!="function"?k("Function expected"):e,E=(e,t,o,r,a)=>({kind:D[e],name:t,metadata:r,addInitializer:c=>o._?k("Already initialized"):a.push(b(c||null))}),T=(e,t)=>I(t,g("metadata"),e[3]),N=(e,t,o,r)=>{for(var a=0,c=e[t>>1],i=c&&c.length;a<i;a++)c[a].call(o);return r},U=(e,t,o,r,a,c)=>{var i,s,d,n=t&7,l=!1,w=0,x=e[w]||(e[w]=[]),_=n&&(a=a.prototype,n<5&&(n>3||!l)&&z(a,o));R(a,o);for(var p=r.length-1;p>=0;p--)d=E(n,o,s={},e[3],x),i=(0,r[p])(a,d),s._=1,b(i)&&(a=i);return T(e,a),_&&f(a,o,_),l?n^4?c:_:a},m,v,S;m=[O("login-callback")];class h extends(S=y){connectedCallback(){super.connectedCallback(),this.handleRedirect()}async handleRedirect(){const t=new URL(window.location.href),o=t.searchParams.get("code"),r=t.searchParams.get("state");if(!o&&!r){console.error("missing state and code");return}if(o&&r){const a=JSON.parse(atob(r)),s=(await(await fetch(a.configUrl)).json()).token_endpoint,n=await(await fetch(s,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"authorization_code",code:o,redirect_uri:window.location.origin+"/callback/",client_id:a.clientId,audience:a.audience})})).json();if(n.access_token){const l=JSON.parse(atob(n.access_token.split(".")[1]));u.expirationDate.set(new Date(l.exp*1e3).toString()),u.accessToken.set(n.access_token),C(n.access_token,u.chainId.get()||"").then(()=>{window.location.replace("/")})}}}render(){return P`<h2>Logged in!</h2>`}}v=j(S);h=U(v,0,"LoginCallback",m,h);N(v,1,h);
1
+ import{i as y,s as u,b as C,x as P,t as O}from"./index-_AVK9fEz.js";var L=Object.create,h=Object.defineProperty,z=Object.getOwnPropertyDescriptor,g=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),k=e=>{throw TypeError(e)},I=(e,t,o)=>t in e?h(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,R=(e,t)=>h(e,"name",{value:t,configurable:!0}),j=e=>[,,,L((e==null?void 0:e[g("metadata")])??null)],D=["class","method","getter","setter","accessor","field","value","get","set"],b=e=>e!==void 0&&typeof e!="function"?k("Function expected"):e,E=(e,t,o,r,a)=>({kind:D[e],name:t,metadata:r,addInitializer:c=>o._?k("Already initialized"):a.push(b(c||null))}),T=(e,t)=>I(t,g("metadata"),e[3]),N=(e,t,o,r)=>{for(var a=0,c=e[t>>1],i=c&&c.length;a<i;a++)c[a].call(o);return r},U=(e,t,o,r,a,c)=>{var i,s,d,n=t&7,l=!1,w=0,x=e[w]||(e[w]=[]),_=n&&(a=a.prototype,n<5&&(n>3||!l)&&z(a,o));R(a,o);for(var p=r.length-1;p>=0;p--)d=E(n,o,s={},e[3],x),i=(0,r[p])(a,d),s._=1,b(i)&&(a=i);return T(e,a),_&&h(a,o,_),l?n^4?c:_:a},m,v,S;m=[O("login-callback")];class f extends(S=y){connectedCallback(){super.connectedCallback(),this.handleRedirect()}async handleRedirect(){const t=new URL(window.location.href),o=t.searchParams.get("code"),r=t.searchParams.get("state");if(!o&&!r){console.error("missing state and code");return}if(o&&r){const a=JSON.parse(atob(r)),s=(await(await fetch(a.configUrl)).json()).token_endpoint,n=await(await fetch(s,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:"authorization_code",code:o,redirect_uri:window.location.origin+"/callback/",client_id:a.clientId,audience:a.audience})})).json();if(n.access_token){const l=JSON.parse(atob(n.access_token.split(".")[1]));u.expirationDate.set(new Date(l.exp*1e3).toString()),u.accessToken.set(n.access_token),C(n.access_token,u.networkId.get()||"").then(()=>{window.location.replace("/")})}}}render(){return P`<h2>Logged in!</h2>`}}v=j(S);f=U(v,0,"LoginCallback",m,f);N(v,1,f);
@@ -1 +1 @@
1
- import{E as i}from"./index-YpAHEASq.js";function m(r,e){const t=document.createElement("custom-toast");let s=-1,o="";if(i.safeParse(r).success){const n=i.parse(r);s=n.error.code,o=n.error.message}switch(s){case-32600:t.title="Invalid Request";break;case-32601:t.title="Method Not Found";break;case-32602:t.title="Invalid Parameters";break;case-32603:t.title="Internal Error";break;default:t.title=(e==null?void 0:e.title)||"Unexpected Error";break}t.message=o||(e==null?void 0:e.message)||"Something went wrong. Please try again.",t.type="error",t.buttonText=(e==null?void 0:e.buttonText)||"Dismiss",document.body.appendChild(t)}export{m as h};
1
+ import{E as i}from"./index-_AVK9fEz.js";function m(r,e){const t=document.createElement("custom-toast");let s=-1,o="";if(i.safeParse(r).success){const n=i.parse(r);s=n.error.code,o=n.error.message}switch(s){case-32600:t.title="Invalid Request";break;case-32601:t.title="Method Not Found";break;case-32602:t.title="Invalid Parameters";break;case-32603:t.title="Internal Error";break;default:t.title=(e==null?void 0:e.title)||"Unexpected Error";break}t.message=o||(e==null?void 0:e.message)||"Something went wrong. Please try again.",t.type="error",t.buttonText=(e==null?void 0:e.buttonText)||"Dismiss",document.body.appendChild(t)}export{m as h};
@@ -433,7 +433,7 @@
433
433
  </h6>
434
434
  <div class="network-meta">
435
435
  <strong>ID:</strong>
436
- ${this.network.chainId}<br />
436
+ ${this.network.id}<br />
437
437
  <strong>Auth:</strong> ${this.network.auth.type}<br />
438
438
  <strong>Synchronizer:</strong>
439
439
  ${this.network.synchronizerId}
@@ -475,7 +475,7 @@
475
475
  margin-bottom: 0.5rem;
476
476
  word-break: break-all;
477
477
  }
478
- `];Sr([I({type:Object})],ae.prototype,"network",2);Sr([Le()],ae.prototype,"_editing",2);ae=Sr([ut("network-card")],ae);var j;(function(r){r.assertEqual=a=>{};function t(a){}r.assertIs=t;function e(a){throw new Error}r.assertNever=e,r.arrayToEnum=a=>{const i={};for(const n of a)i[n]=n;return i},r.getValidEnumValues=a=>{const i=r.objectKeys(a).filter(s=>typeof a[a[s]]!="number"),n={};for(const s of i)n[s]=a[s];return r.objectValues(n)},r.objectValues=a=>r.objectKeys(a).map(function(i){return a[i]}),r.objectKeys=typeof Object.keys=="function"?a=>Object.keys(a):a=>{const i=[];for(const n in a)Object.prototype.hasOwnProperty.call(a,n)&&i.push(n);return i},r.find=(a,i)=>{for(const n of a)if(i(n))return n},r.isInteger=typeof Number.isInteger=="function"?a=>Number.isInteger(a):a=>typeof a=="number"&&Number.isFinite(a)&&Math.floor(a)===a;function o(a,i=" | "){return a.map(n=>typeof n=="string"?`'${n}'`:n).join(i)}r.joinValues=o,r.jsonStringifyReplacer=(a,i)=>typeof i=="bigint"?i.toString():i})(j||(j={}));var oo;(function(r){r.mergeShapes=(t,e)=>({...t,...e})})(oo||(oo={}));const f=j.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),st=r=>{switch(typeof r){case"undefined":return f.undefined;case"string":return f.string;case"number":return Number.isNaN(r)?f.nan:f.number;case"boolean":return f.boolean;case"function":return f.function;case"bigint":return f.bigint;case"symbol":return f.symbol;case"object":return Array.isArray(r)?f.array:r===null?f.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?f.promise:typeof Map<"u"&&r instanceof Map?f.map:typeof Set<"u"&&r instanceof Set?f.set:typeof Date<"u"&&r instanceof Date?f.date:f.object;default:return f.unknown}},p=j.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class rt extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=o=>{this.issues=[...this.issues,o]},this.addIssues=(o=[])=>{this.issues=[...this.issues,...o]};const e=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,e):this.__proto__=e,this.name="ZodError",this.issues=t}format(t){const e=t||function(i){return i.message},o={_errors:[]},a=i=>{for(const n of i.issues)if(n.code==="invalid_union")n.unionErrors.map(a);else if(n.code==="invalid_return_type")a(n.returnTypeError);else if(n.code==="invalid_arguments")a(n.argumentsError);else if(n.path.length===0)o._errors.push(e(n));else{let s=o,d=0;for(;d<n.path.length;){const l=n.path[d];d===n.path.length-1?(s[l]=s[l]||{_errors:[]},s[l]._errors.push(e(n))):s[l]=s[l]||{_errors:[]},s=s[l],d++}}};return a(this),o}static assert(t){if(!(t instanceof rt))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,j.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=e=>e.message){const e={},o=[];for(const a of this.issues)if(a.path.length>0){const i=a.path[0];e[i]=e[i]||[],e[i].push(t(a))}else o.push(t(a));return{formErrors:o,fieldErrors:e}}get formErrors(){return this.flatten()}}rt.create=r=>new rt(r);const nr=(r,t)=>{let e;switch(r.code){case p.invalid_type:r.received===f.undefined?e="Required":e=`Expected ${r.expected}, received ${r.received}`;break;case p.invalid_literal:e=`Invalid literal value, expected ${JSON.stringify(r.expected,j.jsonStringifyReplacer)}`;break;case p.unrecognized_keys:e=`Unrecognized key(s) in object: ${j.joinValues(r.keys,", ")}`;break;case p.invalid_union:e="Invalid input";break;case p.invalid_union_discriminator:e=`Invalid discriminator value. Expected ${j.joinValues(r.options)}`;break;case p.invalid_enum_value:e=`Invalid enum value. Expected ${j.joinValues(r.options)}, received '${r.received}'`;break;case p.invalid_arguments:e="Invalid function arguments";break;case p.invalid_return_type:e="Invalid function return type";break;case p.invalid_date:e="Invalid date";break;case p.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(e=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(e=`${e} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?e=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?e=`Invalid input: must end with "${r.validation.endsWith}"`:j.assertNever(r.validation):r.validation!=="regex"?e=`Invalid ${r.validation}`:e="Invalid";break;case p.too_small:r.type==="array"?e=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?e=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?e=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="bigint"?e=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?e=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:e="Invalid input";break;case p.too_big:r.type==="array"?e=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?e=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?e=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?e=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?e=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:e="Invalid input";break;case p.custom:e="Invalid input";break;case p.invalid_intersection_types:e="Intersection results could not be merged";break;case p.not_multiple_of:e=`Number must be a multiple of ${r.multipleOf}`;break;case p.not_finite:e="Number must be finite";break;default:e=t.defaultError,j.assertNever(r)}return{message:e}};let Vi=nr;function Fi(){return Vi}const Wi=r=>{const{data:t,path:e,errorMaps:o,issueData:a}=r,i=[...e,...a.path||[]],n={...a,path:i};if(a.message!==void 0)return{...a,path:i,message:a.message};let s="";const d=o.filter(l=>!!l).slice().reverse();for(const l of d)s=l(n,{data:t,defaultError:s}).message;return{...a,path:i,message:s}};function g(r,t){const e=Fi(),o=Wi({issueData:t,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,e,e===nr?void 0:nr].filter(a=>!!a)});r.common.issues.push(o)}class B{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,e){const o=[];for(const a of e){if(a.status==="aborted")return w;a.status==="dirty"&&t.dirty(),o.push(a.value)}return{status:t.value,value:o}}static async mergeObjectAsync(t,e){const o=[];for(const a of e){const i=await a.key,n=await a.value;o.push({key:i,value:n})}return B.mergeObjectSync(t,o)}static mergeObjectSync(t,e){const o={};for(const a of e){const{key:i,value:n}=a;if(i.status==="aborted"||n.status==="aborted")return w;i.status==="dirty"&&t.dirty(),n.status==="dirty"&&t.dirty(),i.value!=="__proto__"&&(typeof n.value<"u"||a.alwaysSet)&&(o[i.value]=n.value)}return{status:t.value,value:o}}}const w=Object.freeze({status:"aborted"}),sr=r=>({status:"dirty",value:r}),F=r=>({status:"valid",value:r}),ao=r=>r.status==="aborted",io=r=>r.status==="dirty",Dt=r=>r.status==="valid",Te=r=>typeof Promise<"u"&&r instanceof Promise;var v;(function(r){r.errToObj=t=>typeof t=="string"?{message:t}:t||{},r.toString=t=>typeof t=="string"?t:t==null?void 0:t.message})(v||(v={}));class bt{constructor(t,e,o,a){this._cachedPath=[],this.parent=t,this.data=e,this._path=o,this._key=a}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const no=(r,t)=>{if(Dt(t))return{success:!0,data:t.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const e=new rt(r.common.issues);return this._error=e,this._error}}};function S(r){if(!r)return{};const{errorMap:t,invalid_type_error:e,required_error:o,description:a}=r;if(t&&(e||o))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:a}:{errorMap:(i,n)=>{const{message:s}=r;return i.code==="invalid_enum_value"?{message:s??n.defaultError}:typeof n.data>"u"?{message:s??o??n.defaultError}:i.code!=="invalid_type"?{message:n.defaultError}:{message:s??e??n.defaultError}},description:a}}class T{get description(){return this._def.description}_getType(t){return st(t.data)}_getOrReturnCtx(t,e){return e||{common:t.parent.common,data:t.data,parsedType:st(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new B,ctx:{common:t.parent.common,data:t.data,parsedType:st(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){const e=this._parse(t);if(Te(e))throw new Error("Synchronous parse encountered promise.");return e}_parseAsync(t){const e=this._parse(t);return Promise.resolve(e)}parse(t,e){const o=this.safeParse(t,e);if(o.success)return o.data;throw o.error}safeParse(t,e){const o={common:{issues:[],async:(e==null?void 0:e.async)??!1,contextualErrorMap:e==null?void 0:e.errorMap},path:(e==null?void 0:e.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:st(t)},a=this._parseSync({data:t,path:o.path,parent:o});return no(o,a)}"~validate"(t){var e,o;const a={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:st(t)};if(!this["~standard"].async)try{const i=this._parseSync({data:t,path:[],parent:a});return Dt(i)?{value:i.value}:{issues:a.common.issues}}catch(i){(o=(e=i==null?void 0:i.message)==null?void 0:e.toLowerCase())!=null&&o.includes("encountered")&&(this["~standard"].async=!0),a.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:a}).then(i=>Dt(i)?{value:i.value}:{issues:a.common.issues})}async parseAsync(t,e){const o=await this.safeParseAsync(t,e);if(o.success)return o.data;throw o.error}async safeParseAsync(t,e){const o={common:{issues:[],contextualErrorMap:e==null?void 0:e.errorMap,async:!0},path:(e==null?void 0:e.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:st(t)},a=this._parse({data:t,path:o.path,parent:o}),i=await(Te(a)?a:Promise.resolve(a));return no(o,i)}refine(t,e){const o=a=>typeof e=="string"||typeof e>"u"?{message:e}:typeof e=="function"?e(a):e;return this._refinement((a,i)=>{const n=t(a),s=()=>i.addIssue({code:p.custom,...o(a)});return typeof Promise<"u"&&n instanceof Promise?n.then(d=>d?!0:(s(),!1)):n?!0:(s(),!1)})}refinement(t,e){return this._refinement((o,a)=>t(o)?!0:(a.addIssue(typeof e=="function"?e(o,a):e),!1))}_refinement(t){return new Tt({schema:this,typeName:k.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:e=>this["~validate"](e)}}optional(){return tt.create(this,this._def)}nullable(){return zt.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return G.create(this)}promise(){return Re.create(this,this._def)}or(t){return je.create([this,t],this._def)}and(t){return Ce.create(this,t,this._def)}transform(t){return new Tt({...S(this._def),schema:this,typeName:k.ZodEffects,effect:{type:"transform",transform:t}})}default(t){const e=typeof t=="function"?t:()=>t;return new Ie({...S(this._def),innerType:this,defaultValue:e,typeName:k.ZodDefault})}brand(){return new Fo({typeName:k.ZodBranded,type:this,...S(this._def)})}catch(t){const e=typeof t=="function"?t:()=>t;return new Pe({...S(this._def),innerType:this,catchValue:e,typeName:k.ZodCatch})}describe(t){const e=this.constructor;return new e({...this._def,description:t})}pipe(t){return Tr.create(this,t)}readonly(){return Ne.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const qi=/^c[^\s-]{8,}$/i,Gi=/^[0-9a-z]+$/,Hi=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Ki=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Yi=/^[a-z0-9_-]{21}$/i,Ji=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Xi=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Qi=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,tn="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Ke;const en=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,rn=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,on=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,an=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,nn=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,sn=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Bo="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",dn=new RegExp(`^${Bo}$`);function Do(r){let t="[0-5]\\d";r.precision?t=`${t}\\.\\d{${r.precision}}`:r.precision==null&&(t=`${t}(\\.\\d+)?`);const e=r.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${e}`}function ln(r){return new RegExp(`^${Do(r)}$`)}function cn(r){let t=`${Bo}T${Do(r)}`;const e=[];return e.push(r.local?"Z?":"Z"),r.offset&&e.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${e.join("|")})`,new RegExp(`^${t}$`)}function pn(r,t){return!!((t==="v4"||!t)&&en.test(r)||(t==="v6"||!t)&&on.test(r))}function mn(r,t){if(!Ji.test(r))return!1;try{const[e]=r.split(".");if(!e)return!1;const o=e.replace(/-/g,"+").replace(/_/g,"/").padEnd(e.length+(4-e.length%4)%4,"="),a=JSON.parse(atob(o));return!(typeof a!="object"||a===null||"typ"in a&&(a==null?void 0:a.typ)!=="JWT"||!a.alg||t&&a.alg!==t)}catch{return!1}}function bn(r,t){return!!((t==="v4"||!t)&&rn.test(r)||(t==="v6"||!t)&&an.test(r))}class lt extends T{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==f.string){const a=this._getOrReturnCtx(t);return g(a,{code:p.invalid_type,expected:f.string,received:a.parsedType}),w}const e=new B;let o;for(const a of this._def.checks)if(a.kind==="min")t.data.length<a.value&&(o=this._getOrReturnCtx(t,o),g(o,{code:p.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),e.dirty());else if(a.kind==="max")t.data.length>a.value&&(o=this._getOrReturnCtx(t,o),g(o,{code:p.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),e.dirty());else if(a.kind==="length"){const i=t.data.length>a.value,n=t.data.length<a.value;(i||n)&&(o=this._getOrReturnCtx(t,o),i?g(o,{code:p.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):n&&g(o,{code:p.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),e.dirty())}else if(a.kind==="email")Qi.test(t.data)||(o=this._getOrReturnCtx(t,o),g(o,{validation:"email",code:p.invalid_string,message:a.message}),e.dirty());else if(a.kind==="emoji")Ke||(Ke=new RegExp(tn,"u")),Ke.test(t.data)||(o=this._getOrReturnCtx(t,o),g(o,{validation:"emoji",code:p.invalid_string,message:a.message}),e.dirty());else if(a.kind==="uuid")Ki.test(t.data)||(o=this._getOrReturnCtx(t,o),g(o,{validation:"uuid",code:p.invalid_string,message:a.message}),e.dirty());else if(a.kind==="nanoid")Yi.test(t.data)||(o=this._getOrReturnCtx(t,o),g(o,{validation:"nanoid",code:p.invalid_string,message:a.message}),e.dirty());else if(a.kind==="cuid")qi.test(t.data)||(o=this._getOrReturnCtx(t,o),g(o,{validation:"cuid",code:p.invalid_string,message:a.message}),e.dirty());else if(a.kind==="cuid2")Gi.test(t.data)||(o=this._getOrReturnCtx(t,o),g(o,{validation:"cuid2",code:p.invalid_string,message:a.message}),e.dirty());else if(a.kind==="ulid")Hi.test(t.data)||(o=this._getOrReturnCtx(t,o),g(o,{validation:"ulid",code:p.invalid_string,message:a.message}),e.dirty());else if(a.kind==="url")try{new URL(t.data)}catch{o=this._getOrReturnCtx(t,o),g(o,{validation:"url",code:p.invalid_string,message:a.message}),e.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(t.data)||(o=this._getOrReturnCtx(t,o),g(o,{validation:"regex",code:p.invalid_string,message:a.message}),e.dirty())):a.kind==="trim"?t.data=t.data.trim():a.kind==="includes"?t.data.includes(a.value,a.position)||(o=this._getOrReturnCtx(t,o),g(o,{code:p.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),e.dirty()):a.kind==="toLowerCase"?t.data=t.data.toLowerCase():a.kind==="toUpperCase"?t.data=t.data.toUpperCase():a.kind==="startsWith"?t.data.startsWith(a.value)||(o=this._getOrReturnCtx(t,o),g(o,{code:p.invalid_string,validation:{startsWith:a.value},message:a.message}),e.dirty()):a.kind==="endsWith"?t.data.endsWith(a.value)||(o=this._getOrReturnCtx(t,o),g(o,{code:p.invalid_string,validation:{endsWith:a.value},message:a.message}),e.dirty()):a.kind==="datetime"?cn(a).test(t.data)||(o=this._getOrReturnCtx(t,o),g(o,{code:p.invalid_string,validation:"datetime",message:a.message}),e.dirty()):a.kind==="date"?dn.test(t.data)||(o=this._getOrReturnCtx(t,o),g(o,{code:p.invalid_string,validation:"date",message:a.message}),e.dirty()):a.kind==="time"?ln(a).test(t.data)||(o=this._getOrReturnCtx(t,o),g(o,{code:p.invalid_string,validation:"time",message:a.message}),e.dirty()):a.kind==="duration"?Xi.test(t.data)||(o=this._getOrReturnCtx(t,o),g(o,{validation:"duration",code:p.invalid_string,message:a.message}),e.dirty()):a.kind==="ip"?pn(t.data,a.version)||(o=this._getOrReturnCtx(t,o),g(o,{validation:"ip",code:p.invalid_string,message:a.message}),e.dirty()):a.kind==="jwt"?mn(t.data,a.alg)||(o=this._getOrReturnCtx(t,o),g(o,{validation:"jwt",code:p.invalid_string,message:a.message}),e.dirty()):a.kind==="cidr"?bn(t.data,a.version)||(o=this._getOrReturnCtx(t,o),g(o,{validation:"cidr",code:p.invalid_string,message:a.message}),e.dirty()):a.kind==="base64"?nn.test(t.data)||(o=this._getOrReturnCtx(t,o),g(o,{validation:"base64",code:p.invalid_string,message:a.message}),e.dirty()):a.kind==="base64url"?sn.test(t.data)||(o=this._getOrReturnCtx(t,o),g(o,{validation:"base64url",code:p.invalid_string,message:a.message}),e.dirty()):j.assertNever(a);return{status:e.value,value:t.data}}_regex(t,e,o){return this.refinement(a=>t.test(a),{validation:e,code:p.invalid_string,...v.errToObj(o)})}_addCheck(t){return new lt({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...v.errToObj(t)})}url(t){return this._addCheck({kind:"url",...v.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...v.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...v.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...v.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...v.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...v.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...v.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...v.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...v.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...v.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...v.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...v.errToObj(t)})}datetime(t){return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,offset:(t==null?void 0:t.offset)??!1,local:(t==null?void 0:t.local)??!1,...v.errToObj(t==null?void 0:t.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,...v.errToObj(t==null?void 0:t.message)})}duration(t){return this._addCheck({kind:"duration",...v.errToObj(t)})}regex(t,e){return this._addCheck({kind:"regex",regex:t,...v.errToObj(e)})}includes(t,e){return this._addCheck({kind:"includes",value:t,position:e==null?void 0:e.position,...v.errToObj(e==null?void 0:e.message)})}startsWith(t,e){return this._addCheck({kind:"startsWith",value:t,...v.errToObj(e)})}endsWith(t,e){return this._addCheck({kind:"endsWith",value:t,...v.errToObj(e)})}min(t,e){return this._addCheck({kind:"min",value:t,...v.errToObj(e)})}max(t,e){return this._addCheck({kind:"max",value:t,...v.errToObj(e)})}length(t,e){return this._addCheck({kind:"length",value:t,...v.errToObj(e)})}nonempty(t){return this.min(1,v.errToObj(t))}trim(){return new lt({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new lt({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new lt({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(const e of this._def.checks)e.kind==="min"&&(t===null||e.value>t)&&(t=e.value);return t}get maxLength(){let t=null;for(const e of this._def.checks)e.kind==="max"&&(t===null||e.value<t)&&(t=e.value);return t}}lt.create=r=>new lt({checks:[],typeName:k.ZodString,coerce:(r==null?void 0:r.coerce)??!1,...S(r)});function gn(r,t){const e=(r.toString().split(".")[1]||"").length,o=(t.toString().split(".")[1]||"").length,a=e>o?e:o,i=Number.parseInt(r.toFixed(a).replace(".","")),n=Number.parseInt(t.toFixed(a).replace(".",""));return i%n/10**a}class Vt extends T{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==f.number){const a=this._getOrReturnCtx(t);return g(a,{code:p.invalid_type,expected:f.number,received:a.parsedType}),w}let e;const o=new B;for(const a of this._def.checks)a.kind==="int"?j.isInteger(t.data)||(e=this._getOrReturnCtx(t,e),g(e,{code:p.invalid_type,expected:"integer",received:"float",message:a.message}),o.dirty()):a.kind==="min"?(a.inclusive?t.data<a.value:t.data<=a.value)&&(e=this._getOrReturnCtx(t,e),g(e,{code:p.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),o.dirty()):a.kind==="max"?(a.inclusive?t.data>a.value:t.data>=a.value)&&(e=this._getOrReturnCtx(t,e),g(e,{code:p.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),o.dirty()):a.kind==="multipleOf"?gn(t.data,a.value)!==0&&(e=this._getOrReturnCtx(t,e),g(e,{code:p.not_multiple_of,multipleOf:a.value,message:a.message}),o.dirty()):a.kind==="finite"?Number.isFinite(t.data)||(e=this._getOrReturnCtx(t,e),g(e,{code:p.not_finite,message:a.message}),o.dirty()):j.assertNever(a);return{status:o.value,value:t.data}}gte(t,e){return this.setLimit("min",t,!0,v.toString(e))}gt(t,e){return this.setLimit("min",t,!1,v.toString(e))}lte(t,e){return this.setLimit("max",t,!0,v.toString(e))}lt(t,e){return this.setLimit("max",t,!1,v.toString(e))}setLimit(t,e,o,a){return new Vt({...this._def,checks:[...this._def.checks,{kind:t,value:e,inclusive:o,message:v.toString(a)}]})}_addCheck(t){return new Vt({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:v.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:v.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:v.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:v.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:v.toString(t)})}multipleOf(t,e){return this._addCheck({kind:"multipleOf",value:t,message:v.toString(e)})}finite(t){return this._addCheck({kind:"finite",message:v.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:v.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:v.toString(t)})}get minValue(){let t=null;for(const e of this._def.checks)e.kind==="min"&&(t===null||e.value>t)&&(t=e.value);return t}get maxValue(){let t=null;for(const e of this._def.checks)e.kind==="max"&&(t===null||e.value<t)&&(t=e.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&j.isInteger(t.value))}get isFinite(){let t=null,e=null;for(const o of this._def.checks){if(o.kind==="finite"||o.kind==="int"||o.kind==="multipleOf")return!0;o.kind==="min"?(e===null||o.value>e)&&(e=o.value):o.kind==="max"&&(t===null||o.value<t)&&(t=o.value)}return Number.isFinite(e)&&Number.isFinite(t)}}Vt.create=r=>new Vt({checks:[],typeName:k.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...S(r)});class ie extends T{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==f.bigint)return this._getInvalidInput(t);let e;const o=new B;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?t.data<a.value:t.data<=a.value)&&(e=this._getOrReturnCtx(t,e),g(e,{code:p.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),o.dirty()):a.kind==="max"?(a.inclusive?t.data>a.value:t.data>=a.value)&&(e=this._getOrReturnCtx(t,e),g(e,{code:p.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),o.dirty()):a.kind==="multipleOf"?t.data%a.value!==BigInt(0)&&(e=this._getOrReturnCtx(t,e),g(e,{code:p.not_multiple_of,multipleOf:a.value,message:a.message}),o.dirty()):j.assertNever(a);return{status:o.value,value:t.data}}_getInvalidInput(t){const e=this._getOrReturnCtx(t);return g(e,{code:p.invalid_type,expected:f.bigint,received:e.parsedType}),w}gte(t,e){return this.setLimit("min",t,!0,v.toString(e))}gt(t,e){return this.setLimit("min",t,!1,v.toString(e))}lte(t,e){return this.setLimit("max",t,!0,v.toString(e))}lt(t,e){return this.setLimit("max",t,!1,v.toString(e))}setLimit(t,e,o,a){return new ie({...this._def,checks:[...this._def.checks,{kind:t,value:e,inclusive:o,message:v.toString(a)}]})}_addCheck(t){return new ie({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:v.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:v.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:v.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:v.toString(t)})}multipleOf(t,e){return this._addCheck({kind:"multipleOf",value:t,message:v.toString(e)})}get minValue(){let t=null;for(const e of this._def.checks)e.kind==="min"&&(t===null||e.value>t)&&(t=e.value);return t}get maxValue(){let t=null;for(const e of this._def.checks)e.kind==="max"&&(t===null||e.value<t)&&(t=e.value);return t}}ie.create=r=>new ie({checks:[],typeName:k.ZodBigInt,coerce:(r==null?void 0:r.coerce)??!1,...S(r)});class so extends T{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==f.boolean){const e=this._getOrReturnCtx(t);return g(e,{code:p.invalid_type,expected:f.boolean,received:e.parsedType}),w}return F(t.data)}}so.create=r=>new so({typeName:k.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...S(r)});class ze extends T{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==f.date){const a=this._getOrReturnCtx(t);return g(a,{code:p.invalid_type,expected:f.date,received:a.parsedType}),w}if(Number.isNaN(t.data.getTime())){const a=this._getOrReturnCtx(t);return g(a,{code:p.invalid_date}),w}const e=new B;let o;for(const a of this._def.checks)a.kind==="min"?t.data.getTime()<a.value&&(o=this._getOrReturnCtx(t,o),g(o,{code:p.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),e.dirty()):a.kind==="max"?t.data.getTime()>a.value&&(o=this._getOrReturnCtx(t,o),g(o,{code:p.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),e.dirty()):j.assertNever(a);return{status:e.value,value:new Date(t.data.getTime())}}_addCheck(t){return new ze({...this._def,checks:[...this._def.checks,t]})}min(t,e){return this._addCheck({kind:"min",value:t.getTime(),message:v.toString(e)})}max(t,e){return this._addCheck({kind:"max",value:t.getTime(),message:v.toString(e)})}get minDate(){let t=null;for(const e of this._def.checks)e.kind==="min"&&(t===null||e.value>t)&&(t=e.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(const e of this._def.checks)e.kind==="max"&&(t===null||e.value<t)&&(t=e.value);return t!=null?new Date(t):null}}ze.create=r=>new ze({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:k.ZodDate,...S(r)});class lo extends T{_parse(t){if(this._getType(t)!==f.symbol){const e=this._getOrReturnCtx(t);return g(e,{code:p.invalid_type,expected:f.symbol,received:e.parsedType}),w}return F(t.data)}}lo.create=r=>new lo({typeName:k.ZodSymbol,...S(r)});class dr extends T{_parse(t){if(this._getType(t)!==f.undefined){const e=this._getOrReturnCtx(t);return g(e,{code:p.invalid_type,expected:f.undefined,received:e.parsedType}),w}return F(t.data)}}dr.create=r=>new dr({typeName:k.ZodUndefined,...S(r)});class lr extends T{_parse(t){if(this._getType(t)!==f.null){const e=this._getOrReturnCtx(t);return g(e,{code:p.invalid_type,expected:f.null,received:e.parsedType}),w}return F(t.data)}}lr.create=r=>new lr({typeName:k.ZodNull,...S(r)});class co extends T{constructor(){super(...arguments),this._any=!0}_parse(t){return F(t.data)}}co.create=r=>new co({typeName:k.ZodAny,...S(r)});class po extends T{constructor(){super(...arguments),this._unknown=!0}_parse(t){return F(t.data)}}po.create=r=>new po({typeName:k.ZodUnknown,...S(r)});class gt extends T{_parse(t){const e=this._getOrReturnCtx(t);return g(e,{code:p.invalid_type,expected:f.never,received:e.parsedType}),w}}gt.create=r=>new gt({typeName:k.ZodNever,...S(r)});class mo extends T{_parse(t){if(this._getType(t)!==f.undefined){const e=this._getOrReturnCtx(t);return g(e,{code:p.invalid_type,expected:f.void,received:e.parsedType}),w}return F(t.data)}}mo.create=r=>new mo({typeName:k.ZodVoid,...S(r)});class G extends T{_parse(t){const{ctx:e,status:o}=this._processInputParams(t),a=this._def;if(e.parsedType!==f.array)return g(e,{code:p.invalid_type,expected:f.array,received:e.parsedType}),w;if(a.exactLength!==null){const n=e.data.length>a.exactLength.value,s=e.data.length<a.exactLength.value;(n||s)&&(g(e,{code:n?p.too_big:p.too_small,minimum:s?a.exactLength.value:void 0,maximum:n?a.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:a.exactLength.message}),o.dirty())}if(a.minLength!==null&&e.data.length<a.minLength.value&&(g(e,{code:p.too_small,minimum:a.minLength.value,type:"array",inclusive:!0,exact:!1,message:a.minLength.message}),o.dirty()),a.maxLength!==null&&e.data.length>a.maxLength.value&&(g(e,{code:p.too_big,maximum:a.maxLength.value,type:"array",inclusive:!0,exact:!1,message:a.maxLength.message}),o.dirty()),e.common.async)return Promise.all([...e.data].map((n,s)=>a.type._parseAsync(new bt(e,n,e.path,s)))).then(n=>B.mergeArray(o,n));const i=[...e.data].map((n,s)=>a.type._parseSync(new bt(e,n,e.path,s)));return B.mergeArray(o,i)}get element(){return this._def.type}min(t,e){return new G({...this._def,minLength:{value:t,message:v.toString(e)}})}max(t,e){return new G({...this._def,maxLength:{value:t,message:v.toString(e)}})}length(t,e){return new G({...this._def,exactLength:{value:t,message:v.toString(e)}})}nonempty(t){return this.min(1,t)}}G.create=(r,t)=>new G({type:r,minLength:null,maxLength:null,exactLength:null,typeName:k.ZodArray,...S(t)});function It(r){if(r instanceof R){const t={};for(const e in r.shape){const o=r.shape[e];t[e]=tt.create(It(o))}return new R({...r._def,shape:()=>t})}else return r instanceof G?new G({...r._def,type:It(r.element)}):r instanceof tt?tt.create(It(r.unwrap())):r instanceof zt?zt.create(It(r.unwrap())):r instanceof St?St.create(r.items.map(t=>It(t))):r}class R extends T{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const t=this._def.shape(),e=j.objectKeys(t);return this._cached={shape:t,keys:e},this._cached}_parse(t){if(this._getType(t)!==f.object){const d=this._getOrReturnCtx(t);return g(d,{code:p.invalid_type,expected:f.object,received:d.parsedType}),w}const{status:e,ctx:o}=this._processInputParams(t),{shape:a,keys:i}=this._getCached(),n=[];if(!(this._def.catchall instanceof gt&&this._def.unknownKeys==="strip"))for(const d in o.data)i.includes(d)||n.push(d);const s=[];for(const d of i){const l=a[d],m=o.data[d];s.push({key:{status:"valid",value:d},value:l._parse(new bt(o,m,o.path,d)),alwaysSet:d in o.data})}if(this._def.catchall instanceof gt){const d=this._def.unknownKeys;if(d==="passthrough")for(const l of n)s.push({key:{status:"valid",value:l},value:{status:"valid",value:o.data[l]}});else if(d==="strict")n.length>0&&(g(o,{code:p.unrecognized_keys,keys:n}),e.dirty());else if(d!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const d=this._def.catchall;for(const l of n){const m=o.data[l];s.push({key:{status:"valid",value:l},value:d._parse(new bt(o,m,o.path,l)),alwaysSet:l in o.data})}}return o.common.async?Promise.resolve().then(async()=>{const d=[];for(const l of s){const m=await l.key,_=await l.value;d.push({key:m,value:_,alwaysSet:l.alwaysSet})}return d}).then(d=>B.mergeObjectSync(e,d)):B.mergeObjectSync(e,s)}get shape(){return this._def.shape()}strict(t){return v.errToObj,new R({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(e,o)=>{var a,i;const n=((i=(a=this._def).errorMap)==null?void 0:i.call(a,e,o).message)??o.defaultError;return e.code==="unrecognized_keys"?{message:v.errToObj(t).message??n}:{message:n}}}:{}})}strip(){return new R({...this._def,unknownKeys:"strip"})}passthrough(){return new R({...this._def,unknownKeys:"passthrough"})}extend(t){return new R({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new R({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:k.ZodObject})}setKey(t,e){return this.augment({[t]:e})}catchall(t){return new R({...this._def,catchall:t})}pick(t){const e={};for(const o of j.objectKeys(t))t[o]&&this.shape[o]&&(e[o]=this.shape[o]);return new R({...this._def,shape:()=>e})}omit(t){const e={};for(const o of j.objectKeys(this.shape))t[o]||(e[o]=this.shape[o]);return new R({...this._def,shape:()=>e})}deepPartial(){return It(this)}partial(t){const e={};for(const o of j.objectKeys(this.shape)){const a=this.shape[o];t&&!t[o]?e[o]=a:e[o]=a.optional()}return new R({...this._def,shape:()=>e})}required(t){const e={};for(const o of j.objectKeys(this.shape))if(t&&!t[o])e[o]=this.shape[o];else{let a=this.shape[o];for(;a instanceof tt;)a=a._def.innerType;e[o]=a}return new R({...this._def,shape:()=>e})}keyof(){return Vo(j.objectKeys(this.shape))}}R.create=(r,t)=>new R({shape:()=>r,unknownKeys:"strip",catchall:gt.create(),typeName:k.ZodObject,...S(t)});R.strictCreate=(r,t)=>new R({shape:()=>r,unknownKeys:"strict",catchall:gt.create(),typeName:k.ZodObject,...S(t)});R.lazycreate=(r,t)=>new R({shape:r,unknownKeys:"strip",catchall:gt.create(),typeName:k.ZodObject,...S(t)});class je extends T{_parse(t){const{ctx:e}=this._processInputParams(t),o=this._def.options;function a(i){for(const s of i)if(s.result.status==="valid")return s.result;for(const s of i)if(s.result.status==="dirty")return e.common.issues.push(...s.ctx.common.issues),s.result;const n=i.map(s=>new rt(s.ctx.common.issues));return g(e,{code:p.invalid_union,unionErrors:n}),w}if(e.common.async)return Promise.all(o.map(async i=>{const n={...e,common:{...e.common,issues:[]},parent:null};return{result:await i._parseAsync({data:e.data,path:e.path,parent:n}),ctx:n}})).then(a);{let i;const n=[];for(const d of o){const l={...e,common:{...e.common,issues:[]},parent:null},m=d._parseSync({data:e.data,path:e.path,parent:l});if(m.status==="valid")return m;m.status==="dirty"&&!i&&(i={result:m,ctx:l}),l.common.issues.length&&n.push(l.common.issues)}if(i)return e.common.issues.push(...i.ctx.common.issues),i.result;const s=n.map(d=>new rt(d));return g(e,{code:p.invalid_union,unionErrors:s}),w}}get options(){return this._def.options}}je.create=(r,t)=>new je({options:r,typeName:k.ZodUnion,...S(t)});const it=r=>r instanceof pr?it(r.schema):r instanceof Tt?it(r.innerType()):r instanceof Oe?[r.value]:r instanceof Et?r.options:r instanceof mr?j.objectValues(r.enum):r instanceof Ie?it(r._def.innerType):r instanceof dr?[void 0]:r instanceof lr?[null]:r instanceof tt?[void 0,...it(r.unwrap())]:r instanceof zt?[null,...it(r.unwrap())]:r instanceof Fo||r instanceof Ne?it(r.unwrap()):r instanceof Pe?it(r._def.innerType):[];class Er extends T{_parse(t){const{ctx:e}=this._processInputParams(t);if(e.parsedType!==f.object)return g(e,{code:p.invalid_type,expected:f.object,received:e.parsedType}),w;const o=this.discriminator,a=e.data[o],i=this.optionsMap.get(a);return i?e.common.async?i._parseAsync({data:e.data,path:e.path,parent:e}):i._parseSync({data:e.data,path:e.path,parent:e}):(g(e,{code:p.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[o]}),w)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,e,o){const a=new Map;for(const i of e){const n=it(i.shape[t]);if(!n.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(const s of n){if(a.has(s))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(s)}`);a.set(s,i)}}return new Er({typeName:k.ZodDiscriminatedUnion,discriminator:t,options:e,optionsMap:a,...S(o)})}}function cr(r,t){const e=st(r),o=st(t);if(r===t)return{valid:!0,data:r};if(e===f.object&&o===f.object){const a=j.objectKeys(t),i=j.objectKeys(r).filter(s=>a.indexOf(s)!==-1),n={...r,...t};for(const s of i){const d=cr(r[s],t[s]);if(!d.valid)return{valid:!1};n[s]=d.data}return{valid:!0,data:n}}else if(e===f.array&&o===f.array){if(r.length!==t.length)return{valid:!1};const a=[];for(let i=0;i<r.length;i++){const n=r[i],s=t[i],d=cr(n,s);if(!d.valid)return{valid:!1};a.push(d.data)}return{valid:!0,data:a}}else return e===f.date&&o===f.date&&+r==+t?{valid:!0,data:r}:{valid:!1}}class Ce extends T{_parse(t){const{status:e,ctx:o}=this._processInputParams(t),a=(i,n)=>{if(ao(i)||ao(n))return w;const s=cr(i.value,n.value);return s.valid?((io(i)||io(n))&&e.dirty(),{status:e.value,value:s.data}):(g(o,{code:p.invalid_intersection_types}),w)};return o.common.async?Promise.all([this._def.left._parseAsync({data:o.data,path:o.path,parent:o}),this._def.right._parseAsync({data:o.data,path:o.path,parent:o})]).then(([i,n])=>a(i,n)):a(this._def.left._parseSync({data:o.data,path:o.path,parent:o}),this._def.right._parseSync({data:o.data,path:o.path,parent:o}))}}Ce.create=(r,t,e)=>new Ce({left:r,right:t,typeName:k.ZodIntersection,...S(e)});class St extends T{_parse(t){const{status:e,ctx:o}=this._processInputParams(t);if(o.parsedType!==f.array)return g(o,{code:p.invalid_type,expected:f.array,received:o.parsedType}),w;if(o.data.length<this._def.items.length)return g(o,{code:p.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),w;!this._def.rest&&o.data.length>this._def.items.length&&(g(o,{code:p.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),e.dirty());const a=[...o.data].map((i,n)=>{const s=this._def.items[n]||this._def.rest;return s?s._parse(new bt(o,i,o.path,n)):null}).filter(i=>!!i);return o.common.async?Promise.all(a).then(i=>B.mergeArray(e,i)):B.mergeArray(e,a)}get items(){return this._def.items}rest(t){return new St({...this._def,rest:t})}}St.create=(r,t)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new St({items:r,typeName:k.ZodTuple,rest:null,...S(t)})};class bo extends T{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:e,ctx:o}=this._processInputParams(t);if(o.parsedType!==f.map)return g(o,{code:p.invalid_type,expected:f.map,received:o.parsedType}),w;const a=this._def.keyType,i=this._def.valueType,n=[...o.data.entries()].map(([s,d],l)=>({key:a._parse(new bt(o,s,o.path,[l,"key"])),value:i._parse(new bt(o,d,o.path,[l,"value"]))}));if(o.common.async){const s=new Map;return Promise.resolve().then(async()=>{for(const d of n){const l=await d.key,m=await d.value;if(l.status==="aborted"||m.status==="aborted")return w;(l.status==="dirty"||m.status==="dirty")&&e.dirty(),s.set(l.value,m.value)}return{status:e.value,value:s}})}else{const s=new Map;for(const d of n){const l=d.key,m=d.value;if(l.status==="aborted"||m.status==="aborted")return w;(l.status==="dirty"||m.status==="dirty")&&e.dirty(),s.set(l.value,m.value)}return{status:e.value,value:s}}}}bo.create=(r,t,e)=>new bo({valueType:t,keyType:r,typeName:k.ZodMap,...S(e)});class ne extends T{_parse(t){const{status:e,ctx:o}=this._processInputParams(t);if(o.parsedType!==f.set)return g(o,{code:p.invalid_type,expected:f.set,received:o.parsedType}),w;const a=this._def;a.minSize!==null&&o.data.size<a.minSize.value&&(g(o,{code:p.too_small,minimum:a.minSize.value,type:"set",inclusive:!0,exact:!1,message:a.minSize.message}),e.dirty()),a.maxSize!==null&&o.data.size>a.maxSize.value&&(g(o,{code:p.too_big,maximum:a.maxSize.value,type:"set",inclusive:!0,exact:!1,message:a.maxSize.message}),e.dirty());const i=this._def.valueType;function n(d){const l=new Set;for(const m of d){if(m.status==="aborted")return w;m.status==="dirty"&&e.dirty(),l.add(m.value)}return{status:e.value,value:l}}const s=[...o.data.values()].map((d,l)=>i._parse(new bt(o,d,o.path,l)));return o.common.async?Promise.all(s).then(d=>n(d)):n(s)}min(t,e){return new ne({...this._def,minSize:{value:t,message:v.toString(e)}})}max(t,e){return new ne({...this._def,maxSize:{value:t,message:v.toString(e)}})}size(t,e){return this.min(t,e).max(t,e)}nonempty(t){return this.min(1,t)}}ne.create=(r,t)=>new ne({valueType:r,minSize:null,maxSize:null,typeName:k.ZodSet,...S(t)});class pr extends T{get schema(){return this._def.getter()}_parse(t){const{ctx:e}=this._processInputParams(t);return this._def.getter()._parse({data:e.data,path:e.path,parent:e})}}pr.create=(r,t)=>new pr({getter:r,typeName:k.ZodLazy,...S(t)});class Oe extends T{_parse(t){if(t.data!==this._def.value){const e=this._getOrReturnCtx(t);return g(e,{received:e.data,code:p.invalid_literal,expected:this._def.value}),w}return{status:"valid",value:t.data}}get value(){return this._def.value}}Oe.create=(r,t)=>new Oe({value:r,typeName:k.ZodLiteral,...S(t)});function Vo(r,t){return new Et({values:r,typeName:k.ZodEnum,...S(t)})}class Et extends T{_parse(t){if(typeof t.data!="string"){const e=this._getOrReturnCtx(t),o=this._def.values;return g(e,{expected:j.joinValues(o),received:e.parsedType,code:p.invalid_type}),w}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){const e=this._getOrReturnCtx(t),o=this._def.values;return g(e,{received:e.data,code:p.invalid_enum_value,options:o}),w}return F(t.data)}get options(){return this._def.values}get enum(){const t={};for(const e of this._def.values)t[e]=e;return t}get Values(){const t={};for(const e of this._def.values)t[e]=e;return t}get Enum(){const t={};for(const e of this._def.values)t[e]=e;return t}extract(t,e=this._def){return Et.create(t,{...this._def,...e})}exclude(t,e=this._def){return Et.create(this.options.filter(o=>!t.includes(o)),{...this._def,...e})}}Et.create=Vo;class mr extends T{_parse(t){const e=j.getValidEnumValues(this._def.values),o=this._getOrReturnCtx(t);if(o.parsedType!==f.string&&o.parsedType!==f.number){const a=j.objectValues(e);return g(o,{expected:j.joinValues(a),received:o.parsedType,code:p.invalid_type}),w}if(this._cache||(this._cache=new Set(j.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){const a=j.objectValues(e);return g(o,{received:o.data,code:p.invalid_enum_value,options:a}),w}return F(t.data)}get enum(){return this._def.values}}mr.create=(r,t)=>new mr({values:r,typeName:k.ZodNativeEnum,...S(t)});class Re extends T{unwrap(){return this._def.type}_parse(t){const{ctx:e}=this._processInputParams(t);if(e.parsedType!==f.promise&&e.common.async===!1)return g(e,{code:p.invalid_type,expected:f.promise,received:e.parsedType}),w;const o=e.parsedType===f.promise?e.data:Promise.resolve(e.data);return F(o.then(a=>this._def.type.parseAsync(a,{path:e.path,errorMap:e.common.contextualErrorMap})))}}Re.create=(r,t)=>new Re({type:r,typeName:k.ZodPromise,...S(t)});class Tt extends T{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===k.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){const{status:e,ctx:o}=this._processInputParams(t),a=this._def.effect||null,i={addIssue:n=>{g(o,n),n.fatal?e.abort():e.dirty()},get path(){return o.path}};if(i.addIssue=i.addIssue.bind(i),a.type==="preprocess"){const n=a.transform(o.data,i);if(o.common.async)return Promise.resolve(n).then(async s=>{if(e.value==="aborted")return w;const d=await this._def.schema._parseAsync({data:s,path:o.path,parent:o});return d.status==="aborted"?w:d.status==="dirty"||e.value==="dirty"?sr(d.value):d});{if(e.value==="aborted")return w;const s=this._def.schema._parseSync({data:n,path:o.path,parent:o});return s.status==="aborted"?w:s.status==="dirty"||e.value==="dirty"?sr(s.value):s}}if(a.type==="refinement"){const n=s=>{const d=a.refinement(s,i);if(o.common.async)return Promise.resolve(d);if(d instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return s};if(o.common.async===!1){const s=this._def.schema._parseSync({data:o.data,path:o.path,parent:o});return s.status==="aborted"?w:(s.status==="dirty"&&e.dirty(),n(s.value),{status:e.value,value:s.value})}else return this._def.schema._parseAsync({data:o.data,path:o.path,parent:o}).then(s=>s.status==="aborted"?w:(s.status==="dirty"&&e.dirty(),n(s.value).then(()=>({status:e.value,value:s.value}))))}if(a.type==="transform")if(o.common.async===!1){const n=this._def.schema._parseSync({data:o.data,path:o.path,parent:o});if(!Dt(n))return w;const s=a.transform(n.value,i);if(s instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:e.value,value:s}}else return this._def.schema._parseAsync({data:o.data,path:o.path,parent:o}).then(n=>Dt(n)?Promise.resolve(a.transform(n.value,i)).then(s=>({status:e.value,value:s})):w);j.assertNever(a)}}Tt.create=(r,t,e)=>new Tt({schema:r,typeName:k.ZodEffects,effect:t,...S(e)});Tt.createWithPreprocess=(r,t,e)=>new Tt({schema:t,effect:{type:"preprocess",transform:r},typeName:k.ZodEffects,...S(e)});class tt extends T{_parse(t){return this._getType(t)===f.undefined?F(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}tt.create=(r,t)=>new tt({innerType:r,typeName:k.ZodOptional,...S(t)});class zt extends T{_parse(t){return this._getType(t)===f.null?F(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}zt.create=(r,t)=>new zt({innerType:r,typeName:k.ZodNullable,...S(t)});class Ie extends T{_parse(t){const{ctx:e}=this._processInputParams(t);let o=e.data;return e.parsedType===f.undefined&&(o=this._def.defaultValue()),this._def.innerType._parse({data:o,path:e.path,parent:e})}removeDefault(){return this._def.innerType}}Ie.create=(r,t)=>new Ie({innerType:r,typeName:k.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...S(t)});class Pe extends T{_parse(t){const{ctx:e}=this._processInputParams(t),o={...e,common:{...e.common,issues:[]}},a=this._def.innerType._parse({data:o.data,path:o.path,parent:{...o}});return Te(a)?a.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new rt(o.common.issues)},input:o.data})})):{status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new rt(o.common.issues)},input:o.data})}}removeCatch(){return this._def.innerType}}Pe.create=(r,t)=>new Pe({innerType:r,typeName:k.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...S(t)});class go extends T{_parse(t){if(this._getType(t)!==f.nan){const e=this._getOrReturnCtx(t);return g(e,{code:p.invalid_type,expected:f.nan,received:e.parsedType}),w}return{status:"valid",value:t.data}}}go.create=r=>new go({typeName:k.ZodNaN,...S(r)});class Fo extends T{_parse(t){const{ctx:e}=this._processInputParams(t),o=e.data;return this._def.type._parse({data:o,path:e.path,parent:e})}unwrap(){return this._def.type}}class Tr extends T{_parse(t){const{status:e,ctx:o}=this._processInputParams(t);if(o.common.async)return(async()=>{const a=await this._def.in._parseAsync({data:o.data,path:o.path,parent:o});return a.status==="aborted"?w:a.status==="dirty"?(e.dirty(),sr(a.value)):this._def.out._parseAsync({data:a.value,path:o.path,parent:o})})();{const a=this._def.in._parseSync({data:o.data,path:o.path,parent:o});return a.status==="aborted"?w:a.status==="dirty"?(e.dirty(),{status:"dirty",value:a.value}):this._def.out._parseSync({data:a.value,path:o.path,parent:o})}}static create(t,e){return new Tr({in:t,out:e,typeName:k.ZodPipeline})}}class Ne extends T{_parse(t){const e=this._def.innerType._parse(t),o=a=>(Dt(a)&&(a.value=Object.freeze(a.value)),a);return Te(e)?e.then(a=>o(a)):o(e)}unwrap(){return this._def.innerType}}Ne.create=(r,t)=>new Ne({innerType:r,typeName:k.ZodReadonly,...S(t)});var k;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(k||(k={}));const A=lt.create,un=Vt.create;gt.create;const fn=G.create,W=R.create;je.create;const Wo=Er.create;Ce.create;St.create;const yt=Oe.create;Et.create;Re.create;const Me=tt.create;zt.create;var Be=W({clientId:A(),clientSecret:A()}),hn=W({identityProviderId:A(),type:yt("password"),issuer:A(),configUrl:A(),audience:A(),tokenUrl:A(),grantType:A(),scope:A(),clientId:A(),admin:Me(Be)}),vn=W({identityProviderId:A(),type:yt("implicit"),issuer:A(),configUrl:A(),audience:A(),scope:A(),clientId:A(),admin:Me(Be)}),xn=W({identityProviderId:A(),type:yt("client_credentials"),issuer:A(),configUrl:A(),audience:A(),scope:A(),clientId:A(),clientSecret:A(),admin:Me(Be)}),yn=W({identityProviderId:A(),type:yt("self_signed"),issuer:A(),audience:A(),scope:A(),clientId:A(),clientSecret:A(),admin:Me(Be)}),wn=Wo("type",[hn,vn,xn,yn]),kn=W({baseUrl:A().url()}),qo=W({name:A(),chainId:A(),synchronizerId:A(),description:A(),ledgerApi:kn,auth:wn});W({connection:Wo("type",[W({type:yt("memory")}),W({type:yt("sqlite"),database:A()}),W({type:yt("postgres"),host:A(),port:un(),user:A(),password:A(),database:A()})]),networks:fn(qo)});var _n=Object.defineProperty,$n=Object.getOwnPropertyDescriptor,De=(r,t,e,o)=>{for(var a=o>1?void 0:o?$n(t,e):t,i=r.length-1,n;i>=0;i--)(n=r[i])&&(a=(o?n(t,e,a):n(a))||a);return o&&a&&_n(t,e,a),a};class An extends Event{constructor(){super("network-edit-cancel",{bubbles:!0,composed:!0})}}class Sn extends Event{constructor(t){super("network-edit-save",{bubbles:!0,composed:!0}),this.network=t}}let Ft=class extends L{constructor(){super(...arguments),this.network={ledgerApi:{},auth:{}},this.authType="implicit",this._error=""}connectedCallback(){super.connectedCallback(),this.network.auth.type&&(this.authType=this.network.auth.type)}onAuthTypeChange(r){const t=r.target;this.authType=t.value,this.updateAuthStructure()}updateAuthStructure(){var r;const t={...this.network};if(this.authType==="implicit"){const e=t.auth;t.auth={type:"implicit",identityProviderId:e.identityProviderId||"",configUrl:e.configUrl||"",clientId:e.clientId||"",issuer:e.issuer||"",audience:e.audience||"",scope:e.scope||"",admin:e.admin}}else if(this.authType==="password"){const e=t.auth;t.auth={type:"password",identityProviderId:e.identityProviderId||"",configUrl:e.configUrl||"",clientId:e.clientId||"",issuer:e.issuer||"",audience:e.audience||"",scope:e.scope||"",tokenUrl:e.tokenUrl||"",grantType:e.grantType||"",admin:(r=t.auth)==null?void 0:r.admin}}else if(this.authType==="self_signed"){const e=t.auth;t.auth={type:"self_signed",identityProviderId:e.identityProviderId||"",issuer:e.issuer||"",audience:e.audience||"",scope:e.scope||"",clientId:e.clientId||"",clientSecret:e.clientSecret||"",admin:e.admin}}this.network=t}handleSubmit(r){r.preventDefault();const t=qo.safeParse(this.network);if(t.success)this.dispatchEvent(new Sn(this.network));else{this._error="Invalid network data, please ensure all fields are set correctly",console.error("Error parsing network data: ",t.error);return}}setNetwork(r){return t=>{this.network[r]=t.value}}setLedgerApi(r){return t=>{this.network.ledgerApi||(this.network.ledgerApi={baseUrl:""}),this.network.ledgerApi[r]=t.value}}setAuth(r){return t=>{this.network.auth[r]=t.value}}setAuthConfigUrl(){return r=>{this.network.auth.type!=="self_signed"&&(this.network.auth.configUrl=r.value)}}setAdminAuth(r){return t=>{this.network.auth.admin&&(this.network.auth.admin[r]=t.value)}}setPasswordAuth(r){return t=>{this.network.auth.type==="password"&&(this.network.auth||(this.network.auth={type:"password",clientId:"",identityProviderId:"",issuer:"",configUrl:"",audience:"",tokenUrl:"",grantType:"",scope:""}),this.network.auth[r]=t.value)}}renderAuthForm(){var r,t;const e=C`
478
+ `];Sr([I({type:Object})],ae.prototype,"network",2);Sr([Le()],ae.prototype,"_editing",2);ae=Sr([ut("network-card")],ae);var j;(function(r){r.assertEqual=a=>{};function t(a){}r.assertIs=t;function e(a){throw new Error}r.assertNever=e,r.arrayToEnum=a=>{const i={};for(const n of a)i[n]=n;return i},r.getValidEnumValues=a=>{const i=r.objectKeys(a).filter(s=>typeof a[a[s]]!="number"),n={};for(const s of i)n[s]=a[s];return r.objectValues(n)},r.objectValues=a=>r.objectKeys(a).map(function(i){return a[i]}),r.objectKeys=typeof Object.keys=="function"?a=>Object.keys(a):a=>{const i=[];for(const n in a)Object.prototype.hasOwnProperty.call(a,n)&&i.push(n);return i},r.find=(a,i)=>{for(const n of a)if(i(n))return n},r.isInteger=typeof Number.isInteger=="function"?a=>Number.isInteger(a):a=>typeof a=="number"&&Number.isFinite(a)&&Math.floor(a)===a;function o(a,i=" | "){return a.map(n=>typeof n=="string"?`'${n}'`:n).join(i)}r.joinValues=o,r.jsonStringifyReplacer=(a,i)=>typeof i=="bigint"?i.toString():i})(j||(j={}));var oo;(function(r){r.mergeShapes=(t,e)=>({...t,...e})})(oo||(oo={}));const f=j.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),st=r=>{switch(typeof r){case"undefined":return f.undefined;case"string":return f.string;case"number":return Number.isNaN(r)?f.nan:f.number;case"boolean":return f.boolean;case"function":return f.function;case"bigint":return f.bigint;case"symbol":return f.symbol;case"object":return Array.isArray(r)?f.array:r===null?f.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?f.promise:typeof Map<"u"&&r instanceof Map?f.map:typeof Set<"u"&&r instanceof Set?f.set:typeof Date<"u"&&r instanceof Date?f.date:f.object;default:return f.unknown}},p=j.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class rt extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=o=>{this.issues=[...this.issues,o]},this.addIssues=(o=[])=>{this.issues=[...this.issues,...o]};const e=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,e):this.__proto__=e,this.name="ZodError",this.issues=t}format(t){const e=t||function(i){return i.message},o={_errors:[]},a=i=>{for(const n of i.issues)if(n.code==="invalid_union")n.unionErrors.map(a);else if(n.code==="invalid_return_type")a(n.returnTypeError);else if(n.code==="invalid_arguments")a(n.argumentsError);else if(n.path.length===0)o._errors.push(e(n));else{let s=o,d=0;for(;d<n.path.length;){const l=n.path[d];d===n.path.length-1?(s[l]=s[l]||{_errors:[]},s[l]._errors.push(e(n))):s[l]=s[l]||{_errors:[]},s=s[l],d++}}};return a(this),o}static assert(t){if(!(t instanceof rt))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,j.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=e=>e.message){const e={},o=[];for(const a of this.issues)if(a.path.length>0){const i=a.path[0];e[i]=e[i]||[],e[i].push(t(a))}else o.push(t(a));return{formErrors:o,fieldErrors:e}}get formErrors(){return this.flatten()}}rt.create=r=>new rt(r);const nr=(r,t)=>{let e;switch(r.code){case p.invalid_type:r.received===f.undefined?e="Required":e=`Expected ${r.expected}, received ${r.received}`;break;case p.invalid_literal:e=`Invalid literal value, expected ${JSON.stringify(r.expected,j.jsonStringifyReplacer)}`;break;case p.unrecognized_keys:e=`Unrecognized key(s) in object: ${j.joinValues(r.keys,", ")}`;break;case p.invalid_union:e="Invalid input";break;case p.invalid_union_discriminator:e=`Invalid discriminator value. Expected ${j.joinValues(r.options)}`;break;case p.invalid_enum_value:e=`Invalid enum value. Expected ${j.joinValues(r.options)}, received '${r.received}'`;break;case p.invalid_arguments:e="Invalid function arguments";break;case p.invalid_return_type:e="Invalid function return type";break;case p.invalid_date:e="Invalid date";break;case p.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(e=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(e=`${e} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?e=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?e=`Invalid input: must end with "${r.validation.endsWith}"`:j.assertNever(r.validation):r.validation!=="regex"?e=`Invalid ${r.validation}`:e="Invalid";break;case p.too_small:r.type==="array"?e=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?e=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?e=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="bigint"?e=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?e=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:e="Invalid input";break;case p.too_big:r.type==="array"?e=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?e=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?e=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?e=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?e=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:e="Invalid input";break;case p.custom:e="Invalid input";break;case p.invalid_intersection_types:e="Intersection results could not be merged";break;case p.not_multiple_of:e=`Number must be a multiple of ${r.multipleOf}`;break;case p.not_finite:e="Number must be finite";break;default:e=t.defaultError,j.assertNever(r)}return{message:e}};let Vi=nr;function Fi(){return Vi}const Wi=r=>{const{data:t,path:e,errorMaps:o,issueData:a}=r,i=[...e,...a.path||[]],n={...a,path:i};if(a.message!==void 0)return{...a,path:i,message:a.message};let s="";const d=o.filter(l=>!!l).slice().reverse();for(const l of d)s=l(n,{data:t,defaultError:s}).message;return{...a,path:i,message:s}};function g(r,t){const e=Fi(),o=Wi({issueData:t,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,e,e===nr?void 0:nr].filter(a=>!!a)});r.common.issues.push(o)}class B{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,e){const o=[];for(const a of e){if(a.status==="aborted")return w;a.status==="dirty"&&t.dirty(),o.push(a.value)}return{status:t.value,value:o}}static async mergeObjectAsync(t,e){const o=[];for(const a of e){const i=await a.key,n=await a.value;o.push({key:i,value:n})}return B.mergeObjectSync(t,o)}static mergeObjectSync(t,e){const o={};for(const a of e){const{key:i,value:n}=a;if(i.status==="aborted"||n.status==="aborted")return w;i.status==="dirty"&&t.dirty(),n.status==="dirty"&&t.dirty(),i.value!=="__proto__"&&(typeof n.value<"u"||a.alwaysSet)&&(o[i.value]=n.value)}return{status:t.value,value:o}}}const w=Object.freeze({status:"aborted"}),sr=r=>({status:"dirty",value:r}),F=r=>({status:"valid",value:r}),ao=r=>r.status==="aborted",io=r=>r.status==="dirty",Dt=r=>r.status==="valid",Te=r=>typeof Promise<"u"&&r instanceof Promise;var v;(function(r){r.errToObj=t=>typeof t=="string"?{message:t}:t||{},r.toString=t=>typeof t=="string"?t:t==null?void 0:t.message})(v||(v={}));class bt{constructor(t,e,o,a){this._cachedPath=[],this.parent=t,this.data=e,this._path=o,this._key=a}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const no=(r,t)=>{if(Dt(t))return{success:!0,data:t.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const e=new rt(r.common.issues);return this._error=e,this._error}}};function S(r){if(!r)return{};const{errorMap:t,invalid_type_error:e,required_error:o,description:a}=r;if(t&&(e||o))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:a}:{errorMap:(i,n)=>{const{message:s}=r;return i.code==="invalid_enum_value"?{message:s??n.defaultError}:typeof n.data>"u"?{message:s??o??n.defaultError}:i.code!=="invalid_type"?{message:n.defaultError}:{message:s??e??n.defaultError}},description:a}}class T{get description(){return this._def.description}_getType(t){return st(t.data)}_getOrReturnCtx(t,e){return e||{common:t.parent.common,data:t.data,parsedType:st(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new B,ctx:{common:t.parent.common,data:t.data,parsedType:st(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){const e=this._parse(t);if(Te(e))throw new Error("Synchronous parse encountered promise.");return e}_parseAsync(t){const e=this._parse(t);return Promise.resolve(e)}parse(t,e){const o=this.safeParse(t,e);if(o.success)return o.data;throw o.error}safeParse(t,e){const o={common:{issues:[],async:(e==null?void 0:e.async)??!1,contextualErrorMap:e==null?void 0:e.errorMap},path:(e==null?void 0:e.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:st(t)},a=this._parseSync({data:t,path:o.path,parent:o});return no(o,a)}"~validate"(t){var e,o;const a={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:st(t)};if(!this["~standard"].async)try{const i=this._parseSync({data:t,path:[],parent:a});return Dt(i)?{value:i.value}:{issues:a.common.issues}}catch(i){(o=(e=i==null?void 0:i.message)==null?void 0:e.toLowerCase())!=null&&o.includes("encountered")&&(this["~standard"].async=!0),a.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:a}).then(i=>Dt(i)?{value:i.value}:{issues:a.common.issues})}async parseAsync(t,e){const o=await this.safeParseAsync(t,e);if(o.success)return o.data;throw o.error}async safeParseAsync(t,e){const o={common:{issues:[],contextualErrorMap:e==null?void 0:e.errorMap,async:!0},path:(e==null?void 0:e.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:st(t)},a=this._parse({data:t,path:o.path,parent:o}),i=await(Te(a)?a:Promise.resolve(a));return no(o,i)}refine(t,e){const o=a=>typeof e=="string"||typeof e>"u"?{message:e}:typeof e=="function"?e(a):e;return this._refinement((a,i)=>{const n=t(a),s=()=>i.addIssue({code:p.custom,...o(a)});return typeof Promise<"u"&&n instanceof Promise?n.then(d=>d?!0:(s(),!1)):n?!0:(s(),!1)})}refinement(t,e){return this._refinement((o,a)=>t(o)?!0:(a.addIssue(typeof e=="function"?e(o,a):e),!1))}_refinement(t){return new Tt({schema:this,typeName:k.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:e=>this["~validate"](e)}}optional(){return tt.create(this,this._def)}nullable(){return zt.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return G.create(this)}promise(){return Re.create(this,this._def)}or(t){return je.create([this,t],this._def)}and(t){return Ce.create(this,t,this._def)}transform(t){return new Tt({...S(this._def),schema:this,typeName:k.ZodEffects,effect:{type:"transform",transform:t}})}default(t){const e=typeof t=="function"?t:()=>t;return new Ie({...S(this._def),innerType:this,defaultValue:e,typeName:k.ZodDefault})}brand(){return new Fo({typeName:k.ZodBranded,type:this,...S(this._def)})}catch(t){const e=typeof t=="function"?t:()=>t;return new Pe({...S(this._def),innerType:this,catchValue:e,typeName:k.ZodCatch})}describe(t){const e=this.constructor;return new e({...this._def,description:t})}pipe(t){return Tr.create(this,t)}readonly(){return Ne.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const qi=/^c[^\s-]{8,}$/i,Gi=/^[0-9a-z]+$/,Hi=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Ki=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Yi=/^[a-z0-9_-]{21}$/i,Ji=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Xi=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Qi=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,tn="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Ke;const en=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,rn=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,on=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,an=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,nn=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,sn=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Bo="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",dn=new RegExp(`^${Bo}$`);function Do(r){let t="[0-5]\\d";r.precision?t=`${t}\\.\\d{${r.precision}}`:r.precision==null&&(t=`${t}(\\.\\d+)?`);const e=r.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${e}`}function ln(r){return new RegExp(`^${Do(r)}$`)}function cn(r){let t=`${Bo}T${Do(r)}`;const e=[];return e.push(r.local?"Z?":"Z"),r.offset&&e.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${e.join("|")})`,new RegExp(`^${t}$`)}function pn(r,t){return!!((t==="v4"||!t)&&en.test(r)||(t==="v6"||!t)&&on.test(r))}function mn(r,t){if(!Ji.test(r))return!1;try{const[e]=r.split(".");if(!e)return!1;const o=e.replace(/-/g,"+").replace(/_/g,"/").padEnd(e.length+(4-e.length%4)%4,"="),a=JSON.parse(atob(o));return!(typeof a!="object"||a===null||"typ"in a&&(a==null?void 0:a.typ)!=="JWT"||!a.alg||t&&a.alg!==t)}catch{return!1}}function bn(r,t){return!!((t==="v4"||!t)&&rn.test(r)||(t==="v6"||!t)&&an.test(r))}class lt extends T{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==f.string){const a=this._getOrReturnCtx(t);return g(a,{code:p.invalid_type,expected:f.string,received:a.parsedType}),w}const e=new B;let o;for(const a of this._def.checks)if(a.kind==="min")t.data.length<a.value&&(o=this._getOrReturnCtx(t,o),g(o,{code:p.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),e.dirty());else if(a.kind==="max")t.data.length>a.value&&(o=this._getOrReturnCtx(t,o),g(o,{code:p.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),e.dirty());else if(a.kind==="length"){const i=t.data.length>a.value,n=t.data.length<a.value;(i||n)&&(o=this._getOrReturnCtx(t,o),i?g(o,{code:p.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):n&&g(o,{code:p.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),e.dirty())}else if(a.kind==="email")Qi.test(t.data)||(o=this._getOrReturnCtx(t,o),g(o,{validation:"email",code:p.invalid_string,message:a.message}),e.dirty());else if(a.kind==="emoji")Ke||(Ke=new RegExp(tn,"u")),Ke.test(t.data)||(o=this._getOrReturnCtx(t,o),g(o,{validation:"emoji",code:p.invalid_string,message:a.message}),e.dirty());else if(a.kind==="uuid")Ki.test(t.data)||(o=this._getOrReturnCtx(t,o),g(o,{validation:"uuid",code:p.invalid_string,message:a.message}),e.dirty());else if(a.kind==="nanoid")Yi.test(t.data)||(o=this._getOrReturnCtx(t,o),g(o,{validation:"nanoid",code:p.invalid_string,message:a.message}),e.dirty());else if(a.kind==="cuid")qi.test(t.data)||(o=this._getOrReturnCtx(t,o),g(o,{validation:"cuid",code:p.invalid_string,message:a.message}),e.dirty());else if(a.kind==="cuid2")Gi.test(t.data)||(o=this._getOrReturnCtx(t,o),g(o,{validation:"cuid2",code:p.invalid_string,message:a.message}),e.dirty());else if(a.kind==="ulid")Hi.test(t.data)||(o=this._getOrReturnCtx(t,o),g(o,{validation:"ulid",code:p.invalid_string,message:a.message}),e.dirty());else if(a.kind==="url")try{new URL(t.data)}catch{o=this._getOrReturnCtx(t,o),g(o,{validation:"url",code:p.invalid_string,message:a.message}),e.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(t.data)||(o=this._getOrReturnCtx(t,o),g(o,{validation:"regex",code:p.invalid_string,message:a.message}),e.dirty())):a.kind==="trim"?t.data=t.data.trim():a.kind==="includes"?t.data.includes(a.value,a.position)||(o=this._getOrReturnCtx(t,o),g(o,{code:p.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),e.dirty()):a.kind==="toLowerCase"?t.data=t.data.toLowerCase():a.kind==="toUpperCase"?t.data=t.data.toUpperCase():a.kind==="startsWith"?t.data.startsWith(a.value)||(o=this._getOrReturnCtx(t,o),g(o,{code:p.invalid_string,validation:{startsWith:a.value},message:a.message}),e.dirty()):a.kind==="endsWith"?t.data.endsWith(a.value)||(o=this._getOrReturnCtx(t,o),g(o,{code:p.invalid_string,validation:{endsWith:a.value},message:a.message}),e.dirty()):a.kind==="datetime"?cn(a).test(t.data)||(o=this._getOrReturnCtx(t,o),g(o,{code:p.invalid_string,validation:"datetime",message:a.message}),e.dirty()):a.kind==="date"?dn.test(t.data)||(o=this._getOrReturnCtx(t,o),g(o,{code:p.invalid_string,validation:"date",message:a.message}),e.dirty()):a.kind==="time"?ln(a).test(t.data)||(o=this._getOrReturnCtx(t,o),g(o,{code:p.invalid_string,validation:"time",message:a.message}),e.dirty()):a.kind==="duration"?Xi.test(t.data)||(o=this._getOrReturnCtx(t,o),g(o,{validation:"duration",code:p.invalid_string,message:a.message}),e.dirty()):a.kind==="ip"?pn(t.data,a.version)||(o=this._getOrReturnCtx(t,o),g(o,{validation:"ip",code:p.invalid_string,message:a.message}),e.dirty()):a.kind==="jwt"?mn(t.data,a.alg)||(o=this._getOrReturnCtx(t,o),g(o,{validation:"jwt",code:p.invalid_string,message:a.message}),e.dirty()):a.kind==="cidr"?bn(t.data,a.version)||(o=this._getOrReturnCtx(t,o),g(o,{validation:"cidr",code:p.invalid_string,message:a.message}),e.dirty()):a.kind==="base64"?nn.test(t.data)||(o=this._getOrReturnCtx(t,o),g(o,{validation:"base64",code:p.invalid_string,message:a.message}),e.dirty()):a.kind==="base64url"?sn.test(t.data)||(o=this._getOrReturnCtx(t,o),g(o,{validation:"base64url",code:p.invalid_string,message:a.message}),e.dirty()):j.assertNever(a);return{status:e.value,value:t.data}}_regex(t,e,o){return this.refinement(a=>t.test(a),{validation:e,code:p.invalid_string,...v.errToObj(o)})}_addCheck(t){return new lt({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...v.errToObj(t)})}url(t){return this._addCheck({kind:"url",...v.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...v.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...v.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...v.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...v.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...v.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...v.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...v.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...v.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...v.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...v.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...v.errToObj(t)})}datetime(t){return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,offset:(t==null?void 0:t.offset)??!1,local:(t==null?void 0:t.local)??!1,...v.errToObj(t==null?void 0:t.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,...v.errToObj(t==null?void 0:t.message)})}duration(t){return this._addCheck({kind:"duration",...v.errToObj(t)})}regex(t,e){return this._addCheck({kind:"regex",regex:t,...v.errToObj(e)})}includes(t,e){return this._addCheck({kind:"includes",value:t,position:e==null?void 0:e.position,...v.errToObj(e==null?void 0:e.message)})}startsWith(t,e){return this._addCheck({kind:"startsWith",value:t,...v.errToObj(e)})}endsWith(t,e){return this._addCheck({kind:"endsWith",value:t,...v.errToObj(e)})}min(t,e){return this._addCheck({kind:"min",value:t,...v.errToObj(e)})}max(t,e){return this._addCheck({kind:"max",value:t,...v.errToObj(e)})}length(t,e){return this._addCheck({kind:"length",value:t,...v.errToObj(e)})}nonempty(t){return this.min(1,v.errToObj(t))}trim(){return new lt({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new lt({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new lt({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(const e of this._def.checks)e.kind==="min"&&(t===null||e.value>t)&&(t=e.value);return t}get maxLength(){let t=null;for(const e of this._def.checks)e.kind==="max"&&(t===null||e.value<t)&&(t=e.value);return t}}lt.create=r=>new lt({checks:[],typeName:k.ZodString,coerce:(r==null?void 0:r.coerce)??!1,...S(r)});function gn(r,t){const e=(r.toString().split(".")[1]||"").length,o=(t.toString().split(".")[1]||"").length,a=e>o?e:o,i=Number.parseInt(r.toFixed(a).replace(".","")),n=Number.parseInt(t.toFixed(a).replace(".",""));return i%n/10**a}class Vt extends T{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==f.number){const a=this._getOrReturnCtx(t);return g(a,{code:p.invalid_type,expected:f.number,received:a.parsedType}),w}let e;const o=new B;for(const a of this._def.checks)a.kind==="int"?j.isInteger(t.data)||(e=this._getOrReturnCtx(t,e),g(e,{code:p.invalid_type,expected:"integer",received:"float",message:a.message}),o.dirty()):a.kind==="min"?(a.inclusive?t.data<a.value:t.data<=a.value)&&(e=this._getOrReturnCtx(t,e),g(e,{code:p.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),o.dirty()):a.kind==="max"?(a.inclusive?t.data>a.value:t.data>=a.value)&&(e=this._getOrReturnCtx(t,e),g(e,{code:p.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),o.dirty()):a.kind==="multipleOf"?gn(t.data,a.value)!==0&&(e=this._getOrReturnCtx(t,e),g(e,{code:p.not_multiple_of,multipleOf:a.value,message:a.message}),o.dirty()):a.kind==="finite"?Number.isFinite(t.data)||(e=this._getOrReturnCtx(t,e),g(e,{code:p.not_finite,message:a.message}),o.dirty()):j.assertNever(a);return{status:o.value,value:t.data}}gte(t,e){return this.setLimit("min",t,!0,v.toString(e))}gt(t,e){return this.setLimit("min",t,!1,v.toString(e))}lte(t,e){return this.setLimit("max",t,!0,v.toString(e))}lt(t,e){return this.setLimit("max",t,!1,v.toString(e))}setLimit(t,e,o,a){return new Vt({...this._def,checks:[...this._def.checks,{kind:t,value:e,inclusive:o,message:v.toString(a)}]})}_addCheck(t){return new Vt({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:v.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:v.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:v.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:v.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:v.toString(t)})}multipleOf(t,e){return this._addCheck({kind:"multipleOf",value:t,message:v.toString(e)})}finite(t){return this._addCheck({kind:"finite",message:v.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:v.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:v.toString(t)})}get minValue(){let t=null;for(const e of this._def.checks)e.kind==="min"&&(t===null||e.value>t)&&(t=e.value);return t}get maxValue(){let t=null;for(const e of this._def.checks)e.kind==="max"&&(t===null||e.value<t)&&(t=e.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&j.isInteger(t.value))}get isFinite(){let t=null,e=null;for(const o of this._def.checks){if(o.kind==="finite"||o.kind==="int"||o.kind==="multipleOf")return!0;o.kind==="min"?(e===null||o.value>e)&&(e=o.value):o.kind==="max"&&(t===null||o.value<t)&&(t=o.value)}return Number.isFinite(e)&&Number.isFinite(t)}}Vt.create=r=>new Vt({checks:[],typeName:k.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...S(r)});class ie extends T{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==f.bigint)return this._getInvalidInput(t);let e;const o=new B;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?t.data<a.value:t.data<=a.value)&&(e=this._getOrReturnCtx(t,e),g(e,{code:p.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),o.dirty()):a.kind==="max"?(a.inclusive?t.data>a.value:t.data>=a.value)&&(e=this._getOrReturnCtx(t,e),g(e,{code:p.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),o.dirty()):a.kind==="multipleOf"?t.data%a.value!==BigInt(0)&&(e=this._getOrReturnCtx(t,e),g(e,{code:p.not_multiple_of,multipleOf:a.value,message:a.message}),o.dirty()):j.assertNever(a);return{status:o.value,value:t.data}}_getInvalidInput(t){const e=this._getOrReturnCtx(t);return g(e,{code:p.invalid_type,expected:f.bigint,received:e.parsedType}),w}gte(t,e){return this.setLimit("min",t,!0,v.toString(e))}gt(t,e){return this.setLimit("min",t,!1,v.toString(e))}lte(t,e){return this.setLimit("max",t,!0,v.toString(e))}lt(t,e){return this.setLimit("max",t,!1,v.toString(e))}setLimit(t,e,o,a){return new ie({...this._def,checks:[...this._def.checks,{kind:t,value:e,inclusive:o,message:v.toString(a)}]})}_addCheck(t){return new ie({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:v.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:v.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:v.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:v.toString(t)})}multipleOf(t,e){return this._addCheck({kind:"multipleOf",value:t,message:v.toString(e)})}get minValue(){let t=null;for(const e of this._def.checks)e.kind==="min"&&(t===null||e.value>t)&&(t=e.value);return t}get maxValue(){let t=null;for(const e of this._def.checks)e.kind==="max"&&(t===null||e.value<t)&&(t=e.value);return t}}ie.create=r=>new ie({checks:[],typeName:k.ZodBigInt,coerce:(r==null?void 0:r.coerce)??!1,...S(r)});class so extends T{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==f.boolean){const e=this._getOrReturnCtx(t);return g(e,{code:p.invalid_type,expected:f.boolean,received:e.parsedType}),w}return F(t.data)}}so.create=r=>new so({typeName:k.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...S(r)});class ze extends T{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==f.date){const a=this._getOrReturnCtx(t);return g(a,{code:p.invalid_type,expected:f.date,received:a.parsedType}),w}if(Number.isNaN(t.data.getTime())){const a=this._getOrReturnCtx(t);return g(a,{code:p.invalid_date}),w}const e=new B;let o;for(const a of this._def.checks)a.kind==="min"?t.data.getTime()<a.value&&(o=this._getOrReturnCtx(t,o),g(o,{code:p.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),e.dirty()):a.kind==="max"?t.data.getTime()>a.value&&(o=this._getOrReturnCtx(t,o),g(o,{code:p.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),e.dirty()):j.assertNever(a);return{status:e.value,value:new Date(t.data.getTime())}}_addCheck(t){return new ze({...this._def,checks:[...this._def.checks,t]})}min(t,e){return this._addCheck({kind:"min",value:t.getTime(),message:v.toString(e)})}max(t,e){return this._addCheck({kind:"max",value:t.getTime(),message:v.toString(e)})}get minDate(){let t=null;for(const e of this._def.checks)e.kind==="min"&&(t===null||e.value>t)&&(t=e.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(const e of this._def.checks)e.kind==="max"&&(t===null||e.value<t)&&(t=e.value);return t!=null?new Date(t):null}}ze.create=r=>new ze({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:k.ZodDate,...S(r)});class lo extends T{_parse(t){if(this._getType(t)!==f.symbol){const e=this._getOrReturnCtx(t);return g(e,{code:p.invalid_type,expected:f.symbol,received:e.parsedType}),w}return F(t.data)}}lo.create=r=>new lo({typeName:k.ZodSymbol,...S(r)});class dr extends T{_parse(t){if(this._getType(t)!==f.undefined){const e=this._getOrReturnCtx(t);return g(e,{code:p.invalid_type,expected:f.undefined,received:e.parsedType}),w}return F(t.data)}}dr.create=r=>new dr({typeName:k.ZodUndefined,...S(r)});class lr extends T{_parse(t){if(this._getType(t)!==f.null){const e=this._getOrReturnCtx(t);return g(e,{code:p.invalid_type,expected:f.null,received:e.parsedType}),w}return F(t.data)}}lr.create=r=>new lr({typeName:k.ZodNull,...S(r)});class co extends T{constructor(){super(...arguments),this._any=!0}_parse(t){return F(t.data)}}co.create=r=>new co({typeName:k.ZodAny,...S(r)});class po extends T{constructor(){super(...arguments),this._unknown=!0}_parse(t){return F(t.data)}}po.create=r=>new po({typeName:k.ZodUnknown,...S(r)});class gt extends T{_parse(t){const e=this._getOrReturnCtx(t);return g(e,{code:p.invalid_type,expected:f.never,received:e.parsedType}),w}}gt.create=r=>new gt({typeName:k.ZodNever,...S(r)});class mo extends T{_parse(t){if(this._getType(t)!==f.undefined){const e=this._getOrReturnCtx(t);return g(e,{code:p.invalid_type,expected:f.void,received:e.parsedType}),w}return F(t.data)}}mo.create=r=>new mo({typeName:k.ZodVoid,...S(r)});class G extends T{_parse(t){const{ctx:e,status:o}=this._processInputParams(t),a=this._def;if(e.parsedType!==f.array)return g(e,{code:p.invalid_type,expected:f.array,received:e.parsedType}),w;if(a.exactLength!==null){const n=e.data.length>a.exactLength.value,s=e.data.length<a.exactLength.value;(n||s)&&(g(e,{code:n?p.too_big:p.too_small,minimum:s?a.exactLength.value:void 0,maximum:n?a.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:a.exactLength.message}),o.dirty())}if(a.minLength!==null&&e.data.length<a.minLength.value&&(g(e,{code:p.too_small,minimum:a.minLength.value,type:"array",inclusive:!0,exact:!1,message:a.minLength.message}),o.dirty()),a.maxLength!==null&&e.data.length>a.maxLength.value&&(g(e,{code:p.too_big,maximum:a.maxLength.value,type:"array",inclusive:!0,exact:!1,message:a.maxLength.message}),o.dirty()),e.common.async)return Promise.all([...e.data].map((n,s)=>a.type._parseAsync(new bt(e,n,e.path,s)))).then(n=>B.mergeArray(o,n));const i=[...e.data].map((n,s)=>a.type._parseSync(new bt(e,n,e.path,s)));return B.mergeArray(o,i)}get element(){return this._def.type}min(t,e){return new G({...this._def,minLength:{value:t,message:v.toString(e)}})}max(t,e){return new G({...this._def,maxLength:{value:t,message:v.toString(e)}})}length(t,e){return new G({...this._def,exactLength:{value:t,message:v.toString(e)}})}nonempty(t){return this.min(1,t)}}G.create=(r,t)=>new G({type:r,minLength:null,maxLength:null,exactLength:null,typeName:k.ZodArray,...S(t)});function It(r){if(r instanceof R){const t={};for(const e in r.shape){const o=r.shape[e];t[e]=tt.create(It(o))}return new R({...r._def,shape:()=>t})}else return r instanceof G?new G({...r._def,type:It(r.element)}):r instanceof tt?tt.create(It(r.unwrap())):r instanceof zt?zt.create(It(r.unwrap())):r instanceof St?St.create(r.items.map(t=>It(t))):r}class R extends T{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const t=this._def.shape(),e=j.objectKeys(t);return this._cached={shape:t,keys:e},this._cached}_parse(t){if(this._getType(t)!==f.object){const d=this._getOrReturnCtx(t);return g(d,{code:p.invalid_type,expected:f.object,received:d.parsedType}),w}const{status:e,ctx:o}=this._processInputParams(t),{shape:a,keys:i}=this._getCached(),n=[];if(!(this._def.catchall instanceof gt&&this._def.unknownKeys==="strip"))for(const d in o.data)i.includes(d)||n.push(d);const s=[];for(const d of i){const l=a[d],m=o.data[d];s.push({key:{status:"valid",value:d},value:l._parse(new bt(o,m,o.path,d)),alwaysSet:d in o.data})}if(this._def.catchall instanceof gt){const d=this._def.unknownKeys;if(d==="passthrough")for(const l of n)s.push({key:{status:"valid",value:l},value:{status:"valid",value:o.data[l]}});else if(d==="strict")n.length>0&&(g(o,{code:p.unrecognized_keys,keys:n}),e.dirty());else if(d!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const d=this._def.catchall;for(const l of n){const m=o.data[l];s.push({key:{status:"valid",value:l},value:d._parse(new bt(o,m,o.path,l)),alwaysSet:l in o.data})}}return o.common.async?Promise.resolve().then(async()=>{const d=[];for(const l of s){const m=await l.key,_=await l.value;d.push({key:m,value:_,alwaysSet:l.alwaysSet})}return d}).then(d=>B.mergeObjectSync(e,d)):B.mergeObjectSync(e,s)}get shape(){return this._def.shape()}strict(t){return v.errToObj,new R({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(e,o)=>{var a,i;const n=((i=(a=this._def).errorMap)==null?void 0:i.call(a,e,o).message)??o.defaultError;return e.code==="unrecognized_keys"?{message:v.errToObj(t).message??n}:{message:n}}}:{}})}strip(){return new R({...this._def,unknownKeys:"strip"})}passthrough(){return new R({...this._def,unknownKeys:"passthrough"})}extend(t){return new R({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new R({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:k.ZodObject})}setKey(t,e){return this.augment({[t]:e})}catchall(t){return new R({...this._def,catchall:t})}pick(t){const e={};for(const o of j.objectKeys(t))t[o]&&this.shape[o]&&(e[o]=this.shape[o]);return new R({...this._def,shape:()=>e})}omit(t){const e={};for(const o of j.objectKeys(this.shape))t[o]||(e[o]=this.shape[o]);return new R({...this._def,shape:()=>e})}deepPartial(){return It(this)}partial(t){const e={};for(const o of j.objectKeys(this.shape)){const a=this.shape[o];t&&!t[o]?e[o]=a:e[o]=a.optional()}return new R({...this._def,shape:()=>e})}required(t){const e={};for(const o of j.objectKeys(this.shape))if(t&&!t[o])e[o]=this.shape[o];else{let a=this.shape[o];for(;a instanceof tt;)a=a._def.innerType;e[o]=a}return new R({...this._def,shape:()=>e})}keyof(){return Vo(j.objectKeys(this.shape))}}R.create=(r,t)=>new R({shape:()=>r,unknownKeys:"strip",catchall:gt.create(),typeName:k.ZodObject,...S(t)});R.strictCreate=(r,t)=>new R({shape:()=>r,unknownKeys:"strict",catchall:gt.create(),typeName:k.ZodObject,...S(t)});R.lazycreate=(r,t)=>new R({shape:r,unknownKeys:"strip",catchall:gt.create(),typeName:k.ZodObject,...S(t)});class je extends T{_parse(t){const{ctx:e}=this._processInputParams(t),o=this._def.options;function a(i){for(const s of i)if(s.result.status==="valid")return s.result;for(const s of i)if(s.result.status==="dirty")return e.common.issues.push(...s.ctx.common.issues),s.result;const n=i.map(s=>new rt(s.ctx.common.issues));return g(e,{code:p.invalid_union,unionErrors:n}),w}if(e.common.async)return Promise.all(o.map(async i=>{const n={...e,common:{...e.common,issues:[]},parent:null};return{result:await i._parseAsync({data:e.data,path:e.path,parent:n}),ctx:n}})).then(a);{let i;const n=[];for(const d of o){const l={...e,common:{...e.common,issues:[]},parent:null},m=d._parseSync({data:e.data,path:e.path,parent:l});if(m.status==="valid")return m;m.status==="dirty"&&!i&&(i={result:m,ctx:l}),l.common.issues.length&&n.push(l.common.issues)}if(i)return e.common.issues.push(...i.ctx.common.issues),i.result;const s=n.map(d=>new rt(d));return g(e,{code:p.invalid_union,unionErrors:s}),w}}get options(){return this._def.options}}je.create=(r,t)=>new je({options:r,typeName:k.ZodUnion,...S(t)});const it=r=>r instanceof pr?it(r.schema):r instanceof Tt?it(r.innerType()):r instanceof Oe?[r.value]:r instanceof Et?r.options:r instanceof mr?j.objectValues(r.enum):r instanceof Ie?it(r._def.innerType):r instanceof dr?[void 0]:r instanceof lr?[null]:r instanceof tt?[void 0,...it(r.unwrap())]:r instanceof zt?[null,...it(r.unwrap())]:r instanceof Fo||r instanceof Ne?it(r.unwrap()):r instanceof Pe?it(r._def.innerType):[];class Er extends T{_parse(t){const{ctx:e}=this._processInputParams(t);if(e.parsedType!==f.object)return g(e,{code:p.invalid_type,expected:f.object,received:e.parsedType}),w;const o=this.discriminator,a=e.data[o],i=this.optionsMap.get(a);return i?e.common.async?i._parseAsync({data:e.data,path:e.path,parent:e}):i._parseSync({data:e.data,path:e.path,parent:e}):(g(e,{code:p.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[o]}),w)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,e,o){const a=new Map;for(const i of e){const n=it(i.shape[t]);if(!n.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(const s of n){if(a.has(s))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(s)}`);a.set(s,i)}}return new Er({typeName:k.ZodDiscriminatedUnion,discriminator:t,options:e,optionsMap:a,...S(o)})}}function cr(r,t){const e=st(r),o=st(t);if(r===t)return{valid:!0,data:r};if(e===f.object&&o===f.object){const a=j.objectKeys(t),i=j.objectKeys(r).filter(s=>a.indexOf(s)!==-1),n={...r,...t};for(const s of i){const d=cr(r[s],t[s]);if(!d.valid)return{valid:!1};n[s]=d.data}return{valid:!0,data:n}}else if(e===f.array&&o===f.array){if(r.length!==t.length)return{valid:!1};const a=[];for(let i=0;i<r.length;i++){const n=r[i],s=t[i],d=cr(n,s);if(!d.valid)return{valid:!1};a.push(d.data)}return{valid:!0,data:a}}else return e===f.date&&o===f.date&&+r==+t?{valid:!0,data:r}:{valid:!1}}class Ce extends T{_parse(t){const{status:e,ctx:o}=this._processInputParams(t),a=(i,n)=>{if(ao(i)||ao(n))return w;const s=cr(i.value,n.value);return s.valid?((io(i)||io(n))&&e.dirty(),{status:e.value,value:s.data}):(g(o,{code:p.invalid_intersection_types}),w)};return o.common.async?Promise.all([this._def.left._parseAsync({data:o.data,path:o.path,parent:o}),this._def.right._parseAsync({data:o.data,path:o.path,parent:o})]).then(([i,n])=>a(i,n)):a(this._def.left._parseSync({data:o.data,path:o.path,parent:o}),this._def.right._parseSync({data:o.data,path:o.path,parent:o}))}}Ce.create=(r,t,e)=>new Ce({left:r,right:t,typeName:k.ZodIntersection,...S(e)});class St extends T{_parse(t){const{status:e,ctx:o}=this._processInputParams(t);if(o.parsedType!==f.array)return g(o,{code:p.invalid_type,expected:f.array,received:o.parsedType}),w;if(o.data.length<this._def.items.length)return g(o,{code:p.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),w;!this._def.rest&&o.data.length>this._def.items.length&&(g(o,{code:p.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),e.dirty());const a=[...o.data].map((i,n)=>{const s=this._def.items[n]||this._def.rest;return s?s._parse(new bt(o,i,o.path,n)):null}).filter(i=>!!i);return o.common.async?Promise.all(a).then(i=>B.mergeArray(e,i)):B.mergeArray(e,a)}get items(){return this._def.items}rest(t){return new St({...this._def,rest:t})}}St.create=(r,t)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new St({items:r,typeName:k.ZodTuple,rest:null,...S(t)})};class bo extends T{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:e,ctx:o}=this._processInputParams(t);if(o.parsedType!==f.map)return g(o,{code:p.invalid_type,expected:f.map,received:o.parsedType}),w;const a=this._def.keyType,i=this._def.valueType,n=[...o.data.entries()].map(([s,d],l)=>({key:a._parse(new bt(o,s,o.path,[l,"key"])),value:i._parse(new bt(o,d,o.path,[l,"value"]))}));if(o.common.async){const s=new Map;return Promise.resolve().then(async()=>{for(const d of n){const l=await d.key,m=await d.value;if(l.status==="aborted"||m.status==="aborted")return w;(l.status==="dirty"||m.status==="dirty")&&e.dirty(),s.set(l.value,m.value)}return{status:e.value,value:s}})}else{const s=new Map;for(const d of n){const l=d.key,m=d.value;if(l.status==="aborted"||m.status==="aborted")return w;(l.status==="dirty"||m.status==="dirty")&&e.dirty(),s.set(l.value,m.value)}return{status:e.value,value:s}}}}bo.create=(r,t,e)=>new bo({valueType:t,keyType:r,typeName:k.ZodMap,...S(e)});class ne extends T{_parse(t){const{status:e,ctx:o}=this._processInputParams(t);if(o.parsedType!==f.set)return g(o,{code:p.invalid_type,expected:f.set,received:o.parsedType}),w;const a=this._def;a.minSize!==null&&o.data.size<a.minSize.value&&(g(o,{code:p.too_small,minimum:a.minSize.value,type:"set",inclusive:!0,exact:!1,message:a.minSize.message}),e.dirty()),a.maxSize!==null&&o.data.size>a.maxSize.value&&(g(o,{code:p.too_big,maximum:a.maxSize.value,type:"set",inclusive:!0,exact:!1,message:a.maxSize.message}),e.dirty());const i=this._def.valueType;function n(d){const l=new Set;for(const m of d){if(m.status==="aborted")return w;m.status==="dirty"&&e.dirty(),l.add(m.value)}return{status:e.value,value:l}}const s=[...o.data.values()].map((d,l)=>i._parse(new bt(o,d,o.path,l)));return o.common.async?Promise.all(s).then(d=>n(d)):n(s)}min(t,e){return new ne({...this._def,minSize:{value:t,message:v.toString(e)}})}max(t,e){return new ne({...this._def,maxSize:{value:t,message:v.toString(e)}})}size(t,e){return this.min(t,e).max(t,e)}nonempty(t){return this.min(1,t)}}ne.create=(r,t)=>new ne({valueType:r,minSize:null,maxSize:null,typeName:k.ZodSet,...S(t)});class pr extends T{get schema(){return this._def.getter()}_parse(t){const{ctx:e}=this._processInputParams(t);return this._def.getter()._parse({data:e.data,path:e.path,parent:e})}}pr.create=(r,t)=>new pr({getter:r,typeName:k.ZodLazy,...S(t)});class Oe extends T{_parse(t){if(t.data!==this._def.value){const e=this._getOrReturnCtx(t);return g(e,{received:e.data,code:p.invalid_literal,expected:this._def.value}),w}return{status:"valid",value:t.data}}get value(){return this._def.value}}Oe.create=(r,t)=>new Oe({value:r,typeName:k.ZodLiteral,...S(t)});function Vo(r,t){return new Et({values:r,typeName:k.ZodEnum,...S(t)})}class Et extends T{_parse(t){if(typeof t.data!="string"){const e=this._getOrReturnCtx(t),o=this._def.values;return g(e,{expected:j.joinValues(o),received:e.parsedType,code:p.invalid_type}),w}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){const e=this._getOrReturnCtx(t),o=this._def.values;return g(e,{received:e.data,code:p.invalid_enum_value,options:o}),w}return F(t.data)}get options(){return this._def.values}get enum(){const t={};for(const e of this._def.values)t[e]=e;return t}get Values(){const t={};for(const e of this._def.values)t[e]=e;return t}get Enum(){const t={};for(const e of this._def.values)t[e]=e;return t}extract(t,e=this._def){return Et.create(t,{...this._def,...e})}exclude(t,e=this._def){return Et.create(this.options.filter(o=>!t.includes(o)),{...this._def,...e})}}Et.create=Vo;class mr extends T{_parse(t){const e=j.getValidEnumValues(this._def.values),o=this._getOrReturnCtx(t);if(o.parsedType!==f.string&&o.parsedType!==f.number){const a=j.objectValues(e);return g(o,{expected:j.joinValues(a),received:o.parsedType,code:p.invalid_type}),w}if(this._cache||(this._cache=new Set(j.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){const a=j.objectValues(e);return g(o,{received:o.data,code:p.invalid_enum_value,options:a}),w}return F(t.data)}get enum(){return this._def.values}}mr.create=(r,t)=>new mr({values:r,typeName:k.ZodNativeEnum,...S(t)});class Re extends T{unwrap(){return this._def.type}_parse(t){const{ctx:e}=this._processInputParams(t);if(e.parsedType!==f.promise&&e.common.async===!1)return g(e,{code:p.invalid_type,expected:f.promise,received:e.parsedType}),w;const o=e.parsedType===f.promise?e.data:Promise.resolve(e.data);return F(o.then(a=>this._def.type.parseAsync(a,{path:e.path,errorMap:e.common.contextualErrorMap})))}}Re.create=(r,t)=>new Re({type:r,typeName:k.ZodPromise,...S(t)});class Tt extends T{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===k.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){const{status:e,ctx:o}=this._processInputParams(t),a=this._def.effect||null,i={addIssue:n=>{g(o,n),n.fatal?e.abort():e.dirty()},get path(){return o.path}};if(i.addIssue=i.addIssue.bind(i),a.type==="preprocess"){const n=a.transform(o.data,i);if(o.common.async)return Promise.resolve(n).then(async s=>{if(e.value==="aborted")return w;const d=await this._def.schema._parseAsync({data:s,path:o.path,parent:o});return d.status==="aborted"?w:d.status==="dirty"||e.value==="dirty"?sr(d.value):d});{if(e.value==="aborted")return w;const s=this._def.schema._parseSync({data:n,path:o.path,parent:o});return s.status==="aborted"?w:s.status==="dirty"||e.value==="dirty"?sr(s.value):s}}if(a.type==="refinement"){const n=s=>{const d=a.refinement(s,i);if(o.common.async)return Promise.resolve(d);if(d instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return s};if(o.common.async===!1){const s=this._def.schema._parseSync({data:o.data,path:o.path,parent:o});return s.status==="aborted"?w:(s.status==="dirty"&&e.dirty(),n(s.value),{status:e.value,value:s.value})}else return this._def.schema._parseAsync({data:o.data,path:o.path,parent:o}).then(s=>s.status==="aborted"?w:(s.status==="dirty"&&e.dirty(),n(s.value).then(()=>({status:e.value,value:s.value}))))}if(a.type==="transform")if(o.common.async===!1){const n=this._def.schema._parseSync({data:o.data,path:o.path,parent:o});if(!Dt(n))return w;const s=a.transform(n.value,i);if(s instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:e.value,value:s}}else return this._def.schema._parseAsync({data:o.data,path:o.path,parent:o}).then(n=>Dt(n)?Promise.resolve(a.transform(n.value,i)).then(s=>({status:e.value,value:s})):w);j.assertNever(a)}}Tt.create=(r,t,e)=>new Tt({schema:r,typeName:k.ZodEffects,effect:t,...S(e)});Tt.createWithPreprocess=(r,t,e)=>new Tt({schema:t,effect:{type:"preprocess",transform:r},typeName:k.ZodEffects,...S(e)});class tt extends T{_parse(t){return this._getType(t)===f.undefined?F(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}tt.create=(r,t)=>new tt({innerType:r,typeName:k.ZodOptional,...S(t)});class zt extends T{_parse(t){return this._getType(t)===f.null?F(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}zt.create=(r,t)=>new zt({innerType:r,typeName:k.ZodNullable,...S(t)});class Ie extends T{_parse(t){const{ctx:e}=this._processInputParams(t);let o=e.data;return e.parsedType===f.undefined&&(o=this._def.defaultValue()),this._def.innerType._parse({data:o,path:e.path,parent:e})}removeDefault(){return this._def.innerType}}Ie.create=(r,t)=>new Ie({innerType:r,typeName:k.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...S(t)});class Pe extends T{_parse(t){const{ctx:e}=this._processInputParams(t),o={...e,common:{...e.common,issues:[]}},a=this._def.innerType._parse({data:o.data,path:o.path,parent:{...o}});return Te(a)?a.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new rt(o.common.issues)},input:o.data})})):{status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new rt(o.common.issues)},input:o.data})}}removeCatch(){return this._def.innerType}}Pe.create=(r,t)=>new Pe({innerType:r,typeName:k.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...S(t)});class go extends T{_parse(t){if(this._getType(t)!==f.nan){const e=this._getOrReturnCtx(t);return g(e,{code:p.invalid_type,expected:f.nan,received:e.parsedType}),w}return{status:"valid",value:t.data}}}go.create=r=>new go({typeName:k.ZodNaN,...S(r)});class Fo extends T{_parse(t){const{ctx:e}=this._processInputParams(t),o=e.data;return this._def.type._parse({data:o,path:e.path,parent:e})}unwrap(){return this._def.type}}class Tr extends T{_parse(t){const{status:e,ctx:o}=this._processInputParams(t);if(o.common.async)return(async()=>{const a=await this._def.in._parseAsync({data:o.data,path:o.path,parent:o});return a.status==="aborted"?w:a.status==="dirty"?(e.dirty(),sr(a.value)):this._def.out._parseAsync({data:a.value,path:o.path,parent:o})})();{const a=this._def.in._parseSync({data:o.data,path:o.path,parent:o});return a.status==="aborted"?w:a.status==="dirty"?(e.dirty(),{status:"dirty",value:a.value}):this._def.out._parseSync({data:a.value,path:o.path,parent:o})}}static create(t,e){return new Tr({in:t,out:e,typeName:k.ZodPipeline})}}class Ne extends T{_parse(t){const e=this._def.innerType._parse(t),o=a=>(Dt(a)&&(a.value=Object.freeze(a.value)),a);return Te(e)?e.then(a=>o(a)):o(e)}unwrap(){return this._def.innerType}}Ne.create=(r,t)=>new Ne({innerType:r,typeName:k.ZodReadonly,...S(t)});var k;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(k||(k={}));const A=lt.create,un=Vt.create;gt.create;const fn=G.create,W=R.create;je.create;const Wo=Er.create;Ce.create;St.create;const yt=Oe.create;Et.create;Re.create;const Me=tt.create;zt.create;var Be=W({clientId:A(),clientSecret:A()}),hn=W({identityProviderId:A(),type:yt("password"),issuer:A(),configUrl:A(),audience:A(),tokenUrl:A(),grantType:A(),scope:A(),clientId:A(),admin:Me(Be)}),vn=W({identityProviderId:A(),type:yt("implicit"),issuer:A(),configUrl:A(),audience:A(),scope:A(),clientId:A(),admin:Me(Be)}),xn=W({identityProviderId:A(),type:yt("client_credentials"),issuer:A(),configUrl:A(),audience:A(),scope:A(),clientId:A(),clientSecret:A(),admin:Me(Be)}),yn=W({identityProviderId:A(),type:yt("self_signed"),issuer:A(),audience:A(),scope:A(),clientId:A(),clientSecret:A(),admin:Me(Be)}),wn=Wo("type",[hn,vn,xn,yn]),kn=W({baseUrl:A().url()}),qo=W({id:A(),name:A(),synchronizerId:A(),description:A(),ledgerApi:kn,auth:wn});W({connection:Wo("type",[W({type:yt("memory")}),W({type:yt("sqlite"),database:A()}),W({type:yt("postgres"),host:A(),port:un(),user:A(),password:A(),database:A()})]),networks:fn(qo)});var _n=Object.defineProperty,$n=Object.getOwnPropertyDescriptor,De=(r,t,e,o)=>{for(var a=o>1?void 0:o?$n(t,e):t,i=r.length-1,n;i>=0;i--)(n=r[i])&&(a=(o?n(t,e,a):n(a))||a);return o&&a&&_n(t,e,a),a};class An extends Event{constructor(){super("network-edit-cancel",{bubbles:!0,composed:!0})}}class Sn extends Event{constructor(t){super("network-edit-save",{bubbles:!0,composed:!0}),this.network=t}}let Ft=class extends L{constructor(){super(...arguments),this.network={ledgerApi:{},auth:{}},this.authType="implicit",this._error=""}connectedCallback(){super.connectedCallback(),this.network.auth.type&&(this.authType=this.network.auth.type)}onAuthTypeChange(r){const t=r.target;this.authType=t.value,this.updateAuthStructure()}updateAuthStructure(){var r;const t={...this.network};if(this.authType==="implicit"){const e=t.auth;t.auth={type:"implicit",identityProviderId:e.identityProviderId||"",configUrl:e.configUrl||"",clientId:e.clientId||"",issuer:e.issuer||"",audience:e.audience||"",scope:e.scope||"",admin:e.admin}}else if(this.authType==="password"){const e=t.auth;t.auth={type:"password",identityProviderId:e.identityProviderId||"",configUrl:e.configUrl||"",clientId:e.clientId||"",issuer:e.issuer||"",audience:e.audience||"",scope:e.scope||"",tokenUrl:e.tokenUrl||"",grantType:e.grantType||"",admin:(r=t.auth)==null?void 0:r.admin}}else if(this.authType==="self_signed"){const e=t.auth;t.auth={type:"self_signed",identityProviderId:e.identityProviderId||"",issuer:e.issuer||"",audience:e.audience||"",scope:e.scope||"",clientId:e.clientId||"",clientSecret:e.clientSecret||"",admin:e.admin}}this.network=t}handleSubmit(r){r.preventDefault();const t=qo.safeParse(this.network);if(t.success)this.dispatchEvent(new Sn(this.network));else{this._error="Invalid network data, please ensure all fields are set correctly",console.error("Error parsing network data: ",t.error);return}}setNetwork(r){return t=>{this.network[r]=t.value}}setLedgerApi(r){return t=>{this.network.ledgerApi||(this.network.ledgerApi={baseUrl:""}),this.network.ledgerApi[r]=t.value}}setAuth(r){return t=>{this.network.auth[r]=t.value}}setAuthConfigUrl(){return r=>{this.network.auth.type!=="self_signed"&&(this.network.auth.configUrl=r.value)}}setAdminAuth(r){return t=>{this.network.auth.admin&&(this.network.auth.admin[r]=t.value)}}setPasswordAuth(r){return t=>{this.network.auth.type==="password"&&(this.network.auth||(this.network.auth={type:"password",clientId:"",identityProviderId:"",issuer:"",configUrl:"",audience:"",tokenUrl:"",grantType:"",scope:""}),this.network.auth[r]=t.value)}}renderAuthForm(){var r,t;const e=C`
479
479
  <network-form-input
480
480
  required
481
481
  label="Identity Provider ID"
@@ -558,8 +558,8 @@
558
558
  <network-form-input
559
559
  required
560
560
  label="Network Id"
561
- .value=${this.network.chainId??""}
562
- @network-input-change=${this.setNetwork("chainId")}
561
+ .value=${this.network.id??""}
562
+ @network-input-change=${this.setNetwork("id")}
563
563
  ></network-form-input>
564
564
 
565
565
  <network-form-input
@@ -707,4 +707,4 @@
707
707
  h3 {
708
708
  margin: 20px 0 30px;
709
709
  }
710
- `];br=On([ut("not-found")],br);class Xt{constructor(){this.state=new Map,this.accessToken={get:()=>this.getWithStorage("accessToken"),set:t=>this.setWithStorage("accessToken",t),clear:()=>this.clearWithStorage("accessToken")},this.chainId={get:()=>this.getWithStorage("chainId"),set:t=>this.setWithStorage("chainId",t),clear:()=>this.clearWithStorage("chainId")},this.expirationDate={get:()=>this.getWithStorage("expirationDate"),set:t=>this.setWithStorage("expirationDate",t),clear:()=>this.clearWithStorage("expirationDate")}}static localStorageKey(t){return`com.splice.wallet.${t}`}getWithStorage(t){if(this.state.has(t))return this.state.get(t);const e=localStorage.getItem(Xt.localStorageKey(t));if(e)return this.state.set(t,e),e}setWithStorage(t,e){localStorage.setItem(Xt.localStorageKey(t),e),this.state.set(t,e)}clearWithStorage(t){localStorage.removeItem(Xt.localStorageKey(t)),this.state.delete(t)}}const Pt=new Xt;var Rn=Object.create,zr=Object.defineProperty,In=Object.getOwnPropertyDescriptor,Go=(r,t)=>(t=Symbol[r])?t:Symbol.for("Symbol."+r),Ho=r=>{throw TypeError(r)},Pn=(r,t,e)=>t in r?zr(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Nn=(r,t)=>zr(r,"name",{value:t,configurable:!0}),Ko=r=>[,,,Rn((r==null?void 0:r[Go("metadata")])??null)],Zn=["class","method","getter","setter","accessor","field","value","get","set"],Yo=r=>r!==void 0&&typeof r!="function"?Ho("Function expected"):r,Ln=(r,t,e,o,a)=>({kind:Zn[r],name:t,metadata:o,addInitializer:i=>e._?Ho("Already initialized"):a.push(Yo(i||null))}),Un=(r,t)=>Pn(t,Go("metadata"),r[3]),Jo=(r,t,e,o)=>{for(var a=0,i=r[t>>1],n=i&&i.length;a<n;a++)i[a].call(e);return o},Xo=(r,t,e,o,a,i)=>{var n,s,d,l=t&7,m=!1,_=0,P=r[_]||(r[_]=[]),D=l&&(a=a.prototype,l<5&&(l>3||!m)&&In(a,e));Nn(a,e);for(var at=o.length-1;at>=0;at--)d=Ln(l,e,s={},r[3],P),n=(0,o[at])(a,d),s._=1,Yo(n)&&(a=n);return Un(r,a),D&&zr(a,e,D),m?l^4?i:D:a},Qo,jr,ta,ea,Cr,ra;const oa="/wallets",Mn="/404",de="/login",Bn=["/wallets","/networks","/approve","/"];Qo=[_o("user-ui")];class gr extends(ta=xt){connectedCallback(){super.connectedCallback(),Bn.includes(window.location.pathname)?window.location.href=oa:window.location.href=Mn}}jr=Ko(ta);gr=Xo(jr,0,"UserUI",Qo,gr);Jo(jr,1,gr);ea=[_o("user-ui-auth-redirect")];class ur extends(ra=xt){connectedCallback(){super.connectedCallback();const t=window.location.pathname.startsWith(de),e=new Date(Pt.expirationDate.get()||""),o=new Date;e>o?setTimeout(()=>{localStorage.clear(),window.location.href=de},e.getTime()-o.getTime()):Pt.accessToken.get()&&(localStorage.clear(),window.location.href=de),!Pt.accessToken.get()&&!t&&(window.location.href=de);const a=Pt.accessToken.get();if(a&&t){const i=Pt.chainId.get();if(!i)throw new Error("missing chainId in state manager");Dn(a,i),window.location.href=oa}}}Cr=Ko(ra);ur=Xo(Cr,0,"UserUIAuthRedirect",ea,ur);Jo(Cr,1,ur);const Dn=async(r,t)=>{await gi(r).request("addSession",{chainId:t}),window.opener&&!window.opener.closed&&window.opener.postMessage({type:Io.SPLICE_WALLET_IDP_AUTH_SUCCESS,token:Pt.accessToken.get()},"*")};export{ii as E,Io as W,jt as a,Dn as b,gi as c,K as d,se as e,jo as f,fo as g,xt as i,J as l,M as o,Pt as s,_o as t,Ye as u,C as x};
710
+ `];br=On([ut("not-found")],br);class Xt{constructor(){this.state=new Map,this.accessToken={get:()=>this.getWithStorage("accessToken"),set:t=>this.setWithStorage("accessToken",t),clear:()=>this.clearWithStorage("accessToken")},this.networkId={get:()=>this.getWithStorage("networkId"),set:t=>this.setWithStorage("networkId",t),clear:()=>this.clearWithStorage("networkId")},this.expirationDate={get:()=>this.getWithStorage("expirationDate"),set:t=>this.setWithStorage("expirationDate",t),clear:()=>this.clearWithStorage("expirationDate")}}static localStorageKey(t){return`com.splice.wallet.${t}`}getWithStorage(t){if(this.state.has(t))return this.state.get(t);const e=localStorage.getItem(Xt.localStorageKey(t));if(e)return this.state.set(t,e),e}setWithStorage(t,e){localStorage.setItem(Xt.localStorageKey(t),e),this.state.set(t,e)}clearWithStorage(t){localStorage.removeItem(Xt.localStorageKey(t)),this.state.delete(t)}}const Pt=new Xt;var Rn=Object.create,zr=Object.defineProperty,In=Object.getOwnPropertyDescriptor,Go=(r,t)=>(t=Symbol[r])?t:Symbol.for("Symbol."+r),Ho=r=>{throw TypeError(r)},Pn=(r,t,e)=>t in r?zr(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Nn=(r,t)=>zr(r,"name",{value:t,configurable:!0}),Ko=r=>[,,,Rn((r==null?void 0:r[Go("metadata")])??null)],Zn=["class","method","getter","setter","accessor","field","value","get","set"],Yo=r=>r!==void 0&&typeof r!="function"?Ho("Function expected"):r,Ln=(r,t,e,o,a)=>({kind:Zn[r],name:t,metadata:o,addInitializer:i=>e._?Ho("Already initialized"):a.push(Yo(i||null))}),Un=(r,t)=>Pn(t,Go("metadata"),r[3]),Jo=(r,t,e,o)=>{for(var a=0,i=r[t>>1],n=i&&i.length;a<n;a++)i[a].call(e);return o},Xo=(r,t,e,o,a,i)=>{var n,s,d,l=t&7,m=!1,_=0,P=r[_]||(r[_]=[]),D=l&&(a=a.prototype,l<5&&(l>3||!m)&&In(a,e));Nn(a,e);for(var at=o.length-1;at>=0;at--)d=Ln(l,e,s={},r[3],P),n=(0,o[at])(a,d),s._=1,Yo(n)&&(a=n);return Un(r,a),D&&zr(a,e,D),m?l^4?i:D:a},Qo,jr,ta,ea,Cr,ra;const oa="/wallets",Mn="/404",de="/login",Bn=["/wallets","/networks","/approve","/"];Qo=[_o("user-ui")];class gr extends(ta=xt){connectedCallback(){super.connectedCallback(),Bn.includes(window.location.pathname)?window.location.href=oa:window.location.href=Mn}}jr=Ko(ta);gr=Xo(jr,0,"UserUI",Qo,gr);Jo(jr,1,gr);ea=[_o("user-ui-auth-redirect")];class ur extends(ra=xt){connectedCallback(){super.connectedCallback();const t=window.location.pathname.startsWith(de),e=new Date(Pt.expirationDate.get()||""),o=new Date;e>o?setTimeout(()=>{localStorage.clear(),window.location.href=de},e.getTime()-o.getTime()):Pt.accessToken.get()&&(localStorage.clear(),window.location.href=de),!Pt.accessToken.get()&&!t&&(window.location.href=de);const a=Pt.accessToken.get();if(a&&t){const i=Pt.networkId.get();if(!i)throw new Error("missing networkId in state manager");Dn(a,i),window.location.href=oa}}}Cr=Ko(ra);ur=Xo(Cr,0,"UserUIAuthRedirect",ea,ur);Jo(Cr,1,ur);const Dn=async(r,t)=>{await gi(r).request("addSession",{networkId:t}),window.opener&&!window.opener.closed&&window.opener.postMessage({type:Io.SPLICE_WALLET_IDP_AUTH_SUCCESS,token:Pt.accessToken.get()},"*")};export{ii as E,Io as W,jt as a,Dn as b,gi as c,K as d,se as e,jo as f,fo as g,xt as i,J as l,M as o,Pt as s,_o as t,Ye as u,C as x};
@@ -1,4 +1,4 @@
1
- import{o as J,d as c,e as L,l as k,f as He,c as ue,s as P,W as De,x as H,a as $e,i as Ue,t as Me}from"./index-YpAHEASq.js";import{r as D}from"./state-BTqOtYLt.js";const te=crypto,ye=t=>t instanceof CryptoKey,R=new TextEncoder,X=new TextDecoder;function Le(...t){const e=t.reduce((n,{length:o})=>n+o,0),r=new Uint8Array(e);let s=0;for(const n of t)r.set(n,s),s+=n.length;return r}const ke=t=>{let e=t;typeof e=="string"&&(e=R.encode(e));const r=32768,s=[];for(let n=0;n<e.length;n+=r)s.push(String.fromCharCode.apply(null,e.subarray(n,n+r)));return btoa(s.join(""))},B=t=>ke(t).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_"),ze=t=>{const e=atob(t),r=new Uint8Array(e.length);for(let s=0;s<e.length;s++)r[s]=e.charCodeAt(s);return r},re=t=>{let e=t;e instanceof Uint8Array&&(e=X.decode(e)),e=e.replace(/-/g,"+").replace(/_/g,"/").replace(/\s/g,"");try{return ze(e)}catch{throw new TypeError("The input to be decoded is not correctly encoded.")}};class h extends Error{constructor(e,r){var s;super(e,r),this.code="ERR_JOSE_GENERIC",this.name=this.constructor.name,(s=Error.captureStackTrace)==null||s.call(Error,this,this.constructor)}}h.code="ERR_JOSE_GENERIC";class Fe extends h{constructor(e,r,s="unspecified",n="unspecified"){super(e,{cause:{claim:s,reason:n,payload:r}}),this.code="ERR_JWT_CLAIM_VALIDATION_FAILED",this.claim=s,this.reason=n,this.payload=r}}Fe.code="ERR_JWT_CLAIM_VALIDATION_FAILED";class Ve extends h{constructor(e,r,s="unspecified",n="unspecified"){super(e,{cause:{claim:s,reason:n,payload:r}}),this.code="ERR_JWT_EXPIRED",this.claim=s,this.reason=n,this.payload=r}}Ve.code="ERR_JWT_EXPIRED";class Ge extends h{constructor(){super(...arguments),this.code="ERR_JOSE_ALG_NOT_ALLOWED"}}Ge.code="ERR_JOSE_ALG_NOT_ALLOWED";class E extends h{constructor(){super(...arguments),this.code="ERR_JOSE_NOT_SUPPORTED"}}E.code="ERR_JOSE_NOT_SUPPORTED";class je extends h{constructor(e="decryption operation failed",r){super(e,r),this.code="ERR_JWE_DECRYPTION_FAILED"}}je.code="ERR_JWE_DECRYPTION_FAILED";class Be extends h{constructor(){super(...arguments),this.code="ERR_JWE_INVALID"}}Be.code="ERR_JWE_INVALID";class T extends h{constructor(){super(...arguments),this.code="ERR_JWS_INVALID"}}T.code="ERR_JWS_INVALID";class Se extends h{constructor(){super(...arguments),this.code="ERR_JWT_INVALID"}}Se.code="ERR_JWT_INVALID";class qe extends h{constructor(){super(...arguments),this.code="ERR_JWK_INVALID"}}qe.code="ERR_JWK_INVALID";class Ye extends h{constructor(){super(...arguments),this.code="ERR_JWKS_INVALID"}}Ye.code="ERR_JWKS_INVALID";class Xe extends h{constructor(e="no applicable key found in the JSON Web Key Set",r){super(e,r),this.code="ERR_JWKS_NO_MATCHING_KEY"}}Xe.code="ERR_JWKS_NO_MATCHING_KEY";class Ze extends h{constructor(e="multiple matching keys found in the JSON Web Key Set",r){super(e,r),this.code="ERR_JWKS_MULTIPLE_MATCHING_KEYS"}}Ze.code="ERR_JWKS_MULTIPLE_MATCHING_KEYS";class Qe extends h{constructor(e="request timed out",r){super(e,r),this.code="ERR_JWKS_TIMEOUT"}}Qe.code="ERR_JWKS_TIMEOUT";class et extends h{constructor(e="signature verification failed",r){super(e,r),this.code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED"}}et.code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED";function m(t,e="algorithm.name"){return new TypeError(`CryptoKey does not support this operation, its ${e} must be ${t}`)}function K(t,e){return t.name===e}function q(t){return parseInt(t.name.slice(4),10)}function tt(t){switch(t){case"ES256":return"P-256";case"ES384":return"P-384";case"ES512":return"P-521";default:throw new Error("unreachable")}}function rt(t,e){if(e.length&&!e.some(r=>t.usages.includes(r))){let r="CryptoKey does not support this operation, its usages must include ";if(e.length>2){const s=e.pop();r+=`one of ${e.join(", ")}, or ${s}.`}else e.length===2?r+=`one of ${e[0]} or ${e[1]}.`:r+=`${e[0]}.`;throw new TypeError(r)}}function st(t,e,...r){switch(e){case"HS256":case"HS384":case"HS512":{if(!K(t.algorithm,"HMAC"))throw m("HMAC");const s=parseInt(e.slice(2),10);if(q(t.algorithm.hash)!==s)throw m(`SHA-${s}`,"algorithm.hash");break}case"RS256":case"RS384":case"RS512":{if(!K(t.algorithm,"RSASSA-PKCS1-v1_5"))throw m("RSASSA-PKCS1-v1_5");const s=parseInt(e.slice(2),10);if(q(t.algorithm.hash)!==s)throw m(`SHA-${s}`,"algorithm.hash");break}case"PS256":case"PS384":case"PS512":{if(!K(t.algorithm,"RSA-PSS"))throw m("RSA-PSS");const s=parseInt(e.slice(2),10);if(q(t.algorithm.hash)!==s)throw m(`SHA-${s}`,"algorithm.hash");break}case"EdDSA":{if(t.algorithm.name!=="Ed25519"&&t.algorithm.name!=="Ed448")throw m("Ed25519 or Ed448");break}case"Ed25519":{if(!K(t.algorithm,"Ed25519"))throw m("Ed25519");break}case"ES256":case"ES384":case"ES512":{if(!K(t.algorithm,"ECDSA"))throw m("ECDSA");const s=tt(e);if(t.algorithm.namedCurve!==s)throw m(s,"algorithm.namedCurve");break}default:throw new TypeError("CryptoKey does not support this operation")}rt(t,r)}function _e(t,e,...r){var s;if(r=r.filter(Boolean),r.length>2){const n=r.pop();t+=`one of type ${r.join(", ")}, or ${n}.`}else r.length===2?t+=`one of type ${r[0]} or ${r[1]}.`:t+=`of type ${r[0]}.`;return e==null?t+=` Received ${e}`:typeof e=="function"&&e.name?t+=` Received function ${e.name}`:typeof e=="object"&&e!=null&&(s=e.constructor)!=null&&s.name&&(t+=` Received an instance of ${e.constructor.name}`),t}const pe=(t,...e)=>_e("Key must be ",t,...e);function we(t,e,...r){return _e(`Key for the ${t} algorithm must be `,e,...r)}const be=t=>ye(t)?!0:(t==null?void 0:t[Symbol.toStringTag])==="KeyObject",U=["CryptoKey"],nt=(...t)=>{const e=t.filter(Boolean);if(e.length===0||e.length===1)return!0;let r;for(const s of e){const n=Object.keys(s);if(!r||r.size===0){r=new Set(n);continue}for(const o of n){if(r.has(o))return!1;r.add(o)}}return!0};function ot(t){return typeof t=="object"&&t!==null}function Ee(t){if(!ot(t)||Object.prototype.toString.call(t)!=="[object Object]")return!1;if(Object.getPrototypeOf(t)===null)return!0;let e=t;for(;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}const it=(t,e)=>{if(t.startsWith("RS")||t.startsWith("PS")){const{modulusLength:r}=e.algorithm;if(typeof r!="number"||r<2048)throw new TypeError(`${t} requires key modulusLength to be 2048 bits or larger`)}};function N(t){return Ee(t)&&typeof t.kty=="string"}function at(t){return t.kty!=="oct"&&typeof t.d=="string"}function ct(t){return t.kty!=="oct"&&typeof t.d>"u"}function dt(t){return N(t)&&t.kty==="oct"&&typeof t.k=="string"}function lt(t){let e,r;switch(t.kty){case"RSA":{switch(t.alg){case"PS256":case"PS384":case"PS512":e={name:"RSA-PSS",hash:`SHA-${t.alg.slice(-3)}`},r=t.d?["sign"]:["verify"];break;case"RS256":case"RS384":case"RS512":e={name:"RSASSA-PKCS1-v1_5",hash:`SHA-${t.alg.slice(-3)}`},r=t.d?["sign"]:["verify"];break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":e={name:"RSA-OAEP",hash:`SHA-${parseInt(t.alg.slice(-3),10)||1}`},r=t.d?["decrypt","unwrapKey"]:["encrypt","wrapKey"];break;default:throw new E('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break}case"EC":{switch(t.alg){case"ES256":e={name:"ECDSA",namedCurve:"P-256"},r=t.d?["sign"]:["verify"];break;case"ES384":e={name:"ECDSA",namedCurve:"P-384"},r=t.d?["sign"]:["verify"];break;case"ES512":e={name:"ECDSA",namedCurve:"P-521"},r=t.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":e={name:"ECDH",namedCurve:t.crv},r=t.d?["deriveBits"]:[];break;default:throw new E('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break}case"OKP":{switch(t.alg){case"Ed25519":e={name:"Ed25519"},r=t.d?["sign"]:["verify"];break;case"EdDSA":e={name:t.crv},r=t.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":e={name:t.crv},r=t.d?["deriveBits"]:[];break;default:throw new E('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break}default:throw new E('Invalid or unsupported JWK "kty" (Key Type) Parameter value')}return{algorithm:e,keyUsages:r}}const ht=async t=>{if(!t.alg)throw new TypeError('"alg" argument is required when "jwk.alg" is not present');const{algorithm:e,keyUsages:r}=lt(t),s=[e,t.ext??!1,t.key_ops??r],n={...t};return delete n.alg,delete n.use,te.subtle.importKey("jwk",n,...s)},ve=t=>re(t);let v,A;const Ae=t=>(t==null?void 0:t[Symbol.toStringTag])==="KeyObject",M=async(t,e,r,s,n=!1)=>{let o=t.get(e);if(o!=null&&o[s])return o[s];const i=await ht({...r,alg:s});return n&&Object.freeze(e),o?o[s]=i:t.set(e,{[s]:i}),i},ut=(t,e)=>{if(Ae(t)){let r=t.export({format:"jwk"});return delete r.d,delete r.dp,delete r.dq,delete r.p,delete r.q,delete r.qi,r.k?ve(r.k):(A||(A=new WeakMap),M(A,t,r,e))}return N(t)?t.k?re(t.k):(A||(A=new WeakMap),M(A,t,t,e,!0)):t},pt=(t,e)=>{if(Ae(t)){let r=t.export({format:"jwk"});return r.k?ve(r.k):(v||(v=new WeakMap),M(v,t,r,e))}return N(t)?t.k?re(t.k):(v||(v=new WeakMap),M(v,t,t,e,!0)):t},ft={normalizePublicKey:ut,normalizePrivateKey:pt},I=t=>t==null?void 0:t[Symbol.toStringTag],Z=(t,e,r)=>{var s,n;if(e.use!==void 0&&e.use!=="sig")throw new TypeError("Invalid key for this operation, when present its use must be sig");if(e.key_ops!==void 0&&((n=(s=e.key_ops).includes)==null?void 0:n.call(s,r))!==!0)throw new TypeError(`Invalid key for this operation, when present its key_ops must include ${r}`);if(e.alg!==void 0&&e.alg!==t)throw new TypeError(`Invalid key for this operation, when present its alg must be ${t}`);return!0},mt=(t,e,r,s)=>{if(!(e instanceof Uint8Array)){if(s&&N(e)){if(dt(e)&&Z(t,e,r))return;throw new TypeError('JSON Web Key for symmetric algorithms must have JWK "kty" (Key Type) equal to "oct" and the JWK "k" (Key Value) present')}if(!be(e))throw new TypeError(we(t,e,...U,"Uint8Array",s?"JSON Web Key":null));if(e.type!=="secret")throw new TypeError(`${I(e)} instances for symmetric algorithms must be of type "secret"`)}},gt=(t,e,r,s)=>{if(s&&N(e))switch(r){case"sign":if(at(e)&&Z(t,e,r))return;throw new TypeError("JSON Web Key for this operation be a private JWK");case"verify":if(ct(e)&&Z(t,e,r))return;throw new TypeError("JSON Web Key for this operation be a public JWK")}if(!be(e))throw new TypeError(we(t,e,...U,s?"JSON Web Key":null));if(e.type==="secret")throw new TypeError(`${I(e)} instances for asymmetric algorithms must not be of type "secret"`);if(r==="sign"&&e.type==="public")throw new TypeError(`${I(e)} instances for asymmetric algorithm signing must be of type "private"`);if(r==="decrypt"&&e.type==="public")throw new TypeError(`${I(e)} instances for asymmetric algorithm decryption must be of type "private"`);if(e.algorithm&&r==="verify"&&e.type==="private")throw new TypeError(`${I(e)} instances for asymmetric algorithm verifying must be of type "public"`);if(e.algorithm&&r==="encrypt"&&e.type==="private")throw new TypeError(`${I(e)} instances for asymmetric algorithm encryption must be of type "public"`)};function Te(t,e,r,s){e.startsWith("HS")||e==="dir"||e.startsWith("PBES2")||/^A\d{3}(?:GCM)?KW$/.test(e)?mt(e,r,s,t):gt(e,r,s,t)}Te.bind(void 0,!1);const yt=Te.bind(void 0,!0);function St(t,e,r,s,n){if(n.crit!==void 0&&(s==null?void 0:s.crit)===void 0)throw new t('"crit" (Critical) Header Parameter MUST be integrity protected');if(!s||s.crit===void 0)return new Set;if(!Array.isArray(s.crit)||s.crit.length===0||s.crit.some(i=>typeof i!="string"||i.length===0))throw new t('"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present');let o;r!==void 0?o=new Map([...Object.entries(r),...e.entries()]):o=e;for(const i of s.crit){if(!o.has(i))throw new E(`Extension Header Parameter "${i}" is not recognized`);if(n[i]===void 0)throw new t(`Extension Header Parameter "${i}" is missing`);if(o.get(i)&&s[i]===void 0)throw new t(`Extension Header Parameter "${i}" MUST be integrity protected`)}return new Set(s.crit)}function _t(t,e){const r=`SHA-${t.slice(-3)}`;switch(t){case"HS256":case"HS384":case"HS512":return{hash:r,name:"HMAC"};case"PS256":case"PS384":case"PS512":return{hash:r,name:"RSA-PSS",saltLength:t.slice(-3)>>3};case"RS256":case"RS384":case"RS512":return{hash:r,name:"RSASSA-PKCS1-v1_5"};case"ES256":case"ES384":case"ES512":return{hash:r,name:"ECDSA",namedCurve:e.namedCurve};case"Ed25519":return{name:"Ed25519"};case"EdDSA":return{name:e.name};default:throw new E(`alg ${t} is not supported either by JOSE or your javascript runtime`)}}async function wt(t,e,r){if(e=await ft.normalizePrivateKey(e,t),ye(e))return st(e,t,r),e;if(e instanceof Uint8Array){if(!t.startsWith("HS"))throw new TypeError(pe(e,...U));return te.subtle.importKey("raw",e,{hash:`SHA-${t.slice(-3)}`,name:"HMAC"},!1,[r])}throw new TypeError(pe(e,...U,"Uint8Array","JSON Web Key"))}const w=t=>Math.floor(t.getTime()/1e3),Ie=60,Re=Ie*60,se=Re*24,bt=se*7,Et=se*365.25,vt=/^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i,Y=t=>{const e=vt.exec(t);if(!e||e[4]&&e[1])throw new TypeError("Invalid time period format");const r=parseFloat(e[2]),s=e[3].toLowerCase();let n;switch(s){case"sec":case"secs":case"second":case"seconds":case"s":n=Math.round(r);break;case"minute":case"minutes":case"min":case"mins":case"m":n=Math.round(r*Ie);break;case"hour":case"hours":case"hr":case"hrs":case"h":n=Math.round(r*Re);break;case"day":case"days":case"d":n=Math.round(r*se);break;case"week":case"weeks":case"w":n=Math.round(r*bt);break;default:n=Math.round(r*Et);break}return e[1]==="-"||e[4]==="ago"?-n:n},At=async(t,e,r)=>{const s=await wt(t,e,"sign");it(t,s);const n=await te.subtle.sign(_t(t,s.algorithm),s,r);return new Uint8Array(n)};class Tt{constructor(e){if(!(e instanceof Uint8Array))throw new TypeError("payload must be an instance of Uint8Array");this._payload=e}setProtectedHeader(e){if(this._protectedHeader)throw new TypeError("setProtectedHeader can only be called once");return this._protectedHeader=e,this}setUnprotectedHeader(e){if(this._unprotectedHeader)throw new TypeError("setUnprotectedHeader can only be called once");return this._unprotectedHeader=e,this}async sign(e,r){if(!this._protectedHeader&&!this._unprotectedHeader)throw new T("either setProtectedHeader or setUnprotectedHeader must be called before #sign()");if(!nt(this._protectedHeader,this._unprotectedHeader))throw new T("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");const s={...this._protectedHeader,...this._unprotectedHeader},n=St(T,new Map([["b64",!0]]),r==null?void 0:r.crit,this._protectedHeader,s);let o=!0;if(n.has("b64")&&(o=this._protectedHeader.b64,typeof o!="boolean"))throw new T('The "b64" (base64url-encode payload) Header Parameter must be a boolean');const{alg:i}=s;if(typeof i!="string"||!i)throw new T('JWS "alg" (Algorithm) Header Parameter missing or invalid');yt(i,e,"sign");let d=this._payload;o&&(d=R.encode(B(d)));let S;this._protectedHeader?S=R.encode(B(JSON.stringify(this._protectedHeader))):S=R.encode("");const _=Le(S,R.encode("."),d),W=await At(i,e,_),a={signature:B(W),payload:""};return o&&(a.payload=X.decode(d)),this._unprotectedHeader&&(a.header=this._unprotectedHeader),this._protectedHeader&&(a.protected=X.decode(S)),a}}class It{constructor(e){this._flattened=new Tt(e)}setProtectedHeader(e){return this._flattened.setProtectedHeader(e),this}async sign(e,r){const s=await this._flattened.sign(e,r);if(s.payload===void 0)throw new TypeError("use the flattened module for creating JWS with b64: false");return`${s.protected}.${s.payload}.${s.signature}`}}function b(t,e){if(!Number.isFinite(e))throw new TypeError(`Invalid ${t} input`);return e}class Rt{constructor(e={}){if(!Ee(e))throw new TypeError("JWT Claims Set MUST be an object");this._payload=e}setIssuer(e){return this._payload={...this._payload,iss:e},this}setSubject(e){return this._payload={...this._payload,sub:e},this}setAudience(e){return this._payload={...this._payload,aud:e},this}setJti(e){return this._payload={...this._payload,jti:e},this}setNotBefore(e){return typeof e=="number"?this._payload={...this._payload,nbf:b("setNotBefore",e)}:e instanceof Date?this._payload={...this._payload,nbf:b("setNotBefore",w(e))}:this._payload={...this._payload,nbf:w(new Date)+Y(e)},this}setExpirationTime(e){return typeof e=="number"?this._payload={...this._payload,exp:b("setExpirationTime",e)}:e instanceof Date?this._payload={...this._payload,exp:b("setExpirationTime",w(e))}:this._payload={...this._payload,exp:w(new Date)+Y(e)},this}setIssuedAt(e){return typeof e>"u"?this._payload={...this._payload,iat:w(new Date)}:e instanceof Date?this._payload={...this._payload,iat:b("setIssuedAt",w(e))}:typeof e=="string"?this._payload={...this._payload,iat:b("setIssuedAt",w(new Date)+Y(e))}:this._payload={...this._payload,iat:b("setIssuedAt",e)},this}}class Ct extends Rt{setProtectedHeader(e){return this._protectedHeader=e,this}async sign(e,r){var n;const s=new It(R.encode(JSON.stringify(this._payload)));if(s.setProtectedHeader(this._protectedHeader),Array.isArray((n=this._protectedHeader)==null?void 0:n.crit)&&this._protectedHeader.crit.includes("b64")&&this._protectedHeader.b64===!1)throw new Se("JWTs MUST NOT use unencoded payload");return s.sign(e,r)}}var z=J({clientId:c(),clientSecret:c()}),Wt=J({identityProviderId:c(),type:k("password"),issuer:c(),configUrl:c(),audience:c(),tokenUrl:c(),grantType:c(),scope:c(),clientId:c(),admin:L(z)}),Pt=J({identityProviderId:c(),type:k("implicit"),issuer:c(),configUrl:c(),audience:c(),scope:c(),clientId:c(),admin:L(z)}),Kt=J({identityProviderId:c(),type:k("client_credentials"),issuer:c(),configUrl:c(),audience:c(),scope:c(),clientId:c(),clientSecret:c(),admin:L(z)}),xt=J({identityProviderId:c(),type:k("self_signed"),issuer:c(),audience:c(),scope:c(),clientId:c(),clientSecret:c(),admin:L(z)});He("type",[Wt,Pt,Kt,xt]);var Jt=class Q{constructor(e,r,s=3600){this.auth=e,this.logger=r,this.expirySeconds=s}async getUserAccessToken(){return this.logger.debug("Fetching self-signed user auth token"),Q.fetchToken(this.logger,{clientId:this.auth.clientId,clientSecret:this.auth.clientSecret,scope:this.auth.scope,audience:this.auth.audience},this.auth.issuer,this.expirySeconds)}async getAdminAccessToken(){if(this.logger.debug("Fetching self-signed admin auth token"),!this.auth.admin)throw new Error("Admin credentials are not configured");return Q.fetchToken(this.logger,{clientId:this.auth.admin.clientId,clientSecret:this.auth.admin.clientSecret,scope:this.auth.scope,audience:this.auth.audience},this.auth.issuer,this.expirySeconds)}static async fetchToken(e,r,s,n=3600){const o=new TextEncoder().encode(r.clientSecret),i=Math.floor(Date.now()/1e3),d=await new Ct({sub:r.clientId,aud:r.audience||"",iat:i,exp:i+n,iss:s}).setProtectedHeader({alg:"HS256"}).sign(o);return e.info(`Generated self-signed JWT token: ${d}`),d}},Nt=Object.create,ne=Object.defineProperty,Ot=Object.getOwnPropertyDescriptor,Ce=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),C=t=>{throw TypeError(t)},Ht=(t,e,r)=>e in t?ne(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,fe=(t,e)=>ne(t,"name",{value:e,configurable:!0}),Dt=t=>[,,,Nt((t==null?void 0:t[Ce("metadata")])??null)],We=["class","method","getter","setter","accessor","field","value","get","set"],x=t=>t!==void 0&&typeof t!="function"?C("Function expected"):t,$t=(t,e,r,s,n)=>({kind:We[t],name:e,metadata:s,addInitializer:o=>r._?C("Already initialized"):n.push(x(o||null))}),Ut=(t,e)=>Ht(e,Ce("metadata"),t[3]),g=(t,e,r,s)=>{for(var n=0,o=t[e>>1],i=o&&o.length;n<i;n++)e&1?o[n].call(r):s=o[n].call(r,s);return s},O=(t,e,r,s,n,o)=>{var i,d,S,_,W,a=e&7,F=!!(e&8),f=!!(e&16),V=a>3?t.length+1:a?F?1:2:0,le=We[a+5],he=a>3&&(t[V-1]=[]),Oe=t[V]||(t[V]=[]),p=a&&(!f&&!F&&(n=n.prototype),a<5&&(a>3||!f)&&Ot(a<4?n:{get[r](){return me(this,o)},set[r](u){return ge(this,o,u)}},r));a?f&&a<4&&fe(o,(a>2?"set ":a>1?"get ":"")+r):fe(n,r);for(var G=s.length-1;G>=0;G--)_=$t(a,r,S={},t[3],Oe),a&&(_.static=F,_.private=f,W=_.access={has:f?u=>Mt(n,u):u=>r in u},a^3&&(W.get=f?u=>(a^1?me:Lt)(u,n,a^4?o:p.get):u=>u[r]),a>2&&(W.set=f?(u,j)=>ge(u,n,j,a^4?o:p.set):(u,j)=>u[r]=j)),d=(0,s[G])(a?a<4?f?o:p[le]:a>4?void 0:{get:p.get,set:p.set}:n,_),S._=1,a^4||d===void 0?x(d)&&(a>4?he.unshift(d):a?f?o=d:p[le]=d:n=d):typeof d!="object"||d===null?C("Object expected"):(x(i=d.get)&&(p.get=i),x(i=d.set)&&(p.set=i),x(i=d.init)&&he.unshift(i));return a||Ut(t,n),p&&ne(n,r,p),f?a^4?o:p:n},oe=(t,e,r)=>e.has(t)||C("Cannot "+r),Mt=(t,e)=>Object(e)!==e?C('Cannot use the "in" operator on this value'):t.has(e),me=(t,e,r)=>(oe(t,e,"read from private field"),r?r.call(t):e.get(t)),$=(t,e,r)=>e.has(t)?C("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),ge=(t,e,r,s)=>(oe(t,e,"write to private field"),s?s.call(t,r):e.set(t,r),r),Lt=(t,e,r)=>(oe(t,e,"access private method"),r),Pe,Ke,xe,Je,ee,Ne,l,ie,ae,ce,de;Ne=[Me("user-ui-login")];class y extends(ee=Ue,Je=[D()],xe=[D()],Ke=[D()],Pe=[D()],ee){constructor(){super(...arguments),$(this,ie,g(l,8,this,[])),g(l,11,this),$(this,ae,g(l,12,this,null)),g(l,15,this),$(this,ce,g(l,16,this,null)),g(l,19,this),$(this,de,g(l,20,this,null)),g(l,23,this)}handleChange(e){const r=parseInt(e.target.value);this.selectedNetwork=this.idps[r]??null,this.message=null}async loadNetworks(){return(await ue(P.accessToken.get()).request("listNetworks")).networks}async connectedCallback(){super.connectedCallback(),this.idps=await this.loadNetworks()}async handleConnectToIDP(){if(this.message=null,!this.selectedNetwork){this.messageType="error",this.message="Please select a network before connecting.";return}P.chainId.set(this.selectedNetwork.chainId);const e=`${window.origin}/callback/`;if(this.selectedNetwork.auth.type==="implicit"){this.messageType="info",this.message=`Redirecting to ${this.selectedNetwork.name}...`;const r=this.selectedNetwork.auth,s=await fetch(r.configUrl).then(i=>i.json()),n={configUrl:r.configUrl,clientId:r.clientId,audience:r.audience},o=new URLSearchParams({response_type:"code",client_id:this.selectedNetwork.auth.clientId||"",redirect_uri:e||"",nonce:crypto.randomUUID(),scope:r.scope||"",audience:r.audience||"",state:btoa(JSON.stringify(n))});setTimeout(()=>{window.location.href=`${s.authorization_endpoint}?${o.toString()}`},400)}else this.selectedNetwork.auth.type==="self_signed"?(await this.selfSign({clientId:this.selectedNetwork.auth.clientId||"",clientSecret:this.selectedNetwork.auth.clientSecret||"",scope:this.selectedNetwork.auth.scope,audience:this.selectedNetwork.auth.audience}),setTimeout(()=>{window.location.replace("/")},400)):(this.messageType="error",this.message="This authentication type is not supported yet.")}async selfSign(e){const r=await Jt.fetchToken(console,e,"unsafe-auth",3600);window.opener&&!window.opener.closed&&window.opener.postMessage({type:De.SPLICE_WALLET_IDP_AUTH_SUCCESS,token:r},"*");const s=JSON.parse(atob(r.split(".")[1]));P.expirationDate.set(new Date(s.exp*1e3).toString()),P.accessToken.set(r),await ue(r).request("addSession",{chainId:P.chainId.get()||""})}render(){return H`
1
+ import{o as J,d as c,e as L,l as k,f as He,c as ue,s as P,W as De,x as H,a as $e,i as Ue,t as Me}from"./index-_AVK9fEz.js";import{r as D}from"./state-BahUv9dS.js";const te=crypto,ye=t=>t instanceof CryptoKey,R=new TextEncoder,X=new TextDecoder;function Le(...t){const e=t.reduce((n,{length:o})=>n+o,0),r=new Uint8Array(e);let s=0;for(const n of t)r.set(n,s),s+=n.length;return r}const ke=t=>{let e=t;typeof e=="string"&&(e=R.encode(e));const r=32768,s=[];for(let n=0;n<e.length;n+=r)s.push(String.fromCharCode.apply(null,e.subarray(n,n+r)));return btoa(s.join(""))},B=t=>ke(t).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_"),ze=t=>{const e=atob(t),r=new Uint8Array(e.length);for(let s=0;s<e.length;s++)r[s]=e.charCodeAt(s);return r},re=t=>{let e=t;e instanceof Uint8Array&&(e=X.decode(e)),e=e.replace(/-/g,"+").replace(/_/g,"/").replace(/\s/g,"");try{return ze(e)}catch{throw new TypeError("The input to be decoded is not correctly encoded.")}};class h extends Error{constructor(e,r){var s;super(e,r),this.code="ERR_JOSE_GENERIC",this.name=this.constructor.name,(s=Error.captureStackTrace)==null||s.call(Error,this,this.constructor)}}h.code="ERR_JOSE_GENERIC";class Fe extends h{constructor(e,r,s="unspecified",n="unspecified"){super(e,{cause:{claim:s,reason:n,payload:r}}),this.code="ERR_JWT_CLAIM_VALIDATION_FAILED",this.claim=s,this.reason=n,this.payload=r}}Fe.code="ERR_JWT_CLAIM_VALIDATION_FAILED";class Ve extends h{constructor(e,r,s="unspecified",n="unspecified"){super(e,{cause:{claim:s,reason:n,payload:r}}),this.code="ERR_JWT_EXPIRED",this.claim=s,this.reason=n,this.payload=r}}Ve.code="ERR_JWT_EXPIRED";class Ge extends h{constructor(){super(...arguments),this.code="ERR_JOSE_ALG_NOT_ALLOWED"}}Ge.code="ERR_JOSE_ALG_NOT_ALLOWED";class E extends h{constructor(){super(...arguments),this.code="ERR_JOSE_NOT_SUPPORTED"}}E.code="ERR_JOSE_NOT_SUPPORTED";class je extends h{constructor(e="decryption operation failed",r){super(e,r),this.code="ERR_JWE_DECRYPTION_FAILED"}}je.code="ERR_JWE_DECRYPTION_FAILED";class Be extends h{constructor(){super(...arguments),this.code="ERR_JWE_INVALID"}}Be.code="ERR_JWE_INVALID";class T extends h{constructor(){super(...arguments),this.code="ERR_JWS_INVALID"}}T.code="ERR_JWS_INVALID";class Se extends h{constructor(){super(...arguments),this.code="ERR_JWT_INVALID"}}Se.code="ERR_JWT_INVALID";class qe extends h{constructor(){super(...arguments),this.code="ERR_JWK_INVALID"}}qe.code="ERR_JWK_INVALID";class Ye extends h{constructor(){super(...arguments),this.code="ERR_JWKS_INVALID"}}Ye.code="ERR_JWKS_INVALID";class Xe extends h{constructor(e="no applicable key found in the JSON Web Key Set",r){super(e,r),this.code="ERR_JWKS_NO_MATCHING_KEY"}}Xe.code="ERR_JWKS_NO_MATCHING_KEY";class Ze extends h{constructor(e="multiple matching keys found in the JSON Web Key Set",r){super(e,r),this.code="ERR_JWKS_MULTIPLE_MATCHING_KEYS"}}Ze.code="ERR_JWKS_MULTIPLE_MATCHING_KEYS";class Qe extends h{constructor(e="request timed out",r){super(e,r),this.code="ERR_JWKS_TIMEOUT"}}Qe.code="ERR_JWKS_TIMEOUT";class et extends h{constructor(e="signature verification failed",r){super(e,r),this.code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED"}}et.code="ERR_JWS_SIGNATURE_VERIFICATION_FAILED";function m(t,e="algorithm.name"){return new TypeError(`CryptoKey does not support this operation, its ${e} must be ${t}`)}function K(t,e){return t.name===e}function q(t){return parseInt(t.name.slice(4),10)}function tt(t){switch(t){case"ES256":return"P-256";case"ES384":return"P-384";case"ES512":return"P-521";default:throw new Error("unreachable")}}function rt(t,e){if(e.length&&!e.some(r=>t.usages.includes(r))){let r="CryptoKey does not support this operation, its usages must include ";if(e.length>2){const s=e.pop();r+=`one of ${e.join(", ")}, or ${s}.`}else e.length===2?r+=`one of ${e[0]} or ${e[1]}.`:r+=`${e[0]}.`;throw new TypeError(r)}}function st(t,e,...r){switch(e){case"HS256":case"HS384":case"HS512":{if(!K(t.algorithm,"HMAC"))throw m("HMAC");const s=parseInt(e.slice(2),10);if(q(t.algorithm.hash)!==s)throw m(`SHA-${s}`,"algorithm.hash");break}case"RS256":case"RS384":case"RS512":{if(!K(t.algorithm,"RSASSA-PKCS1-v1_5"))throw m("RSASSA-PKCS1-v1_5");const s=parseInt(e.slice(2),10);if(q(t.algorithm.hash)!==s)throw m(`SHA-${s}`,"algorithm.hash");break}case"PS256":case"PS384":case"PS512":{if(!K(t.algorithm,"RSA-PSS"))throw m("RSA-PSS");const s=parseInt(e.slice(2),10);if(q(t.algorithm.hash)!==s)throw m(`SHA-${s}`,"algorithm.hash");break}case"EdDSA":{if(t.algorithm.name!=="Ed25519"&&t.algorithm.name!=="Ed448")throw m("Ed25519 or Ed448");break}case"Ed25519":{if(!K(t.algorithm,"Ed25519"))throw m("Ed25519");break}case"ES256":case"ES384":case"ES512":{if(!K(t.algorithm,"ECDSA"))throw m("ECDSA");const s=tt(e);if(t.algorithm.namedCurve!==s)throw m(s,"algorithm.namedCurve");break}default:throw new TypeError("CryptoKey does not support this operation")}rt(t,r)}function _e(t,e,...r){var s;if(r=r.filter(Boolean),r.length>2){const n=r.pop();t+=`one of type ${r.join(", ")}, or ${n}.`}else r.length===2?t+=`one of type ${r[0]} or ${r[1]}.`:t+=`of type ${r[0]}.`;return e==null?t+=` Received ${e}`:typeof e=="function"&&e.name?t+=` Received function ${e.name}`:typeof e=="object"&&e!=null&&(s=e.constructor)!=null&&s.name&&(t+=` Received an instance of ${e.constructor.name}`),t}const pe=(t,...e)=>_e("Key must be ",t,...e);function we(t,e,...r){return _e(`Key for the ${t} algorithm must be `,e,...r)}const be=t=>ye(t)?!0:(t==null?void 0:t[Symbol.toStringTag])==="KeyObject",U=["CryptoKey"],nt=(...t)=>{const e=t.filter(Boolean);if(e.length===0||e.length===1)return!0;let r;for(const s of e){const n=Object.keys(s);if(!r||r.size===0){r=new Set(n);continue}for(const o of n){if(r.has(o))return!1;r.add(o)}}return!0};function ot(t){return typeof t=="object"&&t!==null}function Ee(t){if(!ot(t)||Object.prototype.toString.call(t)!=="[object Object]")return!1;if(Object.getPrototypeOf(t)===null)return!0;let e=t;for(;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}const it=(t,e)=>{if(t.startsWith("RS")||t.startsWith("PS")){const{modulusLength:r}=e.algorithm;if(typeof r!="number"||r<2048)throw new TypeError(`${t} requires key modulusLength to be 2048 bits or larger`)}};function N(t){return Ee(t)&&typeof t.kty=="string"}function at(t){return t.kty!=="oct"&&typeof t.d=="string"}function ct(t){return t.kty!=="oct"&&typeof t.d>"u"}function dt(t){return N(t)&&t.kty==="oct"&&typeof t.k=="string"}function lt(t){let e,r;switch(t.kty){case"RSA":{switch(t.alg){case"PS256":case"PS384":case"PS512":e={name:"RSA-PSS",hash:`SHA-${t.alg.slice(-3)}`},r=t.d?["sign"]:["verify"];break;case"RS256":case"RS384":case"RS512":e={name:"RSASSA-PKCS1-v1_5",hash:`SHA-${t.alg.slice(-3)}`},r=t.d?["sign"]:["verify"];break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":e={name:"RSA-OAEP",hash:`SHA-${parseInt(t.alg.slice(-3),10)||1}`},r=t.d?["decrypt","unwrapKey"]:["encrypt","wrapKey"];break;default:throw new E('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break}case"EC":{switch(t.alg){case"ES256":e={name:"ECDSA",namedCurve:"P-256"},r=t.d?["sign"]:["verify"];break;case"ES384":e={name:"ECDSA",namedCurve:"P-384"},r=t.d?["sign"]:["verify"];break;case"ES512":e={name:"ECDSA",namedCurve:"P-521"},r=t.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":e={name:"ECDH",namedCurve:t.crv},r=t.d?["deriveBits"]:[];break;default:throw new E('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break}case"OKP":{switch(t.alg){case"Ed25519":e={name:"Ed25519"},r=t.d?["sign"]:["verify"];break;case"EdDSA":e={name:t.crv},r=t.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":e={name:t.crv},r=t.d?["deriveBits"]:[];break;default:throw new E('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break}default:throw new E('Invalid or unsupported JWK "kty" (Key Type) Parameter value')}return{algorithm:e,keyUsages:r}}const ht=async t=>{if(!t.alg)throw new TypeError('"alg" argument is required when "jwk.alg" is not present');const{algorithm:e,keyUsages:r}=lt(t),s=[e,t.ext??!1,t.key_ops??r],n={...t};return delete n.alg,delete n.use,te.subtle.importKey("jwk",n,...s)},ve=t=>re(t);let v,A;const Ae=t=>(t==null?void 0:t[Symbol.toStringTag])==="KeyObject",M=async(t,e,r,s,n=!1)=>{let o=t.get(e);if(o!=null&&o[s])return o[s];const i=await ht({...r,alg:s});return n&&Object.freeze(e),o?o[s]=i:t.set(e,{[s]:i}),i},ut=(t,e)=>{if(Ae(t)){let r=t.export({format:"jwk"});return delete r.d,delete r.dp,delete r.dq,delete r.p,delete r.q,delete r.qi,r.k?ve(r.k):(A||(A=new WeakMap),M(A,t,r,e))}return N(t)?t.k?re(t.k):(A||(A=new WeakMap),M(A,t,t,e,!0)):t},pt=(t,e)=>{if(Ae(t)){let r=t.export({format:"jwk"});return r.k?ve(r.k):(v||(v=new WeakMap),M(v,t,r,e))}return N(t)?t.k?re(t.k):(v||(v=new WeakMap),M(v,t,t,e,!0)):t},ft={normalizePublicKey:ut,normalizePrivateKey:pt},I=t=>t==null?void 0:t[Symbol.toStringTag],Z=(t,e,r)=>{var s,n;if(e.use!==void 0&&e.use!=="sig")throw new TypeError("Invalid key for this operation, when present its use must be sig");if(e.key_ops!==void 0&&((n=(s=e.key_ops).includes)==null?void 0:n.call(s,r))!==!0)throw new TypeError(`Invalid key for this operation, when present its key_ops must include ${r}`);if(e.alg!==void 0&&e.alg!==t)throw new TypeError(`Invalid key for this operation, when present its alg must be ${t}`);return!0},mt=(t,e,r,s)=>{if(!(e instanceof Uint8Array)){if(s&&N(e)){if(dt(e)&&Z(t,e,r))return;throw new TypeError('JSON Web Key for symmetric algorithms must have JWK "kty" (Key Type) equal to "oct" and the JWK "k" (Key Value) present')}if(!be(e))throw new TypeError(we(t,e,...U,"Uint8Array",s?"JSON Web Key":null));if(e.type!=="secret")throw new TypeError(`${I(e)} instances for symmetric algorithms must be of type "secret"`)}},gt=(t,e,r,s)=>{if(s&&N(e))switch(r){case"sign":if(at(e)&&Z(t,e,r))return;throw new TypeError("JSON Web Key for this operation be a private JWK");case"verify":if(ct(e)&&Z(t,e,r))return;throw new TypeError("JSON Web Key for this operation be a public JWK")}if(!be(e))throw new TypeError(we(t,e,...U,s?"JSON Web Key":null));if(e.type==="secret")throw new TypeError(`${I(e)} instances for asymmetric algorithms must not be of type "secret"`);if(r==="sign"&&e.type==="public")throw new TypeError(`${I(e)} instances for asymmetric algorithm signing must be of type "private"`);if(r==="decrypt"&&e.type==="public")throw new TypeError(`${I(e)} instances for asymmetric algorithm decryption must be of type "private"`);if(e.algorithm&&r==="verify"&&e.type==="private")throw new TypeError(`${I(e)} instances for asymmetric algorithm verifying must be of type "public"`);if(e.algorithm&&r==="encrypt"&&e.type==="private")throw new TypeError(`${I(e)} instances for asymmetric algorithm encryption must be of type "public"`)};function Te(t,e,r,s){e.startsWith("HS")||e==="dir"||e.startsWith("PBES2")||/^A\d{3}(?:GCM)?KW$/.test(e)?mt(e,r,s,t):gt(e,r,s,t)}Te.bind(void 0,!1);const yt=Te.bind(void 0,!0);function St(t,e,r,s,n){if(n.crit!==void 0&&(s==null?void 0:s.crit)===void 0)throw new t('"crit" (Critical) Header Parameter MUST be integrity protected');if(!s||s.crit===void 0)return new Set;if(!Array.isArray(s.crit)||s.crit.length===0||s.crit.some(i=>typeof i!="string"||i.length===0))throw new t('"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present');let o;r!==void 0?o=new Map([...Object.entries(r),...e.entries()]):o=e;for(const i of s.crit){if(!o.has(i))throw new E(`Extension Header Parameter "${i}" is not recognized`);if(n[i]===void 0)throw new t(`Extension Header Parameter "${i}" is missing`);if(o.get(i)&&s[i]===void 0)throw new t(`Extension Header Parameter "${i}" MUST be integrity protected`)}return new Set(s.crit)}function _t(t,e){const r=`SHA-${t.slice(-3)}`;switch(t){case"HS256":case"HS384":case"HS512":return{hash:r,name:"HMAC"};case"PS256":case"PS384":case"PS512":return{hash:r,name:"RSA-PSS",saltLength:t.slice(-3)>>3};case"RS256":case"RS384":case"RS512":return{hash:r,name:"RSASSA-PKCS1-v1_5"};case"ES256":case"ES384":case"ES512":return{hash:r,name:"ECDSA",namedCurve:e.namedCurve};case"Ed25519":return{name:"Ed25519"};case"EdDSA":return{name:e.name};default:throw new E(`alg ${t} is not supported either by JOSE or your javascript runtime`)}}async function wt(t,e,r){if(e=await ft.normalizePrivateKey(e,t),ye(e))return st(e,t,r),e;if(e instanceof Uint8Array){if(!t.startsWith("HS"))throw new TypeError(pe(e,...U));return te.subtle.importKey("raw",e,{hash:`SHA-${t.slice(-3)}`,name:"HMAC"},!1,[r])}throw new TypeError(pe(e,...U,"Uint8Array","JSON Web Key"))}const w=t=>Math.floor(t.getTime()/1e3),Ie=60,Re=Ie*60,se=Re*24,bt=se*7,Et=se*365.25,vt=/^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i,Y=t=>{const e=vt.exec(t);if(!e||e[4]&&e[1])throw new TypeError("Invalid time period format");const r=parseFloat(e[2]),s=e[3].toLowerCase();let n;switch(s){case"sec":case"secs":case"second":case"seconds":case"s":n=Math.round(r);break;case"minute":case"minutes":case"min":case"mins":case"m":n=Math.round(r*Ie);break;case"hour":case"hours":case"hr":case"hrs":case"h":n=Math.round(r*Re);break;case"day":case"days":case"d":n=Math.round(r*se);break;case"week":case"weeks":case"w":n=Math.round(r*bt);break;default:n=Math.round(r*Et);break}return e[1]==="-"||e[4]==="ago"?-n:n},At=async(t,e,r)=>{const s=await wt(t,e,"sign");it(t,s);const n=await te.subtle.sign(_t(t,s.algorithm),s,r);return new Uint8Array(n)};class Tt{constructor(e){if(!(e instanceof Uint8Array))throw new TypeError("payload must be an instance of Uint8Array");this._payload=e}setProtectedHeader(e){if(this._protectedHeader)throw new TypeError("setProtectedHeader can only be called once");return this._protectedHeader=e,this}setUnprotectedHeader(e){if(this._unprotectedHeader)throw new TypeError("setUnprotectedHeader can only be called once");return this._unprotectedHeader=e,this}async sign(e,r){if(!this._protectedHeader&&!this._unprotectedHeader)throw new T("either setProtectedHeader or setUnprotectedHeader must be called before #sign()");if(!nt(this._protectedHeader,this._unprotectedHeader))throw new T("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");const s={...this._protectedHeader,...this._unprotectedHeader},n=St(T,new Map([["b64",!0]]),r==null?void 0:r.crit,this._protectedHeader,s);let o=!0;if(n.has("b64")&&(o=this._protectedHeader.b64,typeof o!="boolean"))throw new T('The "b64" (base64url-encode payload) Header Parameter must be a boolean');const{alg:i}=s;if(typeof i!="string"||!i)throw new T('JWS "alg" (Algorithm) Header Parameter missing or invalid');yt(i,e,"sign");let d=this._payload;o&&(d=R.encode(B(d)));let S;this._protectedHeader?S=R.encode(B(JSON.stringify(this._protectedHeader))):S=R.encode("");const _=Le(S,R.encode("."),d),W=await At(i,e,_),a={signature:B(W),payload:""};return o&&(a.payload=X.decode(d)),this._unprotectedHeader&&(a.header=this._unprotectedHeader),this._protectedHeader&&(a.protected=X.decode(S)),a}}class It{constructor(e){this._flattened=new Tt(e)}setProtectedHeader(e){return this._flattened.setProtectedHeader(e),this}async sign(e,r){const s=await this._flattened.sign(e,r);if(s.payload===void 0)throw new TypeError("use the flattened module for creating JWS with b64: false");return`${s.protected}.${s.payload}.${s.signature}`}}function b(t,e){if(!Number.isFinite(e))throw new TypeError(`Invalid ${t} input`);return e}class Rt{constructor(e={}){if(!Ee(e))throw new TypeError("JWT Claims Set MUST be an object");this._payload=e}setIssuer(e){return this._payload={...this._payload,iss:e},this}setSubject(e){return this._payload={...this._payload,sub:e},this}setAudience(e){return this._payload={...this._payload,aud:e},this}setJti(e){return this._payload={...this._payload,jti:e},this}setNotBefore(e){return typeof e=="number"?this._payload={...this._payload,nbf:b("setNotBefore",e)}:e instanceof Date?this._payload={...this._payload,nbf:b("setNotBefore",w(e))}:this._payload={...this._payload,nbf:w(new Date)+Y(e)},this}setExpirationTime(e){return typeof e=="number"?this._payload={...this._payload,exp:b("setExpirationTime",e)}:e instanceof Date?this._payload={...this._payload,exp:b("setExpirationTime",w(e))}:this._payload={...this._payload,exp:w(new Date)+Y(e)},this}setIssuedAt(e){return typeof e>"u"?this._payload={...this._payload,iat:w(new Date)}:e instanceof Date?this._payload={...this._payload,iat:b("setIssuedAt",w(e))}:typeof e=="string"?this._payload={...this._payload,iat:b("setIssuedAt",w(new Date)+Y(e))}:this._payload={...this._payload,iat:b("setIssuedAt",e)},this}}class Ct extends Rt{setProtectedHeader(e){return this._protectedHeader=e,this}async sign(e,r){var n;const s=new It(R.encode(JSON.stringify(this._payload)));if(s.setProtectedHeader(this._protectedHeader),Array.isArray((n=this._protectedHeader)==null?void 0:n.crit)&&this._protectedHeader.crit.includes("b64")&&this._protectedHeader.b64===!1)throw new Se("JWTs MUST NOT use unencoded payload");return s.sign(e,r)}}var z=J({clientId:c(),clientSecret:c()}),Wt=J({identityProviderId:c(),type:k("password"),issuer:c(),configUrl:c(),audience:c(),tokenUrl:c(),grantType:c(),scope:c(),clientId:c(),admin:L(z)}),Pt=J({identityProviderId:c(),type:k("implicit"),issuer:c(),configUrl:c(),audience:c(),scope:c(),clientId:c(),admin:L(z)}),Kt=J({identityProviderId:c(),type:k("client_credentials"),issuer:c(),configUrl:c(),audience:c(),scope:c(),clientId:c(),clientSecret:c(),admin:L(z)}),xt=J({identityProviderId:c(),type:k("self_signed"),issuer:c(),audience:c(),scope:c(),clientId:c(),clientSecret:c(),admin:L(z)});He("type",[Wt,Pt,Kt,xt]);var Jt=class Q{constructor(e,r,s=3600){this.auth=e,this.logger=r,this.expirySeconds=s}async getUserAccessToken(){return this.logger.debug("Fetching self-signed user auth token"),Q.fetchToken(this.logger,{clientId:this.auth.clientId,clientSecret:this.auth.clientSecret,scope:this.auth.scope,audience:this.auth.audience},this.auth.issuer,this.expirySeconds)}async getAdminAccessToken(){if(this.logger.debug("Fetching self-signed admin auth token"),!this.auth.admin)throw new Error("Admin credentials are not configured");return Q.fetchToken(this.logger,{clientId:this.auth.admin.clientId,clientSecret:this.auth.admin.clientSecret,scope:this.auth.scope,audience:this.auth.audience},this.auth.issuer,this.expirySeconds)}static async fetchToken(e,r,s,n=3600){const o=new TextEncoder().encode(r.clientSecret),i=Math.floor(Date.now()/1e3),d=await new Ct({sub:r.clientId,aud:r.audience||"",iat:i,exp:i+n,iss:s}).setProtectedHeader({alg:"HS256"}).sign(o);return e.info(`Generated self-signed JWT token: ${d}`),d}},Nt=Object.create,ne=Object.defineProperty,Ot=Object.getOwnPropertyDescriptor,Ce=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),C=t=>{throw TypeError(t)},Ht=(t,e,r)=>e in t?ne(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,fe=(t,e)=>ne(t,"name",{value:e,configurable:!0}),Dt=t=>[,,,Nt((t==null?void 0:t[Ce("metadata")])??null)],We=["class","method","getter","setter","accessor","field","value","get","set"],x=t=>t!==void 0&&typeof t!="function"?C("Function expected"):t,$t=(t,e,r,s,n)=>({kind:We[t],name:e,metadata:s,addInitializer:o=>r._?C("Already initialized"):n.push(x(o||null))}),Ut=(t,e)=>Ht(e,Ce("metadata"),t[3]),g=(t,e,r,s)=>{for(var n=0,o=t[e>>1],i=o&&o.length;n<i;n++)e&1?o[n].call(r):s=o[n].call(r,s);return s},O=(t,e,r,s,n,o)=>{var i,d,S,_,W,a=e&7,F=!!(e&8),f=!!(e&16),V=a>3?t.length+1:a?F?1:2:0,le=We[a+5],he=a>3&&(t[V-1]=[]),Oe=t[V]||(t[V]=[]),p=a&&(!f&&!F&&(n=n.prototype),a<5&&(a>3||!f)&&Ot(a<4?n:{get[r](){return me(this,o)},set[r](u){return ge(this,o,u)}},r));a?f&&a<4&&fe(o,(a>2?"set ":a>1?"get ":"")+r):fe(n,r);for(var G=s.length-1;G>=0;G--)_=$t(a,r,S={},t[3],Oe),a&&(_.static=F,_.private=f,W=_.access={has:f?u=>Mt(n,u):u=>r in u},a^3&&(W.get=f?u=>(a^1?me:Lt)(u,n,a^4?o:p.get):u=>u[r]),a>2&&(W.set=f?(u,j)=>ge(u,n,j,a^4?o:p.set):(u,j)=>u[r]=j)),d=(0,s[G])(a?a<4?f?o:p[le]:a>4?void 0:{get:p.get,set:p.set}:n,_),S._=1,a^4||d===void 0?x(d)&&(a>4?he.unshift(d):a?f?o=d:p[le]=d:n=d):typeof d!="object"||d===null?C("Object expected"):(x(i=d.get)&&(p.get=i),x(i=d.set)&&(p.set=i),x(i=d.init)&&he.unshift(i));return a||Ut(t,n),p&&ne(n,r,p),f?a^4?o:p:n},oe=(t,e,r)=>e.has(t)||C("Cannot "+r),Mt=(t,e)=>Object(e)!==e?C('Cannot use the "in" operator on this value'):t.has(e),me=(t,e,r)=>(oe(t,e,"read from private field"),r?r.call(t):e.get(t)),$=(t,e,r)=>e.has(t)?C("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),ge=(t,e,r,s)=>(oe(t,e,"write to private field"),s?s.call(t,r):e.set(t,r),r),Lt=(t,e,r)=>(oe(t,e,"access private method"),r),Pe,Ke,xe,Je,ee,Ne,l,ie,ae,ce,de;Ne=[Me("user-ui-login")];class y extends(ee=Ue,Je=[D()],xe=[D()],Ke=[D()],Pe=[D()],ee){constructor(){super(...arguments),$(this,ie,g(l,8,this,[])),g(l,11,this),$(this,ae,g(l,12,this,null)),g(l,15,this),$(this,ce,g(l,16,this,null)),g(l,19,this),$(this,de,g(l,20,this,null)),g(l,23,this)}handleChange(e){const r=parseInt(e.target.value);this.selectedNetwork=this.idps[r]??null,this.message=null}async loadNetworks(){return(await ue(P.accessToken.get()).request("listNetworks")).networks}async connectedCallback(){super.connectedCallback(),this.idps=await this.loadNetworks()}async handleConnectToIDP(){if(this.message=null,!this.selectedNetwork){this.messageType="error",this.message="Please select a network before connecting.";return}P.networkId.set(this.selectedNetwork.id);const e=`${window.origin}/callback/`;if(this.selectedNetwork.auth.type==="implicit"){this.messageType="info",this.message=`Redirecting to ${this.selectedNetwork.name}...`;const r=this.selectedNetwork.auth,s=await fetch(r.configUrl).then(i=>i.json()),n={configUrl:r.configUrl,clientId:r.clientId,audience:r.audience},o=new URLSearchParams({response_type:"code",client_id:this.selectedNetwork.auth.clientId||"",redirect_uri:e||"",nonce:crypto.randomUUID(),scope:r.scope||"",audience:r.audience||"",state:btoa(JSON.stringify(n))});setTimeout(()=>{window.location.href=`${s.authorization_endpoint}?${o.toString()}`},400)}else this.selectedNetwork.auth.type==="self_signed"?(await this.selfSign({clientId:this.selectedNetwork.auth.clientId||"",clientSecret:this.selectedNetwork.auth.clientSecret||"",scope:this.selectedNetwork.auth.scope,audience:this.selectedNetwork.auth.audience}),setTimeout(()=>{window.location.replace("/")},400)):(this.messageType="error",this.message="This authentication type is not supported yet.")}async selfSign(e){const r=await Jt.fetchToken(console,e,"unsafe-auth",3600);window.opener&&!window.opener.closed&&window.opener.postMessage({type:De.SPLICE_WALLET_IDP_AUTH_SUCCESS,token:r},"*");const s=JSON.parse(atob(r.split(".")[1]));P.expirationDate.set(new Date(s.exp*1e3).toString()),P.accessToken.set(r),await ue(r).request("addSession",{networkId:P.networkId.get()||""})}render(){return H`
2
2
  <div class="card">
3
3
  <h1>Sign in to Canton Network</h1>
4
4
 
@@ -1,4 +1,4 @@
1
- import{c as y,s as x,x as $,a as j,i as tt,t as et}from"./index-YpAHEASq.js";import{r as I}from"./state-BTqOtYLt.js";import{h as T}from"./handle-errors-DT2Go5Ch.js";var it=Object.create,z=Object.defineProperty,rt=Object.getOwnPropertyDescriptor,H=(i,e)=>(e=Symbol[i])?e:Symbol.for("Symbol."+i),v=i=>{throw TypeError(i)},nt=(i,e,r)=>e in i?z(i,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[e]=r,B=(i,e)=>z(i,"name",{value:e,configurable:!0}),ot=i=>[,,,it((i==null?void 0:i[H("metadata")])??null)],J=["class","method","getter","setter","accessor","field","value","get","set"],N=i=>i!==void 0&&typeof i!="function"?v("Function expected"):i,st=(i,e,r,t,o)=>({kind:J[i],name:e,metadata:t,addInitializer:a=>r._?v("Already initialized"):o.push(N(a||null))}),at=(i,e)=>nt(e,H("metadata"),i[3]),p=(i,e,r,t)=>{for(var o=0,a=i[e>>1],h=a&&a.length;o<h;o++)e&1?a[o].call(r):t=a[o].call(r,t);return t},b=(i,e,r,t,o,a)=>{var h,d,_,k,m,n=e&7,f=!!(e&8),c=!!(e&16),g=n>3?i.length+1:n?f?1:2:0,E=J[n+5],F=n>3&&(i[g-1]=[]),Z=i[g]||(i[g]=[]),u=n&&(!c&&!f&&(o=o.prototype),n<5&&(n>3||!c)&&rt(n<4?o:{get[r](){return G(this,a)},set[r](l){return K(this,a,l)}},r));n?c&&n<4&&B(a,(n>2?"set ":n>1?"get ":"")+r):B(o,r);for(var C=t.length-1;C>=0;C--)k=st(n,r,_={},i[3],Z),n&&(k.static=f,k.private=c,m=k.access={has:c?l=>dt(o,l):l=>r in l},n^3&&(m.get=c?l=>(n^1?G:ct)(l,o,n^4?a:u.get):l=>l[r]),n>2&&(m.set=c?(l,M)=>K(l,o,M,n^4?a:u.set):(l,M)=>l[r]=M)),d=(0,t[C])(n?n<4?c?a:u[E]:n>4?void 0:{get:u.get,set:u.set}:o,k),_._=1,n^4||d===void 0?N(d)&&(n>4?F.unshift(d):n?c?a=d:u[E]=d:o=d):typeof d!="object"||d===null?v("Object expected"):(N(h=d.get)&&(u.get=h),N(h=d.set)&&(u.set=h),N(h=d.init)&&F.unshift(h));return n||at(i,o),u&&z(o,r,u),c?n^4?a:u:o},P=(i,e,r)=>e.has(i)||v("Cannot "+r),dt=(i,e)=>Object(e)!==e?v('Cannot use the "in" operator on this value'):i.has(e),G=(i,e,r)=>(P(i,e,"read from private field"),r?r.call(i):e.get(i)),S=(i,e,r)=>e.has(i)?v("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(i):e.set(i,r),K=(i,e,r,t)=>(P(i,e,"write to private field"),t?t.call(i,r):e.set(i,r),r),ct=(i,e,r)=>(P(i,e,"access private method"),r),L,Q,R,V,X,U,Y,s,A,O,W,D,q;Y=[et("user-ui-networks")];class w extends(U=tt,X=[I()],V=[I()],R=[I()],Q=[I()],L=[I()],U){constructor(){var e,r;super(...arguments),S(this,A,p(s,8,this,[])),p(s,11,this),S(this,O,p(s,12,this,[])),p(s,15,this),S(this,W,p(s,16,this,!1)),p(s,19,this),S(this,D,p(s,20,this,null)),p(s,23,this),S(this,q,p(s,24,this,((r=(e=this.editingNetwork)==null?void 0:e.auth)==null?void 0:r.type)??"implicit")),p(s,27,this),this.openAddModal=()=>{this.isModalOpen=!0,this.editingNetwork=null},this.syncWallets=async()=>{try{const o=await y(x.accessToken.get()).request("syncWallets");alert(`Wallet sync completed. Added ${o.added.length} wallets.`)}catch(t){T(t)}},this.closeModal=()=>{this.isModalOpen=!1,this.listNetworks()},this.handleSubmit=async t=>{var h,d,_,k,m,n,f,c;t.preventDefault();let o;switch(t.network.auth.type){case"implicit":o={type:"implicit",identityProviderId:t.network.auth.identityProviderId,issuer:t.network.auth.issuer??"",configUrl:t.network.auth.configUrl??"",audience:t.network.auth.audience??"",scope:t.network.auth.scope??"",clientId:t.network.auth.clientId??"",admin:{clientId:((h=t.network.auth.admin)==null?void 0:h.clientId)??"",clientSecret:((d=t.network.auth.admin)==null?void 0:d.clientSecret)??""}};break;case"client_credentials":o={type:"client_credentials",identityProviderId:t.network.auth.identityProviderId,issuer:t.network.auth.issuer??"",configUrl:t.network.auth.configUrl??"",audience:t.network.auth.audience??"",scope:t.network.auth.scope??"",clientId:t.network.auth.clientId??"",clientSecret:t.network.auth.clientSecret??"",admin:{clientId:((_=t.network.auth.admin)==null?void 0:_.clientId)??"",clientSecret:((k=t.network.auth.admin)==null?void 0:k.clientSecret)??""}};break;case"password":o={type:"password",identityProviderId:t.network.auth.identityProviderId,issuer:t.network.auth.issuer??"",configUrl:t.network.auth.configUrl??"",audience:t.network.auth.audience??"",tokenUrl:t.network.auth.tokenUrl??"",grantType:t.network.auth.grantType??"",scope:t.network.auth.scope??"",clientId:t.network.auth.clientId??"",admin:{clientId:((m=t.network.auth.admin)==null?void 0:m.clientId)??"",clientSecret:((n=t.network.auth.admin)==null?void 0:n.clientSecret)??""}};break;case"self_signed":o={type:"self_signed",identityProviderId:t.network.auth.identityProviderId,issuer:t.network.auth.issuer??"",audience:t.network.auth.audience??"",scope:t.network.auth.scope??"",clientId:t.network.auth.clientId??"",clientSecret:t.network.auth.clientSecret??"",admin:{clientId:((f=t.network.auth.admin)==null?void 0:f.clientId)??"",clientSecret:((c=t.network.auth.admin)==null?void 0:c.clientSecret)??""},configUrl:""};break}const a={...t.network,auth:o,ledgerApi:t.network.ledgerApi.baseUrl};try{await y(x.accessToken.get()).request("addNetwork",{network:a}),await this.listNetworks()}catch(g){T(g)}finally{this.closeModal()}}}async listNetworks(){const r=await y(x.accessToken.get()).request("listNetworks");this.networks=r.networks}async listSessions(){const r=await y(x.accessToken.get()).request("listSessions");this.sessions=r.sessions}connectedCallback(){super.connectedCallback(),this.listNetworks(),this.listSessions()}async handleDelete(e){if(confirm(`Delete network "${e.network.name}"?`))try{const r={networkName:e.network.chainId};await y(x.accessToken.get()).request("removeNetwork",r),await this.listNetworks()}catch(r){T(r)}}onAuthTypeChange(e){const r=e.target;this.authType=r.value}render(){return $`
1
+ import{c as y,s as x,x as $,a as j,i as tt,t as et}from"./index-_AVK9fEz.js";import{r as I}from"./state-BahUv9dS.js";import{h as T}from"./handle-errors-C_r_-A1k.js";var it=Object.create,z=Object.defineProperty,rt=Object.getOwnPropertyDescriptor,H=(i,e)=>(e=Symbol[i])?e:Symbol.for("Symbol."+i),v=i=>{throw TypeError(i)},nt=(i,e,r)=>e in i?z(i,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[e]=r,B=(i,e)=>z(i,"name",{value:e,configurable:!0}),ot=i=>[,,,it((i==null?void 0:i[H("metadata")])??null)],J=["class","method","getter","setter","accessor","field","value","get","set"],N=i=>i!==void 0&&typeof i!="function"?v("Function expected"):i,st=(i,e,r,t,o)=>({kind:J[i],name:e,metadata:t,addInitializer:a=>r._?v("Already initialized"):o.push(N(a||null))}),at=(i,e)=>nt(e,H("metadata"),i[3]),p=(i,e,r,t)=>{for(var o=0,a=i[e>>1],h=a&&a.length;o<h;o++)e&1?a[o].call(r):t=a[o].call(r,t);return t},b=(i,e,r,t,o,a)=>{var h,d,_,k,m,n=e&7,f=!!(e&8),c=!!(e&16),g=n>3?i.length+1:n?f?1:2:0,E=J[n+5],F=n>3&&(i[g-1]=[]),Z=i[g]||(i[g]=[]),u=n&&(!c&&!f&&(o=o.prototype),n<5&&(n>3||!c)&&rt(n<4?o:{get[r](){return G(this,a)},set[r](l){return K(this,a,l)}},r));n?c&&n<4&&B(a,(n>2?"set ":n>1?"get ":"")+r):B(o,r);for(var C=t.length-1;C>=0;C--)k=st(n,r,_={},i[3],Z),n&&(k.static=f,k.private=c,m=k.access={has:c?l=>dt(o,l):l=>r in l},n^3&&(m.get=c?l=>(n^1?G:ct)(l,o,n^4?a:u.get):l=>l[r]),n>2&&(m.set=c?(l,M)=>K(l,o,M,n^4?a:u.set):(l,M)=>l[r]=M)),d=(0,t[C])(n?n<4?c?a:u[E]:n>4?void 0:{get:u.get,set:u.set}:o,k),_._=1,n^4||d===void 0?N(d)&&(n>4?F.unshift(d):n?c?a=d:u[E]=d:o=d):typeof d!="object"||d===null?v("Object expected"):(N(h=d.get)&&(u.get=h),N(h=d.set)&&(u.set=h),N(h=d.init)&&F.unshift(h));return n||at(i,o),u&&z(o,r,u),c?n^4?a:u:o},P=(i,e,r)=>e.has(i)||v("Cannot "+r),dt=(i,e)=>Object(e)!==e?v('Cannot use the "in" operator on this value'):i.has(e),G=(i,e,r)=>(P(i,e,"read from private field"),r?r.call(i):e.get(i)),S=(i,e,r)=>e.has(i)?v("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(i):e.set(i,r),K=(i,e,r,t)=>(P(i,e,"write to private field"),t?t.call(i,r):e.set(i,r),r),ct=(i,e,r)=>(P(i,e,"access private method"),r),L,Q,R,V,X,U,Y,s,A,O,W,D,q;Y=[et("user-ui-networks")];class w extends(U=tt,X=[I()],V=[I()],R=[I()],Q=[I()],L=[I()],U){constructor(){var e,r;super(...arguments),S(this,A,p(s,8,this,[])),p(s,11,this),S(this,O,p(s,12,this,[])),p(s,15,this),S(this,W,p(s,16,this,!1)),p(s,19,this),S(this,D,p(s,20,this,null)),p(s,23,this),S(this,q,p(s,24,this,((r=(e=this.editingNetwork)==null?void 0:e.auth)==null?void 0:r.type)??"implicit")),p(s,27,this),this.openAddModal=()=>{this.isModalOpen=!0,this.editingNetwork=null},this.syncWallets=async()=>{try{const o=await y(x.accessToken.get()).request("syncWallets");alert(`Wallet sync completed. Added ${o.added.length} wallets.`)}catch(t){T(t)}},this.closeModal=()=>{this.isModalOpen=!1,this.listNetworks()},this.handleSubmit=async t=>{var h,d,_,k,m,n,f,c;t.preventDefault();let o;switch(t.network.auth.type){case"implicit":o={type:"implicit",identityProviderId:t.network.auth.identityProviderId,issuer:t.network.auth.issuer??"",configUrl:t.network.auth.configUrl??"",audience:t.network.auth.audience??"",scope:t.network.auth.scope??"",clientId:t.network.auth.clientId??"",admin:{clientId:((h=t.network.auth.admin)==null?void 0:h.clientId)??"",clientSecret:((d=t.network.auth.admin)==null?void 0:d.clientSecret)??""}};break;case"client_credentials":o={type:"client_credentials",identityProviderId:t.network.auth.identityProviderId,issuer:t.network.auth.issuer??"",configUrl:t.network.auth.configUrl??"",audience:t.network.auth.audience??"",scope:t.network.auth.scope??"",clientId:t.network.auth.clientId??"",clientSecret:t.network.auth.clientSecret??"",admin:{clientId:((_=t.network.auth.admin)==null?void 0:_.clientId)??"",clientSecret:((k=t.network.auth.admin)==null?void 0:k.clientSecret)??""}};break;case"password":o={type:"password",identityProviderId:t.network.auth.identityProviderId,issuer:t.network.auth.issuer??"",configUrl:t.network.auth.configUrl??"",audience:t.network.auth.audience??"",tokenUrl:t.network.auth.tokenUrl??"",grantType:t.network.auth.grantType??"",scope:t.network.auth.scope??"",clientId:t.network.auth.clientId??"",admin:{clientId:((m=t.network.auth.admin)==null?void 0:m.clientId)??"",clientSecret:((n=t.network.auth.admin)==null?void 0:n.clientSecret)??""}};break;case"self_signed":o={type:"self_signed",identityProviderId:t.network.auth.identityProviderId,issuer:t.network.auth.issuer??"",audience:t.network.auth.audience??"",scope:t.network.auth.scope??"",clientId:t.network.auth.clientId??"",clientSecret:t.network.auth.clientSecret??"",admin:{clientId:((f=t.network.auth.admin)==null?void 0:f.clientId)??"",clientSecret:((c=t.network.auth.admin)==null?void 0:c.clientSecret)??""},configUrl:""};break}const a={...t.network,auth:o,ledgerApi:t.network.ledgerApi.baseUrl};try{await y(x.accessToken.get()).request("addNetwork",{network:a}),await this.listNetworks()}catch(g){T(g)}finally{this.closeModal()}}}async listNetworks(){const r=await y(x.accessToken.get()).request("listNetworks");this.networks=r.networks}async listSessions(){const r=await y(x.accessToken.get()).request("listSessions");this.sessions=r.sessions}connectedCallback(){super.connectedCallback(),this.listNetworks(),this.listSessions()}async handleDelete(e){if(confirm(`Delete network "${e.network.name}"?`))try{const r={networkName:e.network.id};await y(x.accessToken.get()).request("removeNetwork",r),await this.listNetworks()}catch(r){T(r)}}onAuthTypeChange(e){const r=e.target;this.authType=r.value}render(){return $`
2
2
  <div class="header"><h1>Sessions</h1></div>
3
3
  <div class="table-container">
4
4
  <table>
@@ -12,7 +12,7 @@ import{c as y,s as x,x as $,a as j,i as tt,t as et}from"./index-YpAHEASq.js";imp
12
12
  <tbody>
13
13
  ${this.sessions.map(e=>$`
14
14
  <tr>
15
- <td>${e.network.chainId}</td>
15
+ <td>${e.network.id}</td>
16
16
  <td>${e.status}</td>
17
17
  <td>
18
18
  <button
@@ -1,4 +1,4 @@
1
- import{g as u,u as l}from"./index-YpAHEASq.js";/**
1
+ import{g as u,u as l}from"./index-_AVK9fEz.js";/**
2
2
  * @license
3
3
  * Copyright 2017 Google LLC
4
4
  * SPDX-License-Identifier: BSD-3-Clause