@tanagram/lore 0.1.6 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +12 -12
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -1,34 +1,34 @@
1
1
  #!/usr/bin/env node
2
- var nn=Object.defineProperty;var sn=(r,t)=>{for(var n in t)nn(r,n,{get:t[n],enumerable:!0})};import{pathToFileURL as Pc}from"node:url";var an=/\d/,on=["-","_","/","."];function cn(r=""){if(!an.test(r))return r!==r.toLowerCase()}function It(r,t){let n=t??on,s=[];if(!r||typeof r!="string")return s;let a="",o,c;for(let i of r){let d=n.includes(i);if(d===!0){s.push(a),a="",o=void 0;continue}let p=cn(i);if(c===!1){if(o===!1&&p===!0){s.push(a),a=i,o=p;continue}if(o===!0&&p===!1&&a.length>1){let u=a.at(-1);s.push(a.slice(0,Math.max(0,a.length-1))),a=u+i,o=p;continue}}a+=i,o=p,c=d}return s.push(a),s}function ln(r){return r?r[0].toUpperCase()+r.slice(1):""}function dn(r){return r?r[0].toLowerCase()+r.slice(1):""}function pn(r,t){return r?(Array.isArray(r)?r:It(r)).map(n=>ln(t?.normalize?n.toLowerCase():n)).join(""):""}function Be(r,t){return dn(pn(r||"",t))}function Ze(r,t){return r?(Array.isArray(r)?r:It(r)).map(n=>n.toLowerCase()).join(t??"-"):""}function Lt(r){return Ze(r||"","_")}import{parseArgs as mn}from"node:util";function Je(r){return Array.isArray(r)?r:r===void 0?[]:[r]}function mt(r,t=""){let n=[];for(let s of r)for(let[a,o]of s.entries())n[a]=Math.max(n[a]||0,o.length);return r.map(s=>s.map((a,o)=>t+a[o===0?"padStart":"padEnd"](n[o])).join(" ")).join(`
3
- `)}function B(r){return typeof r=="function"?r():r}var ie=class extends Error{code;constructor(r,t){super(r),this.name="CLIError",this.code=t}};function un(r=[],t={}){let n=new Set(t.boolean||[]),s=new Set(t.string||[]),a=t.alias||{},o=t.default||{},c=new Map,i=new Map;for(let[v,k]of Object.entries(a)){let z=k;for(let V of z)c.set(v,V),i.has(V)||i.set(V,[]),i.get(V).push(v),c.set(V,v),i.has(v)||i.set(v,[]),i.get(v).push(V)}let d={};function p(v){if(n.has(v))return"boolean";let k=i.get(v)||[];for(let z of k)if(n.has(z))return"boolean";return"string"}function u(v){if(s.has(v))return!0;let k=i.get(v)||[];for(let z of k)if(s.has(z))return!0;return!1}let T=new Set([...n,...s,...Object.keys(a),...Object.values(a).flat(),...Object.keys(o)]);for(let v of T)d[v]||(d[v]={type:p(v),default:o[v]});for(let[v,k]of c.entries())v.length===1&&d[k]&&!d[k].short&&(d[k].short=v);let w=[],_={};for(let v=0;v<r.length;v++){let k=r[v];if(k==="--"){w.push(...r.slice(v));break}if(k.startsWith("--no-")){let z=k.slice(5);_[z]=!0;continue}w.push(k)}let P;try{P=mn({args:w,options:Object.keys(d).length>0?d:void 0,allowPositionals:!0,strict:!1})}catch{P={values:{},positionals:w}}let R={_:[]};R._=P.positionals;for(let[v,k]of Object.entries(P.values)){let z=k;p(v)==="boolean"&&typeof k=="string"?z=k!=="false":u(v)&&typeof k=="boolean"&&(z=""),R[v]=z}for(let[v]of Object.entries(_)){R[v]=!1;let k=c.get(v);k&&(R[k]=!1);let z=i.get(v);if(z)for(let V of z)R[V]=!1}for(let[v,k]of c.entries())R[v]!==void 0&&R[k]===void 0&&(R[k]=R[v]),R[k]!==void 0&&R[v]===void 0&&(R[v]=R[k]),R[v]!==R[k]&&o[k]===R[k]&&(R[k]=R[v]);return R}var hn=(()=>{let r=globalThis.process?.env??{};return r.NO_COLOR==="1"||r.TERM==="dumb"||r.TEST||r.CI})(),Ke=(r,t=39)=>n=>hn?n:`\x1B[${r}m${n}\x1B[${t}m`,Ge=Ke(1,22),M=Ke(36),Qe=Ke(90),He=Ke(4,24);function fn(r,t){let n={boolean:[],string:[],alias:{},default:{}},s=Bt(t);for(let i of s){if(i.type==="positional")continue;i.type==="string"||i.type==="enum"?n.string.push(i.name):i.type==="boolean"&&n.boolean.push(i.name),i.default!==void 0&&(n.default[i.name]=i.default),i.alias&&(n.alias[i.name]=i.alias);let d=Be(i.name),p=Ze(i.name);if(d!==i.name||p!==i.name){let u=Je(n.alias[i.name]||[]);d!==i.name&&!u.includes(d)&&u.push(d),p!==i.name&&!u.includes(p)&&u.push(p),u.length>0&&(n.alias[i.name]=u)}}let a=un(r,n),[...o]=a._,c=new Proxy(a,{get(i,d){return i[d]??i[Be(d)]??i[Ze(d)]}});for(let[,i]of s.entries())if(i.type==="positional"){let d=o.shift();if(d!==void 0)c[i.name]=d;else{if(i.default===void 0&&i.required!==!1)throw new ie(`Missing required positional argument: ${i.name.toUpperCase()}`,"EARG");c[i.name]=i.default}}else if(i.type==="enum"){let d=c[i.name],p=i.options||[];if(d!==void 0&&p.length>0&&!p.includes(d))throw new ie(`Invalid value for argument: ${M(`--${i.name}`)} (${M(d)}). Expected one of: ${p.map(u=>M(u)).join(", ")}.`,"EARG")}else if(i.required&&c[i.name]===void 0)throw new ie(`Missing required argument: --${i.name}`,"EARG");return c}function Bt(r){let t=[];for(let[n,s]of Object.entries(r||{}))t.push({...s,name:n,alias:Je(s.alias)});return t}async function gn(r){return Promise.all(r.map(t=>B(t)))}async function We(r,t){let n=await B(r.args||{}),s=fn(t.rawArgs,n),a={rawArgs:t.rawArgs,args:s,data:t.data,cmd:r},o=await gn(r.plugins??[]),c,i;try{for(let u of o)await u.setup?.(a);typeof r.setup=="function"&&await r.setup(a);let p=await B(r.subCommands);if(p&&Object.keys(p).length>0){let u=yn(t.rawArgs,n),T=t.rawArgs[u];if(T){let w=await Nt(p,T);if(!w)throw new ie(`Unknown command ${M(T)}`,"E_UNKNOWN_COMMAND");await We(w,{rawArgs:t.rawArgs.slice(u+1)})}else{let w=await B(r.default);if(w){if(r.run)throw new ie("Cannot specify both 'run' and 'default' on the same command.","E_DEFAULT_CONFLICT");let _=await Nt(p,w);if(!_)throw new ie(`Default sub command ${M(w)} not found in subCommands.`,"E_UNKNOWN_COMMAND");await We(_,{rawArgs:t.rawArgs})}else if(!r.run)throw new ie("No command specified.","E_NO_COMMAND")}}typeof r.run=="function"&&(c=await r.run(a))}catch(p){i=p}let d=[];if(typeof r.cleanup=="function")try{await r.cleanup(a)}catch(p){d.push(p)}for(let p of[...o].reverse())try{await p.cleanup?.(a)}catch(u){d.push(u)}if(i)throw i;if(d.length===1)throw d[0];if(d.length>1)throw new Error("Multiple cleanup errors",{cause:d});return{result:c}}async function Nt(r,t){if(t in r)return B(r[t]);for(let n of Object.values(r)){let s=await B(n),a=await B(s?.meta);if(a?.alias&&Je(a.alias).includes(t))return s}}function yn(r,t){for(let n=0;n<r.length;n++){let s=r[n];if(s==="--")return-1;if(s.startsWith("-")){!s.includes("=")&&bn(s,t)&&n++;continue}return n}return-1}function bn(r,t){let n=r.replace(/^-{1,2}/,""),s=Be(n);for(let[a,o]of Object.entries(t))if(!(o.type!=="string"&&o.type!=="enum")&&(s===Be(a)||(Array.isArray(o.alias)?o.alias:o.alias?[o.alias]:[]).includes(n)))return!0;return!1}var _n=/^no[-A-Z]/;async function $t(r,t){let n=await B(r.meta||{}),s=Bt(await B(r.args||{})),a=await B(t?.meta||{}),o=`${a.name?`${a.name} `:""}`+(n.name||process.argv[1]),c=[],i=[],d=[],p=[];for(let _ of s)if(_.type==="positional"){let P=_.name.toUpperCase(),R=_.required!==!1&&_.default===void 0;i.push([M(P+ut(_)),Ut(_,R)]),p.push(R?`<${P}>`:`[${P}]`)}else{let P=_.required===!0&&_.default===void 0,R=[...(_.alias||[]).map(v=>`-${v}`),`--${_.name}`].join(", ")+ut(_);if(c.push([M(R),Ut(_,P)]),_.type==="boolean"&&(_.default===!0||_.negativeDescription)&&!_n.test(_.name)){let v=[...(_.alias||[]).map(k=>`--no-${k}`),`--no-${_.name}`].join(", ");c.push([M(v),[_.negativeDescription,P?Qe("(Required)"):""].filter(Boolean).join(" ")])}P&&p.push(`--${_.name}`+ut(_))}if(r.subCommands){let _=[],P=await B(r.subCommands);for(let[R,v]of Object.entries(P)){let k=await B((await B(v))?.meta);if(k?.hidden)continue;let z=Je(k?.alias),V=[R,...z].join(", ");d.push([M(V),k?.description||""]),_.push(R,...z)}p.push(_.join("|"))}let u=[],T=n.version||a.version;u.push(Qe(`${n.description} (${o+(T?` v${T}`:"")})`),"");let w=c.length>0||i.length>0;return u.push(`${He(Ge("USAGE"))} ${M(`${o}${w?" [OPTIONS]":""} ${p.join(" ")}`)}`,""),i.length>0&&(u.push(He(Ge("ARGUMENTS")),""),u.push(mt(i," ")),u.push("")),c.length>0&&(u.push(He(Ge("OPTIONS")),""),u.push(mt(c," ")),u.push("")),d.length>0&&(u.push(He(Ge("COMMANDS")),""),u.push(mt(d," ")),u.push("",`Use ${M(`${o} <command> --help`)} for more information about a command.`)),u.filter(_=>typeof _=="string").join(`
4
- `)}function ut(r){let t=r.valueHint?`=<${r.valueHint}>`:"",n=t||`=<${Lt(r.name)}>`;return!r.type||r.type==="positional"||r.type==="boolean"?t:r.type==="enum"&&r.options?.length?`=<${r.options.join("|")}>`:n}function Ut(r,t){let n=t?Qe("(Required)"):"",s=r.default===void 0?"":Qe(`(Default: ${r.default})`);return[r.description,n,s].filter(Boolean).join(" ")}var e={};sn(e,{BRAND:()=>Zn,DIRTY:()=>ce,EMPTY_PATH:()=>kn,INVALID:()=>y,NEVER:()=>Ps,OK:()=>O,ParseStatus:()=>A,Schema:()=>S,ZodAny:()=>re,ZodArray:()=>X,ZodBigInt:()=>de,ZodBoolean:()=>pe,ZodBranded:()=>De,ZodCatch:()=>Se,ZodDate:()=>me,ZodDefault:()=>xe,ZodDiscriminatedUnion:()=>et,ZodEffects:()=>q,ZodEnum:()=>_e,ZodError:()=>N,ZodFirstPartyTypeKind:()=>b,ZodFunction:()=>rt,ZodIntersection:()=>ge,ZodIssueCode:()=>m,ZodLazy:()=>ye,ZodLiteral:()=>be,ZodMap:()=>Oe,ZodNaN:()=>Ie,ZodNativeEnum:()=>ve,ZodNever:()=>F,ZodNull:()=>he,ZodNullable:()=>H,ZodNumber:()=>le,ZodObject:()=>U,ZodOptional:()=>$,ZodParsedType:()=>f,ZodPipeline:()=>qe,ZodPromise:()=>ne,ZodReadonly:()=>ke,ZodRecord:()=>tt,ZodSchema:()=>S,ZodSet:()=>Ee,ZodString:()=>te,ZodSymbol:()=>ze,ZodTransformer:()=>q,ZodTuple:()=>G,ZodType:()=>S,ZodUndefined:()=>ue,ZodUnion:()=>fe,ZodUnknown:()=>Y,ZodVoid:()=>Ae,addIssueToContext:()=>h,any:()=>es,array:()=>ss,bigint:()=>Wn,boolean:()=>Jt,coerce:()=>Cs,custom:()=>Ht,date:()=>Jn,datetimeRegex:()=>Zt,defaultErrorMap:()=>J,discriminatedUnion:()=>cs,effect:()=>vs,enum:()=>ys,function:()=>hs,getErrorMap:()=>Re,getParsedType:()=>Z,instanceof:()=>Hn,intersection:()=>ls,isAborted:()=>Ye,isAsync:()=>Ce,isDirty:()=>Xe,isValid:()=>ee,late:()=>Gn,lazy:()=>fs,literal:()=>gs,makeIssue:()=>$e,map:()=>ms,nan:()=>Qn,nativeEnum:()=>bs,never:()=>rs,null:()=>Xn,nullable:()=>Ss,number:()=>Wt,object:()=>as,objectUtil:()=>ht,oboolean:()=>Rs,onumber:()=>ws,optional:()=>xs,ostring:()=>Ts,pipeline:()=>js,preprocess:()=>ks,promise:()=>_s,quotelessJson:()=>vn,record:()=>ps,set:()=>us,setErrorMap:()=>Sn,strictObject:()=>os,string:()=>Qt,symbol:()=>Kn,transformer:()=>vs,tuple:()=>ds,undefined:()=>Yn,union:()=>is,unknown:()=>ts,util:()=>j,void:()=>ns});var j;(function(r){r.assertEqual=a=>{};function t(a){}r.assertIs=t;function n(a){throw new Error}r.assertNever=n,r.arrayToEnum=a=>{let o={};for(let c of a)o[c]=c;return o},r.getValidEnumValues=a=>{let o=r.objectKeys(a).filter(i=>typeof a[a[i]]!="number"),c={};for(let i of o)c[i]=a[i];return r.objectValues(c)},r.objectValues=a=>r.objectKeys(a).map(function(o){return a[o]}),r.objectKeys=typeof Object.keys=="function"?a=>Object.keys(a):a=>{let o=[];for(let c in a)Object.prototype.hasOwnProperty.call(a,c)&&o.push(c);return o},r.find=(a,o)=>{for(let c of a)if(o(c))return c},r.isInteger=typeof Number.isInteger=="function"?a=>Number.isInteger(a):a=>typeof a=="number"&&Number.isFinite(a)&&Math.floor(a)===a;function s(a,o=" | "){return a.map(c=>typeof c=="string"?`'${c}'`:c).join(o)}r.joinValues=s,r.jsonStringifyReplacer=(a,o)=>typeof o=="bigint"?o.toString():o})(j||(j={}));var ht;(function(r){r.mergeShapes=(t,n)=>({...t,...n})})(ht||(ht={}));var f=j.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Z=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=j.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),vn=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:"),N=class r extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=s=>{this.issues=[...this.issues,s]},this.addIssues=(s=[])=>{this.issues=[...this.issues,...s]};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},s={_errors:[]},a=o=>{for(let c of o.issues)if(c.code==="invalid_union")c.unionErrors.map(a);else if(c.code==="invalid_return_type")a(c.returnTypeError);else if(c.code==="invalid_arguments")a(c.argumentsError);else if(c.path.length===0)s._errors.push(n(c));else{let i=s,d=0;for(;d<c.path.length;){let p=c.path[d];d===c.path.length-1?(i[p]=i[p]||{_errors:[]},i[p]._errors.push(n(c))):i[p]=i[p]||{_errors:[]},i=i[p],d++}}};return a(this),s}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,j.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=n=>n.message){let n={},s=[];for(let a of this.issues)if(a.path.length>0){let o=a.path[0];n[o]=n[o]||[],n[o].push(t(a))}else s.push(t(a));return{formErrors:s,fieldErrors:n}}get formErrors(){return this.flatten()}};N.create=r=>new N(r);var xn=(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,j.jsonStringifyReplacer)}`;break;case m.unrecognized_keys:n=`Unrecognized key(s) in object: ${j.joinValues(r.keys,", ")}`;break;case m.invalid_union:n="Invalid input";break;case m.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${j.joinValues(r.options)}`;break;case m.invalid_enum_value:n=`Invalid enum value. Expected ${j.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}"`:j.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,j.assertNever(r)}return{message:n}},J=xn;var Dt=J;function Sn(r){Dt=r}function Re(){return Dt}var $e=r=>{let{data:t,path:n,errorMaps:s,issueData:a}=r,o=[...n,...a.path||[]],c={...a,path:o};if(a.message!==void 0)return{...a,path:o,message:a.message};let i="",d=s.filter(p=>!!p).slice().reverse();for(let p of d)i=p(c,{data:t,defaultError:i}).message;return{...a,path:o,message:i}},kn=[];function h(r,t){let n=Re(),s=$e({issueData:t,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,n,n===J?void 0:J].filter(a=>!!a)});r.common.issues.push(s)}var A=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 s=[];for(let a of n){if(a.status==="aborted")return y;a.status==="dirty"&&t.dirty(),s.push(a.value)}return{status:t.value,value:s}}static async mergeObjectAsync(t,n){let s=[];for(let a of n){let o=await a.key,c=await a.value;s.push({key:o,value:c})}return r.mergeObjectSync(t,s)}static mergeObjectSync(t,n){let s={};for(let a of n){let{key:o,value:c}=a;if(o.status==="aborted"||c.status==="aborted")return y;o.status==="dirty"&&t.dirty(),c.status==="dirty"&&t.dirty(),o.value!=="__proto__"&&(typeof c.value<"u"||a.alwaysSet)&&(s[o.value]=c.value)}return{status:t.value,value:s}}},y=Object.freeze({status:"aborted"}),ce=r=>({status:"dirty",value:r}),O=r=>({status:"valid",value:r}),Ye=r=>r.status==="aborted",Xe=r=>r.status==="dirty",ee=r=>r.status==="valid",Ce=r=>typeof Promise<"u"&&r instanceof Promise;var g;(function(r){r.errToObj=t=>typeof t=="string"?{message:t}:t||{},r.toString=t=>typeof t=="string"?t:t?.message})(g||(g={}));var D=class{constructor(t,n,s,a){this._cachedPath=[],this.parent=t,this.data=n,this._path=s,this._key=a}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},qt=(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 N(r.common.issues);return this._error=n,this._error}}};function x(r){if(!r)return{};let{errorMap:t,invalid_type_error:n,required_error:s,description:a}=r;if(t&&(n||s))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:a}:{errorMap:(c,i)=>{let{message:d}=r;return c.code==="invalid_enum_value"?{message:d??i.defaultError}:typeof i.data>"u"?{message:d??s??i.defaultError}:c.code!=="invalid_type"?{message:i.defaultError}:{message:d??n??i.defaultError}},description:a}}var S=class{get description(){return this._def.description}_getType(t){return Z(t.data)}_getOrReturnCtx(t,n){return n||{common:t.parent.common,data:t.data,parsedType:Z(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new A,ctx:{common:t.parent.common,data:t.data,parsedType:Z(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 s=this.safeParse(t,n);if(s.success)return s.data;throw s.error}safeParse(t,n){let s={common:{issues:[],async:n?.async??!1,contextualErrorMap:n?.errorMap},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Z(t)},a=this._parseSync({data:t,path:s.path,parent:s});return qt(s,a)}"~validate"(t){let n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Z(t)};if(!this["~standard"].async)try{let s=this._parseSync({data:t,path:[],parent:n});return ee(s)?{value:s.value}:{issues:n.common.issues}}catch(s){s?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:n}).then(s=>ee(s)?{value:s.value}:{issues:n.common.issues})}async parseAsync(t,n){let s=await this.safeParseAsync(t,n);if(s.success)return s.data;throw s.error}async safeParseAsync(t,n){let s={common:{issues:[],contextualErrorMap:n?.errorMap,async:!0},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Z(t)},a=this._parse({data:t,path:s.path,parent:s}),o=await(Ce(a)?a:Promise.resolve(a));return qt(s,o)}refine(t,n){let s=a=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(a):n;return this._refinement((a,o)=>{let c=t(a),i=()=>o.addIssue({code:m.custom,...s(a)});return typeof Promise<"u"&&c instanceof Promise?c.then(d=>d?!0:(i(),!1)):c?!0:(i(),!1)})}refinement(t,n){return this._refinement((s,a)=>t(s)?!0:(a.addIssue(typeof n=="function"?n(s,a):n),!1))}_refinement(t){return new q({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 $.create(this,this._def)}nullable(){return H.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return X.create(this)}promise(){return ne.create(this,this._def)}or(t){return fe.create([this,t],this._def)}and(t){return ge.create(this,t,this._def)}transform(t){return new q({...x(this._def),schema:this,typeName:b.ZodEffects,effect:{type:"transform",transform:t}})}default(t){let n=typeof t=="function"?t:()=>t;return new xe({...x(this._def),innerType:this,defaultValue:n,typeName:b.ZodDefault})}brand(){return new De({typeName:b.ZodBranded,type:this,...x(this._def)})}catch(t){let n=typeof t=="function"?t:()=>t;return new Se({...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 qe.create(this,t)}readonly(){return ke.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},jn=/^c[^\s-]{8,}$/i,Tn=/^[0-9a-z]+$/,wn=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Rn=/^[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,Cn=/^[a-z0-9_-]{21}$/i,Pn=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,zn=/^[-+]?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)?)??$/,An=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,On="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",ft,En=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,In=/^(?:(?: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])$/,Ln=/^(([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]))$/,Nn=/^(([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])$/,Un=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Bn=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Ft="((\\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])))",$n=new RegExp(`^${Ft}$`);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 Dn(r){return new RegExp(`^${Vt(r)}$`)}function Zt(r){let t=`${Ft}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 qn(r,t){return!!((t==="v4"||!t)&&En.test(r)||(t==="v6"||!t)&&Ln.test(r))}function Mn(r,t){if(!Pn.test(r))return!1;try{let[n]=r.split(".");if(!n)return!1;let s=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),a=JSON.parse(atob(s));return!(typeof a!="object"||a===null||"typ"in a&&a?.typ!=="JWT"||!a.alg||t&&a.alg!==t)}catch{return!1}}function Fn(r,t){return!!((t==="v4"||!t)&&In.test(r)||(t==="v6"||!t)&&Nn.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 o=this._getOrReturnCtx(t);return h(o,{code:m.invalid_type,expected:f.string,received:o.parsedType}),y}let s=new A,a;for(let o of this._def.checks)if(o.kind==="min")t.data.length<o.value&&(a=this._getOrReturnCtx(t,a),h(a,{code:m.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),s.dirty());else if(o.kind==="max")t.data.length>o.value&&(a=this._getOrReturnCtx(t,a),h(a,{code:m.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),s.dirty());else if(o.kind==="length"){let c=t.data.length>o.value,i=t.data.length<o.value;(c||i)&&(a=this._getOrReturnCtx(t,a),c?h(a,{code:m.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}):i&&h(a,{code:m.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}),s.dirty())}else if(o.kind==="email")An.test(t.data)||(a=this._getOrReturnCtx(t,a),h(a,{validation:"email",code:m.invalid_string,message:o.message}),s.dirty());else if(o.kind==="emoji")ft||(ft=new RegExp(On,"u")),ft.test(t.data)||(a=this._getOrReturnCtx(t,a),h(a,{validation:"emoji",code:m.invalid_string,message:o.message}),s.dirty());else if(o.kind==="uuid")Rn.test(t.data)||(a=this._getOrReturnCtx(t,a),h(a,{validation:"uuid",code:m.invalid_string,message:o.message}),s.dirty());else if(o.kind==="nanoid")Cn.test(t.data)||(a=this._getOrReturnCtx(t,a),h(a,{validation:"nanoid",code:m.invalid_string,message:o.message}),s.dirty());else if(o.kind==="cuid")jn.test(t.data)||(a=this._getOrReturnCtx(t,a),h(a,{validation:"cuid",code:m.invalid_string,message:o.message}),s.dirty());else if(o.kind==="cuid2")Tn.test(t.data)||(a=this._getOrReturnCtx(t,a),h(a,{validation:"cuid2",code:m.invalid_string,message:o.message}),s.dirty());else if(o.kind==="ulid")wn.test(t.data)||(a=this._getOrReturnCtx(t,a),h(a,{validation:"ulid",code:m.invalid_string,message:o.message}),s.dirty());else if(o.kind==="url")try{new URL(t.data)}catch{a=this._getOrReturnCtx(t,a),h(a,{validation:"url",code:m.invalid_string,message:o.message}),s.dirty()}else o.kind==="regex"?(o.regex.lastIndex=0,o.regex.test(t.data)||(a=this._getOrReturnCtx(t,a),h(a,{validation:"regex",code:m.invalid_string,message:o.message}),s.dirty())):o.kind==="trim"?t.data=t.data.trim():o.kind==="includes"?t.data.includes(o.value,o.position)||(a=this._getOrReturnCtx(t,a),h(a,{code:m.invalid_string,validation:{includes:o.value,position:o.position},message:o.message}),s.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)||(a=this._getOrReturnCtx(t,a),h(a,{code:m.invalid_string,validation:{startsWith:o.value},message:o.message}),s.dirty()):o.kind==="endsWith"?t.data.endsWith(o.value)||(a=this._getOrReturnCtx(t,a),h(a,{code:m.invalid_string,validation:{endsWith:o.value},message:o.message}),s.dirty()):o.kind==="datetime"?Zt(o).test(t.data)||(a=this._getOrReturnCtx(t,a),h(a,{code:m.invalid_string,validation:"datetime",message:o.message}),s.dirty()):o.kind==="date"?$n.test(t.data)||(a=this._getOrReturnCtx(t,a),h(a,{code:m.invalid_string,validation:"date",message:o.message}),s.dirty()):o.kind==="time"?Dn(o).test(t.data)||(a=this._getOrReturnCtx(t,a),h(a,{code:m.invalid_string,validation:"time",message:o.message}),s.dirty()):o.kind==="duration"?zn.test(t.data)||(a=this._getOrReturnCtx(t,a),h(a,{validation:"duration",code:m.invalid_string,message:o.message}),s.dirty()):o.kind==="ip"?qn(t.data,o.version)||(a=this._getOrReturnCtx(t,a),h(a,{validation:"ip",code:m.invalid_string,message:o.message}),s.dirty()):o.kind==="jwt"?Mn(t.data,o.alg)||(a=this._getOrReturnCtx(t,a),h(a,{validation:"jwt",code:m.invalid_string,message:o.message}),s.dirty()):o.kind==="cidr"?Fn(t.data,o.version)||(a=this._getOrReturnCtx(t,a),h(a,{validation:"cidr",code:m.invalid_string,message:o.message}),s.dirty()):o.kind==="base64"?Un.test(t.data)||(a=this._getOrReturnCtx(t,a),h(a,{validation:"base64",code:m.invalid_string,message:o.message}),s.dirty()):o.kind==="base64url"?Bn.test(t.data)||(a=this._getOrReturnCtx(t,a),h(a,{validation:"base64url",code:m.invalid_string,message:o.message}),s.dirty()):j.assertNever(o);return{status:s.value,value:t.data}}_regex(t,n,s){return this.refinement(a=>t.test(a),{validation:n,code:m.invalid_string,...g.errToObj(s)})}_addCheck(t){return new r({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...g.errToObj(t)})}url(t){return this._addCheck({kind:"url",...g.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...g.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...g.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...g.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...g.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...g.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...g.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...g.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...g.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...g.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...g.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...g.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,...g.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,...g.errToObj(t?.message)})}duration(t){return this._addCheck({kind:"duration",...g.errToObj(t)})}regex(t,n){return this._addCheck({kind:"regex",regex:t,...g.errToObj(n)})}includes(t,n){return this._addCheck({kind:"includes",value:t,position:n?.position,...g.errToObj(n?.message)})}startsWith(t,n){return this._addCheck({kind:"startsWith",value:t,...g.errToObj(n)})}endsWith(t,n){return this._addCheck({kind:"endsWith",value:t,...g.errToObj(n)})}min(t,n){return this._addCheck({kind:"min",value:t,...g.errToObj(n)})}max(t,n){return this._addCheck({kind:"max",value:t,...g.errToObj(n)})}length(t,n){return this._addCheck({kind:"length",value:t,...g.errToObj(n)})}nonempty(t){return this.min(1,g.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 Vn(r,t){let n=(r.toString().split(".")[1]||"").length,s=(t.toString().split(".")[1]||"").length,a=n>s?n:s,o=Number.parseInt(r.toFixed(a).replace(".","")),c=Number.parseInt(t.toFixed(a).replace(".",""));return o%c/10**a}var le=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}),y}let s,a=new A;for(let o of this._def.checks)o.kind==="int"?j.isInteger(t.data)||(s=this._getOrReturnCtx(t,s),h(s,{code:m.invalid_type,expected:"integer",received:"float",message:o.message}),a.dirty()):o.kind==="min"?(o.inclusive?t.data<o.value:t.data<=o.value)&&(s=this._getOrReturnCtx(t,s),h(s,{code:m.too_small,minimum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),a.dirty()):o.kind==="max"?(o.inclusive?t.data>o.value:t.data>=o.value)&&(s=this._getOrReturnCtx(t,s),h(s,{code:m.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),a.dirty()):o.kind==="multipleOf"?Vn(t.data,o.value)!==0&&(s=this._getOrReturnCtx(t,s),h(s,{code:m.not_multiple_of,multipleOf:o.value,message:o.message}),a.dirty()):o.kind==="finite"?Number.isFinite(t.data)||(s=this._getOrReturnCtx(t,s),h(s,{code:m.not_finite,message:o.message}),a.dirty()):j.assertNever(o);return{status:a.value,value:t.data}}gte(t,n){return this.setLimit("min",t,!0,g.toString(n))}gt(t,n){return this.setLimit("min",t,!1,g.toString(n))}lte(t,n){return this.setLimit("max",t,!0,g.toString(n))}lt(t,n){return this.setLimit("max",t,!1,g.toString(n))}setLimit(t,n,s,a){return new r({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:s,message:g.toString(a)}]})}_addCheck(t){return new r({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:g.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:g.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:g.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:g.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:g.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:g.toString(n)})}finite(t){return this._addCheck({kind:"finite",message:g.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:g.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:g.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"&&j.isInteger(t.value))}get isFinite(){let t=null,n=null;for(let s of this._def.checks){if(s.kind==="finite"||s.kind==="int"||s.kind==="multipleOf")return!0;s.kind==="min"?(n===null||s.value>n)&&(n=s.value):s.kind==="max"&&(t===null||s.value<t)&&(t=s.value)}return Number.isFinite(n)&&Number.isFinite(t)}};le.create=r=>new le({checks:[],typeName:b.ZodNumber,coerce:r?.coerce||!1,...x(r)});var de=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 s,a=new A;for(let o of this._def.checks)o.kind==="min"?(o.inclusive?t.data<o.value:t.data<=o.value)&&(s=this._getOrReturnCtx(t,s),h(s,{code:m.too_small,type:"bigint",minimum:o.value,inclusive:o.inclusive,message:o.message}),a.dirty()):o.kind==="max"?(o.inclusive?t.data>o.value:t.data>=o.value)&&(s=this._getOrReturnCtx(t,s),h(s,{code:m.too_big,type:"bigint",maximum:o.value,inclusive:o.inclusive,message:o.message}),a.dirty()):o.kind==="multipleOf"?t.data%o.value!==BigInt(0)&&(s=this._getOrReturnCtx(t,s),h(s,{code:m.not_multiple_of,multipleOf:o.value,message:o.message}),a.dirty()):j.assertNever(o);return{status:a.value,value:t.data}}_getInvalidInput(t){let n=this._getOrReturnCtx(t);return h(n,{code:m.invalid_type,expected:f.bigint,received:n.parsedType}),y}gte(t,n){return this.setLimit("min",t,!0,g.toString(n))}gt(t,n){return this.setLimit("min",t,!1,g.toString(n))}lte(t,n){return this.setLimit("max",t,!0,g.toString(n))}lt(t,n){return this.setLimit("max",t,!1,g.toString(n))}setLimit(t,n,s,a){return new r({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:s,message:g.toString(a)}]})}_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:g.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:g.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:g.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:g.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:g.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}};de.create=r=>new de({checks:[],typeName:b.ZodBigInt,coerce:r?.coerce??!1,...x(r)});var pe=class extends S{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==f.boolean){let s=this._getOrReturnCtx(t);return h(s,{code:m.invalid_type,expected:f.boolean,received:s.parsedType}),y}return O(t.data)}};pe.create=r=>new pe({typeName:b.ZodBoolean,coerce:r?.coerce||!1,...x(r)});var me=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}),y}if(Number.isNaN(t.data.getTime())){let o=this._getOrReturnCtx(t);return h(o,{code:m.invalid_date}),y}let s=new A,a;for(let o of this._def.checks)o.kind==="min"?t.data.getTime()<o.value&&(a=this._getOrReturnCtx(t,a),h(a,{code:m.too_small,message:o.message,inclusive:!0,exact:!1,minimum:o.value,type:"date"}),s.dirty()):o.kind==="max"?t.data.getTime()>o.value&&(a=this._getOrReturnCtx(t,a),h(a,{code:m.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),s.dirty()):j.assertNever(o);return{status:s.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:g.toString(n)})}max(t,n){return this._addCheck({kind:"max",value:t.getTime(),message:g.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}};me.create=r=>new me({checks:[],coerce:r?.coerce||!1,typeName:b.ZodDate,...x(r)});var ze=class extends S{_parse(t){if(this._getType(t)!==f.symbol){let s=this._getOrReturnCtx(t);return h(s,{code:m.invalid_type,expected:f.symbol,received:s.parsedType}),y}return O(t.data)}};ze.create=r=>new ze({typeName:b.ZodSymbol,...x(r)});var ue=class extends S{_parse(t){if(this._getType(t)!==f.undefined){let s=this._getOrReturnCtx(t);return h(s,{code:m.invalid_type,expected:f.undefined,received:s.parsedType}),y}return O(t.data)}};ue.create=r=>new ue({typeName:b.ZodUndefined,...x(r)});var he=class extends S{_parse(t){if(this._getType(t)!==f.null){let s=this._getOrReturnCtx(t);return h(s,{code:m.invalid_type,expected:f.null,received:s.parsedType}),y}return O(t.data)}};he.create=r=>new he({typeName:b.ZodNull,...x(r)});var re=class extends S{constructor(){super(...arguments),this._any=!0}_parse(t){return O(t.data)}};re.create=r=>new re({typeName:b.ZodAny,...x(r)});var Y=class extends S{constructor(){super(...arguments),this._unknown=!0}_parse(t){return O(t.data)}};Y.create=r=>new Y({typeName:b.ZodUnknown,...x(r)});var F=class extends S{_parse(t){let n=this._getOrReturnCtx(t);return h(n,{code:m.invalid_type,expected:f.never,received:n.parsedType}),y}};F.create=r=>new F({typeName:b.ZodNever,...x(r)});var Ae=class extends S{_parse(t){if(this._getType(t)!==f.undefined){let s=this._getOrReturnCtx(t);return h(s,{code:m.invalid_type,expected:f.void,received:s.parsedType}),y}return O(t.data)}};Ae.create=r=>new Ae({typeName:b.ZodVoid,...x(r)});var X=class r extends S{_parse(t){let{ctx:n,status:s}=this._processInputParams(t),a=this._def;if(n.parsedType!==f.array)return h(n,{code:m.invalid_type,expected:f.array,received:n.parsedType}),y;if(a.exactLength!==null){let c=n.data.length>a.exactLength.value,i=n.data.length<a.exactLength.value;(c||i)&&(h(n,{code:c?m.too_big:m.too_small,minimum:i?a.exactLength.value:void 0,maximum:c?a.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:a.exactLength.message}),s.dirty())}if(a.minLength!==null&&n.data.length<a.minLength.value&&(h(n,{code:m.too_small,minimum:a.minLength.value,type:"array",inclusive:!0,exact:!1,message:a.minLength.message}),s.dirty()),a.maxLength!==null&&n.data.length>a.maxLength.value&&(h(n,{code:m.too_big,maximum:a.maxLength.value,type:"array",inclusive:!0,exact:!1,message:a.maxLength.message}),s.dirty()),n.common.async)return Promise.all([...n.data].map((c,i)=>a.type._parseAsync(new D(n,c,n.path,i)))).then(c=>A.mergeArray(s,c));let o=[...n.data].map((c,i)=>a.type._parseSync(new D(n,c,n.path,i)));return A.mergeArray(s,o)}get element(){return this._def.type}min(t,n){return new r({...this._def,minLength:{value:t,message:g.toString(n)}})}max(t,n){return new r({...this._def,maxLength:{value:t,message:g.toString(n)}})}length(t,n){return new r({...this._def,exactLength:{value:t,message:g.toString(n)}})}nonempty(t){return this.min(1,t)}};X.create=(r,t)=>new X({type:r,minLength:null,maxLength:null,exactLength:null,typeName:b.ZodArray,...x(t)});function Pe(r){if(r instanceof U){let t={};for(let n in r.shape){let s=r.shape[n];t[n]=$.create(Pe(s))}return new U({...r._def,shape:()=>t})}else return r instanceof X?new X({...r._def,type:Pe(r.element)}):r instanceof $?$.create(Pe(r.unwrap())):r instanceof H?H.create(Pe(r.unwrap())):r instanceof G?G.create(r.items.map(t=>Pe(t))):r}var U=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=j.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}),y}let{status:s,ctx:a}=this._processInputParams(t),{shape:o,keys:c}=this._getCached(),i=[];if(!(this._def.catchall instanceof F&&this._def.unknownKeys==="strip"))for(let p in a.data)c.includes(p)||i.push(p);let d=[];for(let p of c){let u=o[p],T=a.data[p];d.push({key:{status:"valid",value:p},value:u._parse(new D(a,T,a.path,p)),alwaysSet:p in a.data})}if(this._def.catchall instanceof F){let p=this._def.unknownKeys;if(p==="passthrough")for(let u of i)d.push({key:{status:"valid",value:u},value:{status:"valid",value:a.data[u]}});else if(p==="strict")i.length>0&&(h(a,{code:m.unrecognized_keys,keys:i}),s.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=a.data[u];d.push({key:{status:"valid",value:u},value:p._parse(new D(a,T,a.path,u)),alwaysSet:u in a.data})}}return a.common.async?Promise.resolve().then(async()=>{let p=[];for(let u of d){let T=await u.key,w=await u.value;p.push({key:T,value:w,alwaysSet:u.alwaysSet})}return p}).then(p=>A.mergeObjectSync(s,p)):A.mergeObjectSync(s,d)}get shape(){return this._def.shape()}strict(t){return g.errToObj,new r({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(n,s)=>{let a=this._def.errorMap?.(n,s).message??s.defaultError;return n.code==="unrecognized_keys"?{message:g.errToObj(t).message??a}:{message:a}}}:{}})}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 s of j.objectKeys(t))t[s]&&this.shape[s]&&(n[s]=this.shape[s]);return new r({...this._def,shape:()=>n})}omit(t){let n={};for(let s of j.objectKeys(this.shape))t[s]||(n[s]=this.shape[s]);return new r({...this._def,shape:()=>n})}deepPartial(){return Pe(this)}partial(t){let n={};for(let s of j.objectKeys(this.shape)){let a=this.shape[s];t&&!t[s]?n[s]=a:n[s]=a.optional()}return new r({...this._def,shape:()=>n})}required(t){let n={};for(let s of j.objectKeys(this.shape))if(t&&!t[s])n[s]=this.shape[s];else{let o=this.shape[s];for(;o instanceof $;)o=o._def.innerType;n[s]=o}return new r({...this._def,shape:()=>n})}keyof(){return Gt(j.objectKeys(this.shape))}};U.create=(r,t)=>new U({shape:()=>r,unknownKeys:"strip",catchall:F.create(),typeName:b.ZodObject,...x(t)});U.strictCreate=(r,t)=>new U({shape:()=>r,unknownKeys:"strict",catchall:F.create(),typeName:b.ZodObject,...x(t)});U.lazycreate=(r,t)=>new U({shape:r,unknownKeys:"strip",catchall:F.create(),typeName:b.ZodObject,...x(t)});var fe=class extends S{_parse(t){let{ctx:n}=this._processInputParams(t),s=this._def.options;function a(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 N(i.ctx.common.issues));return h(n,{code:m.invalid_union,unionErrors:c}),y}if(n.common.async)return Promise.all(s.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(a);{let o,c=[];for(let d of s){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"&&!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(d=>new N(d));return h(n,{code:m.invalid_union,unionErrors:i}),y}}get options(){return this._def.options}};fe.create=(r,t)=>new fe({options:r,typeName:b.ZodUnion,...x(t)});var K=r=>r instanceof ye?K(r.schema):r instanceof q?K(r.innerType()):r instanceof be?[r.value]:r instanceof _e?r.options:r instanceof ve?j.objectValues(r.enum):r instanceof xe?K(r._def.innerType):r instanceof ue?[void 0]:r instanceof he?[null]:r instanceof $?[void 0,...K(r.unwrap())]:r instanceof H?[null,...K(r.unwrap())]:r instanceof De||r instanceof ke?K(r.unwrap()):r instanceof Se?K(r._def.innerType):[],et=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}),y;let s=this.discriminator,a=n.data[s],o=this.optionsMap.get(a);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:[s]}),y)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,s){let a=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(a.has(i))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(i)}`);a.set(i,o)}}return new r({typeName:b.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:a,...x(s)})}};function gt(r,t){let n=Z(r),s=Z(t);if(r===t)return{valid:!0,data:r};if(n===f.object&&s===f.object){let a=j.objectKeys(t),o=j.objectKeys(r).filter(i=>a.indexOf(i)!==-1),c={...r,...t};for(let i of o){let d=gt(r[i],t[i]);if(!d.valid)return{valid:!1};c[i]=d.data}return{valid:!0,data:c}}else if(n===f.array&&s===f.array){if(r.length!==t.length)return{valid:!1};let a=[];for(let o=0;o<r.length;o++){let c=r[o],i=t[o],d=gt(c,i);if(!d.valid)return{valid:!1};a.push(d.data)}return{valid:!0,data:a}}else return n===f.date&&s===f.date&&+r==+t?{valid:!0,data:r}:{valid:!1}}var ge=class extends S{_parse(t){let{status:n,ctx:s}=this._processInputParams(t),a=(o,c)=>{if(Ye(o)||Ye(c))return y;let i=gt(o.value,c.value);return i.valid?((Xe(o)||Xe(c))&&n.dirty(),{status:n.value,value:i.data}):(h(s,{code:m.invalid_intersection_types}),y)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then(([o,c])=>a(o,c)):a(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}};ge.create=(r,t,n)=>new ge({left:r,right:t,typeName:b.ZodIntersection,...x(n)});var G=class r extends S{_parse(t){let{status:n,ctx:s}=this._processInputParams(t);if(s.parsedType!==f.array)return h(s,{code:m.invalid_type,expected:f.array,received:s.parsedType}),y;if(s.data.length<this._def.items.length)return h(s,{code:m.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),y;!this._def.rest&&s.data.length>this._def.items.length&&(h(s,{code:m.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());let o=[...s.data].map((c,i)=>{let d=this._def.items[i]||this._def.rest;return d?d._parse(new D(s,c,s.path,i)):null}).filter(c=>!!c);return s.common.async?Promise.all(o).then(c=>A.mergeArray(n,c)):A.mergeArray(n,o)}get items(){return this._def.items}rest(t){return new r({...this._def,rest:t})}};G.create=(r,t)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new G({items:r,typeName:b.ZodTuple,rest:null,...x(t)})};var tt=class r extends S{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:n,ctx:s}=this._processInputParams(t);if(s.parsedType!==f.object)return h(s,{code:m.invalid_type,expected:f.object,received:s.parsedType}),y;let a=[],o=this._def.keyType,c=this._def.valueType;for(let i in s.data)a.push({key:o._parse(new D(s,i,s.path,i)),value:c._parse(new D(s,s.data[i],s.path,i)),alwaysSet:i in s.data});return s.common.async?A.mergeObjectAsync(n,a):A.mergeObjectSync(n,a)}get element(){return this._def.valueType}static create(t,n,s){return n instanceof S?new r({keyType:t,valueType:n,typeName:b.ZodRecord,...x(s)}):new r({keyType:te.create(),valueType:t,typeName:b.ZodRecord,...x(n)})}},Oe=class extends S{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:n,ctx:s}=this._processInputParams(t);if(s.parsedType!==f.map)return h(s,{code:m.invalid_type,expected:f.map,received:s.parsedType}),y;let a=this._def.keyType,o=this._def.valueType,c=[...s.data.entries()].map(([i,d],p)=>({key:a._parse(new D(s,i,s.path,[p,"key"])),value:o._parse(new D(s,d,s.path,[p,"value"]))}));if(s.common.async){let i=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 y;(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 d of c){let p=d.key,u=d.value;if(p.status==="aborted"||u.status==="aborted")return y;(p.status==="dirty"||u.status==="dirty")&&n.dirty(),i.set(p.value,u.value)}return{status:n.value,value:i}}}};Oe.create=(r,t,n)=>new Oe({valueType:t,keyType:r,typeName:b.ZodMap,...x(n)});var Ee=class r extends S{_parse(t){let{status:n,ctx:s}=this._processInputParams(t);if(s.parsedType!==f.set)return h(s,{code:m.invalid_type,expected:f.set,received:s.parsedType}),y;let a=this._def;a.minSize!==null&&s.data.size<a.minSize.value&&(h(s,{code:m.too_small,minimum:a.minSize.value,type:"set",inclusive:!0,exact:!1,message:a.minSize.message}),n.dirty()),a.maxSize!==null&&s.data.size>a.maxSize.value&&(h(s,{code:m.too_big,maximum:a.maxSize.value,type:"set",inclusive:!0,exact:!1,message:a.maxSize.message}),n.dirty());let o=this._def.valueType;function c(d){let p=new Set;for(let u of d){if(u.status==="aborted")return y;u.status==="dirty"&&n.dirty(),p.add(u.value)}return{status:n.value,value:p}}let i=[...s.data.values()].map((d,p)=>o._parse(new D(s,d,s.path,p)));return s.common.async?Promise.all(i).then(d=>c(d)):c(i)}min(t,n){return new r({...this._def,minSize:{value:t,message:g.toString(n)}})}max(t,n){return new r({...this._def,maxSize:{value:t,message:g.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 rt=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}),y;function s(i,d){return $e({data:i,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Re(),J].filter(p=>!!p),issueData:{code:m.invalid_arguments,argumentsError:d}})}function a(i,d){return $e({data:i,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Re(),J].filter(p=>!!p),issueData:{code:m.invalid_return_type,returnTypeError:d}})}let o={errorMap:n.common.contextualErrorMap},c=n.data;if(this._def.returns instanceof ne){let i=this;return O(async function(...d){let p=new N([]),u=await i._def.args.parseAsync(d,o).catch(_=>{throw p.addIssue(s(d,_)),p}),T=await Reflect.apply(c,this,u);return await i._def.returns._def.type.parseAsync(T,o).catch(_=>{throw p.addIssue(a(T,_)),p})})}else{let i=this;return O(function(...d){let p=i._def.args.safeParse(d,o);if(!p.success)throw new N([s(d,p.error)]);let u=Reflect.apply(c,this,p.data),T=i._def.returns.safeParse(u,o);if(!T.success)throw new N([a(u,T.error)]);return T.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new r({...this._def,args:G.create(t).rest(Y.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,s){return new r({args:t||G.create([]).rest(Y.create()),returns:n||Y.create(),typeName:b.ZodFunction,...x(s)})}},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 be=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}),y}return{status:"valid",value:t.data}}get value(){return this._def.value}};be.create=(r,t)=>new be({value:r,typeName:b.ZodLiteral,...x(t)});function Gt(r,t){return new _e({values:r,typeName:b.ZodEnum,...x(t)})}var _e=class r extends S{_parse(t){if(typeof t.data!="string"){let n=this._getOrReturnCtx(t),s=this._def.values;return h(n,{expected:j.joinValues(s),received:n.parsedType,code:m.invalid_type}),y}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){let n=this._getOrReturnCtx(t),s=this._def.values;return h(n,{received:n.data,code:m.invalid_enum_value,options:s}),y}return O(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(s=>!t.includes(s)),{...this._def,...n})}};_e.create=Gt;var ve=class extends S{_parse(t){let n=j.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(t);if(s.parsedType!==f.string&&s.parsedType!==f.number){let a=j.objectValues(n);return h(s,{expected:j.joinValues(a),received:s.parsedType,code:m.invalid_type}),y}if(this._cache||(this._cache=new Set(j.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){let a=j.objectValues(n);return h(s,{received:s.data,code:m.invalid_enum_value,options:a}),y}return O(t.data)}get enum(){return this._def.values}};ve.create=(r,t)=>new ve({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}),y;let s=n.parsedType===f.promise?n.data:Promise.resolve(n.data);return O(s.then(a=>this._def.type.parseAsync(a,{path:n.path,errorMap:n.common.contextualErrorMap})))}};ne.create=(r,t)=>new ne({type:r,typeName:b.ZodPromise,...x(t)});var q=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:s}=this._processInputParams(t),a=this._def.effect||null,o={addIssue:c=>{h(s,c),c.fatal?n.abort():n.dirty()},get path(){return s.path}};if(o.addIssue=o.addIssue.bind(o),a.type==="preprocess"){let c=a.transform(s.data,o);if(s.common.async)return Promise.resolve(c).then(async i=>{if(n.value==="aborted")return y;let d=await this._def.schema._parseAsync({data:i,path:s.path,parent:s});return d.status==="aborted"?y:d.status==="dirty"?ce(d.value):n.value==="dirty"?ce(d.value):d});{if(n.value==="aborted")return y;let i=this._def.schema._parseSync({data:c,path:s.path,parent:s});return i.status==="aborted"?y:i.status==="dirty"?ce(i.value):n.value==="dirty"?ce(i.value):i}}if(a.type==="refinement"){let c=i=>{let d=a.refinement(i,o);if(s.common.async)return Promise.resolve(d);if(d instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return i};if(s.common.async===!1){let i=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});return i.status==="aborted"?y:(i.status==="dirty"&&n.dirty(),c(i.value),{status:n.value,value:i.value})}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(i=>i.status==="aborted"?y:(i.status==="dirty"&&n.dirty(),c(i.value).then(()=>({status:n.value,value:i.value}))))}if(a.type==="transform")if(s.common.async===!1){let c=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(!ee(c))return y;let i=a.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:s.data,path:s.path,parent:s}).then(c=>ee(c)?Promise.resolve(a.transform(c.value,o)).then(i=>({status:n.value,value:i})):y);j.assertNever(a)}};q.create=(r,t,n)=>new q({schema:r,typeName:b.ZodEffects,effect:t,...x(n)});q.createWithPreprocess=(r,t,n)=>new q({schema:t,effect:{type:"preprocess",transform:r},typeName:b.ZodEffects,...x(n)});var $=class extends S{_parse(t){return this._getType(t)===f.undefined?O(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};$.create=(r,t)=>new $({innerType:r,typeName:b.ZodOptional,...x(t)});var H=class extends S{_parse(t){return this._getType(t)===f.null?O(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};H.create=(r,t)=>new H({innerType:r,typeName:b.ZodNullable,...x(t)});var xe=class extends S{_parse(t){let{ctx:n}=this._processInputParams(t),s=n.data;return n.parsedType===f.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:n.path,parent:n})}removeDefault(){return this._def.innerType}};xe.create=(r,t)=>new xe({innerType:r,typeName:b.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...x(t)});var Se=class extends S{_parse(t){let{ctx:n}=this._processInputParams(t),s={...n,common:{...n.common,issues:[]}},a=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});return Ce(a)?a.then(o=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new N(s.common.issues)},input:s.data})})):{status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new N(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}};Se.create=(r,t)=>new Se({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 s=this._getOrReturnCtx(t);return h(s,{code:m.invalid_type,expected:f.nan,received:s.parsedType}),y}return{status:"valid",value:t.data}}};Ie.create=r=>new Ie({typeName:b.ZodNaN,...x(r)});var Zn=Symbol("zod_brand"),De=class extends S{_parse(t){let{ctx:n}=this._processInputParams(t),s=n.data;return this._def.type._parse({data:s,path:n.path,parent:n})}unwrap(){return this._def.type}},qe=class r extends S{_parse(t){let{status:n,ctx:s}=this._processInputParams(t);if(s.common.async)return(async()=>{let o=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return o.status==="aborted"?y:o.status==="dirty"?(n.dirty(),ce(o.value)):this._def.out._parseAsync({data:o.value,path:s.path,parent:s})})();{let a=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return a.status==="aborted"?y:a.status==="dirty"?(n.dirty(),{status:"dirty",value:a.value}):this._def.out._parseSync({data:a.value,path:s.path,parent:s})}}static create(t,n){return new r({in:t,out:n,typeName:b.ZodPipeline})}},ke=class extends S{_parse(t){let n=this._def.innerType._parse(t),s=a=>(ee(a)&&(a.value=Object.freeze(a.value)),a);return Ce(n)?n.then(a=>s(a)):s(n)}unwrap(){return this._def.innerType}};ke.create=(r,t)=>new ke({innerType:r,typeName:b.ZodReadonly,...x(t)});function Mt(r,t){let n=typeof r=="function"?r(t):typeof r=="string"?{message:r}:r;return typeof n=="string"?{message:n}:n}function Ht(r,t={},n){return r?re.create().superRefine((s,a)=>{let o=r(s);if(o instanceof Promise)return o.then(c=>{if(!c){let i=Mt(t,s),d=i.fatal??n??!0;a.addIssue({code:"custom",...i,fatal:d})}});if(!o){let c=Mt(t,s),i=c.fatal??n??!0;a.addIssue({code:"custom",...c,fatal:i})}}):re.create()}var Gn={object:U.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 Hn=(r,t={message:`Input not instance of ${r.name}`})=>Ht(n=>n instanceof r,t),Qt=te.create,Wt=le.create,Qn=Ie.create,Wn=de.create,Jt=pe.create,Jn=me.create,Kn=ze.create,Yn=ue.create,Xn=he.create,es=re.create,ts=Y.create,rs=F.create,ns=Ae.create,ss=X.create,as=U.create,os=U.strictCreate,is=fe.create,cs=et.create,ls=ge.create,ds=G.create,ps=tt.create,ms=Oe.create,us=Ee.create,hs=rt.create,fs=ye.create,gs=be.create,ys=_e.create,bs=ve.create,_s=ne.create,vs=q.create,xs=$.create,Ss=H.create,ks=q.createWithPreprocess,js=qe.create,Ts=()=>Qt().optional(),ws=()=>Wt().optional(),Rs=()=>Jt().optional(),Cs={string:r=>te.create({...r,coerce:!0}),number:r=>le.create({...r,coerce:!0}),boolean:r=>pe.create({...r,coerce:!0}),bigint:r=>de.create({...r,coerce:!0}),date:r=>me.create({...r,coerce:!0})};var Ps=y;var zs=r=>typeof r?.safeParse=="function";var yt=r=>typeof r?.passthrough=="function";var As=(r,t)=>yt(r)?yt(t)?r.merge(t):r:yt(t)?t:Object.assign({},r,t);var hl=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()))}),Os=Symbol("ContractNoBody"),Yt=r=>"method"in r&&"path"in r;var Xt=(r,t)=>Object.fromEntries(Object.entries(r).map(([n,s])=>{var a,o,c;return Yt(s)?[n,{...s,path:t?.pathPrefix?t.pathPrefix+s.path:s.path,headers:As(t?.baseHeaders,s.headers),strictStatusCodes:(a=s.strictStatusCodes)!==null&&a!==void 0?a:t?.strictStatusCodes,validateResponseOnClient:(o=s.validateResponseOnClient)!==null&&o!==void 0?o:t?.validateResponseOnClient,responses:{...t?.commonResponses,...s.responses},metadata:t?.metadata?{...t?.metadata,...(c=s.metadata)!==null&&c!==void 0?c:{}}:s.metadata}]:[n,Xt(s,t)]})),bt=Symbol("ContractPlainType"),Q=()=>({router:(r,t)=>Xt(r,t),query:r=>r,mutation:r=>r,responses:r=>r,response:()=>bt,body:()=>bt,type:()=>bt,otherResponse:({contentType:r,body:t})=>({contentType:r,body:t}),noBody:()=>Os}),Es=({path:r,params:t})=>{let n=t;return r.replace(/\/?:([^/?]+)\??/g,(s,a)=>n[a]?`${s.startsWith("/")?"/":""}${n[a]}`:"")},Is=(r,t=!1)=>{let n=t?Ls(r):Ns(r);return n?.length>0?"?"+n:""},Ls=r=>r?Object.entries(r).filter(([,t])=>t!==void 0).map(([t,n])=>{let s;return typeof n=="string"&&!["true","false","null"].includes(n.trim())&&isNaN(Number(n))?s=n:s=JSON.stringify(n),`${encodeURIComponent(t)}=${encodeURIComponent(s)}`}).join("&"):"",Ns=r=>r?Object.keys(r).flatMap(t=>_t(t,r[t])).map(([t,n])=>`${encodeURIComponent(t)}=${encodeURIComponent(n)}`).join("&"):"",_t=(r,t)=>Array.isArray(t)?t.flatMap((n,s)=>_t(`${r}[${s}]`,n)):t instanceof Date?[[`${r}`,t.toISOString()]]:t===null?[[`${r}`,""]]:t===void 0?[]:typeof t=="object"?Object.keys(t).flatMap(n=>_t(`${r}[${n}]`,t[n])):[[`${r}`,`${t}`]];var vt=class extends Error{constructor(t,n){let s=n.join(",");super(`Server returned unexpected response. Expected one of: ${s} got: ${t.status}`),this.response=t}};var Us=async({route:r,path:t,method:n,headers:s,body:a,validateResponse:o,fetchOptions:c})=>{let i=await fetch(t,{...c,method:n,headers:s,body:a}),d=i.headers.get("content-type");if(d?.includes("application/")&&d?.includes("json")){let p={status:i.status,body:await i.json(),headers:i.headers},u=r.responses[p.status];return(o??r.validateResponseOnClient)&&zs(u)?{...p,body:u.parse(p.body)}:p}return d?.includes("text/")?{status:i.status,body:await i.text(),headers:i.headers}:{status:i.status,body:await i.blob(),headers:i.headers}},Bs=r=>{let t=new FormData,n=(s,a)=>{a instanceof File?t.append(s,a):t.append(s,JSON.stringify(a))};return Object.entries(r).forEach(([s,a])=>{if(Array.isArray(a))for(let o of a)n(s,o);else n(s,a)}),t},Kt=r=>Object.fromEntries(Object.entries(r).map(([t,n])=>[t.toLowerCase(),n])),$s=r=>{let{path:t,clientArgs:n,route:s,body:a,query:o,extraInputArgs:c,headers:i,fetchOptions:d}=r,p=n.api||Us,u=n.baseHeaders&&Object.fromEntries(Object.entries(n.baseHeaders).map(([_,P])=>typeof P=="function"?[_,P(r)]:[_,P])),T={...u&&Kt(u),...Kt(i)};Object.keys(T).forEach(_=>{T[_]===void 0&&delete T[_]});let w={route:s,path:t,method:s.method,headers:T,body:void 0,rawBody:a,rawQuery:o,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 s.method!=="GET"&&("contentType"in s&&s.contentType==="multipart/form-data"?w={...w,contentType:"multipart/form-data",body:a instanceof FormData?a:Bs(a)}:"contentType"in s&&s.contentType==="application/x-www-form-urlencoded"?w={...w,contentType:"application/x-www-form-urlencoded",headers:{"content-type":"application/x-www-form-urlencoded",...w.headers},body:typeof a=="string"?a:new URLSearchParams(a)}:a!=null&&(w={...w,contentType:"application/json",headers:{"content-type":"application/json",...w.headers},body:JSON.stringify(a)})),p({...w,...c})},Ds=(r,t,n)=>{let{query:s,params:a,body:o,headers:c,extraHeaders:i,overrideClientOptions:d,fetchOptions:p,cache:u,next:T,...w}=n||{},_={...t,...d};return{path:qs(s,_.baseUrl,a,r,!!_.jsonQuery),clientArgs:_,route:r,body:o,query:s,extraInputArgs:w,fetchOptions:{...u&&{cache:u},...T&&{next:T},...p},headers:{...i,...c}}},qs=(r,t,n,s,a)=>{let o=Es({path:s.path,params:n}),c=Is(r,a);return`${t}${o}${c}`},Ms=(r,t)=>{let n=Object.keys(r.responses);return async s=>{let a=Ds(r,t,s),o=await $s(a);if(!t.throwOnUnknownStatus||n.includes(o.status.toString()))return o;throw new vt(o,n)}},xt=(r,t)=>Object.fromEntries(Object.entries(r).map(([n,s])=>Yt(s)?[n,Ms(s,t)]:[n,xt(s,t)]));var St=["free","creator","team"],er=typeof process<"u"&&process.env?.NODE_ENV!=="production",Fs={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:er?"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:er?"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 tr=Fs.stripe.plans,gl=Object.freeze(Object.fromEntries(tr.map(r=>[r.tier,r])));var Vs=Q(),E=e.object({message:e.string()}),kt=e.record(e.unknown()),je=e.string().regex(/^doc_[0-9A-Za-z]{22}$/),nt=e.string().regex(/^proj_[0-9A-Za-z]{22}$/),Zs=["active","archived"],st=e.enum(Zs),rr=e.object({id:e.string().min(1),display_name:e.string().min(1)}),nr=e.object({id:nt,name:e.string().min(1)}),jt=e.object({id:je,title:e.string().min(1),status:st,author:rr,project:nr.nullable(),created_at:e.string().datetime(),updated_at:e.string().datetime(),archived_at:e.string().datetime().nullable()}),Gs=e.object({type:e.literal("list"),list_type:e.literal("doc"),objects:e.array(jt)}),Hs=e.object({project_id:nt.optional(),status:st.optional()}),Qs=e.object({title:e.string().trim().min(1).max(300).optional(),prosemirror_json:kt.optional(),project_id:nt.nullable().optional()}),Ws=e.object({id:je,created_at:e.string().datetime()}),Js=e.object({title:e.string().trim().min(1).max(300).optional(),prosemirror_json:kt.optional(),project_id:nt.nullable().optional(),status:st.optional()}).refine(r=>Object.keys(r).length>0,{message:"At least one field must be provided"}),Ks=e.object({id:je,updated_at:e.string().datetime()}),Ys=e.object({id:je,title:e.string().min(1),prosemirror_json:kt,status:st,author:rr,project:nr.nullable(),created_at:e.string().datetime(),updated_at:e.string().datetime(),archived_at:e.string().datetime().nullable()}),sr=Vs.router({listDocs:{method:"GET",path:"/docs",headers:e.object({authorization:e.string().min(1).optional()}),query:Hs,responses:{200:Gs,401:E,403:E},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:Qs,responses:{201:Ws,401:E,403:E,404:E,422:E},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:Ys,401:E,403:E,404:E},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:Js,responses:{200:Ks,401:E,403:E,404:E,422:E},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:E,403:E,404:E},summary:"Hard-delete a doc and any mention references it owns"}});var Xs=Q(),C=e.object({message:e.string()}),Tt=e.record(e.unknown()),W=e.string().regex(/^proj_[0-9A-Za-z]{22}$/),ea=["active","archived"],at=e.enum(ea),wt=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:wt}),ta=e.object({id:W,name:e.string().min(1),status:at,author:wt,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()}),ra=e.object({type:e.literal("list"),list_type:e.literal("project"),objects:e.array(ta)}),na=e.object({status:at.optional()}),sa=e.object({name:e.string().trim().min(1).max(200),prosemirror_json:Tt.optional()}),aa=e.object({id:W,created_at:e.string().datetime()}),oa=e.object({name:e.string().trim().min(1).max(200).optional(),prosemirror_json:Tt.optional()}).refine(r=>Object.keys(r).length>0,{message:"At least one field must be provided"}),ia=e.object({id:W,updated_at:e.string().datetime()}),ca=e.object({archived:e.boolean()}),la=e.object({id:W,status:at,archived_at:e.string().datetime().nullable()}),da=e.object({id:W,name:e.string().min(1),prosemirror_json:Tt,status:at,author:wt,created_at:e.string().datetime(),updated_at:e.string().datetime(),archived_at:e.string().datetime().nullable(),threads:e.array(ar),docs:e.array(jt)}),pa=e.object({thread_id:e.string().min(1).max(64)}),ma=ar,or=Xs.router({listProjects:{method:"GET",path:"/projects",headers:e.object({authorization:e.string().min(1).optional()}),query:na,responses:{200:ra,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:sa,responses:{201:aa,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:W}),headers:e.object({authorization:e.string().min(1).optional()}),responses:{200:da,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:W}),headers:e.object({authorization:e.string().min(1).optional()}),body:oa,responses:{200:ia,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:W}),headers:e.object({authorization:e.string().min(1).optional()}),body:ca,responses:{200:la,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:W}),headers:e.object({authorization:e.string().min(1).optional()}),body:pa,responses:{201:ma,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:W,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 ua=Q(),ot=e.object({message:e.string()}),ha=["thread","plan","doc","user"],it=e.enum(ha),fa=["doc","project"],ga=e.enum(fa),ya=e.object({kind:it,id:e.string().min(1),title:e.string().min(1),href:e.string().min(1)}),ba=e.object({type:e.literal("list"),list_type:e.literal("mention"),objects:e.array(ya)}),_a=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(it).optional())}),va=e.object({source_kind:ga,source_id:e.string().min(1),source_title:e.string().min(1),source_href:e.string().min(1),target_kind:it,target_id:e.string().min(1),created_at:e.string().datetime()}),xa=e.object({type:e.literal("list"),list_type:e.literal("backlink"),objects:e.array(va)}),Sa=e.object({target_kind:it,target_id:e.string().min(1).max(64)}),ir=ua.router({searchMentions:{method:"GET",path:"/mentions/search",headers:e.object({authorization:e.string().min(1).optional()}),query:_a,responses:{200:ba,401:ot,422:ot},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:Sa,responses:{200:xa,401:ot,403:ot},summary:"List every doc/project body in the caller\u2019s organization that mentions the given target. Newest-first."}});var ka=Q(),ja=e.object({type:e.literal("list"),list_type:e.literal("thread"),has_more:e.boolean(),objects:e.array(e.unknown())}),se=e.object({message:e.string()}),cr=e.object({thread_id:e.string().min(1),is_favorited:e.boolean(),favorited_at:e.string().datetime().nullable()}),Ta=e.object({before:e.string().min(1).max(64).optional()}),lr=ka.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:cr,401:se,403:se,404:se},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:cr,401:se,403:se,404:se},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:Ta,responses:{200:ja,401:se,403:se},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 wa=Q(),Ra=e.object({id:e.string().uuid(),role:e.enum(["user","assistant"]),content:e.string().min(1),timestamp:e.string().datetime()}),Ca=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()}),Wl=Ca.extend({messages:e.array(Ra)}),l=e.object({message:e.string()}),Pa=/^[a-zA-Z0-9_-]{2,32}$/,yr=e.string().regex(Pa,"Handle must be 2\u201332 characters: letters, numbers, dashes, or underscores."),Rt=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()}),za=e.object({stytchMemberId:e.string().min(1).optional(),emailAddress:e.string().email(),name:e.string().nullable(),user:Rt,is_admin:e.boolean()}),Aa=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"}),Oa=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()}),br=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()}),Ea=e.object({type:e.literal("list"),list_type:e.literal("organization_member"),objects:e.array(Oa)}),Ia=e.object({email_address:e.string().email()}),La=e.object({email_address:e.string().email(),member_id:e.string().min(1)}),Na=e.object({location:e.string().trim().min(1),contact:e.string().trim().email()}),Ua=e.object({location:e.string().min(1),contact:e.string().email(),created_at:e.string().datetime()}),Ba=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()}),$a=e.object({name:e.string().min(1),email_domains:e.array(e.string().min(1)).nonempty(),stytch_org_id:e.string().min(1)}),Da=e.object({user:Ba,organization:$a}),qa=e.object({path_glob:e.string().min(1),name:e.string().min(1),description:e.string().min(1)}),Ma=e.object({repo_origin_path:e.string().min(1),building_blocks:e.array(qa)}),_r=e.string().regex(/^th_[0-9A-Za-z]{22}$/),lt=e.string().regex(/^tb_[0-9A-Za-z]{22}$/),Fa=e.object({id:_r,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:lt,revision_count:e.number().int().positive()}),Va=e.object({id:e.string().min(1),display_name:e.string().min(1)}),Za=e.object({id:e.string().min(1),author_id:e.string().min(1).nullable(),author:Va.nullable(),created_at:e.string().datetime(),deleted_at:e.string().datetime().nullable(),content:e.string().min(1)}),Ga=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(Za)}),Ha=e.object({thread_block_id:lt,from_position:e.number().int().positive(),to_position:e.number().int().positive(),selected_text:e.string().min(1),content:e.string().trim().min(1)}),Qa=e.object({id:e.string().min(1)}),Wa=e.object({content:e.string().trim().min(1)}),Ja=e.object({id:e.string().min(1)}),Ka=e.object({content:e.string().trim().min(1)}),Ya=e.object({id:e.string().min(1)}),Xa=e.object({content:e.string().trim().min(1)}),eo=e.object({id:e.string().min(1)}),to=e.object({resolved:e.boolean()}),ro=e.object({id:e.string().min(1),resolved_at:e.string().datetime().nullable()}),no=e.object({resolved:e.boolean()}),so=e.object({id:e.string().min(1),resolved_at:e.string().datetime().nullable()}),vr=e.record(e.unknown()),ao=e.object({id:lt,body:e.string(),created_at:e.string().datetime(),prosemirror_json:vr,comment_threads:e.array(Ga)}),oo=e.object({id:_r,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:lt,revision_count:e.number().int().positive(),revisions:e.array(ao)}),io=e.object({type:e.literal("list"),list_type:e.literal("plan"),has_more:e.boolean(),objects:e.array(Fa)}),co=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()}),xr=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)}),lo=e.array(xr),po=e.object({type:e.literal("list"),list_type:e.literal("building_block"),has_more:e.boolean(),objects:e.array(xr)}),mo=e.object({repo_origin_path:e.string().min(1),before:e.string().min(1).optional(),after:e.string().min(1).optional()}),uo=e.enum(["thread","building_block"]),ho=e.object({repo_origin_path:e.string().min(1),sources:e.array(uo).nonempty()}),fo=e.object({type:e.literal("list"),list_type:e.literal("repository"),has_more:e.boolean(),objects:e.array(ho)}),ae=e.enum(["claudeCode","codex","amp","cursor","unspecified"]),go=["transcript","plan"],yo=e.enum(go),bo=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:yo.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"}),Pt=e.object({id:e.string().min(1),display_name:e.string().min(1)}),_o=e.object({id:e.string().min(1),display_name:e.string().min(1)}),Sr=e.object({id:e.string().min(1),author_id:e.string().min(1).nullable(),author:_o.nullable(),created_at:e.string().datetime(),deleted_at:e.string().datetime().nullable(),content:e.string().min(1)}),kr=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()}),vo=kr.extend({comments:e.array(Sr)}),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(vo).optional()}).passthrough(),jr=e.object({type:e.literal("list"),list_type:e.literal("thread_block"),has_more:e.boolean(),objects:e.array(Me)}),dr=Me.extend({type:e.literal("plan"),prosemirror_json:vr,thread_file_id:e.string().min(1)}),xo=e.union([e.literal(-1),e.literal(1)]),Tr=e.union([e.literal(-1),e.literal(0),e.literal(1)]),pr=e.object({score:e.number().int(),up_count:e.number().int().nonnegative(),down_count:e.number().int().nonnegative(),viewer_vote:Tr}),So=e.object({value:xo}),ko=e.object({id:e.string().min(1),display_name:e.string().min(1),avatar_url:e.string().nullable()}),Te=e.object({id:e.string().min(1),thread_id:e.string().min(1),author_id:e.string().min(1).nullable(),author:ko.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()}),jo=e.object({type:e.literal("list"),list_type:e.literal("thread_comment"),objects:e.array(Te)}),To=e.object({content:e.string().trim().min(1).max(4e3),parent_comment_id:e.string().min(1).optional()}),wo=Te,Ro=e.object({content:e.string().trim().min(1).max(4e3)}),Co=Te,Po=Te,Jl=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:Te}),e.object({kind:e.literal("updated"),thread_id:e.string().min(1),actor_user_id:e.string().min(1),version:e.number(),comment:Te}),e.object({kind:e.literal("deleted"),thread_id:e.string().min(1),actor_user_id:e.string().min(1),version:e.number(),comment:Te})]),zo=e.enum(["pending","generating","ready","failed"]),Ao=e.enum(["pending","generating","ready","failed"]),Oo=e.enum(["pending","placeholder","ai","user"]),wr=e.enum(["pending","generating","ready","failed"]),Eo=e.enum(["asked","requested","decided","corrected","shared"]),Io=e.object({id:e.string().min(1),kind:Eo,summary:e.string().min(1),block_id:e.string().min(1)}),Lo=e.object({type:e.literal("list"),list_type:e.literal("thread_decision"),status:wr,generated_at:e.string().nullable(),objects:e.array(Io)}),Le=e.object({id:e.string().min(1),thread_file_id:e.string().min(1),organization_id:e.string().min(1),author:Pt,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:zo,summary_generated_at:e.string().nullable(),title_status:Ao,title_generated_at:e.string().nullable(),title_source:Oo,decisions_status:wr,decisions_generated_at:e.string().nullable(),score:e.number().int(),up_count:e.number().int().nonnegative(),down_count:e.number().int().nonnegative(),viewer_vote:Tr,comment_count:e.number().int().nonnegative(),is_favorited:e.boolean()}),No=e.object({storage_url:e.string().min(1)}),Uo=e.object({storage_url:e.string(),harness:ae,thread:Le.nullable()}),Bo=e.object({status:e.literal("complete"),thread_files:e.array(Uo)}),$o=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:Le.nullable()}),Do=e.object({id:e.string(),substrate:e.enum(["s3","filesystem"]),status:e.enum(["incomplete","locked_for_parsing","complete","error"]),thread_files:e.array($o)}),qo=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"}),Mo=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})]),Fo=Le,mr=e.object({type:e.literal("list"),list_type:e.literal("thread"),has_more:e.boolean(),objects:e.array(Fo)}),Vo=e.enum(["recent","popular"]),Zo=Le,Go=e.object({type:e.literal("list"),list_type:e.literal("discover_thread"),has_more:e.boolean(),objects:e.array(Zo)}),Ho=e.object({before:e.string().min(1).optional(),after:e.string().min(1).optional(),sort:Vo.optional(),harness:ae.optional(),search:e.string().max(200).optional()}),Qo=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())}),Wo=e.object({id:e.string(),status:e.enum(["incomplete","locked_for_parsing","complete","error"]),created_at:e.string(),thread_count:e.number().int().nonnegative()}),Jo=e.object({type:e.literal("list"),list_type:e.literal("upload_session"),objects:e.array(Wo)}),Ko=e.object({before:e.string().min(1).optional(),after:e.string().min(1).optional()}),Yo=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()}),Xo=e.object({path:e.string().min(1),start_offset:e.number().int().nonnegative(),end_offset:e.number().int().positive()}),ei=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()}),ti=e.object({type:e.literal("list"),list_type:e.literal("skill"),objects:e.array(ei)}),ri=e.object({id:e.string(),title:e.string(),visibility:e.enum(["private","workspace","public"]),started_at:e.string(),author:Pt,skills_invoked:e.array(e.string())}),ni=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(ri)}),si=e.object({path:e.string().min(1),text:e.string().max(64e3)}),ai=e.enum(["text_edit","redact","delete_block"]),oi=e.object({id:e.string(),thread_block_id:e.string(),editor:e.object({id:e.string(),display_name:e.string()}),kind:ai,path:e.string().nullable(),previous_text:e.string().nullable(),new_text:e.string().nullable(),created_at:e.string()}),ii=e.object({type:e.literal("list"),list_type:e.literal("thread_block_edit"),objects:e.array(oi)}),ci=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()}),li=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()}),di=e.object({type:e.literal("list"),list_type:e.literal("admin_organization"),objects:e.array(li)}),Rr=e.object({id:e.string(),name:e.string()}),pi=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)}),mi=e.object({type:e.literal("list"),list_type:e.literal("admin_user"),objects:e.array(pi)}),ui=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:Pt,organization:Rr}),hi=e.object({type:e.literal("list"),list_type:e.literal("admin_thread"),has_more:e.boolean(),objects:e.array(ui)}),fi=e.object({before:e.string().min(1).optional(),after:e.string().min(1).optional()}),ur=e.object({token:e.string().min(1),thread_id:e.string().min(1)}),gi=e.object({visitor:e.string().min(1).max(64).optional()}),yi=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()}),bi=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(yi)}),_i=e.object({windows:e.array(bi)}),vi=e.object({quoted_text:e.string().min(1),comment:e.string().nullable(),type:e.enum(["comment","highlight:trapdoor"])}),xi=kr,Si=Sr.extend({comment_thread_id:e.string().min(1)}),ki=e.object({markdown:e.string().min(1)}),ji=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(vi),comment_threads:e.array(xi),comments:e.array(Si)}),Ne=e.enum(St),Cr=e.object({skills:e.boolean(),workspace_scope:e.boolean(),review:e.boolean(),shared_thread_ttl_days:e.number().int().positive().nullable()}),Ct=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:Cr}),Ti=e.object({effective_plan:Ne,features:Cr,user:Ct,organization:Ct.nullable()}),wi=e.object({plan:e.enum(["creator","team"]),seat_quantity:e.number().int().positive().optional()}),Ri=e.object({checkout_url:e.string().min(1)}),Ci=e.object({portal_url:e.string().min(1)}),Pi=e.object({seat_quantity:e.number().int().positive()}),hr=e.object({plan:Ne.nullable()}),ct=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()}),zi=e.object({users:e.array(ct),organizations:e.array(ct)}),Ai=e.object({id:e.string().min(1),display_name:e.string().min(1),handle:e.string().nullable(),avatar_url:e.string().nullable()}),Oi=e.object({thread_id:e.string().min(1),title:e.string().min(1),author:Ai,last_active_at:e.string().datetime(),last_block_excerpt:e.string().nullable(),last_block_kind:e.string().min(1).nullable(),is_streaming:e.boolean()}),Ei=e.object({type:e.literal("list"),list_type:e.literal("live_thread"),objects:e.array(Oi)}),Ii=e.object({thread_id:e.string().min(1)}),Li=e.object({thread_id:e.string().min(1),last_seen_at:e.string().datetime(),started_at:e.string().datetime()}),Ni=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()}),Ui=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()}),Pr=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()}),fr=e.object({type:e.literal("list"),list_type:e.literal("user_follow"),objects:e.array(Pr)}),Bi=e.object({date:e.string().regex(/^\d{4}-\d{2}-\d{2}$/),count:e.number().int().nonnegative()}),$i=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(Bi)}),Di=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"])})}),qi=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"])})}),Mi=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)})}),Fi=e.object({type:e.literal("user_followed"),occurred_at:e.string().datetime(),id:e.string().min(1),followee:Pr}),Vi=e.discriminatedUnion("type",[Di,qi,Mi,Fi]),Zi=e.object({type:e.literal("list"),list_type:e.literal("user_activity"),objects:e.array(Vi)}),Gi=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()}),Hi=e.object({type:e.literal("list"),list_type:e.literal("profile_published_project"),objects:e.array(Gi)}),gr=e.object({id:e.string().min(1),published_at:e.string().datetime().nullable()}),Qi=e.enum(["avatar","banner"]),Wi=e.enum(["image/png","image/jpeg","image/webp","image/gif"]),Ji=e.object({kind:Qi,content_type:Wi,base64_data:e.string().min(1)}),Ki=e.object({substrate:e.enum(["s3","filesystem"]),storage_url:e.string().min(1)}),Yi=br,zr=wa.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:za,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:Ii,responses:{200:Li,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:Ei,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:Yo,responses:{200:mr,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:mr,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:Ko,responses:{200:jr,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:Wa,responses:{201:Ja,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:Xa,responses:{201:eo,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:no,responses:{200:so,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:ti,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:ni,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:Xo,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:si,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:ii,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:Lo,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:qo,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:So,responses:{200:pr,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:pr,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:jo,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:To,responses:{201:wo,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:Ro,responses:{200:Co,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:Po,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:Mo,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:Da,responses:{201:Rt,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:br,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:Aa,responses:{200:Rt,401:l,409:l,422:l},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:Yi,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:Zi,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:$i,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:fr,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:fr,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:Ni,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:Ui,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:Hi,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:gr,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:gr,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:Ji,responses:{200:Ki,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:Ea,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:Ia,responses:{201:La,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:fo,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:Ma,responses:{201:lo,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:oo,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:Ha,responses:{201:Qa,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:Ka,responses:{201:Ya,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:to,responses:{200:ro,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:co,responses:{200:io,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:mo,responses:{200:po,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:Jo,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(bo).nonempty()}),responses:{201:Do,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(No).nonempty()}),responses:{200:Bo,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:ci,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:di,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:mi,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:fi,responses:{200:hi,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:Ho,responses:{200:Go},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:Qo},summary:"Unauthenticated rollup of public-thread counts for the Discover header."},createWaitlistEntry:{method:"POST",path:"/waitlist_entries",body:Na,responses:{201:Ua,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:ur,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:gi,responses:{200:ur,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:_i,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:ki,responses:{200:ji,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:Ti,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:wi,responses:{200:Ri,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:Ci,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:Pi,responses:{200:Ct,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:zi,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:hr,responses:{200:ct,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:hr,responses:{200:ct,401:l,403:l,404:l},summary:"Admin override for an organization's plan tier. Null clears the override."},projects:or,docs:sr,mentions:ir,favorites:lr},{pathPrefix:"/api"});import Ve from"node:fs";import Or from"node:path";import ec from"node:os";import Ar from"node:path";var Xi="prod";function L(){return Xi}function Fe(){let r=L()==="dev"?".lore-dev":".lore";return Ar.join(ec.homedir(),r)}function dt(){return Ar.join(Fe(),"log.txt")}function pt(){return Or.join(Fe(),"token")}function zt(){let r;try{r=Ve.readFileSync(pt(),"utf8")}catch(n){if(n&&typeof n=="object"&&"code"in n&&n.code==="ENOENT")return{token:"",source:"none"};throw n}let t=r.trim();return!t||rc(t,new Date)?{token:"",source:"none"}:{token:t,source:"file"}}function Er(){return zt().token}function Ir(){return Ve.existsSync(pt())}function Lr(r){let t=pt();Ve.mkdirSync(Or.dirname(t),{recursive:!0,mode:448}),Ve.writeFileSync(t,r,{mode:384})}function Nr(){try{Ve.rmSync(pt())}catch(r){if(r&&typeof r=="object"&&"code"in r&&r.code==="ENOENT")return;throw r}}function tc(r){let t=r.split(".");if(t.length<2)throw new Error("invalid JWT format");return JSON.parse(Buffer.from(t[1],"base64url").toString("utf8"))}function rc(r,t){let n;try{n=tc(r)}catch{return!1}let s=n["https://stytch.com/session"]?.expires_at;if(typeof s!="string")return!1;let a=Date.parse(s.trim());return Number.isNaN(a)?!1:t.getTime()>=a}var nc={dev:"http://localhost:4000",prod:"https://lore.tanagram.ai"};function Ue(r={}){let t=r.token??Er();return xt(zr,{baseUrl:nc[L()],baseHeaders:t?{authorization:`Bearer ${t}`}:{}})}import Br from"node:fs";var Ur=!1;function sc(){Ur||(Br.mkdirSync(Fe(),{recursive:!0}),Ur=!0)}function ac(r){let t=typeof r=="string"?r:JSON.stringify(r);return/[\s"=]/.test(t)?JSON.stringify(t):t}function oc(r,t,n){let s=`${new Date().toISOString()} ${r} ${t}`;if(!n)return`${s}
5
- `;let a=Object.entries(n).map(([o,c])=>`${o}=${ac(c)}`).join(" ");return a?`${s} ${a}
2
+ var on=Object.defineProperty;var cn=(r,t)=>{for(var n in t)on(r,n,{get:t[n],enumerable:!0})};import{pathToFileURL as Oc}from"node:url";var ln=/\d/,dn=["-","_","/","."];function pn(r=""){if(!ln.test(r))return r!==r.toLowerCase()}function It(r,t){let n=t??dn,s=[];if(!r||typeof r!="string")return s;let a="",o,c;for(let i of r){let d=n.includes(i);if(d===!0){s.push(a),a="",o=void 0;continue}let p=pn(i);if(c===!1){if(o===!1&&p===!0){s.push(a),a=i,o=p;continue}if(o===!0&&p===!1&&a.length>1){let u=a.at(-1);s.push(a.slice(0,Math.max(0,a.length-1))),a=u+i,o=p;continue}}a+=i,o=p,c=d}return s.push(a),s}function mn(r){return r?r[0].toUpperCase()+r.slice(1):""}function un(r){return r?r[0].toLowerCase()+r.slice(1):""}function hn(r,t){return r?(Array.isArray(r)?r:It(r)).map(n=>mn(t?.normalize?n.toLowerCase():n)).join(""):""}function Be(r,t){return un(hn(r||"",t))}function Ze(r,t){return r?(Array.isArray(r)?r:It(r)).map(n=>n.toLowerCase()).join(t??"-"):""}function Lt(r){return Ze(r||"","_")}import{parseArgs as fn}from"node:util";function Je(r){return Array.isArray(r)?r:r===void 0?[]:[r]}function mt(r,t=""){let n=[];for(let s of r)for(let[a,o]of s.entries())n[a]=Math.max(n[a]||0,o.length);return r.map(s=>s.map((a,o)=>t+a[o===0?"padStart":"padEnd"](n[o])).join(" ")).join(`
3
+ `)}function B(r){return typeof r=="function"?r():r}var ie=class extends Error{code;constructor(r,t){super(r),this.name="CLIError",this.code=t}};function gn(r=[],t={}){let n=new Set(t.boolean||[]),s=new Set(t.string||[]),a=t.alias||{},o=t.default||{},c=new Map,i=new Map;for(let[v,k]of Object.entries(a)){let z=k;for(let F of z)c.set(v,F),i.has(F)||i.set(F,[]),i.get(F).push(v),c.set(F,v),i.has(v)||i.set(v,[]),i.get(v).push(F)}let d={};function p(v){if(n.has(v))return"boolean";let k=i.get(v)||[];for(let z of k)if(n.has(z))return"boolean";return"string"}function u(v){if(s.has(v))return!0;let k=i.get(v)||[];for(let z of k)if(s.has(z))return!0;return!1}let T=new Set([...n,...s,...Object.keys(a),...Object.values(a).flat(),...Object.keys(o)]);for(let v of T)d[v]||(d[v]={type:p(v),default:o[v]});for(let[v,k]of c.entries())v.length===1&&d[k]&&!d[k].short&&(d[k].short=v);let w=[],_={};for(let v=0;v<r.length;v++){let k=r[v];if(k==="--"){w.push(...r.slice(v));break}if(k.startsWith("--no-")){let z=k.slice(5);_[z]=!0;continue}w.push(k)}let P;try{P=fn({args:w,options:Object.keys(d).length>0?d:void 0,allowPositionals:!0,strict:!1})}catch{P={values:{},positionals:w}}let R={_:[]};R._=P.positionals;for(let[v,k]of Object.entries(P.values)){let z=k;p(v)==="boolean"&&typeof k=="string"?z=k!=="false":u(v)&&typeof k=="boolean"&&(z=""),R[v]=z}for(let[v]of Object.entries(_)){R[v]=!1;let k=c.get(v);k&&(R[k]=!1);let z=i.get(v);if(z)for(let F of z)R[F]=!1}for(let[v,k]of c.entries())R[v]!==void 0&&R[k]===void 0&&(R[k]=R[v]),R[k]!==void 0&&R[v]===void 0&&(R[v]=R[k]),R[v]!==R[k]&&o[k]===R[k]&&(R[k]=R[v]);return R}var yn=(()=>{let r=globalThis.process?.env??{};return r.NO_COLOR==="1"||r.TERM==="dumb"||r.TEST||r.CI})(),Ke=(r,t=39)=>n=>yn?n:`\x1B[${r}m${n}\x1B[${t}m`,Ge=Ke(1,22),M=Ke(36),Qe=Ke(90),He=Ke(4,24);function bn(r,t){let n={boolean:[],string:[],alias:{},default:{}},s=Bt(t);for(let i of s){if(i.type==="positional")continue;i.type==="string"||i.type==="enum"?n.string.push(i.name):i.type==="boolean"&&n.boolean.push(i.name),i.default!==void 0&&(n.default[i.name]=i.default),i.alias&&(n.alias[i.name]=i.alias);let d=Be(i.name),p=Ze(i.name);if(d!==i.name||p!==i.name){let u=Je(n.alias[i.name]||[]);d!==i.name&&!u.includes(d)&&u.push(d),p!==i.name&&!u.includes(p)&&u.push(p),u.length>0&&(n.alias[i.name]=u)}}let a=gn(r,n),[...o]=a._,c=new Proxy(a,{get(i,d){return i[d]??i[Be(d)]??i[Ze(d)]}});for(let[,i]of s.entries())if(i.type==="positional"){let d=o.shift();if(d!==void 0)c[i.name]=d;else{if(i.default===void 0&&i.required!==!1)throw new ie(`Missing required positional argument: ${i.name.toUpperCase()}`,"EARG");c[i.name]=i.default}}else if(i.type==="enum"){let d=c[i.name],p=i.options||[];if(d!==void 0&&p.length>0&&!p.includes(d))throw new ie(`Invalid value for argument: ${M(`--${i.name}`)} (${M(d)}). Expected one of: ${p.map(u=>M(u)).join(", ")}.`,"EARG")}else if(i.required&&c[i.name]===void 0)throw new ie(`Missing required argument: --${i.name}`,"EARG");return c}function Bt(r){let t=[];for(let[n,s]of Object.entries(r||{}))t.push({...s,name:n,alias:Je(s.alias)});return t}async function _n(r){return Promise.all(r.map(t=>B(t)))}async function We(r,t){let n=await B(r.args||{}),s=bn(t.rawArgs,n),a={rawArgs:t.rawArgs,args:s,data:t.data,cmd:r},o=await _n(r.plugins??[]),c,i;try{for(let u of o)await u.setup?.(a);typeof r.setup=="function"&&await r.setup(a);let p=await B(r.subCommands);if(p&&Object.keys(p).length>0){let u=vn(t.rawArgs,n),T=t.rawArgs[u];if(T){let w=await Nt(p,T);if(!w)throw new ie(`Unknown command ${M(T)}`,"E_UNKNOWN_COMMAND");await We(w,{rawArgs:t.rawArgs.slice(u+1)})}else{let w=await B(r.default);if(w){if(r.run)throw new ie("Cannot specify both 'run' and 'default' on the same command.","E_DEFAULT_CONFLICT");let _=await Nt(p,w);if(!_)throw new ie(`Default sub command ${M(w)} not found in subCommands.`,"E_UNKNOWN_COMMAND");await We(_,{rawArgs:t.rawArgs})}else if(!r.run)throw new ie("No command specified.","E_NO_COMMAND")}}typeof r.run=="function"&&(c=await r.run(a))}catch(p){i=p}let d=[];if(typeof r.cleanup=="function")try{await r.cleanup(a)}catch(p){d.push(p)}for(let p of[...o].reverse())try{await p.cleanup?.(a)}catch(u){d.push(u)}if(i)throw i;if(d.length===1)throw d[0];if(d.length>1)throw new Error("Multiple cleanup errors",{cause:d});return{result:c}}async function Nt(r,t){if(t in r)return B(r[t]);for(let n of Object.values(r)){let s=await B(n),a=await B(s?.meta);if(a?.alias&&Je(a.alias).includes(t))return s}}function vn(r,t){for(let n=0;n<r.length;n++){let s=r[n];if(s==="--")return-1;if(s.startsWith("-")){!s.includes("=")&&xn(s,t)&&n++;continue}return n}return-1}function xn(r,t){let n=r.replace(/^-{1,2}/,""),s=Be(n);for(let[a,o]of Object.entries(t))if(!(o.type!=="string"&&o.type!=="enum")&&(s===Be(a)||(Array.isArray(o.alias)?o.alias:o.alias?[o.alias]:[]).includes(n)))return!0;return!1}var Sn=/^no[-A-Z]/;async function $t(r,t){let n=await B(r.meta||{}),s=Bt(await B(r.args||{})),a=await B(t?.meta||{}),o=`${a.name?`${a.name} `:""}`+(n.name||process.argv[1]),c=[],i=[],d=[],p=[];for(let _ of s)if(_.type==="positional"){let P=_.name.toUpperCase(),R=_.required!==!1&&_.default===void 0;i.push([M(P+ut(_)),Ut(_,R)]),p.push(R?`<${P}>`:`[${P}]`)}else{let P=_.required===!0&&_.default===void 0,R=[...(_.alias||[]).map(v=>`-${v}`),`--${_.name}`].join(", ")+ut(_);if(c.push([M(R),Ut(_,P)]),_.type==="boolean"&&(_.default===!0||_.negativeDescription)&&!Sn.test(_.name)){let v=[...(_.alias||[]).map(k=>`--no-${k}`),`--no-${_.name}`].join(", ");c.push([M(v),[_.negativeDescription,P?Qe("(Required)"):""].filter(Boolean).join(" ")])}P&&p.push(`--${_.name}`+ut(_))}if(r.subCommands){let _=[],P=await B(r.subCommands);for(let[R,v]of Object.entries(P)){let k=await B((await B(v))?.meta);if(k?.hidden)continue;let z=Je(k?.alias),F=[R,...z].join(", ");d.push([M(F),k?.description||""]),_.push(R,...z)}p.push(_.join("|"))}let u=[],T=n.version||a.version;u.push(Qe(`${n.description} (${o+(T?` v${T}`:"")})`),"");let w=c.length>0||i.length>0;return u.push(`${He(Ge("USAGE"))} ${M(`${o}${w?" [OPTIONS]":""} ${p.join(" ")}`)}`,""),i.length>0&&(u.push(He(Ge("ARGUMENTS")),""),u.push(mt(i," ")),u.push("")),c.length>0&&(u.push(He(Ge("OPTIONS")),""),u.push(mt(c," ")),u.push("")),d.length>0&&(u.push(He(Ge("COMMANDS")),""),u.push(mt(d," ")),u.push("",`Use ${M(`${o} <command> --help`)} for more information about a command.`)),u.filter(_=>typeof _=="string").join(`
4
+ `)}function ut(r){let t=r.valueHint?`=<${r.valueHint}>`:"",n=t||`=<${Lt(r.name)}>`;return!r.type||r.type==="positional"||r.type==="boolean"?t:r.type==="enum"&&r.options?.length?`=<${r.options.join("|")}>`:n}function Ut(r,t){let n=t?Qe("(Required)"):"",s=r.default===void 0?"":Qe(`(Default: ${r.default})`);return[r.description,n,s].filter(Boolean).join(" ")}var e={};cn(e,{BRAND:()=>Qn,DIRTY:()=>ce,EMPTY_PATH:()=>wn,INVALID:()=>y,NEVER:()=>Es,OK:()=>E,ParseStatus:()=>A,Schema:()=>S,ZodAny:()=>re,ZodArray:()=>X,ZodBigInt:()=>de,ZodBoolean:()=>pe,ZodBranded:()=>De,ZodCatch:()=>Se,ZodDate:()=>me,ZodDefault:()=>xe,ZodDiscriminatedUnion:()=>et,ZodEffects:()=>q,ZodEnum:()=>_e,ZodError:()=>N,ZodFirstPartyTypeKind:()=>b,ZodFunction:()=>rt,ZodIntersection:()=>ge,ZodIssueCode:()=>m,ZodLazy:()=>ye,ZodLiteral:()=>be,ZodMap:()=>Ee,ZodNaN:()=>Ie,ZodNativeEnum:()=>ve,ZodNever:()=>V,ZodNull:()=>he,ZodNullable:()=>H,ZodNumber:()=>le,ZodObject:()=>U,ZodOptional:()=>$,ZodParsedType:()=>f,ZodPipeline:()=>qe,ZodPromise:()=>ne,ZodReadonly:()=>ke,ZodRecord:()=>tt,ZodSchema:()=>S,ZodSet:()=>Oe,ZodString:()=>te,ZodSymbol:()=>ze,ZodTransformer:()=>q,ZodTuple:()=>G,ZodType:()=>S,ZodUndefined:()=>ue,ZodUnion:()=>fe,ZodUnknown:()=>Y,ZodVoid:()=>Ae,addIssueToContext:()=>h,any:()=>ns,array:()=>is,bigint:()=>Yn,boolean:()=>Jt,coerce:()=>As,custom:()=>Ht,date:()=>Xn,datetimeRegex:()=>Zt,defaultErrorMap:()=>J,discriminatedUnion:()=>ps,effect:()=>ks,enum:()=>vs,function:()=>ys,getErrorMap:()=>Re,getParsedType:()=>Z,instanceof:()=>Jn,intersection:()=>ms,isAborted:()=>Ye,isAsync:()=>Ce,isDirty:()=>Xe,isValid:()=>ee,late:()=>Wn,lazy:()=>bs,literal:()=>_s,makeIssue:()=>$e,map:()=>fs,nan:()=>Kn,nativeEnum:()=>xs,never:()=>as,null:()=>rs,nullable:()=>Ts,number:()=>Wt,object:()=>cs,objectUtil:()=>ht,oboolean:()=>zs,onumber:()=>Ps,optional:()=>js,ostring:()=>Cs,pipeline:()=>Rs,preprocess:()=>ws,promise:()=>Ss,quotelessJson:()=>kn,record:()=>hs,set:()=>gs,setErrorMap:()=>Tn,strictObject:()=>ls,string:()=>Qt,symbol:()=>es,transformer:()=>ks,tuple:()=>us,undefined:()=>ts,union:()=>ds,unknown:()=>ss,util:()=>j,void:()=>os});var j;(function(r){r.assertEqual=a=>{};function t(a){}r.assertIs=t;function n(a){throw new Error}r.assertNever=n,r.arrayToEnum=a=>{let o={};for(let c of a)o[c]=c;return o},r.getValidEnumValues=a=>{let o=r.objectKeys(a).filter(i=>typeof a[a[i]]!="number"),c={};for(let i of o)c[i]=a[i];return r.objectValues(c)},r.objectValues=a=>r.objectKeys(a).map(function(o){return a[o]}),r.objectKeys=typeof Object.keys=="function"?a=>Object.keys(a):a=>{let o=[];for(let c in a)Object.prototype.hasOwnProperty.call(a,c)&&o.push(c);return o},r.find=(a,o)=>{for(let c of a)if(o(c))return c},r.isInteger=typeof Number.isInteger=="function"?a=>Number.isInteger(a):a=>typeof a=="number"&&Number.isFinite(a)&&Math.floor(a)===a;function s(a,o=" | "){return a.map(c=>typeof c=="string"?`'${c}'`:c).join(o)}r.joinValues=s,r.jsonStringifyReplacer=(a,o)=>typeof o=="bigint"?o.toString():o})(j||(j={}));var ht;(function(r){r.mergeShapes=(t,n)=>({...t,...n})})(ht||(ht={}));var f=j.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Z=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=j.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),kn=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:"),N=class r extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=s=>{this.issues=[...this.issues,s]},this.addIssues=(s=[])=>{this.issues=[...this.issues,...s]};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},s={_errors:[]},a=o=>{for(let c of o.issues)if(c.code==="invalid_union")c.unionErrors.map(a);else if(c.code==="invalid_return_type")a(c.returnTypeError);else if(c.code==="invalid_arguments")a(c.argumentsError);else if(c.path.length===0)s._errors.push(n(c));else{let i=s,d=0;for(;d<c.path.length;){let p=c.path[d];d===c.path.length-1?(i[p]=i[p]||{_errors:[]},i[p]._errors.push(n(c))):i[p]=i[p]||{_errors:[]},i=i[p],d++}}};return a(this),s}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,j.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=n=>n.message){let n={},s=[];for(let a of this.issues)if(a.path.length>0){let o=a.path[0];n[o]=n[o]||[],n[o].push(t(a))}else s.push(t(a));return{formErrors:s,fieldErrors:n}}get formErrors(){return this.flatten()}};N.create=r=>new N(r);var jn=(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,j.jsonStringifyReplacer)}`;break;case m.unrecognized_keys:n=`Unrecognized key(s) in object: ${j.joinValues(r.keys,", ")}`;break;case m.invalid_union:n="Invalid input";break;case m.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${j.joinValues(r.options)}`;break;case m.invalid_enum_value:n=`Invalid enum value. Expected ${j.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}"`:j.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,j.assertNever(r)}return{message:n}},J=jn;var Dt=J;function Tn(r){Dt=r}function Re(){return Dt}var $e=r=>{let{data:t,path:n,errorMaps:s,issueData:a}=r,o=[...n,...a.path||[]],c={...a,path:o};if(a.message!==void 0)return{...a,path:o,message:a.message};let i="",d=s.filter(p=>!!p).slice().reverse();for(let p of d)i=p(c,{data:t,defaultError:i}).message;return{...a,path:o,message:i}},wn=[];function h(r,t){let n=Re(),s=$e({issueData:t,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,n,n===J?void 0:J].filter(a=>!!a)});r.common.issues.push(s)}var A=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 s=[];for(let a of n){if(a.status==="aborted")return y;a.status==="dirty"&&t.dirty(),s.push(a.value)}return{status:t.value,value:s}}static async mergeObjectAsync(t,n){let s=[];for(let a of n){let o=await a.key,c=await a.value;s.push({key:o,value:c})}return r.mergeObjectSync(t,s)}static mergeObjectSync(t,n){let s={};for(let a of n){let{key:o,value:c}=a;if(o.status==="aborted"||c.status==="aborted")return y;o.status==="dirty"&&t.dirty(),c.status==="dirty"&&t.dirty(),o.value!=="__proto__"&&(typeof c.value<"u"||a.alwaysSet)&&(s[o.value]=c.value)}return{status:t.value,value:s}}},y=Object.freeze({status:"aborted"}),ce=r=>({status:"dirty",value:r}),E=r=>({status:"valid",value:r}),Ye=r=>r.status==="aborted",Xe=r=>r.status==="dirty",ee=r=>r.status==="valid",Ce=r=>typeof Promise<"u"&&r instanceof Promise;var g;(function(r){r.errToObj=t=>typeof t=="string"?{message:t}:t||{},r.toString=t=>typeof t=="string"?t:t?.message})(g||(g={}));var D=class{constructor(t,n,s,a){this._cachedPath=[],this.parent=t,this.data=n,this._path=s,this._key=a}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},qt=(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 N(r.common.issues);return this._error=n,this._error}}};function x(r){if(!r)return{};let{errorMap:t,invalid_type_error:n,required_error:s,description:a}=r;if(t&&(n||s))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:a}:{errorMap:(c,i)=>{let{message:d}=r;return c.code==="invalid_enum_value"?{message:d??i.defaultError}:typeof i.data>"u"?{message:d??s??i.defaultError}:c.code!=="invalid_type"?{message:i.defaultError}:{message:d??n??i.defaultError}},description:a}}var S=class{get description(){return this._def.description}_getType(t){return Z(t.data)}_getOrReturnCtx(t,n){return n||{common:t.parent.common,data:t.data,parsedType:Z(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new A,ctx:{common:t.parent.common,data:t.data,parsedType:Z(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 s=this.safeParse(t,n);if(s.success)return s.data;throw s.error}safeParse(t,n){let s={common:{issues:[],async:n?.async??!1,contextualErrorMap:n?.errorMap},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Z(t)},a=this._parseSync({data:t,path:s.path,parent:s});return qt(s,a)}"~validate"(t){let n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Z(t)};if(!this["~standard"].async)try{let s=this._parseSync({data:t,path:[],parent:n});return ee(s)?{value:s.value}:{issues:n.common.issues}}catch(s){s?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:n}).then(s=>ee(s)?{value:s.value}:{issues:n.common.issues})}async parseAsync(t,n){let s=await this.safeParseAsync(t,n);if(s.success)return s.data;throw s.error}async safeParseAsync(t,n){let s={common:{issues:[],contextualErrorMap:n?.errorMap,async:!0},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Z(t)},a=this._parse({data:t,path:s.path,parent:s}),o=await(Ce(a)?a:Promise.resolve(a));return qt(s,o)}refine(t,n){let s=a=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(a):n;return this._refinement((a,o)=>{let c=t(a),i=()=>o.addIssue({code:m.custom,...s(a)});return typeof Promise<"u"&&c instanceof Promise?c.then(d=>d?!0:(i(),!1)):c?!0:(i(),!1)})}refinement(t,n){return this._refinement((s,a)=>t(s)?!0:(a.addIssue(typeof n=="function"?n(s,a):n),!1))}_refinement(t){return new q({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 $.create(this,this._def)}nullable(){return H.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return X.create(this)}promise(){return ne.create(this,this._def)}or(t){return fe.create([this,t],this._def)}and(t){return ge.create(this,t,this._def)}transform(t){return new q({...x(this._def),schema:this,typeName:b.ZodEffects,effect:{type:"transform",transform:t}})}default(t){let n=typeof t=="function"?t:()=>t;return new xe({...x(this._def),innerType:this,defaultValue:n,typeName:b.ZodDefault})}brand(){return new De({typeName:b.ZodBranded,type:this,...x(this._def)})}catch(t){let n=typeof t=="function"?t:()=>t;return new Se({...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 qe.create(this,t)}readonly(){return ke.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Rn=/^c[^\s-]{8,}$/i,Cn=/^[0-9a-z]+$/,Pn=/^[0-9A-HJKMNP-TV-Z]{26}$/i,zn=/^[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,An=/^[a-z0-9_-]{21}$/i,En=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,On=/^[-+]?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)?)??$/,In=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Ln="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",ft,Nn=/^(?:(?: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])$/,Un=/^(?:(?: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])$/,Dn=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,qn=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Vt="((\\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])))",Mn=new RegExp(`^${Vt}$`);function Ft(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 Vn(r){return new RegExp(`^${Ft(r)}$`)}function Zt(r){let t=`${Vt}T${Ft(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 Fn(r,t){return!!((t==="v4"||!t)&&Nn.test(r)||(t==="v6"||!t)&&Bn.test(r))}function Zn(r,t){if(!En.test(r))return!1;try{let[n]=r.split(".");if(!n)return!1;let s=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),a=JSON.parse(atob(s));return!(typeof a!="object"||a===null||"typ"in a&&a?.typ!=="JWT"||!a.alg||t&&a.alg!==t)}catch{return!1}}function Gn(r,t){return!!((t==="v4"||!t)&&Un.test(r)||(t==="v6"||!t)&&$n.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 o=this._getOrReturnCtx(t);return h(o,{code:m.invalid_type,expected:f.string,received:o.parsedType}),y}let s=new A,a;for(let o of this._def.checks)if(o.kind==="min")t.data.length<o.value&&(a=this._getOrReturnCtx(t,a),h(a,{code:m.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),s.dirty());else if(o.kind==="max")t.data.length>o.value&&(a=this._getOrReturnCtx(t,a),h(a,{code:m.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),s.dirty());else if(o.kind==="length"){let c=t.data.length>o.value,i=t.data.length<o.value;(c||i)&&(a=this._getOrReturnCtx(t,a),c?h(a,{code:m.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}):i&&h(a,{code:m.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}),s.dirty())}else if(o.kind==="email")In.test(t.data)||(a=this._getOrReturnCtx(t,a),h(a,{validation:"email",code:m.invalid_string,message:o.message}),s.dirty());else if(o.kind==="emoji")ft||(ft=new RegExp(Ln,"u")),ft.test(t.data)||(a=this._getOrReturnCtx(t,a),h(a,{validation:"emoji",code:m.invalid_string,message:o.message}),s.dirty());else if(o.kind==="uuid")zn.test(t.data)||(a=this._getOrReturnCtx(t,a),h(a,{validation:"uuid",code:m.invalid_string,message:o.message}),s.dirty());else if(o.kind==="nanoid")An.test(t.data)||(a=this._getOrReturnCtx(t,a),h(a,{validation:"nanoid",code:m.invalid_string,message:o.message}),s.dirty());else if(o.kind==="cuid")Rn.test(t.data)||(a=this._getOrReturnCtx(t,a),h(a,{validation:"cuid",code:m.invalid_string,message:o.message}),s.dirty());else if(o.kind==="cuid2")Cn.test(t.data)||(a=this._getOrReturnCtx(t,a),h(a,{validation:"cuid2",code:m.invalid_string,message:o.message}),s.dirty());else if(o.kind==="ulid")Pn.test(t.data)||(a=this._getOrReturnCtx(t,a),h(a,{validation:"ulid",code:m.invalid_string,message:o.message}),s.dirty());else if(o.kind==="url")try{new URL(t.data)}catch{a=this._getOrReturnCtx(t,a),h(a,{validation:"url",code:m.invalid_string,message:o.message}),s.dirty()}else o.kind==="regex"?(o.regex.lastIndex=0,o.regex.test(t.data)||(a=this._getOrReturnCtx(t,a),h(a,{validation:"regex",code:m.invalid_string,message:o.message}),s.dirty())):o.kind==="trim"?t.data=t.data.trim():o.kind==="includes"?t.data.includes(o.value,o.position)||(a=this._getOrReturnCtx(t,a),h(a,{code:m.invalid_string,validation:{includes:o.value,position:o.position},message:o.message}),s.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)||(a=this._getOrReturnCtx(t,a),h(a,{code:m.invalid_string,validation:{startsWith:o.value},message:o.message}),s.dirty()):o.kind==="endsWith"?t.data.endsWith(o.value)||(a=this._getOrReturnCtx(t,a),h(a,{code:m.invalid_string,validation:{endsWith:o.value},message:o.message}),s.dirty()):o.kind==="datetime"?Zt(o).test(t.data)||(a=this._getOrReturnCtx(t,a),h(a,{code:m.invalid_string,validation:"datetime",message:o.message}),s.dirty()):o.kind==="date"?Mn.test(t.data)||(a=this._getOrReturnCtx(t,a),h(a,{code:m.invalid_string,validation:"date",message:o.message}),s.dirty()):o.kind==="time"?Vn(o).test(t.data)||(a=this._getOrReturnCtx(t,a),h(a,{code:m.invalid_string,validation:"time",message:o.message}),s.dirty()):o.kind==="duration"?On.test(t.data)||(a=this._getOrReturnCtx(t,a),h(a,{validation:"duration",code:m.invalid_string,message:o.message}),s.dirty()):o.kind==="ip"?Fn(t.data,o.version)||(a=this._getOrReturnCtx(t,a),h(a,{validation:"ip",code:m.invalid_string,message:o.message}),s.dirty()):o.kind==="jwt"?Zn(t.data,o.alg)||(a=this._getOrReturnCtx(t,a),h(a,{validation:"jwt",code:m.invalid_string,message:o.message}),s.dirty()):o.kind==="cidr"?Gn(t.data,o.version)||(a=this._getOrReturnCtx(t,a),h(a,{validation:"cidr",code:m.invalid_string,message:o.message}),s.dirty()):o.kind==="base64"?Dn.test(t.data)||(a=this._getOrReturnCtx(t,a),h(a,{validation:"base64",code:m.invalid_string,message:o.message}),s.dirty()):o.kind==="base64url"?qn.test(t.data)||(a=this._getOrReturnCtx(t,a),h(a,{validation:"base64url",code:m.invalid_string,message:o.message}),s.dirty()):j.assertNever(o);return{status:s.value,value:t.data}}_regex(t,n,s){return this.refinement(a=>t.test(a),{validation:n,code:m.invalid_string,...g.errToObj(s)})}_addCheck(t){return new r({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...g.errToObj(t)})}url(t){return this._addCheck({kind:"url",...g.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...g.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...g.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...g.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...g.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...g.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...g.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...g.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...g.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...g.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...g.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...g.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,...g.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,...g.errToObj(t?.message)})}duration(t){return this._addCheck({kind:"duration",...g.errToObj(t)})}regex(t,n){return this._addCheck({kind:"regex",regex:t,...g.errToObj(n)})}includes(t,n){return this._addCheck({kind:"includes",value:t,position:n?.position,...g.errToObj(n?.message)})}startsWith(t,n){return this._addCheck({kind:"startsWith",value:t,...g.errToObj(n)})}endsWith(t,n){return this._addCheck({kind:"endsWith",value:t,...g.errToObj(n)})}min(t,n){return this._addCheck({kind:"min",value:t,...g.errToObj(n)})}max(t,n){return this._addCheck({kind:"max",value:t,...g.errToObj(n)})}length(t,n){return this._addCheck({kind:"length",value:t,...g.errToObj(n)})}nonempty(t){return this.min(1,g.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 Hn(r,t){let n=(r.toString().split(".")[1]||"").length,s=(t.toString().split(".")[1]||"").length,a=n>s?n:s,o=Number.parseInt(r.toFixed(a).replace(".","")),c=Number.parseInt(t.toFixed(a).replace(".",""));return o%c/10**a}var le=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}),y}let s,a=new A;for(let o of this._def.checks)o.kind==="int"?j.isInteger(t.data)||(s=this._getOrReturnCtx(t,s),h(s,{code:m.invalid_type,expected:"integer",received:"float",message:o.message}),a.dirty()):o.kind==="min"?(o.inclusive?t.data<o.value:t.data<=o.value)&&(s=this._getOrReturnCtx(t,s),h(s,{code:m.too_small,minimum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),a.dirty()):o.kind==="max"?(o.inclusive?t.data>o.value:t.data>=o.value)&&(s=this._getOrReturnCtx(t,s),h(s,{code:m.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),a.dirty()):o.kind==="multipleOf"?Hn(t.data,o.value)!==0&&(s=this._getOrReturnCtx(t,s),h(s,{code:m.not_multiple_of,multipleOf:o.value,message:o.message}),a.dirty()):o.kind==="finite"?Number.isFinite(t.data)||(s=this._getOrReturnCtx(t,s),h(s,{code:m.not_finite,message:o.message}),a.dirty()):j.assertNever(o);return{status:a.value,value:t.data}}gte(t,n){return this.setLimit("min",t,!0,g.toString(n))}gt(t,n){return this.setLimit("min",t,!1,g.toString(n))}lte(t,n){return this.setLimit("max",t,!0,g.toString(n))}lt(t,n){return this.setLimit("max",t,!1,g.toString(n))}setLimit(t,n,s,a){return new r({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:s,message:g.toString(a)}]})}_addCheck(t){return new r({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:g.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:g.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:g.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:g.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:g.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:g.toString(n)})}finite(t){return this._addCheck({kind:"finite",message:g.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:g.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:g.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"&&j.isInteger(t.value))}get isFinite(){let t=null,n=null;for(let s of this._def.checks){if(s.kind==="finite"||s.kind==="int"||s.kind==="multipleOf")return!0;s.kind==="min"?(n===null||s.value>n)&&(n=s.value):s.kind==="max"&&(t===null||s.value<t)&&(t=s.value)}return Number.isFinite(n)&&Number.isFinite(t)}};le.create=r=>new le({checks:[],typeName:b.ZodNumber,coerce:r?.coerce||!1,...x(r)});var de=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 s,a=new A;for(let o of this._def.checks)o.kind==="min"?(o.inclusive?t.data<o.value:t.data<=o.value)&&(s=this._getOrReturnCtx(t,s),h(s,{code:m.too_small,type:"bigint",minimum:o.value,inclusive:o.inclusive,message:o.message}),a.dirty()):o.kind==="max"?(o.inclusive?t.data>o.value:t.data>=o.value)&&(s=this._getOrReturnCtx(t,s),h(s,{code:m.too_big,type:"bigint",maximum:o.value,inclusive:o.inclusive,message:o.message}),a.dirty()):o.kind==="multipleOf"?t.data%o.value!==BigInt(0)&&(s=this._getOrReturnCtx(t,s),h(s,{code:m.not_multiple_of,multipleOf:o.value,message:o.message}),a.dirty()):j.assertNever(o);return{status:a.value,value:t.data}}_getInvalidInput(t){let n=this._getOrReturnCtx(t);return h(n,{code:m.invalid_type,expected:f.bigint,received:n.parsedType}),y}gte(t,n){return this.setLimit("min",t,!0,g.toString(n))}gt(t,n){return this.setLimit("min",t,!1,g.toString(n))}lte(t,n){return this.setLimit("max",t,!0,g.toString(n))}lt(t,n){return this.setLimit("max",t,!1,g.toString(n))}setLimit(t,n,s,a){return new r({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:s,message:g.toString(a)}]})}_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:g.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:g.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:g.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:g.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:g.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}};de.create=r=>new de({checks:[],typeName:b.ZodBigInt,coerce:r?.coerce??!1,...x(r)});var pe=class extends S{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==f.boolean){let s=this._getOrReturnCtx(t);return h(s,{code:m.invalid_type,expected:f.boolean,received:s.parsedType}),y}return E(t.data)}};pe.create=r=>new pe({typeName:b.ZodBoolean,coerce:r?.coerce||!1,...x(r)});var me=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}),y}if(Number.isNaN(t.data.getTime())){let o=this._getOrReturnCtx(t);return h(o,{code:m.invalid_date}),y}let s=new A,a;for(let o of this._def.checks)o.kind==="min"?t.data.getTime()<o.value&&(a=this._getOrReturnCtx(t,a),h(a,{code:m.too_small,message:o.message,inclusive:!0,exact:!1,minimum:o.value,type:"date"}),s.dirty()):o.kind==="max"?t.data.getTime()>o.value&&(a=this._getOrReturnCtx(t,a),h(a,{code:m.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),s.dirty()):j.assertNever(o);return{status:s.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:g.toString(n)})}max(t,n){return this._addCheck({kind:"max",value:t.getTime(),message:g.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}};me.create=r=>new me({checks:[],coerce:r?.coerce||!1,typeName:b.ZodDate,...x(r)});var ze=class extends S{_parse(t){if(this._getType(t)!==f.symbol){let s=this._getOrReturnCtx(t);return h(s,{code:m.invalid_type,expected:f.symbol,received:s.parsedType}),y}return E(t.data)}};ze.create=r=>new ze({typeName:b.ZodSymbol,...x(r)});var ue=class extends S{_parse(t){if(this._getType(t)!==f.undefined){let s=this._getOrReturnCtx(t);return h(s,{code:m.invalid_type,expected:f.undefined,received:s.parsedType}),y}return E(t.data)}};ue.create=r=>new ue({typeName:b.ZodUndefined,...x(r)});var he=class extends S{_parse(t){if(this._getType(t)!==f.null){let s=this._getOrReturnCtx(t);return h(s,{code:m.invalid_type,expected:f.null,received:s.parsedType}),y}return E(t.data)}};he.create=r=>new he({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 Y=class extends S{constructor(){super(...arguments),this._unknown=!0}_parse(t){return E(t.data)}};Y.create=r=>new Y({typeName:b.ZodUnknown,...x(r)});var V=class extends S{_parse(t){let n=this._getOrReturnCtx(t);return h(n,{code:m.invalid_type,expected:f.never,received:n.parsedType}),y}};V.create=r=>new V({typeName:b.ZodNever,...x(r)});var Ae=class extends S{_parse(t){if(this._getType(t)!==f.undefined){let s=this._getOrReturnCtx(t);return h(s,{code:m.invalid_type,expected:f.void,received:s.parsedType}),y}return E(t.data)}};Ae.create=r=>new Ae({typeName:b.ZodVoid,...x(r)});var X=class r extends S{_parse(t){let{ctx:n,status:s}=this._processInputParams(t),a=this._def;if(n.parsedType!==f.array)return h(n,{code:m.invalid_type,expected:f.array,received:n.parsedType}),y;if(a.exactLength!==null){let c=n.data.length>a.exactLength.value,i=n.data.length<a.exactLength.value;(c||i)&&(h(n,{code:c?m.too_big:m.too_small,minimum:i?a.exactLength.value:void 0,maximum:c?a.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:a.exactLength.message}),s.dirty())}if(a.minLength!==null&&n.data.length<a.minLength.value&&(h(n,{code:m.too_small,minimum:a.minLength.value,type:"array",inclusive:!0,exact:!1,message:a.minLength.message}),s.dirty()),a.maxLength!==null&&n.data.length>a.maxLength.value&&(h(n,{code:m.too_big,maximum:a.maxLength.value,type:"array",inclusive:!0,exact:!1,message:a.maxLength.message}),s.dirty()),n.common.async)return Promise.all([...n.data].map((c,i)=>a.type._parseAsync(new D(n,c,n.path,i)))).then(c=>A.mergeArray(s,c));let o=[...n.data].map((c,i)=>a.type._parseSync(new D(n,c,n.path,i)));return A.mergeArray(s,o)}get element(){return this._def.type}min(t,n){return new r({...this._def,minLength:{value:t,message:g.toString(n)}})}max(t,n){return new r({...this._def,maxLength:{value:t,message:g.toString(n)}})}length(t,n){return new r({...this._def,exactLength:{value:t,message:g.toString(n)}})}nonempty(t){return this.min(1,t)}};X.create=(r,t)=>new X({type:r,minLength:null,maxLength:null,exactLength:null,typeName:b.ZodArray,...x(t)});function Pe(r){if(r instanceof U){let t={};for(let n in r.shape){let s=r.shape[n];t[n]=$.create(Pe(s))}return new U({...r._def,shape:()=>t})}else return r instanceof X?new X({...r._def,type:Pe(r.element)}):r instanceof $?$.create(Pe(r.unwrap())):r instanceof H?H.create(Pe(r.unwrap())):r instanceof G?G.create(r.items.map(t=>Pe(t))):r}var U=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=j.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}),y}let{status:s,ctx:a}=this._processInputParams(t),{shape:o,keys:c}=this._getCached(),i=[];if(!(this._def.catchall instanceof V&&this._def.unknownKeys==="strip"))for(let p in a.data)c.includes(p)||i.push(p);let d=[];for(let p of c){let u=o[p],T=a.data[p];d.push({key:{status:"valid",value:p},value:u._parse(new D(a,T,a.path,p)),alwaysSet:p in a.data})}if(this._def.catchall instanceof V){let p=this._def.unknownKeys;if(p==="passthrough")for(let u of i)d.push({key:{status:"valid",value:u},value:{status:"valid",value:a.data[u]}});else if(p==="strict")i.length>0&&(h(a,{code:m.unrecognized_keys,keys:i}),s.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=a.data[u];d.push({key:{status:"valid",value:u},value:p._parse(new D(a,T,a.path,u)),alwaysSet:u in a.data})}}return a.common.async?Promise.resolve().then(async()=>{let p=[];for(let u of d){let T=await u.key,w=await u.value;p.push({key:T,value:w,alwaysSet:u.alwaysSet})}return p}).then(p=>A.mergeObjectSync(s,p)):A.mergeObjectSync(s,d)}get shape(){return this._def.shape()}strict(t){return g.errToObj,new r({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(n,s)=>{let a=this._def.errorMap?.(n,s).message??s.defaultError;return n.code==="unrecognized_keys"?{message:g.errToObj(t).message??a}:{message:a}}}:{}})}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 s of j.objectKeys(t))t[s]&&this.shape[s]&&(n[s]=this.shape[s]);return new r({...this._def,shape:()=>n})}omit(t){let n={};for(let s of j.objectKeys(this.shape))t[s]||(n[s]=this.shape[s]);return new r({...this._def,shape:()=>n})}deepPartial(){return Pe(this)}partial(t){let n={};for(let s of j.objectKeys(this.shape)){let a=this.shape[s];t&&!t[s]?n[s]=a:n[s]=a.optional()}return new r({...this._def,shape:()=>n})}required(t){let n={};for(let s of j.objectKeys(this.shape))if(t&&!t[s])n[s]=this.shape[s];else{let o=this.shape[s];for(;o instanceof $;)o=o._def.innerType;n[s]=o}return new r({...this._def,shape:()=>n})}keyof(){return Gt(j.objectKeys(this.shape))}};U.create=(r,t)=>new U({shape:()=>r,unknownKeys:"strip",catchall:V.create(),typeName:b.ZodObject,...x(t)});U.strictCreate=(r,t)=>new U({shape:()=>r,unknownKeys:"strict",catchall:V.create(),typeName:b.ZodObject,...x(t)});U.lazycreate=(r,t)=>new U({shape:r,unknownKeys:"strip",catchall:V.create(),typeName:b.ZodObject,...x(t)});var fe=class extends S{_parse(t){let{ctx:n}=this._processInputParams(t),s=this._def.options;function a(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 N(i.ctx.common.issues));return h(n,{code:m.invalid_union,unionErrors:c}),y}if(n.common.async)return Promise.all(s.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(a);{let o,c=[];for(let d of s){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"&&!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(d=>new N(d));return h(n,{code:m.invalid_union,unionErrors:i}),y}}get options(){return this._def.options}};fe.create=(r,t)=>new fe({options:r,typeName:b.ZodUnion,...x(t)});var K=r=>r instanceof ye?K(r.schema):r instanceof q?K(r.innerType()):r instanceof be?[r.value]:r instanceof _e?r.options:r instanceof ve?j.objectValues(r.enum):r instanceof xe?K(r._def.innerType):r instanceof ue?[void 0]:r instanceof he?[null]:r instanceof $?[void 0,...K(r.unwrap())]:r instanceof H?[null,...K(r.unwrap())]:r instanceof De||r instanceof ke?K(r.unwrap()):r instanceof Se?K(r._def.innerType):[],et=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}),y;let s=this.discriminator,a=n.data[s],o=this.optionsMap.get(a);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:[s]}),y)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,s){let a=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(a.has(i))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(i)}`);a.set(i,o)}}return new r({typeName:b.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:a,...x(s)})}};function gt(r,t){let n=Z(r),s=Z(t);if(r===t)return{valid:!0,data:r};if(n===f.object&&s===f.object){let a=j.objectKeys(t),o=j.objectKeys(r).filter(i=>a.indexOf(i)!==-1),c={...r,...t};for(let i of o){let d=gt(r[i],t[i]);if(!d.valid)return{valid:!1};c[i]=d.data}return{valid:!0,data:c}}else if(n===f.array&&s===f.array){if(r.length!==t.length)return{valid:!1};let a=[];for(let o=0;o<r.length;o++){let c=r[o],i=t[o],d=gt(c,i);if(!d.valid)return{valid:!1};a.push(d.data)}return{valid:!0,data:a}}else return n===f.date&&s===f.date&&+r==+t?{valid:!0,data:r}:{valid:!1}}var ge=class extends S{_parse(t){let{status:n,ctx:s}=this._processInputParams(t),a=(o,c)=>{if(Ye(o)||Ye(c))return y;let i=gt(o.value,c.value);return i.valid?((Xe(o)||Xe(c))&&n.dirty(),{status:n.value,value:i.data}):(h(s,{code:m.invalid_intersection_types}),y)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then(([o,c])=>a(o,c)):a(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}};ge.create=(r,t,n)=>new ge({left:r,right:t,typeName:b.ZodIntersection,...x(n)});var G=class r extends S{_parse(t){let{status:n,ctx:s}=this._processInputParams(t);if(s.parsedType!==f.array)return h(s,{code:m.invalid_type,expected:f.array,received:s.parsedType}),y;if(s.data.length<this._def.items.length)return h(s,{code:m.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),y;!this._def.rest&&s.data.length>this._def.items.length&&(h(s,{code:m.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());let o=[...s.data].map((c,i)=>{let d=this._def.items[i]||this._def.rest;return d?d._parse(new D(s,c,s.path,i)):null}).filter(c=>!!c);return s.common.async?Promise.all(o).then(c=>A.mergeArray(n,c)):A.mergeArray(n,o)}get items(){return this._def.items}rest(t){return new r({...this._def,rest:t})}};G.create=(r,t)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new G({items:r,typeName:b.ZodTuple,rest:null,...x(t)})};var tt=class r extends S{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:n,ctx:s}=this._processInputParams(t);if(s.parsedType!==f.object)return h(s,{code:m.invalid_type,expected:f.object,received:s.parsedType}),y;let a=[],o=this._def.keyType,c=this._def.valueType;for(let i in s.data)a.push({key:o._parse(new D(s,i,s.path,i)),value:c._parse(new D(s,s.data[i],s.path,i)),alwaysSet:i in s.data});return s.common.async?A.mergeObjectAsync(n,a):A.mergeObjectSync(n,a)}get element(){return this._def.valueType}static create(t,n,s){return n instanceof S?new r({keyType:t,valueType:n,typeName:b.ZodRecord,...x(s)}):new r({keyType:te.create(),valueType:t,typeName:b.ZodRecord,...x(n)})}},Ee=class extends S{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:n,ctx:s}=this._processInputParams(t);if(s.parsedType!==f.map)return h(s,{code:m.invalid_type,expected:f.map,received:s.parsedType}),y;let a=this._def.keyType,o=this._def.valueType,c=[...s.data.entries()].map(([i,d],p)=>({key:a._parse(new D(s,i,s.path,[p,"key"])),value:o._parse(new D(s,d,s.path,[p,"value"]))}));if(s.common.async){let i=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 y;(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 d of c){let p=d.key,u=d.value;if(p.status==="aborted"||u.status==="aborted")return y;(p.status==="dirty"||u.status==="dirty")&&n.dirty(),i.set(p.value,u.value)}return{status:n.value,value:i}}}};Ee.create=(r,t,n)=>new Ee({valueType:t,keyType:r,typeName:b.ZodMap,...x(n)});var Oe=class r extends S{_parse(t){let{status:n,ctx:s}=this._processInputParams(t);if(s.parsedType!==f.set)return h(s,{code:m.invalid_type,expected:f.set,received:s.parsedType}),y;let a=this._def;a.minSize!==null&&s.data.size<a.minSize.value&&(h(s,{code:m.too_small,minimum:a.minSize.value,type:"set",inclusive:!0,exact:!1,message:a.minSize.message}),n.dirty()),a.maxSize!==null&&s.data.size>a.maxSize.value&&(h(s,{code:m.too_big,maximum:a.maxSize.value,type:"set",inclusive:!0,exact:!1,message:a.maxSize.message}),n.dirty());let o=this._def.valueType;function c(d){let p=new Set;for(let u of d){if(u.status==="aborted")return y;u.status==="dirty"&&n.dirty(),p.add(u.value)}return{status:n.value,value:p}}let i=[...s.data.values()].map((d,p)=>o._parse(new D(s,d,s.path,p)));return s.common.async?Promise.all(i).then(d=>c(d)):c(i)}min(t,n){return new r({...this._def,minSize:{value:t,message:g.toString(n)}})}max(t,n){return new r({...this._def,maxSize:{value:t,message:g.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 rt=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}),y;function s(i,d){return $e({data:i,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Re(),J].filter(p=>!!p),issueData:{code:m.invalid_arguments,argumentsError:d}})}function a(i,d){return $e({data:i,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Re(),J].filter(p=>!!p),issueData:{code:m.invalid_return_type,returnTypeError:d}})}let o={errorMap:n.common.contextualErrorMap},c=n.data;if(this._def.returns instanceof ne){let i=this;return E(async function(...d){let p=new N([]),u=await i._def.args.parseAsync(d,o).catch(_=>{throw p.addIssue(s(d,_)),p}),T=await Reflect.apply(c,this,u);return await i._def.returns._def.type.parseAsync(T,o).catch(_=>{throw p.addIssue(a(T,_)),p})})}else{let i=this;return E(function(...d){let p=i._def.args.safeParse(d,o);if(!p.success)throw new N([s(d,p.error)]);let u=Reflect.apply(c,this,p.data),T=i._def.returns.safeParse(u,o);if(!T.success)throw new N([a(u,T.error)]);return T.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new r({...this._def,args:G.create(t).rest(Y.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,s){return new r({args:t||G.create([]).rest(Y.create()),returns:n||Y.create(),typeName:b.ZodFunction,...x(s)})}},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 be=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}),y}return{status:"valid",value:t.data}}get value(){return this._def.value}};be.create=(r,t)=>new be({value:r,typeName:b.ZodLiteral,...x(t)});function Gt(r,t){return new _e({values:r,typeName:b.ZodEnum,...x(t)})}var _e=class r extends S{_parse(t){if(typeof t.data!="string"){let n=this._getOrReturnCtx(t),s=this._def.values;return h(n,{expected:j.joinValues(s),received:n.parsedType,code:m.invalid_type}),y}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){let n=this._getOrReturnCtx(t),s=this._def.values;return h(n,{received:n.data,code:m.invalid_enum_value,options:s}),y}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(s=>!t.includes(s)),{...this._def,...n})}};_e.create=Gt;var ve=class extends S{_parse(t){let n=j.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(t);if(s.parsedType!==f.string&&s.parsedType!==f.number){let a=j.objectValues(n);return h(s,{expected:j.joinValues(a),received:s.parsedType,code:m.invalid_type}),y}if(this._cache||(this._cache=new Set(j.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){let a=j.objectValues(n);return h(s,{received:s.data,code:m.invalid_enum_value,options:a}),y}return E(t.data)}get enum(){return this._def.values}};ve.create=(r,t)=>new ve({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}),y;let s=n.parsedType===f.promise?n.data:Promise.resolve(n.data);return E(s.then(a=>this._def.type.parseAsync(a,{path:n.path,errorMap:n.common.contextualErrorMap})))}};ne.create=(r,t)=>new ne({type:r,typeName:b.ZodPromise,...x(t)});var q=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:s}=this._processInputParams(t),a=this._def.effect||null,o={addIssue:c=>{h(s,c),c.fatal?n.abort():n.dirty()},get path(){return s.path}};if(o.addIssue=o.addIssue.bind(o),a.type==="preprocess"){let c=a.transform(s.data,o);if(s.common.async)return Promise.resolve(c).then(async i=>{if(n.value==="aborted")return y;let d=await this._def.schema._parseAsync({data:i,path:s.path,parent:s});return d.status==="aborted"?y:d.status==="dirty"?ce(d.value):n.value==="dirty"?ce(d.value):d});{if(n.value==="aborted")return y;let i=this._def.schema._parseSync({data:c,path:s.path,parent:s});return i.status==="aborted"?y:i.status==="dirty"?ce(i.value):n.value==="dirty"?ce(i.value):i}}if(a.type==="refinement"){let c=i=>{let d=a.refinement(i,o);if(s.common.async)return Promise.resolve(d);if(d instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return i};if(s.common.async===!1){let i=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});return i.status==="aborted"?y:(i.status==="dirty"&&n.dirty(),c(i.value),{status:n.value,value:i.value})}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(i=>i.status==="aborted"?y:(i.status==="dirty"&&n.dirty(),c(i.value).then(()=>({status:n.value,value:i.value}))))}if(a.type==="transform")if(s.common.async===!1){let c=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(!ee(c))return y;let i=a.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:s.data,path:s.path,parent:s}).then(c=>ee(c)?Promise.resolve(a.transform(c.value,o)).then(i=>({status:n.value,value:i})):y);j.assertNever(a)}};q.create=(r,t,n)=>new q({schema:r,typeName:b.ZodEffects,effect:t,...x(n)});q.createWithPreprocess=(r,t,n)=>new q({schema:t,effect:{type:"preprocess",transform:r},typeName:b.ZodEffects,...x(n)});var $=class extends S{_parse(t){return this._getType(t)===f.undefined?E(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};$.create=(r,t)=>new $({innerType:r,typeName:b.ZodOptional,...x(t)});var H=class extends S{_parse(t){return this._getType(t)===f.null?E(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};H.create=(r,t)=>new H({innerType:r,typeName:b.ZodNullable,...x(t)});var xe=class extends S{_parse(t){let{ctx:n}=this._processInputParams(t),s=n.data;return n.parsedType===f.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:n.path,parent:n})}removeDefault(){return this._def.innerType}};xe.create=(r,t)=>new xe({innerType:r,typeName:b.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...x(t)});var Se=class extends S{_parse(t){let{ctx:n}=this._processInputParams(t),s={...n,common:{...n.common,issues:[]}},a=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});return Ce(a)?a.then(o=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new N(s.common.issues)},input:s.data})})):{status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new N(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}};Se.create=(r,t)=>new Se({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 s=this._getOrReturnCtx(t);return h(s,{code:m.invalid_type,expected:f.nan,received:s.parsedType}),y}return{status:"valid",value:t.data}}};Ie.create=r=>new Ie({typeName:b.ZodNaN,...x(r)});var Qn=Symbol("zod_brand"),De=class extends S{_parse(t){let{ctx:n}=this._processInputParams(t),s=n.data;return this._def.type._parse({data:s,path:n.path,parent:n})}unwrap(){return this._def.type}},qe=class r extends S{_parse(t){let{status:n,ctx:s}=this._processInputParams(t);if(s.common.async)return(async()=>{let o=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return o.status==="aborted"?y:o.status==="dirty"?(n.dirty(),ce(o.value)):this._def.out._parseAsync({data:o.value,path:s.path,parent:s})})();{let a=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return a.status==="aborted"?y:a.status==="dirty"?(n.dirty(),{status:"dirty",value:a.value}):this._def.out._parseSync({data:a.value,path:s.path,parent:s})}}static create(t,n){return new r({in:t,out:n,typeName:b.ZodPipeline})}},ke=class extends S{_parse(t){let n=this._def.innerType._parse(t),s=a=>(ee(a)&&(a.value=Object.freeze(a.value)),a);return Ce(n)?n.then(a=>s(a)):s(n)}unwrap(){return this._def.innerType}};ke.create=(r,t)=>new ke({innerType:r,typeName:b.ZodReadonly,...x(t)});function Mt(r,t){let n=typeof r=="function"?r(t):typeof r=="string"?{message:r}:r;return typeof n=="string"?{message:n}:n}function Ht(r,t={},n){return r?re.create().superRefine((s,a)=>{let o=r(s);if(o instanceof Promise)return o.then(c=>{if(!c){let i=Mt(t,s),d=i.fatal??n??!0;a.addIssue({code:"custom",...i,fatal:d})}});if(!o){let c=Mt(t,s),i=c.fatal??n??!0;a.addIssue({code:"custom",...c,fatal:i})}}):re.create()}var Wn={object:U.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 Jn=(r,t={message:`Input not instance of ${r.name}`})=>Ht(n=>n instanceof r,t),Qt=te.create,Wt=le.create,Kn=Ie.create,Yn=de.create,Jt=pe.create,Xn=me.create,es=ze.create,ts=ue.create,rs=he.create,ns=re.create,ss=Y.create,as=V.create,os=Ae.create,is=X.create,cs=U.create,ls=U.strictCreate,ds=fe.create,ps=et.create,ms=ge.create,us=G.create,hs=tt.create,fs=Ee.create,gs=Oe.create,ys=rt.create,bs=ye.create,_s=be.create,vs=_e.create,xs=ve.create,Ss=ne.create,ks=q.create,js=$.create,Ts=H.create,ws=q.createWithPreprocess,Rs=qe.create,Cs=()=>Qt().optional(),Ps=()=>Wt().optional(),zs=()=>Jt().optional(),As={string:r=>te.create({...r,coerce:!0}),number:r=>le.create({...r,coerce:!0}),boolean:r=>pe.create({...r,coerce:!0}),bigint:r=>de.create({...r,coerce:!0}),date:r=>me.create({...r,coerce:!0})};var Es=y;var Os=r=>typeof r?.safeParse=="function";var yt=r=>typeof r?.passthrough=="function";var Is=(r,t)=>yt(r)?yt(t)?r.merge(t):r:yt(t)?t:Object.assign({},r,t);var bl=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()))}),Ls=Symbol("ContractNoBody"),Yt=r=>"method"in r&&"path"in r;var Xt=(r,t)=>Object.fromEntries(Object.entries(r).map(([n,s])=>{var a,o,c;return Yt(s)?[n,{...s,path:t?.pathPrefix?t.pathPrefix+s.path:s.path,headers:Is(t?.baseHeaders,s.headers),strictStatusCodes:(a=s.strictStatusCodes)!==null&&a!==void 0?a:t?.strictStatusCodes,validateResponseOnClient:(o=s.validateResponseOnClient)!==null&&o!==void 0?o:t?.validateResponseOnClient,responses:{...t?.commonResponses,...s.responses},metadata:t?.metadata?{...t?.metadata,...(c=s.metadata)!==null&&c!==void 0?c:{}}:s.metadata}]:[n,Xt(s,t)]})),bt=Symbol("ContractPlainType"),Q=()=>({router:(r,t)=>Xt(r,t),query:r=>r,mutation:r=>r,responses:r=>r,response:()=>bt,body:()=>bt,type:()=>bt,otherResponse:({contentType:r,body:t})=>({contentType:r,body:t}),noBody:()=>Ls}),Ns=({path:r,params:t})=>{let n=t;return r.replace(/\/?:([^/?]+)\??/g,(s,a)=>n[a]?`${s.startsWith("/")?"/":""}${n[a]}`:"")},Us=(r,t=!1)=>{let n=t?Bs(r):$s(r);return n?.length>0?"?"+n:""},Bs=r=>r?Object.entries(r).filter(([,t])=>t!==void 0).map(([t,n])=>{let s;return typeof n=="string"&&!["true","false","null"].includes(n.trim())&&isNaN(Number(n))?s=n:s=JSON.stringify(n),`${encodeURIComponent(t)}=${encodeURIComponent(s)}`}).join("&"):"",$s=r=>r?Object.keys(r).flatMap(t=>_t(t,r[t])).map(([t,n])=>`${encodeURIComponent(t)}=${encodeURIComponent(n)}`).join("&"):"",_t=(r,t)=>Array.isArray(t)?t.flatMap((n,s)=>_t(`${r}[${s}]`,n)):t instanceof Date?[[`${r}`,t.toISOString()]]:t===null?[[`${r}`,""]]:t===void 0?[]:typeof t=="object"?Object.keys(t).flatMap(n=>_t(`${r}[${n}]`,t[n])):[[`${r}`,`${t}`]];var vt=class extends Error{constructor(t,n){let s=n.join(",");super(`Server returned unexpected response. Expected one of: ${s} got: ${t.status}`),this.response=t}};var Ds=async({route:r,path:t,method:n,headers:s,body:a,validateResponse:o,fetchOptions:c})=>{let i=await fetch(t,{...c,method:n,headers:s,body:a}),d=i.headers.get("content-type");if(d?.includes("application/")&&d?.includes("json")){let p={status:i.status,body:await i.json(),headers:i.headers},u=r.responses[p.status];return(o??r.validateResponseOnClient)&&Os(u)?{...p,body:u.parse(p.body)}:p}return d?.includes("text/")?{status:i.status,body:await i.text(),headers:i.headers}:{status:i.status,body:await i.blob(),headers:i.headers}},qs=r=>{let t=new FormData,n=(s,a)=>{a instanceof File?t.append(s,a):t.append(s,JSON.stringify(a))};return Object.entries(r).forEach(([s,a])=>{if(Array.isArray(a))for(let o of a)n(s,o);else n(s,a)}),t},Kt=r=>Object.fromEntries(Object.entries(r).map(([t,n])=>[t.toLowerCase(),n])),Ms=r=>{let{path:t,clientArgs:n,route:s,body:a,query:o,extraInputArgs:c,headers:i,fetchOptions:d}=r,p=n.api||Ds,u=n.baseHeaders&&Object.fromEntries(Object.entries(n.baseHeaders).map(([_,P])=>typeof P=="function"?[_,P(r)]:[_,P])),T={...u&&Kt(u),...Kt(i)};Object.keys(T).forEach(_=>{T[_]===void 0&&delete T[_]});let w={route:s,path:t,method:s.method,headers:T,body:void 0,rawBody:a,rawQuery:o,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 s.method!=="GET"&&("contentType"in s&&s.contentType==="multipart/form-data"?w={...w,contentType:"multipart/form-data",body:a instanceof FormData?a:qs(a)}:"contentType"in s&&s.contentType==="application/x-www-form-urlencoded"?w={...w,contentType:"application/x-www-form-urlencoded",headers:{"content-type":"application/x-www-form-urlencoded",...w.headers},body:typeof a=="string"?a:new URLSearchParams(a)}:a!=null&&(w={...w,contentType:"application/json",headers:{"content-type":"application/json",...w.headers},body:JSON.stringify(a)})),p({...w,...c})},Vs=(r,t,n)=>{let{query:s,params:a,body:o,headers:c,extraHeaders:i,overrideClientOptions:d,fetchOptions:p,cache:u,next:T,...w}=n||{},_={...t,...d};return{path:Fs(s,_.baseUrl,a,r,!!_.jsonQuery),clientArgs:_,route:r,body:o,query:s,extraInputArgs:w,fetchOptions:{...u&&{cache:u},...T&&{next:T},...p},headers:{...i,...c}}},Fs=(r,t,n,s,a)=>{let o=Ns({path:s.path,params:n}),c=Us(r,a);return`${t}${o}${c}`},Zs=(r,t)=>{let n=Object.keys(r.responses);return async s=>{let a=Vs(r,t,s),o=await Ms(a);if(!t.throwOnUnknownStatus||n.includes(o.status.toString()))return o;throw new vt(o,n)}},xt=(r,t)=>Object.fromEntries(Object.entries(r).map(([n,s])=>Yt(s)?[n,Zs(s,t)]:[n,xt(s,t)]));var St=["free","creator","team"],er=typeof process<"u"&&process.env?.NODE_ENV!=="production",Gs={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:er?"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:er?"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 tr=Gs.stripe.plans,vl=Object.freeze(Object.fromEntries(tr.map(r=>[r.tier,r])));var Hs=Q(),O=e.object({message:e.string()}),kt=e.record(e.unknown()),je=e.string().regex(/^doc_[0-9A-Za-z]{22}$/),nt=e.string().regex(/^proj_[0-9A-Za-z]{22}$/),Qs=["active","archived"],st=e.enum(Qs),rr=e.object({id:e.string().min(1),display_name:e.string().min(1)}),nr=e.object({id:nt,name:e.string().min(1)}),jt=e.object({id:je,title:e.string().min(1),status:st,author:rr,project:nr.nullable(),created_at:e.string().datetime(),updated_at:e.string().datetime(),archived_at:e.string().datetime().nullable()}),Ws=e.object({type:e.literal("list"),list_type:e.literal("doc"),objects:e.array(jt)}),Js=e.object({project_id:nt.optional(),status:st.optional()}),Ks=e.object({title:e.string().trim().min(1).max(300).optional(),prosemirror_json:kt.optional(),project_id:nt.nullable().optional()}),Ys=e.object({id:je,created_at:e.string().datetime()}),Xs=e.object({title:e.string().trim().min(1).max(300).optional(),prosemirror_json:kt.optional(),project_id:nt.nullable().optional(),status:st.optional()}).refine(r=>Object.keys(r).length>0,{message:"At least one field must be provided"}),ea=e.object({id:je,updated_at:e.string().datetime()}),ta=e.object({id:je,title:e.string().min(1),prosemirror_json:kt,status:st,author:rr,project:nr.nullable(),created_at:e.string().datetime(),updated_at:e.string().datetime(),archived_at:e.string().datetime().nullable()}),sr=Hs.router({listDocs:{method:"GET",path:"/docs",headers:e.object({authorization:e.string().min(1).optional()}),query:Js,responses:{200:Ws,401:O,403:O},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:Ks,responses:{201:Ys,401:O,403:O,404:O,422:O},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:ta,401:O,403:O,404:O},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:Xs,responses:{200:ea,401:O,403:O,404:O,422:O},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:O,403:O,404:O},summary:"Hard-delete a doc and any mention references it owns"}});var ra=Q(),C=e.object({message:e.string()}),Tt=e.record(e.unknown()),W=e.string().regex(/^proj_[0-9A-Za-z]{22}$/),na=["active","archived"],at=e.enum(na),wt=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:wt}),sa=e.object({id:W,name:e.string().min(1),status:at,author:wt,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()}),aa=e.object({type:e.literal("list"),list_type:e.literal("project"),objects:e.array(sa)}),oa=e.object({status:at.optional()}),ia=e.object({name:e.string().trim().min(1).max(200),prosemirror_json:Tt.optional()}),ca=e.object({id:W,created_at:e.string().datetime()}),la=e.object({name:e.string().trim().min(1).max(200).optional(),prosemirror_json:Tt.optional()}).refine(r=>Object.keys(r).length>0,{message:"At least one field must be provided"}),da=e.object({id:W,updated_at:e.string().datetime()}),pa=e.object({archived:e.boolean()}),ma=e.object({id:W,status:at,archived_at:e.string().datetime().nullable()}),ua=e.object({id:W,name:e.string().min(1),prosemirror_json:Tt,status:at,author:wt,created_at:e.string().datetime(),updated_at:e.string().datetime(),archived_at:e.string().datetime().nullable(),threads:e.array(ar),docs:e.array(jt)}),ha=e.object({thread_id:e.string().min(1).max(64)}),fa=ar,or=ra.router({listProjects:{method:"GET",path:"/projects",headers:e.object({authorization:e.string().min(1).optional()}),query:oa,responses:{200:aa,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:ia,responses:{201:ca,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:W}),headers:e.object({authorization:e.string().min(1).optional()}),responses:{200:ua,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:W}),headers:e.object({authorization:e.string().min(1).optional()}),body:la,responses:{200:da,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:W}),headers:e.object({authorization:e.string().min(1).optional()}),body:pa,responses:{200:ma,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:W}),headers:e.object({authorization:e.string().min(1).optional()}),body:ha,responses:{201:fa,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:W,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 ga=Q(),ot=e.object({message:e.string()}),ya=["thread","plan","doc","user"],it=e.enum(ya),ba=["doc","project"],_a=e.enum(ba),va=e.object({kind:it,id:e.string().min(1),title:e.string().min(1),href:e.string().min(1)}),xa=e.object({type:e.literal("list"),list_type:e.literal("mention"),objects:e.array(va)}),Sa=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(it).optional())}),ka=e.object({source_kind:_a,source_id:e.string().min(1),source_title:e.string().min(1),source_href:e.string().min(1),target_kind:it,target_id:e.string().min(1),created_at:e.string().datetime()}),ja=e.object({type:e.literal("list"),list_type:e.literal("backlink"),objects:e.array(ka)}),Ta=e.object({target_kind:it,target_id:e.string().min(1).max(64)}),ir=ga.router({searchMentions:{method:"GET",path:"/mentions/search",headers:e.object({authorization:e.string().min(1).optional()}),query:Sa,responses:{200:xa,401:ot,422:ot},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:Ta,responses:{200:ja,401:ot,403:ot},summary:"List every doc/project body in the caller\u2019s organization that mentions the given target. Newest-first."}});var wa=Q(),Ra=e.object({type:e.literal("list"),list_type:e.literal("thread"),has_more:e.boolean(),objects:e.array(e.unknown())}),se=e.object({message:e.string()}),cr=e.object({thread_id:e.string().min(1),is_favorited:e.boolean(),favorited_at:e.string().datetime().nullable()}),Ca=e.object({before:e.string().min(1).max(64).optional()}),lr=wa.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:cr,401:se,403:se,404:se},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:cr,401:se,403:se,404:se},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:Ca,responses:{200:Ra,401:se,403:se},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 Pa=Q(),za=e.object({id:e.string().uuid(),role:e.enum(["user","assistant"]),content:e.string().min(1),timestamp:e.string().datetime()}),Aa=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()}),Xl=Aa.extend({messages:e.array(za)}),l=e.object({message:e.string()}),Ea=/^[a-zA-Z0-9_-]{2,32}$/,yr=e.string().regex(Ea,"Handle must be 2\u201332 characters: letters, numbers, dashes, or underscores."),Rt=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()}),Oa=e.object({stytchMemberId:e.string().min(1).optional(),emailAddress:e.string().email(),name:e.string().nullable(),user:Rt,is_admin:e.boolean()}),Ia=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"}),La=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()}),br=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()}),Na=e.object({type:e.literal("list"),list_type:e.literal("organization_member"),objects:e.array(La)}),Ua=e.object({email_address:e.string().email()}),Ba=e.object({email_address:e.string().email(),member_id:e.string().min(1)}),$a=e.object({location:e.string().trim().min(1),contact:e.string().trim().email()}),Da=e.object({location:e.string().min(1),contact:e.string().email(),created_at:e.string().datetime()}),qa=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()}),Ma=e.object({name:e.string().min(1),email_domains:e.array(e.string().min(1)).nonempty(),stytch_org_id:e.string().min(1)}),Va=e.object({user:qa,organization:Ma}),Fa=e.object({path_glob:e.string().min(1),name:e.string().min(1),description:e.string().min(1)}),Za=e.object({repo_origin_path:e.string().min(1),building_blocks:e.array(Fa)}),_r=e.string().regex(/^th_[0-9A-Za-z]{22}$/),lt=e.string().regex(/^tb_[0-9A-Za-z]{22}$/),Ga=e.object({id:_r,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:lt,revision_count:e.number().int().positive()}),Ha=e.object({id:e.string().min(1),display_name:e.string().min(1)}),Qa=e.object({id:e.string().min(1),author_id:e.string().min(1).nullable(),author:Ha.nullable(),created_at:e.string().datetime(),deleted_at:e.string().datetime().nullable(),content:e.string().min(1)}),Wa=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(Qa)}),Ja=e.object({thread_block_id:lt,from_position:e.number().int().positive(),to_position:e.number().int().positive(),selected_text:e.string().min(1),content:e.string().trim().min(1)}),Ka=e.object({id:e.string().min(1)}),Ya=e.object({content:e.string().trim().min(1)}),Xa=e.object({id:e.string().min(1)}),eo=e.object({content:e.string().trim().min(1)}),to=e.object({id:e.string().min(1)}),ro=e.object({content:e.string().trim().min(1)}),no=e.object({id:e.string().min(1)}),so=e.object({resolved:e.boolean()}),ao=e.object({id:e.string().min(1),resolved_at:e.string().datetime().nullable()}),oo=e.object({resolved:e.boolean()}),io=e.object({id:e.string().min(1),resolved_at:e.string().datetime().nullable()}),vr=e.record(e.unknown()),co=e.object({id:lt,body:e.string(),created_at:e.string().datetime(),prosemirror_json:vr,comment_threads:e.array(Wa)}),lo=e.object({id:_r,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:lt,revision_count:e.number().int().positive(),revisions:e.array(co)}),po=e.object({type:e.literal("list"),list_type:e.literal("plan"),has_more:e.boolean(),objects:e.array(Ga)}),mo=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()}),xr=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)}),uo=e.array(xr),ho=e.object({type:e.literal("list"),list_type:e.literal("building_block"),has_more:e.boolean(),objects:e.array(xr)}),fo=e.object({repo_origin_path:e.string().min(1),before:e.string().min(1).optional(),after:e.string().min(1).optional()}),go=e.enum(["thread","building_block"]),yo=e.object({repo_origin_path:e.string().min(1),sources:e.array(go).nonempty()}),bo=e.object({type:e.literal("list"),list_type:e.literal("repository"),has_more:e.boolean(),objects:e.array(yo)}),ae=e.enum(["claudeCode","codex","amp","cursor","unspecified"]),_o=["transcript","plan"],vo=e.enum(_o),xo=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:vo.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"}),Pt=e.object({id:e.string().min(1),display_name:e.string().min(1)}),So=e.object({id:e.string().min(1),display_name:e.string().min(1)}),Sr=e.object({id:e.string().min(1),author_id:e.string().min(1).nullable(),author:So.nullable(),created_at:e.string().datetime(),deleted_at:e.string().datetime().nullable(),content:e.string().min(1)}),kr=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()}),ko=kr.extend({comments:e.array(Sr)}),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(ko).optional()}).passthrough(),jr=e.object({type:e.literal("list"),list_type:e.literal("thread_block"),has_more:e.boolean(),objects:e.array(Me)}),dr=Me.extend({type:e.literal("plan"),prosemirror_json:vr,thread_file_id:e.string().min(1)}),jo=e.union([e.literal(-1),e.literal(1)]),Tr=e.union([e.literal(-1),e.literal(0),e.literal(1)]),pr=e.object({score:e.number().int(),up_count:e.number().int().nonnegative(),down_count:e.number().int().nonnegative(),viewer_vote:Tr}),To=e.object({value:jo}),wo=e.object({id:e.string().min(1),display_name:e.string().min(1),avatar_url:e.string().nullable()}),Te=e.object({id:e.string().min(1),thread_id:e.string().min(1),author_id:e.string().min(1).nullable(),author:wo.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()}),Ro=e.object({type:e.literal("list"),list_type:e.literal("thread_comment"),objects:e.array(Te)}),Co=e.object({content:e.string().trim().min(1).max(4e3),parent_comment_id:e.string().min(1).optional()}),Po=Te,zo=e.object({content:e.string().trim().min(1).max(4e3)}),Ao=Te,Eo=Te,ed=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:Te}),e.object({kind:e.literal("updated"),thread_id:e.string().min(1),actor_user_id:e.string().min(1),version:e.number(),comment:Te}),e.object({kind:e.literal("deleted"),thread_id:e.string().min(1),actor_user_id:e.string().min(1),version:e.number(),comment:Te})]),Oo=e.enum(["pending","generating","ready","failed"]),Io=e.enum(["pending","generating","ready","failed"]),Lo=e.enum(["pending","placeholder","ai","user"]),wr=e.enum(["pending","generating","ready","failed"]),No=e.enum(["asked","requested","decided","corrected","shared"]),Uo=e.object({id:e.string().min(1),kind:No,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:wr,generated_at:e.string().nullable(),objects:e.array(Uo)}),Le=e.object({id:e.string().min(1),thread_file_id:e.string().min(1),organization_id:e.string().min(1),author:Pt,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:Oo,summary_generated_at:e.string().nullable(),title_status:Io,title_generated_at:e.string().nullable(),title_source:Lo,decisions_status:wr,decisions_generated_at:e.string().nullable(),score:e.number().int(),up_count:e.number().int().nonnegative(),down_count:e.number().int().nonnegative(),viewer_vote:Tr,comment_count:e.number().int().nonnegative(),is_favorited:e.boolean()}),$o=e.object({storage_url:e.string().min(1)}),Do=e.object({storage_url:e.string(),harness:ae,thread:Le.nullable()}),qo=e.object({status:e.literal("complete"),thread_files:e.array(Do)}),Mo=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:Le.nullable()}),Vo=e.object({id:e.string(),substrate:e.enum(["s3","filesystem"]),status:e.enum(["incomplete","locked_for_parsing","complete","error"]),thread_files:e.array(Mo)}),Fo=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"}),Zo=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})]),Go=Le,mr=e.object({type:e.literal("list"),list_type:e.literal("thread"),has_more:e.boolean(),objects:e.array(Go)}),Ho=e.enum(["recent","popular"]),Qo=Le,Wo=e.object({type:e.literal("list"),list_type:e.literal("discover_thread"),has_more:e.boolean(),objects:e.array(Qo)}),Jo=e.object({before:e.string().min(1).optional(),after:e.string().min(1).optional(),sort:Ho.optional(),harness:ae.optional(),search:e.string().max(200).optional()}),Ko=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())}),Yo=e.object({id:e.string(),status:e.enum(["incomplete","locked_for_parsing","complete","error"]),created_at:e.string(),thread_count:e.number().int().nonnegative()}),Xo=e.object({type:e.literal("list"),list_type:e.literal("upload_session"),objects:e.array(Yo)}),ei=e.object({before:e.string().min(1).optional(),after:e.string().min(1).optional()}),ti=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()}),ri=e.object({path:e.string().min(1),start_offset:e.number().int().nonnegative(),end_offset:e.number().int().positive()}),ni=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()}),si=e.object({type:e.literal("list"),list_type:e.literal("skill"),objects:e.array(ni)}),ai=e.object({id:e.string(),title:e.string(),visibility:e.enum(["private","workspace","public"]),started_at:e.string(),author:Pt,skills_invoked:e.array(e.string())}),oi=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(ai)}),ii=e.object({path:e.string().min(1),text:e.string().max(64e3)}),ci=e.enum(["text_edit","redact","delete_block"]),li=e.object({id:e.string(),thread_block_id:e.string(),editor:e.object({id:e.string(),display_name:e.string()}),kind:ci,path:e.string().nullable(),previous_text:e.string().nullable(),new_text:e.string().nullable(),created_at:e.string()}),di=e.object({type:e.literal("list"),list_type:e.literal("thread_block_edit"),objects:e.array(li)}),pi=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()}),mi=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()}),ui=e.object({type:e.literal("list"),list_type:e.literal("admin_organization"),objects:e.array(mi)}),Rr=e.object({id:e.string(),name:e.string()}),hi=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)}),fi=e.object({type:e.literal("list"),list_type:e.literal("admin_user"),objects:e.array(hi)}),gi=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:Pt,organization:Rr}),yi=e.object({type:e.literal("list"),list_type:e.literal("admin_thread"),has_more:e.boolean(),objects:e.array(gi)}),bi=e.object({before:e.string().min(1).optional(),after:e.string().min(1).optional()}),ur=e.object({token:e.string().min(1),thread_id:e.string().min(1)}),_i=e.object({visitor:e.string().min(1).max(64).optional()}),vi=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()}),xi=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(vi)}),Si=e.object({windows:e.array(xi)}),ki=e.object({quoted_text:e.string().min(1),comment:e.string().nullable(),type:e.enum(["comment","highlight:trapdoor"])}),ji=kr,Ti=Sr.extend({comment_thread_id:e.string().min(1)}),wi=e.object({markdown:e.string().min(1)}),Ri=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(ki),comment_threads:e.array(ji),comments:e.array(Ti)}),Ne=e.enum(St),Cr=e.object({skills:e.boolean(),workspace_scope:e.boolean(),review:e.boolean(),shared_thread_ttl_days:e.number().int().positive().nullable()}),Ct=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:Cr}),Ci=e.object({effective_plan:Ne,features:Cr,user:Ct,organization:Ct.nullable()}),Pi=e.object({plan:e.enum(["creator","team"]),seat_quantity:e.number().int().positive().optional()}),zi=e.object({checkout_url:e.string().min(1)}),Ai=e.object({portal_url:e.string().min(1)}),Ei=e.object({seat_quantity:e.number().int().positive()}),hr=e.object({plan:Ne.nullable()}),ct=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()}),Oi=e.object({users:e.array(ct),organizations:e.array(ct)}),Ii=e.object({id:e.string().min(1),display_name:e.string().min(1),handle:e.string().nullable(),avatar_url:e.string().nullable()}),Li=e.object({thread_id:e.string().min(1),title:e.string().min(1),author:Ii,last_active_at:e.string().datetime(),last_block_excerpt:e.string().nullable(),last_block_kind:e.string().min(1).nullable(),is_streaming:e.boolean()}),Ni=e.object({type:e.literal("list"),list_type:e.literal("live_thread"),objects:e.array(Li)}),Ui=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()}),Di=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()}),Pr=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()}),fr=e.object({type:e.literal("list"),list_type:e.literal("user_follow"),objects:e.array(Pr)}),qi=e.object({date:e.string().regex(/^\d{4}-\d{2}-\d{2}$/),count:e.number().int().nonnegative()}),Mi=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(qi)}),Vi=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"])})}),Fi=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"])})}),Zi=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)})}),Gi=e.object({type:e.literal("user_followed"),occurred_at:e.string().datetime(),id:e.string().min(1),followee:Pr}),Hi=e.discriminatedUnion("type",[Vi,Fi,Zi,Gi]),Qi=e.object({type:e.literal("list"),list_type:e.literal("user_activity"),objects:e.array(Hi)}),Wi=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()}),Ji=e.object({type:e.literal("list"),list_type:e.literal("profile_published_project"),objects:e.array(Wi)}),gr=e.object({id:e.string().min(1),published_at:e.string().datetime().nullable()}),Ki=e.enum(["avatar","banner"]),Yi=e.enum(["image/png","image/jpeg","image/webp","image/gif"]),Xi=e.object({kind:Ki,content_type:Yi,base64_data:e.string().min(1)}),ec=e.object({substrate:e.enum(["s3","filesystem"]),storage_url:e.string().min(1)}),tc=br,zr=Pa.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:Oa,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:Ui,responses:{200:Bi,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:Ni,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:ti,responses:{200:mr,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:mr,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:ei,responses:{200:jr,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:Ya,responses:{201:Xa,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:ro,responses:{201:no,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:oo,responses:{200:io,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:si,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:oi,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:ri,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:ii,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:di,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:Bo,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:Fo,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:To,responses:{200:pr,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:pr,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:Ro,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:Co,responses:{201:Po,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:zo,responses:{200:Ao,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:Eo,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:Zo,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:Va,responses:{201:Rt,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:br,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:Ia,responses:{200:Rt,401:l,409:l,422:l},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:tc,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:Qi,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:Mi,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:fr,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:fr,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:$i,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:Di,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:Ji,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:gr,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:gr,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:Xi,responses:{200:ec,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:Na,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:Ua,responses:{201:Ba,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:bo,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:Za,responses:{201:uo,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:lo,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:Ja,responses:{201:Ka,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:eo,responses:{201:to,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:so,responses:{200:ao,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:mo,responses:{200:po,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:fo,responses:{200:ho,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:Xo,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(xo).nonempty()}),responses:{201:Vo,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($o).nonempty()}),responses:{200:qo,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:pi,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:ui,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:fi,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:bi,responses:{200:yi,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:Jo,responses:{200:Wo},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:Ko},summary:"Unauthenticated rollup of public-thread counts for the Discover header."},createWaitlistEntry:{method:"POST",path:"/waitlist_entries",body:$a,responses:{201:Da,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:ur,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:_i,responses:{200:ur,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:Si,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:wi,responses:{200:Ri,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:Ci,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:Pi,responses:{200:zi,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:Ai,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:Ei,responses:{200:Ct,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:Oi,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:hr,responses:{200:ct,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:hr,responses:{200:ct,401:l,403:l,404:l},summary:"Admin override for an organization's plan tier. Null clears the override."},projects:or,docs:sr,mentions:ir,favorites:lr},{pathPrefix:"/api"});import Fe from"node:fs";import Lr from"node:path";import sc from"node:os";import Ir from"node:path";var rc="prod",Ar="0.1.7",nc=`@tanagram/lore/${Ar}`;function L(){return rc}function Er(){return Ar}function Or(){return nc}function Ve(){let r=L()==="dev"?".lore-dev":".lore";return Ir.join(sc.homedir(),r)}function dt(){return Ir.join(Ve(),"log.txt")}function pt(){return Lr.join(Ve(),"token")}function zt(){let r;try{r=Fe.readFileSync(pt(),"utf8")}catch(n){if(n&&typeof n=="object"&&"code"in n&&n.code==="ENOENT")return{token:"",source:"none"};throw n}let t=r.trim();return!t||oc(t,new Date)?{token:"",source:"none"}:{token:t,source:"file"}}function Nr(){return zt().token}function Ur(){return Fe.existsSync(pt())}function Br(r){let t=pt();Fe.mkdirSync(Lr.dirname(t),{recursive:!0,mode:448}),Fe.writeFileSync(t,r,{mode:384})}function $r(){try{Fe.rmSync(pt())}catch(r){if(r&&typeof r=="object"&&"code"in r&&r.code==="ENOENT")return;throw r}}function ac(r){let t=r.split(".");if(t.length<2)throw new Error("invalid JWT format");return JSON.parse(Buffer.from(t[1],"base64url").toString("utf8"))}function oc(r,t){let n;try{n=ac(r)}catch{return!1}let s=n["https://stytch.com/session"]?.expires_at;if(typeof s!="string")return!1;let a=Date.parse(s.trim());return Number.isNaN(a)?!1:t.getTime()>=a}var ic={dev:"http://localhost:4000",prod:"https://lore.tanagram.ai"};function Ue(r={}){let t=r.token??Nr();return xt(zr,{baseUrl:ic[L()],baseHeaders:{"User-Agent":Or(),...t?{authorization:`Bearer ${t}`}:{}}})}import qr from"node:fs";var Dr=!1;function cc(){Dr||(qr.mkdirSync(Ve(),{recursive:!0}),Dr=!0)}function lc(r){let t=typeof r=="string"?r:JSON.stringify(r);return/[\s"=]/.test(t)?JSON.stringify(t):t}function dc(r,t,n){let s=`${new Date().toISOString()} ${r} ${t}`;if(!n)return`${s}
5
+ `;let a=Object.entries(n).map(([o,c])=>`${o}=${lc(c)}`).join(" ");return a?`${s} ${a}
6
6
  `:`${s}
7
- `}function At(r,t,n){let s=oc(r,t,n);sc(),Br.appendFileSync(dt(),s),L()==="dev"&&process.stderr.write(s)}var I={info(r,t){At("info",r,t)},warn(r,t){At("warn",r,t)},error(r,t){At("error",r,t)}};var $r={meta:{name:"health",description:"Check API health"},async run({data:r}){I.info("command_start",{command:"health"});let n=await(r?.client??Ue()).health();if(n.status===200){console.log(n.body.status);return}throw I.error("health_failed",{status:n.status}),console.error(`health check failed: HTTP ${n.status}`),new Error(`health check failed: HTTP ${n.status}`)}};var Dr={meta:{name:"hello",description:"Print a friendly greeting"},run(){I.info("command_start",{command:"hello"}),console.log("hello world")}};import{spawn as cc}from"node:child_process";import Fr from"node:crypto";import lc from"node:http";var ic={dev:"http://localhost:8080",prod:"https://lore.tanagram.ai"};function qr(){return ic[L()]}var dc=5*60*1e3;function pc(){return Fr.randomBytes(32).toString("base64url")}function mc(r){return Fr.createHash("sha256").update(r).digest("base64url")}function uc(r){let t;try{t=JSON.parse(Buffer.from(r.trim(),"base64url").toString("utf8"))}catch(n){throw new Error(`decoding: ${n instanceof Error?n.message:String(n)}`)}if(typeof t.session_jwt!="string"||!t.session_jwt)throw new Error("missing session token");if(typeof t.code_challenge!="string"||!t.code_challenge)throw new Error("missing code challenge");return{sessionJwt:t.session_jwt,codeChallenge:t.code_challenge}}function hc(r){return r.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Mr(r,t,n){let s=t==="success";r.writeHead(200,{"Content-Type":"text/html"}),r.end(`<!DOCTYPE html>
7
+ `}function At(r,t,n){let s=dc(r,t,n);cc(),qr.appendFileSync(dt(),s),L()==="dev"&&process.stderr.write(s)}var I={info(r,t){At("info",r,t)},warn(r,t){At("warn",r,t)},error(r,t){At("error",r,t)}};var Mr={meta:{name:"health",description:"Check API health"},async run({data:r}){I.info("command_start",{command:"health"});let n=await(r?.client??Ue()).health();if(n.status===200){console.log(n.body.status);return}throw I.error("health_failed",{status:n.status}),console.error(`health check failed: HTTP ${n.status}`),new Error(`health check failed: HTTP ${n.status}`)}};var Vr={meta:{name:"hello",description:"Print a friendly greeting"},run(){I.info("command_start",{command:"hello"}),console.log("hello world")}};import{spawn as mc}from"node:child_process";import Gr from"node:crypto";import uc from"node:http";var pc={dev:"http://localhost:8080",prod:"https://lore.tanagram.ai"};function Fr(){return pc[L()]}var hc=5*60*1e3;function fc(){return Gr.randomBytes(32).toString("base64url")}function gc(r){return Gr.createHash("sha256").update(r).digest("base64url")}function yc(r){let t;try{t=JSON.parse(Buffer.from(r.trim(),"base64url").toString("utf8"))}catch(n){throw new Error(`decoding: ${n instanceof Error?n.message:String(n)}`)}if(typeof t.session_jwt!="string"||!t.session_jwt)throw new Error("missing session token");if(typeof t.code_challenge!="string"||!t.code_challenge)throw new Error("missing code challenge");return{sessionJwt:t.session_jwt,codeChallenge:t.code_challenge}}function bc(r){return r.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Zr(r,t,n){let s=t==="success";r.writeHead(200,{"Content-Type":"text/html"}),r.end(`<!DOCTYPE html>
8
8
  <html><head><meta charset="utf-8"><title>Lore CLI</title></head>
9
9
  <body style="font-family:system-ui;display:flex;justify-content:center;align-items:center;min-height:100vh;margin:0;background:#fafafa">
10
10
  <div style="text-align:center;max-width:400px;padding:40px;border:1px solid #e0e0e0;border-radius:10px;background:#fff;box-shadow:0 2px 10px rgba(0,0,0,0.1)">
11
11
  <div style="font-size:48px;margin-bottom:20px">${s?"\u2713":"\u2717"}</div>
12
12
  <h1 style="margin:0 0 10px">${s?"Authorization Complete":"Authorization Cancelled"}</h1>
13
- <p style="color:#666">${s?"You can close this window now.":hc(n??"Authorization was cancelled.")}</p>
13
+ <p style="color:#666">${s?"You can close this window now.":bc(n??"Authorization was cancelled.")}</p>
14
14
  <p style="color:#999;font-size:14px">You can close this tab and return to your terminal.</p>
15
- </div></body></html>`)}async function fc(){let r,t=new Promise(o=>{r=o}),n=lc.createServer((o,c)=>{let i=new URL(o.url??"/","http://127.0.0.1");if(i.pathname!=="/callback"){c.writeHead(404),c.end();return}let d=i.searchParams.get("error");if(d){let u=i.searchParams.get("error_description")||d;Mr(c,"error",u),r?.({type:"error",description:u});return}let p=i.searchParams.get("code");if(p){Mr(c,"success"),r?.({type:"code",code:p});return}c.writeHead(400),c.end()});return await new Promise((o,c)=>{n.once("error",c),n.listen(0,"127.0.0.1",()=>{n.off("error",c),o()})}),{redirectURI:`http://127.0.0.1:${n.address().port}/callback`,waitForCallback(o){return new Promise((c,i)=>{let d=setTimeout(()=>{i(new Error("authorization timed out"))},o);t.then(p=>{clearTimeout(d),c(p)})})},close(){return new Promise((o,c)=>{n.close(i=>{if(i){c(i);return}o()})})}}}async function gc(r){let{command:t,args:n}=yc(process.platform,r);await new Promise((s,a)=>{let o=cc(t,n,{detached:!0,stdio:"ignore"});o.once("error",a),o.once("spawn",()=>{o.unref(),s()})})}function yc(r,t){return r==="win32"?{command:"rundll32",args:["url.dll,FileProtocolHandler",t]}:r==="darwin"?{command:"open",args:[t]}:{command:"xdg-open",args:[t]}}async function bc(r){if(zt().source==="none")return!1;try{return(await r.whoAmI({headers:{}})).status===200}catch{return!1}}async function _c({client:r=Ue(),openBrowser:t=gc,setAccessToken:n=Lr,webBaseURL:s=qr(),timeoutMs:a=dc}={}){if(await bc(r)){console.log(`
15
+ </div></body></html>`)}async function _c(){let r,t=new Promise(o=>{r=o}),n=uc.createServer((o,c)=>{let i=new URL(o.url??"/","http://127.0.0.1");if(i.pathname!=="/callback"){c.writeHead(404),c.end();return}let d=i.searchParams.get("error");if(d){let u=i.searchParams.get("error_description")||d;Zr(c,"error",u),r?.({type:"error",description:u});return}let p=i.searchParams.get("code");if(p){Zr(c,"success"),r?.({type:"code",code:p});return}c.writeHead(400),c.end()});return await new Promise((o,c)=>{n.once("error",c),n.listen(0,"127.0.0.1",()=>{n.off("error",c),o()})}),{redirectURI:`http://127.0.0.1:${n.address().port}/callback`,waitForCallback(o){return new Promise((c,i)=>{let d=setTimeout(()=>{i(new Error("authorization timed out"))},o);t.then(p=>{clearTimeout(d),c(p)})})},close(){return new Promise((o,c)=>{n.close(i=>{if(i){c(i);return}o()})})}}}async function vc(r){let{command:t,args:n}=xc(process.platform,r);await new Promise((s,a)=>{let o=mc(t,n,{detached:!0,stdio:"ignore"});o.once("error",a),o.once("spawn",()=>{o.unref(),s()})})}function xc(r,t){return r==="win32"?{command:"rundll32",args:["url.dll,FileProtocolHandler",t]}:r==="darwin"?{command:"open",args:[t]}:{command:"xdg-open",args:[t]}}async function Sc(r){if(zt().source==="none")return!1;try{return(await r.whoAmI({headers:{}})).status===200}catch{return!1}}async function kc({client:r=Ue(),openBrowser:t=vc,setAccessToken:n=Br,webBaseURL:s=Fr(),timeoutMs:a=hc}={}){if(await Sc(r)){console.log(`
16
16
  Already logged in. Use 'lore logout' if you want to sign out.
17
- `);return}let o=pc(),c=mc(o),i=await fc();try{let d=new URL("/cli-authorize",s);d.searchParams.set("redirect_uri",i.redirectURI),d.searchParams.set("code_challenge",c),d.searchParams.set("code_challenge_method","S256");try{await t(d.toString()),console.log(`
17
+ `);return}let o=fc(),c=gc(o),i=await _c();try{let d=new URL("/cli-authorize",s);d.searchParams.set("redirect_uri",i.redirectURI),d.searchParams.set("code_challenge",c),d.searchParams.set("code_challenge_method","S256");try{await t(d.toString()),console.log(`
18
18
  Opening browser to log in...`),console.log(`
19
19
  If your browser didn't open, visit:`)}catch(T){I.warn("open_browser_failed",{error:T instanceof Error?T.message:String(T)}),console.log(`
20
20
  Visit this URL to log in:`)}console.log(` ${d.toString()}
21
21
  `),console.log(" Waiting for authorization. Click Authorize in your browser...");let p=await i.waitForCallback(a);if(p.type==="error")throw console.log(`
22
22
  Authorization denied: ${p.description}
23
- `),new Error(p.description);let u=uc(p.code);if(u.codeChallenge!==c)throw console.log(`
23
+ `),new Error(p.description);let u=yc(p.code);if(u.codeChallenge!==c)throw console.log(`
24
24
  Authorization code verification failed.
25
25
  `),new Error("PKCE challenge mismatch");n(u.sessionJwt),console.log(`
26
26
  Logged in successfully.
27
27
  `)}catch(d){throw d instanceof Error&&d.message==="authorization timed out"&&console.log(`
28
28
  Authorization timed out. Please try again.
29
- `),d}finally{await i.close()}}var Vr={meta:{name:"login",description:"Authorize this CLI against your Lore workspace"},async run({data:r}){I.info("command_start",{command:"login"}),await _c({client:r?.client,openBrowser:r?.openBrowser,setAccessToken:r?.setAccessToken,webBaseURL:r?.webBaseURL,timeoutMs:r?.timeoutMs})}};var Zr={meta:{name:"logout",description:"Log out of your Lore workspace"},run(){I.info("command_start",{command:"logout"});let r=Ir();if(Nr(),!r){console.log(`
29
+ `),d}finally{await i.close()}}var Hr={meta:{name:"login",description:"Authorize this CLI against your Lore workspace"},async run({data:r}){I.info("command_start",{command:"login"}),await kc({client:r?.client,openBrowser:r?.openBrowser,setAccessToken:r?.setAccessToken,webBaseURL:r?.webBaseURL,timeoutMs:r?.timeoutMs})}};var Qr={meta:{name:"logout",description:"Log out of your Lore workspace"},run(){I.info("command_start",{command:"logout"});let r=Ur();if($r(),!r){console.log(`
30
30
  Not currently logged in.
31
31
  `);return}console.log(`
32
32
  Logged out successfully.
33
- `)}};var Gr={meta:{name:"logs",description:"Print the path to the log file"},run(){I.info("command_start",{command:"logs"}),console.log(dt())}};import{promises as oe}from"node:fs";import vc from"node:os";import we from"node:path";import{fileURLToPath as Hr}from"node:url";function Ot(){return we.join(vc.homedir(),".claude","skills")}function Qr(r){return r.map(t=>t.name).sort().join(", ")}function Wr(r){return r[0]?we.dirname(r[0].destination):Ot()}async function xc(r){try{return(await oe.stat(r)).isDirectory()}catch(t){if(t.code==="ENOENT")return!1;throw t}}async function Jr(){let r=[Hr(new URL("../skills",import.meta.url)),Hr(new URL("../../skills",import.meta.url))];for(let t of r)if(await xc(t))return t;throw new Error("bundled skills directory not found")}function Sc(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[,s,a,o]=n,c=a.replace(/^name: .*$/m,`name: ${t}`);if(c===a)throw new Error("skill file frontmatter is missing a name");return`${s}${c}${o}${r.slice(n[0].length)}`}async function kc({destination:r=Ot(),environment:t=L(),sourceDir:n}={}){let s=n??await Jr(),a=(await oe.readdir(s,{withFileTypes:!0})).filter(i=>i.isDirectory()),o=t==="prod"?"":`-${t}`,c=[];await oe.mkdir(r,{recursive:!0});for(let i of a){let d=`${i.name}${o}`,p=we.join(s,i.name),u=we.join(r,d);if(await oe.cp(p,u,{recursive:!0,force:!0}),o){let T=we.join(u,"SKILL.md"),w=await oe.readFile(T,"utf8");await oe.writeFile(T,Sc(w,d))}c.push({name:d,source:p,destination:u})}return c}async function jc({destination:r=Ot(),environment:t=L(),sourceDir:n}={}){let s=n??await Jr(),a=(await oe.readdir(s,{withFileTypes:!0})).filter(i=>i.isDirectory()),o=t==="prod"?"":`-${t}`,c=[];for(let i of a){let d=`${i.name}${o}`,p=we.join(s,i.name),u=we.join(r,d);await oe.rm(u,{recursive:!0,force:!0}),c.push({name:d,source:p,destination:u})}return c}var Kr={meta:{name:"postinstall:install-skills",hidden:!0},args:{destination:{type:"positional",required:!1,description:"Install destination"}},async run({args:r}){let t=await kc({destination:r.destination});console.log(`installed skills ${Qr(t)} to ${Wr(t)}`)}},Yr={meta:{name:"postinstall:uninstall-skills",hidden:!0},args:{destination:{type:"positional",required:!1,description:"Install destination"}},async run({args:r}){let t=await jc({destination:r.destination});console.log(`uninstalled skills ${Qr(t)} from ${Wr(t)}`)}};var Xr={meta:{name:"whoami",description:"Print the authenticated Lore user",hidden:!0},async run({data:r}){I.info("command_start",{command:"whoami"});let n=await(r?.client??Ue()).whoAmI({headers:{}});if(n.status===200){console.log(n.body.emailAddress);return}throw console.error("Not authenticated. Run 'lore login' first."),new Error(`whoami failed: HTTP ${n.status}`)}};var Tc="phc_sMsUvf0nK50rZdztSlX9rDJqIreLcXj4dyGS0tORQpQ",wc="https://phe.tanagram.ai/capture/",Rc=2e3;function en(r){return process.env[r]??""}function Cc(r,t){let n=[r,t].filter(Boolean);return n.length>0?n.join("@"):"unknown-cli-user"}async function tn({commandName:r,durationMs:t}){let n=en("USER"),s=en("HOST"),a=new AbortController,o=setTimeout(()=>a.abort(),Rc);try{await fetch(wc,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({api_key:Tc,event:"lore.cli.command_run",properties:{distinct_id:Cc(n,s),command_name:r,duration_ms:Math.round(t),environment:L(),user:n,host:s}}),signal:a.signal})}catch(c){I.warn("posthog_capture_failed",{command:r,error:c instanceof Error?c.message:String(c)})}finally{clearTimeout(o)}}var rn={hello:Dr,health:$r,login:Vr,logout:Zr,whoami:Xr,logs:Gr,"postinstall:install-skills":Kr,"postinstall:uninstall-skills":Yr};function zc(r){let t=r.find(n=>!n.startsWith("-"));return t||"hello"}var Ac={name:"cli-metrics",setup(r){r.data={...r.data,commandStartedAtMs:performance.now()}},async cleanup(r){let t=r.data?.commandStartedAtMs;if(typeof t!="number")return;let n=performance.now()-t;await(r.data?.captureCliCommandMetric??tn)({commandName:zc(r.rawArgs),durationMs:n})}},Et={meta:{name:"lore",description:"Lore CLI"},plugins:[Ac],subCommands:rn,default:"hello"};function Oc(r){return r instanceof Error&&r.name==="CLIError"}function Ec(r){let t=r.find(s=>!s.startsWith("-")),n=t?rn[t]:void 0;return n?[n,Et]:[Et,void 0]}async function Ic(r){try{if(r.includes("--help")||r.includes("-h")){console.log(await $t(...Ec(r)));return}await We(Et,{rawArgs:r})}catch(t){Oc(t)||L()==="prod"&&t instanceof Error?console.error(t.message):console.error(t,`
34
- `),process.exit(1)}}process.argv[1]&&import.meta.url===Pc(process.argv[1]).href&&await Ic(process.argv.slice(2));export{Et as mainCommand};
33
+ `)}};var Wr={meta:{name:"logs",description:"Print the path to the log file"},run(){I.info("command_start",{command:"logs"}),console.log(dt())}};import{promises as oe}from"node:fs";import jc from"node:os";import we from"node:path";import{fileURLToPath as Jr}from"node:url";function Et(){return we.join(jc.homedir(),".claude","skills")}function Kr(r){return r.map(t=>t.name).sort().join(", ")}function Yr(r){return r[0]?we.dirname(r[0].destination):Et()}async function Tc(r){try{return(await oe.stat(r)).isDirectory()}catch(t){if(t.code==="ENOENT")return!1;throw t}}async function Xr(){let r=[Jr(new URL("../skills",import.meta.url)),Jr(new URL("../../skills",import.meta.url))];for(let t of r)if(await Tc(t))return t;throw new Error("bundled skills directory not found")}function wc(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[,s,a,o]=n,c=a.replace(/^name: .*$/m,`name: ${t}`);if(c===a)throw new Error("skill file frontmatter is missing a name");return`${s}${c}${o}${r.slice(n[0].length)}`}async function Rc({destination:r=Et(),environment:t=L(),sourceDir:n}={}){let s=n??await Xr(),a=(await oe.readdir(s,{withFileTypes:!0})).filter(i=>i.isDirectory()),o=t==="prod"?"":`-${t}`,c=[];await oe.mkdir(r,{recursive:!0});for(let i of a){let d=`${i.name}${o}`,p=we.join(s,i.name),u=we.join(r,d);if(await oe.cp(p,u,{recursive:!0,force:!0}),o){let T=we.join(u,"SKILL.md"),w=await oe.readFile(T,"utf8");await oe.writeFile(T,wc(w,d))}c.push({name:d,source:p,destination:u})}return c}async function Cc({destination:r=Et(),environment:t=L(),sourceDir:n}={}){let s=n??await Xr(),a=(await oe.readdir(s,{withFileTypes:!0})).filter(i=>i.isDirectory()),o=t==="prod"?"":`-${t}`,c=[];for(let i of a){let d=`${i.name}${o}`,p=we.join(s,i.name),u=we.join(r,d);await oe.rm(u,{recursive:!0,force:!0}),c.push({name:d,source:p,destination:u})}return c}var en={meta:{name:"postinstall:install-skills",hidden:!0},args:{destination:{type:"positional",required:!1,description:"Install destination"}},async run({args:r}){let t=await Rc({destination:r.destination});console.log(`installed skills ${Kr(t)} to ${Yr(t)}`)}},tn={meta:{name:"postinstall:uninstall-skills",hidden:!0},args:{destination:{type:"positional",required:!1,description:"Install destination"}},async run({args:r}){let t=await Cc({destination:r.destination});console.log(`uninstalled skills ${Kr(t)} from ${Yr(t)}`)}};var rn={meta:{name:"whoami",description:"Print the authenticated Lore user",hidden:!0},async run({data:r}){I.info("command_start",{command:"whoami"});let n=await(r?.client??Ue()).whoAmI({headers:{}});if(n.status===200){console.log(n.body.emailAddress);return}throw console.error("Not authenticated. Run 'lore login' first."),new Error(`whoami failed: HTTP ${n.status}`)}};var Pc="phc_sMsUvf0nK50rZdztSlX9rDJqIreLcXj4dyGS0tORQpQ",zc="https://phe.tanagram.ai/capture/",Ac=2e3;function nn(r){return process.env[r]??""}function Ec(r,t){let n=[r,t].filter(Boolean);return n.length>0?n.join("@"):"unknown-cli-user"}async function sn({commandName:r,durationMs:t}){let n=nn("USER"),s=nn("HOST"),a=new AbortController,o=setTimeout(()=>a.abort(),Ac);try{await fetch(zc,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({api_key:Pc,event:"lore.cli.command_run",properties:{distinct_id:Ec(n,s),command_name:r,cli_version:Er(),duration_ms:Math.round(t),environment:L(),user:n,host:s}}),signal:a.signal})}catch(c){I.warn("posthog_capture_failed",{command:r,error:c instanceof Error?c.message:String(c)})}finally{clearTimeout(o)}}var an={hello:Vr,health:Mr,login:Hr,logout:Qr,whoami:rn,logs:Wr,"postinstall:install-skills":en,"postinstall:uninstall-skills":tn};function Ic(r){let t=r.find(n=>!n.startsWith("-"));return t||"hello"}var Lc={name:"cli-metrics",setup(r){r.data={...r.data,commandStartedAtMs:performance.now()}},async cleanup(r){let t=r.data?.commandStartedAtMs;if(typeof t!="number")return;let n=performance.now()-t;await(r.data?.captureCliCommandMetric??sn)({commandName:Ic(r.rawArgs),durationMs:n})}},Ot={meta:{name:"lore",description:"Lore CLI"},plugins:[Lc],subCommands:an,default:"hello"};function Nc(r){return r instanceof Error&&r.name==="CLIError"}function Uc(r){let t=r.find(s=>!s.startsWith("-")),n=t?an[t]:void 0;return n?[n,Ot]:[Ot,void 0]}async function Bc(r){try{if(r.includes("--help")||r.includes("-h")){console.log(await $t(...Uc(r)));return}await We(Ot,{rawArgs:r})}catch(t){Nc(t)||L()==="prod"&&t instanceof Error?console.error(t.message):console.error(t,`
34
+ `),process.exit(1)}}process.argv[1]&&import.meta.url===Oc(process.argv[1]).href&&await Bc(process.argv.slice(2));export{Ot as mainCommand};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanagram/lore",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "Lore CLI",
5
5
  "type": "module",
6
6
  "bin": {
@@ -29,8 +29,8 @@
29
29
  "scripts": {
30
30
  "dev": "pnpm run postinstall && tsx src/index.ts",
31
31
  "postinstall": "node scripts/runPostinstallCommand.mjs postinstall:install-skills",
32
- "build": "esbuild src/index.ts --bundle --platform=node --format=esm --target=node20 --outfile=dist/index.js && chmod +x dist/index.js",
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",
32
+ "build": "esbuild src/index.ts --bundle --platform=node --format=esm --target=node20 --define:process.env.LORE_CLI_VERSION='\"'\"$npm_package_version\"'\"' --outfile=dist/index.js && chmod +x dist/index.js",
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\"' --define:process.env.LORE_CLI_VERSION='\"'\"$npm_package_version\"'\"' --outfile=dist/index.js && chmod +x dist/index.js",
34
34
  "start": "node dist/index.js",
35
35
  "lint": "biome check src",
36
36
  "typecheck": "tsc --noEmit",