@tanagram/lore 0.1.2 → 0.1.4
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/README.md +3 -0
- package/dist/index.js +8 -8
- package/package.json +8 -4
- package/scripts/runPostinstallCommand.mjs +68 -0
- package/skills/lore-read/SKILL.md +82 -0
- package/skills/share/SKILL.md +74 -0
package/README.md
CHANGED
|
@@ -25,3 +25,6 @@ dirs so they don't stomp each other:
|
|
|
25
25
|
Run `lore logs` to print the active log file path. In dev, log lines also
|
|
26
26
|
tee to stderr so you see them while iterating; in prod the file is the only
|
|
27
27
|
sink so installed users don't see noise on every command.
|
|
28
|
+
|
|
29
|
+
`pnpm dev` runs the CLI postinstall hook before starting so bundled dev skills
|
|
30
|
+
are refreshed in `~/.claude/skills` on each dev session.
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var
|
|
3
|
-
`)}function A(r){return typeof r=="function"?r():r}var Q=class extends Error{code;constructor(r,t){super(r),this.name="CLIError",this.code=t}};function
|
|
4
|
-
`)}catch(n){console.error(n)}}var
|
|
5
|
-
`)}function
|
|
6
|
-
`),process.exit(1)}}async function Kr(r){let t=await A(r.args||{}),n=new Set,a=new Set;for(let[s,o]of Object.entries(t)){n.add(s);for(let c of Ne(o.alias))a.add(c)}return{help:Pt("help","h",n,a),version:Pt("version","v",n,a)}}function Pt(r,t,n,a){return n.has(r)||a.has(r)?[]:n.has(t)||a.has(t)?[`--${r}`]:[`--${r}`,`-${t}`]}import Bt from"node:fs";var Jr="prod";function ke(){return Jr}import Yr from"node:os";import It from"node:path";function lt(){let r=ke()==="dev"?".lore-dev":".lore";return It.join(Yr.homedir(),r)}function Ge(){return It.join(lt(),"log.txt")}var Lt=!1;function Xr(){Lt||(Bt.mkdirSync(lt(),{recursive:!0}),Lt=!0)}function en(r){let t=typeof r=="string"?r:JSON.stringify(r);return/[\s"=]/.test(t)?JSON.stringify(t):t}function tn(r,t,n){let a=`${new Date().toISOString()} ${r} ${t}`;if(!n)return a+`
|
|
7
|
-
`;let s=Object.entries(n).map(([
|
|
8
|
-
|
|
9
|
-
`}function Nt(r,t,n){let a=tn(r,t,n);Xr(),Bt.appendFileSync(Ge(),a),ke()==="dev"&&process.stderr.write(a)}var se={info(r,t){Nt("info",r,t)},error(r,t){Nt("error",r,t)}};var qt={meta:{name:"hello",description:"Print a friendly greeting"},run(){se.info("command_start",{command:"hello"}),console.log("hello world")}};var e={};Ir(e,{BRAND:()=>Cn,DIRTY:()=>oe,EMPTY_PATH:()=>sn,INVALID:()=>g,NEVER:()=>ma,OK:()=>E,ParseStatus:()=>O,Schema:()=>S,ZodAny:()=>te,ZodArray:()=>Y,ZodBigInt:()=>ce,ZodBoolean:()=>de,ZodBranded:()=>qe,ZodCatch:()=>ve,ZodDate:()=>le,ZodDefault:()=>_e,ZodDiscriminatedUnion:()=>We,ZodEffects:()=>U,ZodEnum:()=>ge,ZodError:()=>L,ZodFirstPartyTypeKind:()=>b,ZodFunction:()=>Je,ZodIntersection:()=>he,ZodIssueCode:()=>m,ZodLazy:()=>fe,ZodLiteral:()=>ye,ZodMap:()=>Pe,ZodNaN:()=>Ae,ZodNativeEnum:()=>be,ZodNever:()=>D,ZodNull:()=>me,ZodNullable:()=>F,ZodNumber:()=>ie,ZodObject:()=>N,ZodOptional:()=>B,ZodParsedType:()=>f,ZodPipeline:()=>Ue,ZodPromise:()=>re,ZodReadonly:()=>xe,ZodRecord:()=>Ke,ZodSchema:()=>S,ZodSet:()=>Oe,ZodString:()=>ee,ZodSymbol:()=>Ce,ZodTransformer:()=>U,ZodTuple:()=>Z,ZodType:()=>S,ZodUndefined:()=>pe,ZodUnion:()=>ue,ZodUnknown:()=>J,ZodVoid:()=>ze,addIssueToContext:()=>h,any:()=>Bn,array:()=>Dn,bigint:()=>An,boolean:()=>Wt,coerce:()=>pa,custom:()=>Gt,date:()=>En,datetimeRegex:()=>Zt,defaultErrorMap:()=>W,discriminatedUnion:()=>Fn,effect:()=>na,enum:()=>ea,function:()=>Jn,getErrorMap:()=>Te,getParsedType:()=>V,instanceof:()=>Pn,intersection:()=>Gn,isAborted:()=>He,isAsync:()=>Re,isDirty:()=>Qe,isValid:()=>X,late:()=>zn,lazy:()=>Yn,literal:()=>Xn,makeIssue:()=>Be,map:()=>Wn,nan:()=>On,nativeEnum:()=>ta,never:()=>Un,null:()=>Nn,nullable:()=>sa,number:()=>Qt,object:()=>Mn,objectUtil:()=>pt,oboolean:()=>la,onumber:()=>da,optional:()=>aa,ostring:()=>ca,pipeline:()=>ia,preprocess:()=>oa,promise:()=>ra,quotelessJson:()=>rn,record:()=>Qn,set:()=>Kn,setErrorMap:()=>an,strictObject:()=>Vn,string:()=>Ht,symbol:()=>In,transformer:()=>na,tuple:()=>Hn,undefined:()=>Ln,union:()=>Zn,unknown:()=>qn,util:()=>k,void:()=>$n});var k;(function(r){r.assertEqual=s=>{};function t(s){}r.assertIs=t;function n(s){throw new Error}r.assertNever=n,r.arrayToEnum=s=>{let o={};for(let c of s)o[c]=c;return o},r.getValidEnumValues=s=>{let o=r.objectKeys(s).filter(i=>typeof s[s[i]]!="number"),c={};for(let i of o)c[i]=s[i];return r.objectValues(c)},r.objectValues=s=>r.objectKeys(s).map(function(o){return s[o]}),r.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{let o=[];for(let c in s)Object.prototype.hasOwnProperty.call(s,c)&&o.push(c);return o},r.find=(s,o)=>{for(let c of s)if(o(c))return c},r.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function a(s,o=" | "){return s.map(c=>typeof c=="string"?`'${c}'`:c).join(o)}r.joinValues=a,r.jsonStringifyReplacer=(s,o)=>typeof o=="bigint"?o.toString():o})(k||(k={}));var pt;(function(r){r.mergeShapes=(t,n)=>({...t,...n})})(pt||(pt={}));var f=k.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),V=r=>{switch(typeof r){case"undefined":return f.undefined;case"string":return f.string;case"number":return Number.isNaN(r)?f.nan:f.number;case"boolean":return f.boolean;case"function":return f.function;case"bigint":return f.bigint;case"symbol":return f.symbol;case"object":return Array.isArray(r)?f.array:r===null?f.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?f.promise:typeof Map<"u"&&r instanceof Map?f.map:typeof Set<"u"&&r instanceof Set?f.set:typeof Date<"u"&&r instanceof Date?f.date:f.object;default:return f.unknown}};var m=k.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"]),rn=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:"),L=class r extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=a=>{this.issues=[...this.issues,a]},this.addIssues=(a=[])=>{this.issues=[...this.issues,...a]};let n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=t}format(t){let n=t||function(o){return o.message},a={_errors:[]},s=o=>{for(let c of o.issues)if(c.code==="invalid_union")c.unionErrors.map(s);else if(c.code==="invalid_return_type")s(c.returnTypeError);else if(c.code==="invalid_arguments")s(c.argumentsError);else if(c.path.length===0)a._errors.push(n(c));else{let i=a,l=0;for(;l<c.path.length;){let p=c.path[l];l===c.path.length-1?(i[p]=i[p]||{_errors:[]},i[p]._errors.push(n(c))):i[p]=i[p]||{_errors:[]},i=i[p],l++}}};return s(this),a}static assert(t){if(!(t instanceof r))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,k.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=n=>n.message){let n={},a=[];for(let s of this.issues)if(s.path.length>0){let o=s.path[0];n[o]=n[o]||[],n[o].push(t(s))}else a.push(t(s));return{formErrors:a,fieldErrors:n}}get formErrors(){return this.flatten()}};L.create=r=>new L(r);var nn=(r,t)=>{let n;switch(r.code){case m.invalid_type:r.received===f.undefined?n="Required":n=`Expected ${r.expected}, received ${r.received}`;break;case m.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(r.expected,k.jsonStringifyReplacer)}`;break;case m.unrecognized_keys:n=`Unrecognized key(s) in object: ${k.joinValues(r.keys,", ")}`;break;case m.invalid_union:n="Invalid input";break;case m.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${k.joinValues(r.options)}`;break;case m.invalid_enum_value:n=`Invalid enum value. Expected ${k.joinValues(r.options)}, received '${r.received}'`;break;case m.invalid_arguments:n="Invalid function arguments";break;case m.invalid_return_type:n="Invalid function return type";break;case m.invalid_date:n="Invalid date";break;case m.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(n=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?n=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?n=`Invalid input: must end with "${r.validation.endsWith}"`:k.assertNever(r.validation):r.validation!=="regex"?n=`Invalid ${r.validation}`:n="Invalid";break;case m.too_small:r.type==="array"?n=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?n=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?n=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="bigint"?n=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?n=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:n="Invalid input";break;case m.too_big:r.type==="array"?n=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?n=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?n=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?n=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?n=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:n="Invalid input";break;case m.custom:n="Invalid input";break;case m.invalid_intersection_types:n="Intersection results could not be merged";break;case m.not_multiple_of:n=`Number must be a multiple of ${r.multipleOf}`;break;case m.not_finite:n="Number must be finite";break;default:n=t.defaultError,k.assertNever(r)}return{message:n}},W=nn;var Ut=W;function an(r){Ut=r}function Te(){return Ut}var Be=r=>{let{data:t,path:n,errorMaps:a,issueData:s}=r,o=[...n,...s.path||[]],c={...s,path:o};if(s.message!==void 0)return{...s,path:o,message:s.message};let i="",l=a.filter(p=>!!p).slice().reverse();for(let p of l)i=p(c,{data:t,defaultError:i}).message;return{...s,path:o,message:i}},sn=[];function h(r,t){let n=Te(),a=Be({issueData:t,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,n,n===W?void 0:W].filter(s=>!!s)});r.common.issues.push(a)}var O=class r{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,n){let a=[];for(let s of n){if(s.status==="aborted")return g;s.status==="dirty"&&t.dirty(),a.push(s.value)}return{status:t.value,value:a}}static async mergeObjectAsync(t,n){let a=[];for(let s of n){let o=await s.key,c=await s.value;a.push({key:o,value:c})}return r.mergeObjectSync(t,a)}static mergeObjectSync(t,n){let a={};for(let s of n){let{key:o,value:c}=s;if(o.status==="aborted"||c.status==="aborted")return g;o.status==="dirty"&&t.dirty(),c.status==="dirty"&&t.dirty(),o.value!=="__proto__"&&(typeof c.value<"u"||s.alwaysSet)&&(a[o.value]=c.value)}return{status:t.value,value:a}}},g=Object.freeze({status:"aborted"}),oe=r=>({status:"dirty",value:r}),E=r=>({status:"valid",value:r}),He=r=>r.status==="aborted",Qe=r=>r.status==="dirty",X=r=>r.status==="valid",Re=r=>typeof Promise<"u"&&r instanceof Promise;var y;(function(r){r.errToObj=t=>typeof t=="string"?{message:t}:t||{},r.toString=t=>typeof t=="string"?t:t?.message})(y||(y={}));var q=class{constructor(t,n,a,s){this._cachedPath=[],this.parent=t,this.data=n,this._path=a,this._key=s}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}},$t=(r,t)=>{if(X(t))return{success:!0,data:t.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let n=new L(r.common.issues);return this._error=n,this._error}}};function x(r){if(!r)return{};let{errorMap:t,invalid_type_error:n,required_error:a,description:s}=r;if(t&&(n||a))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:s}:{errorMap:(c,i)=>{let{message:l}=r;return c.code==="invalid_enum_value"?{message:l??i.defaultError}:typeof i.data>"u"?{message:l??a??i.defaultError}:c.code!=="invalid_type"?{message:i.defaultError}:{message:l??n??i.defaultError}},description:s}}var S=class{get description(){return this._def.description}_getType(t){return V(t.data)}_getOrReturnCtx(t,n){return n||{common:t.parent.common,data:t.data,parsedType:V(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new O,ctx:{common:t.parent.common,data:t.data,parsedType:V(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){let n=this._parse(t);if(Re(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(t){let n=this._parse(t);return Promise.resolve(n)}parse(t,n){let a=this.safeParse(t,n);if(a.success)return a.data;throw a.error}safeParse(t,n){let a={common:{issues:[],async:n?.async??!1,contextualErrorMap:n?.errorMap},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:V(t)},s=this._parseSync({data:t,path:a.path,parent:a});return $t(a,s)}"~validate"(t){let n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:V(t)};if(!this["~standard"].async)try{let a=this._parseSync({data:t,path:[],parent:n});return X(a)?{value:a.value}:{issues:n.common.issues}}catch(a){a?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:n}).then(a=>X(a)?{value:a.value}:{issues:n.common.issues})}async parseAsync(t,n){let a=await this.safeParseAsync(t,n);if(a.success)return a.data;throw a.error}async safeParseAsync(t,n){let a={common:{issues:[],contextualErrorMap:n?.errorMap,async:!0},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:V(t)},s=this._parse({data:t,path:a.path,parent:a}),o=await(Re(s)?s:Promise.resolve(s));return $t(a,o)}refine(t,n){let a=s=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(s):n;return this._refinement((s,o)=>{let c=t(s),i=()=>o.addIssue({code:m.custom,...a(s)});return typeof Promise<"u"&&c instanceof Promise?c.then(l=>l?!0:(i(),!1)):c?!0:(i(),!1)})}refinement(t,n){return this._refinement((a,s)=>t(a)?!0:(s.addIssue(typeof n=="function"?n(a,s):n),!1))}_refinement(t){return new U({schema:this,typeName:b.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:n=>this["~validate"](n)}}optional(){return B.create(this,this._def)}nullable(){return F.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Y.create(this)}promise(){return re.create(this,this._def)}or(t){return ue.create([this,t],this._def)}and(t){return he.create(this,t,this._def)}transform(t){return new U({...x(this._def),schema:this,typeName:b.ZodEffects,effect:{type:"transform",transform:t}})}default(t){let n=typeof t=="function"?t:()=>t;return new _e({...x(this._def),innerType:this,defaultValue:n,typeName:b.ZodDefault})}brand(){return new qe({typeName:b.ZodBranded,type:this,...x(this._def)})}catch(t){let n=typeof t=="function"?t:()=>t;return new ve({...x(this._def),innerType:this,catchValue:n,typeName:b.ZodCatch})}describe(t){let n=this.constructor;return new n({...this._def,description:t})}pipe(t){return Ue.create(this,t)}readonly(){return xe.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},on=/^c[^\s-]{8,}$/i,cn=/^[0-9a-z]+$/,dn=/^[0-9A-HJKMNP-TV-Z]{26}$/i,ln=/^[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,pn=/^[a-z0-9_-]{21}$/i,mn=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,un=/^[-+]?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)?)??$/,hn=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,fn="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",mt,yn=/^(?:(?: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])$/,gn=/^(?:(?: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])$/,bn=/^(([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]))$/,_n=/^(([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])$/,vn=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,xn=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Mt="((\\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])))",Sn=new RegExp(`^${Mt}$`);function Vt(r){let t="[0-5]\\d";r.precision?t=`${t}\\.\\d{${r.precision}}`:r.precision==null&&(t=`${t}(\\.\\d+)?`);let n=r.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function jn(r){return new RegExp(`^${Vt(r)}$`)}function Zt(r){let t=`${Mt}T${Vt(r)}`,n=[];return n.push(r.local?"Z?":"Z"),r.offset&&n.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${n.join("|")})`,new RegExp(`^${t}$`)}function kn(r,t){return!!((t==="v4"||!t)&&yn.test(r)||(t==="v6"||!t)&&bn.test(r))}function Tn(r,t){if(!mn.test(r))return!1;try{let[n]=r.split(".");if(!n)return!1;let a=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),s=JSON.parse(atob(a));return!(typeof s!="object"||s===null||"typ"in s&&s?.typ!=="JWT"||!s.alg||t&&s.alg!==t)}catch{return!1}}function Rn(r,t){return!!((t==="v4"||!t)&&gn.test(r)||(t==="v6"||!t)&&_n.test(r))}var ee=class r extends S{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==f.string){let o=this._getOrReturnCtx(t);return h(o,{code:m.invalid_type,expected:f.string,received:o.parsedType}),g}let a=new O,s;for(let o of this._def.checks)if(o.kind==="min")t.data.length<o.value&&(s=this._getOrReturnCtx(t,s),h(s,{code:m.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),a.dirty());else if(o.kind==="max")t.data.length>o.value&&(s=this._getOrReturnCtx(t,s),h(s,{code:m.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),a.dirty());else if(o.kind==="length"){let c=t.data.length>o.value,i=t.data.length<o.value;(c||i)&&(s=this._getOrReturnCtx(t,s),c?h(s,{code:m.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}):i&&h(s,{code:m.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}),a.dirty())}else if(o.kind==="email")hn.test(t.data)||(s=this._getOrReturnCtx(t,s),h(s,{validation:"email",code:m.invalid_string,message:o.message}),a.dirty());else if(o.kind==="emoji")mt||(mt=new RegExp(fn,"u")),mt.test(t.data)||(s=this._getOrReturnCtx(t,s),h(s,{validation:"emoji",code:m.invalid_string,message:o.message}),a.dirty());else if(o.kind==="uuid")ln.test(t.data)||(s=this._getOrReturnCtx(t,s),h(s,{validation:"uuid",code:m.invalid_string,message:o.message}),a.dirty());else if(o.kind==="nanoid")pn.test(t.data)||(s=this._getOrReturnCtx(t,s),h(s,{validation:"nanoid",code:m.invalid_string,message:o.message}),a.dirty());else if(o.kind==="cuid")on.test(t.data)||(s=this._getOrReturnCtx(t,s),h(s,{validation:"cuid",code:m.invalid_string,message:o.message}),a.dirty());else if(o.kind==="cuid2")cn.test(t.data)||(s=this._getOrReturnCtx(t,s),h(s,{validation:"cuid2",code:m.invalid_string,message:o.message}),a.dirty());else if(o.kind==="ulid")dn.test(t.data)||(s=this._getOrReturnCtx(t,s),h(s,{validation:"ulid",code:m.invalid_string,message:o.message}),a.dirty());else if(o.kind==="url")try{new URL(t.data)}catch{s=this._getOrReturnCtx(t,s),h(s,{validation:"url",code:m.invalid_string,message:o.message}),a.dirty()}else o.kind==="regex"?(o.regex.lastIndex=0,o.regex.test(t.data)||(s=this._getOrReturnCtx(t,s),h(s,{validation:"regex",code:m.invalid_string,message:o.message}),a.dirty())):o.kind==="trim"?t.data=t.data.trim():o.kind==="includes"?t.data.includes(o.value,o.position)||(s=this._getOrReturnCtx(t,s),h(s,{code:m.invalid_string,validation:{includes:o.value,position:o.position},message:o.message}),a.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)||(s=this._getOrReturnCtx(t,s),h(s,{code:m.invalid_string,validation:{startsWith:o.value},message:o.message}),a.dirty()):o.kind==="endsWith"?t.data.endsWith(o.value)||(s=this._getOrReturnCtx(t,s),h(s,{code:m.invalid_string,validation:{endsWith:o.value},message:o.message}),a.dirty()):o.kind==="datetime"?Zt(o).test(t.data)||(s=this._getOrReturnCtx(t,s),h(s,{code:m.invalid_string,validation:"datetime",message:o.message}),a.dirty()):o.kind==="date"?Sn.test(t.data)||(s=this._getOrReturnCtx(t,s),h(s,{code:m.invalid_string,validation:"date",message:o.message}),a.dirty()):o.kind==="time"?jn(o).test(t.data)||(s=this._getOrReturnCtx(t,s),h(s,{code:m.invalid_string,validation:"time",message:o.message}),a.dirty()):o.kind==="duration"?un.test(t.data)||(s=this._getOrReturnCtx(t,s),h(s,{validation:"duration",code:m.invalid_string,message:o.message}),a.dirty()):o.kind==="ip"?kn(t.data,o.version)||(s=this._getOrReturnCtx(t,s),h(s,{validation:"ip",code:m.invalid_string,message:o.message}),a.dirty()):o.kind==="jwt"?Tn(t.data,o.alg)||(s=this._getOrReturnCtx(t,s),h(s,{validation:"jwt",code:m.invalid_string,message:o.message}),a.dirty()):o.kind==="cidr"?Rn(t.data,o.version)||(s=this._getOrReturnCtx(t,s),h(s,{validation:"cidr",code:m.invalid_string,message:o.message}),a.dirty()):o.kind==="base64"?vn.test(t.data)||(s=this._getOrReturnCtx(t,s),h(s,{validation:"base64",code:m.invalid_string,message:o.message}),a.dirty()):o.kind==="base64url"?xn.test(t.data)||(s=this._getOrReturnCtx(t,s),h(s,{validation:"base64url",code:m.invalid_string,message:o.message}),a.dirty()):k.assertNever(o);return{status:a.value,value:t.data}}_regex(t,n,a){return this.refinement(s=>t.test(s),{validation:n,code:m.invalid_string,...y.errToObj(a)})}_addCheck(t){return new r({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...y.errToObj(t)})}url(t){return this._addCheck({kind:"url",...y.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...y.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...y.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...y.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...y.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...y.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...y.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...y.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...y.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...y.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...y.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...y.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,...y.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,...y.errToObj(t?.message)})}duration(t){return this._addCheck({kind:"duration",...y.errToObj(t)})}regex(t,n){return this._addCheck({kind:"regex",regex:t,...y.errToObj(n)})}includes(t,n){return this._addCheck({kind:"includes",value:t,position:n?.position,...y.errToObj(n?.message)})}startsWith(t,n){return this._addCheck({kind:"startsWith",value:t,...y.errToObj(n)})}endsWith(t,n){return this._addCheck({kind:"endsWith",value:t,...y.errToObj(n)})}min(t,n){return this._addCheck({kind:"min",value:t,...y.errToObj(n)})}max(t,n){return this._addCheck({kind:"max",value:t,...y.errToObj(n)})}length(t,n){return this._addCheck({kind:"length",value:t,...y.errToObj(n)})}nonempty(t){return this.min(1,y.errToObj(t))}trim(){return new r({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new r({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new r({...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 n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxLength(){let t=null;for(let n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}};ee.create=r=>new ee({checks:[],typeName:b.ZodString,coerce:r?.coerce??!1,...x(r)});function wn(r,t){let n=(r.toString().split(".")[1]||"").length,a=(t.toString().split(".")[1]||"").length,s=n>a?n:a,o=Number.parseInt(r.toFixed(s).replace(".","")),c=Number.parseInt(t.toFixed(s).replace(".",""));return o%c/10**s}var ie=class r extends S{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==f.number){let o=this._getOrReturnCtx(t);return h(o,{code:m.invalid_type,expected:f.number,received:o.parsedType}),g}let a,s=new O;for(let o of this._def.checks)o.kind==="int"?k.isInteger(t.data)||(a=this._getOrReturnCtx(t,a),h(a,{code:m.invalid_type,expected:"integer",received:"float",message:o.message}),s.dirty()):o.kind==="min"?(o.inclusive?t.data<o.value:t.data<=o.value)&&(a=this._getOrReturnCtx(t,a),h(a,{code:m.too_small,minimum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),s.dirty()):o.kind==="max"?(o.inclusive?t.data>o.value:t.data>=o.value)&&(a=this._getOrReturnCtx(t,a),h(a,{code:m.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),s.dirty()):o.kind==="multipleOf"?wn(t.data,o.value)!==0&&(a=this._getOrReturnCtx(t,a),h(a,{code:m.not_multiple_of,multipleOf:o.value,message:o.message}),s.dirty()):o.kind==="finite"?Number.isFinite(t.data)||(a=this._getOrReturnCtx(t,a),h(a,{code:m.not_finite,message:o.message}),s.dirty()):k.assertNever(o);return{status:s.value,value:t.data}}gte(t,n){return this.setLimit("min",t,!0,y.toString(n))}gt(t,n){return this.setLimit("min",t,!1,y.toString(n))}lte(t,n){return this.setLimit("max",t,!0,y.toString(n))}lt(t,n){return this.setLimit("max",t,!1,y.toString(n))}setLimit(t,n,a,s){return new r({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:a,message:y.toString(s)}]})}_addCheck(t){return new r({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:y.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:y.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:y.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:y.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:y.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:y.toString(n)})}finite(t){return this._addCheck({kind:"finite",message:y.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:y.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:y.toString(t)})}get minValue(){let t=null;for(let n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(let n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&k.isInteger(t.value))}get isFinite(){let t=null,n=null;for(let a of this._def.checks){if(a.kind==="finite"||a.kind==="int"||a.kind==="multipleOf")return!0;a.kind==="min"?(n===null||a.value>n)&&(n=a.value):a.kind==="max"&&(t===null||a.value<t)&&(t=a.value)}return Number.isFinite(n)&&Number.isFinite(t)}};ie.create=r=>new ie({checks:[],typeName:b.ZodNumber,coerce:r?.coerce||!1,...x(r)});var ce=class r extends S{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==f.bigint)return this._getInvalidInput(t);let a,s=new O;for(let o of this._def.checks)o.kind==="min"?(o.inclusive?t.data<o.value:t.data<=o.value)&&(a=this._getOrReturnCtx(t,a),h(a,{code:m.too_small,type:"bigint",minimum:o.value,inclusive:o.inclusive,message:o.message}),s.dirty()):o.kind==="max"?(o.inclusive?t.data>o.value:t.data>=o.value)&&(a=this._getOrReturnCtx(t,a),h(a,{code:m.too_big,type:"bigint",maximum:o.value,inclusive:o.inclusive,message:o.message}),s.dirty()):o.kind==="multipleOf"?t.data%o.value!==BigInt(0)&&(a=this._getOrReturnCtx(t,a),h(a,{code:m.not_multiple_of,multipleOf:o.value,message:o.message}),s.dirty()):k.assertNever(o);return{status:s.value,value:t.data}}_getInvalidInput(t){let n=this._getOrReturnCtx(t);return h(n,{code:m.invalid_type,expected:f.bigint,received:n.parsedType}),g}gte(t,n){return this.setLimit("min",t,!0,y.toString(n))}gt(t,n){return this.setLimit("min",t,!1,y.toString(n))}lte(t,n){return this.setLimit("max",t,!0,y.toString(n))}lt(t,n){return this.setLimit("max",t,!1,y.toString(n))}setLimit(t,n,a,s){return new r({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:a,message:y.toString(s)}]})}_addCheck(t){return new r({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:y.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:y.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:y.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:y.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:y.toString(n)})}get minValue(){let t=null;for(let n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(let n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}};ce.create=r=>new ce({checks:[],typeName:b.ZodBigInt,coerce:r?.coerce??!1,...x(r)});var de=class extends S{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==f.boolean){let a=this._getOrReturnCtx(t);return h(a,{code:m.invalid_type,expected:f.boolean,received:a.parsedType}),g}return E(t.data)}};de.create=r=>new de({typeName:b.ZodBoolean,coerce:r?.coerce||!1,...x(r)});var le=class r extends S{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==f.date){let o=this._getOrReturnCtx(t);return h(o,{code:m.invalid_type,expected:f.date,received:o.parsedType}),g}if(Number.isNaN(t.data.getTime())){let o=this._getOrReturnCtx(t);return h(o,{code:m.invalid_date}),g}let a=new O,s;for(let o of this._def.checks)o.kind==="min"?t.data.getTime()<o.value&&(s=this._getOrReturnCtx(t,s),h(s,{code:m.too_small,message:o.message,inclusive:!0,exact:!1,minimum:o.value,type:"date"}),a.dirty()):o.kind==="max"?t.data.getTime()>o.value&&(s=this._getOrReturnCtx(t,s),h(s,{code:m.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),a.dirty()):k.assertNever(o);return{status:a.value,value:new Date(t.data.getTime())}}_addCheck(t){return new r({...this._def,checks:[...this._def.checks,t]})}min(t,n){return this._addCheck({kind:"min",value:t.getTime(),message:y.toString(n)})}max(t,n){return this._addCheck({kind:"max",value:t.getTime(),message:y.toString(n)})}get minDate(){let t=null;for(let n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(let n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t!=null?new Date(t):null}};le.create=r=>new le({checks:[],coerce:r?.coerce||!1,typeName:b.ZodDate,...x(r)});var Ce=class extends S{_parse(t){if(this._getType(t)!==f.symbol){let a=this._getOrReturnCtx(t);return h(a,{code:m.invalid_type,expected:f.symbol,received:a.parsedType}),g}return E(t.data)}};Ce.create=r=>new Ce({typeName:b.ZodSymbol,...x(r)});var pe=class extends S{_parse(t){if(this._getType(t)!==f.undefined){let a=this._getOrReturnCtx(t);return h(a,{code:m.invalid_type,expected:f.undefined,received:a.parsedType}),g}return E(t.data)}};pe.create=r=>new pe({typeName:b.ZodUndefined,...x(r)});var me=class extends S{_parse(t){if(this._getType(t)!==f.null){let a=this._getOrReturnCtx(t);return h(a,{code:m.invalid_type,expected:f.null,received:a.parsedType}),g}return E(t.data)}};me.create=r=>new me({typeName:b.ZodNull,...x(r)});var te=class extends S{constructor(){super(...arguments),this._any=!0}_parse(t){return E(t.data)}};te.create=r=>new te({typeName:b.ZodAny,...x(r)});var J=class extends S{constructor(){super(...arguments),this._unknown=!0}_parse(t){return E(t.data)}};J.create=r=>new J({typeName:b.ZodUnknown,...x(r)});var D=class extends S{_parse(t){let n=this._getOrReturnCtx(t);return h(n,{code:m.invalid_type,expected:f.never,received:n.parsedType}),g}};D.create=r=>new D({typeName:b.ZodNever,...x(r)});var ze=class extends S{_parse(t){if(this._getType(t)!==f.undefined){let a=this._getOrReturnCtx(t);return h(a,{code:m.invalid_type,expected:f.void,received:a.parsedType}),g}return E(t.data)}};ze.create=r=>new ze({typeName:b.ZodVoid,...x(r)});var Y=class r extends S{_parse(t){let{ctx:n,status:a}=this._processInputParams(t),s=this._def;if(n.parsedType!==f.array)return h(n,{code:m.invalid_type,expected:f.array,received:n.parsedType}),g;if(s.exactLength!==null){let c=n.data.length>s.exactLength.value,i=n.data.length<s.exactLength.value;(c||i)&&(h(n,{code:c?m.too_big:m.too_small,minimum:i?s.exactLength.value:void 0,maximum:c?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),a.dirty())}if(s.minLength!==null&&n.data.length<s.minLength.value&&(h(n,{code:m.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),a.dirty()),s.maxLength!==null&&n.data.length>s.maxLength.value&&(h(n,{code:m.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),a.dirty()),n.common.async)return Promise.all([...n.data].map((c,i)=>s.type._parseAsync(new q(n,c,n.path,i)))).then(c=>O.mergeArray(a,c));let o=[...n.data].map((c,i)=>s.type._parseSync(new q(n,c,n.path,i)));return O.mergeArray(a,o)}get element(){return this._def.type}min(t,n){return new r({...this._def,minLength:{value:t,message:y.toString(n)}})}max(t,n){return new r({...this._def,maxLength:{value:t,message:y.toString(n)}})}length(t,n){return new r({...this._def,exactLength:{value:t,message:y.toString(n)}})}nonempty(t){return this.min(1,t)}};Y.create=(r,t)=>new Y({type:r,minLength:null,maxLength:null,exactLength:null,typeName:b.ZodArray,...x(t)});function we(r){if(r instanceof N){let t={};for(let n in r.shape){let a=r.shape[n];t[n]=B.create(we(a))}return new N({...r._def,shape:()=>t})}else return r instanceof Y?new Y({...r._def,type:we(r.element)}):r instanceof B?B.create(we(r.unwrap())):r instanceof F?F.create(we(r.unwrap())):r instanceof Z?Z.create(r.items.map(t=>we(t))):r}var N=class r extends S{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(),n=k.objectKeys(t);return this._cached={shape:t,keys:n},this._cached}_parse(t){if(this._getType(t)!==f.object){let p=this._getOrReturnCtx(t);return h(p,{code:m.invalid_type,expected:f.object,received:p.parsedType}),g}let{status:a,ctx:s}=this._processInputParams(t),{shape:o,keys:c}=this._getCached(),i=[];if(!(this._def.catchall instanceof D&&this._def.unknownKeys==="strip"))for(let p in s.data)c.includes(p)||i.push(p);let l=[];for(let p of c){let u=o[p],T=s.data[p];l.push({key:{status:"valid",value:p},value:u._parse(new q(s,T,s.path,p)),alwaysSet:p in s.data})}if(this._def.catchall instanceof D){let p=this._def.unknownKeys;if(p==="passthrough")for(let u of i)l.push({key:{status:"valid",value:u},value:{status:"valid",value:s.data[u]}});else if(p==="strict")i.length>0&&(h(s,{code:m.unrecognized_keys,keys:i}),a.dirty());else if(p!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let p=this._def.catchall;for(let u of i){let T=s.data[u];l.push({key:{status:"valid",value:u},value:p._parse(new q(s,T,s.path,u)),alwaysSet:u in s.data})}}return s.common.async?Promise.resolve().then(async()=>{let p=[];for(let u of l){let T=await u.key,R=await u.value;p.push({key:T,value:R,alwaysSet:u.alwaysSet})}return p}).then(p=>O.mergeObjectSync(a,p)):O.mergeObjectSync(a,l)}get shape(){return this._def.shape()}strict(t){return y.errToObj,new r({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(n,a)=>{let s=this._def.errorMap?.(n,a).message??a.defaultError;return n.code==="unrecognized_keys"?{message:y.errToObj(t).message??s}:{message:s}}}:{}})}strip(){return new r({...this._def,unknownKeys:"strip"})}passthrough(){return new r({...this._def,unknownKeys:"passthrough"})}extend(t){return new r({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new r({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:b.ZodObject})}setKey(t,n){return this.augment({[t]:n})}catchall(t){return new r({...this._def,catchall:t})}pick(t){let n={};for(let a of k.objectKeys(t))t[a]&&this.shape[a]&&(n[a]=this.shape[a]);return new r({...this._def,shape:()=>n})}omit(t){let n={};for(let a of k.objectKeys(this.shape))t[a]||(n[a]=this.shape[a]);return new r({...this._def,shape:()=>n})}deepPartial(){return we(this)}partial(t){let n={};for(let a of k.objectKeys(this.shape)){let s=this.shape[a];t&&!t[a]?n[a]=s:n[a]=s.optional()}return new r({...this._def,shape:()=>n})}required(t){let n={};for(let a of k.objectKeys(this.shape))if(t&&!t[a])n[a]=this.shape[a];else{let o=this.shape[a];for(;o instanceof B;)o=o._def.innerType;n[a]=o}return new r({...this._def,shape:()=>n})}keyof(){return Ft(k.objectKeys(this.shape))}};N.create=(r,t)=>new N({shape:()=>r,unknownKeys:"strip",catchall:D.create(),typeName:b.ZodObject,...x(t)});N.strictCreate=(r,t)=>new N({shape:()=>r,unknownKeys:"strict",catchall:D.create(),typeName:b.ZodObject,...x(t)});N.lazycreate=(r,t)=>new N({shape:r,unknownKeys:"strip",catchall:D.create(),typeName:b.ZodObject,...x(t)});var ue=class extends S{_parse(t){let{ctx:n}=this._processInputParams(t),a=this._def.options;function s(o){for(let i of o)if(i.result.status==="valid")return i.result;for(let i of o)if(i.result.status==="dirty")return n.common.issues.push(...i.ctx.common.issues),i.result;let c=o.map(i=>new L(i.ctx.common.issues));return h(n,{code:m.invalid_union,unionErrors:c}),g}if(n.common.async)return Promise.all(a.map(async o=>{let c={...n,common:{...n.common,issues:[]},parent:null};return{result:await o._parseAsync({data:n.data,path:n.path,parent:c}),ctx:c}})).then(s);{let o,c=[];for(let l of a){let p={...n,common:{...n.common,issues:[]},parent:null},u=l._parseSync({data:n.data,path:n.path,parent:p});if(u.status==="valid")return u;u.status==="dirty"&&!o&&(o={result:u,ctx:p}),p.common.issues.length&&c.push(p.common.issues)}if(o)return n.common.issues.push(...o.ctx.common.issues),o.result;let i=c.map(l=>new L(l));return h(n,{code:m.invalid_union,unionErrors:i}),g}}get options(){return this._def.options}};ue.create=(r,t)=>new ue({options:r,typeName:b.ZodUnion,...x(t)});var K=r=>r instanceof fe?K(r.schema):r instanceof U?K(r.innerType()):r instanceof ye?[r.value]:r instanceof ge?r.options:r instanceof be?k.objectValues(r.enum):r instanceof _e?K(r._def.innerType):r instanceof pe?[void 0]:r instanceof me?[null]:r instanceof B?[void 0,...K(r.unwrap())]:r instanceof F?[null,...K(r.unwrap())]:r instanceof qe||r instanceof xe?K(r.unwrap()):r instanceof ve?K(r._def.innerType):[],We=class r extends S{_parse(t){let{ctx:n}=this._processInputParams(t);if(n.parsedType!==f.object)return h(n,{code:m.invalid_type,expected:f.object,received:n.parsedType}),g;let a=this.discriminator,s=n.data[a],o=this.optionsMap.get(s);return o?n.common.async?o._parseAsync({data:n.data,path:n.path,parent:n}):o._parseSync({data:n.data,path:n.path,parent:n}):(h(n,{code:m.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[a]}),g)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,a){let s=new Map;for(let o of n){let c=K(o.shape[t]);if(!c.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let i of c){if(s.has(i))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(i)}`);s.set(i,o)}}return new r({typeName:b.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:s,...x(a)})}};function ut(r,t){let n=V(r),a=V(t);if(r===t)return{valid:!0,data:r};if(n===f.object&&a===f.object){let s=k.objectKeys(t),o=k.objectKeys(r).filter(i=>s.indexOf(i)!==-1),c={...r,...t};for(let i of o){let l=ut(r[i],t[i]);if(!l.valid)return{valid:!1};c[i]=l.data}return{valid:!0,data:c}}else if(n===f.array&&a===f.array){if(r.length!==t.length)return{valid:!1};let s=[];for(let o=0;o<r.length;o++){let c=r[o],i=t[o],l=ut(c,i);if(!l.valid)return{valid:!1};s.push(l.data)}return{valid:!0,data:s}}else return n===f.date&&a===f.date&&+r==+t?{valid:!0,data:r}:{valid:!1}}var he=class extends S{_parse(t){let{status:n,ctx:a}=this._processInputParams(t),s=(o,c)=>{if(He(o)||He(c))return g;let i=ut(o.value,c.value);return i.valid?((Qe(o)||Qe(c))&&n.dirty(),{status:n.value,value:i.data}):(h(a,{code:m.invalid_intersection_types}),g)};return a.common.async?Promise.all([this._def.left._parseAsync({data:a.data,path:a.path,parent:a}),this._def.right._parseAsync({data:a.data,path:a.path,parent:a})]).then(([o,c])=>s(o,c)):s(this._def.left._parseSync({data:a.data,path:a.path,parent:a}),this._def.right._parseSync({data:a.data,path:a.path,parent:a}))}};he.create=(r,t,n)=>new he({left:r,right:t,typeName:b.ZodIntersection,...x(n)});var Z=class r extends S{_parse(t){let{status:n,ctx:a}=this._processInputParams(t);if(a.parsedType!==f.array)return h(a,{code:m.invalid_type,expected:f.array,received:a.parsedType}),g;if(a.data.length<this._def.items.length)return h(a,{code:m.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),g;!this._def.rest&&a.data.length>this._def.items.length&&(h(a,{code:m.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());let o=[...a.data].map((c,i)=>{let l=this._def.items[i]||this._def.rest;return l?l._parse(new q(a,c,a.path,i)):null}).filter(c=>!!c);return a.common.async?Promise.all(o).then(c=>O.mergeArray(n,c)):O.mergeArray(n,o)}get items(){return this._def.items}rest(t){return new r({...this._def,rest:t})}};Z.create=(r,t)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Z({items:r,typeName:b.ZodTuple,rest:null,...x(t)})};var Ke=class r extends S{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:n,ctx:a}=this._processInputParams(t);if(a.parsedType!==f.object)return h(a,{code:m.invalid_type,expected:f.object,received:a.parsedType}),g;let s=[],o=this._def.keyType,c=this._def.valueType;for(let i in a.data)s.push({key:o._parse(new q(a,i,a.path,i)),value:c._parse(new q(a,a.data[i],a.path,i)),alwaysSet:i in a.data});return a.common.async?O.mergeObjectAsync(n,s):O.mergeObjectSync(n,s)}get element(){return this._def.valueType}static create(t,n,a){return n instanceof S?new r({keyType:t,valueType:n,typeName:b.ZodRecord,...x(a)}):new r({keyType:ee.create(),valueType:t,typeName:b.ZodRecord,...x(n)})}},Pe=class extends S{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:n,ctx:a}=this._processInputParams(t);if(a.parsedType!==f.map)return h(a,{code:m.invalid_type,expected:f.map,received:a.parsedType}),g;let s=this._def.keyType,o=this._def.valueType,c=[...a.data.entries()].map(([i,l],p)=>({key:s._parse(new q(a,i,a.path,[p,"key"])),value:o._parse(new q(a,l,a.path,[p,"value"]))}));if(a.common.async){let i=new Map;return Promise.resolve().then(async()=>{for(let l of c){let p=await l.key,u=await l.value;if(p.status==="aborted"||u.status==="aborted")return g;(p.status==="dirty"||u.status==="dirty")&&n.dirty(),i.set(p.value,u.value)}return{status:n.value,value:i}})}else{let i=new Map;for(let l of c){let p=l.key,u=l.value;if(p.status==="aborted"||u.status==="aborted")return g;(p.status==="dirty"||u.status==="dirty")&&n.dirty(),i.set(p.value,u.value)}return{status:n.value,value:i}}}};Pe.create=(r,t,n)=>new Pe({valueType:t,keyType:r,typeName:b.ZodMap,...x(n)});var Oe=class r extends S{_parse(t){let{status:n,ctx:a}=this._processInputParams(t);if(a.parsedType!==f.set)return h(a,{code:m.invalid_type,expected:f.set,received:a.parsedType}),g;let s=this._def;s.minSize!==null&&a.data.size<s.minSize.value&&(h(a,{code:m.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),n.dirty()),s.maxSize!==null&&a.data.size>s.maxSize.value&&(h(a,{code:m.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),n.dirty());let o=this._def.valueType;function c(l){let p=new Set;for(let u of l){if(u.status==="aborted")return g;u.status==="dirty"&&n.dirty(),p.add(u.value)}return{status:n.value,value:p}}let i=[...a.data.values()].map((l,p)=>o._parse(new q(a,l,a.path,p)));return a.common.async?Promise.all(i).then(l=>c(l)):c(i)}min(t,n){return new r({...this._def,minSize:{value:t,message:y.toString(n)}})}max(t,n){return new r({...this._def,maxSize:{value:t,message:y.toString(n)}})}size(t,n){return this.min(t,n).max(t,n)}nonempty(t){return this.min(1,t)}};Oe.create=(r,t)=>new Oe({valueType:r,minSize:null,maxSize:null,typeName:b.ZodSet,...x(t)});var Je=class r extends S{constructor(){super(...arguments),this.validate=this.implement}_parse(t){let{ctx:n}=this._processInputParams(t);if(n.parsedType!==f.function)return h(n,{code:m.invalid_type,expected:f.function,received:n.parsedType}),g;function a(i,l){return Be({data:i,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Te(),W].filter(p=>!!p),issueData:{code:m.invalid_arguments,argumentsError:l}})}function s(i,l){return Be({data:i,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Te(),W].filter(p=>!!p),issueData:{code:m.invalid_return_type,returnTypeError:l}})}let o={errorMap:n.common.contextualErrorMap},c=n.data;if(this._def.returns instanceof re){let i=this;return E(async function(...l){let p=new L([]),u=await i._def.args.parseAsync(l,o).catch(_=>{throw p.addIssue(a(l,_)),p}),T=await Reflect.apply(c,this,u);return await i._def.returns._def.type.parseAsync(T,o).catch(_=>{throw p.addIssue(s(T,_)),p})})}else{let i=this;return E(function(...l){let p=i._def.args.safeParse(l,o);if(!p.success)throw new L([a(l,p.error)]);let u=Reflect.apply(c,this,p.data),T=i._def.returns.safeParse(u,o);if(!T.success)throw new L([s(u,T.error)]);return T.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new r({...this._def,args:Z.create(t).rest(J.create())})}returns(t){return new r({...this._def,returns:t})}implement(t){return this.parse(t)}strictImplement(t){return this.parse(t)}static create(t,n,a){return new r({args:t||Z.create([]).rest(J.create()),returns:n||J.create(),typeName:b.ZodFunction,...x(a)})}},fe=class extends S{get schema(){return this._def.getter()}_parse(t){let{ctx:n}=this._processInputParams(t);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}};fe.create=(r,t)=>new fe({getter:r,typeName:b.ZodLazy,...x(t)});var ye=class extends S{_parse(t){if(t.data!==this._def.value){let n=this._getOrReturnCtx(t);return h(n,{received:n.data,code:m.invalid_literal,expected:this._def.value}),g}return{status:"valid",value:t.data}}get value(){return this._def.value}};ye.create=(r,t)=>new ye({value:r,typeName:b.ZodLiteral,...x(t)});function Ft(r,t){return new ge({values:r,typeName:b.ZodEnum,...x(t)})}var ge=class r extends S{_parse(t){if(typeof t.data!="string"){let n=this._getOrReturnCtx(t),a=this._def.values;return h(n,{expected:k.joinValues(a),received:n.parsedType,code:m.invalid_type}),g}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){let n=this._getOrReturnCtx(t),a=this._def.values;return h(n,{received:n.data,code:m.invalid_enum_value,options:a}),g}return E(t.data)}get options(){return this._def.values}get enum(){let t={};for(let n of this._def.values)t[n]=n;return t}get Values(){let t={};for(let n of this._def.values)t[n]=n;return t}get Enum(){let t={};for(let n of this._def.values)t[n]=n;return t}extract(t,n=this._def){return r.create(t,{...this._def,...n})}exclude(t,n=this._def){return r.create(this.options.filter(a=>!t.includes(a)),{...this._def,...n})}};ge.create=Ft;var be=class extends S{_parse(t){let n=k.getValidEnumValues(this._def.values),a=this._getOrReturnCtx(t);if(a.parsedType!==f.string&&a.parsedType!==f.number){let s=k.objectValues(n);return h(a,{expected:k.joinValues(s),received:a.parsedType,code:m.invalid_type}),g}if(this._cache||(this._cache=new Set(k.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){let s=k.objectValues(n);return h(a,{received:a.data,code:m.invalid_enum_value,options:s}),g}return E(t.data)}get enum(){return this._def.values}};be.create=(r,t)=>new be({values:r,typeName:b.ZodNativeEnum,...x(t)});var re=class extends S{unwrap(){return this._def.type}_parse(t){let{ctx:n}=this._processInputParams(t);if(n.parsedType!==f.promise&&n.common.async===!1)return h(n,{code:m.invalid_type,expected:f.promise,received:n.parsedType}),g;let a=n.parsedType===f.promise?n.data:Promise.resolve(n.data);return E(a.then(s=>this._def.type.parseAsync(s,{path:n.path,errorMap:n.common.contextualErrorMap})))}};re.create=(r,t)=>new re({type:r,typeName:b.ZodPromise,...x(t)});var U=class extends S{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===b.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){let{status:n,ctx:a}=this._processInputParams(t),s=this._def.effect||null,o={addIssue:c=>{h(a,c),c.fatal?n.abort():n.dirty()},get path(){return a.path}};if(o.addIssue=o.addIssue.bind(o),s.type==="preprocess"){let c=s.transform(a.data,o);if(a.common.async)return Promise.resolve(c).then(async i=>{if(n.value==="aborted")return g;let l=await this._def.schema._parseAsync({data:i,path:a.path,parent:a});return l.status==="aborted"?g:l.status==="dirty"?oe(l.value):n.value==="dirty"?oe(l.value):l});{if(n.value==="aborted")return g;let i=this._def.schema._parseSync({data:c,path:a.path,parent:a});return i.status==="aborted"?g:i.status==="dirty"?oe(i.value):n.value==="dirty"?oe(i.value):i}}if(s.type==="refinement"){let c=i=>{let l=s.refinement(i,o);if(a.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return i};if(a.common.async===!1){let i=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});return i.status==="aborted"?g:(i.status==="dirty"&&n.dirty(),c(i.value),{status:n.value,value:i.value})}else return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then(i=>i.status==="aborted"?g:(i.status==="dirty"&&n.dirty(),c(i.value).then(()=>({status:n.value,value:i.value}))))}if(s.type==="transform")if(a.common.async===!1){let c=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});if(!X(c))return g;let i=s.transform(c.value,o);if(i instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:i}}else return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then(c=>X(c)?Promise.resolve(s.transform(c.value,o)).then(i=>({status:n.value,value:i})):g);k.assertNever(s)}};U.create=(r,t,n)=>new U({schema:r,typeName:b.ZodEffects,effect:t,...x(n)});U.createWithPreprocess=(r,t,n)=>new U({schema:t,effect:{type:"preprocess",transform:r},typeName:b.ZodEffects,...x(n)});var B=class extends S{_parse(t){return this._getType(t)===f.undefined?E(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};B.create=(r,t)=>new B({innerType:r,typeName:b.ZodOptional,...x(t)});var F=class extends S{_parse(t){return this._getType(t)===f.null?E(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};F.create=(r,t)=>new F({innerType:r,typeName:b.ZodNullable,...x(t)});var _e=class extends S{_parse(t){let{ctx:n}=this._processInputParams(t),a=n.data;return n.parsedType===f.undefined&&(a=this._def.defaultValue()),this._def.innerType._parse({data:a,path:n.path,parent:n})}removeDefault(){return this._def.innerType}};_e.create=(r,t)=>new _e({innerType:r,typeName:b.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...x(t)});var ve=class extends S{_parse(t){let{ctx:n}=this._processInputParams(t),a={...n,common:{...n.common,issues:[]}},s=this._def.innerType._parse({data:a.data,path:a.path,parent:{...a}});return Re(s)?s.then(o=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new L(a.common.issues)},input:a.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new L(a.common.issues)},input:a.data})}}removeCatch(){return this._def.innerType}};ve.create=(r,t)=>new ve({innerType:r,typeName:b.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...x(t)});var Ae=class extends S{_parse(t){if(this._getType(t)!==f.nan){let a=this._getOrReturnCtx(t);return h(a,{code:m.invalid_type,expected:f.nan,received:a.parsedType}),g}return{status:"valid",value:t.data}}};Ae.create=r=>new Ae({typeName:b.ZodNaN,...x(r)});var Cn=Symbol("zod_brand"),qe=class extends S{_parse(t){let{ctx:n}=this._processInputParams(t),a=n.data;return this._def.type._parse({data:a,path:n.path,parent:n})}unwrap(){return this._def.type}},Ue=class r extends S{_parse(t){let{status:n,ctx:a}=this._processInputParams(t);if(a.common.async)return(async()=>{let o=await this._def.in._parseAsync({data:a.data,path:a.path,parent:a});return o.status==="aborted"?g:o.status==="dirty"?(n.dirty(),oe(o.value)):this._def.out._parseAsync({data:o.value,path:a.path,parent:a})})();{let s=this._def.in._parseSync({data:a.data,path:a.path,parent:a});return s.status==="aborted"?g:s.status==="dirty"?(n.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:a.path,parent:a})}}static create(t,n){return new r({in:t,out:n,typeName:b.ZodPipeline})}},xe=class extends S{_parse(t){let n=this._def.innerType._parse(t),a=s=>(X(s)&&(s.value=Object.freeze(s.value)),s);return Re(n)?n.then(s=>a(s)):a(n)}unwrap(){return this._def.innerType}};xe.create=(r,t)=>new xe({innerType:r,typeName:b.ZodReadonly,...x(t)});function Dt(r,t){let n=typeof r=="function"?r(t):typeof r=="string"?{message:r}:r;return typeof n=="string"?{message:n}:n}function Gt(r,t={},n){return r?te.create().superRefine((a,s)=>{let o=r(a);if(o instanceof Promise)return o.then(c=>{if(!c){let i=Dt(t,a),l=i.fatal??n??!0;s.addIssue({code:"custom",...i,fatal:l})}});if(!o){let c=Dt(t,a),i=c.fatal??n??!0;s.addIssue({code:"custom",...c,fatal:i})}}):te.create()}var zn={object:N.lazycreate},b;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(b||(b={}));var Pn=(r,t={message:`Input not instance of ${r.name}`})=>Gt(n=>n instanceof r,t),Ht=ee.create,Qt=ie.create,On=Ae.create,An=ce.create,Wt=de.create,En=le.create,In=Ce.create,Ln=pe.create,Nn=me.create,Bn=te.create,qn=J.create,Un=D.create,$n=ze.create,Dn=Y.create,Mn=N.create,Vn=N.strictCreate,Zn=ue.create,Fn=We.create,Gn=he.create,Hn=Z.create,Qn=Ke.create,Wn=Pe.create,Kn=Oe.create,Jn=Je.create,Yn=fe.create,Xn=ye.create,ea=ge.create,ta=be.create,ra=re.create,na=U.create,aa=B.create,sa=F.create,oa=U.createWithPreprocess,ia=Ue.create,ca=()=>Ht().optional(),da=()=>Qt().optional(),la=()=>Wt().optional(),pa={string:r=>ee.create({...r,coerce:!0}),number:r=>ie.create({...r,coerce:!0}),boolean:r=>de.create({...r,coerce:!0}),bigint:r=>ce.create({...r,coerce:!0}),date:r=>le.create({...r,coerce:!0})};var ma=g;var ua=r=>typeof r?.safeParse=="function";var ht=r=>typeof r?.passthrough=="function";var ha=(r,t)=>ht(r)?ht(t)?r.merge(t):r:ht(t)?t:Object.assign({},r,t);var Cc=e.object({name:e.literal("ZodError"),issues:e.array(e.object({path:e.array(e.union([e.string(),e.number()])),message:e.string().optional(),code:e.nativeEnum(e.ZodIssueCode)}).catchall(e.any()))}),fa=Symbol("ContractNoBody"),Jt=r=>"method"in r&&"path"in r;var Yt=(r,t)=>Object.fromEntries(Object.entries(r).map(([n,a])=>{var s,o,c;return Jt(a)?[n,{...a,path:t?.pathPrefix?t.pathPrefix+a.path:a.path,headers:ha(t?.baseHeaders,a.headers),strictStatusCodes:(s=a.strictStatusCodes)!==null&&s!==void 0?s:t?.strictStatusCodes,validateResponseOnClient:(o=a.validateResponseOnClient)!==null&&o!==void 0?o:t?.validateResponseOnClient,responses:{...t?.commonResponses,...a.responses},metadata:t?.metadata?{...t?.metadata,...(c=a.metadata)!==null&&c!==void 0?c:{}}:a.metadata}]:[n,Yt(a,t)]})),ft=Symbol("ContractPlainType"),G=()=>({router:(r,t)=>Yt(r,t),query:r=>r,mutation:r=>r,responses:r=>r,response:()=>ft,body:()=>ft,type:()=>ft,otherResponse:({contentType:r,body:t})=>({contentType:r,body:t}),noBody:()=>fa}),ya=({path:r,params:t})=>{let n=t;return r.replace(/\/?:([^/?]+)\??/g,(a,s)=>n[s]?`${a.startsWith("/")?"/":""}${n[s]}`:"")},ga=(r,t=!1)=>{let n=t?ba(r):_a(r);return n?.length>0?"?"+n:""},ba=r=>r?Object.entries(r).filter(([,t])=>t!==void 0).map(([t,n])=>{let a;return typeof n=="string"&&!["true","false","null"].includes(n.trim())&&isNaN(Number(n))?a=n:a=JSON.stringify(n),`${encodeURIComponent(t)}=${encodeURIComponent(a)}`}).join("&"):"",_a=r=>r?Object.keys(r).flatMap(t=>yt(t,r[t])).map(([t,n])=>`${encodeURIComponent(t)}=${encodeURIComponent(n)}`).join("&"):"",yt=(r,t)=>Array.isArray(t)?t.flatMap((n,a)=>yt(`${r}[${a}]`,n)):t instanceof Date?[[`${r}`,t.toISOString()]]:t===null?[[`${r}`,""]]:t===void 0?[]:typeof t=="object"?Object.keys(t).flatMap(n=>yt(`${r}[${n}]`,t[n])):[[`${r}`,`${t}`]];var gt=class extends Error{constructor(t,n){let a=n.join(",");super(`Server returned unexpected response. Expected one of: ${a} got: ${t.status}`),this.response=t}};var va=async({route:r,path:t,method:n,headers:a,body:s,validateResponse:o,fetchOptions:c})=>{let i=await fetch(t,{...c,method:n,headers:a,body:s}),l=i.headers.get("content-type");if(l?.includes("application/")&&l?.includes("json")){let p={status:i.status,body:await i.json(),headers:i.headers},u=r.responses[p.status];return(o??r.validateResponseOnClient)&&ua(u)?{...p,body:u.parse(p.body)}:p}return l?.includes("text/")?{status:i.status,body:await i.text(),headers:i.headers}:{status:i.status,body:await i.blob(),headers:i.headers}},xa=r=>{let t=new FormData,n=(a,s)=>{s instanceof File?t.append(a,s):t.append(a,JSON.stringify(s))};return Object.entries(r).forEach(([a,s])=>{if(Array.isArray(s))for(let o of s)n(a,o);else n(a,s)}),t},Kt=r=>Object.fromEntries(Object.entries(r).map(([t,n])=>[t.toLowerCase(),n])),Sa=r=>{let{path:t,clientArgs:n,route:a,body:s,query:o,extraInputArgs:c,headers:i,fetchOptions:l}=r,p=n.api||va,u=n.baseHeaders&&Object.fromEntries(Object.entries(n.baseHeaders).map(([_,z])=>typeof z=="function"?[_,z(r)]:[_,z])),T={...u&&Kt(u),...Kt(i)};Object.keys(T).forEach(_=>{T[_]===void 0&&delete T[_]});let R={route:a,path:t,method:a.method,headers:T,body:void 0,rawBody:s,rawQuery:o,contentType:void 0,validateResponse:n.validateResponse,fetchOptions:{...n.credentials&&{credentials:n.credentials},...l},...l?.signal&&{signal:l.signal},...l?.cache&&{cache:l.cache},...l&&"next"in l&&!!l?.next&&{next:l.next}};return a.method!=="GET"&&("contentType"in a&&a.contentType==="multipart/form-data"?R={...R,contentType:"multipart/form-data",body:s instanceof FormData?s:xa(s)}:"contentType"in a&&a.contentType==="application/x-www-form-urlencoded"?R={...R,contentType:"application/x-www-form-urlencoded",headers:{"content-type":"application/x-www-form-urlencoded",...R.headers},body:typeof s=="string"?s:new URLSearchParams(s)}:s!=null&&(R={...R,contentType:"application/json",headers:{"content-type":"application/json",...R.headers},body:JSON.stringify(s)})),p({...R,...c})},ja=(r,t,n)=>{let{query:a,params:s,body:o,headers:c,extraHeaders:i,overrideClientOptions:l,fetchOptions:p,cache:u,next:T,...R}=n||{},_={...t,...l};return{path:ka(a,_.baseUrl,s,r,!!_.jsonQuery),clientArgs:_,route:r,body:o,query:a,extraInputArgs:R,fetchOptions:{...u&&{cache:u},...T&&{next:T},...p},headers:{...i,...c}}},ka=(r,t,n,a,s)=>{let o=ya({path:a.path,params:n}),c=ga(r,s);return`${t}${o}${c}`},Ta=(r,t)=>{let n=Object.keys(r.responses);return async a=>{let s=ja(r,t,a),o=await Sa(s);if(!t.throwOnUnknownStatus||n.includes(o.status.toString()))return o;throw new gt(o,n)}},bt=(r,t)=>Object.fromEntries(Object.entries(r).map(([n,a])=>Jt(a)?[n,Ta(a,t)]:[n,bt(a,t)]));var _t=["free","creator","team"],Xt=typeof process<"u"&&process.env?.NODE_ENV!=="production",Ra={stripe:{plans:[{tier:"free",subjectType:"user",name:"Free",description:"Upload threads, share read-only links, and collaborate with your workspace. Shared links expire after 3 days.",price:0,priceId:null,features:[{name:"Thread uploads + public links"},{name:"Workspace membership"},{name:"Shared links live 3 days"}],entitlements:{skills:!1,workspaceScope:!1,review:!1,sharedThreadTtlDays:3}},{tier:"creator",subjectType:"user",name:"Creator",description:"For builders who share a lot. Permanent links and the Skills tab.",price:29,isFeatured:!0,priceId:Xt?"price_1TP9BSKwvRM43sh64waIrvjj":"price_1TPA2gKwvRM43sh6Kp4ZCpJZ",features:[{name:"Everything in Free"},{name:"Shared threads live forever"},{name:"Skills tab \u2014 tool usage across every thread"}],entitlements:{skills:!0,workspaceScope:!1,review:!1,sharedThreadTtlDays:null}},{tier:"team",subjectType:"organization",name:"Team",description:"GitHub for Prompts. Org-wide thread sharing plus the review surface.",price:19,minSeats:2,priceId:Xt?"price_1TP9MpKwvRM43sh6TBIFxVCd":"price_1TPA3CKwvRM43sh6k0bgPTsQ",features:[{name:"Everything in Creator"},{name:"Workspace-wide thread sharing"},{name:"Minimum 2 seats"},{name:"Review feature (beta)"}],entitlements:{skills:!0,workspaceScope:!0,review:!0,sharedThreadTtlDays:null}}]}};var er=Ra.stripe.plans,Pc=Object.freeze(Object.fromEntries(er.map(r=>[r.tier,r])));var wa=G(),I=e.object({message:e.string()}),vt=e.record(e.unknown()),Se=e.string().regex(/^doc_[0-9A-Za-z]{22}$/),Ye=e.string().regex(/^proj_[0-9A-Za-z]{22}$/),Ca=["active","archived"],Xe=e.enum(Ca),tr=e.object({id:e.string().min(1),display_name:e.string().min(1)}),rr=e.object({id:Ye,name:e.string().min(1)}),xt=e.object({id:Se,title:e.string().min(1),status:Xe,author:tr,project:rr.nullable(),created_at:e.string().datetime(),updated_at:e.string().datetime(),archived_at:e.string().datetime().nullable()}),za=e.object({type:e.literal("list"),list_type:e.literal("doc"),objects:e.array(xt)}),Pa=e.object({project_id:Ye.optional(),status:Xe.optional()}),Oa=e.object({title:e.string().trim().min(1).max(300).optional(),prosemirror_json:vt.optional(),project_id:Ye.nullable().optional()}),Aa=e.object({id:Se,created_at:e.string().datetime()}),Ea=e.object({title:e.string().trim().min(1).max(300).optional(),prosemirror_json:vt.optional(),project_id:Ye.nullable().optional(),status:Xe.optional()}).refine(r=>Object.keys(r).length>0,{message:"At least one field must be provided"}),Ia=e.object({id:Se,updated_at:e.string().datetime()}),La=e.object({id:Se,title:e.string().min(1),prosemirror_json:vt,status:Xe,author:tr,project:rr.nullable(),created_at:e.string().datetime(),updated_at:e.string().datetime(),archived_at:e.string().datetime().nullable()}),nr=wa.router({listDocs:{method:"GET",path:"/docs",headers:e.object({authorization:e.string().min(1).optional()}),query:Pa,responses:{200:za,401:I,403:I},summary:"List docs in the authenticated user\u2019s organization. Optional project_id filter scopes to a single project."},createDoc:{method:"POST",path:"/docs",headers:e.object({authorization:e.string().min(1).optional()}),body:Oa,responses:{201:Aa,401:I,403:I,404:I,422:I},summary:"Create a doc. If project_id is provided, the doc is scoped to that project; otherwise it lives at the workspace level."},getDoc:{method:"GET",path:"/docs/:docId",pathParams:e.object({docId:Se}),headers:e.object({authorization:e.string().min(1).optional()}),responses:{200:La,401:I,403:I,404:I},summary:"Get a doc by id with its rich-text body and parent project (if any)"},updateDoc:{method:"PATCH",path:"/docs/:docId",pathParams:e.object({docId:Se}),headers:e.object({authorization:e.string().min(1).optional()}),body:Ea,responses:{200:Ia,401:I,403:I,404:I,422:I},summary:"Update a doc. If prosemirror_json changes, the server re-syncs lore.mention_references from mention nodes."},deleteDoc:{method:"DELETE",path:"/docs/:docId",pathParams:e.object({docId:Se}),headers:e.object({authorization:e.string().min(1).optional()}),body:e.object({}).optional(),responses:{204:e.object({}),401:I,403:I,404:I},summary:"Hard-delete a doc and any mention references it owns"}});var Na=G(),C=e.object({message:e.string()}),St=e.record(e.unknown()),H=e.string().regex(/^proj_[0-9A-Za-z]{22}$/),Ba=["active","archived"],et=e.enum(Ba),jt=e.object({id:e.string().min(1),display_name:e.string().min(1)}),ar=e.object({thread_id:e.string().min(1),title:e.string().min(1),added_at:e.string().datetime(),added_by:jt}),qa=e.object({id:H,name:e.string().min(1),status:et,author:jt,thread_count:e.number().int().nonnegative(),doc_count:e.number().int().nonnegative(),created_at:e.string().datetime(),updated_at:e.string().datetime(),archived_at:e.string().datetime().nullable()}),Ua=e.object({type:e.literal("list"),list_type:e.literal("project"),objects:e.array(qa)}),$a=e.object({status:et.optional()}),Da=e.object({name:e.string().trim().min(1).max(200),prosemirror_json:St.optional()}),Ma=e.object({id:H,created_at:e.string().datetime()}),Va=e.object({name:e.string().trim().min(1).max(200).optional(),prosemirror_json:St.optional()}).refine(r=>Object.keys(r).length>0,{message:"At least one field must be provided"}),Za=e.object({id:H,updated_at:e.string().datetime()}),Fa=e.object({archived:e.boolean()}),Ga=e.object({id:H,status:et,archived_at:e.string().datetime().nullable()}),Ha=e.object({id:H,name:e.string().min(1),prosemirror_json:St,status:et,author:jt,created_at:e.string().datetime(),updated_at:e.string().datetime(),archived_at:e.string().datetime().nullable(),threads:e.array(ar),docs:e.array(xt)}),Qa=e.object({thread_id:e.string().min(1).max(64)}),Wa=ar,sr=Na.router({listProjects:{method:"GET",path:"/projects",headers:e.object({authorization:e.string().min(1).optional()}),query:$a,responses:{200:Ua,401:C},summary:"List projects in the authenticated user\u2019s organization"},createProject:{method:"POST",path:"/projects",headers:e.object({authorization:e.string().min(1).optional()}),body:Da,responses:{201:Ma,401:C,422:C},summary:"Create a new project in the authenticated user\u2019s organization"},getProject:{method:"GET",path:"/projects/:projectId",pathParams:e.object({projectId:H}),headers:e.object({authorization:e.string().min(1).optional()}),responses:{200:Ha,401:C,403:C,404:C},summary:"Get a project with its attached threads and child docs. The project description is the canonical mention source for project-scoped @-mentions."},updateProject:{method:"PATCH",path:"/projects/:projectId",pathParams:e.object({projectId:H}),headers:e.object({authorization:e.string().min(1).optional()}),body:Va,responses:{200:Za,401:C,403:C,404:C,422:C},summary:"Update a project\u2019s name or rich-text body. Body changes re-sync mention_references for source_kind=project."},archiveProject:{method:"POST",path:"/projects/:projectId/archive",pathParams:e.object({projectId:H}),headers:e.object({authorization:e.string().min(1).optional()}),body:Fa,responses:{200:Ga,401:C,403:C,404:C},summary:"Archive (soft-delete) or unarchive a project"},addProjectThread:{method:"POST",path:"/projects/:projectId/threads",pathParams:e.object({projectId:H}),headers:e.object({authorization:e.string().min(1).optional()}),body:Qa,responses:{201:Wa,401:C,403:C,404:C,409:C,422:C},summary:"Pin an existing visible thread to this project. Idempotent \u2014 re-adding returns the existing membership."},removeProjectThread:{method:"DELETE",path:"/projects/:projectId/threads/:threadId",pathParams:e.object({projectId:H,threadId:e.string().min(1).max(64)}),headers:e.object({authorization:e.string().min(1).optional()}),body:e.object({}).optional(),responses:{204:e.object({}),401:C,403:C,404:C},summary:"Remove a thread membership from a project"}});var Ka=G(),tt=e.object({message:e.string()}),Ja=["thread","plan","doc","user"],rt=e.enum(Ja),Ya=["doc","project"],Xa=e.enum(Ya),es=e.object({kind:rt,id:e.string().min(1),title:e.string().min(1),href:e.string().min(1)}),ts=e.object({type:e.literal("list"),list_type:e.literal("mention"),objects:e.array(es)}),rs=e.object({q:e.string().trim().min(1).max(50),kinds:e.string().optional().transform(r=>{if(!r)return;let t=r.split(",").map(n=>n.trim()).filter(n=>n.length>0);return t.length>0?t:void 0}).pipe(e.array(rt).optional())}),ns=e.object({source_kind:Xa,source_id:e.string().min(1),source_title:e.string().min(1),source_href:e.string().min(1),target_kind:rt,target_id:e.string().min(1),created_at:e.string().datetime()}),as=e.object({type:e.literal("list"),list_type:e.literal("backlink"),objects:e.array(ns)}),ss=e.object({target_kind:rt,target_id:e.string().min(1).max(64)}),or=Ka.router({searchMentions:{method:"GET",path:"/mentions/search",headers:e.object({authorization:e.string().min(1).optional()}),query:rs,responses:{200:ts,401:tt,422:tt},summary:"Search threads, plans, files, and users by title/name for @-mention typeahead. Org-scoped, max 10 results across all kinds."},listBacklinks:{method:"GET",path:"/mentions/backlinks",headers:e.object({authorization:e.string().min(1).optional()}),query:ss,responses:{200:as,401:tt,403:tt},summary:"List every doc/project body in the caller\u2019s organization that mentions the given target. Newest-first."}});var os=G(),is=e.object({type:e.literal("list"),list_type:e.literal("thread"),has_more:e.boolean(),objects:e.array(e.unknown())}),ne=e.object({message:e.string()}),ir=e.object({thread_id:e.string().min(1),is_favorited:e.boolean(),favorited_at:e.string().datetime().nullable()}),cs=e.object({before:e.string().min(1).max(64).optional()}),cr=os.router({addThreadFavorite:{method:"POST",path:"/threads/:id/favorite",pathParams:e.object({id:e.string().min(1).max(64)}),headers:e.object({authorization:e.string().min(1).optional()}),body:e.object({}).optional(),responses:{201:ir,401:ne,403:ne,404:ne},summary:"Bookmark a thread for the authenticated user. Idempotent \u2014 re-favoriting returns the existing membership."},removeThreadFavorite:{method:"DELETE",path:"/threads/:id/favorite",pathParams:e.object({id:e.string().min(1).max(64)}),headers:e.object({authorization:e.string().min(1).optional()}),body:e.object({}).optional(),responses:{200:ir,401:ne,403:ne,404:ne},summary:"Remove a thread bookmark for the authenticated user (no-op if absent)."},listFavoriteThreads:{method:"GET",path:"/favorites/threads",headers:e.object({authorization:e.string().min(1).optional()}),query:cs,responses:{200:is,401:ne,403:ne},summary:"List threads the authenticated user has favorited, newest favorited first. Visibility filtering still applies \u2014 a thread the viewer can no longer see (e.g. visibility downgraded) is omitted from the list."}});var ds=G(),ls=e.object({id:e.string().uuid(),role:e.enum(["user","assistant"]),content:e.string().min(1),timestamp:e.string().datetime()}),ps=e.object({id:e.string().uuid(),title:e.string().min(1),author:e.string().min(1),authorAvatar:e.string().min(1).max(4),model:e.string().min(1),turnCount:e.number().int().nonnegative(),createdAt:e.string().datetime(),preview:e.string()}),dd=ps.extend({messages:e.array(ls)}),d=e.object({message:e.string()}),ms=/^[a-zA-Z0-9_-]{2,32}$/,yr=e.string().regex(ms,"Handle must be 2\u201332 characters: letters, numbers, dashes, or underscores."),kt=e.object({id:e.string(),first_name:e.string().min(1),last_name:e.string().min(1),display_name:e.string().min(1),stytch_id:e.string().nullable(),handle:e.string().nullable(),bio:e.string().max(280).nullable(),avatar_url:e.string().nullable(),banner_url:e.string().nullable(),share_new_threads_to_workspace:e.boolean(),experimental_features_enabled:e.boolean(),onboarded_at:e.string().nullable()}),us=e.object({stytchMemberId:e.string().min(1).optional(),emailAddress:e.string().email(),name:e.string().nullable(),user:kt,is_admin:e.boolean()}),hs=e.object({share_new_threads_to_workspace:e.boolean().optional(),experimental_features_enabled:e.boolean().optional(),onboarded_at:e.union([e.literal("now"),e.null()]).optional(),display_name:e.string().min(1).max(120).optional(),handle:yr.optional(),bio:e.string().max(280).nullable().optional(),avatar_storage_url:e.string().min(1).nullable().optional(),banner_storage_url:e.string().min(1).nullable().optional()}).refine(r=>Object.keys(r).length>0,{message:"At least one field must be provided"}),fs=e.object({id:e.string(),display_name:e.string(),handle:e.string().nullable(),avatar_url:e.string().nullable(),visible_thread_count:e.number().int().nonnegative(),last_active_at:e.string().datetime().nullable()}),gr=e.object({id:e.string().min(1),display_name:e.string().min(1),handle:e.string().nullable(),bio:e.string().max(280).nullable(),avatar_url:e.string().nullable(),banner_url:e.string().nullable(),organization_name:e.string().min(1).nullable(),created_at:e.string().min(1),visible_thread_count:e.number().int().nonnegative(),follower_count:e.number().int().nonnegative(),following_count:e.number().int().nonnegative(),published_project_count:e.number().int().nonnegative(),is_following:e.boolean(),is_self:e.boolean()}),ys=e.object({type:e.literal("list"),list_type:e.literal("organization_member"),objects:e.array(fs)}),gs=e.object({email_address:e.string().email()}),bs=e.object({email_address:e.string().email(),member_id:e.string().min(1)}),_s=e.object({location:e.string().trim().min(1),contact:e.string().trim().email()}),vs=e.object({location:e.string().min(1),contact:e.string().email(),created_at:e.string().datetime()}),xs=e.object({first_name:e.string().min(1),last_name:e.string().min(1),display_name:e.string().min(1),stytch_id:e.string().min(1).optional()}),Ss=e.object({name:e.string().min(1),email_domains:e.array(e.string().min(1)).nonempty(),stytch_org_id:e.string().min(1)}),js=e.object({user:xs,organization:Ss}),ks=e.object({path_glob:e.string().min(1),name:e.string().min(1),description:e.string().min(1)}),Ts=e.object({repo_origin_path:e.string().min(1),building_blocks:e.array(ks)}),br=e.string().regex(/^th_[0-9A-Za-z]{22}$/),at=e.string().regex(/^tb_[0-9A-Za-z]{22}$/),Rs=e.object({id:br,author:e.object({id:e.string().min(1),display_name:e.string().min(1)}),body:e.string(),created_at:e.string().datetime(),repo_origin_path:e.string().min(1),latest_revision_id:at,revision_count:e.number().int().positive()}),ws=e.object({id:e.string().min(1),display_name:e.string().min(1)}),Cs=e.object({id:e.string().min(1),author_id:e.string().min(1).nullable(),author:ws.nullable(),created_at:e.string().datetime(),deleted_at:e.string().datetime().nullable(),content:e.string().min(1)}),zs=e.object({id:e.string().min(1),thread_block_id:e.string().min(1),created_at:e.string().datetime(),resolved_at:e.string().datetime().nullable(),comments:e.array(Cs)}),Ps=e.object({thread_block_id:at,from_position:e.number().int().positive(),to_position:e.number().int().positive(),selected_text:e.string().min(1),content:e.string().trim().min(1)}),Os=e.object({id:e.string().min(1)}),As=e.object({content:e.string().trim().min(1)}),Es=e.object({id:e.string().min(1)}),Is=e.object({content:e.string().trim().min(1)}),Ls=e.object({id:e.string().min(1)}),Ns=e.object({content:e.string().trim().min(1)}),Bs=e.object({id:e.string().min(1)}),qs=e.object({resolved:e.boolean()}),Us=e.object({id:e.string().min(1),resolved_at:e.string().datetime().nullable()}),$s=e.object({resolved:e.boolean()}),Ds=e.object({id:e.string().min(1),resolved_at:e.string().datetime().nullable()}),_r=e.record(e.unknown()),Ms=e.object({id:at,body:e.string(),created_at:e.string().datetime(),prosemirror_json:_r,comment_threads:e.array(zs)}),Vs=e.object({id:br,created_at:e.string().datetime(),repo_origin_path:e.string().min(1),author:e.object({id:e.string().min(1),display_name:e.string().min(1)}),latest_revision_id:at,revision_count:e.number().int().positive(),revisions:e.array(Ms)}),Zs=e.object({type:e.literal("list"),list_type:e.literal("plan"),has_more:e.boolean(),objects:e.array(Rs)}),Fs=e.object({before:e.string().min(1).optional(),after:e.string().min(1).optional(),author_id:e.string().min(1).optional(),repo_origin_path:e.string().min(1).optional()}),vr=e.object({id:e.string().min(1),organization_id:e.string().min(1),created_at:e.string().min(1),repo_origin_path:e.string().min(1),path_glob:e.string().min(1),name:e.string().min(1),description:e.string().min(1)}),Gs=e.array(vr),Hs=e.object({type:e.literal("list"),list_type:e.literal("building_block"),has_more:e.boolean(),objects:e.array(vr)}),Qs=e.object({repo_origin_path:e.string().min(1),before:e.string().min(1).optional(),after:e.string().min(1).optional()}),Ws=e.enum(["thread","building_block"]),Ks=e.object({repo_origin_path:e.string().min(1),sources:e.array(Ws).nonempty()}),Js=e.object({type:e.literal("list"),list_type:e.literal("repository"),has_more:e.boolean(),objects:e.array(Ks)}),ae=e.enum(["claudeCode","codex","amp","cursor","unspecified"]),Ys=["transcript","plan"],Xs=e.enum(Ys),eo=e.object({md5:e.string().min(1),harness:ae,filename:e.string().min(1).optional(),repo_origin_path:e.string().min(1).optional(),harness_internal_id:e.string().min(1).optional(),file_type:Xs.optional()}).refine(r=>(r.filename?.trim().length??0)>0||(r.harness_internal_id?.trim().length??0)>0,{path:["harness_internal_id"],message:"filename or harness_internal_id is required"}),Rt=e.object({id:e.string().min(1),display_name:e.string().min(1)}),to=e.object({id:e.string().min(1),display_name:e.string().min(1)}),xr=e.object({id:e.string().min(1),author_id:e.string().min(1).nullable(),author:to.nullable(),created_at:e.string().datetime(),deleted_at:e.string().datetime().nullable(),content:e.string().min(1)}),Sr=e.object({id:e.string().min(1),thread_block_id:e.string().min(1),created_at:e.string().datetime(),resolved_at:e.string().datetime().nullable()}),ro=Sr.extend({comments:e.array(xr)}),$e=e.object({id:e.string().min(1),type:e.string().min(1),index_in_thread:e.number().int().nonnegative(),isCritiqued:e.boolean(),comment_threads:e.array(ro).optional()}).passthrough(),jr=e.object({type:e.literal("list"),list_type:e.literal("thread_block"),has_more:e.boolean(),objects:e.array($e)}),dr=$e.extend({type:e.literal("plan"),prosemirror_json:_r,thread_file_id:e.string().min(1)}),no=e.union([e.literal(-1),e.literal(1)]),kr=e.union([e.literal(-1),e.literal(0),e.literal(1)]),lr=e.object({score:e.number().int(),up_count:e.number().int().nonnegative(),down_count:e.number().int().nonnegative(),viewer_vote:kr}),ao=e.object({value:no}),so=e.object({id:e.string().min(1),display_name:e.string().min(1),avatar_url:e.string().nullable()}),je=e.object({id:e.string().min(1),thread_id:e.string().min(1),author_id:e.string().min(1).nullable(),author:so.nullable(),parent_comment_id:e.string().min(1).nullable(),content:e.string(),created_at:e.string().datetime(),updated_at:e.string().datetime(),deleted_at:e.string().datetime().nullable()}),oo=e.object({type:e.literal("list"),list_type:e.literal("thread_comment"),objects:e.array(je)}),io=e.object({content:e.string().trim().min(1).max(4e3),parent_comment_id:e.string().min(1).optional()}),co=je,lo=e.object({content:e.string().trim().min(1).max(4e3)}),po=je,mo=je,ld=e.discriminatedUnion("kind",[e.object({kind:e.literal("created"),thread_id:e.string().min(1),actor_user_id:e.string().min(1),version:e.number(),comment:je}),e.object({kind:e.literal("updated"),thread_id:e.string().min(1),actor_user_id:e.string().min(1),version:e.number(),comment:je}),e.object({kind:e.literal("deleted"),thread_id:e.string().min(1),actor_user_id:e.string().min(1),version:e.number(),comment:je})]),uo=e.enum(["pending","generating","ready","failed"]),ho=e.enum(["pending","generating","ready","failed"]),fo=e.enum(["pending","placeholder","ai","user"]),Tr=e.enum(["pending","generating","ready","failed"]),yo=e.enum(["asked","requested","decided","corrected","shared"]),go=e.object({id:e.string().min(1),kind:yo,summary:e.string().min(1),block_id:e.string().min(1)}),bo=e.object({type:e.literal("list"),list_type:e.literal("thread_decision"),status:Tr,generated_at:e.string().nullable(),objects:e.array(go)}),Ee=e.object({id:e.string().min(1),thread_file_id:e.string().min(1),organization_id:e.string().min(1),author:Rt,repo:e.string().min(1),title:e.string().min(1),started_at:e.string().min(1),blocks:jr,user_message_count:e.number().int().nonnegative(),files_touched:e.array(e.string()),skills_invoked:e.array(e.string()),harness:ae,transcript_parsing_state:e.enum(["pending","parsed","too_large_to_parse"]),visibility:e.enum(["private","workspace","public"]),has_plan:e.boolean().optional(),summary:e.string().nullable(),summary_status:uo,summary_generated_at:e.string().nullable(),title_status:ho,title_generated_at:e.string().nullable(),title_source:fo,decisions_status:Tr,decisions_generated_at:e.string().nullable(),score:e.number().int(),up_count:e.number().int().nonnegative(),down_count:e.number().int().nonnegative(),viewer_vote:kr,comment_count:e.number().int().nonnegative(),is_favorited:e.boolean()}),_o=e.object({storage_url:e.string().min(1)}),vo=e.object({storage_url:e.string(),harness:ae,thread:Ee.nullable()}),xo=e.object({status:e.literal("complete"),thread_files:e.array(vo)}),So=e.object({id:e.string(),presigned_url:e.string().nullable(),presigned_url_expires_at:e.string().nullable(),storage_url:e.string(),harness:ae,expected_md5:e.string(),error:e.string().nullable(),thread:Ee.nullable()}),jo=e.object({id:e.string(),substrate:e.enum(["s3","filesystem"]),status:e.enum(["incomplete","locked_for_parsing","complete","error"]),thread_files:e.array(So)}),ko=e.object({visibility:e.enum(["private","workspace","public"]).optional(),title:e.string().trim().min(1).max(200).optional()}).refine(r=>r.visibility!==void 0||r.title!==void 0,{message:"At least one of visibility or title must be provided"}),To=e.discriminatedUnion("visibility",[e.object({visibility:e.literal("private")}),e.object({visibility:e.literal("workspace")}),e.object({visibility:e.literal("public"),title:e.string().min(1),author_display_name:e.string().min(1),first_user_message:e.string().nullable(),summary:e.string().nullable(),started_at:e.string().min(1),harness:ae})]),Ro=Ee,pr=e.object({type:e.literal("list"),list_type:e.literal("thread"),has_more:e.boolean(),objects:e.array(Ro)}),wo=e.enum(["recent","popular"]),Co=Ee,zo=e.object({type:e.literal("list"),list_type:e.literal("discover_thread"),has_more:e.boolean(),objects:e.array(Co)}),Po=e.object({before:e.string().min(1).optional(),after:e.string().min(1).optional(),sort:wo.optional(),harness:ae.optional(),search:e.string().max(200).optional()}),Oo=e.object({thread_count:e.number().int().nonnegative(),author_count:e.number().int().nonnegative(),organization_count:e.number().int().nonnegative(),harness_breakdown:e.record(ae,e.number().int().nonnegative())}),Ao=e.object({id:e.string(),status:e.enum(["incomplete","locked_for_parsing","complete","error"]),created_at:e.string(),thread_count:e.number().int().nonnegative()}),Eo=e.object({type:e.literal("list"),list_type:e.literal("upload_session"),objects:e.array(Ao)}),Io=e.object({before:e.string().min(1).optional(),after:e.string().min(1).optional()}),Lo=e.object({before:e.string().min(1).optional(),after:e.string().min(1).optional(),author_ids:e.string().min(1).optional(),created_at:e.string().min(1).optional(),filepath_prefixes:e.string().min(1).optional()}),No=e.object({path:e.string().min(1),start_offset:e.number().int().nonnegative(),end_offset:e.number().int().positive()}),Bo=e.object({name:e.string(),usage_count:e.number().int().nonnegative(),author_count:e.number().int().nonnegative(),first_used_at:e.string().nullable(),last_used_at:e.string().nullable(),usage_count_last_24h:e.number().int().nonnegative(),usage_count_last_7d:e.number().int().nonnegative()}),qo=e.object({type:e.literal("list"),list_type:e.literal("skill"),objects:e.array(Bo)}),Uo=e.object({id:e.string(),title:e.string(),visibility:e.enum(["private","workspace","public"]),started_at:e.string(),author:Rt,skills_invoked:e.array(e.string())}),$o=e.object({name:e.string(),usage_count:e.number().int().nonnegative(),author_count:e.number().int().nonnegative(),first_used_at:e.string().nullable(),last_used_at:e.string().nullable(),threads:e.array(Uo)}),Do=e.object({path:e.string().min(1),text:e.string().max(64e3)}),Mo=e.enum(["text_edit","redact","delete_block"]),Vo=e.object({id:e.string(),thread_block_id:e.string(),editor:e.object({id:e.string(),display_name:e.string()}),kind:Mo,path:e.string().nullable(),previous_text:e.string().nullable(),new_text:e.string().nullable(),created_at:e.string()}),Zo=e.object({type:e.literal("list"),list_type:e.literal("thread_block_edit"),objects:e.array(Vo)}),Fo=e.object({organization_count:e.number().int().nonnegative(),user_count:e.number().int().nonnegative(),thread_count:e.number().int().nonnegative(),thread_count_last_24h:e.number().int().nonnegative(),user_count_last_24h:e.number().int().nonnegative()}),Go=e.object({id:e.string(),name:e.string(),email_domains:e.array(e.string()),stytch_org_id:e.string(),member_count:e.number().int().nonnegative(),thread_count:e.number().int().nonnegative(),default_thread_visibility:e.enum(["private","workspace","public"]),created_at:e.string()}),Ho=e.object({type:e.literal("list"),list_type:e.literal("admin_organization"),objects:e.array(Go)}),Rr=e.object({id:e.string(),name:e.string()}),Qo=e.object({id:e.string(),display_name:e.string(),stytch_id:e.string().nullable(),thread_count:e.number().int().nonnegative(),onboarded_at:e.string().nullable(),created_at:e.string(),organizations:e.array(Rr)}),Wo=e.object({type:e.literal("list"),list_type:e.literal("admin_user"),objects:e.array(Qo)}),Ko=e.object({id:e.string(),title:e.string(),started_at:e.string(),created_at:e.string(),deleted_at:e.string().nullable(),visibility:e.enum(["private","workspace","public"]),harness:ae,author:Rt,organization:Rr}),Jo=e.object({type:e.literal("list"),list_type:e.literal("admin_thread"),has_more:e.boolean(),objects:e.array(Ko)}),Yo=e.object({before:e.string().min(1).optional(),after:e.string().min(1).optional()}),mr=e.object({token:e.string().min(1),thread_id:e.string().min(1)}),Xo=e.object({visitor:e.string().min(1).max(64).optional()}),ei=e.object({user_id:e.string(),display_name:e.string(),shares_sent:e.number().int().nonnegative(),unique_viewers:e.number().int().nonnegative(),attributed_signups:e.number().int().nonnegative()}),ti=e.object({window_days:e.number().int().positive(),shares_sent:e.number().int().nonnegative(),unique_viewers:e.number().int().nonnegative(),attributed_signups:e.number().int().nonnegative(),active_sharers:e.number().int().nonnegative(),k_factor:e.number().nullable(),shares_sent_sparkline:e.array(e.number().int().nonnegative()),top_sharers:e.array(ei)}),ri=e.object({windows:e.array(ti)}),ni=e.object({quoted_text:e.string().min(1),comment:e.string().nullable(),type:e.enum(["comment","highlight:trapdoor"])}),ai=Sr,si=xr.extend({comment_thread_id:e.string().min(1)}),oi=e.object({markdown:e.string().min(1)}),ii=e.object({storage_url:e.string().min(1),thread_file_id:e.string().min(1),parsed_plan_block:dr,critiqued_plan_block:dr,annotations:e.array(ni),comment_threads:e.array(ai),comments:e.array(si)}),Ie=e.enum(_t),wr=e.object({skills:e.boolean(),workspace_scope:e.boolean(),review:e.boolean(),shared_thread_ttl_days:e.number().int().positive().nullable()}),Tt=e.object({subject_type:e.enum(["user","organization"]),subject_id:e.string().min(1),effective_plan:Ie,admin_override:Ie.nullable(),stripe_subscription_status:e.string().nullable(),cancel_at_period_end:e.boolean(),current_period_end:e.string().nullable(),seat_quantity:e.number().int().positive(),member_count:e.number().int().nonnegative().nullable(),features:wr}),ci=e.object({effective_plan:Ie,features:wr,user:Tt,organization:Tt.nullable()}),di=e.object({plan:e.enum(["creator","team"]),seat_quantity:e.number().int().positive().optional()}),li=e.object({checkout_url:e.string().min(1)}),pi=e.object({portal_url:e.string().min(1)}),mi=e.object({seat_quantity:e.number().int().positive()}),ur=e.object({plan:Ie.nullable()}),nt=e.object({subject_type:e.enum(["user","organization"]),subject_id:e.string().min(1),label:e.string().min(1),effective_plan:Ie,admin_override:Ie.nullable(),stripe_subscription_status:e.string().nullable(),seat_quantity:e.number().int().positive()}),ui=e.object({users:e.array(nt),organizations:e.array(nt)}),hi=e.object({id:e.string().min(1),display_name:e.string().min(1),handle:e.string().nullable(),avatar_url:e.string().nullable()}),fi=e.object({thread_id:e.string().min(1),title:e.string().min(1),author:hi,last_active_at:e.string().datetime(),last_block_excerpt:e.string().nullable(),last_block_kind:e.string().min(1).nullable(),is_streaming:e.boolean()}),yi=e.object({type:e.literal("list"),list_type:e.literal("live_thread"),objects:e.array(fi)}),gi=e.object({thread_id:e.string().min(1)}),bi=e.object({thread_id:e.string().min(1),last_seen_at:e.string().datetime(),started_at:e.string().datetime()}),_i=e.object({follower_id:e.string().min(1),followee_id:e.string().min(1),is_following:e.literal(!0),follower_count:e.number().int().nonnegative()}),vi=e.object({follower_id:e.string().min(1),followee_id:e.string().min(1),is_following:e.literal(!1),follower_count:e.number().int().nonnegative()}),Cr=e.object({id:e.string().min(1),display_name:e.string().min(1),handle:e.string().nullable(),avatar_url:e.string().nullable(),bio:e.string().max(280).nullable(),is_following:e.boolean(),is_self:e.boolean()}),hr=e.object({type:e.literal("list"),list_type:e.literal("user_follow"),objects:e.array(Cr)}),xi=e.object({date:e.string().regex(/^\d{4}-\d{2}-\d{2}$/),count:e.number().int().nonnegative()}),Si=e.object({window_start:e.string().datetime(),window_end:e.string().datetime(),total_contributions:e.number().int().nonnegative(),days_active:e.number().int().nonnegative(),daily_average:e.number().nonnegative(),current_streak_days:e.number().int().nonnegative(),days:e.array(xi)}),ji=e.object({type:e.literal("thread_created"),occurred_at:e.string().datetime(),id:e.string().min(1),thread:e.object({id:e.string().min(1),title:e.string(),visibility:e.enum(["private","workspace","public"])})}),ki=e.object({type:e.literal("comment_posted"),occurred_at:e.string().datetime(),id:e.string().min(1),comment_excerpt:e.string(),thread:e.object({id:e.string().min(1),title:e.string(),visibility:e.enum(["private","workspace","public"])})}),Ti=e.object({type:e.literal("project_published"),occurred_at:e.string().datetime(),id:e.string().min(1),project:e.object({id:e.string().min(1),name:e.string().min(1)})}),Ri=e.object({type:e.literal("user_followed"),occurred_at:e.string().datetime(),id:e.string().min(1),followee:Cr}),wi=e.discriminatedUnion("type",[ji,ki,Ti,Ri]),Ci=e.object({type:e.literal("list"),list_type:e.literal("user_activity"),objects:e.array(wi)}),zi=e.object({id:e.string().min(1),name:e.string().min(1),excerpt:e.string(),published_at:e.string().datetime(),updated_at:e.string().datetime()}),Pi=e.object({type:e.literal("list"),list_type:e.literal("profile_published_project"),objects:e.array(zi)}),fr=e.object({id:e.string().min(1),published_at:e.string().datetime().nullable()}),Oi=e.enum(["avatar","banner"]),Ai=e.enum(["image/png","image/jpeg","image/webp","image/gif"]),Ei=e.object({kind:Oi,content_type:Ai,base64_data:e.string().min(1)}),Ii=e.object({substrate:e.enum(["s3","filesystem"]),storage_url:e.string().min(1)}),Li=gr,zr=ds.router({health:{method:"GET",path:"/health",responses:{200:e.object({status:e.literal("ok")})},summary:"Health check"},whoAmI:{method:"GET",path:"/whoami",headers:e.object({authorization:e.string().min(1).optional(),"x-lore-referral-token":e.string().min(1).max(16).optional()}),responses:{200:us,401:d},summary:"Validate a Stytch B2B Bearer token and return member plus user fields"},recordHeartbeat:{method:"POST",path:"/heartbeat",headers:e.object({authorization:e.string().min(1).optional()}),body:gi,responses:{200:bi,401:d,403:d,404:d,422:d},summary:"Record (or refresh) a presence heartbeat for the authenticated user against one of their own threads. Idempotent; the daemon should call this every ~30s while a session is open."},listLiveThreads:{method:"GET",path:"/threads/live",headers:e.object({authorization:e.string().min(1).optional()}),responses:{200:yi,401:d,403:d},summary:"List teammates with activity in the last 5 minutes. Excludes the requester. Org-scoped, deduped per author, max 10."},listThreads:{method:"GET",path:"/threads",headers:e.object({authorization:e.string().min(1).optional()}),query:Lo,responses:{200:pr,401:d},summary:"List threads visible to the authenticated user"},getThread:{method:"GET",path:"/threads/:id",pathParams:e.object({id:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),responses:{200:Ee,404:d},summary:"Load a visible thread by id"},getSimilarThreads:{method:"GET",path:"/threads/:id/similar",pathParams:e.object({id:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),responses:{200:pr,404:d,409:d},summary:"List the top 20 visible threads with the closest summary embedding"},listThreadBlocks:{method:"GET",path:"/threads/:id/blocks",pathParams:e.object({id:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),query:Io,responses:{200:jr,401:d},summary:"List blocks for a visible thread"},createThreadBlockCommentThread:{method:"POST",path:"/threads/:threadId/blocks/:blockId/comment-threads",pathParams:e.object({threadId:e.string().min(1),blockId:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),body:As,responses:{201:Es,401:d,404:d},summary:"Create a new block-level comment thread on a visible thread block"},createThreadBlockComment:{method:"POST",path:"/threads/:threadId/blocks/:blockId/comment-threads/:commentThreadId/comments",pathParams:e.object({threadId:e.string().min(1),blockId:e.string().min(1),commentThreadId:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),body:Ns,responses:{201:Bs,401:d,404:d,409:d},summary:"Reply to a block-level comment thread on a visible thread block"},updateThreadBlockCommentThread:{method:"PATCH",path:"/threads/:threadId/blocks/:blockId/comment-threads/:commentThreadId",pathParams:e.object({threadId:e.string().min(1),blockId:e.string().min(1),commentThreadId:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),body:$s,responses:{200:Ds,401:d,404:d},summary:"Resolve or reopen a block-level comment thread on a visible thread block"},listSkills:{method:"GET",path:"/skills",headers:e.object({authorization:e.string().min(1).optional()}),responses:{200:qo,401:d},summary:"Aggregate skill usage across threads the viewer can see"},getSkillDetail:{method:"GET",path:"/skills/:name",pathParams:e.object({name:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),responses:{200:$o,401:d,404:d},summary:"Per-skill detail: usage stats + visible threads that invoked it"},redactThreadBlock:{method:"POST",path:"/threads/:threadId/blocks/:blockId/redactions",pathParams:e.object({threadId:e.string().min(1),blockId:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),body:No,responses:{200:$e,401:d,403:d,404:d,422:d},summary:"Permanently redact a character range within a text field of a thread block (author only)"},updateThreadBlockText:{method:"PATCH",path:"/threads/:threadId/blocks/:blockId/text",pathParams:e.object({threadId:e.string().min(1),blockId:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),body:Do,responses:{200:$e,401:d,403:d,404:d,422:d},summary:"Replace a single text leaf in a thread block with new content (author only)"},critiqueThreadBlock:{method:"POST",path:"/threads/:threadId/blocks/:blockId/critique",pathParams:e.object({threadId:e.string().min(1),blockId:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),body:e.object({}).optional(),responses:{200:$e,401:d,403:d,404:d,409:d,422:d},summary:"Critique a plan block once and persist its annotations as nested comment threads (author only)"},deleteThreadBlock:{method:"DELETE",path:"/threads/:threadId/blocks/:blockId",pathParams:e.object({threadId:e.string().min(1),blockId:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),body:e.object({}).optional(),responses:{204:e.null(),401:d,403:d,404:d},summary:"Soft-delete a thread block (author only)"},listThreadBlockEdits:{method:"GET",path:"/threads/:threadId/blocks/:blockId/edits",pathParams:e.object({threadId:e.string().min(1),blockId:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),responses:{200:Zo,401:d,404:d},summary:"List edits made to a thread block (visible to anyone who can see the thread)"},listThreadDecisions:{method:"GET",path:"/threads/:id/decisions",pathParams:e.object({id:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),responses:{200:bo,401:d,404:d},summary:"List AI-extracted user decisions for a thread, in chronological order"},updateThread:{method:"PATCH",path:"/threads/:id",pathParams:e.object({id:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),body:ko,responses:{200:Ee,401:d,403:d,404:d},summary:"Update thread visibility (author only)"},deleteThread:{method:"DELETE",path:"/threads/:id",pathParams:e.object({id:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),body:e.object({}).optional(),responses:{204:e.null(),401:d,403:d,404:d},summary:"Soft-delete a thread (author only)"},castThreadVote:{method:"PUT",path:"/threads/:id/vote",pathParams:e.object({id:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),body:ao,responses:{200:lr,401:d,403:d,404:d,422:d},summary:"Cast or change the caller's up/down vote on a public thread. Idempotent \u2014 re-casting the same value is a no-op."},clearThreadVote:{method:"DELETE",path:"/threads/:id/vote",pathParams:e.object({id:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),body:e.object({}).optional(),responses:{200:lr,401:d,404:d},summary:"Clear the caller's vote on a thread. No-op when the caller hasn't voted."},listThreadComments:{method:"GET",path:"/threads/:threadId/comments",pathParams:e.object({threadId:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),responses:{200:oo,403:d,404:d},summary:"List all (live + soft-deleted as tombstones) comments on a public thread, flat with parent_comment_id pointers."},createThreadComment:{method:"POST",path:"/threads/:threadId/comments",pathParams:e.object({threadId:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),body:io,responses:{201:co,401:d,403:d,404:d,422:d},summary:"Post a top-level or reply comment on a public thread."},updateThreadComment:{method:"PATCH",path:"/threads/:threadId/comments/:commentId",pathParams:e.object({threadId:e.string().min(1),commentId:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),body:lo,responses:{200:po,401:d,403:d,404:d,422:d},summary:"Edit your own thread comment (author only; rejects edits to soft-deleted rows)."},deleteThreadComment:{method:"DELETE",path:"/threads/:threadId/comments/:commentId",pathParams:e.object({threadId:e.string().min(1),commentId:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),body:e.object({}).optional(),responses:{200:mo,401:d,403:d,404:d},summary:"Soft-delete your own thread comment (author only). Idempotent."},getThreadPreview:{method:"GET",path:"/threads/:id/preview",pathParams:e.object({id:e.string().min(1)}),responses:{200:To,404:d},summary:"Unauthenticated, visibility-redacted metadata for OG / social preview consumers"},createUser:{method:"POST",path:"/users",headers:e.object({authorization:e.string().min(1).optional()}),body:js,responses:{201:kt,401:d},summary:"Create a user record with ApiKey authentication"},getUser:{method:"GET",path:"/users/:id",pathParams:e.object({id:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),responses:{200:gr,404:d},summary:"Public profile for a user. Optional auth \u2014 unauthenticated viewers see only public thread metadata; signed-in viewers see counts scoped to the threads they'd normally be able to access."},updateCurrentUser:{method:"PATCH",path:"/users/me",headers:e.object({authorization:e.string().min(1).optional()}),body:hs,responses:{200:kt,401:d,409:d,422:d},summary:"Update the authenticated user profile"},getUserByHandle:{method:"GET",path:"/users/by-handle/:handle",pathParams:e.object({handle:yr}),headers:e.object({authorization:e.string().min(1).optional()}),responses:{200:Li,404:d},summary:"Resolve a public profile by handle \u2014 same shape as GET /users/:id but keyed on the user's chosen handle."},listUserActivity:{method:"GET",path:"/users/:id/activity",pathParams:e.object({id:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),query:e.object({limit:e.coerce.number().int().positive().max(100).optional()}),responses:{200:Ci,404:d},summary:"Reverse-chronological activity feed for a user, scoped to what the viewer can see (same visibility rules as listThreads)."},getUserContributions:{method:"GET",path:"/users/:id/contributions",pathParams:e.object({id:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),responses:{200:Si,404:d},summary:"Daily contribution counts for the trailing 365 days \u2014 counts thread blocks the user authored on threads visible to the viewer."},listUserFollowers:{method:"GET",path:"/users/:id/followers",pathParams:e.object({id:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),responses:{200:hr,404:d},summary:"List the users following a given user."},listUserFollowing:{method:"GET",path:"/users/:id/following",pathParams:e.object({id:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),responses:{200:hr,404:d},summary:"List the users a given user is following."},followUser:{method:"POST",path:"/users/:id/follow",pathParams:e.object({id:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),body:e.object({}).optional(),responses:{200:_i,401:d,404:d,409:d,422:d},summary:"Follow another user. Idempotent \u2014 repeating the call is a no-op."},unfollowUser:{method:"DELETE",path:"/users/:id/follow",pathParams:e.object({id:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),body:e.object({}).optional(),responses:{200:vi,401:d,404:d},summary:"Unfollow a user. Idempotent \u2014 repeating the call is a no-op."},listProfilePublishedProjects:{method:"GET",path:"/users/:id/projects",pathParams:e.object({id:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),responses:{200:Pi,404:d},summary:"Projects the user has published to their public profile."},publishProject:{method:"POST",path:"/projects/:id/publish",pathParams:e.object({id:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),body:e.object({}).optional(),responses:{200:fr,401:d,403:d,404:d},summary:"Publish a project to the author's public profile. Stamps published_at with `now()`. Author-only."},unpublishProject:{method:"DELETE",path:"/projects/:id/publish",pathParams:e.object({id:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),body:e.object({}).optional(),responses:{200:fr,401:d,403:d,404:d},summary:"Remove a project from the author's public profile."},uploadProfileImage:{method:"POST",path:"/users/me/profile-image",headers:e.object({authorization:e.string().min(1).optional()}),body:Ei,responses:{200:Ii,401:d,413:d,422:d},summary:"Upload an avatar or banner image (base64-encoded JSON body). The API streams the bytes to its configured storage substrate using its own credentials and returns the canonical storage URL the client passes to PATCH /users/me."},listOrganizationMembers:{method:"GET",path:"/organization/members",headers:e.object({authorization:e.string().min(1).optional()}),responses:{200:ys,401:d},summary:"List members of the authenticated user\u2019s organization"},createOrganizationInvite:{method:"POST",path:"/organization/invites",headers:e.object({authorization:e.string().min(1).optional()}),body:gs,responses:{201:bs,401:d,403:d,409:d,422:d},summary:"Invite a teammate to the authenticated user\u2019s workspace via Stytch B2B"},listRepositories:{method:"GET",path:"/repositories",headers:e.object({authorization:e.string().min(1).optional()}),responses:{200:Js,401:d,403:d},summary:"List repositories known to the authenticated user\u2019s organization across threads and building blocks"},createBuildingBlockSnapshots:{method:"POST",path:"/building_blocks",headers:e.object({authorization:e.string().min(1).optional()}),body:Ts,responses:{201:Gs,401:d,403:d},summary:"Create building block snapshots for the authenticated user\u2019s organization"},getPlan:{method:"GET",path:"/plans/:id",pathParams:e.object({id:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),responses:{200:Vs,401:d,403:d,404:d},summary:"Load a thread-backed plan container visible to the authenticated user, including all visible plan revisions in that thread"},createPlanCommentThread:{method:"POST",path:"/plans/:id/comment-threads",pathParams:e.object({id:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),body:Ps,responses:{201:Os,401:d,403:d,404:d,422:d},summary:"Create a new inline comment thread on a specific revision inside a thread-backed plan container"},createPlanComment:{method:"POST",path:"/plans/:id/comment-threads/:threadId/comments",pathParams:e.object({id:e.string().min(1),threadId:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),body:Is,responses:{201:Ls,401:d,403:d,404:d,409:d},summary:"Reply to an inline comment thread on a thread-backed plan container"},updatePlanCommentThread:{method:"PATCH",path:"/plans/:id/comment-threads/:threadId",pathParams:e.object({id:e.string().min(1),threadId:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),body:qs,responses:{200:Us,401:d,403:d,404:d},summary:"Resolve or reopen an inline comment thread on a thread-backed plan container"},listPlans:{method:"GET",path:"/plans",headers:e.object({authorization:e.string().min(1).optional()}),query:Fs,responses:{200:Zs,401:d,403:d},summary:"List thread-backed plan containers visible to the authenticated user in their organization, ordered by latest visible revision and optionally filtered by author or repository"},listBuildingBlockSnapshots:{method:"GET",path:"/building_blocks",headers:e.object({authorization:e.string().min(1).optional()}),query:Qs,responses:{200:Hs,401:d,403:d},summary:"List building block snapshots for the authenticated user\u2019s organization and repo origin path"},listUploadSessions:{method:"GET",path:"/upload_sessions",headers:e.object({authorization:e.string().min(1).optional()}),responses:{200:Eo,401:d},summary:"List recent upload sessions for the authenticated user"},createUploadSession:{method:"POST",path:"/upload_sessions",headers:e.object({authorization:e.string().min(1).optional()}),body:e.object({thread_files:e.array(eo).nonempty()}),responses:{201:jo,400:d,401:d},summary:"Create an upload session with presigned URLs for file uploads"},completeUploadSession:{method:"POST",path:"/upload_sessions/:id/complete",pathParams:e.object({id:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),body:e.object({thread_files:e.array(_o).nonempty()}),responses:{200:xo,400:d,401:d,404:d,409:d,422:d},summary:"Complete an upload session after files have been uploaded to storage"},adminStats:{method:"GET",path:"/admin/stats",headers:e.object({authorization:e.string().min(1).optional()}),responses:{200:Fo,401:d,403:d},summary:"Cross-org operational counts. Tanagram admins only."},adminListOrganizations:{method:"GET",path:"/admin/organizations",headers:e.object({authorization:e.string().min(1).optional()}),responses:{200:Ho,401:d,403:d},summary:"List every organization with member and thread counts. Tanagram admins only."},adminListUsers:{method:"GET",path:"/admin/users",headers:e.object({authorization:e.string().min(1).optional()}),responses:{200:Wo,401:d,403:d},summary:"List every user with their org memberships and thread count. Tanagram admins only."},adminListThreads:{method:"GET",path:"/admin/threads",headers:e.object({authorization:e.string().min(1).optional()}),query:Yo,responses:{200:Jo,401:d,403:d},summary:"List live threads across every organization. Tanagram admins only."},adminHardDeleteThread:{method:"DELETE",path:"/admin/threads/:id",pathParams:e.object({id:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),body:e.object({}).optional(),responses:{204:e.null(),401:d,403:d,404:d},summary:"Permanently remove a thread. Tanagram admins only."},listDiscoverThreads:{method:"GET",path:"/discover/threads",headers:e.object({authorization:e.string().min(1).optional()}),query:Po,responses:{200:zo},summary:"Feed of public threads with sort, harness filter, search, and cursor pagination. Auth is optional and populates viewer_vote."},discoverStats:{method:"GET",path:"/discover/stats",responses:{200:Oo},summary:"Unauthenticated rollup of public-thread counts for the Discover header."},createWaitlistEntry:{method:"POST",path:"/waitlist_entries",body:_s,responses:{201:vs,409:d},summary:"Create an unauthenticated waitlist entry keyed by (location, contact)."},createShareToken:{method:"POST",path:"/threads/:id/share-token",pathParams:e.object({id:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),body:e.object({}).optional(),responses:{201:mr,401:d,403:d,404:d,409:d},summary:"Mint a short share-link token for a public thread. Author only. The token powers `/s/:token` short URLs and enables k-factor attribution."},resolveShareToken:{method:"GET",path:"/referrals/resolve/:token",pathParams:e.object({token:e.string().min(1).max(16)}),query:Xo,responses:{200:mr,404:d},summary:"Resolve a share-link token to its thread and record the view. Unauthenticated by design."},adminGrowth:{method:"GET",path:"/admin/growth",headers:e.object({authorization:e.string().min(1).optional()}),responses:{200:ri,401:d,403:d},summary:"Share-link k-factor, funnel, sparkline, and top sharers by window. Tanagram admins only."},adminRunCritiquePlayground:{method:"POST",path:"/admin/critique-playground/run",headers:e.object({authorization:e.string().min(1).optional()}),body:oi,responses:{200:ii,401:d,403:d,409:d},summary:"Admin-only critique playground that saves markdown to a file:// plan artifact and returns parsed + critiqued plan blocks."},getBillingState:{method:"GET",path:"/billing/state",headers:e.object({authorization:e.string().min(1).optional()}),responses:{200:ci,401:d},summary:"Resolve the caller's plan, features, seat count, and any admin override."},createBillingCheckout:{method:"POST",path:"/billing/checkout",headers:e.object({authorization:e.string().min(1).optional()}),body:di,responses:{200:li,400:d,401:d,403:d,503:d},summary:"Start a Stripe Checkout session for Creator ($29/mo) or Team ($19/seat/mo, min 2)."},createBillingPortal:{method:"POST",path:"/billing/portal",headers:e.object({authorization:e.string().min(1).optional()}),body:e.object({subject_type:e.enum(["user","organization"]).default("user")}).optional(),responses:{200:pi,401:d,404:d,503:d},summary:"Open the Stripe customer portal so the subject can manage their subscription."},updateTeamSeats:{method:"PATCH",path:"/billing/team-seats",headers:e.object({authorization:e.string().min(1).optional()}),body:mi,responses:{200:Tt,400:d,401:d,403:d,404:d,503:d},summary:"Adjust the caller-organization's Team seat quantity (admin of that org only)."},adminListBilling:{method:"GET",path:"/admin/billing",headers:e.object({authorization:e.string().min(1).optional()}),responses:{200:ui,401:d,403:d},summary:"List every user and org with current plan + override for the admin panel."},adminSetUserPlanOverride:{method:"PUT",path:"/admin/billing/users/:id/override",pathParams:e.object({id:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),body:ur,responses:{200:nt,401:d,403:d,404:d},summary:"Admin override for a user's plan tier. Null clears the override."},adminSetOrganizationPlanOverride:{method:"PUT",path:"/admin/billing/organizations/:id/override",pathParams:e.object({id:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),body:ur,responses:{200:nt,401:d,403:d,404:d},summary:"Admin override for an organization's plan tier. Null clears the override."},projects:sr,docs:nr,mentions:or,favorites:cr},{pathPrefix:"/api"});var Ni={dev:"http://localhost:4000",prod:"https://lore.tanagram.ai"};function Pr(){return bt(zr,{baseUrl:Ni[ke()],baseHeaders:{}})}var Or={meta:{name:"health",description:"Check API health"},async run({data:r}){se.info("command_start",{command:"health"});let n=await(r?.client??Pr()).health();if(n.status===200){console.log(n.body.status);return}throw se.error("health_failed",{status:n.status}),console.error(`health check failed: HTTP ${n.status}`),new Error(`health check failed: HTTP ${n.status}`)}};var Ar={meta:{name:"logs",description:"Print the path to the log file"},run(){se.info("command_start",{command:"logs"}),console.log(Ge())}};var Bi={meta:{name:"lore",description:"Lore CLI"},subCommands:{hello:qt,health:Or,logs:Ar},default:"hello"};import.meta.url===`file://${process.argv[1]}`&&Et(Bi);export{Bi as mainCommand};
|
|
2
|
+
var Mr=Object.defineProperty;var Fr=(r,t)=>{for(var n in t)Mr(r,n,{get:t[n],enumerable:!0})};import{pathToFileURL as Jo}from"node:url";var Vr=/\d/,Zr=["-","_","/","."];function Gr(r=""){if(!Vr.test(r))return r!==r.toLowerCase()}function Pt(r,t){let n=t??Zr,a=[];if(!r||typeof r!="string")return a;let s="",i,c;for(let o of r){let d=n.includes(o);if(d===!0){a.push(s),s="",i=void 0;continue}let p=Gr(o);if(c===!1){if(i===!1&&p===!0){a.push(s),s=o,i=p;continue}if(i===!0&&p===!1&&s.length>1){let u=s.at(-1);a.push(s.slice(0,Math.max(0,s.length-1))),s=u+o,i=p;continue}}s+=o,i=p,c=d}return a.push(s),a}function Hr(r){return r?r[0].toUpperCase()+r.slice(1):""}function Qr(r){return r?r[0].toLowerCase()+r.slice(1):""}function Wr(r,t){return r?(Array.isArray(r)?r:Pt(r)).map(n=>Hr(t?.normalize?n.toLowerCase():n)).join(""):""}function Be(r,t){return Qr(Wr(r||"",t))}function Fe(r,t){return r?(Array.isArray(r)?r:Pt(r)).map(n=>n.toLowerCase()).join(t??"-"):""}function Ot(r){return Fe(r||"","_")}import{parseArgs as Kr}from"node:util";function $e(r){return Array.isArray(r)?r:r===void 0?[]:[r]}function ot(r,t=""){let n=[];for(let a of r)for(let[s,i]of a.entries())n[s]=Math.max(n[s]||0,i.length);return r.map(a=>a.map((s,i)=>t+s[i===0?"padStart":"padEnd"](n[i])).join(" ")).join(`
|
|
3
|
+
`)}function A(r){return typeof r=="function"?r():r}var Q=class extends Error{code;constructor(r,t){super(r),this.name="CLIError",this.code=t}};function Jr(r=[],t={}){let n=new Set(t.boolean||[]),a=new Set(t.string||[]),s=t.alias||{},i=t.default||{},c=new Map,o=new Map;for(let[v,j]of Object.entries(s)){let P=j;for(let M of P)c.set(v,M),o.has(M)||o.set(M,[]),o.get(M).push(v),c.set(M,v),o.has(v)||o.set(v,[]),o.get(v).push(M)}let d={};function p(v){if(n.has(v))return"boolean";let j=o.get(v)||[];for(let P of j)if(n.has(P))return"boolean";return"string"}function u(v){if(a.has(v))return!0;let j=o.get(v)||[];for(let P of j)if(a.has(P))return!0;return!1}let T=new Set([...n,...a,...Object.keys(s),...Object.values(s).flat(),...Object.keys(i)]);for(let v of T)d[v]||(d[v]={type:p(v),default:i[v]});for(let[v,j]of c.entries())v.length===1&&d[j]&&!d[j].short&&(d[j].short=v);let R=[],_={};for(let v=0;v<r.length;v++){let j=r[v];if(j==="--"){R.push(...r.slice(v));break}if(j.startsWith("--no-")){let P=j.slice(5);_[P]=!0;continue}R.push(j)}let z;try{z=Kr({args:R,options:Object.keys(d).length>0?d:void 0,allowPositionals:!0,strict:!1})}catch{z={values:{},positionals:R}}let w={_:[]};w._=z.positionals;for(let[v,j]of Object.entries(z.values)){let P=j;p(v)==="boolean"&&typeof j=="string"?P=j!=="false":u(v)&&typeof j=="boolean"&&(P=""),w[v]=P}for(let[v]of Object.entries(_)){w[v]=!1;let j=c.get(v);j&&(w[j]=!1);let P=o.get(v);if(P)for(let M of P)w[M]=!1}for(let[v,j]of c.entries())w[v]!==void 0&&w[j]===void 0&&(w[j]=w[v]),w[j]!==void 0&&w[v]===void 0&&(w[v]=w[j]),w[v]!==w[j]&&i[j]===w[j]&&(w[j]=w[v]);return w}var Yr=(()=>{let r=globalThis.process?.env??{};return r.NO_COLOR==="1"||r.TERM==="dumb"||r.TEST||r.CI})(),He=(r,t=39)=>n=>Yr?n:`\x1B[${r}m${n}\x1B[${t}m`,Ve=He(1,22),q=He(36),Ge=He(90),Ze=He(4,24);function Xr(r,t){let n={boolean:[],string:[],alias:{},default:{}},a=It(t);for(let o of a){if(o.type==="positional")continue;o.type==="string"||o.type==="enum"?n.string.push(o.name):o.type==="boolean"&&n.boolean.push(o.name),o.default!==void 0&&(n.default[o.name]=o.default),o.alias&&(n.alias[o.name]=o.alias);let d=Be(o.name),p=Fe(o.name);if(d!==o.name||p!==o.name){let u=$e(n.alias[o.name]||[]);d!==o.name&&!u.includes(d)&&u.push(d),p!==o.name&&!u.includes(p)&&u.push(p),u.length>0&&(n.alias[o.name]=u)}}let s=Jr(r,n),[...i]=s._,c=new Proxy(s,{get(o,d){return o[d]??o[Be(d)]??o[Fe(d)]}});for(let[,o]of a.entries())if(o.type==="positional"){let d=i.shift();if(d!==void 0)c[o.name]=d;else{if(o.default===void 0&&o.required!==!1)throw new Q(`Missing required positional argument: ${o.name.toUpperCase()}`,"EARG");c[o.name]=o.default}}else if(o.type==="enum"){let d=c[o.name],p=o.options||[];if(d!==void 0&&p.length>0&&!p.includes(d))throw new Q(`Invalid value for argument: ${q(`--${o.name}`)} (${q(d)}). Expected one of: ${p.map(u=>q(u)).join(", ")}.`,"EARG")}else if(o.required&&c[o.name]===void 0)throw new Q(`Missing required argument: --${o.name}`,"EARG");return c}function It(r){let t=[];for(let[n,a]of Object.entries(r||{}))t.push({...a,name:n,alias:$e(a.alias)});return t}async function en(r){return Promise.all(r.map(t=>A(t)))}async function lt(r,t){let n=await A(r.args||{}),a=Xr(t.rawArgs,n),s={rawArgs:t.rawArgs,args:a,data:t.data,cmd:r},i=await en(r.plugins??[]),c,o;try{for(let u of i)await u.setup?.(s);typeof r.setup=="function"&&await r.setup(s);let p=await A(r.subCommands);if(p&&Object.keys(p).length>0){let u=Lt(t.rawArgs,n),T=t.rawArgs[u];if(T){let R=await pt(p,T);if(!R)throw new Q(`Unknown command ${q(T)}`,"E_UNKNOWN_COMMAND");await lt(R,{rawArgs:t.rawArgs.slice(u+1)})}else{let R=await A(r.default);if(R){if(r.run)throw new Q("Cannot specify both 'run' and 'default' on the same command.","E_DEFAULT_CONFLICT");let _=await pt(p,R);if(!_)throw new Q(`Default sub command ${q(R)} not found in subCommands.`,"E_UNKNOWN_COMMAND");await lt(_,{rawArgs:t.rawArgs})}else if(!r.run)throw new Q("No command specified.","E_NO_COMMAND")}}typeof r.run=="function"&&(c=await r.run(s))}catch(p){o=p}let d=[];if(typeof r.cleanup=="function")try{await r.cleanup(s)}catch(p){d.push(p)}for(let p of[...i].reverse())try{await p.cleanup?.(s)}catch(u){d.push(u)}if(o)throw o;if(d.length===1)throw d[0];if(d.length>1)throw new Error("Multiple cleanup errors",{cause:d});return{result:c}}async function dt(r,t,n){let a=await A(r.subCommands);if(a&&Object.keys(a).length>0){let s=Lt(t,await A(r.args||{})),i=t[s],c=await pt(a,i);if(c)return dt(c,t.slice(s+1),r)}return[r,n]}async function pt(r,t){if(t in r)return A(r[t]);for(let n of Object.values(r)){let a=await A(n),s=await A(a?.meta);if(s?.alias&&$e(s.alias).includes(t))return a}}function Lt(r,t){for(let n=0;n<r.length;n++){let a=r[n];if(a==="--")return-1;if(a.startsWith("-")){!a.includes("=")&&tn(a,t)&&n++;continue}return n}return-1}function tn(r,t){let n=r.replace(/^-{1,2}/,""),a=Be(n);for(let[s,i]of Object.entries(t))if(!(i.type!=="string"&&i.type!=="enum")&&(a===Be(s)||(Array.isArray(i.alias)?i.alias:i.alias?[i.alias]:[]).includes(n)))return!0;return!1}async function rn(r,t){try{console.log(await an(r,t)+`
|
|
4
|
+
`)}catch(n){console.error(n)}}var nn=/^no[-A-Z]/;async function an(r,t){let n=await A(r.meta||{}),a=It(await A(r.args||{})),s=await A(t?.meta||{}),i=`${s.name?`${s.name} `:""}`+(n.name||process.argv[1]),c=[],o=[],d=[],p=[];for(let _ of a)if(_.type==="positional"){let z=_.name.toUpperCase(),w=_.required!==!1&&_.default===void 0;o.push([q(z+ct(_)),At(_,w)]),p.push(w?`<${z}>`:`[${z}]`)}else{let z=_.required===!0&&_.default===void 0,w=[...(_.alias||[]).map(v=>`-${v}`),`--${_.name}`].join(", ")+ct(_);if(c.push([q(w),At(_,z)]),_.type==="boolean"&&(_.default===!0||_.negativeDescription)&&!nn.test(_.name)){let v=[...(_.alias||[]).map(j=>`--no-${j}`),`--no-${_.name}`].join(", ");c.push([q(v),[_.negativeDescription,z?Ge("(Required)"):""].filter(Boolean).join(" ")])}z&&p.push(`--${_.name}`+ct(_))}if(r.subCommands){let _=[],z=await A(r.subCommands);for(let[w,v]of Object.entries(z)){let j=await A((await A(v))?.meta);if(j?.hidden)continue;let P=$e(j?.alias),M=[w,...P].join(", ");d.push([q(M),j?.description||""]),_.push(w,...P)}p.push(_.join("|"))}let u=[],T=n.version||s.version;u.push(Ge(`${n.description} (${i+(T?` v${T}`:"")})`),"");let R=c.length>0||o.length>0;return u.push(`${Ze(Ve("USAGE"))} ${q(`${i}${R?" [OPTIONS]":""} ${p.join(" ")}`)}`,""),o.length>0&&(u.push(Ze(Ve("ARGUMENTS")),""),u.push(ot(o," ")),u.push("")),c.length>0&&(u.push(Ze(Ve("OPTIONS")),""),u.push(ot(c," ")),u.push("")),d.length>0&&(u.push(Ze(Ve("COMMANDS")),""),u.push(ot(d," ")),u.push("",`Use ${q(`${i} <command> --help`)} for more information about a command.`)),u.filter(_=>typeof _=="string").join(`
|
|
5
|
+
`)}function ct(r){let t=r.valueHint?`=<${r.valueHint}>`:"",n=t||`=<${Ot(r.name)}>`;return!r.type||r.type==="positional"||r.type==="boolean"?t:r.type==="enum"&&r.options?.length?`=<${r.options.join("|")}>`:n}function At(r,t){let n=t?Ge("(Required)"):"",a=r.default===void 0?"":Ge(`(Default: ${r.default})`);return[r.description,n,a].filter(Boolean).join(" ")}async function Nt(r,t={}){let n=t.rawArgs||process.argv.slice(2),a=t.showUsage||rn;try{let s=await sn(r);if(s.help.length>0&&n.some(i=>s.help.includes(i)))await a(...await dt(r,n)),process.exit(0);else if(n.length===1&&s.version.includes(n[0])){let i=typeof r.meta=="function"?await r.meta():await r.meta;if(!i?.version)throw new Q("No version specified","E_NO_VERSION");console.log(i.version)}else await lt(r,{rawArgs:n})}catch(s){s instanceof Q?(await a(...await dt(r,n)),console.error(s.message)):console.error(s,`
|
|
6
|
+
`),process.exit(1)}}async function sn(r){let t=await A(r.args||{}),n=new Set,a=new Set;for(let[s,i]of Object.entries(t)){n.add(s);for(let c of $e(i.alias))a.add(c)}return{help:Et("help","h",n,a),version:Et("version","v",n,a)}}function Et(r,t,n,a){return n.has(r)||a.has(r)?[]:n.has(t)||a.has(t)?[`--${r}`]:[`--${r}`,`-${t}`]}var e={};Fr(e,{BRAND:()=>An,DIRTY:()=>oe,EMPTY_PATH:()=>dn,INVALID:()=>g,NEVER:()=>ya,OK:()=>E,ParseStatus:()=>O,Schema:()=>S,ZodAny:()=>re,ZodArray:()=>Y,ZodBigInt:()=>le,ZodBoolean:()=>de,ZodBranded:()=>qe,ZodCatch:()=>xe,ZodDate:()=>pe,ZodDefault:()=>ve,ZodDiscriminatedUnion:()=>Ke,ZodEffects:()=>U,ZodEnum:()=>be,ZodError:()=>L,ZodFirstPartyTypeKind:()=>b,ZodFunction:()=>Ye,ZodIntersection:()=>fe,ZodIssueCode:()=>m,ZodLazy:()=>ye,ZodLiteral:()=>ge,ZodMap:()=>Ae,ZodNaN:()=>Ie,ZodNativeEnum:()=>_e,ZodNever:()=>D,ZodNull:()=>ue,ZodNullable:()=>Z,ZodNumber:()=>ce,ZodObject:()=>N,ZodOptional:()=>B,ZodParsedType:()=>f,ZodPipeline:()=>De,ZodPromise:()=>ne,ZodReadonly:()=>Se,ZodRecord:()=>Je,ZodSchema:()=>S,ZodSet:()=>Ee,ZodString:()=>te,ZodSymbol:()=>Pe,ZodTransformer:()=>U,ZodTuple:()=>V,ZodType:()=>S,ZodUndefined:()=>me,ZodUnion:()=>he,ZodUnknown:()=>J,ZodVoid:()=>Oe,addIssueToContext:()=>h,any:()=>Dn,array:()=>Zn,bigint:()=>Nn,boolean:()=>Ht,coerce:()=>fa,custom:()=>Vt,date:()=>Bn,datetimeRegex:()=>Mt,defaultErrorMap:()=>W,discriminatedUnion:()=>Wn,effect:()=>oa,enum:()=>aa,function:()=>ta,getErrorMap:()=>we,getParsedType:()=>F,instanceof:()=>In,intersection:()=>Kn,isAborted:()=>Qe,isAsync:()=>Ce,isDirty:()=>We,isValid:()=>ee,late:()=>En,lazy:()=>ra,literal:()=>na,makeIssue:()=>Ue,map:()=>Xn,nan:()=>Ln,nativeEnum:()=>sa,never:()=>Fn,null:()=>qn,nullable:()=>la,number:()=>Gt,object:()=>Gn,objectUtil:()=>mt,oboolean:()=>ha,onumber:()=>ua,optional:()=>ca,ostring:()=>ma,pipeline:()=>pa,preprocess:()=>da,promise:()=>ia,quotelessJson:()=>on,record:()=>Yn,set:()=>ea,setErrorMap:()=>ln,strictObject:()=>Hn,string:()=>Zt,symbol:()=>$n,transformer:()=>oa,tuple:()=>Jn,undefined:()=>Un,union:()=>Qn,unknown:()=>Mn,util:()=>k,void:()=>Vn});var k;(function(r){r.assertEqual=s=>{};function t(s){}r.assertIs=t;function n(s){throw new Error}r.assertNever=n,r.arrayToEnum=s=>{let i={};for(let c of s)i[c]=c;return i},r.getValidEnumValues=s=>{let i=r.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),c={};for(let o of i)c[o]=s[o];return r.objectValues(c)},r.objectValues=s=>r.objectKeys(s).map(function(i){return s[i]}),r.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{let i=[];for(let c in s)Object.prototype.hasOwnProperty.call(s,c)&&i.push(c);return i},r.find=(s,i)=>{for(let c of s)if(i(c))return c},r.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function a(s,i=" | "){return s.map(c=>typeof c=="string"?`'${c}'`:c).join(i)}r.joinValues=a,r.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(k||(k={}));var mt;(function(r){r.mergeShapes=(t,n)=>({...t,...n})})(mt||(mt={}));var f=k.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),F=r=>{switch(typeof r){case"undefined":return f.undefined;case"string":return f.string;case"number":return Number.isNaN(r)?f.nan:f.number;case"boolean":return f.boolean;case"function":return f.function;case"bigint":return f.bigint;case"symbol":return f.symbol;case"object":return Array.isArray(r)?f.array:r===null?f.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?f.promise:typeof Map<"u"&&r instanceof Map?f.map:typeof Set<"u"&&r instanceof Set?f.set:typeof Date<"u"&&r instanceof Date?f.date:f.object;default:return f.unknown}};var m=k.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"]),on=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:"),L=class r extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=a=>{this.issues=[...this.issues,a]},this.addIssues=(a=[])=>{this.issues=[...this.issues,...a]};let n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=t}format(t){let n=t||function(i){return i.message},a={_errors:[]},s=i=>{for(let c of i.issues)if(c.code==="invalid_union")c.unionErrors.map(s);else if(c.code==="invalid_return_type")s(c.returnTypeError);else if(c.code==="invalid_arguments")s(c.argumentsError);else if(c.path.length===0)a._errors.push(n(c));else{let o=a,d=0;for(;d<c.path.length;){let p=c.path[d];d===c.path.length-1?(o[p]=o[p]||{_errors:[]},o[p]._errors.push(n(c))):o[p]=o[p]||{_errors:[]},o=o[p],d++}}};return s(this),a}static assert(t){if(!(t instanceof r))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,k.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=n=>n.message){let n={},a=[];for(let s of this.issues)if(s.path.length>0){let i=s.path[0];n[i]=n[i]||[],n[i].push(t(s))}else a.push(t(s));return{formErrors:a,fieldErrors:n}}get formErrors(){return this.flatten()}};L.create=r=>new L(r);var cn=(r,t)=>{let n;switch(r.code){case m.invalid_type:r.received===f.undefined?n="Required":n=`Expected ${r.expected}, received ${r.received}`;break;case m.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(r.expected,k.jsonStringifyReplacer)}`;break;case m.unrecognized_keys:n=`Unrecognized key(s) in object: ${k.joinValues(r.keys,", ")}`;break;case m.invalid_union:n="Invalid input";break;case m.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${k.joinValues(r.options)}`;break;case m.invalid_enum_value:n=`Invalid enum value. Expected ${k.joinValues(r.options)}, received '${r.received}'`;break;case m.invalid_arguments:n="Invalid function arguments";break;case m.invalid_return_type:n="Invalid function return type";break;case m.invalid_date:n="Invalid date";break;case m.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(n=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?n=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?n=`Invalid input: must end with "${r.validation.endsWith}"`:k.assertNever(r.validation):r.validation!=="regex"?n=`Invalid ${r.validation}`:n="Invalid";break;case m.too_small:r.type==="array"?n=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?n=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?n=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="bigint"?n=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?n=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:n="Invalid input";break;case m.too_big:r.type==="array"?n=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?n=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?n=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?n=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?n=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:n="Invalid input";break;case m.custom:n="Invalid input";break;case m.invalid_intersection_types:n="Intersection results could not be merged";break;case m.not_multiple_of:n=`Number must be a multiple of ${r.multipleOf}`;break;case m.not_finite:n="Number must be finite";break;default:n=t.defaultError,k.assertNever(r)}return{message:n}},W=cn;var Bt=W;function ln(r){Bt=r}function we(){return Bt}var Ue=r=>{let{data:t,path:n,errorMaps:a,issueData:s}=r,i=[...n,...s.path||[]],c={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.message};let o="",d=a.filter(p=>!!p).slice().reverse();for(let p of d)o=p(c,{data:t,defaultError:o}).message;return{...s,path:i,message:o}},dn=[];function h(r,t){let n=we(),a=Ue({issueData:t,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,n,n===W?void 0:W].filter(s=>!!s)});r.common.issues.push(a)}var O=class r{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,n){let a=[];for(let s of n){if(s.status==="aborted")return g;s.status==="dirty"&&t.dirty(),a.push(s.value)}return{status:t.value,value:a}}static async mergeObjectAsync(t,n){let a=[];for(let s of n){let i=await s.key,c=await s.value;a.push({key:i,value:c})}return r.mergeObjectSync(t,a)}static mergeObjectSync(t,n){let a={};for(let s of n){let{key:i,value:c}=s;if(i.status==="aborted"||c.status==="aborted")return g;i.status==="dirty"&&t.dirty(),c.status==="dirty"&&t.dirty(),i.value!=="__proto__"&&(typeof c.value<"u"||s.alwaysSet)&&(a[i.value]=c.value)}return{status:t.value,value:a}}},g=Object.freeze({status:"aborted"}),oe=r=>({status:"dirty",value:r}),E=r=>({status:"valid",value:r}),Qe=r=>r.status==="aborted",We=r=>r.status==="dirty",ee=r=>r.status==="valid",Ce=r=>typeof Promise<"u"&&r instanceof Promise;var y;(function(r){r.errToObj=t=>typeof t=="string"?{message:t}:t||{},r.toString=t=>typeof t=="string"?t:t?.message})(y||(y={}));var $=class{constructor(t,n,a,s){this._cachedPath=[],this.parent=t,this.data=n,this._path=a,this._key=s}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}},$t=(r,t)=>{if(ee(t))return{success:!0,data:t.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let n=new L(r.common.issues);return this._error=n,this._error}}};function x(r){if(!r)return{};let{errorMap:t,invalid_type_error:n,required_error:a,description:s}=r;if(t&&(n||a))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:s}:{errorMap:(c,o)=>{let{message:d}=r;return c.code==="invalid_enum_value"?{message:d??o.defaultError}:typeof o.data>"u"?{message:d??a??o.defaultError}:c.code!=="invalid_type"?{message:o.defaultError}:{message:d??n??o.defaultError}},description:s}}var S=class{get description(){return this._def.description}_getType(t){return F(t.data)}_getOrReturnCtx(t,n){return n||{common:t.parent.common,data:t.data,parsedType:F(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new O,ctx:{common:t.parent.common,data:t.data,parsedType:F(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){let n=this._parse(t);if(Ce(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(t){let n=this._parse(t);return Promise.resolve(n)}parse(t,n){let a=this.safeParse(t,n);if(a.success)return a.data;throw a.error}safeParse(t,n){let a={common:{issues:[],async:n?.async??!1,contextualErrorMap:n?.errorMap},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:F(t)},s=this._parseSync({data:t,path:a.path,parent:a});return $t(a,s)}"~validate"(t){let n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:F(t)};if(!this["~standard"].async)try{let a=this._parseSync({data:t,path:[],parent:n});return ee(a)?{value:a.value}:{issues:n.common.issues}}catch(a){a?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:n}).then(a=>ee(a)?{value:a.value}:{issues:n.common.issues})}async parseAsync(t,n){let a=await this.safeParseAsync(t,n);if(a.success)return a.data;throw a.error}async safeParseAsync(t,n){let a={common:{issues:[],contextualErrorMap:n?.errorMap,async:!0},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:F(t)},s=this._parse({data:t,path:a.path,parent:a}),i=await(Ce(s)?s:Promise.resolve(s));return $t(a,i)}refine(t,n){let a=s=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(s):n;return this._refinement((s,i)=>{let c=t(s),o=()=>i.addIssue({code:m.custom,...a(s)});return typeof Promise<"u"&&c instanceof Promise?c.then(d=>d?!0:(o(),!1)):c?!0:(o(),!1)})}refinement(t,n){return this._refinement((a,s)=>t(a)?!0:(s.addIssue(typeof n=="function"?n(a,s):n),!1))}_refinement(t){return new U({schema:this,typeName:b.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:n=>this["~validate"](n)}}optional(){return B.create(this,this._def)}nullable(){return Z.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Y.create(this)}promise(){return ne.create(this,this._def)}or(t){return he.create([this,t],this._def)}and(t){return fe.create(this,t,this._def)}transform(t){return new U({...x(this._def),schema:this,typeName:b.ZodEffects,effect:{type:"transform",transform:t}})}default(t){let n=typeof t=="function"?t:()=>t;return new ve({...x(this._def),innerType:this,defaultValue:n,typeName:b.ZodDefault})}brand(){return new qe({typeName:b.ZodBranded,type:this,...x(this._def)})}catch(t){let n=typeof t=="function"?t:()=>t;return new xe({...x(this._def),innerType:this,catchValue:n,typeName:b.ZodCatch})}describe(t){let n=this.constructor;return new n({...this._def,description:t})}pipe(t){return De.create(this,t)}readonly(){return Se.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},pn=/^c[^\s-]{8,}$/i,mn=/^[0-9a-z]+$/,un=/^[0-9A-HJKMNP-TV-Z]{26}$/i,hn=/^[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,fn=/^[a-z0-9_-]{21}$/i,yn=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,gn=/^[-+]?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)?)??$/,bn=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,_n="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",ut,vn=/^(?:(?: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])$/,xn=/^(?:(?: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])$/,Sn=/^(([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]))$/,jn=/^(([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])$/,kn=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Tn=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,qt="((\\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])))",Rn=new RegExp(`^${qt}$`);function Dt(r){let t="[0-5]\\d";r.precision?t=`${t}\\.\\d{${r.precision}}`:r.precision==null&&(t=`${t}(\\.\\d+)?`);let n=r.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function wn(r){return new RegExp(`^${Dt(r)}$`)}function Mt(r){let t=`${qt}T${Dt(r)}`,n=[];return n.push(r.local?"Z?":"Z"),r.offset&&n.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${n.join("|")})`,new RegExp(`^${t}$`)}function Cn(r,t){return!!((t==="v4"||!t)&&vn.test(r)||(t==="v6"||!t)&&Sn.test(r))}function zn(r,t){if(!yn.test(r))return!1;try{let[n]=r.split(".");if(!n)return!1;let a=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),s=JSON.parse(atob(a));return!(typeof s!="object"||s===null||"typ"in s&&s?.typ!=="JWT"||!s.alg||t&&s.alg!==t)}catch{return!1}}function Pn(r,t){return!!((t==="v4"||!t)&&xn.test(r)||(t==="v6"||!t)&&jn.test(r))}var te=class r extends S{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==f.string){let i=this._getOrReturnCtx(t);return h(i,{code:m.invalid_type,expected:f.string,received:i.parsedType}),g}let a=new O,s;for(let i of this._def.checks)if(i.kind==="min")t.data.length<i.value&&(s=this._getOrReturnCtx(t,s),h(s,{code:m.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),a.dirty());else if(i.kind==="max")t.data.length>i.value&&(s=this._getOrReturnCtx(t,s),h(s,{code:m.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),a.dirty());else if(i.kind==="length"){let c=t.data.length>i.value,o=t.data.length<i.value;(c||o)&&(s=this._getOrReturnCtx(t,s),c?h(s,{code:m.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):o&&h(s,{code:m.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),a.dirty())}else if(i.kind==="email")bn.test(t.data)||(s=this._getOrReturnCtx(t,s),h(s,{validation:"email",code:m.invalid_string,message:i.message}),a.dirty());else if(i.kind==="emoji")ut||(ut=new RegExp(_n,"u")),ut.test(t.data)||(s=this._getOrReturnCtx(t,s),h(s,{validation:"emoji",code:m.invalid_string,message:i.message}),a.dirty());else if(i.kind==="uuid")hn.test(t.data)||(s=this._getOrReturnCtx(t,s),h(s,{validation:"uuid",code:m.invalid_string,message:i.message}),a.dirty());else if(i.kind==="nanoid")fn.test(t.data)||(s=this._getOrReturnCtx(t,s),h(s,{validation:"nanoid",code:m.invalid_string,message:i.message}),a.dirty());else if(i.kind==="cuid")pn.test(t.data)||(s=this._getOrReturnCtx(t,s),h(s,{validation:"cuid",code:m.invalid_string,message:i.message}),a.dirty());else if(i.kind==="cuid2")mn.test(t.data)||(s=this._getOrReturnCtx(t,s),h(s,{validation:"cuid2",code:m.invalid_string,message:i.message}),a.dirty());else if(i.kind==="ulid")un.test(t.data)||(s=this._getOrReturnCtx(t,s),h(s,{validation:"ulid",code:m.invalid_string,message:i.message}),a.dirty());else if(i.kind==="url")try{new URL(t.data)}catch{s=this._getOrReturnCtx(t,s),h(s,{validation:"url",code:m.invalid_string,message:i.message}),a.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(t.data)||(s=this._getOrReturnCtx(t,s),h(s,{validation:"regex",code:m.invalid_string,message:i.message}),a.dirty())):i.kind==="trim"?t.data=t.data.trim():i.kind==="includes"?t.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(t,s),h(s,{code:m.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),a.dirty()):i.kind==="toLowerCase"?t.data=t.data.toLowerCase():i.kind==="toUpperCase"?t.data=t.data.toUpperCase():i.kind==="startsWith"?t.data.startsWith(i.value)||(s=this._getOrReturnCtx(t,s),h(s,{code:m.invalid_string,validation:{startsWith:i.value},message:i.message}),a.dirty()):i.kind==="endsWith"?t.data.endsWith(i.value)||(s=this._getOrReturnCtx(t,s),h(s,{code:m.invalid_string,validation:{endsWith:i.value},message:i.message}),a.dirty()):i.kind==="datetime"?Mt(i).test(t.data)||(s=this._getOrReturnCtx(t,s),h(s,{code:m.invalid_string,validation:"datetime",message:i.message}),a.dirty()):i.kind==="date"?Rn.test(t.data)||(s=this._getOrReturnCtx(t,s),h(s,{code:m.invalid_string,validation:"date",message:i.message}),a.dirty()):i.kind==="time"?wn(i).test(t.data)||(s=this._getOrReturnCtx(t,s),h(s,{code:m.invalid_string,validation:"time",message:i.message}),a.dirty()):i.kind==="duration"?gn.test(t.data)||(s=this._getOrReturnCtx(t,s),h(s,{validation:"duration",code:m.invalid_string,message:i.message}),a.dirty()):i.kind==="ip"?Cn(t.data,i.version)||(s=this._getOrReturnCtx(t,s),h(s,{validation:"ip",code:m.invalid_string,message:i.message}),a.dirty()):i.kind==="jwt"?zn(t.data,i.alg)||(s=this._getOrReturnCtx(t,s),h(s,{validation:"jwt",code:m.invalid_string,message:i.message}),a.dirty()):i.kind==="cidr"?Pn(t.data,i.version)||(s=this._getOrReturnCtx(t,s),h(s,{validation:"cidr",code:m.invalid_string,message:i.message}),a.dirty()):i.kind==="base64"?kn.test(t.data)||(s=this._getOrReturnCtx(t,s),h(s,{validation:"base64",code:m.invalid_string,message:i.message}),a.dirty()):i.kind==="base64url"?Tn.test(t.data)||(s=this._getOrReturnCtx(t,s),h(s,{validation:"base64url",code:m.invalid_string,message:i.message}),a.dirty()):k.assertNever(i);return{status:a.value,value:t.data}}_regex(t,n,a){return this.refinement(s=>t.test(s),{validation:n,code:m.invalid_string,...y.errToObj(a)})}_addCheck(t){return new r({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...y.errToObj(t)})}url(t){return this._addCheck({kind:"url",...y.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...y.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...y.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...y.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...y.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...y.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...y.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...y.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...y.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...y.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...y.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...y.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,...y.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,...y.errToObj(t?.message)})}duration(t){return this._addCheck({kind:"duration",...y.errToObj(t)})}regex(t,n){return this._addCheck({kind:"regex",regex:t,...y.errToObj(n)})}includes(t,n){return this._addCheck({kind:"includes",value:t,position:n?.position,...y.errToObj(n?.message)})}startsWith(t,n){return this._addCheck({kind:"startsWith",value:t,...y.errToObj(n)})}endsWith(t,n){return this._addCheck({kind:"endsWith",value:t,...y.errToObj(n)})}min(t,n){return this._addCheck({kind:"min",value:t,...y.errToObj(n)})}max(t,n){return this._addCheck({kind:"max",value:t,...y.errToObj(n)})}length(t,n){return this._addCheck({kind:"length",value:t,...y.errToObj(n)})}nonempty(t){return this.min(1,y.errToObj(t))}trim(){return new r({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new r({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new r({...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 n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxLength(){let t=null;for(let n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}};te.create=r=>new te({checks:[],typeName:b.ZodString,coerce:r?.coerce??!1,...x(r)});function On(r,t){let n=(r.toString().split(".")[1]||"").length,a=(t.toString().split(".")[1]||"").length,s=n>a?n:a,i=Number.parseInt(r.toFixed(s).replace(".","")),c=Number.parseInt(t.toFixed(s).replace(".",""));return i%c/10**s}var ce=class r extends S{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==f.number){let i=this._getOrReturnCtx(t);return h(i,{code:m.invalid_type,expected:f.number,received:i.parsedType}),g}let a,s=new O;for(let i of this._def.checks)i.kind==="int"?k.isInteger(t.data)||(a=this._getOrReturnCtx(t,a),h(a,{code:m.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?t.data<i.value:t.data<=i.value)&&(a=this._getOrReturnCtx(t,a),h(a,{code:m.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?t.data>i.value:t.data>=i.value)&&(a=this._getOrReturnCtx(t,a),h(a,{code:m.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?On(t.data,i.value)!==0&&(a=this._getOrReturnCtx(t,a),h(a,{code:m.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(t.data)||(a=this._getOrReturnCtx(t,a),h(a,{code:m.not_finite,message:i.message}),s.dirty()):k.assertNever(i);return{status:s.value,value:t.data}}gte(t,n){return this.setLimit("min",t,!0,y.toString(n))}gt(t,n){return this.setLimit("min",t,!1,y.toString(n))}lte(t,n){return this.setLimit("max",t,!0,y.toString(n))}lt(t,n){return this.setLimit("max",t,!1,y.toString(n))}setLimit(t,n,a,s){return new r({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:a,message:y.toString(s)}]})}_addCheck(t){return new r({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:y.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:y.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:y.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:y.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:y.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:y.toString(n)})}finite(t){return this._addCheck({kind:"finite",message:y.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:y.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:y.toString(t)})}get minValue(){let t=null;for(let n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(let n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&k.isInteger(t.value))}get isFinite(){let t=null,n=null;for(let a of this._def.checks){if(a.kind==="finite"||a.kind==="int"||a.kind==="multipleOf")return!0;a.kind==="min"?(n===null||a.value>n)&&(n=a.value):a.kind==="max"&&(t===null||a.value<t)&&(t=a.value)}return Number.isFinite(n)&&Number.isFinite(t)}};ce.create=r=>new ce({checks:[],typeName:b.ZodNumber,coerce:r?.coerce||!1,...x(r)});var le=class r extends S{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==f.bigint)return this._getInvalidInput(t);let a,s=new O;for(let i of this._def.checks)i.kind==="min"?(i.inclusive?t.data<i.value:t.data<=i.value)&&(a=this._getOrReturnCtx(t,a),h(a,{code:m.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?t.data>i.value:t.data>=i.value)&&(a=this._getOrReturnCtx(t,a),h(a,{code:m.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?t.data%i.value!==BigInt(0)&&(a=this._getOrReturnCtx(t,a),h(a,{code:m.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):k.assertNever(i);return{status:s.value,value:t.data}}_getInvalidInput(t){let n=this._getOrReturnCtx(t);return h(n,{code:m.invalid_type,expected:f.bigint,received:n.parsedType}),g}gte(t,n){return this.setLimit("min",t,!0,y.toString(n))}gt(t,n){return this.setLimit("min",t,!1,y.toString(n))}lte(t,n){return this.setLimit("max",t,!0,y.toString(n))}lt(t,n){return this.setLimit("max",t,!1,y.toString(n))}setLimit(t,n,a,s){return new r({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:a,message:y.toString(s)}]})}_addCheck(t){return new r({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:y.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:y.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:y.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:y.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:y.toString(n)})}get minValue(){let t=null;for(let n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(let n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}};le.create=r=>new le({checks:[],typeName:b.ZodBigInt,coerce:r?.coerce??!1,...x(r)});var de=class extends S{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==f.boolean){let a=this._getOrReturnCtx(t);return h(a,{code:m.invalid_type,expected:f.boolean,received:a.parsedType}),g}return E(t.data)}};de.create=r=>new de({typeName:b.ZodBoolean,coerce:r?.coerce||!1,...x(r)});var pe=class r extends S{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==f.date){let i=this._getOrReturnCtx(t);return h(i,{code:m.invalid_type,expected:f.date,received:i.parsedType}),g}if(Number.isNaN(t.data.getTime())){let i=this._getOrReturnCtx(t);return h(i,{code:m.invalid_date}),g}let a=new O,s;for(let i of this._def.checks)i.kind==="min"?t.data.getTime()<i.value&&(s=this._getOrReturnCtx(t,s),h(s,{code:m.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),a.dirty()):i.kind==="max"?t.data.getTime()>i.value&&(s=this._getOrReturnCtx(t,s),h(s,{code:m.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),a.dirty()):k.assertNever(i);return{status:a.value,value:new Date(t.data.getTime())}}_addCheck(t){return new r({...this._def,checks:[...this._def.checks,t]})}min(t,n){return this._addCheck({kind:"min",value:t.getTime(),message:y.toString(n)})}max(t,n){return this._addCheck({kind:"max",value:t.getTime(),message:y.toString(n)})}get minDate(){let t=null;for(let n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(let n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t!=null?new Date(t):null}};pe.create=r=>new pe({checks:[],coerce:r?.coerce||!1,typeName:b.ZodDate,...x(r)});var Pe=class extends S{_parse(t){if(this._getType(t)!==f.symbol){let a=this._getOrReturnCtx(t);return h(a,{code:m.invalid_type,expected:f.symbol,received:a.parsedType}),g}return E(t.data)}};Pe.create=r=>new Pe({typeName:b.ZodSymbol,...x(r)});var me=class extends S{_parse(t){if(this._getType(t)!==f.undefined){let a=this._getOrReturnCtx(t);return h(a,{code:m.invalid_type,expected:f.undefined,received:a.parsedType}),g}return E(t.data)}};me.create=r=>new me({typeName:b.ZodUndefined,...x(r)});var ue=class extends S{_parse(t){if(this._getType(t)!==f.null){let a=this._getOrReturnCtx(t);return h(a,{code:m.invalid_type,expected:f.null,received:a.parsedType}),g}return E(t.data)}};ue.create=r=>new ue({typeName:b.ZodNull,...x(r)});var re=class extends S{constructor(){super(...arguments),this._any=!0}_parse(t){return E(t.data)}};re.create=r=>new re({typeName:b.ZodAny,...x(r)});var J=class extends S{constructor(){super(...arguments),this._unknown=!0}_parse(t){return E(t.data)}};J.create=r=>new J({typeName:b.ZodUnknown,...x(r)});var D=class extends S{_parse(t){let n=this._getOrReturnCtx(t);return h(n,{code:m.invalid_type,expected:f.never,received:n.parsedType}),g}};D.create=r=>new D({typeName:b.ZodNever,...x(r)});var Oe=class extends S{_parse(t){if(this._getType(t)!==f.undefined){let a=this._getOrReturnCtx(t);return h(a,{code:m.invalid_type,expected:f.void,received:a.parsedType}),g}return E(t.data)}};Oe.create=r=>new Oe({typeName:b.ZodVoid,...x(r)});var Y=class r extends S{_parse(t){let{ctx:n,status:a}=this._processInputParams(t),s=this._def;if(n.parsedType!==f.array)return h(n,{code:m.invalid_type,expected:f.array,received:n.parsedType}),g;if(s.exactLength!==null){let c=n.data.length>s.exactLength.value,o=n.data.length<s.exactLength.value;(c||o)&&(h(n,{code:c?m.too_big:m.too_small,minimum:o?s.exactLength.value:void 0,maximum:c?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),a.dirty())}if(s.minLength!==null&&n.data.length<s.minLength.value&&(h(n,{code:m.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),a.dirty()),s.maxLength!==null&&n.data.length>s.maxLength.value&&(h(n,{code:m.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),a.dirty()),n.common.async)return Promise.all([...n.data].map((c,o)=>s.type._parseAsync(new $(n,c,n.path,o)))).then(c=>O.mergeArray(a,c));let i=[...n.data].map((c,o)=>s.type._parseSync(new $(n,c,n.path,o)));return O.mergeArray(a,i)}get element(){return this._def.type}min(t,n){return new r({...this._def,minLength:{value:t,message:y.toString(n)}})}max(t,n){return new r({...this._def,maxLength:{value:t,message:y.toString(n)}})}length(t,n){return new r({...this._def,exactLength:{value:t,message:y.toString(n)}})}nonempty(t){return this.min(1,t)}};Y.create=(r,t)=>new Y({type:r,minLength:null,maxLength:null,exactLength:null,typeName:b.ZodArray,...x(t)});function ze(r){if(r instanceof N){let t={};for(let n in r.shape){let a=r.shape[n];t[n]=B.create(ze(a))}return new N({...r._def,shape:()=>t})}else return r instanceof Y?new Y({...r._def,type:ze(r.element)}):r instanceof B?B.create(ze(r.unwrap())):r instanceof Z?Z.create(ze(r.unwrap())):r instanceof V?V.create(r.items.map(t=>ze(t))):r}var N=class r extends S{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(),n=k.objectKeys(t);return this._cached={shape:t,keys:n},this._cached}_parse(t){if(this._getType(t)!==f.object){let p=this._getOrReturnCtx(t);return h(p,{code:m.invalid_type,expected:f.object,received:p.parsedType}),g}let{status:a,ctx:s}=this._processInputParams(t),{shape:i,keys:c}=this._getCached(),o=[];if(!(this._def.catchall instanceof D&&this._def.unknownKeys==="strip"))for(let p in s.data)c.includes(p)||o.push(p);let d=[];for(let p of c){let u=i[p],T=s.data[p];d.push({key:{status:"valid",value:p},value:u._parse(new $(s,T,s.path,p)),alwaysSet:p in s.data})}if(this._def.catchall instanceof D){let p=this._def.unknownKeys;if(p==="passthrough")for(let u of o)d.push({key:{status:"valid",value:u},value:{status:"valid",value:s.data[u]}});else if(p==="strict")o.length>0&&(h(s,{code:m.unrecognized_keys,keys:o}),a.dirty());else if(p!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let p=this._def.catchall;for(let u of o){let T=s.data[u];d.push({key:{status:"valid",value:u},value:p._parse(new $(s,T,s.path,u)),alwaysSet:u in s.data})}}return s.common.async?Promise.resolve().then(async()=>{let p=[];for(let u of d){let T=await u.key,R=await u.value;p.push({key:T,value:R,alwaysSet:u.alwaysSet})}return p}).then(p=>O.mergeObjectSync(a,p)):O.mergeObjectSync(a,d)}get shape(){return this._def.shape()}strict(t){return y.errToObj,new r({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(n,a)=>{let s=this._def.errorMap?.(n,a).message??a.defaultError;return n.code==="unrecognized_keys"?{message:y.errToObj(t).message??s}:{message:s}}}:{}})}strip(){return new r({...this._def,unknownKeys:"strip"})}passthrough(){return new r({...this._def,unknownKeys:"passthrough"})}extend(t){return new r({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new r({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:b.ZodObject})}setKey(t,n){return this.augment({[t]:n})}catchall(t){return new r({...this._def,catchall:t})}pick(t){let n={};for(let a of k.objectKeys(t))t[a]&&this.shape[a]&&(n[a]=this.shape[a]);return new r({...this._def,shape:()=>n})}omit(t){let n={};for(let a of k.objectKeys(this.shape))t[a]||(n[a]=this.shape[a]);return new r({...this._def,shape:()=>n})}deepPartial(){return ze(this)}partial(t){let n={};for(let a of k.objectKeys(this.shape)){let s=this.shape[a];t&&!t[a]?n[a]=s:n[a]=s.optional()}return new r({...this._def,shape:()=>n})}required(t){let n={};for(let a of k.objectKeys(this.shape))if(t&&!t[a])n[a]=this.shape[a];else{let i=this.shape[a];for(;i instanceof B;)i=i._def.innerType;n[a]=i}return new r({...this._def,shape:()=>n})}keyof(){return Ft(k.objectKeys(this.shape))}};N.create=(r,t)=>new N({shape:()=>r,unknownKeys:"strip",catchall:D.create(),typeName:b.ZodObject,...x(t)});N.strictCreate=(r,t)=>new N({shape:()=>r,unknownKeys:"strict",catchall:D.create(),typeName:b.ZodObject,...x(t)});N.lazycreate=(r,t)=>new N({shape:r,unknownKeys:"strip",catchall:D.create(),typeName:b.ZodObject,...x(t)});var he=class extends S{_parse(t){let{ctx:n}=this._processInputParams(t),a=this._def.options;function s(i){for(let o of i)if(o.result.status==="valid")return o.result;for(let o of i)if(o.result.status==="dirty")return n.common.issues.push(...o.ctx.common.issues),o.result;let c=i.map(o=>new L(o.ctx.common.issues));return h(n,{code:m.invalid_union,unionErrors:c}),g}if(n.common.async)return Promise.all(a.map(async i=>{let c={...n,common:{...n.common,issues:[]},parent:null};return{result:await i._parseAsync({data:n.data,path:n.path,parent:c}),ctx:c}})).then(s);{let i,c=[];for(let d of a){let p={...n,common:{...n.common,issues:[]},parent:null},u=d._parseSync({data:n.data,path:n.path,parent:p});if(u.status==="valid")return u;u.status==="dirty"&&!i&&(i={result:u,ctx:p}),p.common.issues.length&&c.push(p.common.issues)}if(i)return n.common.issues.push(...i.ctx.common.issues),i.result;let o=c.map(d=>new L(d));return h(n,{code:m.invalid_union,unionErrors:o}),g}}get options(){return this._def.options}};he.create=(r,t)=>new he({options:r,typeName:b.ZodUnion,...x(t)});var K=r=>r instanceof ye?K(r.schema):r instanceof U?K(r.innerType()):r instanceof ge?[r.value]:r instanceof be?r.options:r instanceof _e?k.objectValues(r.enum):r instanceof ve?K(r._def.innerType):r instanceof me?[void 0]:r instanceof ue?[null]:r instanceof B?[void 0,...K(r.unwrap())]:r instanceof Z?[null,...K(r.unwrap())]:r instanceof qe||r instanceof Se?K(r.unwrap()):r instanceof xe?K(r._def.innerType):[],Ke=class r extends S{_parse(t){let{ctx:n}=this._processInputParams(t);if(n.parsedType!==f.object)return h(n,{code:m.invalid_type,expected:f.object,received:n.parsedType}),g;let a=this.discriminator,s=n.data[a],i=this.optionsMap.get(s);return i?n.common.async?i._parseAsync({data:n.data,path:n.path,parent:n}):i._parseSync({data:n.data,path:n.path,parent:n}):(h(n,{code:m.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[a]}),g)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,a){let s=new Map;for(let i of n){let c=K(i.shape[t]);if(!c.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let o of c){if(s.has(o))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(o)}`);s.set(o,i)}}return new r({typeName:b.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:s,...x(a)})}};function ht(r,t){let n=F(r),a=F(t);if(r===t)return{valid:!0,data:r};if(n===f.object&&a===f.object){let s=k.objectKeys(t),i=k.objectKeys(r).filter(o=>s.indexOf(o)!==-1),c={...r,...t};for(let o of i){let d=ht(r[o],t[o]);if(!d.valid)return{valid:!1};c[o]=d.data}return{valid:!0,data:c}}else if(n===f.array&&a===f.array){if(r.length!==t.length)return{valid:!1};let s=[];for(let i=0;i<r.length;i++){let c=r[i],o=t[i],d=ht(c,o);if(!d.valid)return{valid:!1};s.push(d.data)}return{valid:!0,data:s}}else return n===f.date&&a===f.date&&+r==+t?{valid:!0,data:r}:{valid:!1}}var fe=class extends S{_parse(t){let{status:n,ctx:a}=this._processInputParams(t),s=(i,c)=>{if(Qe(i)||Qe(c))return g;let o=ht(i.value,c.value);return o.valid?((We(i)||We(c))&&n.dirty(),{status:n.value,value:o.data}):(h(a,{code:m.invalid_intersection_types}),g)};return a.common.async?Promise.all([this._def.left._parseAsync({data:a.data,path:a.path,parent:a}),this._def.right._parseAsync({data:a.data,path:a.path,parent:a})]).then(([i,c])=>s(i,c)):s(this._def.left._parseSync({data:a.data,path:a.path,parent:a}),this._def.right._parseSync({data:a.data,path:a.path,parent:a}))}};fe.create=(r,t,n)=>new fe({left:r,right:t,typeName:b.ZodIntersection,...x(n)});var V=class r extends S{_parse(t){let{status:n,ctx:a}=this._processInputParams(t);if(a.parsedType!==f.array)return h(a,{code:m.invalid_type,expected:f.array,received:a.parsedType}),g;if(a.data.length<this._def.items.length)return h(a,{code:m.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),g;!this._def.rest&&a.data.length>this._def.items.length&&(h(a,{code:m.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());let i=[...a.data].map((c,o)=>{let d=this._def.items[o]||this._def.rest;return d?d._parse(new $(a,c,a.path,o)):null}).filter(c=>!!c);return a.common.async?Promise.all(i).then(c=>O.mergeArray(n,c)):O.mergeArray(n,i)}get items(){return this._def.items}rest(t){return new r({...this._def,rest:t})}};V.create=(r,t)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new V({items:r,typeName:b.ZodTuple,rest:null,...x(t)})};var Je=class r extends S{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:n,ctx:a}=this._processInputParams(t);if(a.parsedType!==f.object)return h(a,{code:m.invalid_type,expected:f.object,received:a.parsedType}),g;let s=[],i=this._def.keyType,c=this._def.valueType;for(let o in a.data)s.push({key:i._parse(new $(a,o,a.path,o)),value:c._parse(new $(a,a.data[o],a.path,o)),alwaysSet:o in a.data});return a.common.async?O.mergeObjectAsync(n,s):O.mergeObjectSync(n,s)}get element(){return this._def.valueType}static create(t,n,a){return n instanceof S?new r({keyType:t,valueType:n,typeName:b.ZodRecord,...x(a)}):new r({keyType:te.create(),valueType:t,typeName:b.ZodRecord,...x(n)})}},Ae=class extends S{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:n,ctx:a}=this._processInputParams(t);if(a.parsedType!==f.map)return h(a,{code:m.invalid_type,expected:f.map,received:a.parsedType}),g;let s=this._def.keyType,i=this._def.valueType,c=[...a.data.entries()].map(([o,d],p)=>({key:s._parse(new $(a,o,a.path,[p,"key"])),value:i._parse(new $(a,d,a.path,[p,"value"]))}));if(a.common.async){let o=new Map;return Promise.resolve().then(async()=>{for(let d of c){let p=await d.key,u=await d.value;if(p.status==="aborted"||u.status==="aborted")return g;(p.status==="dirty"||u.status==="dirty")&&n.dirty(),o.set(p.value,u.value)}return{status:n.value,value:o}})}else{let o=new Map;for(let d of c){let p=d.key,u=d.value;if(p.status==="aborted"||u.status==="aborted")return g;(p.status==="dirty"||u.status==="dirty")&&n.dirty(),o.set(p.value,u.value)}return{status:n.value,value:o}}}};Ae.create=(r,t,n)=>new Ae({valueType:t,keyType:r,typeName:b.ZodMap,...x(n)});var Ee=class r extends S{_parse(t){let{status:n,ctx:a}=this._processInputParams(t);if(a.parsedType!==f.set)return h(a,{code:m.invalid_type,expected:f.set,received:a.parsedType}),g;let s=this._def;s.minSize!==null&&a.data.size<s.minSize.value&&(h(a,{code:m.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),n.dirty()),s.maxSize!==null&&a.data.size>s.maxSize.value&&(h(a,{code:m.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),n.dirty());let i=this._def.valueType;function c(d){let p=new Set;for(let u of d){if(u.status==="aborted")return g;u.status==="dirty"&&n.dirty(),p.add(u.value)}return{status:n.value,value:p}}let o=[...a.data.values()].map((d,p)=>i._parse(new $(a,d,a.path,p)));return a.common.async?Promise.all(o).then(d=>c(d)):c(o)}min(t,n){return new r({...this._def,minSize:{value:t,message:y.toString(n)}})}max(t,n){return new r({...this._def,maxSize:{value:t,message:y.toString(n)}})}size(t,n){return this.min(t,n).max(t,n)}nonempty(t){return this.min(1,t)}};Ee.create=(r,t)=>new Ee({valueType:r,minSize:null,maxSize:null,typeName:b.ZodSet,...x(t)});var Ye=class r extends S{constructor(){super(...arguments),this.validate=this.implement}_parse(t){let{ctx:n}=this._processInputParams(t);if(n.parsedType!==f.function)return h(n,{code:m.invalid_type,expected:f.function,received:n.parsedType}),g;function a(o,d){return Ue({data:o,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,we(),W].filter(p=>!!p),issueData:{code:m.invalid_arguments,argumentsError:d}})}function s(o,d){return Ue({data:o,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,we(),W].filter(p=>!!p),issueData:{code:m.invalid_return_type,returnTypeError:d}})}let i={errorMap:n.common.contextualErrorMap},c=n.data;if(this._def.returns instanceof ne){let o=this;return E(async function(...d){let p=new L([]),u=await o._def.args.parseAsync(d,i).catch(_=>{throw p.addIssue(a(d,_)),p}),T=await Reflect.apply(c,this,u);return await o._def.returns._def.type.parseAsync(T,i).catch(_=>{throw p.addIssue(s(T,_)),p})})}else{let o=this;return E(function(...d){let p=o._def.args.safeParse(d,i);if(!p.success)throw new L([a(d,p.error)]);let u=Reflect.apply(c,this,p.data),T=o._def.returns.safeParse(u,i);if(!T.success)throw new L([s(u,T.error)]);return T.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new r({...this._def,args:V.create(t).rest(J.create())})}returns(t){return new r({...this._def,returns:t})}implement(t){return this.parse(t)}strictImplement(t){return this.parse(t)}static create(t,n,a){return new r({args:t||V.create([]).rest(J.create()),returns:n||J.create(),typeName:b.ZodFunction,...x(a)})}},ye=class extends S{get schema(){return this._def.getter()}_parse(t){let{ctx:n}=this._processInputParams(t);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}};ye.create=(r,t)=>new ye({getter:r,typeName:b.ZodLazy,...x(t)});var ge=class extends S{_parse(t){if(t.data!==this._def.value){let n=this._getOrReturnCtx(t);return h(n,{received:n.data,code:m.invalid_literal,expected:this._def.value}),g}return{status:"valid",value:t.data}}get value(){return this._def.value}};ge.create=(r,t)=>new ge({value:r,typeName:b.ZodLiteral,...x(t)});function Ft(r,t){return new be({values:r,typeName:b.ZodEnum,...x(t)})}var be=class r extends S{_parse(t){if(typeof t.data!="string"){let n=this._getOrReturnCtx(t),a=this._def.values;return h(n,{expected:k.joinValues(a),received:n.parsedType,code:m.invalid_type}),g}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){let n=this._getOrReturnCtx(t),a=this._def.values;return h(n,{received:n.data,code:m.invalid_enum_value,options:a}),g}return E(t.data)}get options(){return this._def.values}get enum(){let t={};for(let n of this._def.values)t[n]=n;return t}get Values(){let t={};for(let n of this._def.values)t[n]=n;return t}get Enum(){let t={};for(let n of this._def.values)t[n]=n;return t}extract(t,n=this._def){return r.create(t,{...this._def,...n})}exclude(t,n=this._def){return r.create(this.options.filter(a=>!t.includes(a)),{...this._def,...n})}};be.create=Ft;var _e=class extends S{_parse(t){let n=k.getValidEnumValues(this._def.values),a=this._getOrReturnCtx(t);if(a.parsedType!==f.string&&a.parsedType!==f.number){let s=k.objectValues(n);return h(a,{expected:k.joinValues(s),received:a.parsedType,code:m.invalid_type}),g}if(this._cache||(this._cache=new Set(k.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){let s=k.objectValues(n);return h(a,{received:a.data,code:m.invalid_enum_value,options:s}),g}return E(t.data)}get enum(){return this._def.values}};_e.create=(r,t)=>new _e({values:r,typeName:b.ZodNativeEnum,...x(t)});var ne=class extends S{unwrap(){return this._def.type}_parse(t){let{ctx:n}=this._processInputParams(t);if(n.parsedType!==f.promise&&n.common.async===!1)return h(n,{code:m.invalid_type,expected:f.promise,received:n.parsedType}),g;let a=n.parsedType===f.promise?n.data:Promise.resolve(n.data);return E(a.then(s=>this._def.type.parseAsync(s,{path:n.path,errorMap:n.common.contextualErrorMap})))}};ne.create=(r,t)=>new ne({type:r,typeName:b.ZodPromise,...x(t)});var U=class extends S{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===b.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){let{status:n,ctx:a}=this._processInputParams(t),s=this._def.effect||null,i={addIssue:c=>{h(a,c),c.fatal?n.abort():n.dirty()},get path(){return a.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){let c=s.transform(a.data,i);if(a.common.async)return Promise.resolve(c).then(async o=>{if(n.value==="aborted")return g;let d=await this._def.schema._parseAsync({data:o,path:a.path,parent:a});return d.status==="aborted"?g:d.status==="dirty"?oe(d.value):n.value==="dirty"?oe(d.value):d});{if(n.value==="aborted")return g;let o=this._def.schema._parseSync({data:c,path:a.path,parent:a});return o.status==="aborted"?g:o.status==="dirty"?oe(o.value):n.value==="dirty"?oe(o.value):o}}if(s.type==="refinement"){let c=o=>{let d=s.refinement(o,i);if(a.common.async)return Promise.resolve(d);if(d instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(a.common.async===!1){let o=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});return o.status==="aborted"?g:(o.status==="dirty"&&n.dirty(),c(o.value),{status:n.value,value:o.value})}else return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then(o=>o.status==="aborted"?g:(o.status==="dirty"&&n.dirty(),c(o.value).then(()=>({status:n.value,value:o.value}))))}if(s.type==="transform")if(a.common.async===!1){let c=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});if(!ee(c))return g;let o=s.transform(c.value,i);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:o}}else return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then(c=>ee(c)?Promise.resolve(s.transform(c.value,i)).then(o=>({status:n.value,value:o})):g);k.assertNever(s)}};U.create=(r,t,n)=>new U({schema:r,typeName:b.ZodEffects,effect:t,...x(n)});U.createWithPreprocess=(r,t,n)=>new U({schema:t,effect:{type:"preprocess",transform:r},typeName:b.ZodEffects,...x(n)});var B=class extends S{_parse(t){return this._getType(t)===f.undefined?E(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};B.create=(r,t)=>new B({innerType:r,typeName:b.ZodOptional,...x(t)});var Z=class extends S{_parse(t){return this._getType(t)===f.null?E(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};Z.create=(r,t)=>new Z({innerType:r,typeName:b.ZodNullable,...x(t)});var ve=class extends S{_parse(t){let{ctx:n}=this._processInputParams(t),a=n.data;return n.parsedType===f.undefined&&(a=this._def.defaultValue()),this._def.innerType._parse({data:a,path:n.path,parent:n})}removeDefault(){return this._def.innerType}};ve.create=(r,t)=>new ve({innerType:r,typeName:b.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...x(t)});var xe=class extends S{_parse(t){let{ctx:n}=this._processInputParams(t),a={...n,common:{...n.common,issues:[]}},s=this._def.innerType._parse({data:a.data,path:a.path,parent:{...a}});return Ce(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new L(a.common.issues)},input:a.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new L(a.common.issues)},input:a.data})}}removeCatch(){return this._def.innerType}};xe.create=(r,t)=>new xe({innerType:r,typeName:b.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...x(t)});var Ie=class extends S{_parse(t){if(this._getType(t)!==f.nan){let a=this._getOrReturnCtx(t);return h(a,{code:m.invalid_type,expected:f.nan,received:a.parsedType}),g}return{status:"valid",value:t.data}}};Ie.create=r=>new Ie({typeName:b.ZodNaN,...x(r)});var An=Symbol("zod_brand"),qe=class extends S{_parse(t){let{ctx:n}=this._processInputParams(t),a=n.data;return this._def.type._parse({data:a,path:n.path,parent:n})}unwrap(){return this._def.type}},De=class r extends S{_parse(t){let{status:n,ctx:a}=this._processInputParams(t);if(a.common.async)return(async()=>{let i=await this._def.in._parseAsync({data:a.data,path:a.path,parent:a});return i.status==="aborted"?g:i.status==="dirty"?(n.dirty(),oe(i.value)):this._def.out._parseAsync({data:i.value,path:a.path,parent:a})})();{let s=this._def.in._parseSync({data:a.data,path:a.path,parent:a});return s.status==="aborted"?g:s.status==="dirty"?(n.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:a.path,parent:a})}}static create(t,n){return new r({in:t,out:n,typeName:b.ZodPipeline})}},Se=class extends S{_parse(t){let n=this._def.innerType._parse(t),a=s=>(ee(s)&&(s.value=Object.freeze(s.value)),s);return Ce(n)?n.then(s=>a(s)):a(n)}unwrap(){return this._def.innerType}};Se.create=(r,t)=>new Se({innerType:r,typeName:b.ZodReadonly,...x(t)});function Ut(r,t){let n=typeof r=="function"?r(t):typeof r=="string"?{message:r}:r;return typeof n=="string"?{message:n}:n}function Vt(r,t={},n){return r?re.create().superRefine((a,s)=>{let i=r(a);if(i instanceof Promise)return i.then(c=>{if(!c){let o=Ut(t,a),d=o.fatal??n??!0;s.addIssue({code:"custom",...o,fatal:d})}});if(!i){let c=Ut(t,a),o=c.fatal??n??!0;s.addIssue({code:"custom",...c,fatal:o})}}):re.create()}var En={object:N.lazycreate},b;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(b||(b={}));var In=(r,t={message:`Input not instance of ${r.name}`})=>Vt(n=>n instanceof r,t),Zt=te.create,Gt=ce.create,Ln=Ie.create,Nn=le.create,Ht=de.create,Bn=pe.create,$n=Pe.create,Un=me.create,qn=ue.create,Dn=re.create,Mn=J.create,Fn=D.create,Vn=Oe.create,Zn=Y.create,Gn=N.create,Hn=N.strictCreate,Qn=he.create,Wn=Ke.create,Kn=fe.create,Jn=V.create,Yn=Je.create,Xn=Ae.create,ea=Ee.create,ta=Ye.create,ra=ye.create,na=ge.create,aa=be.create,sa=_e.create,ia=ne.create,oa=U.create,ca=B.create,la=Z.create,da=U.createWithPreprocess,pa=De.create,ma=()=>Zt().optional(),ua=()=>Gt().optional(),ha=()=>Ht().optional(),fa={string:r=>te.create({...r,coerce:!0}),number:r=>ce.create({...r,coerce:!0}),boolean:r=>de.create({...r,coerce:!0}),bigint:r=>le.create({...r,coerce:!0}),date:r=>pe.create({...r,coerce:!0})};var ya=g;var ga=r=>typeof r?.safeParse=="function";var ft=r=>typeof r?.passthrough=="function";var ba=(r,t)=>ft(r)?ft(t)?r.merge(t):r:ft(t)?t:Object.assign({},r,t);var Ac=e.object({name:e.literal("ZodError"),issues:e.array(e.object({path:e.array(e.union([e.string(),e.number()])),message:e.string().optional(),code:e.nativeEnum(e.ZodIssueCode)}).catchall(e.any()))}),_a=Symbol("ContractNoBody"),Wt=r=>"method"in r&&"path"in r;var Kt=(r,t)=>Object.fromEntries(Object.entries(r).map(([n,a])=>{var s,i,c;return Wt(a)?[n,{...a,path:t?.pathPrefix?t.pathPrefix+a.path:a.path,headers:ba(t?.baseHeaders,a.headers),strictStatusCodes:(s=a.strictStatusCodes)!==null&&s!==void 0?s:t?.strictStatusCodes,validateResponseOnClient:(i=a.validateResponseOnClient)!==null&&i!==void 0?i:t?.validateResponseOnClient,responses:{...t?.commonResponses,...a.responses},metadata:t?.metadata?{...t?.metadata,...(c=a.metadata)!==null&&c!==void 0?c:{}}:a.metadata}]:[n,Kt(a,t)]})),yt=Symbol("ContractPlainType"),G=()=>({router:(r,t)=>Kt(r,t),query:r=>r,mutation:r=>r,responses:r=>r,response:()=>yt,body:()=>yt,type:()=>yt,otherResponse:({contentType:r,body:t})=>({contentType:r,body:t}),noBody:()=>_a}),va=({path:r,params:t})=>{let n=t;return r.replace(/\/?:([^/?]+)\??/g,(a,s)=>n[s]?`${a.startsWith("/")?"/":""}${n[s]}`:"")},xa=(r,t=!1)=>{let n=t?Sa(r):ja(r);return n?.length>0?"?"+n:""},Sa=r=>r?Object.entries(r).filter(([,t])=>t!==void 0).map(([t,n])=>{let a;return typeof n=="string"&&!["true","false","null"].includes(n.trim())&&isNaN(Number(n))?a=n:a=JSON.stringify(n),`${encodeURIComponent(t)}=${encodeURIComponent(a)}`}).join("&"):"",ja=r=>r?Object.keys(r).flatMap(t=>gt(t,r[t])).map(([t,n])=>`${encodeURIComponent(t)}=${encodeURIComponent(n)}`).join("&"):"",gt=(r,t)=>Array.isArray(t)?t.flatMap((n,a)=>gt(`${r}[${a}]`,n)):t instanceof Date?[[`${r}`,t.toISOString()]]:t===null?[[`${r}`,""]]:t===void 0?[]:typeof t=="object"?Object.keys(t).flatMap(n=>gt(`${r}[${n}]`,t[n])):[[`${r}`,`${t}`]];var bt=class extends Error{constructor(t,n){let a=n.join(",");super(`Server returned unexpected response. Expected one of: ${a} got: ${t.status}`),this.response=t}};var ka=async({route:r,path:t,method:n,headers:a,body:s,validateResponse:i,fetchOptions:c})=>{let o=await fetch(t,{...c,method:n,headers:a,body:s}),d=o.headers.get("content-type");if(d?.includes("application/")&&d?.includes("json")){let p={status:o.status,body:await o.json(),headers:o.headers},u=r.responses[p.status];return(i??r.validateResponseOnClient)&&ga(u)?{...p,body:u.parse(p.body)}:p}return d?.includes("text/")?{status:o.status,body:await o.text(),headers:o.headers}:{status:o.status,body:await o.blob(),headers:o.headers}},Ta=r=>{let t=new FormData,n=(a,s)=>{s instanceof File?t.append(a,s):t.append(a,JSON.stringify(s))};return Object.entries(r).forEach(([a,s])=>{if(Array.isArray(s))for(let i of s)n(a,i);else n(a,s)}),t},Qt=r=>Object.fromEntries(Object.entries(r).map(([t,n])=>[t.toLowerCase(),n])),Ra=r=>{let{path:t,clientArgs:n,route:a,body:s,query:i,extraInputArgs:c,headers:o,fetchOptions:d}=r,p=n.api||ka,u=n.baseHeaders&&Object.fromEntries(Object.entries(n.baseHeaders).map(([_,z])=>typeof z=="function"?[_,z(r)]:[_,z])),T={...u&&Qt(u),...Qt(o)};Object.keys(T).forEach(_=>{T[_]===void 0&&delete T[_]});let R={route:a,path:t,method:a.method,headers:T,body:void 0,rawBody:s,rawQuery:i,contentType:void 0,validateResponse:n.validateResponse,fetchOptions:{...n.credentials&&{credentials:n.credentials},...d},...d?.signal&&{signal:d.signal},...d?.cache&&{cache:d.cache},...d&&"next"in d&&!!d?.next&&{next:d.next}};return a.method!=="GET"&&("contentType"in a&&a.contentType==="multipart/form-data"?R={...R,contentType:"multipart/form-data",body:s instanceof FormData?s:Ta(s)}:"contentType"in a&&a.contentType==="application/x-www-form-urlencoded"?R={...R,contentType:"application/x-www-form-urlencoded",headers:{"content-type":"application/x-www-form-urlencoded",...R.headers},body:typeof s=="string"?s:new URLSearchParams(s)}:s!=null&&(R={...R,contentType:"application/json",headers:{"content-type":"application/json",...R.headers},body:JSON.stringify(s)})),p({...R,...c})},wa=(r,t,n)=>{let{query:a,params:s,body:i,headers:c,extraHeaders:o,overrideClientOptions:d,fetchOptions:p,cache:u,next:T,...R}=n||{},_={...t,...d};return{path:Ca(a,_.baseUrl,s,r,!!_.jsonQuery),clientArgs:_,route:r,body:i,query:a,extraInputArgs:R,fetchOptions:{...u&&{cache:u},...T&&{next:T},...p},headers:{...o,...c}}},Ca=(r,t,n,a,s)=>{let i=va({path:a.path,params:n}),c=xa(r,s);return`${t}${i}${c}`},za=(r,t)=>{let n=Object.keys(r.responses);return async a=>{let s=wa(r,t,a),i=await Ra(s);if(!t.throwOnUnknownStatus||n.includes(i.status.toString()))return i;throw new bt(i,n)}},_t=(r,t)=>Object.fromEntries(Object.entries(r).map(([n,a])=>Wt(a)?[n,za(a,t)]:[n,_t(a,t)]));var vt=["free","creator","team"],Jt=typeof process<"u"&&process.env?.NODE_ENV!=="production",Pa={stripe:{plans:[{tier:"free",subjectType:"user",name:"Free",description:"Upload threads, share read-only links, and collaborate with your workspace. Shared links expire after 3 days.",price:0,priceId:null,features:[{name:"Thread uploads + public links"},{name:"Workspace membership"},{name:"Shared links live 3 days"}],entitlements:{skills:!1,workspaceScope:!1,review:!1,sharedThreadTtlDays:3}},{tier:"creator",subjectType:"user",name:"Creator",description:"For builders who share a lot. Permanent links and the Skills tab.",price:29,isFeatured:!0,priceId:Jt?"price_1TP9BSKwvRM43sh64waIrvjj":"price_1TPA2gKwvRM43sh6Kp4ZCpJZ",features:[{name:"Everything in Free"},{name:"Shared threads live forever"},{name:"Skills tab \u2014 tool usage across every thread"}],entitlements:{skills:!0,workspaceScope:!1,review:!1,sharedThreadTtlDays:null}},{tier:"team",subjectType:"organization",name:"Team",description:"GitHub for Prompts. Org-wide thread sharing plus the review surface.",price:19,minSeats:2,priceId:Jt?"price_1TP9MpKwvRM43sh6TBIFxVCd":"price_1TPA3CKwvRM43sh6k0bgPTsQ",features:[{name:"Everything in Creator"},{name:"Workspace-wide thread sharing"},{name:"Minimum 2 seats"},{name:"Review feature (beta)"}],entitlements:{skills:!0,workspaceScope:!0,review:!0,sharedThreadTtlDays:null}}]}};var Yt=Pa.stripe.plans,Ic=Object.freeze(Object.fromEntries(Yt.map(r=>[r.tier,r])));var Oa=G(),I=e.object({message:e.string()}),xt=e.record(e.unknown()),je=e.string().regex(/^doc_[0-9A-Za-z]{22}$/),Xe=e.string().regex(/^proj_[0-9A-Za-z]{22}$/),Aa=["active","archived"],et=e.enum(Aa),Xt=e.object({id:e.string().min(1),display_name:e.string().min(1)}),er=e.object({id:Xe,name:e.string().min(1)}),St=e.object({id:je,title:e.string().min(1),status:et,author:Xt,project:er.nullable(),created_at:e.string().datetime(),updated_at:e.string().datetime(),archived_at:e.string().datetime().nullable()}),Ea=e.object({type:e.literal("list"),list_type:e.literal("doc"),objects:e.array(St)}),Ia=e.object({project_id:Xe.optional(),status:et.optional()}),La=e.object({title:e.string().trim().min(1).max(300).optional(),prosemirror_json:xt.optional(),project_id:Xe.nullable().optional()}),Na=e.object({id:je,created_at:e.string().datetime()}),Ba=e.object({title:e.string().trim().min(1).max(300).optional(),prosemirror_json:xt.optional(),project_id:Xe.nullable().optional(),status:et.optional()}).refine(r=>Object.keys(r).length>0,{message:"At least one field must be provided"}),$a=e.object({id:je,updated_at:e.string().datetime()}),Ua=e.object({id:je,title:e.string().min(1),prosemirror_json:xt,status:et,author:Xt,project:er.nullable(),created_at:e.string().datetime(),updated_at:e.string().datetime(),archived_at:e.string().datetime().nullable()}),tr=Oa.router({listDocs:{method:"GET",path:"/docs",headers:e.object({authorization:e.string().min(1).optional()}),query:Ia,responses:{200:Ea,401:I,403:I},summary:"List docs in the authenticated user\u2019s organization. Optional project_id filter scopes to a single project."},createDoc:{method:"POST",path:"/docs",headers:e.object({authorization:e.string().min(1).optional()}),body:La,responses:{201:Na,401:I,403:I,404:I,422:I},summary:"Create a doc. If project_id is provided, the doc is scoped to that project; otherwise it lives at the workspace level."},getDoc:{method:"GET",path:"/docs/:docId",pathParams:e.object({docId:je}),headers:e.object({authorization:e.string().min(1).optional()}),responses:{200:Ua,401:I,403:I,404:I},summary:"Get a doc by id with its rich-text body and parent project (if any)"},updateDoc:{method:"PATCH",path:"/docs/:docId",pathParams:e.object({docId:je}),headers:e.object({authorization:e.string().min(1).optional()}),body:Ba,responses:{200:$a,401:I,403:I,404:I,422:I},summary:"Update a doc. If prosemirror_json changes, the server re-syncs lore.mention_references from mention nodes."},deleteDoc:{method:"DELETE",path:"/docs/:docId",pathParams:e.object({docId:je}),headers:e.object({authorization:e.string().min(1).optional()}),body:e.object({}).optional(),responses:{204:e.object({}),401:I,403:I,404:I},summary:"Hard-delete a doc and any mention references it owns"}});var qa=G(),C=e.object({message:e.string()}),jt=e.record(e.unknown()),H=e.string().regex(/^proj_[0-9A-Za-z]{22}$/),Da=["active","archived"],tt=e.enum(Da),kt=e.object({id:e.string().min(1),display_name:e.string().min(1)}),rr=e.object({thread_id:e.string().min(1),title:e.string().min(1),added_at:e.string().datetime(),added_by:kt}),Ma=e.object({id:H,name:e.string().min(1),status:tt,author:kt,thread_count:e.number().int().nonnegative(),doc_count:e.number().int().nonnegative(),created_at:e.string().datetime(),updated_at:e.string().datetime(),archived_at:e.string().datetime().nullable()}),Fa=e.object({type:e.literal("list"),list_type:e.literal("project"),objects:e.array(Ma)}),Va=e.object({status:tt.optional()}),Za=e.object({name:e.string().trim().min(1).max(200),prosemirror_json:jt.optional()}),Ga=e.object({id:H,created_at:e.string().datetime()}),Ha=e.object({name:e.string().trim().min(1).max(200).optional(),prosemirror_json:jt.optional()}).refine(r=>Object.keys(r).length>0,{message:"At least one field must be provided"}),Qa=e.object({id:H,updated_at:e.string().datetime()}),Wa=e.object({archived:e.boolean()}),Ka=e.object({id:H,status:tt,archived_at:e.string().datetime().nullable()}),Ja=e.object({id:H,name:e.string().min(1),prosemirror_json:jt,status:tt,author:kt,created_at:e.string().datetime(),updated_at:e.string().datetime(),archived_at:e.string().datetime().nullable(),threads:e.array(rr),docs:e.array(St)}),Ya=e.object({thread_id:e.string().min(1).max(64)}),Xa=rr,nr=qa.router({listProjects:{method:"GET",path:"/projects",headers:e.object({authorization:e.string().min(1).optional()}),query:Va,responses:{200:Fa,401:C},summary:"List projects in the authenticated user\u2019s organization"},createProject:{method:"POST",path:"/projects",headers:e.object({authorization:e.string().min(1).optional()}),body:Za,responses:{201:Ga,401:C,422:C},summary:"Create a new project in the authenticated user\u2019s organization"},getProject:{method:"GET",path:"/projects/:projectId",pathParams:e.object({projectId:H}),headers:e.object({authorization:e.string().min(1).optional()}),responses:{200:Ja,401:C,403:C,404:C},summary:"Get a project with its attached threads and child docs. The project description is the canonical mention source for project-scoped @-mentions."},updateProject:{method:"PATCH",path:"/projects/:projectId",pathParams:e.object({projectId:H}),headers:e.object({authorization:e.string().min(1).optional()}),body:Ha,responses:{200:Qa,401:C,403:C,404:C,422:C},summary:"Update a project\u2019s name or rich-text body. Body changes re-sync mention_references for source_kind=project."},archiveProject:{method:"POST",path:"/projects/:projectId/archive",pathParams:e.object({projectId:H}),headers:e.object({authorization:e.string().min(1).optional()}),body:Wa,responses:{200:Ka,401:C,403:C,404:C},summary:"Archive (soft-delete) or unarchive a project"},addProjectThread:{method:"POST",path:"/projects/:projectId/threads",pathParams:e.object({projectId:H}),headers:e.object({authorization:e.string().min(1).optional()}),body:Ya,responses:{201:Xa,401:C,403:C,404:C,409:C,422:C},summary:"Pin an existing visible thread to this project. Idempotent \u2014 re-adding returns the existing membership."},removeProjectThread:{method:"DELETE",path:"/projects/:projectId/threads/:threadId",pathParams:e.object({projectId:H,threadId:e.string().min(1).max(64)}),headers:e.object({authorization:e.string().min(1).optional()}),body:e.object({}).optional(),responses:{204:e.object({}),401:C,403:C,404:C},summary:"Remove a thread membership from a project"}});var es=G(),rt=e.object({message:e.string()}),ts=["thread","plan","doc","user"],nt=e.enum(ts),rs=["doc","project"],ns=e.enum(rs),as=e.object({kind:nt,id:e.string().min(1),title:e.string().min(1),href:e.string().min(1)}),ss=e.object({type:e.literal("list"),list_type:e.literal("mention"),objects:e.array(as)}),is=e.object({q:e.string().trim().min(1).max(50),kinds:e.string().optional().transform(r=>{if(!r)return;let t=r.split(",").map(n=>n.trim()).filter(n=>n.length>0);return t.length>0?t:void 0}).pipe(e.array(nt).optional())}),os=e.object({source_kind:ns,source_id:e.string().min(1),source_title:e.string().min(1),source_href:e.string().min(1),target_kind:nt,target_id:e.string().min(1),created_at:e.string().datetime()}),cs=e.object({type:e.literal("list"),list_type:e.literal("backlink"),objects:e.array(os)}),ls=e.object({target_kind:nt,target_id:e.string().min(1).max(64)}),ar=es.router({searchMentions:{method:"GET",path:"/mentions/search",headers:e.object({authorization:e.string().min(1).optional()}),query:is,responses:{200:ss,401:rt,422:rt},summary:"Search threads, plans, files, and users by title/name for @-mention typeahead. Org-scoped, max 10 results across all kinds."},listBacklinks:{method:"GET",path:"/mentions/backlinks",headers:e.object({authorization:e.string().min(1).optional()}),query:ls,responses:{200:cs,401:rt,403:rt},summary:"List every doc/project body in the caller\u2019s organization that mentions the given target. Newest-first."}});var ds=G(),ps=e.object({type:e.literal("list"),list_type:e.literal("thread"),has_more:e.boolean(),objects:e.array(e.unknown())}),ae=e.object({message:e.string()}),sr=e.object({thread_id:e.string().min(1),is_favorited:e.boolean(),favorited_at:e.string().datetime().nullable()}),ms=e.object({before:e.string().min(1).max(64).optional()}),ir=ds.router({addThreadFavorite:{method:"POST",path:"/threads/:id/favorite",pathParams:e.object({id:e.string().min(1).max(64)}),headers:e.object({authorization:e.string().min(1).optional()}),body:e.object({}).optional(),responses:{201:sr,401:ae,403:ae,404:ae},summary:"Bookmark a thread for the authenticated user. Idempotent \u2014 re-favoriting returns the existing membership."},removeThreadFavorite:{method:"DELETE",path:"/threads/:id/favorite",pathParams:e.object({id:e.string().min(1).max(64)}),headers:e.object({authorization:e.string().min(1).optional()}),body:e.object({}).optional(),responses:{200:sr,401:ae,403:ae,404:ae},summary:"Remove a thread bookmark for the authenticated user (no-op if absent)."},listFavoriteThreads:{method:"GET",path:"/favorites/threads",headers:e.object({authorization:e.string().min(1).optional()}),query:ms,responses:{200:ps,401:ae,403:ae},summary:"List threads the authenticated user has favorited, newest favorited first. Visibility filtering still applies \u2014 a thread the viewer can no longer see (e.g. visibility downgraded) is omitted from the list."}});var us=G(),hs=e.object({id:e.string().uuid(),role:e.enum(["user","assistant"]),content:e.string().min(1),timestamp:e.string().datetime()}),fs=e.object({id:e.string().uuid(),title:e.string().min(1),author:e.string().min(1),authorAvatar:e.string().min(1).max(4),model:e.string().min(1),turnCount:e.number().int().nonnegative(),createdAt:e.string().datetime(),preview:e.string()}),ul=fs.extend({messages:e.array(hs)}),l=e.object({message:e.string()}),ys=/^[a-zA-Z0-9_-]{2,32}$/,hr=e.string().regex(ys,"Handle must be 2\u201332 characters: letters, numbers, dashes, or underscores."),Tt=e.object({id:e.string(),first_name:e.string().min(1),last_name:e.string().min(1),display_name:e.string().min(1),stytch_id:e.string().nullable(),handle:e.string().nullable(),bio:e.string().max(280).nullable(),avatar_url:e.string().nullable(),banner_url:e.string().nullable(),share_new_threads_to_workspace:e.boolean(),experimental_features_enabled:e.boolean(),onboarded_at:e.string().nullable()}),gs=e.object({stytchMemberId:e.string().min(1).optional(),emailAddress:e.string().email(),name:e.string().nullable(),user:Tt,is_admin:e.boolean()}),bs=e.object({share_new_threads_to_workspace:e.boolean().optional(),experimental_features_enabled:e.boolean().optional(),onboarded_at:e.union([e.literal("now"),e.null()]).optional(),display_name:e.string().min(1).max(120).optional(),handle:hr.optional(),bio:e.string().max(280).nullable().optional(),avatar_storage_url:e.string().min(1).nullable().optional(),banner_storage_url:e.string().min(1).nullable().optional()}).refine(r=>Object.keys(r).length>0,{message:"At least one field must be provided"}),_s=e.object({id:e.string(),display_name:e.string(),handle:e.string().nullable(),avatar_url:e.string().nullable(),visible_thread_count:e.number().int().nonnegative(),last_active_at:e.string().datetime().nullable()}),fr=e.object({id:e.string().min(1),display_name:e.string().min(1),handle:e.string().nullable(),bio:e.string().max(280).nullable(),avatar_url:e.string().nullable(),banner_url:e.string().nullable(),organization_name:e.string().min(1).nullable(),created_at:e.string().min(1),visible_thread_count:e.number().int().nonnegative(),follower_count:e.number().int().nonnegative(),following_count:e.number().int().nonnegative(),published_project_count:e.number().int().nonnegative(),is_following:e.boolean(),is_self:e.boolean()}),vs=e.object({type:e.literal("list"),list_type:e.literal("organization_member"),objects:e.array(_s)}),xs=e.object({email_address:e.string().email()}),Ss=e.object({email_address:e.string().email(),member_id:e.string().min(1)}),js=e.object({location:e.string().trim().min(1),contact:e.string().trim().email()}),ks=e.object({location:e.string().min(1),contact:e.string().email(),created_at:e.string().datetime()}),Ts=e.object({first_name:e.string().min(1),last_name:e.string().min(1),display_name:e.string().min(1),stytch_id:e.string().min(1).optional()}),Rs=e.object({name:e.string().min(1),email_domains:e.array(e.string().min(1)).nonempty(),stytch_org_id:e.string().min(1)}),ws=e.object({user:Ts,organization:Rs}),Cs=e.object({path_glob:e.string().min(1),name:e.string().min(1),description:e.string().min(1)}),zs=e.object({repo_origin_path:e.string().min(1),building_blocks:e.array(Cs)}),yr=e.string().regex(/^th_[0-9A-Za-z]{22}$/),st=e.string().regex(/^tb_[0-9A-Za-z]{22}$/),Ps=e.object({id:yr,author:e.object({id:e.string().min(1),display_name:e.string().min(1)}),body:e.string(),created_at:e.string().datetime(),repo_origin_path:e.string().min(1),latest_revision_id:st,revision_count:e.number().int().positive()}),Os=e.object({id:e.string().min(1),display_name:e.string().min(1)}),As=e.object({id:e.string().min(1),author_id:e.string().min(1).nullable(),author:Os.nullable(),created_at:e.string().datetime(),deleted_at:e.string().datetime().nullable(),content:e.string().min(1)}),Es=e.object({id:e.string().min(1),thread_block_id:e.string().min(1),created_at:e.string().datetime(),resolved_at:e.string().datetime().nullable(),comments:e.array(As)}),Is=e.object({thread_block_id:st,from_position:e.number().int().positive(),to_position:e.number().int().positive(),selected_text:e.string().min(1),content:e.string().trim().min(1)}),Ls=e.object({id:e.string().min(1)}),Ns=e.object({content:e.string().trim().min(1)}),Bs=e.object({id:e.string().min(1)}),$s=e.object({content:e.string().trim().min(1)}),Us=e.object({id:e.string().min(1)}),qs=e.object({content:e.string().trim().min(1)}),Ds=e.object({id:e.string().min(1)}),Ms=e.object({resolved:e.boolean()}),Fs=e.object({id:e.string().min(1),resolved_at:e.string().datetime().nullable()}),Vs=e.object({resolved:e.boolean()}),Zs=e.object({id:e.string().min(1),resolved_at:e.string().datetime().nullable()}),gr=e.record(e.unknown()),Gs=e.object({id:st,body:e.string(),created_at:e.string().datetime(),prosemirror_json:gr,comment_threads:e.array(Es)}),Hs=e.object({id:yr,created_at:e.string().datetime(),repo_origin_path:e.string().min(1),author:e.object({id:e.string().min(1),display_name:e.string().min(1)}),latest_revision_id:st,revision_count:e.number().int().positive(),revisions:e.array(Gs)}),Qs=e.object({type:e.literal("list"),list_type:e.literal("plan"),has_more:e.boolean(),objects:e.array(Ps)}),Ws=e.object({before:e.string().min(1).optional(),after:e.string().min(1).optional(),author_id:e.string().min(1).optional(),repo_origin_path:e.string().min(1).optional()}),br=e.object({id:e.string().min(1),organization_id:e.string().min(1),created_at:e.string().min(1),repo_origin_path:e.string().min(1),path_glob:e.string().min(1),name:e.string().min(1),description:e.string().min(1)}),Ks=e.array(br),Js=e.object({type:e.literal("list"),list_type:e.literal("building_block"),has_more:e.boolean(),objects:e.array(br)}),Ys=e.object({repo_origin_path:e.string().min(1),before:e.string().min(1).optional(),after:e.string().min(1).optional()}),Xs=e.enum(["thread","building_block"]),ei=e.object({repo_origin_path:e.string().min(1),sources:e.array(Xs).nonempty()}),ti=e.object({type:e.literal("list"),list_type:e.literal("repository"),has_more:e.boolean(),objects:e.array(ei)}),se=e.enum(["claudeCode","codex","amp","cursor","unspecified"]),ri=["transcript","plan"],ni=e.enum(ri),ai=e.object({md5:e.string().min(1),harness:se,filename:e.string().min(1).optional(),repo_origin_path:e.string().min(1).optional(),harness_internal_id:e.string().min(1).optional(),file_type:ni.optional()}).refine(r=>(r.filename?.trim().length??0)>0||(r.harness_internal_id?.trim().length??0)>0,{path:["harness_internal_id"],message:"filename or harness_internal_id is required"}),wt=e.object({id:e.string().min(1),display_name:e.string().min(1)}),si=e.object({id:e.string().min(1),display_name:e.string().min(1)}),_r=e.object({id:e.string().min(1),author_id:e.string().min(1).nullable(),author:si.nullable(),created_at:e.string().datetime(),deleted_at:e.string().datetime().nullable(),content:e.string().min(1)}),vr=e.object({id:e.string().min(1),thread_block_id:e.string().min(1),created_at:e.string().datetime(),resolved_at:e.string().datetime().nullable()}),ii=vr.extend({comments:e.array(_r)}),Me=e.object({id:e.string().min(1),type:e.string().min(1),index_in_thread:e.number().int().nonnegative(),isCritiqued:e.boolean(),comment_threads:e.array(ii).optional()}).passthrough(),xr=e.object({type:e.literal("list"),list_type:e.literal("thread_block"),has_more:e.boolean(),objects:e.array(Me)}),or=Me.extend({type:e.literal("plan"),prosemirror_json:gr,thread_file_id:e.string().min(1)}),oi=e.union([e.literal(-1),e.literal(1)]),Sr=e.union([e.literal(-1),e.literal(0),e.literal(1)]),cr=e.object({score:e.number().int(),up_count:e.number().int().nonnegative(),down_count:e.number().int().nonnegative(),viewer_vote:Sr}),ci=e.object({value:oi}),li=e.object({id:e.string().min(1),display_name:e.string().min(1),avatar_url:e.string().nullable()}),ke=e.object({id:e.string().min(1),thread_id:e.string().min(1),author_id:e.string().min(1).nullable(),author:li.nullable(),parent_comment_id:e.string().min(1).nullable(),content:e.string(),created_at:e.string().datetime(),updated_at:e.string().datetime(),deleted_at:e.string().datetime().nullable()}),di=e.object({type:e.literal("list"),list_type:e.literal("thread_comment"),objects:e.array(ke)}),pi=e.object({content:e.string().trim().min(1).max(4e3),parent_comment_id:e.string().min(1).optional()}),mi=ke,ui=e.object({content:e.string().trim().min(1).max(4e3)}),hi=ke,fi=ke,hl=e.discriminatedUnion("kind",[e.object({kind:e.literal("created"),thread_id:e.string().min(1),actor_user_id:e.string().min(1),version:e.number(),comment:ke}),e.object({kind:e.literal("updated"),thread_id:e.string().min(1),actor_user_id:e.string().min(1),version:e.number(),comment:ke}),e.object({kind:e.literal("deleted"),thread_id:e.string().min(1),actor_user_id:e.string().min(1),version:e.number(),comment:ke})]),yi=e.enum(["pending","generating","ready","failed"]),gi=e.enum(["pending","generating","ready","failed"]),bi=e.enum(["pending","placeholder","ai","user"]),jr=e.enum(["pending","generating","ready","failed"]),_i=e.enum(["asked","requested","decided","corrected","shared"]),vi=e.object({id:e.string().min(1),kind:_i,summary:e.string().min(1),block_id:e.string().min(1)}),xi=e.object({type:e.literal("list"),list_type:e.literal("thread_decision"),status:jr,generated_at:e.string().nullable(),objects:e.array(vi)}),Le=e.object({id:e.string().min(1),thread_file_id:e.string().min(1),organization_id:e.string().min(1),author:wt,repo:e.string().min(1),title:e.string().min(1),started_at:e.string().min(1),blocks:xr,user_message_count:e.number().int().nonnegative(),files_touched:e.array(e.string()),skills_invoked:e.array(e.string()),harness:se,transcript_parsing_state:e.enum(["pending","parsed","too_large_to_parse"]),visibility:e.enum(["private","workspace","public"]),has_plan:e.boolean().optional(),summary:e.string().nullable(),summary_status:yi,summary_generated_at:e.string().nullable(),title_status:gi,title_generated_at:e.string().nullable(),title_source:bi,decisions_status:jr,decisions_generated_at:e.string().nullable(),score:e.number().int(),up_count:e.number().int().nonnegative(),down_count:e.number().int().nonnegative(),viewer_vote:Sr,comment_count:e.number().int().nonnegative(),is_favorited:e.boolean()}),Si=e.object({storage_url:e.string().min(1)}),ji=e.object({storage_url:e.string(),harness:se,thread:Le.nullable()}),ki=e.object({status:e.literal("complete"),thread_files:e.array(ji)}),Ti=e.object({id:e.string(),presigned_url:e.string().nullable(),presigned_url_expires_at:e.string().nullable(),storage_url:e.string(),harness:se,expected_md5:e.string(),error:e.string().nullable(),thread:Le.nullable()}),Ri=e.object({id:e.string(),substrate:e.enum(["s3","filesystem"]),status:e.enum(["incomplete","locked_for_parsing","complete","error"]),thread_files:e.array(Ti)}),wi=e.object({visibility:e.enum(["private","workspace","public"]).optional(),title:e.string().trim().min(1).max(200).optional()}).refine(r=>r.visibility!==void 0||r.title!==void 0,{message:"At least one of visibility or title must be provided"}),Ci=e.discriminatedUnion("visibility",[e.object({visibility:e.literal("private")}),e.object({visibility:e.literal("workspace")}),e.object({visibility:e.literal("public"),title:e.string().min(1),author_display_name:e.string().min(1),first_user_message:e.string().nullable(),summary:e.string().nullable(),started_at:e.string().min(1),harness:se})]),zi=Le,lr=e.object({type:e.literal("list"),list_type:e.literal("thread"),has_more:e.boolean(),objects:e.array(zi)}),Pi=e.enum(["recent","popular"]),Oi=Le,Ai=e.object({type:e.literal("list"),list_type:e.literal("discover_thread"),has_more:e.boolean(),objects:e.array(Oi)}),Ei=e.object({before:e.string().min(1).optional(),after:e.string().min(1).optional(),sort:Pi.optional(),harness:se.optional(),search:e.string().max(200).optional()}),Ii=e.object({thread_count:e.number().int().nonnegative(),author_count:e.number().int().nonnegative(),organization_count:e.number().int().nonnegative(),harness_breakdown:e.record(se,e.number().int().nonnegative())}),Li=e.object({id:e.string(),status:e.enum(["incomplete","locked_for_parsing","complete","error"]),created_at:e.string(),thread_count:e.number().int().nonnegative()}),Ni=e.object({type:e.literal("list"),list_type:e.literal("upload_session"),objects:e.array(Li)}),Bi=e.object({before:e.string().min(1).optional(),after:e.string().min(1).optional()}),$i=e.object({before:e.string().min(1).optional(),after:e.string().min(1).optional(),author_ids:e.string().min(1).optional(),created_at:e.string().min(1).optional(),filepath_prefixes:e.string().min(1).optional()}),Ui=e.object({path:e.string().min(1),start_offset:e.number().int().nonnegative(),end_offset:e.number().int().positive()}),qi=e.object({name:e.string(),usage_count:e.number().int().nonnegative(),author_count:e.number().int().nonnegative(),first_used_at:e.string().nullable(),last_used_at:e.string().nullable(),usage_count_last_24h:e.number().int().nonnegative(),usage_count_last_7d:e.number().int().nonnegative()}),Di=e.object({type:e.literal("list"),list_type:e.literal("skill"),objects:e.array(qi)}),Mi=e.object({id:e.string(),title:e.string(),visibility:e.enum(["private","workspace","public"]),started_at:e.string(),author:wt,skills_invoked:e.array(e.string())}),Fi=e.object({name:e.string(),usage_count:e.number().int().nonnegative(),author_count:e.number().int().nonnegative(),first_used_at:e.string().nullable(),last_used_at:e.string().nullable(),threads:e.array(Mi)}),Vi=e.object({path:e.string().min(1),text:e.string().max(64e3)}),Zi=e.enum(["text_edit","redact","delete_block"]),Gi=e.object({id:e.string(),thread_block_id:e.string(),editor:e.object({id:e.string(),display_name:e.string()}),kind:Zi,path:e.string().nullable(),previous_text:e.string().nullable(),new_text:e.string().nullable(),created_at:e.string()}),Hi=e.object({type:e.literal("list"),list_type:e.literal("thread_block_edit"),objects:e.array(Gi)}),Qi=e.object({organization_count:e.number().int().nonnegative(),user_count:e.number().int().nonnegative(),thread_count:e.number().int().nonnegative(),thread_count_last_24h:e.number().int().nonnegative(),user_count_last_24h:e.number().int().nonnegative()}),Wi=e.object({id:e.string(),name:e.string(),email_domains:e.array(e.string()),stytch_org_id:e.string(),member_count:e.number().int().nonnegative(),thread_count:e.number().int().nonnegative(),default_thread_visibility:e.enum(["private","workspace","public"]),created_at:e.string()}),Ki=e.object({type:e.literal("list"),list_type:e.literal("admin_organization"),objects:e.array(Wi)}),kr=e.object({id:e.string(),name:e.string()}),Ji=e.object({id:e.string(),display_name:e.string(),stytch_id:e.string().nullable(),thread_count:e.number().int().nonnegative(),onboarded_at:e.string().nullable(),created_at:e.string(),organizations:e.array(kr)}),Yi=e.object({type:e.literal("list"),list_type:e.literal("admin_user"),objects:e.array(Ji)}),Xi=e.object({id:e.string(),title:e.string(),started_at:e.string(),created_at:e.string(),deleted_at:e.string().nullable(),visibility:e.enum(["private","workspace","public"]),harness:se,author:wt,organization:kr}),eo=e.object({type:e.literal("list"),list_type:e.literal("admin_thread"),has_more:e.boolean(),objects:e.array(Xi)}),to=e.object({before:e.string().min(1).optional(),after:e.string().min(1).optional()}),dr=e.object({token:e.string().min(1),thread_id:e.string().min(1)}),ro=e.object({visitor:e.string().min(1).max(64).optional()}),no=e.object({user_id:e.string(),display_name:e.string(),shares_sent:e.number().int().nonnegative(),unique_viewers:e.number().int().nonnegative(),attributed_signups:e.number().int().nonnegative()}),ao=e.object({window_days:e.number().int().positive(),shares_sent:e.number().int().nonnegative(),unique_viewers:e.number().int().nonnegative(),attributed_signups:e.number().int().nonnegative(),active_sharers:e.number().int().nonnegative(),k_factor:e.number().nullable(),shares_sent_sparkline:e.array(e.number().int().nonnegative()),top_sharers:e.array(no)}),so=e.object({windows:e.array(ao)}),io=e.object({quoted_text:e.string().min(1),comment:e.string().nullable(),type:e.enum(["comment","highlight:trapdoor"])}),oo=vr,co=_r.extend({comment_thread_id:e.string().min(1)}),lo=e.object({markdown:e.string().min(1)}),po=e.object({storage_url:e.string().min(1),thread_file_id:e.string().min(1),parsed_plan_block:or,critiqued_plan_block:or,annotations:e.array(io),comment_threads:e.array(oo),comments:e.array(co)}),Ne=e.enum(vt),Tr=e.object({skills:e.boolean(),workspace_scope:e.boolean(),review:e.boolean(),shared_thread_ttl_days:e.number().int().positive().nullable()}),Rt=e.object({subject_type:e.enum(["user","organization"]),subject_id:e.string().min(1),effective_plan:Ne,admin_override:Ne.nullable(),stripe_subscription_status:e.string().nullable(),cancel_at_period_end:e.boolean(),current_period_end:e.string().nullable(),seat_quantity:e.number().int().positive(),member_count:e.number().int().nonnegative().nullable(),features:Tr}),mo=e.object({effective_plan:Ne,features:Tr,user:Rt,organization:Rt.nullable()}),uo=e.object({plan:e.enum(["creator","team"]),seat_quantity:e.number().int().positive().optional()}),ho=e.object({checkout_url:e.string().min(1)}),fo=e.object({portal_url:e.string().min(1)}),yo=e.object({seat_quantity:e.number().int().positive()}),pr=e.object({plan:Ne.nullable()}),at=e.object({subject_type:e.enum(["user","organization"]),subject_id:e.string().min(1),label:e.string().min(1),effective_plan:Ne,admin_override:Ne.nullable(),stripe_subscription_status:e.string().nullable(),seat_quantity:e.number().int().positive()}),go=e.object({users:e.array(at),organizations:e.array(at)}),bo=e.object({id:e.string().min(1),display_name:e.string().min(1),handle:e.string().nullable(),avatar_url:e.string().nullable()}),_o=e.object({thread_id:e.string().min(1),title:e.string().min(1),author:bo,last_active_at:e.string().datetime(),last_block_excerpt:e.string().nullable(),last_block_kind:e.string().min(1).nullable(),is_streaming:e.boolean()}),vo=e.object({type:e.literal("list"),list_type:e.literal("live_thread"),objects:e.array(_o)}),xo=e.object({thread_id:e.string().min(1)}),So=e.object({thread_id:e.string().min(1),last_seen_at:e.string().datetime(),started_at:e.string().datetime()}),jo=e.object({follower_id:e.string().min(1),followee_id:e.string().min(1),is_following:e.literal(!0),follower_count:e.number().int().nonnegative()}),ko=e.object({follower_id:e.string().min(1),followee_id:e.string().min(1),is_following:e.literal(!1),follower_count:e.number().int().nonnegative()}),Rr=e.object({id:e.string().min(1),display_name:e.string().min(1),handle:e.string().nullable(),avatar_url:e.string().nullable(),bio:e.string().max(280).nullable(),is_following:e.boolean(),is_self:e.boolean()}),mr=e.object({type:e.literal("list"),list_type:e.literal("user_follow"),objects:e.array(Rr)}),To=e.object({date:e.string().regex(/^\d{4}-\d{2}-\d{2}$/),count:e.number().int().nonnegative()}),Ro=e.object({window_start:e.string().datetime(),window_end:e.string().datetime(),total_contributions:e.number().int().nonnegative(),days_active:e.number().int().nonnegative(),daily_average:e.number().nonnegative(),current_streak_days:e.number().int().nonnegative(),days:e.array(To)}),wo=e.object({type:e.literal("thread_created"),occurred_at:e.string().datetime(),id:e.string().min(1),thread:e.object({id:e.string().min(1),title:e.string(),visibility:e.enum(["private","workspace","public"])})}),Co=e.object({type:e.literal("comment_posted"),occurred_at:e.string().datetime(),id:e.string().min(1),comment_excerpt:e.string(),thread:e.object({id:e.string().min(1),title:e.string(),visibility:e.enum(["private","workspace","public"])})}),zo=e.object({type:e.literal("project_published"),occurred_at:e.string().datetime(),id:e.string().min(1),project:e.object({id:e.string().min(1),name:e.string().min(1)})}),Po=e.object({type:e.literal("user_followed"),occurred_at:e.string().datetime(),id:e.string().min(1),followee:Rr}),Oo=e.discriminatedUnion("type",[wo,Co,zo,Po]),Ao=e.object({type:e.literal("list"),list_type:e.literal("user_activity"),objects:e.array(Oo)}),Eo=e.object({id:e.string().min(1),name:e.string().min(1),excerpt:e.string(),published_at:e.string().datetime(),updated_at:e.string().datetime()}),Io=e.object({type:e.literal("list"),list_type:e.literal("profile_published_project"),objects:e.array(Eo)}),ur=e.object({id:e.string().min(1),published_at:e.string().datetime().nullable()}),Lo=e.enum(["avatar","banner"]),No=e.enum(["image/png","image/jpeg","image/webp","image/gif"]),Bo=e.object({kind:Lo,content_type:No,base64_data:e.string().min(1)}),$o=e.object({substrate:e.enum(["s3","filesystem"]),storage_url:e.string().min(1)}),Uo=fr,wr=us.router({health:{method:"GET",path:"/health",responses:{200:e.object({status:e.literal("ok")})},summary:"Health check"},whoAmI:{method:"GET",path:"/whoami",headers:e.object({authorization:e.string().min(1).optional(),"x-lore-referral-token":e.string().min(1).max(16).optional()}),responses:{200:gs,401:l},summary:"Validate a Stytch B2B Bearer token and return member plus user fields"},recordHeartbeat:{method:"POST",path:"/heartbeat",headers:e.object({authorization:e.string().min(1).optional()}),body:xo,responses:{200:So,401:l,403:l,404:l,422:l},summary:"Record (or refresh) a presence heartbeat for the authenticated user against one of their own threads. Idempotent; the daemon should call this every ~30s while a session is open."},listLiveThreads:{method:"GET",path:"/threads/live",headers:e.object({authorization:e.string().min(1).optional()}),responses:{200:vo,401:l,403:l},summary:"List teammates with activity in the last 5 minutes. Excludes the requester. Org-scoped, deduped per author, max 10."},listThreads:{method:"GET",path:"/threads",headers:e.object({authorization:e.string().min(1).optional()}),query:$i,responses:{200:lr,401:l},summary:"List threads visible to the authenticated user"},getThread:{method:"GET",path:"/threads/:id",pathParams:e.object({id:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),responses:{200:Le,404:l},summary:"Load a visible thread by id"},getSimilarThreads:{method:"GET",path:"/threads/:id/similar",pathParams:e.object({id:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),responses:{200:lr,404:l,409:l},summary:"List the top 20 visible threads with the closest summary embedding"},listThreadBlocks:{method:"GET",path:"/threads/:id/blocks",pathParams:e.object({id:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),query:Bi,responses:{200:xr,401:l},summary:"List blocks for a visible thread"},createThreadBlockCommentThread:{method:"POST",path:"/threads/:threadId/blocks/:blockId/comment-threads",pathParams:e.object({threadId:e.string().min(1),blockId:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),body:Ns,responses:{201:Bs,401:l,404:l},summary:"Create a new block-level comment thread on a visible thread block"},createThreadBlockComment:{method:"POST",path:"/threads/:threadId/blocks/:blockId/comment-threads/:commentThreadId/comments",pathParams:e.object({threadId:e.string().min(1),blockId:e.string().min(1),commentThreadId:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),body:qs,responses:{201:Ds,401:l,404:l,409:l},summary:"Reply to a block-level comment thread on a visible thread block"},updateThreadBlockCommentThread:{method:"PATCH",path:"/threads/:threadId/blocks/:blockId/comment-threads/:commentThreadId",pathParams:e.object({threadId:e.string().min(1),blockId:e.string().min(1),commentThreadId:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),body:Vs,responses:{200:Zs,401:l,404:l},summary:"Resolve or reopen a block-level comment thread on a visible thread block"},listSkills:{method:"GET",path:"/skills",headers:e.object({authorization:e.string().min(1).optional()}),responses:{200:Di,401:l},summary:"Aggregate skill usage across threads the viewer can see"},getSkillDetail:{method:"GET",path:"/skills/:name",pathParams:e.object({name:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),responses:{200:Fi,401:l,404:l},summary:"Per-skill detail: usage stats + visible threads that invoked it"},redactThreadBlock:{method:"POST",path:"/threads/:threadId/blocks/:blockId/redactions",pathParams:e.object({threadId:e.string().min(1),blockId:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),body:Ui,responses:{200:Me,401:l,403:l,404:l,422:l},summary:"Permanently redact a character range within a text field of a thread block (author only)"},updateThreadBlockText:{method:"PATCH",path:"/threads/:threadId/blocks/:blockId/text",pathParams:e.object({threadId:e.string().min(1),blockId:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),body:Vi,responses:{200:Me,401:l,403:l,404:l,422:l},summary:"Replace a single text leaf in a thread block with new content (author only)"},critiqueThreadBlock:{method:"POST",path:"/threads/:threadId/blocks/:blockId/critique",pathParams:e.object({threadId:e.string().min(1),blockId:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),body:e.object({}).optional(),responses:{200:Me,401:l,403:l,404:l,409:l,422:l},summary:"Critique a plan block once and persist its annotations as nested comment threads (author only)"},deleteThreadBlock:{method:"DELETE",path:"/threads/:threadId/blocks/:blockId",pathParams:e.object({threadId:e.string().min(1),blockId:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),body:e.object({}).optional(),responses:{204:e.null(),401:l,403:l,404:l},summary:"Soft-delete a thread block (author only)"},listThreadBlockEdits:{method:"GET",path:"/threads/:threadId/blocks/:blockId/edits",pathParams:e.object({threadId:e.string().min(1),blockId:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),responses:{200:Hi,401:l,404:l},summary:"List edits made to a thread block (visible to anyone who can see the thread)"},listThreadDecisions:{method:"GET",path:"/threads/:id/decisions",pathParams:e.object({id:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),responses:{200:xi,401:l,404:l},summary:"List AI-extracted user decisions for a thread, in chronological order"},updateThread:{method:"PATCH",path:"/threads/:id",pathParams:e.object({id:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),body:wi,responses:{200:Le,401:l,403:l,404:l},summary:"Update thread visibility (author only)"},deleteThread:{method:"DELETE",path:"/threads/:id",pathParams:e.object({id:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),body:e.object({}).optional(),responses:{204:e.null(),401:l,403:l,404:l},summary:"Soft-delete a thread (author only)"},castThreadVote:{method:"PUT",path:"/threads/:id/vote",pathParams:e.object({id:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),body:ci,responses:{200:cr,401:l,403:l,404:l,422:l},summary:"Cast or change the caller's up/down vote on a public thread. Idempotent \u2014 re-casting the same value is a no-op."},clearThreadVote:{method:"DELETE",path:"/threads/:id/vote",pathParams:e.object({id:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),body:e.object({}).optional(),responses:{200:cr,401:l,404:l},summary:"Clear the caller's vote on a thread. No-op when the caller hasn't voted."},listThreadComments:{method:"GET",path:"/threads/:threadId/comments",pathParams:e.object({threadId:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),responses:{200:di,403:l,404:l},summary:"List all (live + soft-deleted as tombstones) comments on a public thread, flat with parent_comment_id pointers."},createThreadComment:{method:"POST",path:"/threads/:threadId/comments",pathParams:e.object({threadId:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),body:pi,responses:{201:mi,401:l,403:l,404:l,422:l},summary:"Post a top-level or reply comment on a public thread."},updateThreadComment:{method:"PATCH",path:"/threads/:threadId/comments/:commentId",pathParams:e.object({threadId:e.string().min(1),commentId:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),body:ui,responses:{200:hi,401:l,403:l,404:l,422:l},summary:"Edit your own thread comment (author only; rejects edits to soft-deleted rows)."},deleteThreadComment:{method:"DELETE",path:"/threads/:threadId/comments/:commentId",pathParams:e.object({threadId:e.string().min(1),commentId:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),body:e.object({}).optional(),responses:{200:fi,401:l,403:l,404:l},summary:"Soft-delete your own thread comment (author only). Idempotent."},getThreadPreview:{method:"GET",path:"/threads/:id/preview",pathParams:e.object({id:e.string().min(1)}),responses:{200:Ci,404:l},summary:"Unauthenticated, visibility-redacted metadata for OG / social preview consumers"},createUser:{method:"POST",path:"/users",headers:e.object({authorization:e.string().min(1).optional()}),body:ws,responses:{201:Tt,401:l},summary:"Create a user record with ApiKey authentication"},getUser:{method:"GET",path:"/users/:id",pathParams:e.object({id:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),responses:{200:fr,404:l},summary:"Public profile for a user. Optional auth \u2014 unauthenticated viewers see only public thread metadata; signed-in viewers see counts scoped to the threads they'd normally be able to access."},updateCurrentUser:{method:"PATCH",path:"/users/me",headers:e.object({authorization:e.string().min(1).optional()}),body:bs,responses:{200:Tt,401:l,409:l,422:l},summary:"Update the authenticated user profile"},getUserByHandle:{method:"GET",path:"/users/by-handle/:handle",pathParams:e.object({handle:hr}),headers:e.object({authorization:e.string().min(1).optional()}),responses:{200:Uo,404:l},summary:"Resolve a public profile by handle \u2014 same shape as GET /users/:id but keyed on the user's chosen handle."},listUserActivity:{method:"GET",path:"/users/:id/activity",pathParams:e.object({id:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),query:e.object({limit:e.coerce.number().int().positive().max(100).optional()}),responses:{200:Ao,404:l},summary:"Reverse-chronological activity feed for a user, scoped to what the viewer can see (same visibility rules as listThreads)."},getUserContributions:{method:"GET",path:"/users/:id/contributions",pathParams:e.object({id:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),responses:{200:Ro,404:l},summary:"Daily contribution counts for the trailing 365 days \u2014 counts thread blocks the user authored on threads visible to the viewer."},listUserFollowers:{method:"GET",path:"/users/:id/followers",pathParams:e.object({id:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),responses:{200:mr,404:l},summary:"List the users following a given user."},listUserFollowing:{method:"GET",path:"/users/:id/following",pathParams:e.object({id:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),responses:{200:mr,404:l},summary:"List the users a given user is following."},followUser:{method:"POST",path:"/users/:id/follow",pathParams:e.object({id:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),body:e.object({}).optional(),responses:{200:jo,401:l,404:l,409:l,422:l},summary:"Follow another user. Idempotent \u2014 repeating the call is a no-op."},unfollowUser:{method:"DELETE",path:"/users/:id/follow",pathParams:e.object({id:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),body:e.object({}).optional(),responses:{200:ko,401:l,404:l},summary:"Unfollow a user. Idempotent \u2014 repeating the call is a no-op."},listProfilePublishedProjects:{method:"GET",path:"/users/:id/projects",pathParams:e.object({id:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),responses:{200:Io,404:l},summary:"Projects the user has published to their public profile."},publishProject:{method:"POST",path:"/projects/:id/publish",pathParams:e.object({id:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),body:e.object({}).optional(),responses:{200:ur,401:l,403:l,404:l},summary:"Publish a project to the author's public profile. Stamps published_at with `now()`. Author-only."},unpublishProject:{method:"DELETE",path:"/projects/:id/publish",pathParams:e.object({id:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),body:e.object({}).optional(),responses:{200:ur,401:l,403:l,404:l},summary:"Remove a project from the author's public profile."},uploadProfileImage:{method:"POST",path:"/users/me/profile-image",headers:e.object({authorization:e.string().min(1).optional()}),body:Bo,responses:{200:$o,401:l,413:l,422:l},summary:"Upload an avatar or banner image (base64-encoded JSON body). The API streams the bytes to its configured storage substrate using its own credentials and returns the canonical storage URL the client passes to PATCH /users/me."},listOrganizationMembers:{method:"GET",path:"/organization/members",headers:e.object({authorization:e.string().min(1).optional()}),responses:{200:vs,401:l},summary:"List members of the authenticated user\u2019s organization"},createOrganizationInvite:{method:"POST",path:"/organization/invites",headers:e.object({authorization:e.string().min(1).optional()}),body:xs,responses:{201:Ss,401:l,403:l,409:l,422:l},summary:"Invite a teammate to the authenticated user\u2019s workspace via Stytch B2B"},listRepositories:{method:"GET",path:"/repositories",headers:e.object({authorization:e.string().min(1).optional()}),responses:{200:ti,401:l,403:l},summary:"List repositories known to the authenticated user\u2019s organization across threads and building blocks"},createBuildingBlockSnapshots:{method:"POST",path:"/building_blocks",headers:e.object({authorization:e.string().min(1).optional()}),body:zs,responses:{201:Ks,401:l,403:l},summary:"Create building block snapshots for the authenticated user\u2019s organization"},getPlan:{method:"GET",path:"/plans/:id",pathParams:e.object({id:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),responses:{200:Hs,401:l,403:l,404:l},summary:"Load a thread-backed plan container visible to the authenticated user, including all visible plan revisions in that thread"},createPlanCommentThread:{method:"POST",path:"/plans/:id/comment-threads",pathParams:e.object({id:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),body:Is,responses:{201:Ls,401:l,403:l,404:l,422:l},summary:"Create a new inline comment thread on a specific revision inside a thread-backed plan container"},createPlanComment:{method:"POST",path:"/plans/:id/comment-threads/:threadId/comments",pathParams:e.object({id:e.string().min(1),threadId:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),body:$s,responses:{201:Us,401:l,403:l,404:l,409:l},summary:"Reply to an inline comment thread on a thread-backed plan container"},updatePlanCommentThread:{method:"PATCH",path:"/plans/:id/comment-threads/:threadId",pathParams:e.object({id:e.string().min(1),threadId:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),body:Ms,responses:{200:Fs,401:l,403:l,404:l},summary:"Resolve or reopen an inline comment thread on a thread-backed plan container"},listPlans:{method:"GET",path:"/plans",headers:e.object({authorization:e.string().min(1).optional()}),query:Ws,responses:{200:Qs,401:l,403:l},summary:"List thread-backed plan containers visible to the authenticated user in their organization, ordered by latest visible revision and optionally filtered by author or repository"},listBuildingBlockSnapshots:{method:"GET",path:"/building_blocks",headers:e.object({authorization:e.string().min(1).optional()}),query:Ys,responses:{200:Js,401:l,403:l},summary:"List building block snapshots for the authenticated user\u2019s organization and repo origin path"},listUploadSessions:{method:"GET",path:"/upload_sessions",headers:e.object({authorization:e.string().min(1).optional()}),responses:{200:Ni,401:l},summary:"List recent upload sessions for the authenticated user"},createUploadSession:{method:"POST",path:"/upload_sessions",headers:e.object({authorization:e.string().min(1).optional()}),body:e.object({thread_files:e.array(ai).nonempty()}),responses:{201:Ri,400:l,401:l},summary:"Create an upload session with presigned URLs for file uploads"},completeUploadSession:{method:"POST",path:"/upload_sessions/:id/complete",pathParams:e.object({id:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),body:e.object({thread_files:e.array(Si).nonempty()}),responses:{200:ki,400:l,401:l,404:l,409:l,422:l},summary:"Complete an upload session after files have been uploaded to storage"},adminStats:{method:"GET",path:"/admin/stats",headers:e.object({authorization:e.string().min(1).optional()}),responses:{200:Qi,401:l,403:l},summary:"Cross-org operational counts. Tanagram admins only."},adminListOrganizations:{method:"GET",path:"/admin/organizations",headers:e.object({authorization:e.string().min(1).optional()}),responses:{200:Ki,401:l,403:l},summary:"List every organization with member and thread counts. Tanagram admins only."},adminListUsers:{method:"GET",path:"/admin/users",headers:e.object({authorization:e.string().min(1).optional()}),responses:{200:Yi,401:l,403:l},summary:"List every user with their org memberships and thread count. Tanagram admins only."},adminListThreads:{method:"GET",path:"/admin/threads",headers:e.object({authorization:e.string().min(1).optional()}),query:to,responses:{200:eo,401:l,403:l},summary:"List live threads across every organization. Tanagram admins only."},adminHardDeleteThread:{method:"DELETE",path:"/admin/threads/:id",pathParams:e.object({id:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),body:e.object({}).optional(),responses:{204:e.null(),401:l,403:l,404:l},summary:"Permanently remove a thread. Tanagram admins only."},listDiscoverThreads:{method:"GET",path:"/discover/threads",headers:e.object({authorization:e.string().min(1).optional()}),query:Ei,responses:{200:Ai},summary:"Feed of public threads with sort, harness filter, search, and cursor pagination. Auth is optional and populates viewer_vote."},discoverStats:{method:"GET",path:"/discover/stats",responses:{200:Ii},summary:"Unauthenticated rollup of public-thread counts for the Discover header."},createWaitlistEntry:{method:"POST",path:"/waitlist_entries",body:js,responses:{201:ks,409:l},summary:"Create an unauthenticated waitlist entry keyed by (location, contact)."},createShareToken:{method:"POST",path:"/threads/:id/share-token",pathParams:e.object({id:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),body:e.object({}).optional(),responses:{201:dr,401:l,403:l,404:l,409:l},summary:"Mint a short share-link token for a public thread. Author only. The token powers `/s/:token` short URLs and enables k-factor attribution."},resolveShareToken:{method:"GET",path:"/referrals/resolve/:token",pathParams:e.object({token:e.string().min(1).max(16)}),query:ro,responses:{200:dr,404:l},summary:"Resolve a share-link token to its thread and record the view. Unauthenticated by design."},adminGrowth:{method:"GET",path:"/admin/growth",headers:e.object({authorization:e.string().min(1).optional()}),responses:{200:so,401:l,403:l},summary:"Share-link k-factor, funnel, sparkline, and top sharers by window. Tanagram admins only."},adminRunCritiquePlayground:{method:"POST",path:"/admin/critique-playground/run",headers:e.object({authorization:e.string().min(1).optional()}),body:lo,responses:{200:po,401:l,403:l,409:l},summary:"Admin-only critique playground that saves markdown to a file:// plan artifact and returns parsed + critiqued plan blocks."},getBillingState:{method:"GET",path:"/billing/state",headers:e.object({authorization:e.string().min(1).optional()}),responses:{200:mo,401:l},summary:"Resolve the caller's plan, features, seat count, and any admin override."},createBillingCheckout:{method:"POST",path:"/billing/checkout",headers:e.object({authorization:e.string().min(1).optional()}),body:uo,responses:{200:ho,400:l,401:l,403:l,503:l},summary:"Start a Stripe Checkout session for Creator ($29/mo) or Team ($19/seat/mo, min 2)."},createBillingPortal:{method:"POST",path:"/billing/portal",headers:e.object({authorization:e.string().min(1).optional()}),body:e.object({subject_type:e.enum(["user","organization"]).default("user")}).optional(),responses:{200:fo,401:l,404:l,503:l},summary:"Open the Stripe customer portal so the subject can manage their subscription."},updateTeamSeats:{method:"PATCH",path:"/billing/team-seats",headers:e.object({authorization:e.string().min(1).optional()}),body:yo,responses:{200:Rt,400:l,401:l,403:l,404:l,503:l},summary:"Adjust the caller-organization's Team seat quantity (admin of that org only)."},adminListBilling:{method:"GET",path:"/admin/billing",headers:e.object({authorization:e.string().min(1).optional()}),responses:{200:go,401:l,403:l},summary:"List every user and org with current plan + override for the admin panel."},adminSetUserPlanOverride:{method:"PUT",path:"/admin/billing/users/:id/override",pathParams:e.object({id:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),body:pr,responses:{200:at,401:l,403:l,404:l},summary:"Admin override for a user's plan tier. Null clears the override."},adminSetOrganizationPlanOverride:{method:"PUT",path:"/admin/billing/organizations/:id/override",pathParams:e.object({id:e.string().min(1)}),headers:e.object({authorization:e.string().min(1).optional()}),body:pr,responses:{200:at,401:l,403:l,404:l},summary:"Admin override for an organization's plan tier. Null clears the override."},projects:nr,docs:tr,mentions:ar,favorites:ir},{pathPrefix:"/api"});var qo="prod";function X(){return qo}var Do={dev:"http://localhost:4000",prod:"https://lore.tanagram.ai"};function Cr(){return _t(wr,{baseUrl:Do[X()],baseHeaders:{}})}import Ar from"node:fs";import Mo from"node:os";import zr from"node:path";function Ct(){let r=X()==="dev"?".lore-dev":".lore";return zr.join(Mo.homedir(),r)}function it(){return zr.join(Ct(),"log.txt")}var Pr=!1;function Fo(){Pr||(Ar.mkdirSync(Ct(),{recursive:!0}),Pr=!0)}function Vo(r){let t=typeof r=="string"?r:JSON.stringify(r);return/[\s"=]/.test(t)?JSON.stringify(t):t}function Zo(r,t,n){let a=`${new Date().toISOString()} ${r} ${t}`;if(!n)return`${a}
|
|
7
|
+
`;let s=Object.entries(n).map(([i,c])=>`${i}=${Vo(c)}`).join(" ");return s?`${a} ${s}
|
|
8
|
+
`:`${a}
|
|
9
|
+
`}function Or(r,t,n){let a=Zo(r,t,n);Fo(),Ar.appendFileSync(it(),a),X()==="dev"&&process.stderr.write(a)}var Te={info(r,t){Or("info",r,t)},error(r,t){Or("error",r,t)}};var Er={meta:{name:"health",description:"Check API health"},async run({data:r}){Te.info("command_start",{command:"health"});let n=await(r?.client??Cr()).health();if(n.status===200){console.log(n.body.status);return}throw Te.error("health_failed",{status:n.status}),console.error(`health check failed: HTTP ${n.status}`),new Error(`health check failed: HTTP ${n.status}`)}};var Ir={meta:{name:"hello",description:"Print a friendly greeting"},run(){Te.info("command_start",{command:"hello"}),console.log("hello world")}};var Lr={meta:{name:"logs",description:"Print the path to the log file"},run(){Te.info("command_start",{command:"logs"}),console.log(it())}};import{promises as ie}from"node:fs";import Go from"node:os";import Re from"node:path";import{fileURLToPath as Nr}from"node:url";function zt(){return Re.join(Go.homedir(),".claude","skills")}function Br(r){return r.map(t=>t.name).sort().join(", ")}function $r(r){return r[0]?Re.dirname(r[0].destination):zt()}async function Ho(r){try{return(await ie.stat(r)).isDirectory()}catch(t){if(t.code==="ENOENT")return!1;throw t}}async function Ur(){let r=[Nr(new URL("../skills",import.meta.url)),Nr(new URL("../../skills",import.meta.url))];for(let t of r)if(await Ho(t))return t;throw new Error("bundled skills directory not found")}function Qo(r,t){let n=r.match(/^(---\r?\n)([\s\S]*?)(\r?\n---(?:\r?\n|$))/);if(!n)throw new Error("skill file is missing frontmatter");let[,a,s,i]=n,c=s.replace(/^name: .*$/m,`name: ${t}`);if(c===s)throw new Error("skill file frontmatter is missing a name");return`${a}${c}${i}${r.slice(n[0].length)}`}async function Wo({destination:r=zt(),environment:t=X(),sourceDir:n}={}){let a=n??await Ur(),s=(await ie.readdir(a,{withFileTypes:!0})).filter(o=>o.isDirectory()),i=t==="prod"?"":`-${t}`,c=[];await ie.mkdir(r,{recursive:!0});for(let o of s){let d=`${o.name}${i}`,p=Re.join(a,o.name),u=Re.join(r,d);if(await ie.cp(p,u,{recursive:!0,force:!0}),i){let T=Re.join(u,"SKILL.md"),R=await ie.readFile(T,"utf8");await ie.writeFile(T,Qo(R,d))}c.push({name:d,source:p,destination:u})}return c}async function Ko({destination:r=zt(),environment:t=X(),sourceDir:n}={}){let a=n??await Ur(),s=(await ie.readdir(a,{withFileTypes:!0})).filter(o=>o.isDirectory()),i=t==="prod"?"":`-${t}`,c=[];for(let o of s){let d=`${o.name}${i}`,p=Re.join(a,o.name),u=Re.join(r,d);await ie.rm(u,{recursive:!0,force:!0}),c.push({name:d,source:p,destination:u})}return c}var qr={meta:{name:"postinstall:install-skills",hidden:!0},args:{destination:{type:"positional",required:!1,description:"Install destination"}},async run({args:r}){let t=await Wo({destination:r.destination});console.log(`installed skills ${Br(t)} to ${$r(t)}`)}},Dr={meta:{name:"postinstall:uninstall-skills",hidden:!0},args:{destination:{type:"positional",required:!1,description:"Install destination"}},async run({args:r}){let t=await Ko({destination:r.destination});console.log(`uninstalled skills ${Br(t)} from ${$r(t)}`)}};var Yo={meta:{name:"lore",description:"Lore CLI"},subCommands:{hello:Ir,health:Er,logs:Lr,"postinstall:install-skills":qr,"postinstall:uninstall-skills":Dr},default:"hello"};process.argv[1]&&import.meta.url===Jo(process.argv[1]).href&&Nt(Yo);export{Yo as mainCommand};
|
package/package.json
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanagram/lore",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Lore CLI",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
7
|
"lore": "./dist/index.js"
|
|
8
8
|
},
|
|
9
9
|
"files": [
|
|
10
|
-
"dist"
|
|
10
|
+
"dist",
|
|
11
|
+
"skills",
|
|
12
|
+
"scripts/runPostinstallCommand.mjs"
|
|
11
13
|
],
|
|
12
14
|
"publishConfig": {
|
|
13
15
|
"access": "public"
|
|
14
16
|
},
|
|
15
17
|
"devDependencies": {
|
|
18
|
+
"@biomejs/biome": "^1.9.4",
|
|
16
19
|
"@ts-rest/core": "^3.52.1",
|
|
17
20
|
"@types/node": "^22.16.5",
|
|
18
21
|
"esbuild": "^0.24.0",
|
|
@@ -24,11 +27,12 @@
|
|
|
24
27
|
"citty": "^0.2.2"
|
|
25
28
|
},
|
|
26
29
|
"scripts": {
|
|
27
|
-
"dev": "tsx src/index.ts",
|
|
30
|
+
"dev": "pnpm run postinstall && tsx src/index.ts",
|
|
31
|
+
"postinstall": "node scripts/runPostinstallCommand.mjs postinstall:install-skills",
|
|
28
32
|
"build": "esbuild src/index.ts --bundle --platform=node --format=esm --target=node20 --outfile=dist/index.js && chmod +x dist/index.js",
|
|
29
33
|
"build:prod": "esbuild src/index.ts --bundle --minify --legal-comments=none --platform=node --format=esm --target=node20 --define:process.env.LORE_BUILD_ENV='\"prod\"' --outfile=dist/index.js && chmod +x dist/index.js",
|
|
30
34
|
"start": "node dist/index.js",
|
|
31
|
-
"lint": "
|
|
35
|
+
"lint": "biome check src",
|
|
32
36
|
"typecheck": "tsc --noEmit",
|
|
33
37
|
"test": "tsx --test src/*.test.ts src/**/*.test.ts"
|
|
34
38
|
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { spawnSync } from 'node:child_process';
|
|
3
|
+
import { existsSync } from 'node:fs';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
6
|
+
|
|
7
|
+
const allowedCommands = new Set([
|
|
8
|
+
'postinstall:install-skills',
|
|
9
|
+
'postinstall:uninstall-skills',
|
|
10
|
+
]);
|
|
11
|
+
|
|
12
|
+
const command = process.argv[2];
|
|
13
|
+
const commandArgs = process.argv.slice(3);
|
|
14
|
+
|
|
15
|
+
if (!allowedCommands.has(command)) {
|
|
16
|
+
console.error(
|
|
17
|
+
`expected one of ${Array.from(allowedCommands).join(', ')}, got ${command ?? 'nothing'}`,
|
|
18
|
+
);
|
|
19
|
+
process.exit(1);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const packageRoot = fileURLToPath(new URL('..', import.meta.url));
|
|
23
|
+
const distEntrypoint = path.join(packageRoot, 'dist', 'index.js');
|
|
24
|
+
const sourceEntrypoint = path.join(packageRoot, 'src', 'index.ts');
|
|
25
|
+
const localTsxBin = path.join(
|
|
26
|
+
packageRoot,
|
|
27
|
+
'node_modules',
|
|
28
|
+
'.bin',
|
|
29
|
+
process.platform === 'win32' ? 'tsx.cmd' : 'tsx',
|
|
30
|
+
);
|
|
31
|
+
// If `sourceEntrypoint` exists, run that; otherwise run `distEntrypoint`.
|
|
32
|
+
// `src` is not distributed through NPM, so in prod only `distEntrypoint` will exist.
|
|
33
|
+
// This may be brittle for other environments if/when we introduce other environments.
|
|
34
|
+
// https://ampcode.com/threads/T-019dfafa-c2db-72e5-a874-dc50f383b5c0
|
|
35
|
+
const useSource = existsSync(sourceEntrypoint);
|
|
36
|
+
const entrypoint = useSource ? sourceEntrypoint : distEntrypoint;
|
|
37
|
+
const executable = useSource
|
|
38
|
+
? existsSync(localTsxBin)
|
|
39
|
+
? localTsxBin
|
|
40
|
+
: 'tsx'
|
|
41
|
+
: process.execPath;
|
|
42
|
+
|
|
43
|
+
if (!existsSync(entrypoint)) {
|
|
44
|
+
console.error(`CLI entrypoint not found at ${entrypoint}`);
|
|
45
|
+
process.exit(1);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const result = spawnSync(
|
|
49
|
+
executable,
|
|
50
|
+
[entrypoint, command, ...commandArgs],
|
|
51
|
+
{
|
|
52
|
+
cwd: packageRoot,
|
|
53
|
+
stdio: 'inherit',
|
|
54
|
+
shell: process.platform === 'win32' && useSource,
|
|
55
|
+
},
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
if (result.error) {
|
|
59
|
+
console.error(result.error.message);
|
|
60
|
+
process.exit(1);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (result.signal) {
|
|
64
|
+
console.error(`postinstall command terminated by ${result.signal}`);
|
|
65
|
+
process.exit(1);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
process.exit(result.status ?? 1);
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: lore-read
|
|
3
|
+
description: >-
|
|
4
|
+
Read information from Lore (the team's shared thread library). Use when the
|
|
5
|
+
user asks to fetch a specific Lore thread, search/list threads, or find
|
|
6
|
+
threads by filepath, author, or time range. Examples: "show me that Lore
|
|
7
|
+
thread", "what did my coworker share on Lore last week", "find Lore
|
|
8
|
+
threads that touched src/foo.ts", "list recent Lore sessions". Shells out
|
|
9
|
+
to the `tanagram lore get` and `tanagram lore list` CLI commands.
|
|
10
|
+
allowed-tools: Bash
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# Read from Lore
|
|
14
|
+
|
|
15
|
+
Fetches data from Lore via the `tanagram` CLI. Two underlying commands:
|
|
16
|
+
|
|
17
|
+
- `tanagram lore get <thread-id-or-url>` — fetch a single thread by ID or session URL.
|
|
18
|
+
- `tanagram lore list [flags]` — list/search threads with optional filters.
|
|
19
|
+
|
|
20
|
+
Both print a JSON payload on stdout. Parse the JSON and summarize for the user; only show raw JSON if they ask for it.
|
|
21
|
+
|
|
22
|
+
## When to Use
|
|
23
|
+
|
|
24
|
+
Run when the user asks to:
|
|
25
|
+
|
|
26
|
+
- "show me / open / read Lore thread <id-or-url>"
|
|
27
|
+
- "what did <coworker> post / share on Lore"
|
|
28
|
+
- "find Lore threads about <filepath / directory>"
|
|
29
|
+
- "list recent Lore threads" or "Lore threads from <time range>"
|
|
30
|
+
- "search Lore for ..."
|
|
31
|
+
|
|
32
|
+
Do NOT run proactively. Only on explicit request.
|
|
33
|
+
|
|
34
|
+
## Fetching a Single Thread
|
|
35
|
+
|
|
36
|
+
When the user gives a thread ID (`th_...`) or a Lore session URL (`https://lore.tanagram.ai/session/th_...`):
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
tanagram lore get <thread-id-or-url>
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
The argument can be either form — the CLI extracts the thread ID from a URL automatically.
|
|
43
|
+
|
|
44
|
+
## Listing / Searching Threads
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
tanagram lore list [--before <cursor>] [--after <cursor>] \
|
|
48
|
+
[--author-ids <id1,id2,...>] \
|
|
49
|
+
[--created-at <unix> | <start>...<end>] \
|
|
50
|
+
[--filepath-prefixes <prefix1,prefix2,...>]
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Flag reference:
|
|
54
|
+
|
|
55
|
+
- `--filepath-prefixes` — comma-separated filepath prefixes. Matches threads whose sessions touched files under any of those prefixes. Use this for "threads about <some path>".
|
|
56
|
+
- `--author-ids` — comma-separated **Lore user IDs** (not names or emails). If the user names a coworker, you need their Lore user ID; if you don't have it, ask the user or fetch a recent unfiltered list and look for their ID in the results before filtering.
|
|
57
|
+
- `--created-at` — either a single Unix timestamp (seconds) or a `<start>...<end>` range of Unix timestamps. Convert any human time range ("last week", "since Monday") into Unix seconds before passing. Today is provided in the system context.
|
|
58
|
+
- `--before` / `--after` — pagination cursors returned in a previous list response. Use these to page through large result sets, not for time filtering (that's `--created-at`).
|
|
59
|
+
|
|
60
|
+
Combine flags freely — they AND together server-side.
|
|
61
|
+
|
|
62
|
+
## Output
|
|
63
|
+
|
|
64
|
+
Both commands emit a single JSON object/array on stdout. After running:
|
|
65
|
+
|
|
66
|
+
1. Parse the JSON.
|
|
67
|
+
2. Summarize the relevant fields for the user (thread ID, title/topic, author, created time, URL, matching filepaths, etc.) instead of dumping raw JSON.
|
|
68
|
+
3. If the user asked for a single thread, surface its Lore URL prominently so they can click through.
|
|
69
|
+
4. If listing, show the top results with their URLs and a one-line hint each. Mention pagination cursors only if the user is likely to want more.
|
|
70
|
+
|
|
71
|
+
## Failure Modes
|
|
72
|
+
|
|
73
|
+
- **Not logged in**: command returns `not logged in - run 'tanagram login' first`. Tell the user to run `tanagram login`.
|
|
74
|
+
- **Bad thread ref**: `tanagram lore get` requires either a `th_...` ID or a Lore session URL. If the user passes something else, ask them to clarify or provide the URL.
|
|
75
|
+
- **Unknown author**: `--author-ids` only accepts Lore user IDs. If the user gives a name/email and you don't have a mapping, run `tanagram lore list` without the author filter (optionally narrowed by `--created-at` or `--filepath-prefixes`) and find the ID from the results, or ask the user.
|
|
76
|
+
- **Empty results**: not an error — tell the user no threads matched and suggest loosening filters.
|
|
77
|
+
|
|
78
|
+
## What This Does NOT Do
|
|
79
|
+
|
|
80
|
+
- It does not export the current session — that's the `share` skill (`tanagram lore export`).
|
|
81
|
+
- It does not modify threads, comments, visibility, or any Lore state. It is read-only.
|
|
82
|
+
- It does not start or manage the Lore background daemon.
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: share
|
|
3
|
+
description: Share (export) the current Claude Code session to Lore and get back a shareable URL. Use when the user says "share this thread", "send this to Lore", "export this conversation", "post this to Lore", or asks for a link to the current session. Safe to invoke explicitly on request — do not run proactively.
|
|
4
|
+
allowed-tools: Bash
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Share to Lore
|
|
8
|
+
|
|
9
|
+
Exports the Claude Code session you are currently running in to Lore (the team's shared thread library) and prints the URL. Lore dedupes session exports by session ID, so re-sharing the same session is safe — it returns the existing thread.
|
|
10
|
+
|
|
11
|
+
## When to Use
|
|
12
|
+
|
|
13
|
+
Run when the user asks to:
|
|
14
|
+
|
|
15
|
+
- "share this thread / conversation / session"
|
|
16
|
+
- "send this to Lore"
|
|
17
|
+
- "export this to Lore"
|
|
18
|
+
- "get a Lore link for this"
|
|
19
|
+
- "post this to Lore"
|
|
20
|
+
|
|
21
|
+
Do NOT run this proactively. Only on explicit request.
|
|
22
|
+
|
|
23
|
+
## Command
|
|
24
|
+
|
|
25
|
+
**Always** pass `--session-id ${CLAUDE_SESSION_ID}` so the CLI exports *this* session — the one the user just asked to share. Claude Code substitutes `${CLAUDE_SESSION_ID}` with the current session's ID; the CLI will not guess it for you.
|
|
26
|
+
|
|
27
|
+
Use this command as the default implementation:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
tanagram lore export --session-id ${CLAUDE_SESSION_ID} --visibility workspace
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Do **not** omit `--session-id` and rely on the cwd-match fallback. The fallback picks the most recent history entry for the current directory, which is frequently a *different* session (a prior run, a parallel worktree, etc.) — the user then has to retry with the explicit flag. The skill runtime gives you the session ID for free, so always pass it.
|
|
34
|
+
|
|
35
|
+
If the user wants to share a *different* session, substitute their ID for `${CLAUDE_SESSION_ID}` in the export command above.
|
|
36
|
+
|
|
37
|
+
If the user explicitly asks to share publicly (anyone with the link) or to keep the thread private to themselves, change the `--visibility` flag in the export command to `public` or `private` respectively. Default to `workspace` whenever the user just says "share".
|
|
38
|
+
|
|
39
|
+
## Output
|
|
40
|
+
|
|
41
|
+
The first command prints a single JSON object on stdout:
|
|
42
|
+
|
|
43
|
+
```json
|
|
44
|
+
{
|
|
45
|
+
"thread_id": "th_...",
|
|
46
|
+
"url": "https://lore.tanagram.ai/session/th_...",
|
|
47
|
+
"session_id": "...",
|
|
48
|
+
"project": "/Users/me/repo",
|
|
49
|
+
"reused": false,
|
|
50
|
+
"visibility": "workspace",
|
|
51
|
+
"clipboard_copied": true
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
- `url` — the shareable Lore link for the session thread. **Always show this to the user as the primary result.**
|
|
56
|
+
- `clipboard_copied` — `true` when the URL was copied to the system clipboard (via `pbcopy` on macOS, `wl-copy`/`xclip`/`xsel` on Linux, `clip.exe` on Windows). `false` when no clipboard tool was available. Mention this to the user when `true` so they know they can paste it directly.
|
|
57
|
+
|
|
58
|
+
## After Running
|
|
59
|
+
|
|
60
|
+
Echo the session URL back to the user as a clickable link. If `clipboard_copied` is `true`, add a short note that the URL is on their clipboard. Do not list other threads, summarize the conversation, or take any additional action unless the user asks. A minimal response looks like:
|
|
61
|
+
|
|
62
|
+
> Shared: https://lore.tanagram.ai/session/th_abc123 (copied to clipboard).
|
|
63
|
+
|
|
64
|
+
## Failure Modes
|
|
65
|
+
|
|
66
|
+
- **Not logged in**: the command returns `not logged in — run 'tanagram login' first`. Tell the user to run `tanagram login` and try again.
|
|
67
|
+
- **No matching history entry**: this happens when `${CLAUDE_SESSION_ID}` isn't present in `~/.claude/history.jsonl` yet (very fresh session) or when the user asked to share a session that the CLI can't find. Ask the user which session they want to share, or suggest `--session-id <id>` / `--project <path>` with the value they provide.
|
|
68
|
+
- **Lore is offline locally**: the command suggests setting `TANAGRAM_LORE_URL` when the SaaS endpoint is unreachable. Relay the message verbatim.
|
|
69
|
+
|
|
70
|
+
## What This Does NOT Do
|
|
71
|
+
|
|
72
|
+
- It does not start the Lore background daemon. For ongoing auto-sync of every session, `tanagram lore enable` is the right command.
|
|
73
|
+
- It does not change the thread title, comments, or other metadata. The user can adjust those in the Lore UI after sharing.
|
|
74
|
+
- It does not advance the background daemon's sync cursor. If the daemon is running, it may re-upload the same session on its next cycle — Lore will return the same thread ID, so this is a no-op.
|