@zibby/core 0.1.37 → 0.1.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agents/base.js +85 -230
- package/dist/framework/agents/assistant-strategy.js +9 -67
- package/dist/framework/agents/claude-strategy.js +16 -105
- package/dist/framework/agents/codex-strategy.js +12 -18
- package/dist/framework/agents/cursor-strategy.js +39 -81
- package/dist/framework/agents/gemini-strategy.js +11 -15
- package/dist/framework/agents/index.js +65 -210
- package/dist/framework/agents/utils/cursor-output-formatter.js +4 -8
- package/dist/framework/agents/utils/openai-proxy-formatter.js +5 -43
- package/dist/framework/agents/utils/structured-output-formatter.js +4 -8
- package/dist/framework/code-generator.js +78 -223
- package/dist/framework/function-bridge.js +1 -60
- package/dist/framework/graph-compiler.js +77 -222
- package/dist/framework/graph.js +73 -218
- package/dist/framework/index.js +89 -242
- package/dist/framework/mcp-client.js +2 -56
- package/dist/framework/node-registry.js +68 -213
- package/dist/framework/node.js +70 -215
- package/dist/framework/state-utils.js +1 -5
- package/dist/index.js +187 -332
- package/dist/package.json +35 -36
- package/dist/utils/ast-utils.js +1 -9
- package/dist/utils/node-schema-parser.js +1 -9
- package/package.json +5 -6
- package/templates/browser-test-automation/run-index.mjs +4 -4
- package/templates/code-analysis/nodes/analyze-ticket-node.js +3 -3
- package/templates/code-analysis/nodes/create-pr-node.js +1 -1
- package/templates/code-analysis/nodes/generate-code-node.js +1 -1
- package/templates/code-analysis/nodes/generate-test-cases-node.js +1 -1
- package/templates/code-analysis/nodes/services/prMetaService.js +1 -1
- package/templates/register-nodes.js +1 -1
- package/scripts/export-default-workflows.js +0 -51
- package/scripts/patch-cursor-mcp.js +0 -174
- package/scripts/setup-ci.sh +0 -115
- package/scripts/setup-official-playwright-mcp.sh +0 -173
- package/scripts/test-with-video.sh +0 -49
|
@@ -1,93 +1,51 @@
|
|
|
1
|
-
var
|
|
2
|
-
`);this.buffer=
|
|
3
|
-
`,
|
|
4
|
-
`,this.extractedResult=o)}catch{if(i.includes('"text"')||i.includes('"content"')){let a=i.match(/"text"\s*:\s*"([^"]*)/),s=i.match(/"content"\s*:\s*"([^"]*)/),c=a?a[1]:s?s[1]:null;c&&!this.rawText.includes(c)&&(n+=c,this.rawText+=c)}}return n||null}flush(){if(!this.buffer.trim())return null;let t="";try{let r=JSON.parse(this.buffer);this._emitToolCalls(r);let n=this.extractText(r);n&&(this.rawText+=n,t+=n,this.tryExtractResult(n))}catch{this.rawText+=this.buffer,t+=this.buffer,this.tryExtractResult(this.buffer)}return this.buffer="",t||null}_emitToolCalls(t){if(!this.onToolCall)return;let r=(a,s)=>{if(!a)return;let c=`${a}:${JSON.stringify(s??{})}`;this._lastToolEmit!==c&&(this._lastToolEmit=c,this.onToolCall(a,s??void 0))},n=a=>{if(a!=null){if(typeof a=="object"&&!Array.isArray(a))return a;if(typeof a=="string")try{return JSON.parse(a)}catch{return}}};if(t.type==="tool_use"||t.type==="tool_call"){if(t.name){r(t.name,n(t.input??t.arguments));return}let a=t.tool_call;if(a&&typeof a=="object"&&!Array.isArray(a)){let s=Object.keys(a);if(s.length===1){let c=s[0],u=a[c],l=u&&typeof u=="object"?u.args??u.input??u:void 0;r(c,n(l))}return}return}if(Array.isArray(t.tool_calls)){for(let a of t.tool_calls)r(a.name,n(a.input??a.arguments));return}let i=t.message??t;if(Array.isArray(i?.tool_calls)){for(let a of i.tool_calls)r(a.name,n(a.input??a.arguments));return}let o=i?.content??t.content;if(Array.isArray(o))for(let a of o)(a.type==="tool_use"||a.type==="tool_call")&&a.name&&r(a.name,n(a.input??a.arguments))}extractText(t){if(t.type==="assistant"&&t.message?.content){let r=t.message.content;if(Array.isArray(r))return r.filter(n=>n.type==="text"&&n.text).map(n=>n.text).join("")}return t.type==="thinking"&&t.text||t.text?t.text:t.content&&typeof t.content=="string"?t.content:t.delta?t.delta:null}tryExtractResult(t){if(!t||typeof t!="string")return;let r=[],n=/```json\s*\n?([\s\S]*?)\n?```/g,i;for(;(i=n.exec(t))!==null;){let p=i[1].trim();try{JSON.parse(p),r.push({text:p,source:"markdown"})}catch{}}let o=0,a=0;for(;o<t.length&&(o=t.indexOf("{",o),o!==-1);){let p=0,h=o;for(let v=o;v<t.length;v++)if(t[v]==="{")p++;else if(t[v]==="}"&&(p--,p===0)){h=v,r.push({text:t.substring(o,h+1),source:"brace"}),a++;break}o=h+1}let s=this.extractedResult,c=s?JSON.stringify(s).length:0,u=0,l=-1;for(let p=0;p<r.length;p++){let h=r[p];try{let v=h.text.replace(/,(\s*[}\]])/g,"$1"),A=JSON.parse(v);this.isValidResult(A)&&(u++,c=JSON.stringify(A).length,s=A,l=p)}catch{}}s&&(this.extractedResult=s)}isValidResult(t){if(!t||typeof t!="object"||Array.isArray(t)||t.session_id||t.timestamp_ms||t.type||t.call_id||t.tool_call||t.result&&typeof t.result=="object"&&(t.result.success&&typeof t.result.success=="object"||t.result.error&&typeof t.result.error=="object")||t.args&&typeof t.args=="object")return!1;if(this.zodSchema)try{return this.zodSchema.parse(t),!0}catch{return!1}return!0}getResult(){return this.extractedResult}getRawText(){return this.rawText}static extractResult(t,r=null){let n=new e;n.zodSchema=r,n.processChunk(t),n.flush();let i=n.getResult();return!i&&process.env.LOG_LEVEL==="debug"&&console.error("[StreamingParser] No result extracted from",t?.length||0,"chars"),i}};var Ua=Symbol("Let zodToJsonSchema decide on which parser to use");var Za={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",target:"jsonSchema7",strictUnions:!1,definitions:{},errorMessages:!1,markdownDescription:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref",openAiAnyTypeName:"OpenAiAnyType"},Aa=e=>typeof e=="string"?{...Za,name:e}:{...Za,...e};var Ra=e=>{let t=Aa(e),r=t.name!==void 0?[...t.basePath,t.definitionPath,t.name]:t.basePath;return{...t,flags:{hasReferencedOpenAiAnyType:!1},currentPath:r,propertyPath:void 0,seen:new Map(Object.entries(t.definitions).map(([n,i])=>[i._def,{def:i._def,path:[...t.basePath,t.definitionPath,n],jsonSchema:void 0}]))}};function Pn(e,t,r,n){n?.errorMessages&&r&&(e.errorMessage={...e.errorMessage,[t]:r})}function U(e,t,r,n,i){e[t]=r,Pn(e,t,n,i)}var kr=(e,t)=>{let r=0;for(;r<e.length&&r<t.length&&e[r]===t[r];r++);return[(e.length-r).toString(),...t.slice(r)].join("/")};var N;(function(e){e.assertEqual=i=>{};function t(i){}e.assertIs=t;function r(i){throw new Error}e.assertNever=r,e.arrayToEnum=i=>{let o={};for(let a of i)o[a]=a;return o},e.getValidEnumValues=i=>{let o=e.objectKeys(i).filter(s=>typeof i[i[s]]!="number"),a={};for(let s of o)a[s]=i[s];return e.objectValues(a)},e.objectValues=i=>e.objectKeys(i).map(function(o){return i[o]}),e.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{let o=[];for(let a in i)Object.prototype.hasOwnProperty.call(i,a)&&o.push(a);return o},e.find=(i,o)=>{for(let a of i)if(o(a))return a},e.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&Number.isFinite(i)&&Math.floor(i)===i;function n(i,o=" | "){return i.map(a=>typeof a=="string"?`'${a}'`:a).join(o)}e.joinValues=n,e.jsonStringifyReplacer=(i,o)=>typeof o=="bigint"?o.toString():o})(N||(N={}));var Ca;(function(e){e.mergeShapes=(t,r)=>({...t,...r})})(Ca||(Ca={}));var $=N.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Te=e=>{switch(typeof e){case"undefined":return $.undefined;case"string":return $.string;case"number":return Number.isNaN(e)?$.nan:$.number;case"boolean":return $.boolean;case"function":return $.function;case"bigint":return $.bigint;case"symbol":return $.symbol;case"object":return Array.isArray(e)?$.array:e===null?$.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?$.promise:typeof Map<"u"&&e instanceof Map?$.map:typeof Set<"u"&&e instanceof Set?$.set:typeof Date<"u"&&e instanceof Date?$.date:$.object;default:return $.unknown}};var m=N.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"]);var ue=class e extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=t}format(t){let r=t||function(o){return o.message},n={_errors:[]},i=o=>{for(let a of o.issues)if(a.code==="invalid_union")a.unionErrors.map(i);else if(a.code==="invalid_return_type")i(a.returnTypeError);else if(a.code==="invalid_arguments")i(a.argumentsError);else if(a.path.length===0)n._errors.push(r(a));else{let s=n,c=0;for(;c<a.path.length;){let u=a.path[c];c===a.path.length-1?(s[u]=s[u]||{_errors:[]},s[u]._errors.push(r(a))):s[u]=s[u]||{_errors:[]},s=s[u],c++}}};return i(this),n}static assert(t){if(!(t instanceof e))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,N.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=r=>r.message){let r=Object.create(null),n=[];for(let i of this.issues)if(i.path.length>0){let o=i.path[0];r[o]=r[o]||[],r[o].push(t(i))}else n.push(t(i));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};ue.create=e=>new ue(e);var Rd=(e,t)=>{let r;switch(e.code){case m.invalid_type:e.received===$.undefined?r="Required":r=`Expected ${e.expected}, received ${e.received}`;break;case m.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(e.expected,N.jsonStringifyReplacer)}`;break;case m.unrecognized_keys:r=`Unrecognized key(s) in object: ${N.joinValues(e.keys,", ")}`;break;case m.invalid_union:r="Invalid input";break;case m.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${N.joinValues(e.options)}`;break;case m.invalid_enum_value:r=`Invalid enum value. Expected ${N.joinValues(e.options)}, received '${e.received}'`;break;case m.invalid_arguments:r="Invalid function arguments";break;case m.invalid_return_type:r="Invalid function return type";break;case m.invalid_date:r="Invalid date";break;case m.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(r=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?r=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?r=`Invalid input: must end with "${e.validation.endsWith}"`:N.assertNever(e.validation):e.validation!=="regex"?r=`Invalid ${e.validation}`:r="Invalid";break;case m.too_small:e.type==="array"?r=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?r=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?r=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="bigint"?r=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?r=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:r="Invalid input";break;case m.too_big:e.type==="array"?r=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?r=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?r=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?r=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?r=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:r="Invalid input";break;case m.custom:r="Invalid input";break;case m.invalid_intersection_types:r="Intersection results could not be merged";break;case m.not_multiple_of:r=`Number must be a multiple of ${e.multipleOf}`;break;case m.not_finite:r="Number must be finite";break;default:r=t.defaultError,N.assertNever(e)}return{message:r}},Ce=Rd;var Cd=Ce;function Zt(){return Cd}var Sr=e=>{let{data:t,path:r,errorMaps:n,issueData:i}=e,o=[...r,...i.path||[]],a={...i,path:o};if(i.message!==void 0)return{...i,path:o,message:i.message};let s="",c=n.filter(u=>!!u).slice().reverse();for(let u of c)s=u(a,{data:t,defaultError:s}).message;return{...i,path:o,message:s}};function _(e,t){let r=Zt(),n=Sr({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,r,r===Ce?void 0:Ce].filter(i=>!!i)});e.common.issues.push(n)}var re=class e{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,r){let n=[];for(let i of r){if(i.status==="aborted")return I;i.status==="dirty"&&t.dirty(),n.push(i.value)}return{status:t.value,value:n}}static async mergeObjectAsync(t,r){let n=[];for(let i of r){let o=await i.key,a=await i.value;n.push({key:o,value:a})}return e.mergeObjectSync(t,n)}static mergeObjectSync(t,r){let n={};for(let i of r){let{key:o,value:a}=i;if(o.status==="aborted"||a.status==="aborted")return I;o.status==="dirty"&&t.dirty(),a.status==="dirty"&&t.dirty(),o.value!=="__proto__"&&(typeof a.value<"u"||i.alwaysSet)&&(n[o.value]=a.value)}return{status:t.value,value:n}}},I=Object.freeze({status:"aborted"}),at=e=>({status:"dirty",value:e}),ne=e=>({status:"valid",value:e}),Tn=e=>e.status==="aborted",jn=e=>e.status==="dirty",Ye=e=>e.status==="valid",Ut=e=>typeof Promise<"u"&&e instanceof Promise;var b;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t?.message})(b||(b={}));var ge=class{constructor(t,r,n,i){this._cachedPath=[],this.parent=t,this.data=r,this._path=n,this._key=i}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}},La=(e,t)=>{if(Ye(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let r=new ue(e.common.issues);return this._error=r,this._error}}};function T(e){if(!e)return{};let{errorMap:t,invalid_type_error:r,required_error:n,description:i}=e;if(t&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(a,s)=>{let{message:c}=e;return a.code==="invalid_enum_value"?{message:c??s.defaultError}:typeof s.data>"u"?{message:c??n??s.defaultError}:a.code!=="invalid_type"?{message:s.defaultError}:{message:c??r??s.defaultError}},description:i}}var E=class{get description(){return this._def.description}_getType(t){return Te(t.data)}_getOrReturnCtx(t,r){return r||{common:t.parent.common,data:t.data,parsedType:Te(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new re,ctx:{common:t.parent.common,data:t.data,parsedType:Te(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){let r=this._parse(t);if(Ut(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(t){let r=this._parse(t);return Promise.resolve(r)}parse(t,r){let n=this.safeParse(t,r);if(n.success)return n.data;throw n.error}safeParse(t,r){let n={common:{issues:[],async:r?.async??!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Te(t)},i=this._parseSync({data:t,path:n.path,parent:n});return La(n,i)}"~validate"(t){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Te(t)};if(!this["~standard"].async)try{let n=this._parseSync({data:t,path:[],parent:r});return Ye(n)?{value:n.value}:{issues:r.common.issues}}catch(n){n?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:r}).then(n=>Ye(n)?{value:n.value}:{issues:r.common.issues})}async parseAsync(t,r){let n=await this.safeParseAsync(t,r);if(n.success)return n.data;throw n.error}async safeParseAsync(t,r){let n={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Te(t)},i=this._parse({data:t,path:n.path,parent:n}),o=await(Ut(i)?i:Promise.resolve(i));return La(n,o)}refine(t,r){let n=i=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(i):r;return this._refinement((i,o)=>{let a=t(i),s=()=>o.addIssue({code:m.custom,...n(i)});return typeof Promise<"u"&&a instanceof Promise?a.then(c=>c?!0:(s(),!1)):a?!0:(s(),!1)})}refinement(t,r){return this._refinement((n,i)=>t(n)?!0:(i.addIssue(typeof r=="function"?r(n,i):r),!1))}_refinement(t){return new _e({schema:this,typeName:f.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:r=>this["~validate"](r)}}optional(){return ve.create(this,this._def)}nullable(){return Ee.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Me.create(this)}promise(){return He.create(this,this._def)}or(t){return dt.create([this,t],this._def)}and(t){return pt.create(this,t,this._def)}transform(t){return new _e({...T(this._def),schema:this,typeName:f.ZodEffects,effect:{type:"transform",transform:t}})}default(t){let r=typeof t=="function"?t:()=>t;return new vt({...T(this._def),innerType:this,defaultValue:r,typeName:f.ZodDefault})}brand(){return new wr({typeName:f.ZodBranded,type:this,...T(this._def)})}catch(t){let r=typeof t=="function"?t:()=>t;return new _t({...T(this._def),innerType:this,catchValue:r,typeName:f.ZodCatch})}describe(t){let r=this.constructor;return new r({...this._def,description:t})}pipe(t){return Ir.create(this,t)}readonly(){return yt.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Ld=/^c[^\s-]{8,}$/i,Md=/^[0-9a-z]+$/,Fd=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Vd=/^[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,Jd=/^[a-z0-9_-]{21}$/i,Wd=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Bd=/^[-+]?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)?)??$/,Kd=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Gd="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Dn,qd=/^(?:(?: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])$/,Xd=/^(?:(?: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])$/,Yd=/^(([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]))$/,Hd=/^(([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])$/,Qd=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,ep=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Ma="((\\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])))",tp=new RegExp(`^${Ma}$`);function Fa(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`);let r=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${r}`}function rp(e){return new RegExp(`^${Fa(e)}$`)}function np(e){let t=`${Ma}T${Fa(e)}`,r=[];return r.push(e.local?"Z?":"Z"),e.offset&&r.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${r.join("|")})`,new RegExp(`^${t}$`)}function ip(e,t){return!!((t==="v4"||!t)&&qd.test(e)||(t==="v6"||!t)&&Yd.test(e))}function op(e,t){if(!Wd.test(e))return!1;try{let[r]=e.split(".");if(!r)return!1;let n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),i=JSON.parse(atob(n));return!(typeof i!="object"||i===null||"typ"in i&&i?.typ!=="JWT"||!i.alg||t&&i.alg!==t)}catch{return!1}}function ap(e,t){return!!((t==="v4"||!t)&&Xd.test(e)||(t==="v6"||!t)&&Hd.test(e))}var ct=class e extends E{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==$.string){let o=this._getOrReturnCtx(t);return _(o,{code:m.invalid_type,expected:$.string,received:o.parsedType}),I}let n=new re,i;for(let o of this._def.checks)if(o.kind==="min")t.data.length<o.value&&(i=this._getOrReturnCtx(t,i),_(i,{code:m.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),n.dirty());else if(o.kind==="max")t.data.length>o.value&&(i=this._getOrReturnCtx(t,i),_(i,{code:m.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),n.dirty());else if(o.kind==="length"){let a=t.data.length>o.value,s=t.data.length<o.value;(a||s)&&(i=this._getOrReturnCtx(t,i),a?_(i,{code:m.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}):s&&_(i,{code:m.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}),n.dirty())}else if(o.kind==="email")Kd.test(t.data)||(i=this._getOrReturnCtx(t,i),_(i,{validation:"email",code:m.invalid_string,message:o.message}),n.dirty());else if(o.kind==="emoji")Dn||(Dn=new RegExp(Gd,"u")),Dn.test(t.data)||(i=this._getOrReturnCtx(t,i),_(i,{validation:"emoji",code:m.invalid_string,message:o.message}),n.dirty());else if(o.kind==="uuid")Vd.test(t.data)||(i=this._getOrReturnCtx(t,i),_(i,{validation:"uuid",code:m.invalid_string,message:o.message}),n.dirty());else if(o.kind==="nanoid")Jd.test(t.data)||(i=this._getOrReturnCtx(t,i),_(i,{validation:"nanoid",code:m.invalid_string,message:o.message}),n.dirty());else if(o.kind==="cuid")Ld.test(t.data)||(i=this._getOrReturnCtx(t,i),_(i,{validation:"cuid",code:m.invalid_string,message:o.message}),n.dirty());else if(o.kind==="cuid2")Md.test(t.data)||(i=this._getOrReturnCtx(t,i),_(i,{validation:"cuid2",code:m.invalid_string,message:o.message}),n.dirty());else if(o.kind==="ulid")Fd.test(t.data)||(i=this._getOrReturnCtx(t,i),_(i,{validation:"ulid",code:m.invalid_string,message:o.message}),n.dirty());else if(o.kind==="url")try{new URL(t.data)}catch{i=this._getOrReturnCtx(t,i),_(i,{validation:"url",code:m.invalid_string,message:o.message}),n.dirty()}else o.kind==="regex"?(o.regex.lastIndex=0,o.regex.test(t.data)||(i=this._getOrReturnCtx(t,i),_(i,{validation:"regex",code:m.invalid_string,message:o.message}),n.dirty())):o.kind==="trim"?t.data=t.data.trim():o.kind==="includes"?t.data.includes(o.value,o.position)||(i=this._getOrReturnCtx(t,i),_(i,{code:m.invalid_string,validation:{includes:o.value,position:o.position},message:o.message}),n.dirty()):o.kind==="toLowerCase"?t.data=t.data.toLowerCase():o.kind==="toUpperCase"?t.data=t.data.toUpperCase():o.kind==="startsWith"?t.data.startsWith(o.value)||(i=this._getOrReturnCtx(t,i),_(i,{code:m.invalid_string,validation:{startsWith:o.value},message:o.message}),n.dirty()):o.kind==="endsWith"?t.data.endsWith(o.value)||(i=this._getOrReturnCtx(t,i),_(i,{code:m.invalid_string,validation:{endsWith:o.value},message:o.message}),n.dirty()):o.kind==="datetime"?np(o).test(t.data)||(i=this._getOrReturnCtx(t,i),_(i,{code:m.invalid_string,validation:"datetime",message:o.message}),n.dirty()):o.kind==="date"?tp.test(t.data)||(i=this._getOrReturnCtx(t,i),_(i,{code:m.invalid_string,validation:"date",message:o.message}),n.dirty()):o.kind==="time"?rp(o).test(t.data)||(i=this._getOrReturnCtx(t,i),_(i,{code:m.invalid_string,validation:"time",message:o.message}),n.dirty()):o.kind==="duration"?Bd.test(t.data)||(i=this._getOrReturnCtx(t,i),_(i,{validation:"duration",code:m.invalid_string,message:o.message}),n.dirty()):o.kind==="ip"?ip(t.data,o.version)||(i=this._getOrReturnCtx(t,i),_(i,{validation:"ip",code:m.invalid_string,message:o.message}),n.dirty()):o.kind==="jwt"?op(t.data,o.alg)||(i=this._getOrReturnCtx(t,i),_(i,{validation:"jwt",code:m.invalid_string,message:o.message}),n.dirty()):o.kind==="cidr"?ap(t.data,o.version)||(i=this._getOrReturnCtx(t,i),_(i,{validation:"cidr",code:m.invalid_string,message:o.message}),n.dirty()):o.kind==="base64"?Qd.test(t.data)||(i=this._getOrReturnCtx(t,i),_(i,{validation:"base64",code:m.invalid_string,message:o.message}),n.dirty()):o.kind==="base64url"?ep.test(t.data)||(i=this._getOrReturnCtx(t,i),_(i,{validation:"base64url",code:m.invalid_string,message:o.message}),n.dirty()):N.assertNever(o);return{status:n.value,value:t.data}}_regex(t,r,n){return this.refinement(i=>t.test(i),{validation:r,code:m.invalid_string,...b.errToObj(n)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...b.errToObj(t)})}url(t){return this._addCheck({kind:"url",...b.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...b.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...b.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...b.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...b.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...b.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...b.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...b.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...b.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...b.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...b.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...b.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?.precision>"u"?null:t?.precision,offset:t?.offset??!1,local:t?.local??!1,...b.errToObj(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?.precision>"u"?null:t?.precision,...b.errToObj(t?.message)})}duration(t){return this._addCheck({kind:"duration",...b.errToObj(t)})}regex(t,r){return this._addCheck({kind:"regex",regex:t,...b.errToObj(r)})}includes(t,r){return this._addCheck({kind:"includes",value:t,position:r?.position,...b.errToObj(r?.message)})}startsWith(t,r){return this._addCheck({kind:"startsWith",value:t,...b.errToObj(r)})}endsWith(t,r){return this._addCheck({kind:"endsWith",value:t,...b.errToObj(r)})}min(t,r){return this._addCheck({kind:"min",value:t,...b.errToObj(r)})}max(t,r){return this._addCheck({kind:"max",value:t,...b.errToObj(r)})}length(t,r){return this._addCheck({kind:"length",value:t,...b.errToObj(r)})}nonempty(t){return this.min(1,b.errToObj(t))}trim(){return new e({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new e({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new e({...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(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxLength(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}};ct.create=e=>new ct({checks:[],typeName:f.ZodString,coerce:e?.coerce??!1,...T(e)});function sp(e,t){let r=(e.toString().split(".")[1]||"").length,n=(t.toString().split(".")[1]||"").length,i=r>n?r:n,o=Number.parseInt(e.toFixed(i).replace(".","")),a=Number.parseInt(t.toFixed(i).replace(".",""));return o%a/10**i}var At=class e extends E{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)!==$.number){let o=this._getOrReturnCtx(t);return _(o,{code:m.invalid_type,expected:$.number,received:o.parsedType}),I}let n,i=new re;for(let o of this._def.checks)o.kind==="int"?N.isInteger(t.data)||(n=this._getOrReturnCtx(t,n),_(n,{code:m.invalid_type,expected:"integer",received:"float",message:o.message}),i.dirty()):o.kind==="min"?(o.inclusive?t.data<o.value:t.data<=o.value)&&(n=this._getOrReturnCtx(t,n),_(n,{code:m.too_small,minimum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),i.dirty()):o.kind==="max"?(o.inclusive?t.data>o.value:t.data>=o.value)&&(n=this._getOrReturnCtx(t,n),_(n,{code:m.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),i.dirty()):o.kind==="multipleOf"?sp(t.data,o.value)!==0&&(n=this._getOrReturnCtx(t,n),_(n,{code:m.not_multiple_of,multipleOf:o.value,message:o.message}),i.dirty()):o.kind==="finite"?Number.isFinite(t.data)||(n=this._getOrReturnCtx(t,n),_(n,{code:m.not_finite,message:o.message}),i.dirty()):N.assertNever(o);return{status:i.value,value:t.data}}gte(t,r){return this.setLimit("min",t,!0,b.toString(r))}gt(t,r){return this.setLimit("min",t,!1,b.toString(r))}lte(t,r){return this.setLimit("max",t,!0,b.toString(r))}lt(t,r){return this.setLimit("max",t,!1,b.toString(r))}setLimit(t,r,n,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:n,message:b.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:b.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:b.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:b.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:b.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:b.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:b.toString(r)})}finite(t){return this._addCheck({kind:"finite",message:b.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:b.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:b.toString(t)})}get minValue(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&N.isInteger(t.value))}get isFinite(){let t=null,r=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(t===null||n.value<t)&&(t=n.value)}return Number.isFinite(r)&&Number.isFinite(t)}};At.create=e=>new At({checks:[],typeName:f.ZodNumber,coerce:e?.coerce||!1,...T(e)});var Rt=class e extends E{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)!==$.bigint)return this._getInvalidInput(t);let n,i=new re;for(let o of this._def.checks)o.kind==="min"?(o.inclusive?t.data<o.value:t.data<=o.value)&&(n=this._getOrReturnCtx(t,n),_(n,{code:m.too_small,type:"bigint",minimum:o.value,inclusive:o.inclusive,message:o.message}),i.dirty()):o.kind==="max"?(o.inclusive?t.data>o.value:t.data>=o.value)&&(n=this._getOrReturnCtx(t,n),_(n,{code:m.too_big,type:"bigint",maximum:o.value,inclusive:o.inclusive,message:o.message}),i.dirty()):o.kind==="multipleOf"?t.data%o.value!==BigInt(0)&&(n=this._getOrReturnCtx(t,n),_(n,{code:m.not_multiple_of,multipleOf:o.value,message:o.message}),i.dirty()):N.assertNever(o);return{status:i.value,value:t.data}}_getInvalidInput(t){let r=this._getOrReturnCtx(t);return _(r,{code:m.invalid_type,expected:$.bigint,received:r.parsedType}),I}gte(t,r){return this.setLimit("min",t,!0,b.toString(r))}gt(t,r){return this.setLimit("min",t,!1,b.toString(r))}lte(t,r){return this.setLimit("max",t,!0,b.toString(r))}lt(t,r){return this.setLimit("max",t,!1,b.toString(r))}setLimit(t,r,n,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:n,message:b.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:b.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:b.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:b.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:b.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:b.toString(r)})}get minValue(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}};Rt.create=e=>new Rt({checks:[],typeName:f.ZodBigInt,coerce:e?.coerce??!1,...T(e)});var Ct=class extends E{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==$.boolean){let n=this._getOrReturnCtx(t);return _(n,{code:m.invalid_type,expected:$.boolean,received:n.parsedType}),I}return ne(t.data)}};Ct.create=e=>new Ct({typeName:f.ZodBoolean,coerce:e?.coerce||!1,...T(e)});var Lt=class e extends E{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==$.date){let o=this._getOrReturnCtx(t);return _(o,{code:m.invalid_type,expected:$.date,received:o.parsedType}),I}if(Number.isNaN(t.data.getTime())){let o=this._getOrReturnCtx(t);return _(o,{code:m.invalid_date}),I}let n=new re,i;for(let o of this._def.checks)o.kind==="min"?t.data.getTime()<o.value&&(i=this._getOrReturnCtx(t,i),_(i,{code:m.too_small,message:o.message,inclusive:!0,exact:!1,minimum:o.value,type:"date"}),n.dirty()):o.kind==="max"?t.data.getTime()>o.value&&(i=this._getOrReturnCtx(t,i),_(i,{code:m.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),n.dirty()):N.assertNever(o);return{status:n.value,value:new Date(t.data.getTime())}}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}min(t,r){return this._addCheck({kind:"min",value:t.getTime(),message:b.toString(r)})}max(t,r){return this._addCheck({kind:"max",value:t.getTime(),message:b.toString(r)})}get minDate(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t!=null?new Date(t):null}};Lt.create=e=>new Lt({checks:[],coerce:e?.coerce||!1,typeName:f.ZodDate,...T(e)});var Mt=class extends E{_parse(t){if(this._getType(t)!==$.symbol){let n=this._getOrReturnCtx(t);return _(n,{code:m.invalid_type,expected:$.symbol,received:n.parsedType}),I}return ne(t.data)}};Mt.create=e=>new Mt({typeName:f.ZodSymbol,...T(e)});var ut=class extends E{_parse(t){if(this._getType(t)!==$.undefined){let n=this._getOrReturnCtx(t);return _(n,{code:m.invalid_type,expected:$.undefined,received:n.parsedType}),I}return ne(t.data)}};ut.create=e=>new ut({typeName:f.ZodUndefined,...T(e)});var lt=class extends E{_parse(t){if(this._getType(t)!==$.null){let n=this._getOrReturnCtx(t);return _(n,{code:m.invalid_type,expected:$.null,received:n.parsedType}),I}return ne(t.data)}};lt.create=e=>new lt({typeName:f.ZodNull,...T(e)});var Ft=class extends E{constructor(){super(...arguments),this._any=!0}_parse(t){return ne(t.data)}};Ft.create=e=>new Ft({typeName:f.ZodAny,...T(e)});var Le=class extends E{constructor(){super(...arguments),this._unknown=!0}_parse(t){return ne(t.data)}};Le.create=e=>new Le({typeName:f.ZodUnknown,...T(e)});var Se=class extends E{_parse(t){let r=this._getOrReturnCtx(t);return _(r,{code:m.invalid_type,expected:$.never,received:r.parsedType}),I}};Se.create=e=>new Se({typeName:f.ZodNever,...T(e)});var Vt=class extends E{_parse(t){if(this._getType(t)!==$.undefined){let n=this._getOrReturnCtx(t);return _(n,{code:m.invalid_type,expected:$.void,received:n.parsedType}),I}return ne(t.data)}};Vt.create=e=>new Vt({typeName:f.ZodVoid,...T(e)});var Me=class e extends E{_parse(t){let{ctx:r,status:n}=this._processInputParams(t),i=this._def;if(r.parsedType!==$.array)return _(r,{code:m.invalid_type,expected:$.array,received:r.parsedType}),I;if(i.exactLength!==null){let a=r.data.length>i.exactLength.value,s=r.data.length<i.exactLength.value;(a||s)&&(_(r,{code:a?m.too_big:m.too_small,minimum:s?i.exactLength.value:void 0,maximum:a?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),n.dirty())}if(i.minLength!==null&&r.data.length<i.minLength.value&&(_(r,{code:m.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),n.dirty()),i.maxLength!==null&&r.data.length>i.maxLength.value&&(_(r,{code:m.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((a,s)=>i.type._parseAsync(new ge(r,a,r.path,s)))).then(a=>re.mergeArray(n,a));let o=[...r.data].map((a,s)=>i.type._parseSync(new ge(r,a,r.path,s)));return re.mergeArray(n,o)}get element(){return this._def.type}min(t,r){return new e({...this._def,minLength:{value:t,message:b.toString(r)}})}max(t,r){return new e({...this._def,maxLength:{value:t,message:b.toString(r)}})}length(t,r){return new e({...this._def,exactLength:{value:t,message:b.toString(r)}})}nonempty(t){return this.min(1,t)}};Me.create=(e,t)=>new Me({type:e,minLength:null,maxLength:null,exactLength:null,typeName:f.ZodArray,...T(t)});function st(e){if(e instanceof le){let t={};for(let r in e.shape){let n=e.shape[r];t[r]=ve.create(st(n))}return new le({...e._def,shape:()=>t})}else return e instanceof Me?new Me({...e._def,type:st(e.element)}):e instanceof ve?ve.create(st(e.unwrap())):e instanceof Ee?Ee.create(st(e.unwrap())):e instanceof De?De.create(e.items.map(t=>st(t))):e}var le=class e extends E{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let t=this._def.shape(),r=N.objectKeys(t);return this._cached={shape:t,keys:r},this._cached}_parse(t){if(this._getType(t)!==$.object){let u=this._getOrReturnCtx(t);return _(u,{code:m.invalid_type,expected:$.object,received:u.parsedType}),I}let{status:n,ctx:i}=this._processInputParams(t),{shape:o,keys:a}=this._getCached(),s=[];if(!(this._def.catchall instanceof Se&&this._def.unknownKeys==="strip"))for(let u in i.data)a.includes(u)||s.push(u);let c=[];for(let u of a){let l=o[u],p=i.data[u];c.push({key:{status:"valid",value:u},value:l._parse(new ge(i,p,i.path,u)),alwaysSet:u in i.data})}if(this._def.catchall instanceof Se){let u=this._def.unknownKeys;if(u==="passthrough")for(let l of s)c.push({key:{status:"valid",value:l},value:{status:"valid",value:i.data[l]}});else if(u==="strict")s.length>0&&(_(i,{code:m.unrecognized_keys,keys:s}),n.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let u=this._def.catchall;for(let l of s){let p=i.data[l];c.push({key:{status:"valid",value:l},value:u._parse(new ge(i,p,i.path,l)),alwaysSet:l in i.data})}}return i.common.async?Promise.resolve().then(async()=>{let u=[];for(let l of c){let p=await l.key,h=await l.value;u.push({key:p,value:h,alwaysSet:l.alwaysSet})}return u}).then(u=>re.mergeObjectSync(n,u)):re.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(t){return b.errToObj,new e({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(r,n)=>{let i=this._def.errorMap?.(r,n).message??n.defaultError;return r.code==="unrecognized_keys"?{message:b.errToObj(t).message??i}:{message:i}}}:{}})}strip(){return new e({...this._def,unknownKeys:"strip"})}passthrough(){return new e({...this._def,unknownKeys:"passthrough"})}extend(t){return new e({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new e({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:f.ZodObject})}setKey(t,r){return this.augment({[t]:r})}catchall(t){return new e({...this._def,catchall:t})}pick(t){let r={};for(let n of N.objectKeys(t))t[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new e({...this._def,shape:()=>r})}omit(t){let r={};for(let n of N.objectKeys(this.shape))t[n]||(r[n]=this.shape[n]);return new e({...this._def,shape:()=>r})}deepPartial(){return st(this)}partial(t){let r={};for(let n of N.objectKeys(this.shape)){let i=this.shape[n];t&&!t[n]?r[n]=i:r[n]=i.optional()}return new e({...this._def,shape:()=>r})}required(t){let r={};for(let n of N.objectKeys(this.shape))if(t&&!t[n])r[n]=this.shape[n];else{let o=this.shape[n];for(;o instanceof ve;)o=o._def.innerType;r[n]=o}return new e({...this._def,shape:()=>r})}keyof(){return Va(N.objectKeys(this.shape))}};le.create=(e,t)=>new le({shape:()=>e,unknownKeys:"strip",catchall:Se.create(),typeName:f.ZodObject,...T(t)});le.strictCreate=(e,t)=>new le({shape:()=>e,unknownKeys:"strict",catchall:Se.create(),typeName:f.ZodObject,...T(t)});le.lazycreate=(e,t)=>new le({shape:e,unknownKeys:"strip",catchall:Se.create(),typeName:f.ZodObject,...T(t)});var dt=class extends E{_parse(t){let{ctx:r}=this._processInputParams(t),n=this._def.options;function i(o){for(let s of o)if(s.result.status==="valid")return s.result;for(let s of o)if(s.result.status==="dirty")return r.common.issues.push(...s.ctx.common.issues),s.result;let a=o.map(s=>new ue(s.ctx.common.issues));return _(r,{code:m.invalid_union,unionErrors:a}),I}if(r.common.async)return Promise.all(n.map(async o=>{let a={...r,common:{...r.common,issues:[]},parent:null};return{result:await o._parseAsync({data:r.data,path:r.path,parent:a}),ctx:a}})).then(i);{let o,a=[];for(let c of n){let u={...r,common:{...r.common,issues:[]},parent:null},l=c._parseSync({data:r.data,path:r.path,parent:u});if(l.status==="valid")return l;l.status==="dirty"&&!o&&(o={result:l,ctx:u}),u.common.issues.length&&a.push(u.common.issues)}if(o)return r.common.issues.push(...o.ctx.common.issues),o.result;let s=a.map(c=>new ue(c));return _(r,{code:m.invalid_union,unionErrors:s}),I}}get options(){return this._def.options}};dt.create=(e,t)=>new dt({options:e,typeName:f.ZodUnion,...T(t)});var je=e=>e instanceof mt?je(e.schema):e instanceof _e?je(e.innerType()):e instanceof ft?[e.value]:e instanceof gt?e.options:e instanceof ht?N.objectValues(e.enum):e instanceof vt?je(e._def.innerType):e instanceof ut?[void 0]:e instanceof lt?[null]:e instanceof ve?[void 0,...je(e.unwrap())]:e instanceof Ee?[null,...je(e.unwrap())]:e instanceof wr||e instanceof yt?je(e.unwrap()):e instanceof _t?je(e._def.innerType):[],En=class e extends E{_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==$.object)return _(r,{code:m.invalid_type,expected:$.object,received:r.parsedType}),I;let n=this.discriminator,i=r.data[n],o=this.optionsMap.get(i);return o?r.common.async?o._parseAsync({data:r.data,path:r.path,parent:r}):o._parseSync({data:r.data,path:r.path,parent:r}):(_(r,{code:m.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),I)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,r,n){let i=new Map;for(let o of r){let a=je(o.shape[t]);if(!a.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let s of a){if(i.has(s))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(s)}`);i.set(s,o)}}return new e({typeName:f.ZodDiscriminatedUnion,discriminator:t,options:r,optionsMap:i,...T(n)})}};function Nn(e,t){let r=Te(e),n=Te(t);if(e===t)return{valid:!0,data:e};if(r===$.object&&n===$.object){let i=N.objectKeys(t),o=N.objectKeys(e).filter(s=>i.indexOf(s)!==-1),a={...e,...t};for(let s of o){let c=Nn(e[s],t[s]);if(!c.valid)return{valid:!1};a[s]=c.data}return{valid:!0,data:a}}else if(r===$.array&&n===$.array){if(e.length!==t.length)return{valid:!1};let i=[];for(let o=0;o<e.length;o++){let a=e[o],s=t[o],c=Nn(a,s);if(!c.valid)return{valid:!1};i.push(c.data)}return{valid:!0,data:i}}else return r===$.date&&n===$.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}var pt=class extends E{_parse(t){let{status:r,ctx:n}=this._processInputParams(t),i=(o,a)=>{if(Tn(o)||Tn(a))return I;let s=Nn(o.value,a.value);return s.valid?((jn(o)||jn(a))&&r.dirty(),{status:r.value,value:s.data}):(_(n,{code:m.invalid_intersection_types}),I)};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(([o,a])=>i(o,a)):i(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};pt.create=(e,t,r)=>new pt({left:e,right:t,typeName:f.ZodIntersection,...T(r)});var De=class e extends E{_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==$.array)return _(n,{code:m.invalid_type,expected:$.array,received:n.parsedType}),I;if(n.data.length<this._def.items.length)return _(n,{code:m.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),I;!this._def.rest&&n.data.length>this._def.items.length&&(_(n,{code:m.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let o=[...n.data].map((a,s)=>{let c=this._def.items[s]||this._def.rest;return c?c._parse(new ge(n,a,n.path,s)):null}).filter(a=>!!a);return n.common.async?Promise.all(o).then(a=>re.mergeArray(r,a)):re.mergeArray(r,o)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};De.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new De({items:e,typeName:f.ZodTuple,rest:null,...T(t)})};var Zn=class e extends E{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==$.object)return _(n,{code:m.invalid_type,expected:$.object,received:n.parsedType}),I;let i=[],o=this._def.keyType,a=this._def.valueType;for(let s in n.data)i.push({key:o._parse(new ge(n,s,n.path,s)),value:a._parse(new ge(n,n.data[s],n.path,s)),alwaysSet:s in n.data});return n.common.async?re.mergeObjectAsync(r,i):re.mergeObjectSync(r,i)}get element(){return this._def.valueType}static create(t,r,n){return r instanceof E?new e({keyType:t,valueType:r,typeName:f.ZodRecord,...T(n)}):new e({keyType:ct.create(),valueType:t,typeName:f.ZodRecord,...T(r)})}},Jt=class extends E{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==$.map)return _(n,{code:m.invalid_type,expected:$.map,received:n.parsedType}),I;let i=this._def.keyType,o=this._def.valueType,a=[...n.data.entries()].map(([s,c],u)=>({key:i._parse(new ge(n,s,n.path,[u,"key"])),value:o._parse(new ge(n,c,n.path,[u,"value"]))}));if(n.common.async){let s=new Map;return Promise.resolve().then(async()=>{for(let c of a){let u=await c.key,l=await c.value;if(u.status==="aborted"||l.status==="aborted")return I;(u.status==="dirty"||l.status==="dirty")&&r.dirty(),s.set(u.value,l.value)}return{status:r.value,value:s}})}else{let s=new Map;for(let c of a){let u=c.key,l=c.value;if(u.status==="aborted"||l.status==="aborted")return I;(u.status==="dirty"||l.status==="dirty")&&r.dirty(),s.set(u.value,l.value)}return{status:r.value,value:s}}}};Jt.create=(e,t,r)=>new Jt({valueType:t,keyType:e,typeName:f.ZodMap,...T(r)});var Wt=class e extends E{_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==$.set)return _(n,{code:m.invalid_type,expected:$.set,received:n.parsedType}),I;let i=this._def;i.minSize!==null&&n.data.size<i.minSize.value&&(_(n,{code:m.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),r.dirty()),i.maxSize!==null&&n.data.size>i.maxSize.value&&(_(n,{code:m.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),r.dirty());let o=this._def.valueType;function a(c){let u=new Set;for(let l of c){if(l.status==="aborted")return I;l.status==="dirty"&&r.dirty(),u.add(l.value)}return{status:r.value,value:u}}let s=[...n.data.values()].map((c,u)=>o._parse(new ge(n,c,n.path,u)));return n.common.async?Promise.all(s).then(c=>a(c)):a(s)}min(t,r){return new e({...this._def,minSize:{value:t,message:b.toString(r)}})}max(t,r){return new e({...this._def,maxSize:{value:t,message:b.toString(r)}})}size(t,r){return this.min(t,r).max(t,r)}nonempty(t){return this.min(1,t)}};Wt.create=(e,t)=>new Wt({valueType:e,minSize:null,maxSize:null,typeName:f.ZodSet,...T(t)});var Un=class e extends E{constructor(){super(...arguments),this.validate=this.implement}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==$.function)return _(r,{code:m.invalid_type,expected:$.function,received:r.parsedType}),I;function n(s,c){return Sr({data:s,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Zt(),Ce].filter(u=>!!u),issueData:{code:m.invalid_arguments,argumentsError:c}})}function i(s,c){return Sr({data:s,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Zt(),Ce].filter(u=>!!u),issueData:{code:m.invalid_return_type,returnTypeError:c}})}let o={errorMap:r.common.contextualErrorMap},a=r.data;if(this._def.returns instanceof He){let s=this;return ne(async function(...c){let u=new ue([]),l=await s._def.args.parseAsync(c,o).catch(v=>{throw u.addIssue(n(c,v)),u}),p=await Reflect.apply(a,this,l);return await s._def.returns._def.type.parseAsync(p,o).catch(v=>{throw u.addIssue(i(p,v)),u})})}else{let s=this;return ne(function(...c){let u=s._def.args.safeParse(c,o);if(!u.success)throw new ue([n(c,u.error)]);let l=Reflect.apply(a,this,u.data),p=s._def.returns.safeParse(l,o);if(!p.success)throw new ue([i(l,p.error)]);return p.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:De.create(t).rest(Le.create())})}returns(t){return new e({...this._def,returns:t})}implement(t){return this.parse(t)}strictImplement(t){return this.parse(t)}static create(t,r,n){return new e({args:t||De.create([]).rest(Le.create()),returns:r||Le.create(),typeName:f.ZodFunction,...T(n)})}},mt=class extends E{get schema(){return this._def.getter()}_parse(t){let{ctx:r}=this._processInputParams(t);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}};mt.create=(e,t)=>new mt({getter:e,typeName:f.ZodLazy,...T(t)});var ft=class extends E{_parse(t){if(t.data!==this._def.value){let r=this._getOrReturnCtx(t);return _(r,{received:r.data,code:m.invalid_literal,expected:this._def.value}),I}return{status:"valid",value:t.data}}get value(){return this._def.value}};ft.create=(e,t)=>new ft({value:e,typeName:f.ZodLiteral,...T(t)});function Va(e,t){return new gt({values:e,typeName:f.ZodEnum,...T(t)})}var gt=class e extends E{_parse(t){if(typeof t.data!="string"){let r=this._getOrReturnCtx(t),n=this._def.values;return _(r,{expected:N.joinValues(n),received:r.parsedType,code:m.invalid_type}),I}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){let r=this._getOrReturnCtx(t),n=this._def.values;return _(r,{received:r.data,code:m.invalid_enum_value,options:n}),I}return ne(t.data)}get options(){return this._def.values}get enum(){let t={};for(let r of this._def.values)t[r]=r;return t}get Values(){let t={};for(let r of this._def.values)t[r]=r;return t}get Enum(){let t={};for(let r of this._def.values)t[r]=r;return t}extract(t,r=this._def){return e.create(t,{...this._def,...r})}exclude(t,r=this._def){return e.create(this.options.filter(n=>!t.includes(n)),{...this._def,...r})}};gt.create=Va;var ht=class extends E{_parse(t){let r=N.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(t);if(n.parsedType!==$.string&&n.parsedType!==$.number){let i=N.objectValues(r);return _(n,{expected:N.joinValues(i),received:n.parsedType,code:m.invalid_type}),I}if(this._cache||(this._cache=new Set(N.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){let i=N.objectValues(r);return _(n,{received:n.data,code:m.invalid_enum_value,options:i}),I}return ne(t.data)}get enum(){return this._def.values}};ht.create=(e,t)=>new ht({values:e,typeName:f.ZodNativeEnum,...T(t)});var He=class extends E{unwrap(){return this._def.type}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==$.promise&&r.common.async===!1)return _(r,{code:m.invalid_type,expected:$.promise,received:r.parsedType}),I;let n=r.parsedType===$.promise?r.data:Promise.resolve(r.data);return ne(n.then(i=>this._def.type.parseAsync(i,{path:r.path,errorMap:r.common.contextualErrorMap})))}};He.create=(e,t)=>new He({type:e,typeName:f.ZodPromise,...T(t)});var _e=class extends E{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===f.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){let{status:r,ctx:n}=this._processInputParams(t),i=this._def.effect||null,o={addIssue:a=>{_(n,a),a.fatal?r.abort():r.dirty()},get path(){return n.path}};if(o.addIssue=o.addIssue.bind(o),i.type==="preprocess"){let a=i.transform(n.data,o);if(n.common.async)return Promise.resolve(a).then(async s=>{if(r.value==="aborted")return I;let c=await this._def.schema._parseAsync({data:s,path:n.path,parent:n});return c.status==="aborted"?I:c.status==="dirty"?at(c.value):r.value==="dirty"?at(c.value):c});{if(r.value==="aborted")return I;let s=this._def.schema._parseSync({data:a,path:n.path,parent:n});return s.status==="aborted"?I:s.status==="dirty"?at(s.value):r.value==="dirty"?at(s.value):s}}if(i.type==="refinement"){let a=s=>{let c=i.refinement(s,o);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return s};if(n.common.async===!1){let s=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?I:(s.status==="dirty"&&r.dirty(),a(s.value),{status:r.value,value:s.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(s=>s.status==="aborted"?I:(s.status==="dirty"&&r.dirty(),a(s.value).then(()=>({status:r.value,value:s.value}))))}if(i.type==="transform")if(n.common.async===!1){let a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!Ye(a))return I;let s=i.transform(a.value,o);if(s instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:s}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>Ye(a)?Promise.resolve(i.transform(a.value,o)).then(s=>({status:r.value,value:s})):I);N.assertNever(i)}};_e.create=(e,t,r)=>new _e({schema:e,typeName:f.ZodEffects,effect:t,...T(r)});_e.createWithPreprocess=(e,t,r)=>new _e({schema:t,effect:{type:"preprocess",transform:e},typeName:f.ZodEffects,...T(r)});var ve=class extends E{_parse(t){return this._getType(t)===$.undefined?ne(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};ve.create=(e,t)=>new ve({innerType:e,typeName:f.ZodOptional,...T(t)});var Ee=class extends E{_parse(t){return this._getType(t)===$.null?ne(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};Ee.create=(e,t)=>new Ee({innerType:e,typeName:f.ZodNullable,...T(t)});var vt=class extends E{_parse(t){let{ctx:r}=this._processInputParams(t),n=r.data;return r.parsedType===$.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};vt.create=(e,t)=>new vt({innerType:e,typeName:f.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...T(t)});var _t=class extends E{_parse(t){let{ctx:r}=this._processInputParams(t),n={...r,common:{...r.common,issues:[]}},i=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Ut(i)?i.then(o=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new ue(n.common.issues)},input:n.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new ue(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};_t.create=(e,t)=>new _t({innerType:e,typeName:f.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...T(t)});var Bt=class extends E{_parse(t){if(this._getType(t)!==$.nan){let n=this._getOrReturnCtx(t);return _(n,{code:m.invalid_type,expected:$.nan,received:n.parsedType}),I}return{status:"valid",value:t.data}}};Bt.create=e=>new Bt({typeName:f.ZodNaN,...T(e)});var wr=class extends E{_parse(t){let{ctx:r}=this._processInputParams(t),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}},Ir=class e extends E{_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.common.async)return(async()=>{let o=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?I:o.status==="dirty"?(r.dirty(),at(o.value)):this._def.out._parseAsync({data:o.value,path:n.path,parent:n})})();{let i=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?I:i.status==="dirty"?(r.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:n.path,parent:n})}}static create(t,r){return new e({in:t,out:r,typeName:f.ZodPipeline})}},yt=class extends E{_parse(t){let r=this._def.innerType._parse(t),n=i=>(Ye(i)&&(i.value=Object.freeze(i.value)),i);return Ut(r)?r.then(i=>n(i)):n(r)}unwrap(){return this._def.innerType}};yt.create=(e,t)=>new yt({innerType:e,typeName:f.ZodReadonly,...T(t)});var Fg={object:le.lazycreate},f;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(f||(f={}));var Vg=ct.create,Jg=At.create,Wg=Bt.create,Bg=Rt.create,Kg=Ct.create,Gg=Lt.create,qg=Mt.create,Xg=ut.create,Yg=lt.create,Hg=Ft.create,Qg=Le.create,eh=Se.create,th=Vt.create,rh=Me.create,nh=le.create,ih=le.strictCreate,oh=dt.create,ah=En.create,sh=pt.create,ch=De.create,uh=Zn.create,lh=Jt.create,dh=Wt.create,ph=Un.create,mh=mt.create,fh=ft.create,gh=gt.create,hh=ht.create,vh=He.create,_h=_e.create,yh=ve.create,$h=Ee.create,xh=_e.createWithPreprocess,bh=Ir.create;function W(e){if(e.target!=="openAi")return{};let t=[...e.basePath,e.definitionPath,e.openAiAnyTypeName];return e.flags.hasReferencedOpenAiAnyType=!0,{$ref:e.$refStrategy==="relative"?kr(t,e.currentPath):t.join("/")}}function Ja(e,t){let r={type:"array"};return e.type?._def&&e.type?._def?.typeName!==f.ZodAny&&(r.items=z(e.type._def,{...t,currentPath:[...t.currentPath,"items"]})),e.minLength&&U(r,"minItems",e.minLength.value,e.minLength.message,t),e.maxLength&&U(r,"maxItems",e.maxLength.value,e.maxLength.message,t),e.exactLength&&(U(r,"minItems",e.exactLength.value,e.exactLength.message,t),U(r,"maxItems",e.exactLength.value,e.exactLength.message,t)),r}function Wa(e,t){let r={type:"integer",format:"int64"};if(!e.checks)return r;for(let n of e.checks)switch(n.kind){case"min":t.target==="jsonSchema7"?n.inclusive?U(r,"minimum",n.value,n.message,t):U(r,"exclusiveMinimum",n.value,n.message,t):(n.inclusive||(r.exclusiveMinimum=!0),U(r,"minimum",n.value,n.message,t));break;case"max":t.target==="jsonSchema7"?n.inclusive?U(r,"maximum",n.value,n.message,t):U(r,"exclusiveMaximum",n.value,n.message,t):(n.inclusive||(r.exclusiveMaximum=!0),U(r,"maximum",n.value,n.message,t));break;case"multipleOf":U(r,"multipleOf",n.value,n.message,t);break}return r}function Ba(){return{type:"boolean"}}function zr(e,t){return z(e.type._def,t)}var Ka=(e,t)=>z(e.innerType._def,t);function An(e,t,r){let n=r??t.dateStrategy;if(Array.isArray(n))return{anyOf:n.map((i,o)=>An(e,t,i))};switch(n){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return up(e,t)}}var up=(e,t)=>{let r={type:"integer",format:"unix-time"};if(t.target==="openApi3")return r;for(let n of e.checks)switch(n.kind){case"min":U(r,"minimum",n.value,n.message,t);break;case"max":U(r,"maximum",n.value,n.message,t);break}return r};function Ga(e,t){return{...z(e.innerType._def,t),default:e.defaultValue()}}function qa(e,t){return t.effectStrategy==="input"?z(e.schema._def,t):W(t)}function Xa(e){return{type:"string",enum:Array.from(e.values)}}var lp=e=>"type"in e&&e.type==="string"?!1:"allOf"in e;function Ya(e,t){let r=[z(e.left._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),z(e.right._def,{...t,currentPath:[...t.currentPath,"allOf","1"]})].filter(o=>!!o),n=t.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,i=[];return r.forEach(o=>{if(lp(o))i.push(...o.allOf),o.unevaluatedProperties===void 0&&(n=void 0);else{let a=o;if("additionalProperties"in o&&o.additionalProperties===!1){let{additionalProperties:s,...c}=o;a=c}else n=void 0;i.push(a)}}),i.length?{allOf:i,...n}:void 0}function Ha(e,t){let r=typeof e.value;return r!=="bigint"&&r!=="number"&&r!=="boolean"&&r!=="string"?{type:Array.isArray(e.value)?"array":"object"}:t.target==="openApi3"?{type:r==="bigint"?"integer":r,enum:[e.value]}:{type:r==="bigint"?"integer":r,const:e.value}}var Rn,ye={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>(Rn===void 0&&(Rn=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Rn),uuid:/^[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}$/,ipv4:/^(?:(?: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])$/,ipv4Cidr:/^(?:(?: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])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([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])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function Or(e,t){let r={type:"string"};if(e.checks)for(let n of e.checks)switch(n.kind){case"min":U(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,n.value):n.value,n.message,t);break;case"max":U(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,n.value):n.value,n.message,t);break;case"email":switch(t.emailStrategy){case"format:email":$e(r,"email",n.message,t);break;case"format:idn-email":$e(r,"idn-email",n.message,t);break;case"pattern:zod":ie(r,ye.email,n.message,t);break}break;case"url":$e(r,"uri",n.message,t);break;case"uuid":$e(r,"uuid",n.message,t);break;case"regex":ie(r,n.regex,n.message,t);break;case"cuid":ie(r,ye.cuid,n.message,t);break;case"cuid2":ie(r,ye.cuid2,n.message,t);break;case"startsWith":ie(r,RegExp(`^${Cn(n.value,t)}`),n.message,t);break;case"endsWith":ie(r,RegExp(`${Cn(n.value,t)}$`),n.message,t);break;case"datetime":$e(r,"date-time",n.message,t);break;case"date":$e(r,"date",n.message,t);break;case"time":$e(r,"time",n.message,t);break;case"duration":$e(r,"duration",n.message,t);break;case"length":U(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,n.value):n.value,n.message,t),U(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,n.value):n.value,n.message,t);break;case"includes":{ie(r,RegExp(Cn(n.value,t)),n.message,t);break}case"ip":{n.version!=="v6"&&$e(r,"ipv4",n.message,t),n.version!=="v4"&&$e(r,"ipv6",n.message,t);break}case"base64url":ie(r,ye.base64url,n.message,t);break;case"jwt":ie(r,ye.jwt,n.message,t);break;case"cidr":{n.version!=="v6"&&ie(r,ye.ipv4Cidr,n.message,t),n.version!=="v4"&&ie(r,ye.ipv6Cidr,n.message,t);break}case"emoji":ie(r,ye.emoji(),n.message,t);break;case"ulid":{ie(r,ye.ulid,n.message,t);break}case"base64":{switch(t.base64Strategy){case"format:binary":{$e(r,"binary",n.message,t);break}case"contentEncoding:base64":{U(r,"contentEncoding","base64",n.message,t);break}case"pattern:zod":{ie(r,ye.base64,n.message,t);break}}break}case"nanoid":ie(r,ye.nanoid,n.message,t);case"toLowerCase":case"toUpperCase":case"trim":break;default:}return r}function Cn(e,t){return t.patternStrategy==="escape"?pp(e):e}var dp=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function pp(e){let t="";for(let r=0;r<e.length;r++)dp.has(e[r])||(t+="\\"),t+=e[r];return t}function $e(e,t,r,n){e.format||e.anyOf?.some(i=>i.format)?(e.anyOf||(e.anyOf=[]),e.format&&(e.anyOf.push({format:e.format,...e.errorMessage&&n.errorMessages&&{errorMessage:{format:e.errorMessage.format}}}),delete e.format,e.errorMessage&&(delete e.errorMessage.format,Object.keys(e.errorMessage).length===0&&delete e.errorMessage)),e.anyOf.push({format:t,...r&&n.errorMessages&&{errorMessage:{format:r}}})):U(e,"format",t,r,n)}function ie(e,t,r,n){e.pattern||e.allOf?.some(i=>i.pattern)?(e.allOf||(e.allOf=[]),e.pattern&&(e.allOf.push({pattern:e.pattern,...e.errorMessage&&n.errorMessages&&{errorMessage:{pattern:e.errorMessage.pattern}}}),delete e.pattern,e.errorMessage&&(delete e.errorMessage.pattern,Object.keys(e.errorMessage).length===0&&delete e.errorMessage)),e.allOf.push({pattern:Qa(t,n),...r&&n.errorMessages&&{errorMessage:{pattern:r}}})):U(e,"pattern",Qa(t,n),r,n)}function Qa(e,t){if(!t.applyRegexFlags||!e.flags)return e.source;let r={i:e.flags.includes("i"),m:e.flags.includes("m"),s:e.flags.includes("s")},n=r.i?e.source.toLowerCase():e.source,i="",o=!1,a=!1,s=!1;for(let c=0;c<n.length;c++){if(o){i+=n[c],o=!1;continue}if(r.i){if(a){if(n[c].match(/[a-z]/)){s?(i+=n[c],i+=`${n[c-2]}-${n[c]}`.toUpperCase(),s=!1):n[c+1]==="-"&&n[c+2]?.match(/[a-z]/)?(i+=n[c],s=!0):i+=`${n[c]}${n[c].toUpperCase()}`;continue}}else if(n[c].match(/[a-z]/)){i+=`[${n[c]}${n[c].toUpperCase()}]`;continue}}if(r.m){if(n[c]==="^"){i+=`(^|(?<=[\r
|
|
5
|
-
]))`;continue}else if(n[c]==="$"){i+=`($|(?=[\r
|
|
6
|
-
]))`;continue}}if(r.s&&n[c]==="."){i+=a?`${n[c]}\r
|
|
7
|
-
`:`[${n[c]}\r
|
|
8
|
-
]`;continue}i+=n[c],n[c]==="\\"?o=!0:a&&n[c]==="]"?a=!1:!a&&n[c]==="["&&(a=!0)}try{new RegExp(i)}catch{return console.warn(`Could not convert regex pattern at ${t.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),e.source}return i}function Pr(e,t){if(t.target==="openAi"&&console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead."),t.target==="openApi3"&&e.keyType?._def.typeName===f.ZodEnum)return{type:"object",required:e.keyType._def.values,properties:e.keyType._def.values.reduce((n,i)=>({...n,[i]:z(e.valueType._def,{...t,currentPath:[...t.currentPath,"properties",i]})??W(t)}),{}),additionalProperties:t.rejectedAdditionalProperties};let r={type:"object",additionalProperties:z(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]})??t.allowedAdditionalProperties};if(t.target==="openApi3")return r;if(e.keyType?._def.typeName===f.ZodString&&e.keyType._def.checks?.length){let{type:n,...i}=Or(e.keyType._def,t);return{...r,propertyNames:i}}else{if(e.keyType?._def.typeName===f.ZodEnum)return{...r,propertyNames:{enum:e.keyType._def.values}};if(e.keyType?._def.typeName===f.ZodBranded&&e.keyType._def.type._def.typeName===f.ZodString&&e.keyType._def.type._def.checks?.length){let{type:n,...i}=zr(e.keyType._def,t);return{...r,propertyNames:i}}}return r}function es(e,t){if(t.mapStrategy==="record")return Pr(e,t);let r=z(e.keyType._def,{...t,currentPath:[...t.currentPath,"items","items","0"]})||W(t),n=z(e.valueType._def,{...t,currentPath:[...t.currentPath,"items","items","1"]})||W(t);return{type:"array",maxItems:125,items:{type:"array",items:[r,n],minItems:2,maxItems:2}}}function ts(e){let t=e.values,n=Object.keys(e.values).filter(o=>typeof t[t[o]]!="number").map(o=>t[o]),i=Array.from(new Set(n.map(o=>typeof o)));return{type:i.length===1?i[0]==="string"?"string":"number":["string","number"],enum:n}}function rs(e){return e.target==="openAi"?void 0:{not:W({...e,currentPath:[...e.currentPath,"not"]})}}function ns(e){return e.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}var Kt={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function os(e,t){if(t.target==="openApi3")return is(e,t);let r=e.options instanceof Map?Array.from(e.options.values()):e.options;if(r.every(n=>n._def.typeName in Kt&&(!n._def.checks||!n._def.checks.length))){let n=r.reduce((i,o)=>{let a=Kt[o._def.typeName];return a&&!i.includes(a)?[...i,a]:i},[]);return{type:n.length>1?n:n[0]}}else if(r.every(n=>n._def.typeName==="ZodLiteral"&&!n.description)){let n=r.reduce((i,o)=>{let a=typeof o._def.value;switch(a){case"string":case"number":case"boolean":return[...i,a];case"bigint":return[...i,"integer"];case"object":if(o._def.value===null)return[...i,"null"];default:return i}},[]);if(n.length===r.length){let i=n.filter((o,a,s)=>s.indexOf(o)===a);return{type:i.length>1?i:i[0],enum:r.reduce((o,a)=>o.includes(a._def.value)?o:[...o,a._def.value],[])}}}else if(r.every(n=>n._def.typeName==="ZodEnum"))return{type:"string",enum:r.reduce((n,i)=>[...n,...i._def.values.filter(o=>!n.includes(o))],[])};return is(e,t)}var is=(e,t)=>{let r=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((n,i)=>z(n._def,{...t,currentPath:[...t.currentPath,"anyOf",`${i}`]})).filter(n=>!!n&&(!t.strictUnions||typeof n=="object"&&Object.keys(n).length>0));return r.length?{anyOf:r}:void 0};function as(e,t){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return t.target==="openApi3"?{type:Kt[e.innerType._def.typeName],nullable:!0}:{type:[Kt[e.innerType._def.typeName],"null"]};if(t.target==="openApi3"){let n=z(e.innerType._def,{...t,currentPath:[...t.currentPath]});return n&&"$ref"in n?{allOf:[n],nullable:!0}:n&&{...n,nullable:!0}}let r=z(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","0"]});return r&&{anyOf:[r,{type:"null"}]}}function ss(e,t){let r={type:"number"};if(!e.checks)return r;for(let n of e.checks)switch(n.kind){case"int":r.type="integer",Pn(r,"type",n.message,t);break;case"min":t.target==="jsonSchema7"?n.inclusive?U(r,"minimum",n.value,n.message,t):U(r,"exclusiveMinimum",n.value,n.message,t):(n.inclusive||(r.exclusiveMinimum=!0),U(r,"minimum",n.value,n.message,t));break;case"max":t.target==="jsonSchema7"?n.inclusive?U(r,"maximum",n.value,n.message,t):U(r,"exclusiveMaximum",n.value,n.message,t):(n.inclusive||(r.exclusiveMaximum=!0),U(r,"maximum",n.value,n.message,t));break;case"multipleOf":U(r,"multipleOf",n.value,n.message,t);break}return r}function cs(e,t){let r=t.target==="openAi",n={type:"object",properties:{}},i=[],o=e.shape();for(let s in o){let c=o[s];if(c===void 0||c._def===void 0)continue;let u=fp(c);u&&r&&(c._def.typeName==="ZodOptional"&&(c=c._def.innerType),c.isNullable()||(c=c.nullable()),u=!1);let l=z(c._def,{...t,currentPath:[...t.currentPath,"properties",s],propertyPath:[...t.currentPath,"properties",s]});l!==void 0&&(n.properties[s]=l,u||i.push(s))}i.length&&(n.required=i);let a=mp(e,t);return a!==void 0&&(n.additionalProperties=a),n}function mp(e,t){if(e.catchall._def.typeName!=="ZodNever")return z(e.catchall._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]});switch(e.unknownKeys){case"passthrough":return t.allowedAdditionalProperties;case"strict":return t.rejectedAdditionalProperties;case"strip":return t.removeAdditionalStrategy==="strict"?t.allowedAdditionalProperties:t.rejectedAdditionalProperties}}function fp(e){try{return e.isOptional()}catch{return!0}}var us=(e,t)=>{if(t.currentPath.toString()===t.propertyPath?.toString())return z(e.innerType._def,t);let r=z(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","1"]});return r?{anyOf:[{not:W(t)},r]}:W(t)};var ls=(e,t)=>{if(t.pipeStrategy==="input")return z(e.in._def,t);if(t.pipeStrategy==="output")return z(e.out._def,t);let r=z(e.in._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),n=z(e.out._def,{...t,currentPath:[...t.currentPath,"allOf",r?"1":"0"]});return{allOf:[r,n].filter(i=>i!==void 0)}};function ds(e,t){return z(e.type._def,t)}function ps(e,t){let n={type:"array",uniqueItems:!0,items:z(e.valueType._def,{...t,currentPath:[...t.currentPath,"items"]})};return e.minSize&&U(n,"minItems",e.minSize.value,e.minSize.message,t),e.maxSize&&U(n,"maxItems",e.maxSize.value,e.maxSize.message,t),n}function ms(e,t){return e.rest?{type:"array",minItems:e.items.length,items:e.items.map((r,n)=>z(r._def,{...t,currentPath:[...t.currentPath,"items",`${n}`]})).reduce((r,n)=>n===void 0?r:[...r,n],[]),additionalItems:z(e.rest._def,{...t,currentPath:[...t.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map((r,n)=>z(r._def,{...t,currentPath:[...t.currentPath,"items",`${n}`]})).reduce((r,n)=>n===void 0?r:[...r,n],[])}}function fs(e){return{not:W(e)}}function gs(e){return W(e)}var hs=(e,t)=>z(e.innerType._def,t);var vs=(e,t,r)=>{switch(t){case f.ZodString:return Or(e,r);case f.ZodNumber:return ss(e,r);case f.ZodObject:return cs(e,r);case f.ZodBigInt:return Wa(e,r);case f.ZodBoolean:return Ba();case f.ZodDate:return An(e,r);case f.ZodUndefined:return fs(r);case f.ZodNull:return ns(r);case f.ZodArray:return Ja(e,r);case f.ZodUnion:case f.ZodDiscriminatedUnion:return os(e,r);case f.ZodIntersection:return Ya(e,r);case f.ZodTuple:return ms(e,r);case f.ZodRecord:return Pr(e,r);case f.ZodLiteral:return Ha(e,r);case f.ZodEnum:return Xa(e);case f.ZodNativeEnum:return ts(e);case f.ZodNullable:return as(e,r);case f.ZodOptional:return us(e,r);case f.ZodMap:return es(e,r);case f.ZodSet:return ps(e,r);case f.ZodLazy:return()=>e.getter()._def;case f.ZodPromise:return ds(e,r);case f.ZodNaN:case f.ZodNever:return rs(r);case f.ZodEffects:return qa(e,r);case f.ZodAny:return W(r);case f.ZodUnknown:return gs(r);case f.ZodDefault:return Ga(e,r);case f.ZodBranded:return zr(e,r);case f.ZodReadonly:return hs(e,r);case f.ZodCatch:return Ka(e,r);case f.ZodPipeline:return ls(e,r);case f.ZodFunction:case f.ZodVoid:case f.ZodSymbol:return;default:return(n=>{})(t)}};function z(e,t,r=!1){let n=t.seen.get(e);if(t.override){let s=t.override?.(e,t,n,r);if(s!==Ua)return s}if(n&&!r){let s=gp(n,t);if(s!==void 0)return s}let i={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,i);let o=vs(e,e.typeName,t),a=typeof o=="function"?z(o(),t):o;if(a&&hp(e,t,a),t.postProcess){let s=t.postProcess(a,e,t);return i.jsonSchema=a,s}return i.jsonSchema=a,a}var gp=(e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"relative":return{$ref:kr(t.currentPath,e.path)};case"none":case"seen":return e.path.length<t.currentPath.length&&e.path.every((r,n)=>t.currentPath[n]===r)?(console.warn(`Recursive reference detected at ${t.currentPath.join("/")}! Defaulting to any`),W(t)):t.$refStrategy==="seen"?W(t):void 0}},hp=(e,t,r)=>(e.description&&(r.description=e.description,t.markdownDescription&&(r.markdownDescription=e.description)),r);var Ln=(e,t)=>{let r=Ra(t),n=typeof t=="object"&&t.definitions?Object.entries(t.definitions).reduce((c,[u,l])=>({...c,[u]:z(l._def,{...r,currentPath:[...r.basePath,r.definitionPath,u]},!0)??W(r)}),{}):void 0,i=typeof t=="string"?t:t?.nameStrategy==="title"?void 0:t?.name,o=z(e._def,i===void 0?r:{...r,currentPath:[...r.basePath,r.definitionPath,i]},!1)??W(r),a=typeof t=="object"&&t.name!==void 0&&t.nameStrategy==="title"?t.name:void 0;a!==void 0&&(o.title=a),r.flags.hasReferencedOpenAiAnyType&&(n||(n={}),n[r.openAiAnyTypeName]||(n[r.openAiAnyTypeName]={type:["string","number","integer","boolean","array","null"],items:{$ref:r.$refStrategy==="relative"?"1":[...r.basePath,r.definitionPath,r.openAiAnyTypeName].join("/")}}));let s=i===void 0?n?{...o,[r.definitionPath]:n}:o:{$ref:[...r.$refStrategy==="relative"?[]:r.basePath,r.definitionPath,i].join("/"),[r.definitionPath]:{...n,[i]:o}};return r.target==="jsonSchema7"?s.$schema="http://json-schema.org/draft-07/schema#":(r.target==="jsonSchema2019-09"||r.target==="openAi")&&(s.$schema="https://json-schema.org/draft/2019-09/schema#"),r.target==="openAi"&&("anyOf"in s||"oneOf"in s||"allOf"in s||"type"in s&&Array.isArray(s.type))&&console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property."),s};var Tr=class{static generateFileOutputInstructions(t,r){let n;typeof t?.parse=="function"?n=Ln(t,{target:"openApi3"}):n=t;let i=this._buildExample(n);return`
|
|
1
|
+
var j=class{constructor(t,e,r=0){this.name=t,this.description=e,this.priority=r}async invoke(t,e={}){throw new Error("AgentStrategy.invoke() must be implemented by subclass")}canHandle(t){throw new Error("AgentStrategy.canHandle() must be implemented by subclass")}getName(){return this.name}getDescription(){return this.description}getPriority(){return this.priority}};import{spawn as Zt,execSync as W}from"node:child_process";import{writeFileSync as xt,readFileSync as $t,mkdirSync as At,existsSync as H,accessSync as It,constants as Tt,unlinkSync as Xt}from"node:fs";import{join as T,resolve as Vt}from"node:path";import{homedir as Y}from"node:os";import G from"chalk";var R={debug:0,info:1,warn:2,error:3,silent:4},tt=class{constructor(){this._level=this._getLogLevel()}_getLogLevel(){if(process.env.ZIBBY_DEBUG==="true")return R.debug;if(process.env.ZIBBY_VERBOSE==="true")return R.info;let t=process.env.LOG_LEVEL?.toLowerCase();return t&&t in R?R[t]:R.info}_shouldLog(t){return R[t]>=this._level}_formatMessage(t,e,r={}){let n=new Date().toISOString(),o=`${this._getPrefix(t)} ${e}`;return Object.keys(r).length>0&&(o+=G.dim(` ${JSON.stringify(r)}`)),o}_getPrefix(t){return{debug:G.gray("[DEBUG]"),info:G.cyan("[INFO]"),warn:G.yellow("[WARN]"),error:G.red("\u274C [ERROR]")}[t]||""}debug(t,e){this._shouldLog("debug")&&console.log(this._formatMessage("debug",t,e))}info(t,e){this._shouldLog("info")&&console.log(this._formatMessage("info",t,e))}warn(t,e){this._shouldLog("warn")&&console.warn(this._formatMessage("warn",t,e))}error(t,e){this._shouldLog("error")&&console.error(this._formatMessage("error",t,e))}setLevel(t){t in R&&(this._level=R[t])}getLevel(){return Object.keys(R).find(t=>R[t]===this._level)}},i=new tt;var K={ASSISTANT:"gpt-5.4-nano-2026-03-17",CLAUDE:"claude-sonnet-4-6",CURSOR:"auto",CODEX:"o4-mini",GEMINI:"gemini-2.5-pro",OPENAI_POSTPROCESSING:"gpt-4o-mini"};var Z={CURSOR_AGENT_DEFAULT:1200*1e3,OPENAI_REQUEST:18e4};var lt=".zibby/output";var at=".session-info.json",ut=".zibby-studio-stop";var ct=new Map;function et(s){return ct.get(s)||null}function pt(){return new Map(ct)}var X=class s{constructor(){this.buffer="",this.extractedResult=null,this.rawText="",this.zodSchema=null,this.lastOutputLength=0,this.onToolCall=null,this._lastToolEmit=null}processChunk(t){if(!t)return null;this.buffer+=t;let e=this.buffer.split(`
|
|
2
|
+
`);this.buffer=e.pop()||"";let r="";for(let n of e)if(n.trim())try{let l=JSON.parse(n);this._emitToolCalls(l);let o=this.extractText(l);if(o){if(this.rawText&&o.startsWith(this.rawText)){let a=o.substring(this.rawText.length);this.rawText=o,r+=a}else(!this.rawText.includes(o)||o.length<20)&&(this.rawText+=o,r+=o);this.tryExtractResult(this.rawText)}else this.isValidResult(l)&&(this.rawText+=`${n}
|
|
3
|
+
`,r+=`${n}
|
|
4
|
+
`,this.extractedResult=l)}catch{if(n.includes('"text"')||n.includes('"content"')){let o=n.match(/"text"\s*:\s*"([^"]*)/),a=n.match(/"content"\s*:\s*"([^"]*)/),c=o?o[1]:a?a[1]:null;c&&!this.rawText.includes(c)&&(r+=c,this.rawText+=c)}}return r||null}flush(){if(!this.buffer.trim())return null;let t="";try{let e=JSON.parse(this.buffer);this._emitToolCalls(e);let r=this.extractText(e);r&&(this.rawText+=r,t+=r,this.tryExtractResult(r))}catch{this.rawText+=this.buffer,t+=this.buffer,this.tryExtractResult(this.buffer)}return this.buffer="",t||null}_emitToolCalls(t){if(!this.onToolCall)return;let e=(o,a)=>{if(!o)return;let c=`${o}:${JSON.stringify(a??{})}`;this._lastToolEmit!==c&&(this._lastToolEmit=c,this.onToolCall(o,a??void 0))},r=o=>{if(o!=null){if(typeof o=="object"&&!Array.isArray(o))return o;if(typeof o=="string")try{return JSON.parse(o)}catch{return}}};if(t.type==="tool_use"||t.type==="tool_call"){if(t.name){e(t.name,r(t.input??t.arguments));return}let o=t.tool_call;if(o&&typeof o=="object"&&!Array.isArray(o)){let a=Object.keys(o);if(a.length===1){let c=a[0],g=o[c],p=g&&typeof g=="object"?g.args??g.input??g:void 0;e(c,r(p))}return}return}if(Array.isArray(t.tool_calls)){for(let o of t.tool_calls)e(o.name,r(o.input??o.arguments));return}let n=t.message??t;if(Array.isArray(n?.tool_calls)){for(let o of n.tool_calls)e(o.name,r(o.input??o.arguments));return}let l=n?.content??t.content;if(Array.isArray(l))for(let o of l)(o.type==="tool_use"||o.type==="tool_call")&&o.name&&e(o.name,r(o.input??o.arguments))}extractText(t){if(t.type==="assistant"&&t.message?.content){let e=t.message.content;if(Array.isArray(e))return e.filter(r=>r.type==="text"&&r.text).map(r=>r.text).join("")}return t.type==="thinking"&&t.text||t.text?t.text:t.content&&typeof t.content=="string"?t.content:t.delta?t.delta:null}tryExtractResult(t){if(!t||typeof t!="string")return;let e=[],r=/```json\s*\n?([\s\S]*?)\n?```/g,n;for(;(n=r.exec(t))!==null;){let f=n[1].trim();try{JSON.parse(f),e.push({text:f,source:"markdown"})}catch{}}let l=0,o=0;for(;l<t.length&&(l=t.indexOf("{",l),l!==-1);){let f=0,h=l;for(let S=l;S<t.length;S++)if(t[S]==="{")f++;else if(t[S]==="}"&&(f--,f===0)){h=S,e.push({text:t.substring(l,h+1),source:"brace"}),o++;break}l=h+1}let a=this.extractedResult,c=a?JSON.stringify(a).length:0,g=0,p=-1;for(let f=0;f<e.length;f++){let h=e[f];try{let S=h.text.replace(/,(\s*[}\]])/g,"$1"),$=JSON.parse(S);this.isValidResult($)&&(g++,c=JSON.stringify($).length,a=$,p=f)}catch{}}a&&(this.extractedResult=a)}isValidResult(t){if(!t||typeof t!="object"||Array.isArray(t)||t.session_id||t.timestamp_ms||t.type||t.call_id||t.tool_call||t.result&&typeof t.result=="object"&&(t.result.success&&typeof t.result.success=="object"||t.result.error&&typeof t.result.error=="object")||t.args&&typeof t.args=="object")return!1;if(this.zodSchema)try{return this.zodSchema.parse(t),!0}catch{return!1}return!0}getResult(){return this.extractedResult}getRawText(){return this.rawText}static extractResult(t,e=null){let r=new s;r.zodSchema=e,r.processChunk(t),r.flush();let n=r.getResult();return!n&&process.env.LOG_LEVEL==="debug"&&console.error("[StreamingParser] No result extracted from",t?.length||0,"chars"),n}};import{zodToJsonSchema as vt}from"zod-to-json-schema";var V=class{static generateFileOutputInstructions(t,e){let r;typeof t?.parse=="function"?r=vt(t,{target:"openApi3"}):r=t;let n=this._buildExample(r);return`
|
|
9
5
|
\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
|
|
10
6
|
\u{1F6A8} MANDATORY: WRITE RESULT TO FILE \u{1F6A8}
|
|
11
7
|
\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
|
|
12
8
|
You MUST write your final result as pure JSON to this EXACT file path:
|
|
13
9
|
|
|
14
|
-
${
|
|
10
|
+
${e}
|
|
15
11
|
|
|
16
12
|
Use your file writing tool (WriteFile or ApplyPatch) to create this file.
|
|
17
13
|
DO NOT just output JSON to stdout. The file MUST exist when you finish.
|
|
18
14
|
DO NOT skip this step. The workflow WILL FAIL if the file is missing.
|
|
19
15
|
|
|
20
16
|
Required JSON structure:
|
|
21
|
-
${JSON.stringify(
|
|
17
|
+
${JSON.stringify(n,null,2)}
|
|
22
18
|
|
|
23
19
|
JSON types (strict \u2014 validators reject wrong types):
|
|
24
20
|
- Use bare JSON numbers for numeric fields (e.g. 3000). Do NOT quote them as strings (wrong: "3000").
|
|
25
21
|
- Use true/false without quotes for booleans.
|
|
26
22
|
- Use unquoted null where a field may be null.
|
|
27
23
|
|
|
28
|
-
Rules: valid JSON only, no markdown wrapping, no extra text in the file.`}static _buildExample(t){if(!t)return{};let r=t.type;if(r==="object"&&t.properties){let n={};for(let[i,o]of Object.entries(t.properties))n[i]=this._buildExample(o);return n}if(r==="array"&&t.items)return[this._buildExample(t.items)];if(r==="string")return"<string>";if(r==="number"||r==="integer")return 0;if(r==="boolean")return!1;if(t.description)return`<${t.description}>`;if(t.nullable||t.oneOf||t.anyOf){let n=t.oneOf?.find(i=>i.type!=="null")||t.anyOf?.find(i=>i.type!=="null");return n?this._buildExample(n):null}return"<value>"}};import Bf from"axios";import{homedir as Kf}from"node:os";import{join as Gf}from"node:path";import{existsSync as qf,readFileSync as Xf}from"node:fs";var vp=Object.freeze({status:"aborted"});function d(e,t,r){function n(s,c){if(s._zod||Object.defineProperty(s,"_zod",{value:{def:c,constr:a,traits:new Set},enumerable:!1}),s._zod.traits.has(e))return;s._zod.traits.add(e),t(s,c);let u=a.prototype,l=Object.keys(u);for(let p=0;p<l.length;p++){let h=l[p];h in s||(s[h]=u[h].bind(s))}}let i=r?.Parent??Object;class o extends i{}Object.defineProperty(o,"name",{value:e});function a(s){var c;let u=r?.Parent?new o:this;n(u,s),(c=u._zod).deferred??(c.deferred=[]);for(let l of u._zod.deferred)l();return u}return Object.defineProperty(a,"init",{value:n}),Object.defineProperty(a,Symbol.hasInstance,{value:s=>r?.Parent&&s instanceof r.Parent?!0:s?._zod?.traits?.has(e)}),Object.defineProperty(a,"name",{value:e}),a}var we=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},Qe=class extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}},jr={};function ee(e){return e&&Object.assign(jr,e),jr}var g={};Dt(g,{BIGINT_FORMAT_RANGES:()=>qn,Class:()=>Fn,NUMBER_FORMAT_RANGES:()=>Gn,aborted:()=>We,allowsEval:()=>Wn,assert:()=>bp,assertEqual:()=>_p,assertIs:()=>$p,assertNever:()=>xp,assertNotEqual:()=>yp,assignProp:()=>Ve,base64ToUint8Array:()=>$s,base64urlToUint8Array:()=>Cp,cached:()=>xt,captureStackTrace:()=>Er,cleanEnum:()=>Rp,cleanRegex:()=>Xt,clone:()=>de,cloneDef:()=>Sp,createTransparentProxy:()=>Tp,defineLazy:()=>D,esc:()=>Dr,escapeRegex:()=>he,extend:()=>Ep,finalizeIssue:()=>ae,floatSafeRemainder:()=>Vn,getElementAtPath:()=>wp,getEnumValues:()=>qt,getLengthableOrigin:()=>Qt,getParsedType:()=>Pp,getSizableOrigin:()=>Ht,hexToUint8Array:()=>Mp,isObject:()=>et,isPlainObject:()=>Je,issue:()=>bt,joinValues:()=>S,jsonStringifyReplacer:()=>$t,merge:()=>Zp,mergeDefs:()=>Ne,normalizeParams:()=>y,nullish:()=>Fe,numKeys:()=>Op,objectClone:()=>kp,omit:()=>Dp,optionalKeys:()=>Kn,parsedType:()=>O,partial:()=>Up,pick:()=>jp,prefixIssues:()=>pe,primitiveTypes:()=>Bn,promiseAllObject:()=>Ip,propertyKeyTypes:()=>Yt,randomString:()=>zp,required:()=>Ap,safeExtend:()=>Np,shallowClone:()=>ys,slugify:()=>Jn,stringifyPrimitive:()=>w,uint8ArrayToBase64:()=>xs,uint8ArrayToBase64url:()=>Lp,uint8ArrayToHex:()=>Fp,unwrapMessage:()=>Gt});function _p(e){return e}function yp(e){return e}function $p(e){}function xp(e){throw new Error("Unexpected value in exhaustive check")}function bp(e){}function qt(e){let t=Object.values(e).filter(n=>typeof n=="number");return Object.entries(e).filter(([n,i])=>t.indexOf(+n)===-1).map(([n,i])=>i)}function S(e,t="|"){return e.map(r=>w(r)).join(t)}function $t(e,t){return typeof t=="bigint"?t.toString():t}function xt(e){return{get value(){{let r=e();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function Fe(e){return e==null}function Xt(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function Vn(e,t){let r=(e.toString().split(".")[1]||"").length,n=t.toString(),i=(n.split(".")[1]||"").length;if(i===0&&/\d?e-\d?/.test(n)){let c=n.match(/\d?e-(\d?)/);c?.[1]&&(i=Number.parseInt(c[1]))}let o=r>i?r:i,a=Number.parseInt(e.toFixed(o).replace(".","")),s=Number.parseInt(t.toFixed(o).replace(".",""));return a%s/10**o}var _s=Symbol("evaluating");function D(e,t,r){let n;Object.defineProperty(e,t,{get(){if(n!==_s)return n===void 0&&(n=_s,n=r()),n},set(i){Object.defineProperty(e,t,{value:i})},configurable:!0})}function kp(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function Ve(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function Ne(...e){let t={};for(let r of e){let n=Object.getOwnPropertyDescriptors(r);Object.assign(t,n)}return Object.defineProperties({},t)}function Sp(e){return Ne(e._zod.def)}function wp(e,t){return t?t.reduce((r,n)=>r?.[n],e):e}function Ip(e){let t=Object.keys(e),r=t.map(n=>e[n]);return Promise.all(r).then(n=>{let i={};for(let o=0;o<t.length;o++)i[t[o]]=n[o];return i})}function zp(e=10){let t="abcdefghijklmnopqrstuvwxyz",r="";for(let n=0;n<e;n++)r+=t[Math.floor(Math.random()*t.length)];return r}function Dr(e){return JSON.stringify(e)}function Jn(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var Er="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function et(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var Wn=xt(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});function Je(e){if(et(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let r=t.prototype;return!(et(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function ys(e){return Je(e)?{...e}:Array.isArray(e)?[...e]:e}function Op(e){let t=0;for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t++;return t}var Pp=e=>{let t=typeof e;switch(t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(e)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(e)?"array":e===null?"null":e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?"promise":typeof Map<"u"&&e instanceof Map?"map":typeof Set<"u"&&e instanceof Set?"set":typeof Date<"u"&&e instanceof Date?"date":typeof File<"u"&&e instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${t}`)}},Yt=new Set(["string","number","symbol"]),Bn=new Set(["string","number","bigint","boolean","symbol","undefined"]);function he(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function de(e,t,r){let n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}function y(e){let t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function Tp(e){let t;return new Proxy({},{get(r,n,i){return t??(t=e()),Reflect.get(t,n,i)},set(r,n,i,o){return t??(t=e()),Reflect.set(t,n,i,o)},has(r,n){return t??(t=e()),Reflect.has(t,n)},deleteProperty(r,n){return t??(t=e()),Reflect.deleteProperty(t,n)},ownKeys(r){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(r,n){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,n)},defineProperty(r,n,i){return t??(t=e()),Reflect.defineProperty(t,n,i)}})}function w(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function Kn(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var Gn={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},qn={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function jp(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let o=Ne(e._zod.def,{get shape(){let a={};for(let s in t){if(!(s in r.shape))throw new Error(`Unrecognized key: "${s}"`);t[s]&&(a[s]=r.shape[s])}return Ve(this,"shape",a),a},checks:[]});return de(e,o)}function Dp(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let o=Ne(e._zod.def,{get shape(){let a={...e._zod.def.shape};for(let s in t){if(!(s in r.shape))throw new Error(`Unrecognized key: "${s}"`);t[s]&&delete a[s]}return Ve(this,"shape",a),a},checks:[]});return de(e,o)}function Ep(e,t){if(!Je(t))throw new Error("Invalid input to extend: expected a plain object");let r=e._zod.def.checks;if(r&&r.length>0){let o=e._zod.def.shape;for(let a in t)if(Object.getOwnPropertyDescriptor(o,a)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let i=Ne(e._zod.def,{get shape(){let o={...e._zod.def.shape,...t};return Ve(this,"shape",o),o}});return de(e,i)}function Np(e,t){if(!Je(t))throw new Error("Invalid input to safeExtend: expected a plain object");let r=Ne(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return Ve(this,"shape",n),n}});return de(e,r)}function Zp(e,t){let r=Ne(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return Ve(this,"shape",n),n},get catchall(){return t._zod.def.catchall},checks:[]});return de(e,r)}function Up(e,t,r){let i=t._zod.def.checks;if(i&&i.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");let a=Ne(t._zod.def,{get shape(){let s=t._zod.def.shape,c={...s};if(r)for(let u in r){if(!(u in s))throw new Error(`Unrecognized key: "${u}"`);r[u]&&(c[u]=e?new e({type:"optional",innerType:s[u]}):s[u])}else for(let u in s)c[u]=e?new e({type:"optional",innerType:s[u]}):s[u];return Ve(this,"shape",c),c},checks:[]});return de(t,a)}function Ap(e,t,r){let n=Ne(t._zod.def,{get shape(){let i=t._zod.def.shape,o={...i};if(r)for(let a in r){if(!(a in o))throw new Error(`Unrecognized key: "${a}"`);r[a]&&(o[a]=new e({type:"nonoptional",innerType:i[a]}))}else for(let a in i)o[a]=new e({type:"nonoptional",innerType:i[a]});return Ve(this,"shape",o),o}});return de(t,n)}function We(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function pe(e,t){return t.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function Gt(e){return typeof e=="string"?e:e?.message}function ae(e,t,r){let n={...e,path:e.path??[]};if(!e.message){let i=Gt(e.inst?._zod.def?.error?.(e))??Gt(t?.error?.(e))??Gt(r.customError?.(e))??Gt(r.localeError?.(e))??"Invalid input";n.message=i}return delete n.inst,delete n.continue,t?.reportInput||delete n.input,n}function Ht(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}function Qt(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function O(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let r=e;if(r&&Object.getPrototypeOf(r)!==Object.prototype&&"constructor"in r&&r.constructor)return r.constructor.name}}return t}function bt(...e){let[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}function Rp(e){return Object.entries(e).filter(([t,r])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function $s(e){let t=atob(e),r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return r}function xs(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t)}function Cp(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),r="=".repeat((4-t.length%4)%4);return $s(t+r)}function Lp(e){return xs(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function Mp(e){let t=e.replace(/^0x/,"");if(t.length%2!==0)throw new Error("Invalid hex string length");let r=new Uint8Array(t.length/2);for(let n=0;n<t.length;n+=2)r[n/2]=Number.parseInt(t.slice(n,n+2),16);return r}function Fp(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}var Fn=class{constructor(...t){}};var bs=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,$t,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Nr=d("$ZodError",bs),er=d("$ZodError",bs,{Parent:Error});function Xn(e,t=r=>r.message){let r={},n=[];for(let i of e.issues)i.path.length>0?(r[i.path[0]]=r[i.path[0]]||[],r[i.path[0]].push(t(i))):n.push(t(i));return{formErrors:n,fieldErrors:r}}function Yn(e,t=r=>r.message){let r={_errors:[]},n=i=>{for(let o of i.issues)if(o.code==="invalid_union"&&o.errors.length)o.errors.map(a=>n({issues:a}));else if(o.code==="invalid_key")n({issues:o.issues});else if(o.code==="invalid_element")n({issues:o.issues});else if(o.path.length===0)r._errors.push(t(o));else{let a=r,s=0;for(;s<o.path.length;){let c=o.path[s];s===o.path.length-1?(a[c]=a[c]||{_errors:[]},a[c]._errors.push(t(o))):a[c]=a[c]||{_errors:[]},a=a[c],s++}}};return n(e),r}var tr=e=>(t,r,n,i)=>{let o=n?Object.assign(n,{async:!1}):{async:!1},a=t._zod.run({value:r,issues:[]},o);if(a instanceof Promise)throw new we;if(a.issues.length){let s=new(i?.Err??e)(a.issues.map(c=>ae(c,o,ee())));throw Er(s,i?.callee),s}return a.value},Hn=tr(er),rr=e=>async(t,r,n,i)=>{let o=n?Object.assign(n,{async:!0}):{async:!0},a=t._zod.run({value:r,issues:[]},o);if(a instanceof Promise&&(a=await a),a.issues.length){let s=new(i?.Err??e)(a.issues.map(c=>ae(c,o,ee())));throw Er(s,i?.callee),s}return a.value},Qn=rr(er),nr=e=>(t,r,n)=>{let i=n?{...n,async:!1}:{async:!1},o=t._zod.run({value:r,issues:[]},i);if(o instanceof Promise)throw new we;return o.issues.length?{success:!1,error:new(e??Nr)(o.issues.map(a=>ae(a,i,ee())))}:{success:!0,data:o.value}},ks=nr(er),ir=e=>async(t,r,n)=>{let i=n?Object.assign(n,{async:!0}):{async:!0},o=t._zod.run({value:r,issues:[]},i);return o instanceof Promise&&(o=await o),o.issues.length?{success:!1,error:new e(o.issues.map(a=>ae(a,i,ee())))}:{success:!0,data:o.value}},Ss=ir(er),ws=e=>(t,r,n)=>{let i=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return tr(e)(t,r,i)};var Is=e=>(t,r,n)=>tr(e)(t,r,n);var zs=e=>async(t,r,n)=>{let i=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return rr(e)(t,r,i)};var Os=e=>async(t,r,n)=>rr(e)(t,r,n);var Ps=e=>(t,r,n)=>{let i=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return nr(e)(t,r,i)};var Ts=e=>(t,r,n)=>nr(e)(t,r,n);var js=e=>async(t,r,n)=>{let i=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return ir(e)(t,r,i)};var Ds=e=>async(t,r,n)=>ir(e)(t,r,n);var Ie={};Dt(Ie,{base64:()=>gi,base64url:()=>Zr,bigint:()=>xi,boolean:()=>ki,browserEmail:()=>Yp,cidrv4:()=>mi,cidrv6:()=>fi,cuid:()=>ei,cuid2:()=>ti,date:()=>vi,datetime:()=>yi,domain:()=>em,duration:()=>ai,e164:()=>hi,email:()=>ci,emoji:()=>ui,extendedDuration:()=>Jp,guid:()=>si,hex:()=>tm,hostname:()=>Qp,html5Email:()=>Gp,idnEmail:()=>Xp,integer:()=>bi,ipv4:()=>li,ipv6:()=>di,ksuid:()=>ii,lowercase:()=>Ii,mac:()=>pi,md5_base64:()=>nm,md5_base64url:()=>im,md5_hex:()=>rm,nanoid:()=>oi,null:()=>Si,number:()=>Ur,rfc5322Email:()=>qp,sha1_base64:()=>am,sha1_base64url:()=>sm,sha1_hex:()=>om,sha256_base64:()=>um,sha256_base64url:()=>lm,sha256_hex:()=>cm,sha384_base64:()=>pm,sha384_base64url:()=>mm,sha384_hex:()=>dm,sha512_base64:()=>gm,sha512_base64url:()=>hm,sha512_hex:()=>fm,string:()=>$i,time:()=>_i,ulid:()=>ri,undefined:()=>wi,unicodeEmail:()=>Es,uppercase:()=>zi,uuid:()=>tt,uuid4:()=>Wp,uuid6:()=>Bp,uuid7:()=>Kp,xid:()=>ni});var ei=/^[cC][^\s-]{8,}$/,ti=/^[0-9a-z]+$/,ri=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,ni=/^[0-9a-vA-V]{20}$/,ii=/^[A-Za-z0-9]{27}$/,oi=/^[a-zA-Z0-9_-]{21}$/,ai=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Jp=/^[-+]?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)?)??$/,si=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,tt=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,Wp=tt(4),Bp=tt(6),Kp=tt(7),ci=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Gp=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,qp=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,Es=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,Xp=Es,Yp=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,Hp="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function ui(){return new RegExp(Hp,"u")}var li=/^(?:(?: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])$/,di=/^(([0-9a-fA-F]{1,4}:){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}|:))$/,pi=e=>{let t=he(e??":");return new RegExp(`^(?:[0-9A-F]{2}${t}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${t}){5}[0-9a-f]{2}$`)},mi=/^((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])\/([0-9]|[1-2][0-9]|3[0-2])$/,fi=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,gi=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Zr=/^[A-Za-z0-9_-]*$/,Qp=/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/,em=/^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,hi=/^\+[1-9]\d{6,14}$/,Ns="(?:(?:\\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])))",vi=new RegExp(`^${Ns}$`);function Zs(e){let t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function _i(e){return new RegExp(`^${Zs(e)}$`)}function yi(e){let t=Zs({precision:e.precision}),r=["Z"];e.local&&r.push(""),e.offset&&r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let n=`${t}(?:${r.join("|")})`;return new RegExp(`^${Ns}T(?:${n})$`)}var $i=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},xi=/^-?\d+n?$/,bi=/^-?\d+$/,Ur=/^-?\d+(?:\.\d+)?$/,ki=/^(?:true|false)$/i,Si=/^null$/i;var wi=/^undefined$/i;var Ii=/^[^A-Z]*$/,zi=/^[^a-z]*$/,tm=/^[0-9a-fA-F]*$/;function or(e,t){return new RegExp(`^[A-Za-z0-9+/]{${e}}${t}$`)}function ar(e){return new RegExp(`^[A-Za-z0-9_-]{${e}}$`)}var rm=/^[0-9a-fA-F]{32}$/,nm=or(22,"=="),im=ar(22),om=/^[0-9a-fA-F]{40}$/,am=or(27,"="),sm=ar(27),cm=/^[0-9a-fA-F]{64}$/,um=or(43,"="),lm=ar(43),dm=/^[0-9a-fA-F]{96}$/,pm=or(64,""),mm=ar(64),fm=/^[0-9a-fA-F]{128}$/,gm=or(86,"=="),hm=ar(86);var J=d("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),As={number:"number",bigint:"bigint",object:"date"},Oi=d("$ZodCheckLessThan",(e,t)=>{J.init(e,t);let r=As[typeof t.value];e._zod.onattach.push(n=>{let i=n._zod.bag,o=(t.inclusive?i.maximum:i.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<o&&(t.inclusive?i.maximum=t.value:i.exclusiveMaximum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value<=t.value:n.value<t.value)||n.issues.push({origin:r,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Pi=d("$ZodCheckGreaterThan",(e,t)=>{J.init(e,t);let r=As[typeof t.value];e._zod.onattach.push(n=>{let i=n._zod.bag,o=(t.inclusive?i.minimum:i.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>o&&(t.inclusive?i.minimum=t.value:i.exclusiveMinimum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:r,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Rs=d("$ZodCheckMultipleOf",(e,t)=>{J.init(e,t),e._zod.onattach.push(r=>{var n;(n=r._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=r=>{if(typeof r.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?r.value%t.value===BigInt(0):Vn(r.value,t.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),Cs=d("$ZodCheckNumberFormat",(e,t)=>{J.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),n=r?"int":"number",[i,o]=Gn[t.format];e._zod.onattach.push(a=>{let s=a._zod.bag;s.format=t.format,s.minimum=i,s.maximum=o,r&&(s.pattern=bi)}),e._zod.check=a=>{let s=a.value;if(r){if(!Number.isInteger(s)){a.issues.push({expected:n,format:t.format,code:"invalid_type",continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?a.issues.push({input:s,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort}):a.issues.push({input:s,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort});return}}s<i&&a.issues.push({origin:"number",input:s,code:"too_small",minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>o&&a.issues.push({origin:"number",input:s,code:"too_big",maximum:o,inclusive:!0,inst:e,continue:!t.abort})}}),Ls=d("$ZodCheckBigIntFormat",(e,t)=>{J.init(e,t);let[r,n]=qn[t.format];e._zod.onattach.push(i=>{let o=i._zod.bag;o.format=t.format,o.minimum=r,o.maximum=n}),e._zod.check=i=>{let o=i.value;o<r&&i.issues.push({origin:"bigint",input:o,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort}),o>n&&i.issues.push({origin:"bigint",input:o,code:"too_big",maximum:n,inclusive:!0,inst:e,continue:!t.abort})}}),Ms=d("$ZodCheckMaxSize",(e,t)=>{var r;J.init(e,t),(r=e._zod.def).when??(r.when=n=>{let i=n.value;return!Fe(i)&&i.size!==void 0}),e._zod.onattach.push(n=>{let i=n._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<i&&(n._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let i=n.value;i.size<=t.maximum||n.issues.push({origin:Ht(i),code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),Fs=d("$ZodCheckMinSize",(e,t)=>{var r;J.init(e,t),(r=e._zod.def).when??(r.when=n=>{let i=n.value;return!Fe(i)&&i.size!==void 0}),e._zod.onattach.push(n=>{let i=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>i&&(n._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let i=n.value;i.size>=t.minimum||n.issues.push({origin:Ht(i),code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),Vs=d("$ZodCheckSizeEquals",(e,t)=>{var r;J.init(e,t),(r=e._zod.def).when??(r.when=n=>{let i=n.value;return!Fe(i)&&i.size!==void 0}),e._zod.onattach.push(n=>{let i=n._zod.bag;i.minimum=t.size,i.maximum=t.size,i.size=t.size}),e._zod.check=n=>{let i=n.value,o=i.size;if(o===t.size)return;let a=o>t.size;n.issues.push({origin:Ht(i),...a?{code:"too_big",maximum:t.size}:{code:"too_small",minimum:t.size},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Js=d("$ZodCheckMaxLength",(e,t)=>{var r;J.init(e,t),(r=e._zod.def).when??(r.when=n=>{let i=n.value;return!Fe(i)&&i.length!==void 0}),e._zod.onattach.push(n=>{let i=n._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<i&&(n._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let i=n.value;if(i.length<=t.maximum)return;let a=Qt(i);n.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),Ws=d("$ZodCheckMinLength",(e,t)=>{var r;J.init(e,t),(r=e._zod.def).when??(r.when=n=>{let i=n.value;return!Fe(i)&&i.length!==void 0}),e._zod.onattach.push(n=>{let i=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>i&&(n._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let i=n.value;if(i.length>=t.minimum)return;let a=Qt(i);n.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),Bs=d("$ZodCheckLengthEquals",(e,t)=>{var r;J.init(e,t),(r=e._zod.def).when??(r.when=n=>{let i=n.value;return!Fe(i)&&i.length!==void 0}),e._zod.onattach.push(n=>{let i=n._zod.bag;i.minimum=t.length,i.maximum=t.length,i.length=t.length}),e._zod.check=n=>{let i=n.value,o=i.length;if(o===t.length)return;let a=Qt(i),s=o>t.length;n.issues.push({origin:a,...s?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),sr=d("$ZodCheckStringFormat",(e,t)=>{var r,n;J.init(e,t),e._zod.onattach.push(i=>{let o=i._zod.bag;o.format=t.format,t.pattern&&(o.patterns??(o.patterns=new Set),o.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.check=i=>{t.pattern.lastIndex=0,!t.pattern.test(i.value)&&i.issues.push({origin:"string",code:"invalid_format",format:t.format,input:i.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),Ks=d("$ZodCheckRegex",(e,t)=>{sr.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Gs=d("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Ii),sr.init(e,t)}),qs=d("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=zi),sr.init(e,t)}),Xs=d("$ZodCheckIncludes",(e,t)=>{J.init(e,t);let r=he(t.includes),n=new RegExp(typeof t.position=="number"?`^.{${t.position}}${r}`:r);t.pattern=n,e._zod.onattach.push(i=>{let o=i._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=i=>{i.value.includes(t.includes,t.position)||i.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:i.value,inst:e,continue:!t.abort})}}),Ys=d("$ZodCheckStartsWith",(e,t)=>{J.init(e,t);let r=new RegExp(`^${he(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{let i=n._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(r)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Hs=d("$ZodCheckEndsWith",(e,t)=>{J.init(e,t);let r=new RegExp(`.*${he(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{let i=n._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(r)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}});function Us(e,t,r){e.issues.length&&t.issues.push(...pe(r,e.issues))}var Qs=d("$ZodCheckProperty",(e,t)=>{J.init(e,t),e._zod.check=r=>{let n=t.schema._zod.run({value:r.value[t.property],issues:[]},{});if(n instanceof Promise)return n.then(i=>Us(i,r,t.property));Us(n,r,t.property)}}),ec=d("$ZodCheckMimeType",(e,t)=>{J.init(e,t);let r=new Set(t.mime);e._zod.onattach.push(n=>{n._zod.bag.mime=t.mime}),e._zod.check=n=>{r.has(n.value.type)||n.issues.push({code:"invalid_value",values:t.mime,input:n.value.type,inst:e,continue:!t.abort})}}),tc=d("$ZodCheckOverwrite",(e,t)=>{J.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}});var Ar=class{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}let n=t.split(`
|
|
29
|
-
|
|
30
|
-
`))}};var nc={major:4,minor:3,patch:6};var P=d("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=nc;let n=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&n.unshift(e);for(let i of n)for(let o of i._zod.onattach)o(e);if(n.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let i=(a,s,c)=>{let u=We(a),l;for(let p of s){if(p._zod.def.when){if(!p._zod.def.when(a))continue}else if(u)continue;let h=a.issues.length,v=p._zod.check(a);if(v instanceof Promise&&c?.async===!1)throw new we;if(l||v instanceof Promise)l=(l??Promise.resolve()).then(async()=>{await v,a.issues.length!==h&&(u||(u=We(a,h)))});else{if(a.issues.length===h)continue;u||(u=We(a,h))}}return l?l.then(()=>a):a},o=(a,s,c)=>{if(We(a))return a.aborted=!0,a;let u=i(s,n,c);if(u instanceof Promise){if(c.async===!1)throw new we;return u.then(l=>e._zod.parse(l,c))}return e._zod.parse(u,c)};e._zod.run=(a,s)=>{if(s.skipChecks)return e._zod.parse(a,s);if(s.direction==="backward"){let u=e._zod.parse({value:a.value,issues:[]},{...s,skipChecks:!0});return u instanceof Promise?u.then(l=>o(l,a,s)):o(u,a,s)}let c=e._zod.parse(a,s);if(c instanceof Promise){if(s.async===!1)throw new we;return c.then(u=>i(u,n,s))}return i(c,n,s)}}D(e,"~standard",()=>({validate:i=>{try{let o=ks(e,i);return o.success?{value:o.data}:{issues:o.error?.issues}}catch{return Ss(e,i).then(a=>a.success?{value:a.data}:{issues:a.error?.issues})}},vendor:"zod",version:1}))}),kt=d("$ZodString",(e,t)=>{P.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??$i(e._zod.bag),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),F=d("$ZodStringFormat",(e,t)=>{sr.init(e,t),kt.init(e,t)}),gc=d("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=si),F.init(e,t)}),hc=d("$ZodUUID",(e,t)=>{if(t.version){let n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(n===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=tt(n))}else t.pattern??(t.pattern=tt());F.init(e,t)}),vc=d("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=ci),F.init(e,t)}),_c=d("$ZodURL",(e,t)=>{F.init(e,t),e._zod.check=r=>{try{let n=r.value.trim(),i=new URL(n);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:r.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(":")?i.protocol.slice(0,-1):i.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort})),t.normalize?r.value=i.href:r.value=n;return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),yc=d("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=ui()),F.init(e,t)}),$c=d("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=oi),F.init(e,t)}),xc=d("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=ei),F.init(e,t)}),bc=d("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=ti),F.init(e,t)}),kc=d("$ZodULID",(e,t)=>{t.pattern??(t.pattern=ri),F.init(e,t)}),Sc=d("$ZodXID",(e,t)=>{t.pattern??(t.pattern=ni),F.init(e,t)}),wc=d("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=ii),F.init(e,t)}),Ic=d("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=yi(t)),F.init(e,t)}),zc=d("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=vi),F.init(e,t)}),Oc=d("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=_i(t)),F.init(e,t)}),Pc=d("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=ai),F.init(e,t)}),Tc=d("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=li),F.init(e,t),e._zod.bag.format="ipv4"}),jc=d("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=di),F.init(e,t),e._zod.bag.format="ipv6",e._zod.check=r=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}}),Dc=d("$ZodMAC",(e,t)=>{t.pattern??(t.pattern=pi(t.delimiter)),F.init(e,t),e._zod.bag.format="mac"}),Ec=d("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=mi),F.init(e,t)}),Nc=d("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=fi),F.init(e,t),e._zod.check=r=>{let n=r.value.split("/");try{if(n.length!==2)throw new Error;let[i,o]=n;if(!o)throw new Error;let a=Number(o);if(`${a}`!==o)throw new Error;if(a<0||a>128)throw new Error;new URL(`http://[${i}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}}});function Zc(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var Uc=d("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=gi),F.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=r=>{Zc(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}});function vm(e){if(!Zr.test(e))return!1;let t=e.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return Zc(r)}var Ac=d("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Zr),F.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=r=>{vm(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),Rc=d("$ZodE164",(e,t)=>{t.pattern??(t.pattern=hi),F.init(e,t)});function _m(e,t=null){try{let r=e.split(".");if(r.length!==3)return!1;let[n]=r;if(!n)return!1;let i=JSON.parse(atob(n));return!("typ"in i&&i?.typ!=="JWT"||!i.alg||t&&(!("alg"in i)||i.alg!==t))}catch{return!1}}var Cc=d("$ZodJWT",(e,t)=>{F.init(e,t),e._zod.check=r=>{_m(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}}),Lc=d("$ZodCustomStringFormat",(e,t)=>{F.init(e,t),e._zod.check=r=>{t.fn(r.value)||r.issues.push({code:"invalid_format",format:t.format,input:r.value,inst:e,continue:!t.abort})}}),ji=d("$ZodNumber",(e,t)=>{P.init(e,t),e._zod.pattern=e._zod.bag.pattern??Ur,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch{}let i=r.value;if(typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i))return r;let o=typeof i=="number"?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:i,inst:e,...o?{received:o}:{}}),r}}),Mc=d("$ZodNumberFormat",(e,t)=>{Cs.init(e,t),ji.init(e,t)}),Vr=d("$ZodBoolean",(e,t)=>{P.init(e,t),e._zod.pattern=ki,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=!!r.value}catch{}let i=r.value;return typeof i=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:e}),r}}),Di=d("$ZodBigInt",(e,t)=>{P.init(e,t),e._zod.pattern=xi,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=BigInt(r.value)}catch{}return typeof r.value=="bigint"||r.issues.push({expected:"bigint",code:"invalid_type",input:r.value,inst:e}),r}}),Fc=d("$ZodBigIntFormat",(e,t)=>{Ls.init(e,t),Di.init(e,t)}),Vc=d("$ZodSymbol",(e,t)=>{P.init(e,t),e._zod.parse=(r,n)=>{let i=r.value;return typeof i=="symbol"||r.issues.push({expected:"symbol",code:"invalid_type",input:i,inst:e}),r}}),Jc=d("$ZodUndefined",(e,t)=>{P.init(e,t),e._zod.pattern=wi,e._zod.values=new Set([void 0]),e._zod.optin="optional",e._zod.optout="optional",e._zod.parse=(r,n)=>{let i=r.value;return typeof i>"u"||r.issues.push({expected:"undefined",code:"invalid_type",input:i,inst:e}),r}}),Wc=d("$ZodNull",(e,t)=>{P.init(e,t),e._zod.pattern=Si,e._zod.values=new Set([null]),e._zod.parse=(r,n)=>{let i=r.value;return i===null||r.issues.push({expected:"null",code:"invalid_type",input:i,inst:e}),r}}),Bc=d("$ZodAny",(e,t)=>{P.init(e,t),e._zod.parse=r=>r}),Kc=d("$ZodUnknown",(e,t)=>{P.init(e,t),e._zod.parse=r=>r}),Gc=d("$ZodNever",(e,t)=>{P.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)}),qc=d("$ZodVoid",(e,t)=>{P.init(e,t),e._zod.parse=(r,n)=>{let i=r.value;return typeof i>"u"||r.issues.push({expected:"void",code:"invalid_type",input:i,inst:e}),r}}),Xc=d("$ZodDate",(e,t)=>{P.init(e,t),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=new Date(r.value)}catch{}let i=r.value,o=i instanceof Date;return o&&!Number.isNaN(i.getTime())||r.issues.push({expected:"date",code:"invalid_type",input:i,...o?{received:"Invalid Date"}:{},inst:e}),r}});function ic(e,t,r){e.issues.length&&t.issues.push(...pe(r,e.issues)),t.value[r]=e.value}var Yc=d("$ZodArray",(e,t)=>{P.init(e,t),e._zod.parse=(r,n)=>{let i=r.value;if(!Array.isArray(i))return r.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),r;r.value=Array(i.length);let o=[];for(let a=0;a<i.length;a++){let s=i[a],c=t.element._zod.run({value:s,issues:[]},n);c instanceof Promise?o.push(c.then(u=>ic(u,r,a))):ic(c,r,a)}return o.length?Promise.all(o).then(()=>r):r}});function Fr(e,t,r,n,i){if(e.issues.length){if(i&&!(r in n))return;t.issues.push(...pe(r,e.issues))}e.value===void 0?r in n&&(t.value[r]=void 0):t.value[r]=e.value}function Hc(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${n}": expected a Zod schema`);let r=Kn(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)}}function Qc(e,t,r,n,i,o){let a=[],s=i.keySet,c=i.catchall._zod,u=c.def.type,l=c.optout==="optional";for(let p in t){if(s.has(p))continue;if(u==="never"){a.push(p);continue}let h=c.run({value:t[p],issues:[]},n);h instanceof Promise?e.push(h.then(v=>Fr(v,r,p,t,l))):Fr(h,r,p,t,l)}return a.length&&r.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:o}),e.length?Promise.all(e).then(()=>r):r}var ym=d("$ZodObject",(e,t)=>{if(P.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){let s=t.shape;Object.defineProperty(t,"shape",{get:()=>{let c={...s};return Object.defineProperty(t,"shape",{value:c}),c}})}let n=xt(()=>Hc(t));D(e._zod,"propValues",()=>{let s=t.shape,c={};for(let u in s){let l=s[u]._zod;if(l.values){c[u]??(c[u]=new Set);for(let p of l.values)c[u].add(p)}}return c});let i=et,o=t.catchall,a;e._zod.parse=(s,c)=>{a??(a=n.value);let u=s.value;if(!i(u))return s.issues.push({expected:"object",code:"invalid_type",input:u,inst:e}),s;s.value={};let l=[],p=a.shape;for(let h of a.keys){let v=p[h],A=v._zod.optout==="optional",Z=v._zod.run({value:u[h],issues:[]},c);Z instanceof Promise?l.push(Z.then(R=>Fr(R,s,h,u,A))):Fr(Z,s,h,u,A)}return o?Qc(l,u,s,c,n.value,e):l.length?Promise.all(l).then(()=>s):s}}),eu=d("$ZodObjectJIT",(e,t)=>{ym.init(e,t);let r=e._zod.parse,n=xt(()=>Hc(t)),i=h=>{let v=new Ar(["shape","payload","ctx"]),A=n.value,Z=H=>{let B=Dr(H);return`shape[${B}]._zod.run({ value: input[${B}], issues: [] }, ctx)`};v.write("const input = payload.value;");let R=Object.create(null),G=0;for(let H of A.keys)R[H]=`key_${G++}`;v.write("const newResult = {};");for(let H of A.keys){let B=R[H],Q=Dr(H),C=h[H]?._zod?.optout==="optional";v.write(`const ${B} = ${Z(H)};`),C?v.write(`
|
|
31
|
-
if (${B}.issues.length) {
|
|
32
|
-
if (${Q} in input) {
|
|
33
|
-
payload.issues = payload.issues.concat(${B}.issues.map(iss => ({
|
|
34
|
-
...iss,
|
|
35
|
-
path: iss.path ? [${Q}, ...iss.path] : [${Q}]
|
|
36
|
-
})));
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if (${B}.value === undefined) {
|
|
41
|
-
if (${Q} in input) {
|
|
42
|
-
newResult[${Q}] = undefined;
|
|
43
|
-
}
|
|
44
|
-
} else {
|
|
45
|
-
newResult[${Q}] = ${B}.value;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
`):v.write(`
|
|
49
|
-
if (${B}.issues.length) {
|
|
50
|
-
payload.issues = payload.issues.concat(${B}.issues.map(iss => ({
|
|
51
|
-
...iss,
|
|
52
|
-
path: iss.path ? [${Q}, ...iss.path] : [${Q}]
|
|
53
|
-
})));
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
if (${B}.value === undefined) {
|
|
57
|
-
if (${Q} in input) {
|
|
58
|
-
newResult[${Q}] = undefined;
|
|
59
|
-
}
|
|
60
|
-
} else {
|
|
61
|
-
newResult[${Q}] = ${B}.value;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
`)}v.write("payload.value = newResult;"),v.write("return payload;");let ze=v.compile();return(H,B)=>ze(h,H,B)},o,a=et,s=!jr.jitless,u=s&&Wn.value,l=t.catchall,p;e._zod.parse=(h,v)=>{p??(p=n.value);let A=h.value;return a(A)?s&&u&&v?.async===!1&&v.jitless!==!0?(o||(o=i(t.shape)),h=o(h,v),l?Qc([],A,h,v,p,e):h):r(h,v):(h.issues.push({expected:"object",code:"invalid_type",input:A,inst:e}),h)}});function oc(e,t,r,n){for(let o of e)if(o.issues.length===0)return t.value=o.value,t;let i=e.filter(o=>!We(o));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(o=>o.issues.map(a=>ae(a,n,ee())))}),t)}var Jr=d("$ZodUnion",(e,t)=>{P.init(e,t),D(e._zod,"optin",()=>t.options.some(i=>i._zod.optin==="optional")?"optional":void 0),D(e._zod,"optout",()=>t.options.some(i=>i._zod.optout==="optional")?"optional":void 0),D(e._zod,"values",()=>{if(t.options.every(i=>i._zod.values))return new Set(t.options.flatMap(i=>Array.from(i._zod.values)))}),D(e._zod,"pattern",()=>{if(t.options.every(i=>i._zod.pattern)){let i=t.options.map(o=>o._zod.pattern);return new RegExp(`^(${i.map(o=>Xt(o.source)).join("|")})$`)}});let r=t.options.length===1,n=t.options[0]._zod.run;e._zod.parse=(i,o)=>{if(r)return n(i,o);let a=!1,s=[];for(let c of t.options){let u=c._zod.run({value:i.value,issues:[]},o);if(u instanceof Promise)s.push(u),a=!0;else{if(u.issues.length===0)return u;s.push(u)}}return a?Promise.all(s).then(c=>oc(c,i,e,o)):oc(s,i,e,o)}});function ac(e,t,r,n){let i=e.filter(o=>o.issues.length===0);return i.length===1?(t.value=i[0].value,t):(i.length===0?t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(o=>o.issues.map(a=>ae(a,n,ee())))}):t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:[],inclusive:!1}),t)}var tu=d("$ZodXor",(e,t)=>{Jr.init(e,t),t.inclusive=!1;let r=t.options.length===1,n=t.options[0]._zod.run;e._zod.parse=(i,o)=>{if(r)return n(i,o);let a=!1,s=[];for(let c of t.options){let u=c._zod.run({value:i.value,issues:[]},o);u instanceof Promise?(s.push(u),a=!0):s.push(u)}return a?Promise.all(s).then(c=>ac(c,i,e,o)):ac(s,i,e,o)}}),ru=d("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Jr.init(e,t);let r=e._zod.parse;D(e._zod,"propValues",()=>{let i={};for(let o of t.options){let a=o._zod.propValues;if(!a||Object.keys(a).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(o)}"`);for(let[s,c]of Object.entries(a)){i[s]||(i[s]=new Set);for(let u of c)i[s].add(u)}}return i});let n=xt(()=>{let i=t.options,o=new Map;for(let a of i){let s=a._zod.propValues?.[t.discriminator];if(!s||s.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(a)}"`);for(let c of s){if(o.has(c))throw new Error(`Duplicate discriminator value "${String(c)}"`);o.set(c,a)}}return o});e._zod.parse=(i,o)=>{let a=i.value;if(!et(a))return i.issues.push({code:"invalid_type",expected:"object",input:a,inst:e}),i;let s=n.value.get(a?.[t.discriminator]);return s?s._zod.run(i,o):t.unionFallback?r(i,o):(i.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:a,path:[t.discriminator],inst:e}),i)}}),nu=d("$ZodIntersection",(e,t)=>{P.init(e,t),e._zod.parse=(r,n)=>{let i=r.value,o=t.left._zod.run({value:i,issues:[]},n),a=t.right._zod.run({value:i,issues:[]},n);return o instanceof Promise||a instanceof Promise?Promise.all([o,a]).then(([c,u])=>sc(r,c,u)):sc(r,o,a)}});function Ti(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Je(e)&&Je(t)){let r=Object.keys(t),n=Object.keys(e).filter(o=>r.indexOf(o)!==-1),i={...e,...t};for(let o of n){let a=Ti(e[o],t[o]);if(!a.valid)return{valid:!1,mergeErrorPath:[o,...a.mergeErrorPath]};i[o]=a.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let n=0;n<e.length;n++){let i=e[n],o=t[n],a=Ti(i,o);if(!a.valid)return{valid:!1,mergeErrorPath:[n,...a.mergeErrorPath]};r.push(a.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function sc(e,t,r){let n=new Map,i;for(let s of t.issues)if(s.code==="unrecognized_keys"){i??(i=s);for(let c of s.keys)n.has(c)||n.set(c,{}),n.get(c).l=!0}else e.issues.push(s);for(let s of r.issues)if(s.code==="unrecognized_keys")for(let c of s.keys)n.has(c)||n.set(c,{}),n.get(c).r=!0;else e.issues.push(s);let o=[...n].filter(([,s])=>s.l&&s.r).map(([s])=>s);if(o.length&&i&&e.issues.push({...i,keys:o}),We(e))return e;let a=Ti(t.value,r.value);if(!a.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(a.mergeErrorPath)}`);return e.value=a.data,e}var Ei=d("$ZodTuple",(e,t)=>{P.init(e,t);let r=t.items;e._zod.parse=(n,i)=>{let o=n.value;if(!Array.isArray(o))return n.issues.push({input:o,inst:e,expected:"tuple",code:"invalid_type"}),n;n.value=[];let a=[],s=[...r].reverse().findIndex(l=>l._zod.optin!=="optional"),c=s===-1?0:r.length-s;if(!t.rest){let l=o.length>r.length,p=o.length<c-1;if(l||p)return n.issues.push({...l?{code:"too_big",maximum:r.length,inclusive:!0}:{code:"too_small",minimum:r.length},input:o,inst:e,origin:"array"}),n}let u=-1;for(let l of r){if(u++,u>=o.length&&u>=c)continue;let p=l._zod.run({value:o[u],issues:[]},i);p instanceof Promise?a.push(p.then(h=>Rr(h,n,u))):Rr(p,n,u)}if(t.rest){let l=o.slice(r.length);for(let p of l){u++;let h=t.rest._zod.run({value:p,issues:[]},i);h instanceof Promise?a.push(h.then(v=>Rr(v,n,u))):Rr(h,n,u)}}return a.length?Promise.all(a).then(()=>n):n}});function Rr(e,t,r){e.issues.length&&t.issues.push(...pe(r,e.issues)),t.value[r]=e.value}var iu=d("$ZodRecord",(e,t)=>{P.init(e,t),e._zod.parse=(r,n)=>{let i=r.value;if(!Je(i))return r.issues.push({expected:"record",code:"invalid_type",input:i,inst:e}),r;let o=[],a=t.keyType._zod.values;if(a){r.value={};let s=new Set;for(let u of a)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){s.add(typeof u=="number"?u.toString():u);let l=t.valueType._zod.run({value:i[u],issues:[]},n);l instanceof Promise?o.push(l.then(p=>{p.issues.length&&r.issues.push(...pe(u,p.issues)),r.value[u]=p.value})):(l.issues.length&&r.issues.push(...pe(u,l.issues)),r.value[u]=l.value)}let c;for(let u in i)s.has(u)||(c=c??[],c.push(u));c&&c.length>0&&r.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:c})}else{r.value={};for(let s of Reflect.ownKeys(i)){if(s==="__proto__")continue;let c=t.keyType._zod.run({value:s,issues:[]},n);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof s=="string"&&Ur.test(s)&&c.issues.length){let p=t.keyType._zod.run({value:Number(s),issues:[]},n);if(p instanceof Promise)throw new Error("Async schemas not supported in object keys currently");p.issues.length===0&&(c=p)}if(c.issues.length){t.mode==="loose"?r.value[s]=i[s]:r.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(p=>ae(p,n,ee())),input:s,path:[s],inst:e});continue}let l=t.valueType._zod.run({value:i[s],issues:[]},n);l instanceof Promise?o.push(l.then(p=>{p.issues.length&&r.issues.push(...pe(s,p.issues)),r.value[c.value]=p.value})):(l.issues.length&&r.issues.push(...pe(s,l.issues)),r.value[c.value]=l.value)}}return o.length?Promise.all(o).then(()=>r):r}}),ou=d("$ZodMap",(e,t)=>{P.init(e,t),e._zod.parse=(r,n)=>{let i=r.value;if(!(i instanceof Map))return r.issues.push({expected:"map",code:"invalid_type",input:i,inst:e}),r;let o=[];r.value=new Map;for(let[a,s]of i){let c=t.keyType._zod.run({value:a,issues:[]},n),u=t.valueType._zod.run({value:s,issues:[]},n);c instanceof Promise||u instanceof Promise?o.push(Promise.all([c,u]).then(([l,p])=>{cc(l,p,r,a,i,e,n)})):cc(c,u,r,a,i,e,n)}return o.length?Promise.all(o).then(()=>r):r}});function cc(e,t,r,n,i,o,a){e.issues.length&&(Yt.has(typeof n)?r.issues.push(...pe(n,e.issues)):r.issues.push({code:"invalid_key",origin:"map",input:i,inst:o,issues:e.issues.map(s=>ae(s,a,ee()))})),t.issues.length&&(Yt.has(typeof n)?r.issues.push(...pe(n,t.issues)):r.issues.push({origin:"map",code:"invalid_element",input:i,inst:o,key:n,issues:t.issues.map(s=>ae(s,a,ee()))})),r.value.set(e.value,t.value)}var au=d("$ZodSet",(e,t)=>{P.init(e,t),e._zod.parse=(r,n)=>{let i=r.value;if(!(i instanceof Set))return r.issues.push({input:i,inst:e,expected:"set",code:"invalid_type"}),r;let o=[];r.value=new Set;for(let a of i){let s=t.valueType._zod.run({value:a,issues:[]},n);s instanceof Promise?o.push(s.then(c=>uc(c,r))):uc(s,r)}return o.length?Promise.all(o).then(()=>r):r}});function uc(e,t){e.issues.length&&t.issues.push(...e.issues),t.value.add(e.value)}var su=d("$ZodEnum",(e,t)=>{P.init(e,t);let r=qt(t.entries),n=new Set(r);e._zod.values=n,e._zod.pattern=new RegExp(`^(${r.filter(i=>Yt.has(typeof i)).map(i=>typeof i=="string"?he(i):i.toString()).join("|")})$`),e._zod.parse=(i,o)=>{let a=i.value;return n.has(a)||i.issues.push({code:"invalid_value",values:r,input:a,inst:e}),i}}),cu=d("$ZodLiteral",(e,t)=>{if(P.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");let r=new Set(t.values);e._zod.values=r,e._zod.pattern=new RegExp(`^(${t.values.map(n=>typeof n=="string"?he(n):n?he(n.toString()):String(n)).join("|")})$`),e._zod.parse=(n,i)=>{let o=n.value;return r.has(o)||n.issues.push({code:"invalid_value",values:t.values,input:o,inst:e}),n}}),uu=d("$ZodFile",(e,t)=>{P.init(e,t),e._zod.parse=(r,n)=>{let i=r.value;return i instanceof File||r.issues.push({expected:"file",code:"invalid_type",input:i,inst:e}),r}}),lu=d("$ZodTransform",(e,t)=>{P.init(e,t),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Qe(e.constructor.name);let i=t.transform(r.value,r);if(n.async)return(i instanceof Promise?i:Promise.resolve(i)).then(a=>(r.value=a,r));if(i instanceof Promise)throw new we;return r.value=i,r}});function lc(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}var Ni=d("$ZodOptional",(e,t)=>{P.init(e,t),e._zod.optin="optional",e._zod.optout="optional",D(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),D(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${Xt(r.source)})?$`):void 0}),e._zod.parse=(r,n)=>{if(t.innerType._zod.optin==="optional"){let i=t.innerType._zod.run(r,n);return i instanceof Promise?i.then(o=>lc(o,r.value)):lc(i,r.value)}return r.value===void 0?r:t.innerType._zod.run(r,n)}}),du=d("$ZodExactOptional",(e,t)=>{Ni.init(e,t),D(e._zod,"values",()=>t.innerType._zod.values),D(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(r,n)=>t.innerType._zod.run(r,n)}),pu=d("$ZodNullable",(e,t)=>{P.init(e,t),D(e._zod,"optin",()=>t.innerType._zod.optin),D(e._zod,"optout",()=>t.innerType._zod.optout),D(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${Xt(r.source)}|null)$`):void 0}),D(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(r,n)=>r.value===null?r:t.innerType._zod.run(r,n)}),mu=d("$ZodDefault",(e,t)=>{P.init(e,t),e._zod.optin="optional",D(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);if(r.value===void 0)return r.value=t.defaultValue,r;let i=t.innerType._zod.run(r,n);return i instanceof Promise?i.then(o=>dc(o,t)):dc(i,t)}});function dc(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var fu=d("$ZodPrefault",(e,t)=>{P.init(e,t),e._zod.optin="optional",D(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>(n.direction==="backward"||r.value===void 0&&(r.value=t.defaultValue),t.innerType._zod.run(r,n))}),gu=d("$ZodNonOptional",(e,t)=>{P.init(e,t),D(e._zod,"values",()=>{let r=t.innerType._zod.values;return r?new Set([...r].filter(n=>n!==void 0)):void 0}),e._zod.parse=(r,n)=>{let i=t.innerType._zod.run(r,n);return i instanceof Promise?i.then(o=>pc(o,e)):pc(i,e)}});function pc(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}var hu=d("$ZodSuccess",(e,t)=>{P.init(e,t),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Qe("ZodSuccess");let i=t.innerType._zod.run(r,n);return i instanceof Promise?i.then(o=>(r.value=o.issues.length===0,r)):(r.value=i.issues.length===0,r)}}),vu=d("$ZodCatch",(e,t)=>{P.init(e,t),D(e._zod,"optin",()=>t.innerType._zod.optin),D(e._zod,"optout",()=>t.innerType._zod.optout),D(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);let i=t.innerType._zod.run(r,n);return i instanceof Promise?i.then(o=>(r.value=o.value,o.issues.length&&(r.value=t.catchValue({...r,error:{issues:o.issues.map(a=>ae(a,n,ee()))},input:r.value}),r.issues=[]),r)):(r.value=i.value,i.issues.length&&(r.value=t.catchValue({...r,error:{issues:i.issues.map(o=>ae(o,n,ee()))},input:r.value}),r.issues=[]),r)}}),_u=d("$ZodNaN",(e,t)=>{P.init(e,t),e._zod.parse=(r,n)=>((typeof r.value!="number"||!Number.isNaN(r.value))&&r.issues.push({input:r.value,inst:e,expected:"nan",code:"invalid_type"}),r)}),yu=d("$ZodPipe",(e,t)=>{P.init(e,t),D(e._zod,"values",()=>t.in._zod.values),D(e._zod,"optin",()=>t.in._zod.optin),D(e._zod,"optout",()=>t.out._zod.optout),D(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(r,n)=>{if(n.direction==="backward"){let o=t.out._zod.run(r,n);return o instanceof Promise?o.then(a=>Cr(a,t.in,n)):Cr(o,t.in,n)}let i=t.in._zod.run(r,n);return i instanceof Promise?i.then(o=>Cr(o,t.out,n)):Cr(i,t.out,n)}});function Cr(e,t,r){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},r)}var Wr=d("$ZodCodec",(e,t)=>{P.init(e,t),D(e._zod,"values",()=>t.in._zod.values),D(e._zod,"optin",()=>t.in._zod.optin),D(e._zod,"optout",()=>t.out._zod.optout),D(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(r,n)=>{if((n.direction||"forward")==="forward"){let o=t.in._zod.run(r,n);return o instanceof Promise?o.then(a=>Lr(a,t,n)):Lr(o,t,n)}else{let o=t.out._zod.run(r,n);return o instanceof Promise?o.then(a=>Lr(a,t,n)):Lr(o,t,n)}}});function Lr(e,t,r){if(e.issues.length)return e.aborted=!0,e;if((r.direction||"forward")==="forward"){let i=t.transform(e.value,e);return i instanceof Promise?i.then(o=>Mr(e,o,t.out,r)):Mr(e,i,t.out,r)}else{let i=t.reverseTransform(e.value,e);return i instanceof Promise?i.then(o=>Mr(e,o,t.in,r)):Mr(e,i,t.in,r)}}function Mr(e,t,r,n){return e.issues.length?(e.aborted=!0,e):r._zod.run({value:t,issues:e.issues},n)}var $u=d("$ZodReadonly",(e,t)=>{P.init(e,t),D(e._zod,"propValues",()=>t.innerType._zod.propValues),D(e._zod,"values",()=>t.innerType._zod.values),D(e._zod,"optin",()=>t.innerType?._zod?.optin),D(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);let i=t.innerType._zod.run(r,n);return i instanceof Promise?i.then(mc):mc(i)}});function mc(e){return e.value=Object.freeze(e.value),e}var xu=d("$ZodTemplateLiteral",(e,t)=>{P.init(e,t);let r=[];for(let n of t.parts)if(typeof n=="object"&&n!==null){if(!n._zod.pattern)throw new Error(`Invalid template literal part, no pattern found: ${[...n._zod.traits].shift()}`);let i=n._zod.pattern instanceof RegExp?n._zod.pattern.source:n._zod.pattern;if(!i)throw new Error(`Invalid template literal part: ${n._zod.traits}`);let o=i.startsWith("^")?1:0,a=i.endsWith("$")?i.length-1:i.length;r.push(i.slice(o,a))}else if(n===null||Bn.has(typeof n))r.push(he(`${n}`));else throw new Error(`Invalid template literal part: ${n}`);e._zod.pattern=new RegExp(`^${r.join("")}$`),e._zod.parse=(n,i)=>typeof n.value!="string"?(n.issues.push({input:n.value,inst:e,expected:"string",code:"invalid_type"}),n):(e._zod.pattern.lastIndex=0,e._zod.pattern.test(n.value)||n.issues.push({input:n.value,inst:e,code:"invalid_format",format:t.format??"template_literal",pattern:e._zod.pattern.source}),n)}),bu=d("$ZodFunction",(e,t)=>(P.init(e,t),e._def=t,e._zod.def=t,e.implement=r=>{if(typeof r!="function")throw new Error("implement() must be called with a function");return function(...n){let i=e._def.input?Hn(e._def.input,n):n,o=Reflect.apply(r,this,i);return e._def.output?Hn(e._def.output,o):o}},e.implementAsync=r=>{if(typeof r!="function")throw new Error("implementAsync() must be called with a function");return async function(...n){let i=e._def.input?await Qn(e._def.input,n):n,o=await Reflect.apply(r,this,i);return e._def.output?await Qn(e._def.output,o):o}},e._zod.parse=(r,n)=>typeof r.value!="function"?(r.issues.push({code:"invalid_type",expected:"function",input:r.value,inst:e}),r):(e._def.output&&e._def.output._zod.def.type==="promise"?r.value=e.implementAsync(r.value):r.value=e.implement(r.value),r),e.input=(...r)=>{let n=e.constructor;return Array.isArray(r[0])?new n({type:"function",input:new Ei({type:"tuple",items:r[0],rest:r[1]}),output:e._def.output}):new n({type:"function",input:r[0],output:e._def.output})},e.output=r=>{let n=e.constructor;return new n({type:"function",input:e._def.input,output:r})},e)),ku=d("$ZodPromise",(e,t)=>{P.init(e,t),e._zod.parse=(r,n)=>Promise.resolve(r.value).then(i=>t.innerType._zod.run({value:i,issues:[]},n))}),Su=d("$ZodLazy",(e,t)=>{P.init(e,t),D(e._zod,"innerType",()=>t.getter()),D(e._zod,"pattern",()=>e._zod.innerType?._zod?.pattern),D(e._zod,"propValues",()=>e._zod.innerType?._zod?.propValues),D(e._zod,"optin",()=>e._zod.innerType?._zod?.optin??void 0),D(e._zod,"optout",()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(r,n)=>e._zod.innerType._zod.run(r,n)}),wu=d("$ZodCustom",(e,t)=>{J.init(e,t),P.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=r=>{let n=r.value,i=t.fn(n);if(i instanceof Promise)return i.then(o=>fc(o,r,n,e));fc(i,r,n,e)}});function fc(e,t,r,n){if(!e){let i={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(i.params=n._zod.def.params),t.issues.push(bt(i))}}var xm=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function t(i){return e[i]??null}let r={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"},n={nan:"NaN"};return i=>{switch(i.code){case"invalid_type":{let o=n[i.expected]??i.expected,a=O(i.input),s=n[a]??a;return`Invalid input: expected ${o}, received ${s}`}case"invalid_value":return i.values.length===1?`Invalid input: expected ${w(i.values[0])}`:`Invalid option: expected one of ${S(i.values,"|")}`;case"too_big":{let o=i.inclusive?"<=":"<",a=t(i.origin);return a?`Too big: expected ${i.origin??"value"} to have ${o}${i.maximum.toString()} ${a.unit??"elements"}`:`Too big: expected ${i.origin??"value"} to be ${o}${i.maximum.toString()}`}case"too_small":{let o=i.inclusive?">=":">",a=t(i.origin);return a?`Too small: expected ${i.origin} to have ${o}${i.minimum.toString()} ${a.unit}`:`Too small: expected ${i.origin} to be ${o}${i.minimum.toString()}`}case"invalid_format":{let o=i;return o.format==="starts_with"?`Invalid string: must start with "${o.prefix}"`:o.format==="ends_with"?`Invalid string: must end with "${o.suffix}"`:o.format==="includes"?`Invalid string: must include "${o.includes}"`:o.format==="regex"?`Invalid string: must match pattern ${o.pattern}`:`Invalid ${r[o.format]??i.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${i.divisor}`;case"unrecognized_keys":return`Unrecognized key${i.keys.length>1?"s":""}: ${S(i.keys,", ")}`;case"invalid_key":return`Invalid key in ${i.origin}`;case"invalid_union":return"Invalid input";case"invalid_element":return`Invalid value in ${i.origin}`;default:return"Invalid input"}}};function Zi(){return{localeError:xm()}}var zu;var Ui=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...r){let n=r[0];return this._map.set(t,n),n&&typeof n=="object"&&"id"in n&&this._idmap.set(n.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){let r=this._map.get(t);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(t),this}get(t){let r=t._zod.parent;if(r){let n={...this.get(r)??{}};delete n.id;let i={...n,...this._map.get(t)};return Object.keys(i).length?i:void 0}return this._map.get(t)}has(t){return this._map.has(t)}};function Ou(){return new Ui}(zu=globalThis).__zod_globalRegistry??(zu.__zod_globalRegistry=Ou());var se=globalThis.__zod_globalRegistry;function Pu(e,t){return new e({type:"string",...y(t)})}function Ai(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...y(t)})}function Br(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...y(t)})}function Ri(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...y(t)})}function Ci(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...y(t)})}function Li(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...y(t)})}function Mi(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...y(t)})}function Kr(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...y(t)})}function Fi(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...y(t)})}function Vi(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...y(t)})}function Ji(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...y(t)})}function Wi(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...y(t)})}function Bi(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...y(t)})}function Ki(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...y(t)})}function Gi(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...y(t)})}function qi(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...y(t)})}function Xi(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...y(t)})}function Tu(e,t){return new e({type:"string",format:"mac",check:"string_format",abort:!1,...y(t)})}function Yi(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...y(t)})}function Hi(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...y(t)})}function Qi(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...y(t)})}function eo(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...y(t)})}function to(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...y(t)})}function ro(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...y(t)})}function ju(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...y(t)})}function Du(e,t){return new e({type:"string",format:"date",check:"string_format",...y(t)})}function Eu(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...y(t)})}function Nu(e,t){return new e({type:"string",format:"duration",check:"string_format",...y(t)})}function Zu(e,t){return new e({type:"number",checks:[],...y(t)})}function Uu(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...y(t)})}function Au(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float32",...y(t)})}function Ru(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float64",...y(t)})}function Cu(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"int32",...y(t)})}function Lu(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"uint32",...y(t)})}function Mu(e,t){return new e({type:"boolean",...y(t)})}function Fu(e,t){return new e({type:"bigint",...y(t)})}function Vu(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"int64",...y(t)})}function Ju(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"uint64",...y(t)})}function Wu(e,t){return new e({type:"symbol",...y(t)})}function Bu(e,t){return new e({type:"undefined",...y(t)})}function Ku(e,t){return new e({type:"null",...y(t)})}function Gu(e){return new e({type:"any"})}function qu(e){return new e({type:"unknown"})}function Xu(e,t){return new e({type:"never",...y(t)})}function Yu(e,t){return new e({type:"void",...y(t)})}function Hu(e,t){return new e({type:"date",...y(t)})}function Qu(e,t){return new e({type:"nan",...y(t)})}function Be(e,t){return new Oi({check:"less_than",...y(t),value:e,inclusive:!1})}function xe(e,t){return new Oi({check:"less_than",...y(t),value:e,inclusive:!0})}function Ke(e,t){return new Pi({check:"greater_than",...y(t),value:e,inclusive:!1})}function me(e,t){return new Pi({check:"greater_than",...y(t),value:e,inclusive:!0})}function el(e){return Ke(0,e)}function tl(e){return Be(0,e)}function rl(e){return xe(0,e)}function nl(e){return me(0,e)}function St(e,t){return new Rs({check:"multiple_of",...y(t),value:e})}function wt(e,t){return new Ms({check:"max_size",...y(t),maximum:e})}function Ge(e,t){return new Fs({check:"min_size",...y(t),minimum:e})}function cr(e,t){return new Vs({check:"size_equals",...y(t),size:e})}function ur(e,t){return new Js({check:"max_length",...y(t),maximum:e})}function rt(e,t){return new Ws({check:"min_length",...y(t),minimum:e})}function lr(e,t){return new Bs({check:"length_equals",...y(t),length:e})}function Gr(e,t){return new Ks({check:"string_format",format:"regex",...y(t),pattern:e})}function qr(e){return new Gs({check:"string_format",format:"lowercase",...y(e)})}function Xr(e){return new qs({check:"string_format",format:"uppercase",...y(e)})}function Yr(e,t){return new Xs({check:"string_format",format:"includes",...y(t),includes:e})}function Hr(e,t){return new Ys({check:"string_format",format:"starts_with",...y(t),prefix:e})}function Qr(e,t){return new Hs({check:"string_format",format:"ends_with",...y(t),suffix:e})}function il(e,t,r){return new Qs({check:"property",property:e,schema:t,...y(r)})}function en(e,t){return new ec({check:"mime_type",mime:e,...y(t)})}function Ze(e){return new tc({check:"overwrite",tx:e})}function tn(e){return Ze(t=>t.normalize(e))}function rn(){return Ze(e=>e.trim())}function nn(){return Ze(e=>e.toLowerCase())}function on(){return Ze(e=>e.toUpperCase())}function an(){return Ze(e=>Jn(e))}function ol(e,t,r){return new e({type:"array",element:t,...y(r)})}function al(e,t){return new e({type:"file",...y(t)})}function sl(e,t,r){let n=y(r);return n.abort??(n.abort=!0),new e({type:"custom",check:"custom",fn:t,...n})}function cl(e,t,r){return new e({type:"custom",check:"custom",fn:t,...y(r)})}function ul(e){let t=wm(r=>(r.addIssue=n=>{if(typeof n=="string")r.issues.push(bt(n,r.value,t._zod.def));else{let i=n;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=r.value),i.inst??(i.inst=t),i.continue??(i.continue=!t._zod.def.abort),r.issues.push(bt(i))}},e(r.value,r)));return t}function wm(e,t){let r=new J({check:"custom",...y(t)});return r._zod.check=e,r}function ll(e){let t=new J({check:"describe"});return t._zod.onattach=[r=>{let n=se.get(r)??{};se.add(r,{...n,description:e})}],t._zod.check=()=>{},t}function dl(e){let t=new J({check:"meta"});return t._zod.onattach=[r=>{let n=se.get(r)??{};se.add(r,{...n,...e})}],t._zod.check=()=>{},t}function pl(e,t){let r=y(t),n=r.truthy??["true","1","yes","on","y","enabled"],i=r.falsy??["false","0","no","off","n","disabled"];r.case!=="sensitive"&&(n=n.map(v=>typeof v=="string"?v.toLowerCase():v),i=i.map(v=>typeof v=="string"?v.toLowerCase():v));let o=new Set(n),a=new Set(i),s=e.Codec??Wr,c=e.Boolean??Vr,u=e.String??kt,l=new u({type:"string",error:r.error}),p=new c({type:"boolean",error:r.error}),h=new s({type:"pipe",in:l,out:p,transform:((v,A)=>{let Z=v;return r.case!=="sensitive"&&(Z=Z.toLowerCase()),o.has(Z)?!0:a.has(Z)?!1:(A.issues.push({code:"invalid_value",expected:"stringbool",values:[...o,...a],input:A.value,inst:h,continue:!1}),{})}),reverseTransform:((v,A)=>v===!0?n[0]||"true":i[0]||"false"),error:r.error});return h}function dr(e,t,r,n={}){let i=y(n),o={...y(n),check:"string_format",type:"string",format:t,fn:typeof r=="function"?r:s=>r.test(s),...i};return r instanceof RegExp&&(o.pattern=r),new e(o)}function It(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??se,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function L(e,t,r={path:[],schemaPath:[]}){var n;let i=e._zod.def,o=t.seen.get(e);if(o)return o.count++,r.schemaPath.includes(e)&&(o.cycle=r.path),o.schema;let a={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,a);let s=e._zod.toJSONSchema?.();if(s)a.schema=s;else{let l={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,a.schema,l);else{let h=a.schema,v=t.processors[i.type];if(!v)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);v(e,t,h,l)}let p=e._zod.parent;p&&(a.ref||(a.ref=p),L(p,t,l),t.seen.get(p).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(a.schema,c),t.io==="input"&&oe(e)&&(delete a.schema.examples,delete a.schema.default),t.io==="input"&&a.schema._prefault&&((n=a.schema).default??(n.default=a.schema._prefault)),delete a.schema._prefault,t.seen.get(e).schema}function zt(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let n=new Map;for(let a of e.seen.entries()){let s=e.metadataRegistry.get(a[0])?.id;if(s){let c=n.get(s);if(c&&c!==a[0])throw new Error(`Duplicate schema id "${s}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);n.set(s,a[0])}}let i=a=>{let s=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let p=e.external.registry.get(a[0])?.id,h=e.external.uri??(A=>A);if(p)return{ref:h(p)};let v=a[1].defId??a[1].schema.id??`schema${e.counter++}`;return a[1].defId=v,{defId:v,ref:`${h("__shared")}#/${s}/${v}`}}if(a[1]===r)return{ref:"#"};let u=`#/${s}/`,l=a[1].schema.id??`__schema${e.counter++}`;return{defId:l,ref:u+l}},o=a=>{if(a[1].schema.$ref)return;let s=a[1],{ref:c,defId:u}=i(a);s.def={...s.schema},u&&(s.defId=u);let l=s.schema;for(let p in l)delete l[p];l.$ref=c};if(e.cycles==="throw")for(let a of e.seen.entries()){let s=a[1];if(s.cycle)throw new Error(`Cycle detected: #/${s.cycle?.join("/")}/<root>
|
|
65
|
-
|
|
66
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let a of e.seen.entries()){let s=a[1];if(t===a[0]){o(a);continue}if(e.external){let u=e.external.registry.get(a[0])?.id;if(t!==a[0]&&u){o(a);continue}}if(e.metadataRegistry.get(a[0])?.id){o(a);continue}if(s.cycle){o(a);continue}if(s.count>1&&e.reused==="ref"){o(a);continue}}}function Ot(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let n=a=>{let s=e.seen.get(a);if(s.ref===null)return;let c=s.def??s.schema,u={...c},l=s.ref;if(s.ref=null,l){n(l);let h=e.seen.get(l),v=h.schema;if(v.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(c.allOf=c.allOf??[],c.allOf.push(v)):Object.assign(c,v),Object.assign(c,u),a._zod.parent===l)for(let Z in c)Z==="$ref"||Z==="allOf"||Z in u||delete c[Z];if(v.$ref&&h.def)for(let Z in c)Z==="$ref"||Z==="allOf"||Z in h.def&&JSON.stringify(c[Z])===JSON.stringify(h.def[Z])&&delete c[Z]}let p=a._zod.parent;if(p&&p!==l){n(p);let h=e.seen.get(p);if(h?.schema.$ref&&(c.$ref=h.schema.$ref,h.def))for(let v in c)v==="$ref"||v==="allOf"||v in h.def&&JSON.stringify(c[v])===JSON.stringify(h.def[v])&&delete c[v]}e.override({zodSchema:a,jsonSchema:c,path:s.path??[]})};for(let a of[...e.seen.entries()].reverse())n(a[0]);let i={};if(e.target==="draft-2020-12"?i.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?i.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?i.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){let a=e.external.registry.get(t)?.id;if(!a)throw new Error("Schema is missing an `id` property");i.$id=e.external.uri(a)}Object.assign(i,r.def??r.schema);let o=e.external?.defs??{};for(let a of e.seen.entries()){let s=a[1];s.def&&s.defId&&(o[s.defId]=s.def)}e.external||Object.keys(o).length>0&&(e.target==="draft-2020-12"?i.$defs=o:i.definitions=o);try{let a=JSON.parse(JSON.stringify(i));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:pr(t,"input",e.processors),output:pr(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function oe(e,t){let r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);let n=e._zod.def;if(n.type==="transform")return!0;if(n.type==="array")return oe(n.element,r);if(n.type==="set")return oe(n.valueType,r);if(n.type==="lazy")return oe(n.getter(),r);if(n.type==="promise"||n.type==="optional"||n.type==="nonoptional"||n.type==="nullable"||n.type==="readonly"||n.type==="default"||n.type==="prefault")return oe(n.innerType,r);if(n.type==="intersection")return oe(n.left,r)||oe(n.right,r);if(n.type==="record"||n.type==="map")return oe(n.keyType,r)||oe(n.valueType,r);if(n.type==="pipe")return oe(n.in,r)||oe(n.out,r);if(n.type==="object"){for(let i in n.shape)if(oe(n.shape[i],r))return!0;return!1}if(n.type==="union"){for(let i of n.options)if(oe(i,r))return!0;return!1}if(n.type==="tuple"){for(let i of n.items)if(oe(i,r))return!0;return!!(n.rest&&oe(n.rest,r))}return!1}var ml=(e,t={})=>r=>{let n=It({...r,processors:t});return L(e,n),zt(n,e),Ot(n,e)},pr=(e,t,r={})=>n=>{let{libraryOptions:i,target:o}=n??{},a=It({...i??{},target:o,io:t,processors:r});return L(e,a),zt(a,e),Ot(a,e)};var Im={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},io=(e,t,r,n)=>{let i=r;i.type="string";let{minimum:o,maximum:a,format:s,patterns:c,contentEncoding:u}=e._zod.bag;if(typeof o=="number"&&(i.minLength=o),typeof a=="number"&&(i.maxLength=a),s&&(i.format=Im[s]??s,i.format===""&&delete i.format,s==="time"&&delete i.format),u&&(i.contentEncoding=u),c&&c.size>0){let l=[...c];l.length===1?i.pattern=l[0].source:l.length>1&&(i.allOf=[...l.map(p=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:p.source}))])}},oo=(e,t,r,n)=>{let i=r,{minimum:o,maximum:a,format:s,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:l}=e._zod.bag;typeof s=="string"&&s.includes("int")?i.type="integer":i.type="number",typeof l=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(i.minimum=l,i.exclusiveMinimum=!0):i.exclusiveMinimum=l),typeof o=="number"&&(i.minimum=o,typeof l=="number"&&t.target!=="draft-04"&&(l>=o?delete i.minimum:delete i.exclusiveMinimum)),typeof u=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(i.maximum=u,i.exclusiveMaximum=!0):i.exclusiveMaximum=u),typeof a=="number"&&(i.maximum=a,typeof u=="number"&&t.target!=="draft-04"&&(u<=a?delete i.maximum:delete i.exclusiveMaximum)),typeof c=="number"&&(i.multipleOf=c)},ao=(e,t,r,n)=>{r.type="boolean"},so=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema")},co=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema")},uo=(e,t,r,n)=>{t.target==="openapi-3.0"?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"},lo=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema")},po=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema")},mo=(e,t,r,n)=>{r.not={}},fo=(e,t,r,n)=>{},go=(e,t,r,n)=>{},ho=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema")},vo=(e,t,r,n)=>{let i=e._zod.def,o=qt(i.entries);o.every(a=>typeof a=="number")&&(r.type="number"),o.every(a=>typeof a=="string")&&(r.type="string"),r.enum=o},_o=(e,t,r,n)=>{let i=e._zod.def,o=[];for(let a of i.values)if(a===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof a=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");o.push(Number(a))}else o.push(a);if(o.length!==0)if(o.length===1){let a=o[0];r.type=a===null?"null":typeof a,t.target==="draft-04"||t.target==="openapi-3.0"?r.enum=[a]:r.const=a}else o.every(a=>typeof a=="number")&&(r.type="number"),o.every(a=>typeof a=="string")&&(r.type="string"),o.every(a=>typeof a=="boolean")&&(r.type="boolean"),o.every(a=>a===null)&&(r.type="null"),r.enum=o},yo=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema")},$o=(e,t,r,n)=>{let i=r,o=e._zod.pattern;if(!o)throw new Error("Pattern not found in template literal");i.type="string",i.pattern=o.source},xo=(e,t,r,n)=>{let i=r,o={type:"string",format:"binary",contentEncoding:"binary"},{minimum:a,maximum:s,mime:c}=e._zod.bag;a!==void 0&&(o.minLength=a),s!==void 0&&(o.maxLength=s),c?c.length===1?(o.contentMediaType=c[0],Object.assign(i,o)):(Object.assign(i,o),i.anyOf=c.map(u=>({contentMediaType:u}))):Object.assign(i,o)},bo=(e,t,r,n)=>{r.type="boolean"},ko=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},So=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Function types cannot be represented in JSON Schema")},wo=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},Io=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema")},zo=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema")},Oo=(e,t,r,n)=>{let i=r,o=e._zod.def,{minimum:a,maximum:s}=e._zod.bag;typeof a=="number"&&(i.minItems=a),typeof s=="number"&&(i.maxItems=s),i.type="array",i.items=L(o.element,t,{...n,path:[...n.path,"items"]})},Po=(e,t,r,n)=>{let i=r,o=e._zod.def;i.type="object",i.properties={};let a=o.shape;for(let u in a)i.properties[u]=L(a[u],t,{...n,path:[...n.path,"properties",u]});let s=new Set(Object.keys(a)),c=new Set([...s].filter(u=>{let l=o.shape[u]._zod;return t.io==="input"?l.optin===void 0:l.optout===void 0}));c.size>0&&(i.required=Array.from(c)),o.catchall?._zod.def.type==="never"?i.additionalProperties=!1:o.catchall?o.catchall&&(i.additionalProperties=L(o.catchall,t,{...n,path:[...n.path,"additionalProperties"]})):t.io==="output"&&(i.additionalProperties=!1)},sn=(e,t,r,n)=>{let i=e._zod.def,o=i.inclusive===!1,a=i.options.map((s,c)=>L(s,t,{...n,path:[...n.path,o?"oneOf":"anyOf",c]}));o?r.oneOf=a:r.anyOf=a},To=(e,t,r,n)=>{let i=e._zod.def,o=L(i.left,t,{...n,path:[...n.path,"allOf",0]}),a=L(i.right,t,{...n,path:[...n.path,"allOf",1]}),s=u=>"allOf"in u&&Object.keys(u).length===1,c=[...s(o)?o.allOf:[o],...s(a)?a.allOf:[a]];r.allOf=c},jo=(e,t,r,n)=>{let i=r,o=e._zod.def;i.type="array";let a=t.target==="draft-2020-12"?"prefixItems":"items",s=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",c=o.items.map((h,v)=>L(h,t,{...n,path:[...n.path,a,v]})),u=o.rest?L(o.rest,t,{...n,path:[...n.path,s,...t.target==="openapi-3.0"?[o.items.length]:[]]}):null;t.target==="draft-2020-12"?(i.prefixItems=c,u&&(i.items=u)):t.target==="openapi-3.0"?(i.items={anyOf:c},u&&i.items.anyOf.push(u),i.minItems=c.length,u||(i.maxItems=c.length)):(i.items=c,u&&(i.additionalItems=u));let{minimum:l,maximum:p}=e._zod.bag;typeof l=="number"&&(i.minItems=l),typeof p=="number"&&(i.maxItems=p)},Do=(e,t,r,n)=>{let i=r,o=e._zod.def;i.type="object";let a=o.keyType,c=a._zod.bag?.patterns;if(o.mode==="loose"&&c&&c.size>0){let l=L(o.valueType,t,{...n,path:[...n.path,"patternProperties","*"]});i.patternProperties={};for(let p of c)i.patternProperties[p.source]=l}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(i.propertyNames=L(o.keyType,t,{...n,path:[...n.path,"propertyNames"]})),i.additionalProperties=L(o.valueType,t,{...n,path:[...n.path,"additionalProperties"]});let u=a._zod.values;if(u){let l=[...u].filter(p=>typeof p=="string"||typeof p=="number");l.length>0&&(i.required=l)}},Eo=(e,t,r,n)=>{let i=e._zod.def,o=L(i.innerType,t,n),a=t.seen.get(e);t.target==="openapi-3.0"?(a.ref=i.innerType,r.nullable=!0):r.anyOf=[o,{type:"null"}]},No=(e,t,r,n)=>{let i=e._zod.def;L(i.innerType,t,n);let o=t.seen.get(e);o.ref=i.innerType},Zo=(e,t,r,n)=>{let i=e._zod.def;L(i.innerType,t,n);let o=t.seen.get(e);o.ref=i.innerType,r.default=JSON.parse(JSON.stringify(i.defaultValue))},Uo=(e,t,r,n)=>{let i=e._zod.def;L(i.innerType,t,n);let o=t.seen.get(e);o.ref=i.innerType,t.io==="input"&&(r._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},Ao=(e,t,r,n)=>{let i=e._zod.def;L(i.innerType,t,n);let o=t.seen.get(e);o.ref=i.innerType;let a;try{a=i.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}r.default=a},Ro=(e,t,r,n)=>{let i=e._zod.def,o=t.io==="input"?i.in._zod.def.type==="transform"?i.out:i.in:i.out;L(o,t,n);let a=t.seen.get(e);a.ref=o},Co=(e,t,r,n)=>{let i=e._zod.def;L(i.innerType,t,n);let o=t.seen.get(e);o.ref=i.innerType,r.readOnly=!0},Lo=(e,t,r,n)=>{let i=e._zod.def;L(i.innerType,t,n);let o=t.seen.get(e);o.ref=i.innerType},cn=(e,t,r,n)=>{let i=e._zod.def;L(i.innerType,t,n);let o=t.seen.get(e);o.ref=i.innerType},Mo=(e,t,r,n)=>{let i=e._zod.innerType;L(i,t,n);let o=t.seen.get(e);o.ref=i},no={string:io,number:oo,boolean:ao,bigint:so,symbol:co,null:uo,undefined:lo,void:po,never:mo,any:fo,unknown:go,date:ho,enum:vo,literal:_o,nan:yo,template_literal:$o,file:xo,success:bo,custom:ko,function:So,transform:wo,map:Io,set:zo,array:Oo,object:Po,union:sn,intersection:To,tuple:jo,record:Do,nullable:Eo,nonoptional:No,default:Zo,prefault:Uo,catch:Ao,pipe:Ro,readonly:Co,promise:Lo,optional:cn,lazy:Mo};function un(e,t){if("_idmap"in e){let n=e,i=It({...t,processors:no}),o={};for(let c of n._idmap.entries()){let[u,l]=c;L(l,i)}let a={},s={registry:n,uri:t?.uri,defs:o};i.external=s;for(let c of n._idmap.entries()){let[u,l]=c;zt(i,l),a[u]=Ot(i,l)}if(Object.keys(o).length>0){let c=i.target==="draft-2020-12"?"$defs":"definitions";a.__shared={[c]:o}}return{schemas:a}}let r=It({...t,processors:no});return L(e,r),zt(r,e),Ot(r,e)}var fr={};Dt(fr,{ZodAny:()=>Nl,ZodArray:()=>Rl,ZodBase64:()=>da,ZodBase64URL:()=>pa,ZodBigInt:()=>yn,ZodBigIntFormat:()=>ga,ZodBoolean:()=>_n,ZodCIDRv4:()=>ua,ZodCIDRv6:()=>la,ZodCUID:()=>ra,ZodCUID2:()=>na,ZodCatch:()=>ad,ZodCodec:()=>Sa,ZodCustom:()=>Sn,ZodCustomStringFormat:()=>hr,ZodDate:()=>va,ZodDefault:()=>ed,ZodDiscriminatedUnion:()=>Ll,ZodE164:()=>ma,ZodEmail:()=>Qo,ZodEmoji:()=>ea,ZodEnum:()=>gr,ZodExactOptional:()=>Yl,ZodFile:()=>ql,ZodFunction:()=>gd,ZodGUID:()=>dn,ZodIPv4:()=>sa,ZodIPv6:()=>ca,ZodIntersection:()=>Ml,ZodJWT:()=>fa,ZodKSUID:()=>aa,ZodLazy:()=>pd,ZodLiteral:()=>Gl,ZodMAC:()=>zl,ZodMap:()=>Bl,ZodNaN:()=>cd,ZodNanoID:()=>ta,ZodNever:()=>Ul,ZodNonOptional:()=>ba,ZodNull:()=>Dl,ZodNullable:()=>Ql,ZodNumber:()=>vn,ZodNumberFormat:()=>Tt,ZodObject:()=>xn,ZodOptional:()=>xa,ZodPipe:()=>ka,ZodPrefault:()=>rd,ZodPromise:()=>fd,ZodReadonly:()=>ud,ZodRecord:()=>kn,ZodSet:()=>Kl,ZodString:()=>gn,ZodStringFormat:()=>V,ZodSuccess:()=>od,ZodSymbol:()=>Tl,ZodTemplateLiteral:()=>dd,ZodTransform:()=>Xl,ZodTuple:()=>Vl,ZodType:()=>j,ZodULID:()=>ia,ZodURL:()=>hn,ZodUUID:()=>Ue,ZodUndefined:()=>jl,ZodUnion:()=>bn,ZodUnknown:()=>Zl,ZodVoid:()=>Al,ZodXID:()=>oa,ZodXor:()=>Cl,_ZodString:()=>Ho,_default:()=>td,_function:()=>Zf,any:()=>mf,array:()=>$n,base64:()=>qm,base64url:()=>Xm,bigint:()=>cf,boolean:()=>Pl,catch:()=>sd,check:()=>Uf,cidrv4:()=>Km,cidrv6:()=>Gm,codec:()=>Df,cuid:()=>Cm,cuid2:()=>Lm,custom:()=>Af,date:()=>gf,describe:()=>Rf,discriminatedUnion:()=>xf,e164:()=>Ym,email:()=>Pm,emoji:()=>Am,enum:()=>ya,exactOptional:()=>Hl,file:()=>Of,float32:()=>nf,float64:()=>of,function:()=>Zf,guid:()=>Tm,hash:()=>rf,hex:()=>tf,hostname:()=>ef,httpUrl:()=>Um,instanceof:()=>Lf,int:()=>Yo,int32:()=>af,int64:()=>uf,intersection:()=>Fl,ipv4:()=>Jm,ipv6:()=>Bm,json:()=>Ff,jwt:()=>Hm,keyof:()=>hf,ksuid:()=>Vm,lazy:()=>md,literal:()=>zf,looseObject:()=>yf,looseRecord:()=>kf,mac:()=>Wm,map:()=>Sf,meta:()=>Cf,nan:()=>jf,nanoid:()=>Rm,nativeEnum:()=>If,never:()=>ha,nonoptional:()=>id,null:()=>El,nullable:()=>mn,nullish:()=>Pf,number:()=>Ol,object:()=>vf,optional:()=>pn,partialRecord:()=>bf,pipe:()=>fn,prefault:()=>nd,preprocess:()=>Vf,promise:()=>Nf,readonly:()=>ld,record:()=>Wl,refine:()=>hd,set:()=>wf,strictObject:()=>_f,string:()=>Xo,stringFormat:()=>Qm,stringbool:()=>Mf,success:()=>Tf,superRefine:()=>vd,symbol:()=>df,templateLiteral:()=>Ef,transform:()=>$a,tuple:()=>Jl,uint32:()=>sf,uint64:()=>lf,ulid:()=>Mm,undefined:()=>pf,union:()=>_a,unknown:()=>Pt,url:()=>Zm,uuid:()=>jm,uuidv4:()=>Dm,uuidv6:()=>Em,uuidv7:()=>Nm,void:()=>ff,xid:()=>Fm,xor:()=>$f});var ln={};Dt(ln,{endsWith:()=>Qr,gt:()=>Ke,gte:()=>me,includes:()=>Yr,length:()=>lr,lowercase:()=>qr,lt:()=>Be,lte:()=>xe,maxLength:()=>ur,maxSize:()=>wt,mime:()=>en,minLength:()=>rt,minSize:()=>Ge,multipleOf:()=>St,negative:()=>tl,nonnegative:()=>nl,nonpositive:()=>rl,normalize:()=>tn,overwrite:()=>Ze,positive:()=>el,property:()=>il,regex:()=>Gr,size:()=>cr,slugify:()=>an,startsWith:()=>Hr,toLowerCase:()=>nn,toUpperCase:()=>on,trim:()=>rn,uppercase:()=>Xr});var mr={};Dt(mr,{ZodISODate:()=>Jo,ZodISODateTime:()=>Fo,ZodISODuration:()=>Go,ZodISOTime:()=>Bo,date:()=>Wo,datetime:()=>Vo,duration:()=>qo,time:()=>Ko});var Fo=d("ZodISODateTime",(e,t)=>{Ic.init(e,t),V.init(e,t)});function Vo(e){return ju(Fo,e)}var Jo=d("ZodISODate",(e,t)=>{zc.init(e,t),V.init(e,t)});function Wo(e){return Du(Jo,e)}var Bo=d("ZodISOTime",(e,t)=>{Oc.init(e,t),V.init(e,t)});function Ko(e){return Eu(Bo,e)}var Go=d("ZodISODuration",(e,t)=>{Pc.init(e,t),V.init(e,t)});function qo(e){return Nu(Go,e)}var fl=(e,t)=>{Nr.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:r=>Yn(e,r)},flatten:{value:r=>Xn(e,r)},addIssue:{value:r=>{e.issues.push(r),e.message=JSON.stringify(e.issues,$t,2)}},addIssues:{value:r=>{e.issues.push(...r),e.message=JSON.stringify(e.issues,$t,2)}},isEmpty:{get(){return e.issues.length===0}}})},Ub=d("ZodError",fl),fe=d("ZodError",fl,{Parent:Error});var gl=tr(fe),hl=rr(fe),vl=nr(fe),_l=ir(fe),yl=ws(fe),$l=Is(fe),xl=zs(fe),bl=Os(fe),kl=Ps(fe),Sl=Ts(fe),wl=js(fe),Il=Ds(fe);var j=d("ZodType",(e,t)=>(P.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:pr(e,"input"),output:pr(e,"output")}}),e.toJSONSchema=ml(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...r)=>e.clone(g.mergeDefs(t,{checks:[...t.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0}),e.with=e.check,e.clone=(r,n)=>de(e,r,n),e.brand=()=>e,e.register=((r,n)=>(r.add(e,n),e)),e.parse=(r,n)=>gl(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>vl(e,r,n),e.parseAsync=async(r,n)=>hl(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>_l(e,r,n),e.spa=e.safeParseAsync,e.encode=(r,n)=>yl(e,r,n),e.decode=(r,n)=>$l(e,r,n),e.encodeAsync=async(r,n)=>xl(e,r,n),e.decodeAsync=async(r,n)=>bl(e,r,n),e.safeEncode=(r,n)=>kl(e,r,n),e.safeDecode=(r,n)=>Sl(e,r,n),e.safeEncodeAsync=async(r,n)=>wl(e,r,n),e.safeDecodeAsync=async(r,n)=>Il(e,r,n),e.refine=(r,n)=>e.check(hd(r,n)),e.superRefine=r=>e.check(vd(r)),e.overwrite=r=>e.check(Ze(r)),e.optional=()=>pn(e),e.exactOptional=()=>Hl(e),e.nullable=()=>mn(e),e.nullish=()=>pn(mn(e)),e.nonoptional=r=>id(e,r),e.array=()=>$n(e),e.or=r=>_a([e,r]),e.and=r=>Fl(e,r),e.transform=r=>fn(e,$a(r)),e.default=r=>td(e,r),e.prefault=r=>nd(e,r),e.catch=r=>sd(e,r),e.pipe=r=>fn(e,r),e.readonly=()=>ld(e),e.describe=r=>{let n=e.clone();return se.add(n,{description:r}),n},Object.defineProperty(e,"description",{get(){return se.get(e)?.description},configurable:!0}),e.meta=(...r)=>{if(r.length===0)return se.get(e);let n=e.clone();return se.add(n,r[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=r=>r(e),e)),Ho=d("_ZodString",(e,t)=>{kt.init(e,t),j.init(e,t),e._zod.processJSONSchema=(n,i,o)=>io(e,n,i,o);let r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null,e.regex=(...n)=>e.check(Gr(...n)),e.includes=(...n)=>e.check(Yr(...n)),e.startsWith=(...n)=>e.check(Hr(...n)),e.endsWith=(...n)=>e.check(Qr(...n)),e.min=(...n)=>e.check(rt(...n)),e.max=(...n)=>e.check(ur(...n)),e.length=(...n)=>e.check(lr(...n)),e.nonempty=(...n)=>e.check(rt(1,...n)),e.lowercase=n=>e.check(qr(n)),e.uppercase=n=>e.check(Xr(n)),e.trim=()=>e.check(rn()),e.normalize=(...n)=>e.check(tn(...n)),e.toLowerCase=()=>e.check(nn()),e.toUpperCase=()=>e.check(on()),e.slugify=()=>e.check(an())}),gn=d("ZodString",(e,t)=>{kt.init(e,t),Ho.init(e,t),e.email=r=>e.check(Ai(Qo,r)),e.url=r=>e.check(Kr(hn,r)),e.jwt=r=>e.check(ro(fa,r)),e.emoji=r=>e.check(Fi(ea,r)),e.guid=r=>e.check(Br(dn,r)),e.uuid=r=>e.check(Ri(Ue,r)),e.uuidv4=r=>e.check(Ci(Ue,r)),e.uuidv6=r=>e.check(Li(Ue,r)),e.uuidv7=r=>e.check(Mi(Ue,r)),e.nanoid=r=>e.check(Vi(ta,r)),e.guid=r=>e.check(Br(dn,r)),e.cuid=r=>e.check(Ji(ra,r)),e.cuid2=r=>e.check(Wi(na,r)),e.ulid=r=>e.check(Bi(ia,r)),e.base64=r=>e.check(Qi(da,r)),e.base64url=r=>e.check(eo(pa,r)),e.xid=r=>e.check(Ki(oa,r)),e.ksuid=r=>e.check(Gi(aa,r)),e.ipv4=r=>e.check(qi(sa,r)),e.ipv6=r=>e.check(Xi(ca,r)),e.cidrv4=r=>e.check(Yi(ua,r)),e.cidrv6=r=>e.check(Hi(la,r)),e.e164=r=>e.check(to(ma,r)),e.datetime=r=>e.check(Vo(r)),e.date=r=>e.check(Wo(r)),e.time=r=>e.check(Ko(r)),e.duration=r=>e.check(qo(r))});function Xo(e){return Pu(gn,e)}var V=d("ZodStringFormat",(e,t)=>{F.init(e,t),Ho.init(e,t)}),Qo=d("ZodEmail",(e,t)=>{vc.init(e,t),V.init(e,t)});function Pm(e){return Ai(Qo,e)}var dn=d("ZodGUID",(e,t)=>{gc.init(e,t),V.init(e,t)});function Tm(e){return Br(dn,e)}var Ue=d("ZodUUID",(e,t)=>{hc.init(e,t),V.init(e,t)});function jm(e){return Ri(Ue,e)}function Dm(e){return Ci(Ue,e)}function Em(e){return Li(Ue,e)}function Nm(e){return Mi(Ue,e)}var hn=d("ZodURL",(e,t)=>{_c.init(e,t),V.init(e,t)});function Zm(e){return Kr(hn,e)}function Um(e){return Kr(hn,{protocol:/^https?$/,hostname:Ie.domain,...g.normalizeParams(e)})}var ea=d("ZodEmoji",(e,t)=>{yc.init(e,t),V.init(e,t)});function Am(e){return Fi(ea,e)}var ta=d("ZodNanoID",(e,t)=>{$c.init(e,t),V.init(e,t)});function Rm(e){return Vi(ta,e)}var ra=d("ZodCUID",(e,t)=>{xc.init(e,t),V.init(e,t)});function Cm(e){return Ji(ra,e)}var na=d("ZodCUID2",(e,t)=>{bc.init(e,t),V.init(e,t)});function Lm(e){return Wi(na,e)}var ia=d("ZodULID",(e,t)=>{kc.init(e,t),V.init(e,t)});function Mm(e){return Bi(ia,e)}var oa=d("ZodXID",(e,t)=>{Sc.init(e,t),V.init(e,t)});function Fm(e){return Ki(oa,e)}var aa=d("ZodKSUID",(e,t)=>{wc.init(e,t),V.init(e,t)});function Vm(e){return Gi(aa,e)}var sa=d("ZodIPv4",(e,t)=>{Tc.init(e,t),V.init(e,t)});function Jm(e){return qi(sa,e)}var zl=d("ZodMAC",(e,t)=>{Dc.init(e,t),V.init(e,t)});function Wm(e){return Tu(zl,e)}var ca=d("ZodIPv6",(e,t)=>{jc.init(e,t),V.init(e,t)});function Bm(e){return Xi(ca,e)}var ua=d("ZodCIDRv4",(e,t)=>{Ec.init(e,t),V.init(e,t)});function Km(e){return Yi(ua,e)}var la=d("ZodCIDRv6",(e,t)=>{Nc.init(e,t),V.init(e,t)});function Gm(e){return Hi(la,e)}var da=d("ZodBase64",(e,t)=>{Uc.init(e,t),V.init(e,t)});function qm(e){return Qi(da,e)}var pa=d("ZodBase64URL",(e,t)=>{Ac.init(e,t),V.init(e,t)});function Xm(e){return eo(pa,e)}var ma=d("ZodE164",(e,t)=>{Rc.init(e,t),V.init(e,t)});function Ym(e){return to(ma,e)}var fa=d("ZodJWT",(e,t)=>{Cc.init(e,t),V.init(e,t)});function Hm(e){return ro(fa,e)}var hr=d("ZodCustomStringFormat",(e,t)=>{Lc.init(e,t),V.init(e,t)});function Qm(e,t,r={}){return dr(hr,e,t,r)}function ef(e){return dr(hr,"hostname",Ie.hostname,e)}function tf(e){return dr(hr,"hex",Ie.hex,e)}function rf(e,t){let r=t?.enc??"hex",n=`${e}_${r}`,i=Ie[n];if(!i)throw new Error(`Unrecognized hash format: ${n}`);return dr(hr,n,i,t)}var vn=d("ZodNumber",(e,t)=>{ji.init(e,t),j.init(e,t),e._zod.processJSONSchema=(n,i,o)=>oo(e,n,i,o),e.gt=(n,i)=>e.check(Ke(n,i)),e.gte=(n,i)=>e.check(me(n,i)),e.min=(n,i)=>e.check(me(n,i)),e.lt=(n,i)=>e.check(Be(n,i)),e.lte=(n,i)=>e.check(xe(n,i)),e.max=(n,i)=>e.check(xe(n,i)),e.int=n=>e.check(Yo(n)),e.safe=n=>e.check(Yo(n)),e.positive=n=>e.check(Ke(0,n)),e.nonnegative=n=>e.check(me(0,n)),e.negative=n=>e.check(Be(0,n)),e.nonpositive=n=>e.check(xe(0,n)),e.multipleOf=(n,i)=>e.check(St(n,i)),e.step=(n,i)=>e.check(St(n,i)),e.finite=()=>e;let r=e._zod.bag;e.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),e.isFinite=!0,e.format=r.format??null});function Ol(e){return Zu(vn,e)}var Tt=d("ZodNumberFormat",(e,t)=>{Mc.init(e,t),vn.init(e,t)});function Yo(e){return Uu(Tt,e)}function nf(e){return Au(Tt,e)}function of(e){return Ru(Tt,e)}function af(e){return Cu(Tt,e)}function sf(e){return Lu(Tt,e)}var _n=d("ZodBoolean",(e,t)=>{Vr.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,n,i)=>ao(e,r,n,i)});function Pl(e){return Mu(_n,e)}var yn=d("ZodBigInt",(e,t)=>{Di.init(e,t),j.init(e,t),e._zod.processJSONSchema=(n,i,o)=>so(e,n,i,o),e.gte=(n,i)=>e.check(me(n,i)),e.min=(n,i)=>e.check(me(n,i)),e.gt=(n,i)=>e.check(Ke(n,i)),e.gte=(n,i)=>e.check(me(n,i)),e.min=(n,i)=>e.check(me(n,i)),e.lt=(n,i)=>e.check(Be(n,i)),e.lte=(n,i)=>e.check(xe(n,i)),e.max=(n,i)=>e.check(xe(n,i)),e.positive=n=>e.check(Ke(BigInt(0),n)),e.negative=n=>e.check(Be(BigInt(0),n)),e.nonpositive=n=>e.check(xe(BigInt(0),n)),e.nonnegative=n=>e.check(me(BigInt(0),n)),e.multipleOf=(n,i)=>e.check(St(n,i));let r=e._zod.bag;e.minValue=r.minimum??null,e.maxValue=r.maximum??null,e.format=r.format??null});function cf(e){return Fu(yn,e)}var ga=d("ZodBigIntFormat",(e,t)=>{Fc.init(e,t),yn.init(e,t)});function uf(e){return Vu(ga,e)}function lf(e){return Ju(ga,e)}var Tl=d("ZodSymbol",(e,t)=>{Vc.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,n,i)=>co(e,r,n,i)});function df(e){return Wu(Tl,e)}var jl=d("ZodUndefined",(e,t)=>{Jc.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,n,i)=>lo(e,r,n,i)});function pf(e){return Bu(jl,e)}var Dl=d("ZodNull",(e,t)=>{Wc.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,n,i)=>uo(e,r,n,i)});function El(e){return Ku(Dl,e)}var Nl=d("ZodAny",(e,t)=>{Bc.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,n,i)=>fo(e,r,n,i)});function mf(){return Gu(Nl)}var Zl=d("ZodUnknown",(e,t)=>{Kc.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,n,i)=>go(e,r,n,i)});function Pt(){return qu(Zl)}var Ul=d("ZodNever",(e,t)=>{Gc.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,n,i)=>mo(e,r,n,i)});function ha(e){return Xu(Ul,e)}var Al=d("ZodVoid",(e,t)=>{qc.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,n,i)=>po(e,r,n,i)});function ff(e){return Yu(Al,e)}var va=d("ZodDate",(e,t)=>{Xc.init(e,t),j.init(e,t),e._zod.processJSONSchema=(n,i,o)=>ho(e,n,i,o),e.min=(n,i)=>e.check(me(n,i)),e.max=(n,i)=>e.check(xe(n,i));let r=e._zod.bag;e.minDate=r.minimum?new Date(r.minimum):null,e.maxDate=r.maximum?new Date(r.maximum):null});function gf(e){return Hu(va,e)}var Rl=d("ZodArray",(e,t)=>{Yc.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Oo(e,r,n,i),e.element=t.element,e.min=(r,n)=>e.check(rt(r,n)),e.nonempty=r=>e.check(rt(1,r)),e.max=(r,n)=>e.check(ur(r,n)),e.length=(r,n)=>e.check(lr(r,n)),e.unwrap=()=>e.element});function $n(e,t){return ol(Rl,e,t)}function hf(e){let t=e._zod.def.shape;return ya(Object.keys(t))}var xn=d("ZodObject",(e,t)=>{eu.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Po(e,r,n,i),g.defineLazy(e,"shape",()=>t.shape),e.keyof=()=>ya(Object.keys(e._zod.def.shape)),e.catchall=r=>e.clone({...e._zod.def,catchall:r}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Pt()}),e.loose=()=>e.clone({...e._zod.def,catchall:Pt()}),e.strict=()=>e.clone({...e._zod.def,catchall:ha()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=r=>g.extend(e,r),e.safeExtend=r=>g.safeExtend(e,r),e.merge=r=>g.merge(e,r),e.pick=r=>g.pick(e,r),e.omit=r=>g.omit(e,r),e.partial=(...r)=>g.partial(xa,e,r[0]),e.required=(...r)=>g.required(ba,e,r[0])});function vf(e,t){let r={type:"object",shape:e??{},...g.normalizeParams(t)};return new xn(r)}function _f(e,t){return new xn({type:"object",shape:e,catchall:ha(),...g.normalizeParams(t)})}function yf(e,t){return new xn({type:"object",shape:e,catchall:Pt(),...g.normalizeParams(t)})}var bn=d("ZodUnion",(e,t)=>{Jr.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,n,i)=>sn(e,r,n,i),e.options=t.options});function _a(e,t){return new bn({type:"union",options:e,...g.normalizeParams(t)})}var Cl=d("ZodXor",(e,t)=>{bn.init(e,t),tu.init(e,t),e._zod.processJSONSchema=(r,n,i)=>sn(e,r,n,i),e.options=t.options});function $f(e,t){return new Cl({type:"union",options:e,inclusive:!1,...g.normalizeParams(t)})}var Ll=d("ZodDiscriminatedUnion",(e,t)=>{bn.init(e,t),ru.init(e,t)});function xf(e,t,r){return new Ll({type:"union",options:t,discriminator:e,...g.normalizeParams(r)})}var Ml=d("ZodIntersection",(e,t)=>{nu.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,n,i)=>To(e,r,n,i)});function Fl(e,t){return new Ml({type:"intersection",left:e,right:t})}var Vl=d("ZodTuple",(e,t)=>{Ei.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,n,i)=>jo(e,r,n,i),e.rest=r=>e.clone({...e._zod.def,rest:r})});function Jl(e,t,r){let n=t instanceof P,i=n?r:t,o=n?t:null;return new Vl({type:"tuple",items:e,rest:o,...g.normalizeParams(i)})}var kn=d("ZodRecord",(e,t)=>{iu.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Do(e,r,n,i),e.keyType=t.keyType,e.valueType=t.valueType});function Wl(e,t,r){return new kn({type:"record",keyType:e,valueType:t,...g.normalizeParams(r)})}function bf(e,t,r){let n=de(e);return n._zod.values=void 0,new kn({type:"record",keyType:n,valueType:t,...g.normalizeParams(r)})}function kf(e,t,r){return new kn({type:"record",keyType:e,valueType:t,mode:"loose",...g.normalizeParams(r)})}var Bl=d("ZodMap",(e,t)=>{ou.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Io(e,r,n,i),e.keyType=t.keyType,e.valueType=t.valueType,e.min=(...r)=>e.check(Ge(...r)),e.nonempty=r=>e.check(Ge(1,r)),e.max=(...r)=>e.check(wt(...r)),e.size=(...r)=>e.check(cr(...r))});function Sf(e,t,r){return new Bl({type:"map",keyType:e,valueType:t,...g.normalizeParams(r)})}var Kl=d("ZodSet",(e,t)=>{au.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,n,i)=>zo(e,r,n,i),e.min=(...r)=>e.check(Ge(...r)),e.nonempty=r=>e.check(Ge(1,r)),e.max=(...r)=>e.check(wt(...r)),e.size=(...r)=>e.check(cr(...r))});function wf(e,t){return new Kl({type:"set",valueType:e,...g.normalizeParams(t)})}var gr=d("ZodEnum",(e,t)=>{su.init(e,t),j.init(e,t),e._zod.processJSONSchema=(n,i,o)=>vo(e,n,i,o),e.enum=t.entries,e.options=Object.values(t.entries);let r=new Set(Object.keys(t.entries));e.extract=(n,i)=>{let o={};for(let a of n)if(r.has(a))o[a]=t.entries[a];else throw new Error(`Key ${a} not found in enum`);return new gr({...t,checks:[],...g.normalizeParams(i),entries:o})},e.exclude=(n,i)=>{let o={...t.entries};for(let a of n)if(r.has(a))delete o[a];else throw new Error(`Key ${a} not found in enum`);return new gr({...t,checks:[],...g.normalizeParams(i),entries:o})}});function ya(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new gr({type:"enum",entries:r,...g.normalizeParams(t)})}function If(e,t){return new gr({type:"enum",entries:e,...g.normalizeParams(t)})}var Gl=d("ZodLiteral",(e,t)=>{cu.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,n,i)=>_o(e,r,n,i),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function zf(e,t){return new Gl({type:"literal",values:Array.isArray(e)?e:[e],...g.normalizeParams(t)})}var ql=d("ZodFile",(e,t)=>{uu.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,n,i)=>xo(e,r,n,i),e.min=(r,n)=>e.check(Ge(r,n)),e.max=(r,n)=>e.check(wt(r,n)),e.mime=(r,n)=>e.check(en(Array.isArray(r)?r:[r],n))});function Of(e){return al(ql,e)}var Xl=d("ZodTransform",(e,t)=>{lu.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,n,i)=>wo(e,r,n,i),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Qe(e.constructor.name);r.addIssue=o=>{if(typeof o=="string")r.issues.push(g.issue(o,r.value,t));else{let a=o;a.fatal&&(a.continue=!1),a.code??(a.code="custom"),a.input??(a.input=r.value),a.inst??(a.inst=e),r.issues.push(g.issue(a))}};let i=t.transform(r.value,r);return i instanceof Promise?i.then(o=>(r.value=o,r)):(r.value=i,r)}});function $a(e){return new Xl({type:"transform",transform:e})}var xa=d("ZodOptional",(e,t)=>{Ni.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,n,i)=>cn(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function pn(e){return new xa({type:"optional",innerType:e})}var Yl=d("ZodExactOptional",(e,t)=>{du.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,n,i)=>cn(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function Hl(e){return new Yl({type:"optional",innerType:e})}var Ql=d("ZodNullable",(e,t)=>{pu.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Eo(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function mn(e){return new Ql({type:"nullable",innerType:e})}function Pf(e){return pn(mn(e))}var ed=d("ZodDefault",(e,t)=>{mu.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Zo(e,r,n,i),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function td(e,t){return new ed({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():g.shallowClone(t)}})}var rd=d("ZodPrefault",(e,t)=>{fu.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Uo(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function nd(e,t){return new rd({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():g.shallowClone(t)}})}var ba=d("ZodNonOptional",(e,t)=>{gu.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,n,i)=>No(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function id(e,t){return new ba({type:"nonoptional",innerType:e,...g.normalizeParams(t)})}var od=d("ZodSuccess",(e,t)=>{hu.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,n,i)=>bo(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function Tf(e){return new od({type:"success",innerType:e})}var ad=d("ZodCatch",(e,t)=>{vu.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Ao(e,r,n,i),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function sd(e,t){return new ad({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}var cd=d("ZodNaN",(e,t)=>{_u.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,n,i)=>yo(e,r,n,i)});function jf(e){return Qu(cd,e)}var ka=d("ZodPipe",(e,t)=>{yu.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Ro(e,r,n,i),e.in=t.in,e.out=t.out});function fn(e,t){return new ka({type:"pipe",in:e,out:t})}var Sa=d("ZodCodec",(e,t)=>{ka.init(e,t),Wr.init(e,t)});function Df(e,t,r){return new Sa({type:"pipe",in:e,out:t,transform:r.decode,reverseTransform:r.encode})}var ud=d("ZodReadonly",(e,t)=>{$u.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Co(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function ld(e){return new ud({type:"readonly",innerType:e})}var dd=d("ZodTemplateLiteral",(e,t)=>{xu.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,n,i)=>$o(e,r,n,i)});function Ef(e,t){return new dd({type:"template_literal",parts:e,...g.normalizeParams(t)})}var pd=d("ZodLazy",(e,t)=>{Su.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Mo(e,r,n,i),e.unwrap=()=>e._zod.def.getter()});function md(e){return new pd({type:"lazy",getter:e})}var fd=d("ZodPromise",(e,t)=>{ku.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,n,i)=>Lo(e,r,n,i),e.unwrap=()=>e._zod.def.innerType});function Nf(e){return new fd({type:"promise",innerType:e})}var gd=d("ZodFunction",(e,t)=>{bu.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,n,i)=>So(e,r,n,i)});function Zf(e){return new gd({type:"function",input:Array.isArray(e?.input)?Jl(e?.input):e?.input??$n(Pt()),output:e?.output??Pt()})}var Sn=d("ZodCustom",(e,t)=>{wu.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,n,i)=>ko(e,r,n,i)});function Uf(e){let t=new J({check:"custom"});return t._zod.check=e,t}function Af(e,t){return sl(Sn,e??(()=>!0),t)}function hd(e,t={}){return cl(Sn,e,t)}function vd(e){return ul(e)}var Rf=ll,Cf=dl;function Lf(e,t={}){let r=new Sn({type:"custom",check:"custom",fn:n=>n instanceof e,abort:!0,...g.normalizeParams(t)});return r._zod.bag.Class=e,r._zod.check=n=>{n.value instanceof e||n.issues.push({code:"invalid_type",expected:e.name,input:n.value,inst:r,path:[...r._zod.def.path??[]]})},r}var Mf=(...e)=>pl({Codec:Sa,Boolean:_n,String:gn},...e);function Ff(e){let t=md(()=>_a([Xo(e),Ol(),Pl(),El(),$n(t),Wl(Xo(),t)]));return t}function Vf(e,t){return fn($a(e),t)}var _d;_d||(_d={});var Jb={...fr,...ln,iso:mr};ee(Zi());function Yf(){if(process.env.OPENAI_PROXY_TOKEN)return x.debug("[Auth] Using OPENAI_PROXY_TOKEN (ECS execution)"),process.env.OPENAI_PROXY_TOKEN;if(process.env.ZIBBY_USER_TOKEN)return x.debug("[Auth] Using ZIBBY_USER_TOKEN (CI/CD PAT)"),process.env.ZIBBY_USER_TOKEN;try{let e=Gf(Kf(),".zibby","config.json");if(qf(e)){let t=JSON.parse(Xf(e,"utf-8"));if(t.sessionToken)return x.debug("[Auth] Using session token from zibby login"),t.sessionToken}}catch(e){x.debug(`[Auth] Could not read zibby login session: ${e.message}`)}return null}function Hf(){return process.env.OPENAI_PROXY_URL?process.env.OPENAI_PROXY_URL.replace(/\/v1\/?$/,""):"https://api-prod.zibby.app/openai-proxy"}function jt(e){if(!(typeof e!="object"||e===null)){if(Object.keys(e).length===0){e.type="object",e.additionalProperties=!0;return}if(e.type||(e.properties?e.type="object":e.items&&(e.type="array")),e.type==="object")if(e.properties){for(let[t,r]of Object.entries(e.properties))r.type==="object"&&r.additionalProperties&&r.additionalProperties!==!1&&(!r.properties||Object.keys(r.properties).length===0)&&(e.properties[t]={type:["object","null"]});e.additionalProperties=!1,e.required=Object.keys(e.properties),Object.values(e.properties).forEach(jt)}else"additionalProperties"in e||(e.additionalProperties=!0);e.type==="array"&&e.items&&jt(e.items),e.anyOf&&e.anyOf.forEach(jt),e.oneOf&&e.oneOf.forEach(jt),e.allOf&&e.allOf.forEach(jt)}}async function yd(e,t){x.info("\u{1F527} [OpenAI Proxy] Formatting structured output...");let r=Yf();if(!r)throw new Error("Authentication required for structured output processing.\n Local development: Run `zibby login`\n CI/CD: Set ZIBBY_USER_TOKEN environment variable (Personal Access Token from UI settings)");let n=Hf();x.info(`\u{1F517} Using OpenAI proxy: ${n}`);let i=un(t),o=i;if(i.$ref&&i.definitions){let l=i.$ref.split("/").pop();o=i.definitions[l]||i,x.debug(`Extracted schema from $ref: ${l}`)}delete o.$schema,jt(o);let a=4e5,s=e;e.length>a&&(x.warn(`\u26A0\uFE0F [OpenAI Proxy] Raw text (${e.length} chars) exceeds limit, keeping last ${a} chars`),s=`... [truncated early content] ...
|
|
67
|
-
${e.slice(-a)}`);let c=`Extract and format the following information into structured JSON matching the schema.
|
|
24
|
+
Rules: valid JSON only, no markdown wrapping, no extra text in the file.`}static _buildExample(t){if(!t)return{};let e=t.type;if(e==="object"&&t.properties){let r={};for(let[n,l]of Object.entries(t.properties))r[n]=this._buildExample(l);return r}if(e==="array"&&t.items)return[this._buildExample(t.items)];if(e==="string")return"<string>";if(e==="number"||e==="integer")return 0;if(e==="boolean")return!1;if(t.description)return`<${t.description}>`;if(t.nullable||t.oneOf||t.anyOf){let r=t.oneOf?.find(n=>n.type!=="null")||t.anyOf?.find(n=>n.type!=="null");return r?this._buildExample(r):null}return"<value>"}};import Nt from"axios";import{homedir as Ct}from"node:os";import{join as Pt}from"node:path";import{existsSync as kt,readFileSync as Lt}from"node:fs";import{toJSONSchema as Mt}from"zod";function Ut(){if(process.env.OPENAI_PROXY_TOKEN)return i.debug("[Auth] Using OPENAI_PROXY_TOKEN (ECS execution)"),process.env.OPENAI_PROXY_TOKEN;if(process.env.ZIBBY_USER_TOKEN)return i.debug("[Auth] Using ZIBBY_USER_TOKEN (CI/CD PAT)"),process.env.ZIBBY_USER_TOKEN;try{let s=Pt(Ct(),".zibby","config.json");if(kt(s)){let t=JSON.parse(Lt(s,"utf-8"));if(t.sessionToken)return i.debug("[Auth] Using session token from zibby login"),t.sessionToken}}catch(s){i.debug(`[Auth] Could not read zibby login session: ${s.message}`)}return null}function Dt(){return process.env.OPENAI_PROXY_URL?process.env.OPENAI_PROXY_URL.replace(/\/v1\/?$/,""):"https://api-prod.zibby.app/openai-proxy"}function J(s){if(!(typeof s!="object"||s===null)){if(Object.keys(s).length===0){s.type="object",s.additionalProperties=!0;return}if(s.type||(s.properties?s.type="object":s.items&&(s.type="array")),s.type==="object")if(s.properties){for(let[t,e]of Object.entries(s.properties))e.type==="object"&&e.additionalProperties&&e.additionalProperties!==!1&&(!e.properties||Object.keys(e.properties).length===0)&&(s.properties[t]={type:["object","null"]});s.additionalProperties=!1,s.required=Object.keys(s.properties),Object.values(s.properties).forEach(J)}else"additionalProperties"in s||(s.additionalProperties=!0);s.type==="array"&&s.items&&J(s.items),s.anyOf&&s.anyOf.forEach(J),s.oneOf&&s.oneOf.forEach(J),s.allOf&&s.allOf.forEach(J)}}async function ft(s,t){i.info("\u{1F527} [OpenAI Proxy] Formatting structured output...");let e=Ut();if(!e)throw new Error("Authentication required for structured output processing.\n Local development: Run `zibby login`\n CI/CD: Set ZIBBY_USER_TOKEN environment variable (Personal Access Token from UI settings)");let r=Dt();i.info(`\u{1F517} Using OpenAI proxy: ${r}`);let n=Mt(t),l=n;if(n.$ref&&n.definitions){let p=n.$ref.split("/").pop();l=n.definitions[p]||n,i.debug(`Extracted schema from $ref: ${p}`)}delete l.$schema,J(l);let o=4e5,a=s;s.length>o&&(i.warn(`\u26A0\uFE0F [OpenAI Proxy] Raw text (${s.length} chars) exceeds limit, keeping last ${o} chars`),a=`... [truncated early content] ...
|
|
25
|
+
${s.slice(-o)}`);let c=`Extract and format the following information into structured JSON matching the schema.
|
|
68
26
|
|
|
69
27
|
RAW CONTENT:
|
|
70
|
-
${
|
|
28
|
+
${a}
|
|
71
29
|
|
|
72
|
-
Extract all relevant information and format it according to the schema. If any required fields are missing, do your best to infer them from the content.`,
|
|
30
|
+
Extract all relevant information and format it according to the schema. If any required fields are missing, do your best to infer them from the content.`,g={model:K.OPENAI_POSTPROCESSING,messages:[{role:"user",content:c}],response_format:{type:"json_schema",json_schema:{name:"extract",schema:l,strict:!0}}};i.info(`\u{1F4E4} Sending to OpenAI proxy: model=${K.OPENAI_POSTPROCESSING}, schema keys=${Object.keys(l.properties||{}).join(", ")}`),i.debug(` Schema size: ${JSON.stringify(l).length} chars`),i.debug(` Prompt size: ${c.length} chars`);try{let p={"Content-Type":"application/json"};process.env.OPENAI_PROXY_TOKEN?(p["x-proxy-token"]=e,p["x-execution-id"]=process.env.EXECUTION_ID||""):(p.Authorization=`Bearer ${e}`,p["x-api-key"]=process.env.ZIBBY_API_KEY||"",p["x-execution-id"]=process.env.EXECUTION_ID||"");let h=(await Nt.post(r,g,{headers:p,timeout:Z.OPENAI_REQUEST})).data?.choices?.[0]?.message?.content;if(!h)throw new Error("OpenAI proxy returned empty response");let S=JSON.parse(h);return i.info("\u2705 Successfully formatted with OpenAI proxy"),{structured:S,raw:s}}catch(p){if(p.response){let f=p.response.status,h=p.response.data;throw i.error(`\u274C OpenAI proxy request failed: ${f}`),i.error(` Status: ${f}`),i.error(` Response: ${JSON.stringify(h,null,2)}`),f===401||f===403?new Error(`Authentication failed for OpenAI proxy.
|
|
73
31
|
Run \`zibby login\` or set ZIBBY_USER_TOKEN environment variable.
|
|
74
|
-
Response: ${JSON.stringify(h)}`,{cause:
|
|
75
|
-
`?(
|
|
76
|
-
${
|
|
32
|
+
Response: ${JSON.stringify(h)}`,{cause:p}):new Error(`Failed to format Cursor output: ${h?.error?.message||"Unknown error"}`,{cause:p})}throw i.error(`\u274C OpenAI proxy request failed: ${p.message}`),new Error(`Failed to format output: ${p.message}`,{cause:p})}}import x from"chalk";var Wt="__WORKFLOW_GRAPH_LOG__",z=x.gray("\u2502"),Bt=x.gray("\u250C"),dt=x.gray("\u2514"),rt=x.green("\u25C6"),gt=x.hex("#c084fc")("\u25C6"),ht=x.hex("#2dd4bf")("\u25C6"),ot=x.red("\u25C6"),mt=`${z} `,_t=2;function yt(s){return s<1e3?`${s}ms`:`${(s/1e3).toFixed(1)}s`}function St(s,t){return(e,r,n)=>{if(typeof e!="string")return s(e,r,n);let l=process.stdout.columns||120,o="";for(let a=0;a<e.length;a++){let c=e[a];t.lineStart&&(o+=mt,t.col=_t,t.lineStart=!1),c===`
|
|
33
|
+
`?(o+=c,t.lineStart=!0,t.col=0,t.inEsc=!1):c==="\x1B"?(t.inEsc=!0,o+=c):t.inEsc?(o+=c,(c>="A"&&c<="Z"||c>="a"&&c<="z")&&(t.inEsc=!1)):(t.col++,o+=c,t.col>=l&&(o+=`
|
|
34
|
+
${mt}`,t.col=_t))}return s(o,r,n)}}var st=class{constructor(){this._currentNode=null,this._origStdoutWrite=null,this._origStderrWrite=null;let t=String(process.env.ZIBBY_RUN_SOURCE||"").trim().toLowerCase(),e=String(process.env.ZIBBY_WORKFLOW_GRAPH_LOG_MARKERS||"").trim()==="1";this._emitWorkflowGraphMarkers=e||t==="studio"}get isInsideNode(){return this._currentNode!==null}_startIntercepting(){this._origStdoutWrite=process.stdout.write.bind(process.stdout),this._origStderrWrite=process.stderr.write.bind(process.stderr);let t={lineStart:!0,col:0,inEsc:!1},e={lineStart:!0,col:0,inEsc:!1};this._outState=t,this._errState=e,process.stdout.write=St(this._origStdoutWrite,t),process.stderr.write=St(this._origStderrWrite,e)}_stopIntercepting(){this._origStdoutWrite&&(this._outState&&!this._outState.lineStart&&this._origStdoutWrite(`
|
|
77
35
|
`),process.stdout.write=this._origStdoutWrite),this._origStderrWrite&&(this._errState&&!this._errState.lineStart&&this._origStderrWrite(`
|
|
78
36
|
`),process.stderr.write=this._origStderrWrite),this._origStdoutWrite=null,this._origStderrWrite=null}_rawWrite(t){(this._origStdoutWrite||process.stdout.write.bind(process.stdout))(`${t}
|
|
79
|
-
`)}_emitGraphLogMarker(t){if(!this._emitWorkflowGraphMarkers)return;let
|
|
80
|
-
`;this._origStdoutWrite?this._origStdoutWrite(
|
|
81
|
-
`),this._outState.lineStart=!0,this._outState.col=0),this._origStdoutWrite(`${t} ${
|
|
82
|
-
`)):process.stdout.write.bind(process.stdout)(`${t} ${
|
|
83
|
-
`)}step(t){this._origStdoutWrite?this._writeDot(
|
|
84
|
-
`)}stepTool(t){this._origStdoutWrite?this._writeDot(
|
|
85
|
-
`)}stepMemory(t){let
|
|
86
|
-
`)}stepFail(t){this._origStdoutWrite?this._writeDot(
|
|
87
|
-
`)}nodeStart(t){this._currentNode=t,this._emitGraphLogMarker({phase:"node_begin",node:t}),this._rawWrite(`${
|
|
37
|
+
`)}_emitGraphLogMarker(t){if(!this._emitWorkflowGraphMarkers)return;let e=`${Wt}${JSON.stringify(t)}
|
|
38
|
+
`;this._origStdoutWrite?this._origStdoutWrite(e):process.stdout.write(e)}_writeDot(t,e){this._origStdoutWrite?(this._outState&&!this._outState.lineStart&&(this._origStdoutWrite(`
|
|
39
|
+
`),this._outState.lineStart=!0,this._outState.col=0),this._origStdoutWrite(`${t} ${e}
|
|
40
|
+
`)):process.stdout.write.bind(process.stdout)(`${t} ${e}
|
|
41
|
+
`)}step(t){this._origStdoutWrite?this._writeDot(rt,t):process.stdout.write.bind(process.stdout)(`${z} ${rt} ${t}
|
|
42
|
+
`)}stepTool(t){this._origStdoutWrite?this._writeDot(gt,t):process.stdout.write.bind(process.stdout)(`${z} ${gt} ${t}
|
|
43
|
+
`)}stepMemory(t){let e=x.hex("#2dd4bf")(t);this._origStdoutWrite?this._writeDot(ht,e):process.stdout.write.bind(process.stdout)(`${z} ${ht} ${e}
|
|
44
|
+
`)}stepFail(t){this._origStdoutWrite?this._writeDot(ot,x.red(t)):process.stdout.write.bind(process.stdout)(`${z} ${ot} ${x.red(t)}
|
|
45
|
+
`)}nodeStart(t){this._currentNode=t,this._emitGraphLogMarker({phase:"node_begin",node:t}),this._rawWrite(`${Bt} ${t}`),this._startIntercepting()}nodeComplete(t,e={}){this._stopIntercepting();let{duration:r,details:n}=e;if(n)for(let o of n)this._rawWrite(`${rt} ${o}`);let l=r?x.dim(` ${yt(r)}`):"";this._rawWrite(`${dt} ${x.green("done")}${l}`),this._emitGraphLogMarker({phase:"node_end",node:t}),this._rawWrite("")}nodeFailed(t,e,r={}){this._stopIntercepting();let{duration:n}=r,l=n?x.dim(` ${yt(n)}`):"";this._rawWrite(`${ot} ${x.red(e)}`),this._rawWrite(`${dt} ${x.red("failed")}${l}`),this._emitGraphLogMarker({phase:"node_end",node:t}),this._rawWrite("")}route(t,e){this._rawWrite(x.dim(` ${t} \u2192 ${e}`)),this._rawWrite("")}graphComplete(){this._rawWrite(x.green.bold("\u2713 Workflow completed"))}},nt=new st;import{copyFileSync as Ft,existsSync as it,lstatSync as Jt,mkdirSync as Ot,rmSync as Gt,symlinkSync as Kt,unlinkSync as zt}from"node:fs";import{join as N}from"node:path";import{homedir as Ht}from"node:os";import{randomBytes as Yt}from"node:crypto";var jt=["cli-config.json","config.json","auth.json","argv.json"];function Et(s){return!(!s||typeof s!="string"||process.env.ZIBBY_CURSOR_USE_GLOBAL_MCP==="1"||process.env.ZIBBY_CURSOR_USE_GLOBAL_MCP==="true")}function wt(s){let t=N(s||process.cwd(),".zibby","tmp");Ot(t,{recursive:!0});let e=`${process.pid}-${Date.now()}-${Yt(4).toString("hex")}`,r=N(t,`cursor-agent-home-${e}`),n=N(r,".cursor");Ot(n,{recursive:!0});let l=Ht(),o=N(l,".cursor");if(it(o))for(let a of jt){let c=N(o,a);if(it(c))try{Ft(c,N(n,a))}catch{}}if(process.platform==="darwin"){let a=N(l,"Library");if(it(a))try{Kt(a,N(r,"Library"))}catch{}}return r}function bt(s){if(!(!s||typeof s!="string"))try{let t=N(s,"Library");try{Jt(t).isSymbolicLink()&&zt(t)}catch{}Gt(s,{recursive:!0,force:!0})}catch{}}var Rt=class extends j{constructor(){super("cursor","Cursor (CLI)",100)}canHandle(t){let e=[T(Y(),".local","bin","cursor-agent"),T(Y(),".cursor","bin","cursor-agent"),"/usr/local/bin/cursor-agent","/usr/local/bin/agent","/Applications/Cursor.app/Contents/Resources/app/bin/cursor","agent","cursor-agent"];for(let r of e)try{if(r.startsWith("/")){It(r,Tt.X_OK);let n=W(`"${r}" --version 2>&1`,{encoding:"utf-8",timeout:3e3,stdio:"pipe"});if(n&&n.length>0)return i.debug(`[Cursor] Found agent at: ${r} (version: ${n.trim().slice(0,50)})`),!0}else{let n=W(`which ${r}`,{encoding:"utf-8",timeout:2e3,stdio:"pipe"}).trim();if(!n)continue;let l=W(`${r} --version 2>&1`,{encoding:"utf-8",timeout:3e3,stdio:"pipe"});if(l&&l.length>0)return i.debug(`[Cursor] Found '${r}' in PATH at ${n} (version: ${l.trim().slice(0,50)})`),!0}}catch{continue}return i.warn("[Cursor] \u274C Cursor Agent CLI not found or not working. Run: agent --version"),!1}async invoke(t,e={}){let{workspace:r=process.cwd(),print:n=!1,schema:l=null,skills:o=null,sessionPath:a=null,nodeName:c=null,timeout:g=Z.CURSOR_AGENT_DEFAULT,config:p={}}=e,f=p?.agent?.strictMode||!1,h=e.model??p?.agent?.cursor?.model??K.CURSOR;i.debug(`[Cursor] Invoking (model: ${h}, timeout: ${g/1e3}s, skills: ${JSON.stringify(o)})`);let $=(this._setupMcpConfig(a,r,p,o,c)||{}).isolatedMcpHome??null,I=[T(Y(),".local","bin","cursor-agent"),T(Y(),".cursor","bin","cursor-agent"),"/usr/local/bin/cursor-agent","/usr/local/bin/agent","/Applications/Cursor.app/Contents/Resources/app/bin/cursor","agent","cursor-agent"],m=null;for(let y of I)try{if(y.startsWith("/"))It(y,Tt.X_OK),W(`"${y}" --version 2>&1`,{encoding:"utf-8",timeout:3e3,stdio:"pipe"});else{if(!W(`which ${y}`,{encoding:"utf-8",timeout:2e3}).trim())throw new Error("not in PATH");W(`${y} --version 2>&1`,{encoding:"utf-8",timeout:3e3,stdio:"pipe"})}m=y,i.debug(`[Agent] Using binary: ${y}`);break}catch(w){i.debug(`[Agent] Binary '${y}' check failed: ${w.message}`);continue}if(!m)throw new Error(`Cursor Agent CLI not found or not working.
|
|
88
46
|
|
|
89
47
|
Checked paths:
|
|
90
|
-
${
|
|
48
|
+
${I.map(y=>` - ${y}`).join(`
|
|
91
49
|
`)}
|
|
92
50
|
|
|
93
51
|
Install cursor-agent:
|
|
@@ -96,23 +54,23 @@ Install cursor-agent:
|
|
|
96
54
|
Then add to PATH:
|
|
97
55
|
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc && source ~/.zshrc
|
|
98
56
|
|
|
99
|
-
Test with: agent --version`);let
|
|
57
|
+
Test with: agent --version`);let b=null;if(l){let y=`zibby-result-${Date.now()}.json`;b=T(r,".zibby","tmp",y);let w=T(r,".zibby","tmp");H(w)||At(w,{recursive:!0});let v=V.generateFileOutputInstructions(l,b);t=`${t}
|
|
100
58
|
|
|
101
|
-
${
|
|
102
|
-
\u25C6 Model: ${h||"auto"}${
|
|
103
|
-
`);let
|
|
104
|
-
${
|
|
105
|
-
`)}catch{}let
|
|
106
|
-
`),
|
|
107
|
-
`;if(
|
|
108
|
-
`)){let
|
|
109
|
-
${
|
|
110
|
-
`).filter(
|
|
111
|
-
`).filter(
|
|
59
|
+
${v}`}let k=process.env.CURSOR_API_KEY,L=k?` | key: ***${k.slice(-4)}`:" | key: not set";console.log(`
|
|
60
|
+
\u25C6 Model: ${h||"auto"}${L}
|
|
61
|
+
`);let M=(await import("chalk")).default;console.log(`
|
|
62
|
+
${M.bold("Prompt sent to LLM:")}`),console.log(M.dim("\u2500".repeat(60))),console.log(M.dim(t)),console.log(M.dim("\u2500".repeat(60)));let B=["--print","--force","--approve-mcps","--output-format","stream-json","--stream-partial-output","--model",h||"auto"];if(process.env.CURSOR_API_KEY&&B.push("--api-key",process.env.CURSOR_API_KEY),B.push(t),i.debug(`[Agent] Prompt: ${t.length} chars, model: ${h||"auto"}`),i.debug(`[Agent] Workspace: ${r}`),process.env.LOG_LEVEL==="debug"||process.env.ZIBBY_LOG_CURSOR_CLI==="1")try{console.log(`\u{1F527} Cursor CLI --model ${h||"auto"} (from .zibby.config.js agent.cursor.model)
|
|
63
|
+
`)}catch{}let C,d=null;try{let y=a||(process.env.ZIBBY_SESSION_PATH?String(process.env.ZIBBY_SESSION_PATH).trim():null);C=await this._spawnWithStreaming(m,B,r,g,null,y,$)}catch(y){d=y}let A=C?.stdout||"";if(l){let y=typeof l.parse=="function",w=null,v=!!(b&&H(b));if(b&&i.info(`[Agent] Result file: ${v?"present":"missing"} at ${b}`),v)try{let u=$t(b,"utf-8").trim();w=JSON.parse(u),i.info(`[Agent] Parsed JSON from result file OK (${u.length} chars) \u2192 object ready for validation`),d&&i.debug("[Agent] Agent exited non-zero but result file was written \u2014 recovering")}catch(u){i.warn(`\u26A0\uFE0F [Agent] Result file exists on disk but is not valid JSON: ${u.message}`)}else if(d)i.warn(`[Agent] Result file missing at ${b} (agent process error \u2014 may still recover if strictMode repairs)`);else throw i.error(`\u274C [Agent] Result file was never created at ${b}`),new Error(`Agent did not write required result file at ${b}`);if(w&&y)try{let u=l.parse(w);return i.info("\u2705 [Agent] Zod validation passed for structured result file"),f&&i.debug("[Agent] strictMode enabled but not needed \u2014 agent wrote valid file"),{raw:A,structured:u}}catch(u){i.warn(`\u26A0\uFE0F [Agent] JSON parsed but Zod rejected it (wrong types/shape): ${u.message?.slice(0,400)}`)}else{if(w)return i.info("\u2705 [Agent] File-based output extracted (no Zod parse fn) \u2014 accepting as structured"),f&&i.debug("[Agent] strictMode enabled but not needed \u2014 agent wrote valid file"),{raw:A,structured:w};v&&i.error("\u274C [Agent] Result file exists but produced no in-memory JSON (parse failed earlier)")}if(f&&!d){let u=C.parsedText,O=w?JSON.stringify(w):u;i.info(`[Agent] strictMode: calling OpenAI proxy to fix structured output (${O.length} chars in)`);try{let _=await ft(O,l);if(y){let E=l.parse(_.structured);return i.info("\u2705 [Agent] Proxy output passed Zod validation"),{raw:A,structured:E}}return{raw:A,..._}}catch(_){if(i.warn(`\u26A0\uFE0F [Agent] strictMode proxy failed: ${_.message}`),w)return i.warn("[Agent] Using agent's original result file as fallback"),{raw:A,structured:w}}}if(d)throw d;let U=v?w==null?"file existed but JSON.parse failed \u2014 see WARN log above":y?"JSON was valid but Zod validation failed \u2014 see WARN log above":"no structured object after read (unexpected)":"file never appeared (agent may not have run Write tool to the path above)";throw i.error(`\u274C [Agent] No validated structured output: ${U}`),i.error("\u{1F4A1} Tip: Set strictMode=true in .zibby.config.js for OpenAI proxy fallback"),new Error(`Agent did not produce a valid result file at ${b}. Enable strictMode for proxy fallback.`)}if(d)throw d;return this._extractFinalResult(A)||C?.parsedText||A}_extractFinalResult(t){if(!t)return null;let e=t.split(`
|
|
64
|
+
`),r=null;for(let n of e){let l=n.trim();if(l)try{let o=JSON.parse(l);if(o.type==="assistant"&&o.message?.content){let a=o.message.content;if(Array.isArray(a)){let c=a.filter(g=>g.type==="text"&&g.text).map(g=>g.text).join("");c&&(r=c)}else typeof a=="string"&&a&&(r=a)}}catch{}}return r?.trim()||null}_setupMcpConfig(t,e,r,n=null,l=null){let o=r?.headless,a=T(Y(),".cursor"),c=T(a,"mcp.json"),g={};if(H(c))try{g=JSON.parse($t(c,"utf-8"))}catch{}let p=g.mcpServers||{},f=r?.paths?.output||lt,h=T(e||process.cwd(),f,at),S=Array.isArray(n)?n.map(m=>et(m)).filter(Boolean):[...pt()].map(([,m])=>m),$=new Set;for(let m of S)typeof m.resolve=="function"&&($.has(m.serverName)||($.add(m.serverName),this._ensureSkillConfigured(p,m,t,h,l,o)));if(t){let m=et("browser");m&&typeof m.resolve=="function"&&!$.has(m.serverName)&&this._ensureSkillConfigured(p,m,t,h,"execute_live",o)}if(Object.keys(p).length===0)return i.debug("[MCP] No MCP servers configured - agent will run without tool access"),{isolatedMcpHome:null};let I=`${JSON.stringify({mcpServers:p},null,2)}
|
|
65
|
+
`;if(Et(t)){let m=wt(e||process.cwd()),b=T(m,".cursor","mcp.json");return xt(b,I,"utf8"),i.debug(`[MCP] Isolated cursor-agent HOME (session-scoped mcp.json): ${m} | servers: ${Object.keys(p).join(", ")}`),{isolatedMcpHome:m}}return H(a)||At(a,{recursive:!0}),xt(c,I,"utf8"),i.debug(`[MCP] Global ~/.cursor/mcp.json | servers: ${Object.keys(p).join(", ")}`),{isolatedMcpHome:null}}_ensureSkillConfigured(t,e,r,n,l=null,o){let a=e.cursorKey||e.serverName,c=t[a]?a:t[e.serverName]?e.serverName:null;if(c&&r){let p=typeof e.resolve=="function"?e.resolve({sessionPath:r,nodeName:l,headless:o}):null;p?.args?t[c].args=p.args:t[c].args=(t[c].args||[]).map(S=>S.startsWith("--output-dir=")?`--output-dir=${r}`:S);let f=p?.env||{},h=e.sessionEnvKey?{[e.sessionEnvKey]:n}:{};t[c].env={...t[c].env||{},...f,...h},i.debug(`[MCP] Updated ${c} session \u2192 ${r}`);return}if(c)return;let g=e.resolve({sessionPath:r,nodeName:l,headless:o});g&&(t[a]={...g,...e.sessionEnvKey&&{env:{...g.env||{},[e.sessionEnvKey]:n}}},i.debug(`[MCP] Configured ${a}`))}_spawnWithStreaming(t,e,r,n,l=null,o=null,a=null){return new Promise((c,g)=>{let p=Date.now(),f="",h="",S=Date.now(),$=0,I=!1,m=null,b=!1,k=!1,L=null;if(o)try{L=T(Vt(String(o)),ut)}catch{L=null}let M=!1,B=()=>{M||(M=!0,bt(a))},C={...process.env};a&&(C.HOME=a,process.platform==="win32"&&(C.USERPROFILE=a),i.debug(`[Agent] cursor-agent HOME=${a} (isolated MCP config)`));let d=Zt(t,e,{cwd:r,shell:!1,stdio:["pipe","pipe","pipe"],env:C});i.debug(`[Agent] PID: ${d.pid}`),d.stdin.on("error",u=>{u.code!=="EPIPE"&&i.warn(`[Agent] stdin error: ${u.message}`)}),d.stdout.on("error",u=>{u.code!=="EPIPE"&&i.warn(`[Agent] stdout error: ${u.message}`)}),d.stderr.on("error",u=>{u.code!=="EPIPE"&&i.warn(`[Agent] stderr error: ${u.message}`)}),l?(d.stdin.write(l,u=>{u&&u.code!=="EPIPE"&&i.warn(`[Agent] Failed to write to stdin: ${u.message}`),d.stdin.end()}),i.debug(`[Agent] Prompt also piped to stdin (${l.length} chars)`)):d.stdin.end();let A=null;L&&(A=setInterval(()=>{if(!(I||k))try{if(H(L)){I=!0,m="studio-stop";try{Xt(L)}catch{}i.warn("\u{1F6D1} Studio stop requested \u2014 terminating Cursor agent (and MCP browser session)"),d.kill("SIGTERM"),setTimeout(()=>{d.killed||d.kill("SIGKILL")},2e3)}}catch{}},600));let F=new Set,y=new Date(p).toISOString().replace(/\.\d+Z$/,""),w=setInterval(()=>{let u=Math.round((Date.now()-p)/1e3),O=Math.round((Date.now()-S)/1e3),_=[];try{let D=Math.ceil(u/60)+1,P=W(`find "${r}" -type f -mmin -${D} -not -path '*/node_modules/*' -not -path '*/.git/*' -not -path '*/target/*' 2>/dev/null | head -20`,{encoding:"utf-8",timeout:5e3}).trim();if(P)for(let q of P.split(`
|
|
66
|
+
`)){let Q=q.replace(`${r}/`,"");F.has(Q)||(F.add(Q),_.push(Q))}}catch{}let E="";_.length>0&&(E=` | \u{1F4C1} new: ${_.map(P=>P.split("/").pop()).join(", ")}`),F.size>0&&(E+=` | \u{1F4E6} total: ${F.size} files`),i.debug(`\u{1F493} [Agent] Running for ${u}s | ${$} lines output${E}`),$===0&&u>=30&&F.size===0&&(u<35&&i.warn(`\u26A0\uFE0F [Agent] No output after ${u}s \u2014 agent may be stuck. Check your CURSOR_API_KEY.`),u>=60&&(I=!0,m=m||"stall",i.error(`\u274C [Agent] No response after ${u}s \u2014 killing. Verify CURSOR_API_KEY is valid and agent CLI works: agent --version`),d.kill("SIGTERM"),setTimeout(()=>{d.killed||d.kill("SIGKILL")},3e3)))},3e4),v=setTimeout(()=>{I=!0,m=m||"timeout";let u=Math.round((Date.now()-p)/1e3);i.error(`\u23F1\uFE0F [Agent] Timeout after ${u}s \u2014 killing process (PID: ${d.pid})`),f.trim()&&i.warn(`\u{1F4E4} [Agent] Partial output (${f.length} chars) before timeout:
|
|
67
|
+
${f.slice(-2e3)}`),d.kill("SIGTERM"),setTimeout(()=>{d.killed||d.kill("SIGKILL")},5e3)},n),U=new X;U.onToolCall=(u,O)=>{let _=u,E=O;if(u==="mcpToolCall"&&O?.name)_=O.name.replace(/^mcp_+[^_]+_+/,""),_.includes("-")&&_.split("-")[0]===_.split("-")[1]&&(_=_.split("-")[0]),E=O.args??O.input??O;else{if(u==="readToolCall"||u==="editToolCall"||u==="writeToolCall")return;(u.startsWith("mcp__")||u.includes("ToolCall"))&&(_=u.replace(/^mcp_+[^_]+_+/,"").replace(/ToolCall$/,""))}if(_.includes("memory")?nt.stepMemory(`Tool: ${_}`):nt.stepTool(`Tool: ${_}`),E!=null&&typeof E=="object"&&Object.keys(E).length>0&&!k){let P=JSON.stringify(E),q=P.length>100?`${P.substring(0,100)}...`:P;console.log(` Input: ${q}`)}},d.stdout.on("data",u=>{let O=u.toString();f+=O,S=Date.now(),b||(b=!0);let _=U.processChunk(O);_&&!k&&process.stdout.write(_);let E=O.split(`
|
|
68
|
+
`).filter(D=>D.trim());$+=E.length}),d.stderr.on("data",u=>{let O=u.toString();h+=O,S=Date.now(),b||(b=!0);let _=O.split(`
|
|
69
|
+
`).filter(E=>E.trim());for(let E of _)i.warn(`\u26A0\uFE0F [Agent stderr] ${E}`)}),d.on("close",(u,O)=>{k=!0,B(),clearTimeout(v),clearInterval(w),A&&clearInterval(A),U.flush();let _=Math.round((Date.now()-p)/1e3);if(i.debug(`[Agent] Exited: code=${u}, signal=${O}, elapsed=${_}s, output=${f.length} chars`),I){if(m==="studio-stop"){g(new Error("Stopped from Zibby Studio"));return}g(new Error(`Cursor Agent timed out after ${_}s (limit: ${n/1e3}s). ${$} lines produced. Last output ${Math.round((Date.now()-S)/1e3)}s ago. ${f.trim()?`
|
|
112
70
|
Partial output (last 500 chars):
|
|
113
|
-
${
|
|
114
|
-
Stderr: ${h.slice(-1e3)}`:""}${
|
|
115
|
-
Stdout (last 500 chars): ${
|
|
71
|
+
${f.slice(-500)}`:"No output captured."}`));return}if(u!==0){g(new Error(`Cursor Agent failed: exit code ${u}, signal ${O}. ${h.trim()?`
|
|
72
|
+
Stderr: ${h.slice(-1e3)}`:""}${f.trim()?`
|
|
73
|
+
Stdout (last 500 chars): ${f.slice(-500)}`:""}`));return}let E=U.getResult(),D=E?JSON.stringify(E,null,2):U.getRawText()||f||"";c({stdout:f||h||"",parsedText:D})}),d.on("error",u=>{B(),clearTimeout(v),clearInterval(w),A&&clearInterval(A),g(new Error(`Cursor Agent spawn error: ${u.message}
|
|
116
74
|
Binary: ${t}
|
|
117
75
|
This usually means the binary is not in PATH. Try:
|
|
118
|
-
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc && source ~/.zshrc`))})})}};export{
|
|
76
|
+
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc && source ~/.zshrc`))})})}};export{Rt as CursorAgentStrategy};
|