@learncard/simple-signing-plugin 1.0.3

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.
@@ -0,0 +1,5 @@
1
+ "use strict";var Se=Object.defineProperty;var bt=Object.getOwnPropertyDescriptor;var xt=Object.getOwnPropertyNames;var wt=Object.prototype.hasOwnProperty;var c=(r,e)=>Se(r,"name",{value:e,configurable:!0});var Tt=(r,e)=>{for(var t in e)Se(r,t,{get:e[t],enumerable:!0})},kt=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of xt(e))!wt.call(r,s)&&s!==t&&Se(r,s,{get:()=>e[s],enumerable:!(n=bt(e,s))||n.enumerable});return r};var St=r=>kt(Se({},"__esModule",{value:!0}),r);var Hr={};Tt(Hr,{SigningAuthorityValidator:()=>_r,getSimpleSigningPlugin:()=>Zr});module.exports=St(Hr);var b;(function(r){r.assertEqual=s=>s;function e(s){}c(e,"assertIs"),r.assertIs=e;function t(s){throw new Error}c(t,"assertNever"),r.assertNever=t,r.arrayToEnum=s=>{let a={};for(let i of s)a[i]=i;return a},r.getValidEnumValues=s=>{let a=r.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),i={};for(let o of a)i[o]=s[o];return r.objectValues(i)},r.objectValues=s=>r.objectKeys(s).map(function(a){return s[a]}),r.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{let a=[];for(let i in s)Object.prototype.hasOwnProperty.call(s,i)&&a.push(i);return a},r.find=(s,a)=>{for(let i of s)if(a(i))return i},r.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function n(s,a=" | "){return s.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}c(n,"joinValues"),r.joinValues=n,r.jsonStringifyReplacer=(s,a)=>typeof a=="bigint"?a.toString():a})(b||(b={}));var f=b.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),J=c(r=>{switch(typeof r){case"undefined":return f.undefined;case"string":return f.string;case"number":return 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}},"getParsedType"),d=b.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"]),Et=c(r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:"),"quotelessJson"),I=class extends Error{constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){let t=e||function(a){return a.message},n={_errors:[]},s=c(a=>{for(let i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(s);else if(i.code==="invalid_return_type")s(i.returnTypeError);else if(i.code==="invalid_arguments")s(i.argumentsError);else if(i.path.length===0)n._errors.push(t(i));else{let o=n,u=0;for(;u<i.path.length;){let l=i.path[u];u===i.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(t(i))):o[l]=o[l]||{_errors:[]},o=o[l],u++}}},"processError");return s(this),n}toString(){return this.message}get message(){return JSON.stringify(this.issues,b.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){let t={},n=[];for(let s of this.issues)s.path.length>0?(t[s.path[0]]=t[s.path[0]]||[],t[s.path[0]].push(e(s))):n.push(e(s));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};c(I,"ZodError");I.create=r=>new I(r);var be=c((r,e)=>{let t;switch(r.code){case d.invalid_type:r.received===f.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case d.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,b.jsonStringifyReplacer)}`;break;case d.unrecognized_keys:t=`Unrecognized key(s) in object: ${b.joinValues(r.keys,", ")}`;break;case d.invalid_union:t="Invalid input";break;case d.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${b.joinValues(r.options)}`;break;case d.invalid_enum_value:t=`Invalid enum value. Expected ${b.joinValues(r.options)}, received '${r.received}'`;break;case d.invalid_arguments:t="Invalid function arguments";break;case d.invalid_return_type:t="Invalid function return type";break;case d.invalid_date:t="Invalid date";break;case d.invalid_string:typeof r.validation=="object"?"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:b.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case d.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(r.minimum)}`:t="Invalid input";break;case d.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(r.maximum)}`:t="Invalid input";break;case d.custom:t="Invalid input";break;case d.invalid_intersection_types:t="Intersection results could not be merged";break;case d.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case d.not_finite:t="Number must be finite";break;default:t=e.defaultError,b.assertNever(r)}return{message:t}},"errorMap"),nt=be;function Rt(r){nt=r}c(Rt,"setErrorMap");function Re(){return nt}c(Re,"getErrorMap");var Oe=c(r=>{let{data:e,path:t,errorMaps:n,issueData:s}=r,a=[...t,...s.path||[]],i={...s,path:a},o="",u=n.filter(l=>!!l).slice().reverse();for(let l of u)o=l(i,{data:e,defaultError:o}).message;return{...s,path:a,message:s.message||o}},"makeIssue"),Ot=[];function p(r,e){let t=Oe({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Re(),be].filter(n=>!!n)});r.common.issues.push(t)}c(p,"addIssueToContext");var E=class{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){let n=[];for(let s of t){if(s.status==="aborted")return y;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){let n=[];for(let s of t)n.push({key:await s.key,value:await s.value});return E.mergeObjectSync(e,n)}static mergeObjectSync(e,t){let n={};for(let s of t){let{key:a,value:i}=s;if(a.status==="aborted"||i.status==="aborted")return y;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),(typeof i.value<"u"||s.alwaysSet)&&(n[a.value]=i.value)}return{status:e.value,value:n}}};c(E,"ParseStatus");var y=Object.freeze({status:"aborted"}),st=c(r=>({status:"dirty",value:r}),"DIRTY"),O=c(r=>({status:"valid",value:r}),"OK"),ze=c(r=>r.status==="aborted","isAborted"),Ue=c(r=>r.status==="dirty","isDirty"),Ce=c(r=>r.status==="valid","isValid"),Ne=c(r=>typeof Promise!==void 0&&r instanceof Promise,"isAsync"),v;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e?.message})(v||(v={}));var P=class{constructor(e,t,n,s){this.parent=e,this.data=t,this._path=n,this._key=s}get path(){return this._path.concat(this._key)}};c(P,"ParseInputLazyPath");var et=c((r,e)=>{if(Ce(e))return{success:!0,data:e.value};{if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");let t=new I(r.common.issues);return{success:!1,error:t}}},"handleResult");function _(r){if(!r)return{};let{errorMap:e,invalid_type_error:t,required_error:n,description:s}=r;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:c((i,o)=>i.code!=="invalid_type"?{message:o.defaultError}:typeof o.data>"u"?{message:n??o.defaultError}:{message:t??o.defaultError},"customMap"),description:s}}c(_,"processCreateParams");var g=class{constructor(e){this.spa=this.safeParseAsync,this._def=e,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.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return J(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:J(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new E,ctx:{common:e.parent.common,data:e.data,parsedType:J(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(Ne(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){var n;let s={common:{issues:[],async:(n=t?.async)!==null&&n!==void 0?n:!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:J(e)},a=this._parseSync({data:e,path:s.path,parent:s});return et(s,a)}async parseAsync(e,t){let n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){let n={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:J(e)},s=this._parse({data:e,path:n.path,parent:n}),a=await(Ne(s)?s:Promise.resolve(s));return et(n,a)}refine(e,t){let n=c(s=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(s):t,"getIssueProperties");return this._refinement((s,a)=>{let i=e(s),o=c(()=>a.addIssue({code:d.custom,...n(s)}),"setError");return typeof Promise<"u"&&i instanceof Promise?i.then(u=>u?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,t){return this._refinement((n,s)=>e(n)?!0:(s.addIssue(typeof t=="function"?t(n,s):t),!1))}_refinement(e){return new N({schema:this,typeName:m.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return j.create(this)}nullable(){return B.create(this)}nullish(){return this.optional().nullable()}array(){return C.create(this)}promise(){return W.create(this)}or(e){return G.create([this,e])}and(e){return X.create(this,e)}transform(e){return new N({schema:this,typeName:m.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let t=typeof e=="function"?e:()=>e;return new ae({innerType:this,defaultValue:t,typeName:m.ZodDefault})}brand(){return new ve({typeName:m.ZodBranded,type:this,..._(void 0)})}catch(e){let t=typeof e=="function"?e:()=>e;return new pe({innerType:this,defaultValue:t,typeName:m.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return ie.create(this,e)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}};c(g,"ZodType");var Ct=/^c[^\s-]{8,}$/i,Nt=/^([a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12}|00000000-0000-0000-0000-000000000000)$/i,Pt=/^(([^<>()[\]\.,;:\s@\"]+(\.[^<>()[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i,At=c(r=>r.precision?r.offset?new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${r.precision}}(([+-]\\d{2}:\\d{2})|Z)$`):new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${r.precision}}Z$`):r.precision===0?r.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}:\\d{2})|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$"):r.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}:\\d{2})|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$"),"datetimeRegex"),D=class extends g{constructor(){super(...arguments),this._regex=(e,t,n)=>this.refinement(s=>e.test(s),{validation:t,code:d.invalid_string,...v.errToObj(n)}),this.nonempty=e=>this.min(1,v.errToObj(e)),this.trim=()=>new D({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==f.string){let a=this._getOrReturnCtx(e);return p(a,{code:d.invalid_type,expected:f.string,received:a.parsedType}),y}let n=new E,s;for(let a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(s=this._getOrReturnCtx(e,s),p(s,{code:d.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="max")e.data.length>a.value&&(s=this._getOrReturnCtx(e,s),p(s,{code:d.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="length"){let i=e.data.length>a.value,o=e.data.length<a.value;(i||o)&&(s=this._getOrReturnCtx(e,s),i?p(s,{code:d.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):o&&p(s,{code:d.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),n.dirty())}else if(a.kind==="email")Pt.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"email",code:d.invalid_string,message:a.message}),n.dirty());else if(a.kind==="uuid")Nt.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"uuid",code:d.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid")Ct.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"cuid",code:d.invalid_string,message:a.message}),n.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),p(s,{validation:"url",code:d.invalid_string,message:a.message}),n.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"regex",code:d.invalid_string,message:a.message}),n.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="startsWith"?e.data.startsWith(a.value)||(s=this._getOrReturnCtx(e,s),p(s,{code:d.invalid_string,validation:{startsWith:a.value},message:a.message}),n.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(s=this._getOrReturnCtx(e,s),p(s,{code:d.invalid_string,validation:{endsWith:a.value},message:a.message}),n.dirty()):a.kind==="datetime"?At(a).test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{code:d.invalid_string,validation:"datetime",message:a.message}),n.dirty()):b.assertNever(a);return{status:n.value,value:e.data}}_addCheck(e){return new D({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...v.errToObj(e)})}url(e){return this._addCheck({kind:"url",...v.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...v.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...v.errToObj(e)})}datetime(e){var t;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:(t=e?.offset)!==null&&t!==void 0?t:!1,...v.errToObj(e?.message)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...v.errToObj(t)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...v.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...v.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...v.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...v.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...v.errToObj(t)})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get minLength(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};c(D,"ZodString");D.create=r=>{var e;return new D({checks:[],typeName:m.ZodString,coerce:(e=r?.coerce)!==null&&e!==void 0?e:!1,..._(r)})};function jt(r,e){let t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=t>n?t:n,a=parseInt(r.toFixed(s).replace(".","")),i=parseInt(e.toFixed(s).replace(".",""));return a%i/Math.pow(10,s)}c(jt,"floatSafeRemainder");var L=class extends g{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==f.number){let a=this._getOrReturnCtx(e);return p(a,{code:d.invalid_type,expected:f.number,received:a.parsedType}),y}let n,s=new E;for(let a of this._def.checks)a.kind==="int"?b.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),p(n,{code:d.invalid_type,expected:"integer",received:"float",message:a.message}),s.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),p(n,{code:d.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),p(n,{code:d.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="multipleOf"?jt(e.data,a.value)!==0&&(n=this._getOrReturnCtx(e,n),p(n,{code:d.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),p(n,{code:d.not_finite,message:a.message}),s.dirty()):b.assertNever(a);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,v.toString(t))}gt(e,t){return this.setLimit("min",e,!1,v.toString(t))}lte(e,t){return this.setLimit("max",e,!0,v.toString(t))}lt(e,t){return this.setLimit("max",e,!1,v.toString(t))}setLimit(e,t,n,s){return new L({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:v.toString(s)}]})}_addCheck(e){return new L({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:v.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:v.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:v.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:v.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:v.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:v.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:v.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int")}};c(L,"ZodNumber");L.create=r=>new L({checks:[],typeName:m.ZodNumber,coerce:r?.coerce||!1,..._(r)});var Y=class extends g{_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==f.bigint){let n=this._getOrReturnCtx(e);return p(n,{code:d.invalid_type,expected:f.bigint,received:n.parsedType}),y}return O(e.data)}};c(Y,"ZodBigInt");Y.create=r=>{var e;return new Y({typeName:m.ZodBigInt,coerce:(e=r?.coerce)!==null&&e!==void 0?e:!1,..._(r)})};var F=class extends g{_parse(e){if(this._def.coerce&&(e.data=Boolean(e.data)),this._getType(e)!==f.boolean){let n=this._getOrReturnCtx(e);return p(n,{code:d.invalid_type,expected:f.boolean,received:n.parsedType}),y}return O(e.data)}};c(F,"ZodBoolean");F.create=r=>new F({typeName:m.ZodBoolean,coerce:r?.coerce||!1,..._(r)});var z=class extends g{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==f.date){let a=this._getOrReturnCtx(e);return p(a,{code:d.invalid_type,expected:f.date,received:a.parsedType}),y}if(isNaN(e.data.getTime())){let a=this._getOrReturnCtx(e);return p(a,{code:d.invalid_date}),y}let n=new E,s;for(let a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(s=this._getOrReturnCtx(e,s),p(s,{code:d.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),n.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(s=this._getOrReturnCtx(e,s),p(s,{code:d.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),n.dirty()):b.assertNever(a);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new z({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:v.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:v.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}};c(z,"ZodDate");z.create=r=>new z({checks:[],coerce:r?.coerce||!1,typeName:m.ZodDate,..._(r)});var ue=class extends g{_parse(e){if(this._getType(e)!==f.symbol){let n=this._getOrReturnCtx(e);return p(n,{code:d.invalid_type,expected:f.symbol,received:n.parsedType}),y}return O(e.data)}};c(ue,"ZodSymbol");ue.create=r=>new ue({typeName:m.ZodSymbol,..._(r)});var K=class extends g{_parse(e){if(this._getType(e)!==f.undefined){let n=this._getOrReturnCtx(e);return p(n,{code:d.invalid_type,expected:f.undefined,received:n.parsedType}),y}return O(e.data)}};c(K,"ZodUndefined");K.create=r=>new K({typeName:m.ZodUndefined,..._(r)});var Q=class extends g{_parse(e){if(this._getType(e)!==f.null){let n=this._getOrReturnCtx(e);return p(n,{code:d.invalid_type,expected:f.null,received:n.parsedType}),y}return O(e.data)}};c(Q,"ZodNull");Q.create=r=>new Q({typeName:m.ZodNull,..._(r)});var Z=class extends g{constructor(){super(...arguments),this._any=!0}_parse(e){return O(e.data)}};c(Z,"ZodAny");Z.create=r=>new Z({typeName:m.ZodAny,..._(r)});var U=class extends g{constructor(){super(...arguments),this._unknown=!0}_parse(e){return O(e.data)}};c(U,"ZodUnknown");U.create=r=>new U({typeName:m.ZodUnknown,..._(r)});var M=class extends g{_parse(e){let t=this._getOrReturnCtx(e);return p(t,{code:d.invalid_type,expected:f.never,received:t.parsedType}),y}};c(M,"ZodNever");M.create=r=>new M({typeName:m.ZodNever,..._(r)});var le=class extends g{_parse(e){if(this._getType(e)!==f.undefined){let n=this._getOrReturnCtx(e);return p(n,{code:d.invalid_type,expected:f.void,received:n.parsedType}),y}return O(e.data)}};c(le,"ZodVoid");le.create=r=>new le({typeName:m.ZodVoid,..._(r)});var C=class extends g{_parse(e){let{ctx:t,status:n}=this._processInputParams(e),s=this._def;if(t.parsedType!==f.array)return p(t,{code:d.invalid_type,expected:f.array,received:t.parsedType}),y;if(s.exactLength!==null){let i=t.data.length>s.exactLength.value,o=t.data.length<s.exactLength.value;(i||o)&&(p(t,{code:i?d.too_big:d.too_small,minimum:o?s.exactLength.value:void 0,maximum:i?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(p(t,{code:d.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(p(t,{code:d.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),t.common.async)return Promise.all(t.data.map((i,o)=>s.type._parseAsync(new P(t,i,t.path,o)))).then(i=>E.mergeArray(n,i));let a=t.data.map((i,o)=>s.type._parseSync(new P(t,i,t.path,o)));return E.mergeArray(n,a)}get element(){return this._def.type}min(e,t){return new C({...this._def,minLength:{value:e,message:v.toString(t)}})}max(e,t){return new C({...this._def,maxLength:{value:e,message:v.toString(t)}})}length(e,t){return new C({...this._def,exactLength:{value:e,message:v.toString(t)}})}nonempty(e){return this.min(1,e)}};c(C,"ZodArray");C.create=(r,e)=>new C({type:r,minLength:null,maxLength:null,exactLength:null,typeName:m.ZodArray,..._(e)});var Pe;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(Pe||(Pe={}));var tt=c(r=>e=>new x({...r,shape:()=>({...r.shape(),...e})}),"AugmentFactory");function ye(r){if(r instanceof x){let e={};for(let t in r.shape){let n=r.shape[t];e[t]=j.create(ye(n))}return new x({...r._def,shape:()=>e})}else return r instanceof C?C.create(ye(r.element)):r instanceof j?j.create(ye(r.unwrap())):r instanceof B?B.create(ye(r.unwrap())):r instanceof A?A.create(r.items.map(e=>ye(e))):r}c(ye,"deepPartialify");var x=class extends g{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=tt(this._def),this.extend=tt(this._def)}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),t=b.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==f.object){let l=this._getOrReturnCtx(e);return p(l,{code:d.invalid_type,expected:f.object,received:l.parsedType}),y}let{status:n,ctx:s}=this._processInputParams(e),{shape:a,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof M&&this._def.unknownKeys==="strip"))for(let l in s.data)i.includes(l)||o.push(l);let u=[];for(let l of i){let h=a[l],w=s.data[l];u.push({key:{status:"valid",value:l},value:h._parse(new P(s,w,s.path,l)),alwaysSet:l in s.data})}if(this._def.catchall instanceof M){let l=this._def.unknownKeys;if(l==="passthrough")for(let h of o)u.push({key:{status:"valid",value:h},value:{status:"valid",value:s.data[h]}});else if(l==="strict")o.length>0&&(p(s,{code:d.unrecognized_keys,keys:o}),n.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let l=this._def.catchall;for(let h of o){let w=s.data[h];u.push({key:{status:"valid",value:h},value:l._parse(new P(s,w,s.path,h)),alwaysSet:h in s.data})}}return s.common.async?Promise.resolve().then(async()=>{let l=[];for(let h of u){let w=await h.key;l.push({key:w,value:await h.value,alwaysSet:h.alwaysSet})}return l}).then(l=>E.mergeObjectSync(n,l)):E.mergeObjectSync(n,u)}get shape(){return this._def.shape()}strict(e){return v.errToObj,new x({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var s,a,i,o;let u=(i=(a=(s=this._def).errorMap)===null||a===void 0?void 0:a.call(s,t,n).message)!==null&&i!==void 0?i:n.defaultError;return t.code==="unrecognized_keys"?{message:(o=v.errToObj(e).message)!==null&&o!==void 0?o:u}:{message:u}}}:{}})}strip(){return new x({...this._def,unknownKeys:"strip"})}passthrough(){return new x({...this._def,unknownKeys:"passthrough"})}setKey(e,t){return this.augment({[e]:t})}merge(e){return new x({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>Pe.mergeShapes(this._def.shape(),e._def.shape()),typeName:m.ZodObject})}catchall(e){return new x({...this._def,catchall:e})}pick(e){let t={};return b.objectKeys(e).map(n=>{this.shape[n]&&(t[n]=this.shape[n])}),new x({...this._def,shape:()=>t})}omit(e){let t={};return b.objectKeys(this.shape).map(n=>{b.objectKeys(e).indexOf(n)===-1&&(t[n]=this.shape[n])}),new x({...this._def,shape:()=>t})}deepPartial(){return ye(this)}partial(e){let t={};if(e)return b.objectKeys(this.shape).map(n=>{b.objectKeys(e).indexOf(n)===-1?t[n]=this.shape[n]:t[n]=this.shape[n].optional()}),new x({...this._def,shape:()=>t});for(let n in this.shape){let s=this.shape[n];t[n]=s.optional()}return new x({...this._def,shape:()=>t})}required(e){let t={};if(e)b.objectKeys(this.shape).map(n=>{if(b.objectKeys(e).indexOf(n)===-1)t[n]=this.shape[n];else{let a=this.shape[n];for(;a instanceof j;)a=a._def.innerType;t[n]=a}});else for(let n in this.shape){let a=this.shape[n];for(;a instanceof j;)a=a._def.innerType;t[n]=a}return new x({...this._def,shape:()=>t})}keyof(){return at(b.objectKeys(this.shape))}};c(x,"ZodObject");x.create=(r,e)=>new x({shape:()=>r,unknownKeys:"strip",catchall:M.create(),typeName:m.ZodObject,..._(e)});x.strictCreate=(r,e)=>new x({shape:()=>r,unknownKeys:"strict",catchall:M.create(),typeName:m.ZodObject,..._(e)});x.lazycreate=(r,e)=>new x({shape:r,unknownKeys:"strip",catchall:M.create(),typeName:m.ZodObject,..._(e)});var G=class extends g{_parse(e){let{ctx:t}=this._processInputParams(e),n=this._def.options;function s(a){for(let o of a)if(o.result.status==="valid")return o.result;for(let o of a)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;let i=a.map(o=>new I(o.ctx.common.issues));return p(t,{code:d.invalid_union,unionErrors:i}),y}if(c(s,"handleResults"),t.common.async)return Promise.all(n.map(async a=>{let i={...t,common:{...t.common,issues:[]},parent:null};return{result:await a._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}})).then(s);{let a,i=[];for(let u of n){let l={...t,common:{...t.common,issues:[]},parent:null},h=u._parseSync({data:t.data,path:t.path,parent:l});if(h.status==="valid")return h;h.status==="dirty"&&!a&&(a={result:h,ctx:l}),l.common.issues.length&&i.push(l.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;let o=i.map(u=>new I(u));return p(t,{code:d.invalid_union,unionErrors:o}),y}}get options(){return this._def.options}};c(G,"ZodUnion");G.create=(r,e)=>new G({options:r,typeName:m.ZodUnion,..._(e)});var Ee=c(r=>r instanceof te?Ee(r.schema):r instanceof N?Ee(r.innerType()):r instanceof re?[r.value]:r instanceof ne?r.options:r instanceof se?Object.keys(r.enum):r instanceof ae?Ee(r._def.innerType):r instanceof K?[void 0]:r instanceof Q?[null]:null,"getDiscriminator"),de=class extends g{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.object)return p(t,{code:d.invalid_type,expected:f.object,received:t.parsedType}),y;let n=this.discriminator,s=t.data[n],a=this.optionsMap.get(s);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):(p(t,{code:d.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),y)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){let s=new Map;for(let a of t){let i=Ee(a.shape[e]);if(!i)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let o of i){if(s.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);s.set(o,a)}}return new de({typeName:m.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,..._(n)})}};c(de,"ZodDiscriminatedUnion");function qe(r,e){let t=J(r),n=J(e);if(r===e)return{valid:!0,data:r};if(t===f.object&&n===f.object){let s=b.objectKeys(e),a=b.objectKeys(r).filter(o=>s.indexOf(o)!==-1),i={...r,...e};for(let o of a){let u=qe(r[o],e[o]);if(!u.valid)return{valid:!1};i[o]=u.data}return{valid:!0,data:i}}else if(t===f.array&&n===f.array){if(r.length!==e.length)return{valid:!1};let s=[];for(let a=0;a<r.length;a++){let i=r[a],o=e[a],u=qe(i,o);if(!u.valid)return{valid:!1};s.push(u.data)}return{valid:!0,data:s}}else return t===f.date&&n===f.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}c(qe,"mergeValues");var X=class extends g{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),s=c((a,i)=>{if(ze(a)||ze(i))return y;let o=qe(a.value,i.value);return o.valid?((Ue(a)||Ue(i))&&t.dirty(),{status:t.value,value:o.data}):(p(n,{code:d.invalid_intersection_types}),y)},"handleParsed");return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([a,i])=>s(a,i)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};c(X,"ZodIntersection");X.create=(r,e,t)=>new X({left:r,right:e,typeName:m.ZodIntersection,..._(t)});var A=class extends g{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.array)return p(n,{code:d.invalid_type,expected:f.array,received:n.parsedType}),y;if(n.data.length<this._def.items.length)return p(n,{code:d.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),y;!this._def.rest&&n.data.length>this._def.items.length&&(p(n,{code:d.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());let a=n.data.map((i,o)=>{let u=this._def.items[o]||this._def.rest;return u?u._parse(new P(n,i,n.path,o)):null}).filter(i=>!!i);return n.common.async?Promise.all(a).then(i=>E.mergeArray(t,i)):E.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new A({...this._def,rest:e})}};c(A,"ZodTuple");A.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new A({items:r,typeName:m.ZodTuple,rest:null,..._(e)})};var ee=class extends g{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.object)return p(n,{code:d.invalid_type,expected:f.object,received:n.parsedType}),y;let s=[],a=this._def.keyType,i=this._def.valueType;for(let o in n.data)s.push({key:a._parse(new P(n,o,n.path,o)),value:i._parse(new P(n,n.data[o],n.path,o))});return n.common.async?E.mergeObjectAsync(t,s):E.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof g?new ee({keyType:e,valueType:t,typeName:m.ZodRecord,..._(n)}):new ee({keyType:D.create(),valueType:e,typeName:m.ZodRecord,..._(t)})}};c(ee,"ZodRecord");var fe=class extends g{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.map)return p(n,{code:d.invalid_type,expected:f.map,received:n.parsedType}),y;let s=this._def.keyType,a=this._def.valueType,i=[...n.data.entries()].map(([o,u],l)=>({key:s._parse(new P(n,o,n.path,[l,"key"])),value:a._parse(new P(n,u,n.path,[l,"value"]))}));if(n.common.async){let o=new Map;return Promise.resolve().then(async()=>{for(let u of i){let l=await u.key,h=await u.value;if(l.status==="aborted"||h.status==="aborted")return y;(l.status==="dirty"||h.status==="dirty")&&t.dirty(),o.set(l.value,h.value)}return{status:t.value,value:o}})}else{let o=new Map;for(let u of i){let l=u.key,h=u.value;if(l.status==="aborted"||h.status==="aborted")return y;(l.status==="dirty"||h.status==="dirty")&&t.dirty(),o.set(l.value,h.value)}return{status:t.value,value:o}}}};c(fe,"ZodMap");fe.create=(r,e,t)=>new fe({valueType:e,keyType:r,typeName:m.ZodMap,..._(t)});var q=class extends g{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.set)return p(n,{code:d.invalid_type,expected:f.set,received:n.parsedType}),y;let s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(p(n,{code:d.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(p(n,{code:d.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());let a=this._def.valueType;function i(u){let l=new Set;for(let h of u){if(h.status==="aborted")return y;h.status==="dirty"&&t.dirty(),l.add(h.value)}return{status:t.value,value:l}}c(i,"finalizeSet");let o=[...n.data.values()].map((u,l)=>a._parse(new P(n,u,n.path,l)));return n.common.async?Promise.all(o).then(u=>i(u)):i(o)}min(e,t){return new q({...this._def,minSize:{value:e,message:v.toString(t)}})}max(e,t){return new q({...this._def,maxSize:{value:e,message:v.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};c(q,"ZodSet");q.create=(r,e)=>new q({valueType:r,minSize:null,maxSize:null,typeName:m.ZodSet,..._(e)});var H=class extends g{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.function)return p(t,{code:d.invalid_type,expected:f.function,received:t.parsedType}),y;function n(o,u){return Oe({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Re(),be].filter(l=>!!l),issueData:{code:d.invalid_arguments,argumentsError:u}})}c(n,"makeArgsIssue");function s(o,u){return Oe({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Re(),be].filter(l=>!!l),issueData:{code:d.invalid_return_type,returnTypeError:u}})}c(s,"makeReturnsIssue");let a={errorMap:t.common.contextualErrorMap},i=t.data;return this._def.returns instanceof W?O(async(...o)=>{let u=new I([]),l=await this._def.args.parseAsync(o,a).catch(T=>{throw u.addIssue(n(o,T)),u}),h=await i(...l);return await this._def.returns._def.type.parseAsync(h,a).catch(T=>{throw u.addIssue(s(h,T)),u})}):O((...o)=>{let u=this._def.args.safeParse(o,a);if(!u.success)throw new I([n(o,u.error)]);let l=i(...u.data),h=this._def.returns.safeParse(l,a);if(!h.success)throw new I([s(l,h.error)]);return h.data})}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new H({...this._def,args:A.create(e).rest(U.create())})}returns(e){return new H({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new H({args:e||A.create([]).rest(U.create()),returns:t||U.create(),typeName:m.ZodFunction,..._(n)})}};c(H,"ZodFunction");var te=class extends g{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};c(te,"ZodLazy");te.create=(r,e)=>new te({getter:r,typeName:m.ZodLazy,..._(e)});var re=class extends g{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return p(t,{code:d.invalid_literal,expected:this._def.value}),y}return{status:"valid",value:e.data}}get value(){return this._def.value}};c(re,"ZodLiteral");re.create=(r,e)=>new re({value:r,typeName:m.ZodLiteral,..._(e)});function at(r,e){return new ne({values:r,typeName:m.ZodEnum,..._(e)})}c(at,"createZodEnum");var ne=class extends g{_parse(e){if(typeof e.data!="string"){let t=this._getOrReturnCtx(e),n=this._def.values;return p(t,{expected:b.joinValues(n),received:t.parsedType,code:d.invalid_type}),y}if(this._def.values.indexOf(e.data)===-1){let t=this._getOrReturnCtx(e),n=this._def.values;return p(t,{received:t.data,code:d.invalid_enum_value,options:n}),y}return O(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}};c(ne,"ZodEnum");ne.create=at;var se=class extends g{_parse(e){let t=b.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==f.string&&n.parsedType!==f.number){let s=b.objectValues(t);return p(n,{expected:b.joinValues(s),received:n.parsedType,code:d.invalid_type}),y}if(t.indexOf(e.data)===-1){let s=b.objectValues(t);return p(n,{received:n.data,code:d.invalid_enum_value,options:s}),y}return O(e.data)}get enum(){return this._def.values}};c(se,"ZodNativeEnum");se.create=(r,e)=>new se({values:r,typeName:m.ZodNativeEnum,..._(e)});var W=class extends g{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.promise&&t.common.async===!1)return p(t,{code:d.invalid_type,expected:f.promise,received:t.parsedType}),y;let n=t.parsedType===f.promise?t.data:Promise.resolve(t.data);return O(n.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}};c(W,"ZodPromise");W.create=(r,e)=>new W({type:r,typeName:m.ZodPromise,..._(e)});var N=class extends g{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===m.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:n}=this._processInputParams(e),s=this._def.effect||null;if(s.type==="preprocess"){let i=s.transform(n.data);return n.common.async?Promise.resolve(i).then(o=>this._def.schema._parseAsync({data:o,path:n.path,parent:n})):this._def.schema._parseSync({data:i,path:n.path,parent:n})}let a={addIssue:i=>{p(n,i),i.fatal?t.abort():t.dirty()},get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),s.type==="refinement"){let i=c(o=>{let u=s.refinement(o,a);if(n.common.async)return Promise.resolve(u);if(u instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o},"executeRefinement");if(n.common.async===!1){let o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?y:(o.status==="dirty"&&t.dirty(),i(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?y:(o.status==="dirty"&&t.dirty(),i(o.value).then(()=>({status:t.value,value:o.value}))))}if(s.type==="transform")if(n.common.async===!1){let i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!Ce(i))return i;let o=s.transform(i.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(i=>Ce(i)?Promise.resolve(s.transform(i.value,a)).then(o=>({status:t.value,value:o})):i);b.assertNever(s)}};c(N,"ZodEffects");N.create=(r,e,t)=>new N({schema:r,typeName:m.ZodEffects,effect:e,..._(t)});N.createWithPreprocess=(r,e,t)=>new N({schema:e,effect:{type:"preprocess",transform:r},typeName:m.ZodEffects,..._(t)});var j=class extends g{_parse(e){return this._getType(e)===f.undefined?O(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};c(j,"ZodOptional");j.create=(r,e)=>new j({innerType:r,typeName:m.ZodOptional,..._(e)});var B=class extends g{_parse(e){return this._getType(e)===f.null?O(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};c(B,"ZodNullable");B.create=(r,e)=>new B({innerType:r,typeName:m.ZodNullable,..._(e)});var ae=class extends g{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return t.parsedType===f.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};c(ae,"ZodDefault");ae.create=(r,e)=>new ae({innerType:r,typeName:m.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,..._(e)});var pe=class extends g{_parse(e){let{ctx:t}=this._processInputParams(e),n=this._def.innerType._parse({data:t.data,path:t.path,parent:t});return Ne(n)?n.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.defaultValue()})):{status:"valid",value:n.status==="valid"?n.value:this._def.defaultValue()}}removeDefault(){return this._def.innerType}};c(pe,"ZodCatch");pe.create=(r,e)=>new pe({innerType:r,typeName:m.ZodCatch,defaultValue:typeof e.default=="function"?e.default:()=>e.default,..._(e)});var he=class extends g{_parse(e){if(this._getType(e)!==f.nan){let n=this._getOrReturnCtx(e);return p(n,{code:d.invalid_type,expected:f.nan,received:n.parsedType}),y}return{status:"valid",value:e.data}}};c(he,"ZodNaN");he.create=r=>new he({typeName:m.ZodNaN,..._(r)});var It=Symbol("zod_brand"),ve=class extends g{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}};c(ve,"ZodBranded");var ie=class extends g{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return c(async()=>{let a=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?y:a.status==="dirty"?(t.dirty(),st(a.value)):this._def.out._parseAsync({data:a.value,path:n.path,parent:n})},"handleAsync")();{let s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?y:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,t){return new ie({in:e,out:t,typeName:m.ZodPipeline})}};c(ie,"ZodPipeline");var it=c((r,e={},t)=>r?Z.create().superRefine((n,s)=>{if(!r(n)){let a=typeof e=="function"?e(n):e,i=typeof a=="string"?{message:a}:a;s.addIssue({code:"custom",...i,fatal:t})}}):Z.create(),"custom"),Dt={object:x.lazycreate},m;(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"})(m||(m={}));var Mt=c((r,e={message:`Input not instance of ${r.name}`})=>it(t=>t instanceof r,e,!0),"instanceOfType"),ot=D.create,ct=L.create,Lt=he.create,$t=Y.create,ut=F.create,Vt=z.create,zt=ue.create,Ut=K.create,qt=Q.create,Bt=Z.create,Zt=U.create,Ht=M.create,Wt=le.create,Jt=C.create,Yt=x.create,Ft=x.strictCreate,Kt=G.create,Qt=de.create,Gt=X.create,Xt=A.create,er=ee.create,tr=fe.create,rr=q.create,nr=H.create,sr=te.create,ar=re.create,ir=ne.create,or=se.create,cr=W.create,rt=N.create,ur=j.create,lr=B.create,dr=N.createWithPreprocess,fr=ie.create,pr=c(()=>ot().optional(),"ostring"),hr=c(()=>ct().optional(),"onumber"),mr=c(()=>ut().optional(),"oboolean"),yr={string:r=>D.create({...r,coerce:!0}),number:r=>L.create({...r,coerce:!0}),boolean:r=>F.create({...r,coerce:!0}),bigint:r=>Y.create({...r,coerce:!0}),date:r=>z.create({...r,coerce:!0})},gr=y,me=Object.freeze({__proto__:null,defaultErrorMap:be,setErrorMap:Rt,getErrorMap:Re,makeIssue:Oe,EMPTY_PATH:Ot,addIssueToContext:p,ParseStatus:E,INVALID:y,DIRTY:st,OK:O,isAborted:ze,isDirty:Ue,isValid:Ce,isAsync:Ne,get util(){return b},ZodParsedType:f,getParsedType:J,ZodType:g,ZodString:D,ZodNumber:L,ZodBigInt:Y,ZodBoolean:F,ZodDate:z,ZodSymbol:ue,ZodUndefined:K,ZodNull:Q,ZodAny:Z,ZodUnknown:U,ZodNever:M,ZodVoid:le,ZodArray:C,get objectUtil(){return Pe},ZodObject:x,ZodUnion:G,ZodDiscriminatedUnion:de,ZodIntersection:X,ZodTuple:A,ZodRecord:ee,ZodMap:fe,ZodSet:q,ZodFunction:H,ZodLazy:te,ZodLiteral:re,ZodEnum:ne,ZodNativeEnum:se,ZodPromise:W,ZodEffects:N,ZodTransformer:N,ZodOptional:j,ZodNullable:B,ZodDefault:ae,ZodCatch:pe,ZodNaN:he,BRAND:It,ZodBranded:ve,ZodPipeline:ie,custom:it,Schema:g,ZodSchema:g,late:Dt,get ZodFirstPartyTypeKind(){return m},coerce:yr,any:Bt,array:Jt,bigint:$t,boolean:ut,date:Vt,discriminatedUnion:Qt,effect:rt,enum:ir,function:nr,instanceof:Mt,intersection:Gt,lazy:sr,literal:ar,map:tr,nan:Lt,nativeEnum:or,never:Ht,null:qt,nullable:lr,number:ct,object:Yt,oboolean:mr,onumber:hr,optional:ur,ostring:pr,pipeline:fr,preprocess:dr,promise:cr,record:er,set:rr,strictObject:Ft,string:ot,symbol:zt,transformer:rt,tuple:Xt,undefined:Ut,union:Kt,unknown:Zt,void:Wt,NEVER:gr,ZodIssueCode:d,quotelessJson:Et,ZodError:I});var _r=me.object({_id:me.string().optional(),ownerDid:me.string(),name:me.string(),did:me.string().optional(),endpoint:me.string().optional()});function vr(r){return r}c(vr,"identity");function br(r){return r.length===0?vr:r.length===1?r[0]:c(function(t){return r.reduce((n,s)=>s(n),t)},"piped")}c(br,"pipeFromArray");function $(r){let e={subscribe(t){let n=null,s=!1,a=!1,i=!1;function o(){if(n===null){i=!0;return}a||(a=!0,typeof n=="function"?n():n&&n.unsubscribe())}return c(o,"unsubscribe"),n=r({next(u){s||t.next?.(u)},error(u){s||(s=!0,t.error?.(u),o())},complete(){s||(s=!0,t.complete?.(),o())}}),i&&o(),{unsubscribe:o}},pipe(...t){return br(t)(e)}};return e}c($,"observable");function lt(r){return e=>{let t=0,n=null,s=[];function a(){n||(n=e.subscribe({next(o){for(let u of s)u.next?.(o)},error(o){for(let u of s)u.error?.(o)},complete(){for(let o of s)o.complete?.()}}))}c(a,"startIfNeeded");function i(){if(t===0&&n){let o=n;n=null,o.unsubscribe()}}return c(i,"resetIfNeeded"),{subscribe(o){return t++,s.push(o),a(),{unsubscribe(){t--,i();let u=s.findIndex(l=>l===o);u>-1&&s.splice(u,1)}}}}}}c(lt,"share");var ge=class extends Error{constructor(e){super(e),this.name="ObservableAbortError",Object.setPrototypeOf(this,ge.prototype)}};c(ge,"ObservableAbortError");function dt(r){let e;return{promise:new Promise((n,s)=>{let a=!1;function i(){a||(a=!0,s(new ge("This operation was aborted.")),o.unsubscribe())}c(i,"onDone");let o=r.subscribe({next(u){a=!0,n(u),i()},error(u){a=!0,s(u),i()},complete(){a=!0,i()}});e=i}),abort:e}}c(dt,"observableToPromise");function ft(r){return $(e=>{function t(s=0,a=r.op){let i=r.links[s];if(!i)throw new Error("No more links to execute - did you forget to add an ending link?");return i({op:a,next(u){return t(s+1,u)}})}return c(t,"execute"),t().subscribe(e)})}c(ft,"createChain");function Be(r){let e=Object.create(null);for(let t in r){let n=r[t];e[n]=t}return e}c(Be,"invert");var Ae={PARSE_ERROR:-32700,BAD_REQUEST:-32600,INTERNAL_SERVER_ERROR:-32603,NOT_IMPLEMENTED:-32603,UNAUTHORIZED:-32001,FORBIDDEN:-32003,NOT_FOUND:-32004,METHOD_NOT_SUPPORTED:-32005,TIMEOUT:-32008,CONFLICT:-32009,PRECONDITION_FAILED:-32012,PAYLOAD_TOO_LARGE:-32013,UNPROCESSABLE_CONTENT:-32022,TOO_MANY_REQUESTS:-32029,CLIENT_CLOSED_REQUEST:-32099},rn=Be(Ae);var an=Be(Ae);var pt=c(()=>{},"noop");function ht(r,e){return new Proxy(pt,{get(n,s){if(!(typeof s!="string"||s==="then"))return ht(r,[...e,s])},apply(n,s,a){let i=e[e.length-1]==="apply";return r({args:i?a.length>=2?a[1]:[]:a,path:i?e.slice(0,-1):e})}})}c(ht,"createInnerProxy");var Ze=c(r=>ht(r,[]),"createRecursiveProxy"),He=c(r=>new Proxy(pt,{get(e,t){if(!(typeof t!="string"||t==="then"))return r(t)}}),"createFlatProxy");function xr(r){return!!r&&!Array.isArray(r)&&typeof r=="object"}c(xr,"isObject");var je=class extends Error{};c(je,"UnknownCauseError");function We(r){if(r instanceof Error)return r;let e=typeof r;if(!(e==="undefined"||e==="function"||r===null)){if(e!=="object")return new Error(String(r));if(xr(r)){let t=new je;for(let n in r)t[n]=r[n];return t}}}c(We,"getCauseFromUnknown");function xe(r){return!!r&&!Array.isArray(r)&&typeof r=="object"}c(xe,"isObject");function wr(r,e){if("error"in r){let n=e.transformer.deserialize(r.error);return{ok:!1,error:{...r,error:n}}}let t={...r.result,...(!r.result.type||r.result.type==="data")&&{type:"data",data:e.transformer.deserialize(r.result.data)}};return{ok:!0,result:t}}c(wr,"transformResultInner");var _e=class extends Error{constructor(){super("Unable to transform response from server")}};c(_e,"TransformResultError");function we(r,e){let t;try{t=wr(r,e)}catch{throw new _e}if(!t.ok&&(!xe(t.error.error)||typeof t.error.error.code!="number"))throw new _e;if(t.ok&&!xe(t.result))throw new _e;return t}c(we,"transformResult");function Tr(r){return r instanceof k||r instanceof Error&&r.name==="TRPCClientError"}c(Tr,"isTRPCClientError");function kr(r){return xe(r)&&xe(r.error)&&typeof r.error.code=="number"&&typeof r.error.message=="string"}c(kr,"isTRPCErrorResponse");var k=class extends Error{static from(e,t={}){let n=e;return Tr(n)?(t.meta&&(n.meta={...n.meta,...t.meta}),n):kr(n)?new k(n.error.message,{...t,result:n}):n instanceof Error?new k(n.message,{...t,cause:We(n)}):new k("Unknown error",{...t,cause:n})}constructor(e,t){let n=t?.cause;super(e,{cause:n}),this.meta=t?.meta,this.cause=n,this.shape=t?.result?.error,this.data=t?.result?.error.data,this.name="TRPCClientError",Object.setPrototypeOf(this,k.prototype)}};c(k,"TRPCClientError");var mt=c(r=>typeof r=="function","isFunction");function yt(r){if(r)return r;if(typeof window<"u"&&mt(window.fetch))return window.fetch;if(typeof globalThis<"u"&&mt(globalThis.fetch))return globalThis.fetch;throw new Error("No fetch implementation found")}c(yt,"getFetch");function Sr(r){return r||(typeof window<"u"&&window.AbortController?window.AbortController:typeof globalThis<"u"&&globalThis.AbortController?globalThis.AbortController:null)}c(Sr,"getAbortController");function Ie(r){return{url:r.url.toString().replace(/\/$/,""),fetch:r.fetch,AbortController:Sr(r.AbortController)}}c(Ie,"resolveHTTPLinkOptions");function Er(r){let e={};for(let t=0;t<r.length;t++){let n=r[t];e[t]=n}return e}c(Er,"arrayToDict");var Rr={query:"GET",mutation:"POST"};function gt(r){return"input"in r?r.runtime.transformer.serialize(r.input):Er(r.inputs.map(e=>r.runtime.transformer.serialize(e)))}c(gt,"getInput");var Te=c(r=>{let e=r.url+"/"+r.path,t=[];if("inputs"in r&&t.push("batch=1"),r.type==="query"){let n=gt(r);n!==void 0&&t.push(`input=${encodeURIComponent(JSON.stringify(n))}`)}return t.length&&(e+="?"+t.join("&")),e},"getUrl"),Je=c(r=>{if(r.type==="query")return;let e=gt(r);return e!==void 0?JSON.stringify(e):void 0},"getBody"),De=c(r=>Fe({...r,contentTypeHeader:"application/json",getUrl:Te,getBody:Je}),"jsonHttpRequester");async function Ye(r,e){let t=r.getUrl(r),n=r.getBody(r),{type:s}=r,a=await r.headers();if(s==="subscription")throw new Error("Subscriptions should use wsLink");let i={...r.contentTypeHeader?{"content-type":r.contentTypeHeader}:{},...r.batchModeHeader?{"trpc-batch-mode":r.batchModeHeader}:{},...a};return yt(r.fetch)(t,{method:Rr[s],signal:e?.signal,body:n,headers:i})}c(Ye,"fetchHTTPResponse");function Fe(r){let e=r.AbortController?new r.AbortController:null,t={},n=!1;return{promise:new Promise((i,o)=>{Ye(r,e).then(u=>(t.response=u,n=!0,u.json())).then(u=>{t.responseJSON=u,i({json:u,meta:t})}).catch(u=>{n=!0,o(k.from(u,{meta:t}))})}),cancel:c(()=>{n||e?.abort()},"cancel")}}c(Fe,"httpRequest");var Ke=c(()=>{throw new Error("Something went wrong. Please submit an issue at https://github.com/trpc/trpc/issues/new")},"throwFatalError");function Qe(r){let e=null,t=null,n=c(()=>{clearTimeout(t),t=null,e=null},"destroyTimerAndPendingItems");function s(o){let u=[[]],l=0;for(;;){let h=o[l];if(!h)break;let w=u[u.length-1];if(h.aborted){h.reject?.(new Error("Aborted")),l++;continue}if(r.validate(w.concat(h).map(S=>S.key))){w.push(h),l++;continue}if(w.length===0){h.reject?.(new Error("Input is too big for a single dispatch")),l++;continue}u.push([])}return u}c(s,"groupItems");function a(){let o=s(e);n();for(let u of o){if(!u.length)continue;let l={items:u,cancel:Ke};for(let S of u)S.batch=l;let h=c((S,R)=>{let V=l.items[S];V.resolve?.(R),V.batch=null,V.reject=null,V.resolve=null},"unitResolver"),{promise:w,cancel:T}=r.fetch(l.items.map(S=>S.key),h);l.cancel=T,w.then(S=>{for(let R=0;R<S.length;R++){let V=S[R];h(R,V)}for(let R of l.items)R.reject?.(new Error("Missing result")),R.batch=null}).catch(S=>{for(let R of l.items)R.reject?.(S),R.batch=null})}}c(a,"dispatch");function i(o){let u={aborted:!1,key:o,batch:null,resolve:Ke,reject:Ke},l=new Promise((w,T)=>{u.reject=T,u.resolve=w,e||(e=[]),e.push(u)});return t||(t=setTimeout(a)),{promise:l,cancel:c(()=>{u.aborted=!0,u.batch?.items.every(w=>w.aborted)&&(u.batch.cancel(),u.batch=null)},"cancel")}}return c(i,"load"),{load:i}}c(Qe,"dataLoader");function Ge(r){return c(function(t){let n=Ie(t),s=t.maxURLLength??1/0;return a=>{let i=c(w=>{let T=c(R=>{if(s===1/0)return!0;let V=R.map(ce=>ce.path).join(","),ke=R.map(ce=>ce.input);return Te({...n,runtime:a,type:w,path:V,inputs:ke}).length<=s},"validate"),S=r({...n,runtime:a,type:w,opts:t});return{validate:T,fetch:S}},"batchLoader"),o=Qe(i("query")),u=Qe(i("mutation")),l=Qe(i("subscription")),h={query:o,subscription:l,mutation:u};return({op:w})=>$(T=>{let S=h[w.type],{promise:R,cancel:V}=S.load(w),ke;return R.then(oe=>{ke=oe;let ce=we(oe.json,a);if(!ce.ok){T.error(k.from(ce.error,{meta:oe.meta}));return}T.next({context:oe.meta,result:ce.result}),T.complete()}).catch(oe=>{T.error(k.from(oe,{meta:ke?.meta}))}),()=>{V()}})}},"httpBatchLink")}c(Ge,"createHTTPBatchLink");var Or=c(r=>e=>{let t=e.map(i=>i.path).join(","),n=e.map(i=>i.input),{promise:s,cancel:a}=De({...r,path:t,inputs:n,headers(){return r.opts.headers?typeof r.opts.headers=="function"?r.opts.headers({opList:e}):r.opts.headers:{}}});return{promise:s.then(i=>(Array.isArray(i.json)?i.json:e.map(()=>i.json)).map(l=>({meta:i.meta,json:l}))),cancel:a}},"batchRequester"),Me=Ge(Or);function Le(r){return e=>{let t=Ie(e);return n=>({op:s})=>$(a=>{let{path:i,input:o,type:u}=s,{promise:l,cancel:h}=r.requester({...t,runtime:n,type:u,path:i,input:o,headers(){return e.headers?typeof e.headers=="function"?e.headers({op:s}):e.headers:{}}}),w;return l.then(T=>{w=T.meta;let S=we(T.json,n);if(!S.ok){a.error(k.from(S.error,{meta:w}));return}a.next({context:T.meta,result:S.result}),a.complete()}).catch(T=>{a.error(k.from(T,{meta:w}))}),()=>{h()}})}}c(Le,"httpLinkFactory");var Cr=Le({requester:De});var $e=class{$request({type:e,input:t,path:n,context:s={}}){return ft({links:this.links,op:{id:++this.requestId,type:e,path:n,input:t,context:s}}).pipe(lt())}requestAsPromise(e){let t=this.$request(e),{promise:n,abort:s}=dt(t);return new Promise((i,o)=>{e.signal?.addEventListener("abort",s),n.then(u=>{i(u.result.data)}).catch(u=>{o(k.from(u))})})}query(e,t,n){return this.requestAsPromise({type:"query",path:e,input:t,context:n?.context,signal:n?.signal})}mutation(e,t,n){return this.requestAsPromise({type:"mutation",path:e,input:t,context:n?.context,signal:n?.signal})}subscription(e,t,n){return this.$request({type:"subscription",path:e,input:t,context:n?.context}).subscribe({next(a){a.result.type==="started"?n.onStarted?.():a.result.type==="stopped"?n.onStopped?.():n.onData?.(a.result.data)},error(a){n.onError?.(a)},complete(){n.onComplete?.()}})}constructor(e){this.requestId=0;let t=(()=>{let n=e.transformer;return n?"input"in n?e.transformer:{input:n,output:n}:{input:{serialize:s=>s,deserialize:s=>s},output:{serialize:s=>s,deserialize:s=>s}}})();this.runtime={transformer:{serialize:n=>t.input.serialize(n),deserialize:n=>t.output.deserialize(n)},combinedTransformer:t},this.links=e.links.map(n=>n(this.runtime))}};c($e,"TRPCUntypedClient");var Nr={query:"query",mutate:"mutation",subscribe:"subscription"},Pr=c(r=>Nr[r],"clientCallTypeToProcedureType");function Ar(r){return He(e=>r.hasOwnProperty(e)?r[e]:e==="__untypedClient"?r:Ze(({path:t,args:n})=>{let s=[e,...t],a=Pr(s.pop()),i=s.join(".");return r[a](i,...n)}))}c(Ar,"createTRPCClientProxy");function Xe(r){let e=new $e(r);return Ar(e)}c(Xe,"createTRPCProxyClient");function jr(r){if(r)return r;if(typeof window<"u"&&window.TextDecoder)return new window.TextDecoder;if(typeof globalThis<"u"&&globalThis.TextDecoder)return new globalThis.TextDecoder;throw new Error("No TextDecoder implementation found")}c(jr,"getTextDecoder");async function Ir(r){let e=r.parse??JSON.parse,t=c(n=>{if(r.signal?.aborted||!n||n==="}")return;let s=n.indexOf(":"),a=n.substring(2,s-1),i=n.substring(s+1);r.onSingle(Number(a),e(i))},"onLine");await Dr(r.readableStream,t,r.textDecoder)}c(Ir,"parseJSONStream");async function Dr(r,e,t){let n="",s=c(a=>{let o=t.decode(a).split(`
2
+ `);if(o.length===1)n+=o[0];else if(o.length>1){e(n+o[0]);for(let u=1;u<o.length-1;u++)e(o[u]);n=o[o.length-1]}},"onChunk");"getReader"in r?await Lr(r,s):await Mr(r,s),e(n)}c(Dr,"readLines");function Mr(r,e){return new Promise(t=>{r.on("data",e),r.on("end",t)})}c(Mr,"readNodeChunks");async function Lr(r,e){let t=r.getReader(),n=await t.read();for(;!n.done;)e(n.value),n=await t.read()}c(Lr,"readStandardChunks");var $r=c((r,e)=>{let t=r.AbortController?new r.AbortController:null,n=Ye({...r,contentTypeHeader:"application/json",batchModeHeader:"stream",getUrl:Te,getBody:Je},t),s=c(()=>t?.abort(),"cancel"),a=n.then(async i=>{if(!i.body)throw new Error("Received response without body");let o={response:i};return Ir({readableStream:i.body,onSingle:e,parse:u=>({json:JSON.parse(u),meta:o}),signal:t?.signal,textDecoder:r.textDecoder})});return{cancel:s,promise:a}},"streamingJsonHttpRequester"),Vr=c(r=>{let e=jr(r.opts.textDecoder);return(t,n)=>{let s=t.map(u=>u.path).join(","),a=t.map(u=>u.input),{cancel:i,promise:o}=$r({...r,textDecoder:e,path:s,inputs:a,headers(){return r.opts.headers?typeof r.opts.headers=="function"?r.opts.headers({opList:t}):r.opts.headers:{}}},(u,l)=>{n(u,l)});return{promise:o.then(()=>[]),cancel:i}}},"streamRequester"),ns=Ge(Vr),zr=c(r=>{if("input"in r){if(!(r.input instanceof FormData))throw new Error("Input is not FormData");return r.input}},"getBody"),Ur=c(r=>{if(r.type!=="mutation")throw new Error("We only handle mutations with formdata");return Fe({...r,getUrl(){return`${r.url}/${r.path}`},getBody:zr})},"formDataRequester"),ss=Le({requester:Ur});var qr=Object.defineProperty,Ve=c((r,e)=>qr(r,"name",{value:e,configurable:!0}),"__name"),Br=Ve(r=>()=>({next:e,op:t})=>$(n=>{let s=null,a=0,i=!1,o=Ve(()=>{a+=1,s?.unsubscribe(),s=e(t).subscribe({error:async u=>{if(a>5||u.data?.httpStatus!==401)return n.error(u);await r(),o()},next:u=>n.next(u),complete:()=>{i&&n.complete()}})},"attempt");return o(),()=>{i=!0,s?.unsubscribe()}}),"callbackLink"),_t=Ve(async(r,e)=>{let t=[],n=Xe({links:[Me({url:r,headers:{Authorization:`Bearer ${await e()}`}})]}),s=Ve(async(i=95+Math.round((Math.random()-.5)*5))=>n.utilities.getChallenges.query({amount:i}),"getChallenges");return s().then(i=>t=i),Xe({links:[Br(async()=>{t=await s()}),Me({url:r,headers:async()=>(t.length===0&&t.push(...await s()),{Authorization:`Bearer ${await e(t.pop())}`})})]})},"getClient");var vt=c(async(r,e)=>_t(r,async t=>{let n=await e.invoke.getDidAuthVp({proofFormat:"jwt",challenge:t});if(typeof n!="string")throw new Error("Error getting DID-Auth-JWT!");return n}),"getNewClient"),Zr=c(async(r,e)=>{let t=r,n=t.id.did(),s=await vt(e,t),a=c(async o=>{let u=o.id.did();n!==u&&(s=await vt(e,o),n=u),t=o},"updateLearnCard"),i=t.invoke.getProfile().then(async o=>{o&&await a(t)});return{name:"Simple Signing Authority",displayName:"Simple Signing Authority Plugin",description:"Lets you create and use Signing Authorities",methods:{createSigningAuthority:async(o,u)=>(await i,await a(o),s.signingAuthority.createSigningAuthority.mutate({name:u})),getSigningAuthorities:async o=>(await i,await a(o),s.signingAuthority.signingAuthorities.query()),authorizeSigningAuthority:async(o,u,l)=>(await i,await a(o),s.signingAuthority.authorizeSigningAuthority.mutate({name:u,authorization:l}))}}},"getSimpleSigningPlugin");
3
+ /* istanbul ignore if -- @preserve */
4
+ /* istanbul ignore next -- @preserve */
5
+ //# sourceMappingURL=simple-signing-plugin.cjs.production.min.js.map