@tanagram/lore 0.1.12 → 0.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -35,7 +35,7 @@ Url: ${dm(t)}`),!0}return!1}function Yce(t,e){return e?.length?am(t).some(n=>Ts(
|
|
|
35
35
|
`),m=f.shift();if(!m)return t.destroy(),n(new Error("No header received from proxy CONNECT response"));let h=m.split(" "),T=+(h[1]||0),S=h.slice(2).join(" "),R={};for(let I of f){if(!I)continue;let x=I.indexOf(":");if(x===-1)return t.destroy(),n(new Error(`Invalid header from proxy CONNECT response: "${I}"`));let F=I.slice(0,x).toLowerCase(),B=I.slice(x+1).trimStart(),se=R[F];typeof se=="string"?R[F]=[se,B]:Array.isArray(se)?se.push(B):R[F]=B}qh("got proxy server response: %o %o",m,R),i(),e({connect:{statusCode:T,statusText:S,headers:R},buffered:d})}t.on("error",c),t.on("end",a),s()})}function Fp(...t){g.log("[https-proxy-agent]",...t)}var Vp=class extends Vh{static __initStatic(){this.protocols=["http","https"]}constructor(e,n){super(n),this.options={},this.proxy=typeof e=="string"?new URL(e):e,this.proxyHeaders=n?.headers??{},Fp("Creating new HttpsProxyAgent instance: %o",this.proxy.href);let r=(this.proxy.hostname||this.proxy.host).replace(/^\[|\]$/g,""),o=this.proxy.port?parseInt(this.proxy.port,10):this.proxy.protocol==="https:"?443:80;this.connectOpts={ALPNProtocols:["http/1.1"],...n?VV(n,"headers"):null,host:r,port:o}}async connect(e,n){let{proxy:r}=this;if(!n.host)throw new TypeError('No "host" provided');let o;if(r.protocol==="https:"){Fp("Creating `tls.Socket`: %o",this.connectOpts);let _=this.connectOpts.servername||this.connectOpts.host;o=PO.connect({...this.connectOpts,servername:_&&Vo.isIP(_)?void 0:_})}else Fp("Creating `net.Socket`: %o",this.connectOpts),o=Vo.connect(this.connectOpts);let s=typeof this.proxyHeaders=="function"?this.proxyHeaders():{...this.proxyHeaders},i=Vo.isIPv6(n.host)?`[${n.host}]`:n.host,a=`CONNECT ${i}:${n.port} HTTP/1.1\r
|
|
36
36
|
`;if(r.username||r.password){let _=`${decodeURIComponent(r.username)}:${decodeURIComponent(r.password)}`;s["Proxy-Authorization"]=`Basic ${Buffer.from(_).toString("base64")}`}s.Host=`${i}:${n.port}`,s["Proxy-Connection"]||(s["Proxy-Connection"]=this.keepAlive?"Keep-Alive":"close");for(let _ of Object.keys(s))a+=`${_}: ${s[_]}\r
|
|
37
37
|
`;let c=FV(o);o.write(`${a}\r
|
|
38
|
-
`);let{connect:l,buffered:p}=await c;if(e.emit("proxyConnect",l),this.emit("proxyConnect",l,e),l.statusCode===200){if(e.once("socket",Ame),n.secureEndpoint){Fp("Upgrading socket connection to TLS");let _=n.servername||n.host;return PO.connect({...VV(n,"host","path","port"),socket:o,servername:Vo.isIP(_)?void 0:_})}return o}o.destroy();let d=new Vo.Socket({writable:!1});return d.readable=!0,e.once("socket",_=>{Fp("Replaying proxy buffer for failed request"),_.push(p),_.push(null)}),d}};Vp.__initStatic();function Ame(t){t.resume()}function VV(t,...e){let n={},r;for(r in t)e.includes(r)||(n[r]=t[r]);return n}var Nme=1024*32;function bme(t){return new Ime({read(){this.push(t),this.push(null)}})}function qV(t){let e;try{e=new URL(t.url)}catch{return Qe(()=>{console.warn("[@sentry/node]: Invalid dsn or tunnel option, will not send any events. The tunnel option must be a full URL when used.")}),up(t,()=>Promise.resolve({}))}let n=e.protocol==="https:",r=Cme(e,t.proxy||(n?process.env.https_proxy:void 0)||process.env.http_proxy),o=n?yme:Rme,s=t.keepAlive===void 0?!1:t.keepAlive,i=r?new Vp(r):new o.Agent({keepAlive:s,maxSockets:30,timeout:2e3}),a=Pme(t,t.httpModule??o,i);return up(t,a)}function Cme(t,e){let{no_proxy:n}=process.env;if(!n?.split(",").some(o=>t.host.endsWith(o)||t.hostname.endsWith(o)))return e}function Pme(t,e,n){let{hostname:r,pathname:o,port:s,protocol:i,search:a}=new URL(t.url);return function(l){return new Promise((p,d)=>{xc(()=>{let _=bme(l.body),f={...t.headers};l.body.length>Nme&&(f["content-encoding"]="gzip",_=_.pipe(Ome()));let m=r.startsWith("["),h=e.request({method:"POST",agent:n,headers:f,hostname:m?r.slice(1,-1):r,path:`${o}${a}`,port:s,protocol:i,ca:t.caCerts},T=>{T.on("data",()=>{}),T.on("end",()=>{}),T.setEncoding("utf8");let S=T.headers["retry-after"]??null,R=T.headers["x-sentry-rate-limits"]??null;p({statusCode:T.statusCode,headers:{"retry-after":S,"x-sentry-rate-limits":Array.isArray(R)?R[0]||null:R}})});h.on("error",d),_.pipe(h)})})}}function $V(t){if(t===!1)return!1;if(typeof t=="string")return t;let e=Uc(process.env.SENTRY_SPOTLIGHT,{strict:!0}),n=e===null&&process.env.SENTRY_SPOTLIGHT?process.env.SENTRY_SPOTLIGHT:void 0;return t===!0?n??!0:e??n}import{posix as Mme,sep as xme}from"node:path";function YV(t){return t.replace(/^[A-Z]:/,"").replace(/\\/g,"/")}function WV(t=process.argv[1]?My(process.argv[1]):process.cwd(),e=xme==="\\"){let n=e?YV(t):t;return r=>{if(!r)return;let o=e?YV(r):r,{dir:s,base:i,ext:a}=Mme.parse(o);(a===".js"||a===".mjs"||a===".cjs")&&(i=i.slice(0,a.length*-1));let c=decodeURIComponent(i);s||(s=".");let l=s.lastIndexOf("/node_modules");if(l>-1)return`${s.slice(l+14).replace(/\//g,".")}:${c}`;if(s.startsWith(n)){let p=s.slice(n.length+1).replace(/\//g,".");return p?`${p}:${c}`:c}return c}}function zV(t){if(process.env.SENTRY_RELEASE)return process.env.SENTRY_RELEASE;if(J.SENTRY_RELEASE?.id)return J.SENTRY_RELEASE.id;let e=process.env.GITHUB_SHA||process.env.CI_MERGE_REQUEST_SOURCE_BRANCH_SHA||process.env.CI_BUILD_REF||process.env.CI_COMMIT_SHA||process.env.BITBUCKET_COMMIT,n=process.env.APPVEYOR_PULL_REQUEST_HEAD_COMMIT||process.env.APPVEYOR_REPO_COMMIT||process.env.CODEBUILD_RESOLVED_SOURCE_VERSION||process.env.AWS_COMMIT_ID||process.env.BUILD_SOURCEVERSION||process.env.GIT_CLONE_COMMIT_HASH||process.env.BUDDY_EXECUTION_REVISION||process.env.BUILDKITE_COMMIT||process.env.CIRCLE_SHA1||process.env.CIRRUS_CHANGE_IN_REPO||process.env.CF_REVISION||process.env.CM_COMMIT||process.env.CF_PAGES_COMMIT_SHA||process.env.DRONE_COMMIT_SHA||process.env.FC_GIT_COMMIT_SHA||process.env.HEROKU_TEST_RUN_COMMIT_VERSION||process.env.HEROKU_BUILD_COMMIT||process.env.HEROKU_SLUG_COMMIT||process.env.RAILWAY_GIT_COMMIT_SHA||process.env.RENDER_GIT_COMMIT||process.env.SEMAPHORE_GIT_SHA||process.env.TRAVIS_PULL_REQUEST_SHA||process.env.VERCEL_GIT_COMMIT_SHA||process.env.VERCEL_GITHUB_COMMIT_SHA||process.env.VERCEL_GITLAB_COMMIT_SHA||process.env.VERCEL_BITBUCKET_COMMIT_SHA||process.env.ZEIT_GITHUB_COMMIT_SHA||process.env.ZEIT_GITLAB_COMMIT_SHA||process.env.ZEIT_BITBUCKET_COMMIT_SHA,r=process.env.CI_COMMIT_ID||process.env.SOURCE_COMMIT||process.env.SOURCE_VERSION||process.env.GIT_COMMIT||process.env.COMMIT_REF||process.env.BUILD_VCS_NUMBER||process.env.CI_COMMIT_SHA;return e||n||r||t}var KV=xf(cI(WV()));b();var XV=K(ne(),1);import*as QV from"node:os";import{threadId as vme,isMainThread as Lme}from"worker_threads";var Dme=6e4,$h=class extends lp{constructor(e){let n=e.includeServerName===!1?void 0:e.serverName||global.process.env.SENTRY_NAME||QV.hostname(),r={...e,platform:"node",runtime:e.runtime||{name:"node",version:global.process.version},serverName:n};e.openTelemetryInstrumentations&&(0,XV.registerInstrumentations)({instrumentations:e.openTelemetryInstrumentations}),Ki(r,"node"),g.log(`Initializing Sentry: process: ${process.pid}, thread: ${Lme?"main":`worker-${vme}`}.`),super(r),this.getOptions().enableLogs&&(this._logOnExitFlushListener=()=>{Lc(this)},n&&this.on("beforeCaptureLog",o=>{o.attributes={...o.attributes,"server.address":n}}),process.on("beforeExit",this._logOnExitFlushListener))}get tracer(){if(this._tracer)return this._tracer;let e="@sentry/node",n=pe,r=X.getTracer(e,n);return this._tracer=r,r}async flush(e){return await this.traceProvider?.forceFlush(),this.getOptions().sendClientReports&&this._flushOutcomes(),super.flush(e)}async close(e){this._clientReportInterval&&clearInterval(this._clientReportInterval),this._clientReportOnExitFlushListener&&process.off("beforeExit",this._clientReportOnExitFlushListener),this._logOnExitFlushListener&&process.off("beforeExit",this._logOnExitFlushListener);let n=await super.close(e);return this.traceProvider&&await this.traceProvider.shutdown(),n}startClientReportTracking(){let e=this.getOptions();e.sendClientReports&&(this._clientReportOnExitFlushListener=()=>{this._flushOutcomes()},this._clientReportInterval=setInterval(()=>{re&&g.log("Flushing client reports based on interval."),this._flushOutcomes()},e.clientReportFlushInterval??Dme).unref(),process.on("beforeExit",this._clientReportOnExitFlushListener))}_setupIntegrations(){yy(),super._setupIntegrations()}_getTraceInfoFromScope(e){return e?eV(this,e):[void 0,void 0]}};var JV=K(cR(),1);import*as ZV from"module";function MO(){if(MV()&&!J._sentryEsmLoaderHookRegistered){J._sentryEsmLoaderHookRegistered=!0;try{let{addHookMessagePort:t}=(0,JV.createAddHookMessageChannel)();ZV.register("import-in-the-middle/hook.mjs",import.meta.url,{data:{addHookMessagePort:t,include:[]},transferList:[t]})}catch(t){g.warn("Failed to register 'import-in-the-middle' hook",t)}}}function Yh(){return[_m(),pm(),fm(),mm(),HV(),Dy(),Tm(),yH(),CH(),UV(),wV(),gV(),CV(),fV(),pV(),kV(),DV()]}function xO(t={}){return Ume(t,Yh)}function Ume(t={},e){let n=wme(t,e);n.debug===!0&&(re?g.enable():Qe(()=>{console.warn("[Sentry] Cannot initialize SDK with `debug` option using a non-debug bundle.")})),n.registerEsmLoaderHooks!==!1&&MO(),rV(),he().update(n.initialScope),n.spotlight&&!n.integrations.some(({name:s})=>s===bO)&&n.integrations.push(BV({sidecarUrl:typeof n.spotlight=="string"?n.spotlight:void 0})),Ki(n,"node-core");let o=new $h(n);return he().setClient(o),o.init(),g.log(`SDK initialized from ${jp()?"CommonJS":"ESM"}`),o.startClientReportTracking(),Bme(),jF(o),nV(o),process.env.VERCEL&&process.on("SIGTERM",async()=>{await o.flush(200)}),o}function vO(){if(!re)return;let t=qF(),e=["SentryContextManager","SentryPropagator"];Xe()&&e.push("SentrySpanProcessor");for(let n of e)t.includes(n)||g.error(`You have to set up the ${n}. Without this, the OpenTelemetry & Sentry integration will not work properly.`);t.includes("SentrySampler")||g.warn("You have to set up the SentrySampler. Without this, the OpenTelemetry & Sentry integration may still work, but sample rates set for the Sentry SDK will not be respected. If you use a custom sampler, make sure to use `wrapSamplingDecision`.")}function wme(t,e){let n=kme(t.release),r=$V(t.spotlight),o=Gme(t.tracesSampleRate),s={...t,dsn:t.dsn??process.env.SENTRY_DSN,environment:t.environment??process.env.SENTRY_ENVIRONMENT,sendClientReports:t.sendClientReports??!0,transport:t.transport??qV,stackParser:yR(t.stackParser||KV),release:n,tracesSampleRate:o,spotlight:r,debug:Uc(t.debug??process.env.SENTRY_DEBUG)},i=t.integrations,a=t.defaultIntegrations??e(s);return{...s,integrations:my({defaultIntegrations:a,integrations:i})}}function kme(t){if(t!==void 0)return t;let e=zV();if(e!==void 0)return e}function Gme(t){if(t!==void 0)return t;let e=process.env.SENTRY_TRACES_SAMPLE_RATE;if(!e)return;let n=parseFloat(e);return isFinite(n)?n:void 0}function Bme(){if(Uc(process.env.SENTRY_USE_ENVIRONMENT)!==!1){let t=process.env.SENTRY_TRACE,e=process.env.SENTRY_BAGGAGE,n=Kl(t,e);he().setPropagationContext(n)}}function Re(t,e){t.setAttribute(W,e)}function qp(t){let e=t.protocol||"",n=t.hostname||t.host||"",r=!t.port||t.port===80||t.port===443||/^(.*):(\d+)$/.test(n)?"":`:${t.port}`,o=t.path?t.path:"/";return`${e}//${n}${r}${o}`}var LO="Http",eq="@opentelemetry_sentry-patched/instrumentation-http",Wh=Lr.major===22&&Lr.minor>=12||Lr.major===23&&Lr.minor>=2||Lr.major>=24,jme=w(`${LO}.sentry`,t=>new ra(t)),Hme=w(LO,t=>{let e=new tq.HttpInstrumentation({...t,disableIncomingRequestInstrumentation:!0});try{e._diag=wn.createComponentLogger({namespace:eq}),e.instrumentationName=eq}catch{}try{let n={get:()=>!1,set:()=>{}};Object.defineProperty(e,"_httpPatched",n),Object.defineProperty(e,"_httpsPatched",n)}catch{}return e});function Fme(t,e={}){return typeof t.spans=="boolean"?t.spans:!(e.skipOpenTelemetrySetup||!Xe(e)&&Wh)}var nq=(t={})=>{let e=t.spans??!0,n=t.disableIncomingRequestSpans,r={sessions:t.trackIncomingRequestsAsSessions,sessionFlushingDelayMS:t.sessionFlushingDelayMS,ignoreRequestBody:t.ignoreIncomingRequestBody,maxRequestBodySize:t.maxIncomingRequestBodySize},o={ignoreIncomingRequests:t.ignoreIncomingRequests,ignoreStaticAssets:t.ignoreStaticAssets,ignoreStatusCodes:t.dropSpansForIncomingRequestStatusCodes,instrumentation:t.instrumentation,onSpanCreated:t.incomingRequestSpanHook},s=Op(r),i=Np(o),a=e&&!n;return{name:LO,setup(c){let l=c.getOptions();a&&Xe(l)&&i.setup(c)},setupOnce(){let c=H()?.getOptions()||{},l=Fme(t,c);s.setupOnce();let p={breadcrumbs:t.breadcrumbs,propagateTraceInOutgoingRequests:typeof t.tracePropagation=="boolean"?t.tracePropagation:Wh||!l,createSpansForOutgoingRequests:Wh,spans:t.spans,ignoreOutgoingRequests:t.ignoreOutgoingRequests,outgoingRequestHook:(d,_)=>{let f=qp(_);if(f.startsWith("data:")){let m=wc(f);d.setAttribute("http.url",m),d.setAttribute(As,m),d.updateName(`${_.method||"GET"} ${m}`)}t.instrumentation?.requestHook?.(d,_)},outgoingResponseHook:t.instrumentation?.responseHook,outgoingRequestApplyCustomAttributes:t.instrumentation?.applyCustomAttributesOnSpan};if(jme(p),l){let d=Vme(t);Hme(d)}},processEvent(c){return i.processEvent(c)}}};function Vme(t={}){return{disableOutgoingRequestInstrumentation:Wh,ignoreOutgoingRequestHook:n=>{let r=qp(n);if(!r)return!1;let o=t.ignoreOutgoingRequests;return!!o?.(r,n)},requireParentforOutgoingSpans:!1,requestHook:(n,r)=>{Re(n,"auto.http.otel.http");let o=qp(r);if(o.startsWith("data:")){let s=wc(o);n.setAttribute("http.url",s),n.setAttribute(As,s),n.updateName(`${r.method||"GET"} ${s}`)}t.instrumentation?.requestHook?.(n,r)},responseHook:(n,r)=>{t.instrumentation?.responseHook?.(n,r)},applyCustomAttributesOnSpan:(n,r,o)=>{t.instrumentation?.applyCustomAttributesOnSpan?.(n,r,o)}}}var cq=K(iq(),1);var uq="NodeFetch",Yme=w(uq,cq.UndiciInstrumentation,t=>Qme(t)),Wme=w(`${uq}.sentry`,oa,t=>t),zme=(t={})=>({name:"NodeFetch",setupOnce(){Kme(t,H()?.getOptions())&&Yme(t),Wme(t)}}),lq=zme;function aq(t,e="/"){let n=`${t}`;return n.endsWith("/")&&e.startsWith("/")?`${n}${e.slice(1)}`:!n.endsWith("/")&&!e.startsWith("/")?`${n}/${e}`:`${n}${e}`}function Kme(t,e={}){return typeof t.spans=="boolean"?t.spans:!e.skipOpenTelemetrySetup&&Xe(e)}function Qme(t={}){return{requireParentforSpans:!1,ignoreRequestHook:n=>{let r=aq(n.origin,n.path),o=t.ignoreOutgoingRequests;return!!(o&&r&&o(r))},startSpanHook:n=>{let r=aq(n.origin,n.path);if(r.startsWith("data:")){let o=wc(r);return{[W]:"auto.http.otel.node_fetch","http.url":o,[As]:o,[tr]:`${n.method||"GET"} ${o}`}}return{[W]:"auto.http.otel.node_fetch"}},requestHook:t.requestHook,responseHook:t.responseHook,headersToSpanAttributes:t.headersToSpanAttributes}}var Aq=K(gq(),1);var mt=typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__;var Rq="Express";function dhe(t){Re(t,"auto.http.otel.express");let e=Y(t).data,n=e["express.type"];n&&t.setAttribute(ee,`${n}.express`);let r=e["express.name"];typeof r=="string"&&t.updateName(r)}function _he(t,e){if(ue()===er())return mt&&g.warn("Isolation scope is still default isolation scope - skipping setting transactionName"),e;if(t.layerType==="request_handler"){let n=t.request,r=n.method?n.method.toUpperCase():"GET";ue().setTransactionName(`${r} ${t.route}`)}return e}var yq=w(Rq,()=>new Aq.ExpressInstrumentation({requestHook:t=>dhe(t),spanNameHook:(t,e)=>_he(t,e)})),fhe=()=>({name:Rq,setupOnce(){yq()}}),Iq=fhe;var Q$=K(q$(),1);import*as RN from"node:diagnostics_channel";b();var UT=K(Te(),1),_a=K(ne(),1);le();var $o;(function(t){let e="fastify.name";t.FASTIFY_NAME=e;let n="fastify.type";t.FASTIFY_TYPE=n;let r="hook.name";t.HOOK_NAME=r;let o="plugin.name";t.PLUGIN_NAME=o})($o||($o={}));var ad;(function(t){let e="middleware";t.MIDDLEWARE=e;let n="request_handler";t.REQUEST_HANDLER=n})(ad||(ad={}));var cd;(function(t){let e="middleware";t.MIDDLEWARE=e;let n="request handler";t.REQUEST_HANDLER=n})(cd||(cd={}));b();var ud=Symbol("opentelemetry.instrumentation.fastify.request_active_span");function AN(t,e,n,r={}){let o=e.startSpan(n,{attributes:r}),s=t[ud]||[];return s.push(o),Object.defineProperty(t,ud,{enumerable:!1,configurable:!0,value:s}),o}function LT(t,e){let n=t[ud]||[];n.length&&(n.forEach(r=>{e&&(r.setStatus({code:Be.ERROR,message:e.message}),r.recordException(e)),r.end()}),delete t[ud])}function Y$(t,e,n){let r,o;try{o=t(),$$(o)&&o.then(s=>e(void 0,s),s=>e(s))}catch(s){r=s}finally{if(!$$(o)&&(e(r,o),r))throw r;return o}}function $$(t){return typeof t=="object"&&t&&typeof Object.getOwnPropertyDescriptor(t,"then")?.value=="function"||!1}var pSe="0.1.0",dSe="@sentry/instrumentation-fastify-v3",W$="anonymous",_Se=new Set(["onTimeout","onRequest","preParsing","preValidation","preSerialization","preHandler","onSend","onResponse","onError"]),DT=class extends _a.InstrumentationBase{constructor(e={}){super(dSe,pSe,e)}init(){return[new _a.InstrumentationNodeModuleDefinition("fastify",[">=3.0.0 <4"],e=>this._patchConstructor(e))]}_hookOnRequest(){let e=this;return function(r,o,s){if(!e.isEnabled())return s();e._wrap(o,"send",e._patchSend());let i=r,a=(0,UT.getRPCMetadata)(P.active()),c=i.routeOptions?i.routeOptions.url:r.routerPath;c&&a?.type===UT.RPCType.HTTP&&(a.route=c);let l=r.method||"GET";ue().setTransactionName(`${l} ${c}`),s()}}_wrapHandler(e,n,r,o){let s=this;return this._diag.debug("Patching fastify route.handler function"),function(...i){if(!s.isEnabled())return r.apply(this,i);let a=r.name||e||W$,c=`${cd.MIDDLEWARE} - ${a}`,l=i[1],p=AN(l,s.tracer,c,{[$o.FASTIFY_TYPE]:ad.MIDDLEWARE,[$o.PLUGIN_NAME]:e,[$o.HOOK_NAME]:n}),d=o&&i[i.length-1];return d&&(i[i.length-1]=function(..._){LT(l),d.apply(this,_)}),P.with(X.setSpan(P.active(),p),()=>Y$(()=>r.apply(this,i),_=>{_ instanceof Error&&(p.setStatus({code:Be.ERROR,message:_.message}),p.recordException(_)),o||LT(l)}))}}_wrapAddHook(){let e=this;return this._diag.debug("Patching fastify server.addHook function"),function(n){return function(...o){let s=o[0],i=o[1],a=this.pluginName;if(!_Se.has(s))return n.apply(this,o);let c=typeof o[o.length-1]=="function"&&i.constructor.name!=="AsyncFunction";return n.apply(this,[s,e._wrapHandler(a,s,i,c)])}}}_patchConstructor(e){let n=this;function r(...o){let s=e.fastify.apply(this,o);return s.addHook("onRequest",n._hookOnRequest()),s.addHook("preHandler",n._hookPreHandler()),fSe(),n._wrap(s,"addHook",n._wrapAddHook()),s}return e.errorCodes!==void 0&&(r.errorCodes=e.errorCodes),r.fastify=r,r.default=r,r}_patchSend(){let e=this;return this._diag.debug("Patching fastify reply.send function"),function(r){return function(...s){let i=s[0];return e.isEnabled()?(0,_a.safeExecuteInTheMiddle)(()=>r.apply(this,s),a=>{!a&&i instanceof Error&&(a=i),LT(this,a)}):r.apply(this,s)}}}_hookPreHandler(){let e=this;return this._diag.debug("Patching fastify preHandler function"),function(r,o,s){if(!e.isEnabled())return s();let i=r,a=i.routeOptions?.handler||i.context?.handler,c=a?.name.startsWith("bound ")?a.name.substring(6):a?.name,l=`${cd.REQUEST_HANDLER} - ${c||this.pluginName||W$}`,p={[$o.PLUGIN_NAME]:this.pluginName,[$o.FASTIFY_TYPE]:ad.REQUEST_HANDLER,[oA]:i.routeOptions?i.routeOptions.url:r.routerPath};c&&(p[$o.FASTIFY_NAME]=c);let d=AN(o,e.tracer,l,p);z$(d);let{requestHook:_}=e.getConfig();return _&&(0,_a.safeExecuteInTheMiddle)(()=>_(d,{request:r}),f=>{f&&e._diag.error("request hook failed",f)},!0),P.with(X.setSpan(P.active(),d),()=>{s()})}}};function fSe(){let t=H();t&&t.on("spanStart",e=>{z$(e)})}function z$(t){let e=Y(t).data,n=e["fastify.type"];if(e[ee]||!n)return;t.setAttributes({[W]:"auto.http.otel.fastify",[ee]:`${n}.fastify`});let r=e["fastify.name"]||e["plugin.name"]||e["hook.name"];if(typeof r=="string"){let o=r.replace(/^fastify -> /,"").replace(/^@fastify\/otel -> /,"");t.updateName(o)}}var wT="Fastify",X$=w(`${wT}.v3`,()=>new DT);function mSe(){let t=H();if(t)return t.getIntegrationByName(wT)}function K$(t,e,n,r){let o=mSe()?.getShouldHandleError()||eY;if(r==="diagnostics-channel"&&(this.diagnosticsChannelExists=!0),this.diagnosticsChannelExists&&r==="onError-hook"){mt&&g.warn("Fastify error handler was already registered via diagnostics channel.","You can safely remove `setupFastifyErrorHandler` call and set `shouldHandleError` on the integration options.");return}o(t,e,n)&&te(t,{mechanism:{handled:!1,type:"auto.function.fastify"}})}var J$=w(`${wT}.v5`,()=>{let t=new Q$.FastifyOtelInstrumentation,e=t.plugin();return RN.subscribe("fastify.initialization",n=>{let r=n.fastify;r?.register(e).after(o=>{o?mt&&g.error("Failed to setup Fastify instrumentation",o):(TSe(),r&&ESe(r))})}),RN.subscribe("tracing:fastify.request.handler:error",n=>{let{error:r,request:o,reply:s}=n;K$.call(K$,r,o,s,"diagnostics-channel")}),t}),hSe=({shouldHandleError:t})=>{let e;return{name:wT,setupOnce(){e=t||eY,X$(),J$()},getShouldHandleError(){return e},setShouldHandleError(n){e=n}}},Z$=(t={})=>hSe(t);function eY(t,e,n){let r=n.statusCode;return r>=500||r<=299}function tY(t){let e=Y(t),n=e.description,r=e.data,o=r["fastify.type"],s=o==="hook",i=o===n?.startsWith("handler -"),a=n==="request"||o==="request-handler";if(r[ee]||!i&&!a&&!s)return;let c=s?"hook":i?"middleware":a?"request_handler":"<unknown>";t.setAttributes({[W]:"auto.http.otel.fastify",[ee]:`${c}.fastify`});let l=r["fastify.name"]||r["plugin.name"]||r["hook.name"];if(typeof l=="string"){let p=l.replace(/^fastify -> /,"").replace(/^@fastify\/otel -> /,"");t.updateName(p)}}function TSe(){let t=H();t&&t.on("spanStart",e=>{tY(e)})}function ESe(t){t.addHook("onRequest",async(e,n)=>{if(e.opentelemetry){let{span:s}=e.opentelemetry();s&&tY(s)}let r=e.routeOptions?.url,o=e.method||"GET";ue().setTransactionName(`${o} ${r}`)})}b();var RY=K(AY(),1);var yY="Graphql",IY=w(yY,RY.GraphQLInstrumentation,t=>{let e=NY(t);return{...e,responseHook(n,r){Re(n,"auto.graphql.otel.graphql"),r.errors?.length&&!Y(n).status&&n.setStatus({code:Be.ERROR});let s=Y(n).data,i=s["graphql.operation.type"],a=s["graphql.operation.name"];if(e.useOperationNameForRootSpan&&i){let c=je(n),p=Y(c).data[au]||[],d=a?`${i} ${a}`:`${i}`;Array.isArray(p)?(p.push(d),c.setAttribute(au,p)):typeof p=="string"?c.setAttribute(au,[p,d]):c.setAttribute(au,d),Y(c).data["original-description"]||c.setAttribute("original-description",Y(c).description),c.updateName(`${Y(c).data["original-description"]} (${BSe(p)})`)}}}}),GSe=(t={})=>({name:yY,setupOnce(){IY(NY(t))}}),OY=GSe;function NY(t){return{ignoreResolveSpans:!0,ignoreTrivialResolveSpans:!0,useOperationNameForRootSpan:!0,...t}}function BSe(t){if(Array.isArray(t)){let e=t.slice().sort();return e.length<=5?e.join(", "):`${e.slice(0,5).join(", ")}, +${e.length-5}`}return`${t}`}var GY=K(kY(),1);var BY="Kafka",jY=w(BY,()=>new GY.KafkaJsInstrumentation({consumerHook(t){Re(t,"auto.kafkajs.otel.consumer")},producerHook(t){Re(t,"auto.kafkajs.otel.producer")}})),HSe=()=>({name:BY,setupOnce(){jY()}}),HY=HSe;var zY=K(WY(),1);var KY="LruMemoizer",QY=w(KY,()=>new zY.LruMemoizerInstrumentation),VSe=()=>({name:KY,setupOnce(){QY()}}),XY=VSe;var iW=K(sW(),1);var aW="Mongo",cW=w(aW,()=>new iW.MongoDBInstrumentation({dbStatementSerializer:zSe,responseHook(t){Re(t,"auto.db.otel.mongo")}}));function zSe(t){let e=xN(t);return JSON.stringify(e)}function xN(t){if(Array.isArray(t))return t.map(e=>xN(e));if(KSe(t)){let e={};return Object.entries(t).map(([n,r])=>[n,xN(r)]).reduce((n,r)=>(XSe(r)&&(n[r[0]]=r[1]),n),e)}return"?"}function KSe(t){return typeof t=="object"&&t!==null&&!QSe(t)}function QSe(t){let e=!1;return typeof Buffer<"u"&&(e=Buffer.isBuffer(t)),e}function XSe(t){return Array.isArray(t)}var JSe=()=>({name:aW,setupOnce(){cW()}}),uW=JSe;var gW=K(SW(),1);var AW="Mongoose",RW=w(AW,()=>new gW.MongooseInstrumentation({responseHook(t){Re(t,"auto.db.otel.mongoose")}})),age=()=>({name:AW,setupOnce(){RW()}}),yW=age;var xW=K(MW(),1);var vW="Mysql",LW=w(vW,()=>new xW.MySQLInstrumentation({})),Tge=()=>({name:vW,setupOnce(){LW()}}),DW=Tge;var FW=K(HW(),1);var VW="Mysql2",qW=w(VW,()=>new FW.MySQL2Instrumentation({responseHook(t){Re(t,"auto.db.otel.mysql2")}})),vge=()=>({name:VW,setupOnce(){qW()}}),$W=vge;var Tz=K(ZW(),1),Ez=K(dz(),1);var Xge=["get","set","setex"],JN=["get","mget"],Jge=["set","setex"];function yd(t,e){return t.includes(e.toLowerCase())}function ZN(t){return yd(JN,t)?"cache.get":yd(Jge,t)?"cache.put":void 0}function Zge(t,e){return e.some(n=>t.startsWith(n))}function fz(t,e){try{if(e.length===0)return;let n=o=>typeof o=="string"||typeof o=="number"||Buffer.isBuffer(o)?[o.toString()]:Array.isArray(o)?_z(o.map(s=>n(s))):["<unknown>"],r=e[0];return yd(Xge,t)&&r!=null?n(r):_z(e.map(o=>n(o)))}catch{return}}function mz(t,e,n){if(!ZN(t))return!1;for(let r of e)if(Zge(r,n))return!0;return!1}function hz(t){let e=n=>{try{return Buffer.isBuffer(n)?n.byteLength:typeof n=="string"?n.length:typeof n=="number"?n.toString().length:n==null?0:JSON.stringify(n).length}catch{return}};return Array.isArray(t)?t.reduce((n,r)=>{let o=e(r);return typeof o=="number"?n!==void 0?n+o:o:n},0):e(t)}function _z(t){let e=[],n=r=>{r.forEach(o=>{Array.isArray(o)?n(o):e.push(o)})};return n(t),e}var SE="Redis",Id={},Sz=(t,e,n,r)=>{t.setAttribute(W,"auto.db.otel.redis");let o=fz(e,n),s=ZN(e);if(!o||!s||!Id.cachePrefixes||!mz(e,o,Id.cachePrefixes))return;let i=Y(t).data["net.peer.name"],a=Y(t).data["net.peer.port"];a&&i&&t.setAttributes({"network.peer.address":i,"network.peer.port":a});let c=hz(r);c&&t.setAttribute(KR,c),yd(JN,e)&&c!==void 0&&t.setAttribute(WR,c>0),t.setAttributes({[ee]:s,[zR]:o});let l=o.join(", ");t.updateName(Id.maxCacheKeyLength?hs(l,Id.maxCacheKeyLength):l)},eAe=w(`${SE}.IORedis`,()=>new Tz.IORedisInstrumentation({responseHook:Sz})),tAe=w(`${SE}.Redis`,()=>new Ez.RedisInstrumentation({responseHook:Sz})),gz=Object.assign(()=>{eAe(),tAe()},{id:SE}),nAe=(t={})=>({name:SE,setupOnce(){Id=t,gz()}}),Az=nAe;var Gz=K(kz(),1);var Bz="Postgres",jz=w(Bz,Gz.PgInstrumentation,t=>({requireParentSpan:!0,requestHook(e){Re(e,"auto.db.otel.postgres")},ignoreConnectSpans:t?.ignoreConnectSpans??!1})),TAe=t=>({name:Bz,setupOnce(){jz(t)}}),Hz=TAe;b();var ei=K(ne(),1);le();var ib="PostgresJs",Fz=[">=3.0.0 <4"],EAe=/^(SELECT|INSERT|UPDATE|DELETE|CREATE|DROP|ALTER)/i,SAe=Symbol.for("sentry.query.from.instrumented.sql"),Vz=w(ib,t=>new sb({requireParentSpan:t?.requireParentSpan??!0,requestHook:t?.requestHook})),sb=class extends ei.InstrumentationBase{constructor(e){super("sentry-postgres-js",pe,e)}init(){let e=new ei.InstrumentationNodeModuleDefinition("postgres",Fz,n=>{try{return this._patchPostgres(n)}catch(r){return mt&&g.error("Failed to patch postgres module:",r),n}},n=>n);return["src","cf/src","cjs/src"].forEach(n=>{e.files.push(new ei.InstrumentationNodeModuleFile(`postgres/${n}/query.js`,Fz,this._patchQueryPrototype.bind(this),this._unpatchQueryPrototype.bind(this)))}),e}_patchPostgres(e){let n=typeof e=="function",r=n?e:e.default;if(typeof r!="function")return mt&&g.warn("postgres module does not export a function. Skipping instrumentation."),e;let o=this,s=function(...i){let a=Reflect.construct(r,i);if(!a||typeof a!="function")return mt&&g.warn("postgres() did not return a valid instance"),a;let c=o.getConfig();return Ly(a,{requireParentSpan:c.requireParentSpan,requestHook:c.requestHook})};Object.setPrototypeOf(s,r),Object.setPrototypeOf(s.prototype,r.prototype);for(let i of Object.getOwnPropertyNames(r))if(!["length","name","prototype"].includes(i)){let a=Object.getOwnPropertyDescriptor(r,i);a&&Object.defineProperty(s,i,a)}return n?s:(Rp(e,"default",s),e)}_shouldCreateSpans(){let e=this.getConfig();return X.getSpan(P.active())!==void 0||!e.requireParentSpan}_setOperationName(e,n,r){if(r){e.setAttribute(ec,r);return}let o=n?.match(EAe);o?.[1]&&e.setAttribute(ec,o[1].toUpperCase())}_reconstructQuery(e){if(e?.length)return e.length===1?e[0]||void 0:e.reduce((n,r,o)=>o===0?r:`${n}$${o}${r}`,"")}_sanitizeSqlQuery(e){return e?e.replace(/--.*$/gm,"").replace(/\/\*[\s\S]*?\*\//g,"").replace(/;\s*$/,"").replace(/\s+/g," ").trim().replace(/\bX'[0-9A-Fa-f]*'/gi,"?").replace(/\bB'[01]*'/gi,"?").replace(/'(?:[^']|'')*'/g,"?").replace(/\b0x[0-9A-Fa-f]+/gi,"?").replace(/\b(?:TRUE|FALSE)\b/gi,"?").replace(/-?\b\d+\.?\d*[eE][+-]?\d+\b/g,"?").replace(/-?\b\d+\.\d+\b/g,"?").replace(/-?\.\d+\b/g,"?").replace(/(?<!\$)-?\b\d+\b/g,"?").replace(/\bIN\b\s*\(\s*\?(?:\s*,\s*\?)*\s*\)/gi,"IN (?)").replace(/\bIN\b\s*\(\s*\$\d+(?:\s*,\s*\$\d+)*\s*\)/gi,"IN ($?)"):"Unknown SQL Query"}_patchQueryPrototype(e){let n=this,r=e.Query.prototype.handle;return e.Query.prototype.handle=async function(...o){if(this[SAe])return r.apply(this,o);if(!n._shouldCreateSpans())return r.apply(this,o);let s=n._reconstructQuery(this.strings),i=n._sanitizeSqlQuery(s);return It({name:i||"postgresjs.query",op:"db"},a=>{Re(a,"auto.db.postgresjs"),a.setAttributes({[Mi]:"postgres",[pA]:i});let c=n.getConfig(),{requestHook:l}=c;l&&(0,ei.safeExecuteInTheMiddle)(()=>l(a,i,void 0),_=>{_&&(a.setAttribute("sentry.hook.error","requestHook failed"),mt&&g.error(`Error in requestHook for ${ib} integration:`,_))},!0);let p=this.resolve;this.resolve=new Proxy(p,{apply:(_,f,m)=>{try{n._setOperationName(a,i,m?.[0]?.command),a.end()}catch(h){mt&&g.error("Error ending span in resolve callback:",h)}return Reflect.apply(_,f,m)}});let d=this.reject;this.reject=new Proxy(d,{apply:(_,f,m)=>{try{a.setStatus({code:2,message:m?.[0]?.message||"unknown_error"}),a.setAttribute(dA,m?.[0]?.code||"unknown"),a.setAttribute(_A,m?.[0]?.name||"unknown"),n._setOperationName(a,i),a.end()}catch(h){mt&&g.error("Error ending span in reject callback:",h)}return Reflect.apply(_,f,m)}});try{return r.apply(this,o)}catch(_){throw a.setStatus({code:2,message:_ instanceof Error?_.message:"unknown_error"}),a.end(),_}})},e.Query.prototype.handle.__sentry_original__=r,e}_unpatchQueryPrototype(e){return e.Query.prototype.handle.__sentry_original__&&(e.Query.prototype.handle=e.Query.prototype.handle.__sentry_original__),e}},gAe=t=>({name:ib,setupOnce(){Vz(t)}}),qz=gAe;b();b();var WE=K(bK(),1);b();var HRe={name:"@prisma/instrumentation-contract",version:"7.6.0",description:"Shared types and utilities for Prisma instrumentation",main:"dist/index.js",module:"dist/index.mjs",types:"dist/index.d.ts",exports:{".":{require:{types:"./dist/index.d.ts",default:"./dist/index.js"},import:{types:"./dist/index.d.mts",default:"./dist/index.mjs"}}},license:"Apache-2.0",homepage:"https://www.prisma.io",repository:{type:"git",url:"https://github.com/prisma/prisma.git",directory:"packages/instrumentation-contract"},bugs:"https://github.com/prisma/prisma/issues",scripts:{dev:"DEV=true tsx helpers/build.ts",build:"tsx helpers/build.ts",prepublishOnly:"pnpm run build",test:"vitest run"},files:["dist"],sideEffects:!1,devDependencies:{"@opentelemetry/api":"1.9.0"},peerDependencies:{"@opentelemetry/api":"^1.8"}},FRe=HRe.version.split(".")[0],Mb="PRISMA_INSTRUMENTATION",xb=`V${FRe}_PRISMA_INSTRUMENTATION`,Yu=globalThis;function VRe(){let t=Yu[xb];return t?.helper?t.helper:Yu[Mb]?.helper}function qRe(t){let e={helper:t};Yu[xb]=e,Yu[Mb]=e}function $Re(){delete Yu[xb],delete Yu[Mb]}var YRe=process.env.PRISMA_SHOW_ALL_TRACES==="true",WRe="00-10-10-00";function zRe(t){switch(t){case"client":return Ne.CLIENT;case"internal":default:return Ne.INTERNAL}}var KRe=class{tracerProvider;ignoreSpanTypes;constructor({tracerProvider:t,ignoreSpanTypes:e}){this.tracerProvider=t,this.ignoreSpanTypes=e}isEnabled(){return!0}getTraceParent(t){let e=X.getSpanContext(t??P.active());return e?`00-${e.traceId}-${e.spanId}-0${e.traceFlags}`:WRe}dispatchEngineSpans(t){let e=this.tracerProvider.getTracer("prisma"),n=new Map,r=t.filter(o=>o.parentId===null);for(let o of r)MK(e,o,t,n,this.ignoreSpanTypes)}getActiveContext(){return P.active()}runInChildSpan(t,e){if(typeof t=="string"&&(t={name:t}),t.internal&&!YRe)return e();let n=this.tracerProvider.getTracer("prisma"),r=t.context??this.getActiveContext(),o=`prisma:client:${t.name}`;if(xK(o,this.ignoreSpanTypes))return e();if(t.active===!1){let s=n.startSpan(o,t,r);return CK(s,e(s,r))}return n.startActiveSpan(o,t,s=>CK(s,e(s,r)))}};function MK(t,e,n,r,o){if(xK(e.name,o))return;let s={attributes:e.attributes,kind:zRe(e.kind),startTime:e.startTime};t.startActiveSpan(e.name,s,i=>{r.set(e.id,i.spanContext().spanId),e.links&&i.addLinks(e.links.flatMap(c=>{let l=r.get(c);return l?{context:{spanId:l,traceId:i.spanContext().traceId,traceFlags:i.spanContext().traceFlags}}:[]}));let a=n.filter(c=>c.parentId===e.id);for(let c of a)MK(t,c,n,r,o);i.end(e.endTime)})}function CK(t,e){return QRe(e)?e.then(n=>(t.end(),n),n=>{throw t.end(),n}):(t.end(),e)}function QRe(t){return t!=null&&typeof t.then=="function"}function xK(t,e){return e.some(n=>typeof n=="string"?n===t:n.test(t))}var vK={name:"@prisma/instrumentation",version:"7.6.0",description:"OpenTelemetry compliant instrumentation for Prisma Client",main:"dist/index.js",module:"dist/index.mjs",types:"dist/index.d.ts",exports:{".":{require:{types:"./dist/index.d.ts",default:"./dist/index.js"},import:{types:"./dist/index.d.ts",default:"./dist/index.mjs"}}},license:"Apache-2.0",homepage:"https://www.prisma.io",repository:{type:"git",url:"https://github.com/prisma/prisma.git",directory:"packages/instrumentation"},bugs:"https://github.com/prisma/prisma/issues",devDependencies:{"@opentelemetry/api":"1.9.0","@prisma/instrumentation-contract":"workspace:*","@types/node":"~20.19.24",typescript:"5.4.5"},dependencies:{"@opentelemetry/instrumentation":"^0.207.0"},peerDependencies:{"@opentelemetry/api":"^1.8"},files:["dist"],keywords:["prisma","instrumentation","opentelemetry","otel"],scripts:{dev:"DEV=true tsx helpers/build.ts",build:"tsx helpers/build.ts",prepublishOnly:"pnpm run build",test:"vitest run"},sideEffects:!1},PK=vK.version,XRe=vK.name,JRe="@prisma/client",LK=class extends WE.InstrumentationBase{tracerProvider;constructor(t={}){super(XRe,PK,t)}setTracerProvider(t){this.tracerProvider=t}init(){return[new WE.InstrumentationNodeModuleDefinition(JRe,[PK])]}enable(){let t=this._config;qRe(new KRe({tracerProvider:this.tracerProvider??X.getTracerProvider(),ignoreSpanTypes:t.ignoreSpanTypes??[]}))}disable(){$Re()}isEnabled(){return VRe()!==void 0}};var DK="Prisma";function ZRe(t){return!!t&&typeof t=="object"&&"dispatchEngineSpans"in t}function UK(){let t=globalThis.PRISMA_INSTRUMENTATION;return t&&typeof t=="object"&&"helper"in t?t.helper:void 0}var vb=class extends LK{constructor(e){super(e?.instrumentationConfig)}enable(){super.enable();let e=UK();ZRe(e)&&(e.createEngineSpan=n=>{let r=X.getTracer("prismaV5Compatibility"),o=r._idGenerator;if(!o){Qe(()=>{console.warn("[Sentry] Could not find _idGenerator on tracer, skipping Prisma v5 compatibility - some Prisma spans may be missing!")});return}try{n.spans.forEach(s=>{let i=eye(s.kind),a=s.parent_span_id,c=s.span_id,l=s.trace_id,p=s.links?.map(_=>({context:{traceId:_.trace_id,spanId:_.span_id,traceFlags:Vt.SAMPLED}})),d=X.setSpanContext(P.active(),{traceId:l,spanId:a,traceFlags:Vt.SAMPLED});P.with(d,()=>{let _={generateTraceId:()=>l,generateSpanId:()=>c};r._idGenerator=_,r.startSpan(s.name,{kind:i,links:p,startTime:s.start_time,attributes:s.attributes}).end(s.end_time),r._idGenerator=o})})}finally{r._idGenerator=o}})}};function eye(t){switch(t){case"client":return Ne.CLIENT;case"internal":default:return Ne.INTERNAL}}var tye=w(DK,t=>new vb(t)),wK=t=>({name:DK,setupOnce(){tye(t)},setup(e){UK()&&e.on("spanStart",n=>{let r=Y(n);r.description?.startsWith("prisma:")&&n.setAttribute(W,"auto.db.otel.prisma"),r.description==="prisma:engine:db_query"&&r.data["db.query.text"]&&n.updateName(r.data["db.query.text"]),r.description==="prisma:engine:db_query"&&!r.data["db.system"]&&n.setAttribute("db.system","prisma")})}});var YK=K($K(),1);var WK="Hapi",zK=w(WK,()=>new YK.HapiInstrumentation),fye=()=>({name:WK,setupOnce(){zK()}}),KK=fye;le();var oi={HONO_TYPE:"hono.type",HONO_NAME:"hono.name"},Gd={MIDDLEWARE:"middleware",REQUEST_HANDLER:"request_handler"};b();var XE=K(ne(),1);var mye="@sentry/instrumentation-hono",hye="0.0.1",QE=class extends XE.InstrumentationBase{constructor(e={}){super(mye,hye,e)}init(){return[new XE.InstrumentationNodeModuleDefinition("hono",[">=4.0.0 <5"],e=>this._patch(e))]}_patch(e){let n=this;class r extends e.Hono{constructor(...s){super(...s),n._wrap(this,"get",n._patchHandler()),n._wrap(this,"post",n._patchHandler()),n._wrap(this,"put",n._patchHandler()),n._wrap(this,"delete",n._patchHandler()),n._wrap(this,"options",n._patchHandler()),n._wrap(this,"patch",n._patchHandler()),n._wrap(this,"all",n._patchHandler()),n._wrap(this,"on",n._patchOnHandler()),n._wrap(this,"use",n._patchMiddlewareHandler())}}try{e.Hono=r}catch{return{...e,Hono:r}}return e}_patchHandler(){let e=this;return function(n){return function(...o){if(typeof o[0]=="string"){let s=o[0];if(o.length===1)return n.apply(this,[s]);let i=o.slice(1);return n.apply(this,[s,...i.map(a=>e._wrapHandler(a))])}return n.apply(this,o.map(s=>e._wrapHandler(s)))}}}_patchOnHandler(){let e=this;return function(n){return function(...o){let s=o.slice(2);return n.apply(this,[...o.slice(0,2),...s.map(i=>e._wrapHandler(i))])}}}_patchMiddlewareHandler(){let e=this;return function(n){return function(...o){if(typeof o[0]=="string"){let s=o[0];if(o.length===1)return n.apply(this,[s]);let i=o.slice(1);return n.apply(this,[s,...i.map(a=>e._wrapHandler(a))])}return n.apply(this,o.map(s=>e._wrapHandler(s)))}}}_wrapHandler(e){let n=this;return function(r,o){if(!n.isEnabled())return e.apply(this,[r,o]);let s=r.req.path,i=n.tracer.startSpan(s);return P.with(X.setSpan(P.active(),i),()=>n._safeExecute(()=>{let a=e.apply(this,[r,o]);if(Lt(a))return a.then(c=>{let l=n._determineHandlerType(c);return i.setAttributes({[oi.HONO_TYPE]:l,[oi.HONO_NAME]:l===Gd.REQUEST_HANDLER?s:e.name||"anonymous"}),n.getConfig().responseHook?.(i),c});{let c=n._determineHandlerType(a);return i.setAttributes({[oi.HONO_TYPE]:c,[oi.HONO_NAME]:c===Gd.REQUEST_HANDLER?s:e.name||"anonymous"}),n.getConfig().responseHook?.(i),a}},()=>i.end(),a=>{n._handleError(i,a),i.end()}))}}_safeExecute(e,n,r){try{let o=e();return Lt(o)?o.then(()=>n(),s=>r(s)):n(),o}catch(o){throw r(o),o}}_determineHandlerType(e){return e===void 0?Gd.MIDDLEWARE:Gd.REQUEST_HANDLER}_handleError(e,n){n instanceof Error&&(e.setStatus({code:Be.ERROR,message:n.message}),e.recordException(n))}};var QK="Hono";function Tye(t){let e=Y(t).data,n=e[oi.HONO_TYPE];if(e[ee]||!n)return;t.setAttributes({[W]:"auto.http.otel.hono",[ee]:`${n}.hono`});let r=e[oi.HONO_NAME];if(typeof r=="string"&&t.updateName(r),ue()===er()){mt&&g.warn("Isolation scope is default isolation scope - skipping setting transactionName");return}let o=e[Co],s=e[xi];typeof o=="string"&&typeof s=="string"&&ue().setTransactionName(`${s} ${o}`)}var XK=w(QK,()=>new QE({responseHook:t=>{Tye(t)}})),Eye=()=>({name:QK,setupOnce(){XK()}}),JK=Eye;var l2=K(u2(),1);le();var p2="Koa",d2=w(p2,l2.KoaInstrumentation,(t={})=>({ignoreLayersType:t.ignoreLayersType,requestHook(e,n){Re(e,"auto.http.otel.koa");let r=Y(e).data,o=r["koa.type"];o&&e.setAttribute(ee,`${o}.koa`);let s=r["koa.name"];if(typeof s=="string"&&e.updateName(s||"< unknown >"),ue()===er()){mt&&g.warn("Isolation scope is default isolation scope - skipping setting transactionName");return}let i=r[Co],a=n.context?.request?.method?.toUpperCase()||"GET";i&&ue().setTransactionName(`${a} ${i}`)}})),bye=(t={})=>({name:p2,setupOnce(){d2(t)}}),_2=bye;var R2=K(A2(),1);var y2="Connect",I2=w(y2,()=>new R2.ConnectInstrumentation),kye=()=>({name:y2,setupOnce(){I2()}}),O2=kye;var U2=K(D2(),1);var Fye=new Set(["callProcedure","execSql","execSqlBatch","execBulkLoad","prepare","execute"]),w2="Tedious",k2=w(w2,()=>new U2.TediousInstrumentation({})),Vye=()=>{let t;return{name:w2,setupOnce(){let e=k2();t=Ip(e)},setup(e){t?.(()=>e.on("spanStart",n=>{let{description:r,data:o}=Y(n);if(!r||o["db.system"]!=="mssql")return;let s=r.split(" ")[0]||"";Fye.has(s)&&n.setAttribute(W,"auto.db.otel.tedious")}))}}},G2=Vye;var V2=K(F2(),1);var q2="GenericPool",$2=w(q2,()=>new V2.GenericPoolInstrumentation({})),$ye=()=>{let t;return{name:q2,setupOnce(){let e=$2();t=Ip(e)},setup(e){t?.(()=>e.on("spanStart",n=>{let o=Y(n).description;(o==="generic-pool.aquire"||o==="generic-pool.acquire")&&n.setAttribute(W,"auto.db.otel.generic_pool")}))}}},Y2=$ye;var n4=K(t4(),1);var r4="Amqplib",nIe={consumeEndHook:t=>{Re(t,"auto.amqplib.otel.consumer")},publishHook:t=>{Re(t,"auto.amqplib.otel.publisher")}},o4=w(r4,()=>new n4.AmqplibInstrumentation(nIe)),rIe=()=>({name:r4,setupOnce(){o4()}}),s4=rIe;var Vd="VercelAI";var fS=K(ne(),1);var oIe=[">=3.0.0 <7"],i4=["generateText","streamText","generateObject","streamObject","embed","embedMany","rerank"];function sIe(t){if(typeof t!="object"||t===null)return!1;let e=t;return"type"in e&&"error"in e&&"toolName"in e&&"toolCallId"in e&&e.type==="tool-error"&&e.error instanceof Error}function iIe(t){if(typeof t!="object"||t===null||!("content"in t))return;let e=t;Array.isArray(e.content)&&(aIe(e.content),cIe(e.content))}function aIe(t){for(let e of t){if(!sIe(e))continue;let n=Zy(e.toolCallId);n?Gn(r=>{r.setContext("trace",{trace_id:n.traceId,span_id:n.spanId}),r.setTag("vercel.ai.tool.name",e.toolName),r.setTag("vercel.ai.tool.callId",e.toolCallId),r.setLevel("error"),te(e.error,{mechanism:{type:"auto.vercelai.otel",handled:!1}})}):Gn(r=>{r.setTag("vercel.ai.tool.name",e.toolName),r.setTag("vercel.ai.tool.callId",e.toolCallId),r.setLevel("error"),te(e.error,{mechanism:{type:"auto.vercelai.otel",handled:!1}})})}}function cIe(t){for(let e of t)typeof e=="object"&&e!==null&&"toolCallId"in e&&typeof e.toolCallId=="string"&&eI(e.toolCallId)}function uIe(t,e,n,r){let o=t?.recordInputs!==void 0?t.recordInputs:e.recordInputs!==void 0?e.recordInputs:n===!0?!0:r,s=t?.recordOutputs!==void 0?t.recordOutputs:e.recordOutputs!==void 0?e.recordOutputs:n===!0?!0:r;return{recordInputs:o,recordOutputs:s}}var _S=class t extends fS.InstrumentationBase{__init(){this._isPatched=!1}__init2(){this._callbacks=[]}constructor(e={}){super("@sentry/instrumentation-vercel-ai",pe,e),t.prototype.__init.call(this),t.prototype.__init2.call(this)}init(){return new fS.InstrumentationNodeModuleDefinition("ai",oIe,this._patch.bind(this))}callWhenPatched(e){this._isPatched?e():this._callbacks.push(e)}_patch(e){this._isPatched=!0,this._callbacks.forEach(r=>r()),this._callbacks=[];let n=r=>new Proxy(r,{apply:(o,s,i)=>{let a=i[0].experimental_telemetry||{},c=a.isEnabled,l=H(),p=l?.getIntegrationByName(Vd),d=p?.options,_=p?!!l?.getOptions().sendDefaultPii:!1,{recordInputs:f,recordOutputs:m}=uIe(d,a,c,_);return i[0].experimental_telemetry={...a,isEnabled:c!==void 0?c:!0,recordInputs:f,recordOutputs:m},Mr(()=>Reflect.apply(o,s,i),h=>{h&&typeof h=="object"&&nt(h,"_sentry_active_span",nr())},()=>{},h=>{iIe(h)})}});if(Object.prototype.toString.call(e)==="[object Module]"){for(let r of i4)e[r]!=null&&(e[r]=n(e[r]));return e}else{let r=i4.reduce((o,s)=>(e[s]!=null&&(o[s]=n(e[s])),o),{});return{...e,...r}}}};var a4=w(Vd,()=>new _S({}));function lIe(t){return!!t.getIntegrationByName("Modules")?.getModules?.()?.ai}var pIe=(t={})=>{let e;return{name:Vd,options:t,setupOnce(){e=a4()},afterAllSetup(n){t.force??lIe(n)?Nm(n):e?.callWhenPatched(()=>Nm(n))}}},c4=pIe;var hS=K(ne(),1);var dIe=[">=4.0.0 <7"],mS=class extends hS.InstrumentationBase{constructor(e={}){super("@sentry/instrumentation-openai",pe,e)}init(){return new hS.InstrumentationNodeModuleDefinition("openai",dIe,this._patch.bind(this))}_patch(e){let n=e;return n=this._patchClient(n,"OpenAI"),n=this._patchClient(n,"AzureOpenAI"),n}_patchClient(e,n){let r=e[n];if(!r)return e;let o=this.getConfig(),s=function(...i){if(zi(ws))return Reflect.construct(r,i);let a=Reflect.construct(r,i);return Cm(a,o)};Object.setPrototypeOf(s,r),Object.setPrototypeOf(s.prototype,r.prototype);for(let i of Object.getOwnPropertyNames(r))if(!["length","name","prototype"].includes(i)){let a=Object.getOwnPropertyDescriptor(r,i);a&&Object.defineProperty(s,i,a)}try{e[n]=s}catch{Object.defineProperty(e,n,{value:s,writable:!0,configurable:!0,enumerable:!0})}if(e.default===r)try{e.default=s}catch{Object.defineProperty(e,"default",{value:s,writable:!0,configurable:!0,enumerable:!0})}return e}};var u4=w(ws,t=>new mS(t)),_Ie=(t={})=>({name:ws,setupOnce(){u4(t)}}),l4=_Ie;var ES=K(ne(),1);var fIe=[">=0.19.2 <1.0.0"],TS=class extends ES.InstrumentationBase{constructor(e={}){super("@sentry/instrumentation-anthropic-ai",pe,e)}init(){return new ES.InstrumentationNodeModuleDefinition("@anthropic-ai/sdk",fIe,this._patch.bind(this))}_patch(e){let n=e.Anthropic,r=this.getConfig(),o=function(...s){if(zi(ks))return Reflect.construct(n,s);let i=Reflect.construct(n,s);return Pm(i,r)};Object.setPrototypeOf(o,n),Object.setPrototypeOf(o.prototype,n.prototype);for(let s of Object.getOwnPropertyNames(n))if(!["length","name","prototype"].includes(s)){let i=Object.getOwnPropertyDescriptor(n,s);i&&Object.defineProperty(o,s,i)}try{e.Anthropic=o}catch{Object.defineProperty(e,"Anthropic",{value:o,writable:!0,configurable:!0,enumerable:!0})}if(e.default===n)try{e.default=o}catch{Object.defineProperty(e,"default",{value:o,writable:!0,configurable:!0,enumerable:!0})}return e}};var p4=w(ks,t=>new TS(t)),mIe=(t={})=>({name:ks,options:t,setupOnce(){p4(t)}}),d4=mIe;var sl=K(ne(),1);var _4=[">=0.10.0 <2"],SS=class extends sl.InstrumentationBase{constructor(e={}){super("@sentry/instrumentation-google-genai",pe,e)}init(){return new sl.InstrumentationNodeModuleDefinition("@google/genai",_4,n=>this._patch(n),n=>n,[new sl.InstrumentationNodeModuleFile("@google/genai/dist/node/index.cjs",_4,n=>this._patch(n),n=>n)])}_patch(e){let n=e.GoogleGenAI,r=this.getConfig();if(typeof n!="function")return e;let o=function(...s){if(zi(Gs))return Reflect.construct(n,s);let i=Reflect.construct(n,s);return Mm(i,r)};Object.setPrototypeOf(o,n),Object.setPrototypeOf(o.prototype,n.prototype);for(let s of Object.getOwnPropertyNames(n))if(!["length","name","prototype"].includes(s)){let i=Object.getOwnPropertyDescriptor(n,s);i&&Object.defineProperty(o,s,i)}return Rp(e,"GoogleGenAI",o),e}};var f4=w(Gs,t=>new SS(t)),hIe=(t={})=>({name:Gs,setupOnce(){f4(t)}}),m4=hIe;var _i=K(ne(),1);var gS=[">=0.1.0 <2.0.0"];function TIe(t,e){return t?Array.isArray(t)?t.includes(e)?t:[...t,e]:typeof t=="object"?[t,e]:t:[e]}function EIe(t,e,n){return new Proxy(t,{apply(r,o,s){let a=s[1];(!a||typeof a!="object"||Array.isArray(a))&&(a={},s[1]=a);let c=a.callbacks,l=TIe(c,e);return a.callbacks=l,Reflect.apply(r,o,s)}})}var AS=class extends _i.InstrumentationBase{constructor(e={}){super("@sentry/instrumentation-langchain",pe,e)}init(){let e=[],n=["@langchain/anthropic","@langchain/openai","@langchain/google-genai","@langchain/mistralai","@langchain/google-vertexai","@langchain/groq"];for(let r of n)e.push(new _i.InstrumentationNodeModuleDefinition(r,gS,this._patch.bind(this),o=>o,[new _i.InstrumentationNodeModuleFile(`${r}/dist/index.cjs`,gS,this._patch.bind(this),o=>o)]));return e.push(new _i.InstrumentationNodeModuleDefinition("langchain",gS,this._patch.bind(this),r=>r,[new _i.InstrumentationNodeModuleFile("langchain/dist/chat_models/universal.cjs",gS,this._patch.bind(this),r=>r)])),e}_patch(e){Ry([ws,ks,Gs]);let n=vm(this.getConfig());return this._patchRunnableMethods(e,n),e}_patchRunnableMethods(e,n){let r=["ChatAnthropic","ChatOpenAI","ChatGoogleGenerativeAI","ChatMistralAI","ChatVertexAI","ChatGroq","ConfigurableModel"],o=e.universal_exports??e,s=Object.values(o).find(c=>typeof c=="function"&&r.includes(c.name));if(!s)return;let i=s.prototype;if(i.__sentry_patched__)return;i.__sentry_patched__=!0;let a=["invoke","stream","batch"];for(let c of a){let l=i[c];typeof l=="function"&&(i[c]=EIe(l,n))}}};var h4=w(xm,t=>new AS(t)),SIe=(t={})=>({name:xm,setupOnce(){h4(t)}}),T4=SIe;var il=K(ne(),1);var E4=[">=0.0.0 <2.0.0"],RS=class extends il.InstrumentationBase{constructor(e={}){super("@sentry/instrumentation-langgraph",pe,e)}init(){return new il.InstrumentationNodeModuleDefinition("@langchain/langgraph",E4,this._patch.bind(this),n=>n,[new il.InstrumentationNodeModuleFile("@langchain/langgraph/dist/index.cjs",E4,this._patch.bind(this),n=>n)])}_patch(e){return e.StateGraph&&typeof e.StateGraph=="function"&&Dm(e.StateGraph.prototype,this.getConfig()),e}};var S4=w(Lm,t=>new RS(t)),gIe=(t={})=>({name:Lm,setupOnce(){S4(t)}}),g4=gIe;var C4=K(ne(),1);b();var Xo=K(ne(),1);le();import*as R4 from"node:net";function y4(t,e,n,r,o){let i=()=>{},a=o.firestoreSpanCreationHook;typeof a=="function"&&(i=p=>{(0,Xo.safeExecuteInTheMiddle)(()=>a(p),d=>{d&&wn.error(d?.message)},!0)});let c=new Xo.InstrumentationNodeModuleDefinition("@firebase/firestore",e,p=>A4(p,n,r,t,i)),l=["@firebase/firestore/dist/lite/index.node.cjs.js","@firebase/firestore/dist/lite/index.node.mjs.js","@firebase/firestore/dist/lite/index.rn.esm2017.js","@firebase/firestore/dist/lite/index.cjs.js"];for(let p of l)c.files.push(new Xo.InstrumentationNodeModuleFile(p,e,d=>A4(d,n,r,t,i),d=>I4(d,r)));return c}function A4(t,e,n,r,o){return I4(t,n),e(t,"addDoc",AIe(r,o)),e(t,"getDocs",yIe(r,o)),e(t,"setDoc",IIe(r,o)),e(t,"deleteDoc",RIe(r,o)),t}function I4(t,e){for(let n of["addDoc","getDocs","setDoc","deleteDoc"])(0,Xo.isWrapped)(t[n])&&e(t,n);return t}function AIe(t,e){return function(r){return function(o,s){let i=IS(t,"addDoc",o);return e(i),yS(i,()=>r(o,s))}}}function RIe(t,e){return function(r){return function(o){let s=IS(t,"deleteDoc",o.parent||o);return e(s),yS(s,()=>r(o))}}}function yIe(t,e){return function(r){return function(o){let s=IS(t,"getDocs",o);return e(s),yS(s,()=>r(o))}}}function IIe(t,e){return function(r){return function(o,s,i){let a=IS(t,"setDoc",o.parent||o);return e(a),yS(a,()=>typeof i<"u"?r(o,s,i):r(o,s))}}}function yS(t,e){return P.with(X.setSpan(P.active(),t),()=>(0,Xo.safeExecuteInTheMiddle)(()=>e(),n=>{n&&t.recordException(n),t.end()},!0))}function IS(t,e,n){let r=t.startSpan(`${e} ${n.path}`,{kind:Ne.CLIENT});return NIe(r,n),r.setAttribute(ec,e),r}function OIe(t){let e,n;if(typeof t.host=="string")if(t.host.startsWith("[")){if(t.host.endsWith("]"))e=t.host.replace(/^\[|\]$/g,"");else if(t.host.includes("]:")){let r=t.host.lastIndexOf(":");r!==-1&&(e=t.host.slice(1,r).replace(/^\[|\]$/g,""),n=t.host.slice(r+1))}}else if(R4.isIPv6(t.host))e=t.host;else{let r=t.host.lastIndexOf(":");r!==-1?(e=t.host.slice(0,r),n=t.host.slice(r+1)):e=t.host}return{address:e,port:n?parseInt(n,10):void 0}}function NIe(t,e){let n=e.firestore.app,r=n.options,s=(e.firestore.toJSON()||{}).settings||{},i={[uA]:e.path,[lA]:n.name,[Mi]:"firebase.firestore","firebase.firestore.type":e.type,"firebase.firestore.options.projectId":r.projectId,"firebase.firestore.options.appId":r.appId,"firebase.firestore.options.messagingSenderId":r.messagingSenderId,"firebase.firestore.options.storageBucket":r.storageBucket},{address:a,port:c}=OIe(s);a&&(i[EA]=a),c&&(i[SA]=c),t.setAttributes(i)}b();var Jo=K(ne(),1);function O4(t,e,n,r,o){let s=()=>{},i=()=>{},a=o.functions?.errorHook,c=o.functions?.requestHook,l=o.functions?.responseHook;typeof l=="function"&&(i=(_,f)=>{(0,Jo.safeExecuteInTheMiddle)(()=>l(_,f),m=>{m&&wn.error(m?.message)},!0)}),typeof c=="function"&&(s=_=>{(0,Jo.safeExecuteInTheMiddle)(()=>c(_),f=>{f&&wn.error(f?.message)},!0)});let p=new Jo.InstrumentationNodeModuleDefinition("firebase-functions",e);return[{name:"firebase-functions/lib/v2/providers/https.js",triggerType:"function"},{name:"firebase-functions/lib/v2/providers/firestore.js",triggerType:"firestore"},{name:"firebase-functions/lib/v2/providers/scheduler.js",triggerType:"scheduler"},{name:"firebase-functions/lib/v2/storage.js",triggerType:"storage"}].forEach(({name:_,triggerType:f})=>{p.files.push(new Jo.InstrumentationNodeModuleFile(_,e,m=>bIe(m,n,r,t,{requestHook:s,responseHook:i,errorHook:a},f),m=>N4(m,r)))}),p}function Sn(t,e,n){return function(o){return function(...s){let i=typeof s[0]=="function"?s[0]:s[1],a=typeof s[0]=="function"?void 0:s[0];if(!i)return o.call(this,...s);let c=async function(...l){let p=process.env.FUNCTION_TARGET||process.env.K_SERVICE||"unknown",d=t.startSpan(`firebase.function.${n}`,{kind:Ne.SERVER}),_={"faas.name":p,"faas.trigger":n,"faas.provider":"firebase"};return process.env.GCLOUD_PROJECT&&(_["cloud.project_id"]=process.env.GCLOUD_PROJECT),process.env.EVENTARC_CLOUD_EVENT_SOURCE&&(_["cloud.event_source"]=process.env.EVENTARC_CLOUD_EVENT_SOURCE),d.setAttributes(_),e?.requestHook?.(d),P.with(X.setSpan(P.active(),d),async()=>{let f,m;try{m=await i.apply(this,l)}catch(h){f=h}if(e?.responseHook?.(d,f),f&&d.recordException(f),d.end(),f)throw await e?.errorHook?.(d,f),f;return m})};return a?o.call(this,a,c):o.call(this,c)}}}function bIe(t,e,n,r,o,s){switch(N4(t,n),s){case"function":e(t,"onRequest",Sn(r,o,"http.request")),e(t,"onCall",Sn(r,o,"http.call"));break;case"firestore":e(t,"onDocumentCreated",Sn(r,o,"firestore.document.created")),e(t,"onDocumentUpdated",Sn(r,o,"firestore.document.updated")),e(t,"onDocumentDeleted",Sn(r,o,"firestore.document.deleted")),e(t,"onDocumentWritten",Sn(r,o,"firestore.document.written")),e(t,"onDocumentCreatedWithAuthContext",Sn(r,o,"firestore.document.created")),e(t,"onDocumentUpdatedWithAuthContext",Sn(r,o,"firestore.document.updated")),e(t,"onDocumentDeletedWithAuthContext",Sn(r,o,"firestore.document.deleted")),e(t,"onDocumentWrittenWithAuthContext",Sn(r,o,"firestore.document.written"));break;case"scheduler":e(t,"onSchedule",Sn(r,o,"scheduler.scheduled"));break;case"storage":e(t,"onObjectFinalized",Sn(r,o,"storage.object.finalized")),e(t,"onObjectArchived",Sn(r,o,"storage.object.archived")),e(t,"onObjectDeleted",Sn(r,o,"storage.object.deleted")),e(t,"onObjectMetadataUpdated",Sn(r,o,"storage.object.metadataUpdated"));break}return t}function N4(t,e){let n=["onSchedule","onRequest","onCall","onObjectFinalized","onObjectArchived","onObjectDeleted","onObjectMetadataUpdated","onDocumentCreated","onDocumentUpdated","onDocumentDeleted","onDocumentWritten","onDocumentCreatedWithAuthContext","onDocumentUpdatedWithAuthContext","onDocumentDeletedWithAuthContext","onDocumentWrittenWithAuthContext"];for(let r of n)(0,Jo.isWrapped)(t[r])&&e(t,r);return t}var b4={},CIe=[">=3.0.0 <5"],PIe=[">=6.0.0 <7"],OS=class extends C4.InstrumentationBase{constructor(e=b4){super("@sentry/instrumentation-firebase",pe,e)}setConfig(e={}){super.setConfig({...b4,...e})}init(){let e=[];return e.push(y4(this.tracer,CIe,this._wrap,this._unwrap,this.getConfig())),e.push(O4(this.tracer,PIe,this._wrap,this._unwrap,this.getConfig())),e}};var P4="Firebase",MIe={firestoreSpanCreationHook:t=>{Re(t,"auto.firebase.otel.firestore"),t.setAttribute(ee,"db.query")},functions:{requestHook:t=>{Re(t,"auto.firebase.otel.functions"),t.setAttribute(ee,"http.request")},errorHook:async(t,e)=>{e&&(te(e,{mechanism:{type:"auto.firebase.otel.functions",handled:!1}}),await nm(2e3))}}},M4=w(P4,()=>new OS(MIe)),xIe=()=>({name:P4,setupOnce(){M4()}}),x4=xIe;function v4(){return[Iq(),Z$(),OY(),JK(),uW(),yW(),DW(),$W(),Az(),Hz(),wK(),KK(),_2(),O2(),G2(),Y2(),HY(),s4(),XY(),T4(),g4(),c4(),l4(),d4(),m4(),qz(),x4()]}b();var NS=K(DI(),1),L4=K(iO(),1);le();var Xb=1e6;function D4(t,e={}){t.getOptions().debug&&RO();let[n,r]=vIe(t,e);t.traceProvider=n,t.asyncLocalStorageLookup=r}function vIe(t,e={}){let n=new L4.BasicTracerProvider({sampler:new Gh(t),resource:(0,NS.defaultResource)().merge((0,NS.resourceFromAttributes)({[gA]:"node",[cA]:"sentry",[AA]:pe})),forceFlushTimeoutMillis:500,spanProcessors:[new kh({timeout:LIe(t.getOptions().maxSpanWaitDuration)}),...e.spanProcessors||[]]});X.setGlobalTracerProvider(n),Ar.setGlobalPropagator(new wh);let r=new AO;return P.setGlobalContextManager(r),[n,r.getAsyncLocalStorageLookup()]}function LIe(t){if(t!=null){if(t>Xb)return mt&&g.warn(`\`maxSpanWaitDuration\` is too high, using the maximum value of ${Xb}`),Xb;if(t<=0||Number.isNaN(t)){mt&&g.warn("`maxSpanWaitDuration` must be a positive number, using default value instead.");return}return t}}function U4(){return Yh().filter(e=>e.name!=="Http"&&e.name!=="NodeFetch").concat(nq(),lq())}function w4(t){return[...U4(),...Xe(t)?v4():[]]}function Jb(t={}){return DIe(t,w4)}function DIe(t={},e){Ki(t,"node");let n=xO({...t,defaultIntegrations:t.defaultIntegrations??e(t)});return n&&!t.skipOpenTelemetrySetup&&(D4(n,{spanProcessors:t.openTelemetrySpanProcessors}),vO()),n}var UIe="prod",G4="0.1.12",wIe=`@tanagram/lore/${G4}`;function xt(){return UIe}function bS(){return G4}function B4(){return wIe}Jb({dsn:"https://583674b382128b1b30b9fa1f0581daab@o4509017064472576.ingest.us.sentry.io/4511344717529088",environment:xt(),release:bS(),sendDefaultPii:!0});tm("service_name","lore-cli");import{realpathSync as hxe}from"node:fs";import{fileURLToPath as Txe,pathToFileURL as w9}from"node:url";var kIe=/\d/,GIe=["-","_","/","."];function BIe(t=""){if(!kIe.test(t))return t!==t.toLowerCase()}function j4(t,e){let n=e??GIe,r=[];if(!t||typeof t!="string")return r;let o="",s,i;for(let a of t){let c=n.includes(a);if(c===!0){r.push(o),o="",s=void 0;continue}let l=BIe(a);if(i===!1){if(s===!1&&l===!0){r.push(o),o=a,s=l;continue}if(s===!0&&l===!1&&o.length>1){let p=o.at(-1);r.push(o.slice(0,Math.max(0,o.length-1))),o=p+a,s=l;continue}}o+=a,s=l,i=c}return r.push(o),r}function jIe(t){return t?t[0].toUpperCase()+t.slice(1):""}function HIe(t){return t?t[0].toLowerCase()+t.slice(1):""}function FIe(t,e){return t?(Array.isArray(t)?t:j4(t)).map(n=>jIe(e?.normalize?n.toLowerCase():n)).join(""):""}function qd(t,e){return HIe(FIe(t||"",e))}function CS(t,e){return t?(Array.isArray(t)?t:j4(t)).map(n=>n.toLowerCase()).join(e??"-"):""}function H4(t){return CS(t||"","_")}import{parseArgs as VIe}from"node:util";function LS(t){return Array.isArray(t)?t:t===void 0?[]:[t]}function Zb(t,e=""){let n=[];for(let r of t)for(let[o,s]of r.entries())n[o]=Math.max(n[o]||0,s.length);return t.map(r=>r.map((o,s)=>e+o[s===0?"padStart":"padEnd"](n[s])).join(" ")).join(`
|
|
38
|
+
`);let{connect:l,buffered:p}=await c;if(e.emit("proxyConnect",l),this.emit("proxyConnect",l,e),l.statusCode===200){if(e.once("socket",Ame),n.secureEndpoint){Fp("Upgrading socket connection to TLS");let _=n.servername||n.host;return PO.connect({...VV(n,"host","path","port"),socket:o,servername:Vo.isIP(_)?void 0:_})}return o}o.destroy();let d=new Vo.Socket({writable:!1});return d.readable=!0,e.once("socket",_=>{Fp("Replaying proxy buffer for failed request"),_.push(p),_.push(null)}),d}};Vp.__initStatic();function Ame(t){t.resume()}function VV(t,...e){let n={},r;for(r in t)e.includes(r)||(n[r]=t[r]);return n}var Nme=1024*32;function bme(t){return new Ime({read(){this.push(t),this.push(null)}})}function qV(t){let e;try{e=new URL(t.url)}catch{return Qe(()=>{console.warn("[@sentry/node]: Invalid dsn or tunnel option, will not send any events. The tunnel option must be a full URL when used.")}),up(t,()=>Promise.resolve({}))}let n=e.protocol==="https:",r=Cme(e,t.proxy||(n?process.env.https_proxy:void 0)||process.env.http_proxy),o=n?yme:Rme,s=t.keepAlive===void 0?!1:t.keepAlive,i=r?new Vp(r):new o.Agent({keepAlive:s,maxSockets:30,timeout:2e3}),a=Pme(t,t.httpModule??o,i);return up(t,a)}function Cme(t,e){let{no_proxy:n}=process.env;if(!n?.split(",").some(o=>t.host.endsWith(o)||t.hostname.endsWith(o)))return e}function Pme(t,e,n){let{hostname:r,pathname:o,port:s,protocol:i,search:a}=new URL(t.url);return function(l){return new Promise((p,d)=>{xc(()=>{let _=bme(l.body),f={...t.headers};l.body.length>Nme&&(f["content-encoding"]="gzip",_=_.pipe(Ome()));let m=r.startsWith("["),h=e.request({method:"POST",agent:n,headers:f,hostname:m?r.slice(1,-1):r,path:`${o}${a}`,port:s,protocol:i,ca:t.caCerts},T=>{T.on("data",()=>{}),T.on("end",()=>{}),T.setEncoding("utf8");let S=T.headers["retry-after"]??null,R=T.headers["x-sentry-rate-limits"]??null;p({statusCode:T.statusCode,headers:{"retry-after":S,"x-sentry-rate-limits":Array.isArray(R)?R[0]||null:R}})});h.on("error",d),_.pipe(h)})})}}function $V(t){if(t===!1)return!1;if(typeof t=="string")return t;let e=Uc(process.env.SENTRY_SPOTLIGHT,{strict:!0}),n=e===null&&process.env.SENTRY_SPOTLIGHT?process.env.SENTRY_SPOTLIGHT:void 0;return t===!0?n??!0:e??n}import{posix as Mme,sep as xme}from"node:path";function YV(t){return t.replace(/^[A-Z]:/,"").replace(/\\/g,"/")}function WV(t=process.argv[1]?My(process.argv[1]):process.cwd(),e=xme==="\\"){let n=e?YV(t):t;return r=>{if(!r)return;let o=e?YV(r):r,{dir:s,base:i,ext:a}=Mme.parse(o);(a===".js"||a===".mjs"||a===".cjs")&&(i=i.slice(0,a.length*-1));let c=decodeURIComponent(i);s||(s=".");let l=s.lastIndexOf("/node_modules");if(l>-1)return`${s.slice(l+14).replace(/\//g,".")}:${c}`;if(s.startsWith(n)){let p=s.slice(n.length+1).replace(/\//g,".");return p?`${p}:${c}`:c}return c}}function zV(t){if(process.env.SENTRY_RELEASE)return process.env.SENTRY_RELEASE;if(J.SENTRY_RELEASE?.id)return J.SENTRY_RELEASE.id;let e=process.env.GITHUB_SHA||process.env.CI_MERGE_REQUEST_SOURCE_BRANCH_SHA||process.env.CI_BUILD_REF||process.env.CI_COMMIT_SHA||process.env.BITBUCKET_COMMIT,n=process.env.APPVEYOR_PULL_REQUEST_HEAD_COMMIT||process.env.APPVEYOR_REPO_COMMIT||process.env.CODEBUILD_RESOLVED_SOURCE_VERSION||process.env.AWS_COMMIT_ID||process.env.BUILD_SOURCEVERSION||process.env.GIT_CLONE_COMMIT_HASH||process.env.BUDDY_EXECUTION_REVISION||process.env.BUILDKITE_COMMIT||process.env.CIRCLE_SHA1||process.env.CIRRUS_CHANGE_IN_REPO||process.env.CF_REVISION||process.env.CM_COMMIT||process.env.CF_PAGES_COMMIT_SHA||process.env.DRONE_COMMIT_SHA||process.env.FC_GIT_COMMIT_SHA||process.env.HEROKU_TEST_RUN_COMMIT_VERSION||process.env.HEROKU_BUILD_COMMIT||process.env.HEROKU_SLUG_COMMIT||process.env.RAILWAY_GIT_COMMIT_SHA||process.env.RENDER_GIT_COMMIT||process.env.SEMAPHORE_GIT_SHA||process.env.TRAVIS_PULL_REQUEST_SHA||process.env.VERCEL_GIT_COMMIT_SHA||process.env.VERCEL_GITHUB_COMMIT_SHA||process.env.VERCEL_GITLAB_COMMIT_SHA||process.env.VERCEL_BITBUCKET_COMMIT_SHA||process.env.ZEIT_GITHUB_COMMIT_SHA||process.env.ZEIT_GITLAB_COMMIT_SHA||process.env.ZEIT_BITBUCKET_COMMIT_SHA,r=process.env.CI_COMMIT_ID||process.env.SOURCE_COMMIT||process.env.SOURCE_VERSION||process.env.GIT_COMMIT||process.env.COMMIT_REF||process.env.BUILD_VCS_NUMBER||process.env.CI_COMMIT_SHA;return e||n||r||t}var KV=xf(cI(WV()));b();var XV=K(ne(),1);import*as QV from"node:os";import{threadId as vme,isMainThread as Lme}from"worker_threads";var Dme=6e4,$h=class extends lp{constructor(e){let n=e.includeServerName===!1?void 0:e.serverName||global.process.env.SENTRY_NAME||QV.hostname(),r={...e,platform:"node",runtime:e.runtime||{name:"node",version:global.process.version},serverName:n};e.openTelemetryInstrumentations&&(0,XV.registerInstrumentations)({instrumentations:e.openTelemetryInstrumentations}),Ki(r,"node"),g.log(`Initializing Sentry: process: ${process.pid}, thread: ${Lme?"main":`worker-${vme}`}.`),super(r),this.getOptions().enableLogs&&(this._logOnExitFlushListener=()=>{Lc(this)},n&&this.on("beforeCaptureLog",o=>{o.attributes={...o.attributes,"server.address":n}}),process.on("beforeExit",this._logOnExitFlushListener))}get tracer(){if(this._tracer)return this._tracer;let e="@sentry/node",n=pe,r=X.getTracer(e,n);return this._tracer=r,r}async flush(e){return await this.traceProvider?.forceFlush(),this.getOptions().sendClientReports&&this._flushOutcomes(),super.flush(e)}async close(e){this._clientReportInterval&&clearInterval(this._clientReportInterval),this._clientReportOnExitFlushListener&&process.off("beforeExit",this._clientReportOnExitFlushListener),this._logOnExitFlushListener&&process.off("beforeExit",this._logOnExitFlushListener);let n=await super.close(e);return this.traceProvider&&await this.traceProvider.shutdown(),n}startClientReportTracking(){let e=this.getOptions();e.sendClientReports&&(this._clientReportOnExitFlushListener=()=>{this._flushOutcomes()},this._clientReportInterval=setInterval(()=>{re&&g.log("Flushing client reports based on interval."),this._flushOutcomes()},e.clientReportFlushInterval??Dme).unref(),process.on("beforeExit",this._clientReportOnExitFlushListener))}_setupIntegrations(){yy(),super._setupIntegrations()}_getTraceInfoFromScope(e){return e?eV(this,e):[void 0,void 0]}};var JV=K(cR(),1);import*as ZV from"module";function MO(){if(MV()&&!J._sentryEsmLoaderHookRegistered){J._sentryEsmLoaderHookRegistered=!0;try{let{addHookMessagePort:t}=(0,JV.createAddHookMessageChannel)();ZV.register("import-in-the-middle/hook.mjs",import.meta.url,{data:{addHookMessagePort:t,include:[]},transferList:[t]})}catch(t){g.warn("Failed to register 'import-in-the-middle' hook",t)}}}function Yh(){return[_m(),pm(),fm(),mm(),HV(),Dy(),Tm(),yH(),CH(),UV(),wV(),gV(),CV(),fV(),pV(),kV(),DV()]}function xO(t={}){return Ume(t,Yh)}function Ume(t={},e){let n=wme(t,e);n.debug===!0&&(re?g.enable():Qe(()=>{console.warn("[Sentry] Cannot initialize SDK with `debug` option using a non-debug bundle.")})),n.registerEsmLoaderHooks!==!1&&MO(),rV(),he().update(n.initialScope),n.spotlight&&!n.integrations.some(({name:s})=>s===bO)&&n.integrations.push(BV({sidecarUrl:typeof n.spotlight=="string"?n.spotlight:void 0})),Ki(n,"node-core");let o=new $h(n);return he().setClient(o),o.init(),g.log(`SDK initialized from ${jp()?"CommonJS":"ESM"}`),o.startClientReportTracking(),Bme(),jF(o),nV(o),process.env.VERCEL&&process.on("SIGTERM",async()=>{await o.flush(200)}),o}function vO(){if(!re)return;let t=qF(),e=["SentryContextManager","SentryPropagator"];Xe()&&e.push("SentrySpanProcessor");for(let n of e)t.includes(n)||g.error(`You have to set up the ${n}. Without this, the OpenTelemetry & Sentry integration will not work properly.`);t.includes("SentrySampler")||g.warn("You have to set up the SentrySampler. Without this, the OpenTelemetry & Sentry integration may still work, but sample rates set for the Sentry SDK will not be respected. If you use a custom sampler, make sure to use `wrapSamplingDecision`.")}function wme(t,e){let n=kme(t.release),r=$V(t.spotlight),o=Gme(t.tracesSampleRate),s={...t,dsn:t.dsn??process.env.SENTRY_DSN,environment:t.environment??process.env.SENTRY_ENVIRONMENT,sendClientReports:t.sendClientReports??!0,transport:t.transport??qV,stackParser:yR(t.stackParser||KV),release:n,tracesSampleRate:o,spotlight:r,debug:Uc(t.debug??process.env.SENTRY_DEBUG)},i=t.integrations,a=t.defaultIntegrations??e(s);return{...s,integrations:my({defaultIntegrations:a,integrations:i})}}function kme(t){if(t!==void 0)return t;let e=zV();if(e!==void 0)return e}function Gme(t){if(t!==void 0)return t;let e=process.env.SENTRY_TRACES_SAMPLE_RATE;if(!e)return;let n=parseFloat(e);return isFinite(n)?n:void 0}function Bme(){if(Uc(process.env.SENTRY_USE_ENVIRONMENT)!==!1){let t=process.env.SENTRY_TRACE,e=process.env.SENTRY_BAGGAGE,n=Kl(t,e);he().setPropagationContext(n)}}function Re(t,e){t.setAttribute(W,e)}function qp(t){let e=t.protocol||"",n=t.hostname||t.host||"",r=!t.port||t.port===80||t.port===443||/^(.*):(\d+)$/.test(n)?"":`:${t.port}`,o=t.path?t.path:"/";return`${e}//${n}${r}${o}`}var LO="Http",eq="@opentelemetry_sentry-patched/instrumentation-http",Wh=Lr.major===22&&Lr.minor>=12||Lr.major===23&&Lr.minor>=2||Lr.major>=24,jme=w(`${LO}.sentry`,t=>new ra(t)),Hme=w(LO,t=>{let e=new tq.HttpInstrumentation({...t,disableIncomingRequestInstrumentation:!0});try{e._diag=wn.createComponentLogger({namespace:eq}),e.instrumentationName=eq}catch{}try{let n={get:()=>!1,set:()=>{}};Object.defineProperty(e,"_httpPatched",n),Object.defineProperty(e,"_httpsPatched",n)}catch{}return e});function Fme(t,e={}){return typeof t.spans=="boolean"?t.spans:!(e.skipOpenTelemetrySetup||!Xe(e)&&Wh)}var nq=(t={})=>{let e=t.spans??!0,n=t.disableIncomingRequestSpans,r={sessions:t.trackIncomingRequestsAsSessions,sessionFlushingDelayMS:t.sessionFlushingDelayMS,ignoreRequestBody:t.ignoreIncomingRequestBody,maxRequestBodySize:t.maxIncomingRequestBodySize},o={ignoreIncomingRequests:t.ignoreIncomingRequests,ignoreStaticAssets:t.ignoreStaticAssets,ignoreStatusCodes:t.dropSpansForIncomingRequestStatusCodes,instrumentation:t.instrumentation,onSpanCreated:t.incomingRequestSpanHook},s=Op(r),i=Np(o),a=e&&!n;return{name:LO,setup(c){let l=c.getOptions();a&&Xe(l)&&i.setup(c)},setupOnce(){let c=H()?.getOptions()||{},l=Fme(t,c);s.setupOnce();let p={breadcrumbs:t.breadcrumbs,propagateTraceInOutgoingRequests:typeof t.tracePropagation=="boolean"?t.tracePropagation:Wh||!l,createSpansForOutgoingRequests:Wh,spans:t.spans,ignoreOutgoingRequests:t.ignoreOutgoingRequests,outgoingRequestHook:(d,_)=>{let f=qp(_);if(f.startsWith("data:")){let m=wc(f);d.setAttribute("http.url",m),d.setAttribute(As,m),d.updateName(`${_.method||"GET"} ${m}`)}t.instrumentation?.requestHook?.(d,_)},outgoingResponseHook:t.instrumentation?.responseHook,outgoingRequestApplyCustomAttributes:t.instrumentation?.applyCustomAttributesOnSpan};if(jme(p),l){let d=Vme(t);Hme(d)}},processEvent(c){return i.processEvent(c)}}};function Vme(t={}){return{disableOutgoingRequestInstrumentation:Wh,ignoreOutgoingRequestHook:n=>{let r=qp(n);if(!r)return!1;let o=t.ignoreOutgoingRequests;return!!o?.(r,n)},requireParentforOutgoingSpans:!1,requestHook:(n,r)=>{Re(n,"auto.http.otel.http");let o=qp(r);if(o.startsWith("data:")){let s=wc(o);n.setAttribute("http.url",s),n.setAttribute(As,s),n.updateName(`${r.method||"GET"} ${s}`)}t.instrumentation?.requestHook?.(n,r)},responseHook:(n,r)=>{t.instrumentation?.responseHook?.(n,r)},applyCustomAttributesOnSpan:(n,r,o)=>{t.instrumentation?.applyCustomAttributesOnSpan?.(n,r,o)}}}var cq=K(iq(),1);var uq="NodeFetch",Yme=w(uq,cq.UndiciInstrumentation,t=>Qme(t)),Wme=w(`${uq}.sentry`,oa,t=>t),zme=(t={})=>({name:"NodeFetch",setupOnce(){Kme(t,H()?.getOptions())&&Yme(t),Wme(t)}}),lq=zme;function aq(t,e="/"){let n=`${t}`;return n.endsWith("/")&&e.startsWith("/")?`${n}${e.slice(1)}`:!n.endsWith("/")&&!e.startsWith("/")?`${n}/${e}`:`${n}${e}`}function Kme(t,e={}){return typeof t.spans=="boolean"?t.spans:!e.skipOpenTelemetrySetup&&Xe(e)}function Qme(t={}){return{requireParentforSpans:!1,ignoreRequestHook:n=>{let r=aq(n.origin,n.path),o=t.ignoreOutgoingRequests;return!!(o&&r&&o(r))},startSpanHook:n=>{let r=aq(n.origin,n.path);if(r.startsWith("data:")){let o=wc(r);return{[W]:"auto.http.otel.node_fetch","http.url":o,[As]:o,[tr]:`${n.method||"GET"} ${o}`}}return{[W]:"auto.http.otel.node_fetch"}},requestHook:t.requestHook,responseHook:t.responseHook,headersToSpanAttributes:t.headersToSpanAttributes}}var Aq=K(gq(),1);var mt=typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__;var Rq="Express";function dhe(t){Re(t,"auto.http.otel.express");let e=Y(t).data,n=e["express.type"];n&&t.setAttribute(ee,`${n}.express`);let r=e["express.name"];typeof r=="string"&&t.updateName(r)}function _he(t,e){if(ue()===er())return mt&&g.warn("Isolation scope is still default isolation scope - skipping setting transactionName"),e;if(t.layerType==="request_handler"){let n=t.request,r=n.method?n.method.toUpperCase():"GET";ue().setTransactionName(`${r} ${t.route}`)}return e}var yq=w(Rq,()=>new Aq.ExpressInstrumentation({requestHook:t=>dhe(t),spanNameHook:(t,e)=>_he(t,e)})),fhe=()=>({name:Rq,setupOnce(){yq()}}),Iq=fhe;var Q$=K(q$(),1);import*as RN from"node:diagnostics_channel";b();var UT=K(Te(),1),_a=K(ne(),1);le();var $o;(function(t){let e="fastify.name";t.FASTIFY_NAME=e;let n="fastify.type";t.FASTIFY_TYPE=n;let r="hook.name";t.HOOK_NAME=r;let o="plugin.name";t.PLUGIN_NAME=o})($o||($o={}));var ad;(function(t){let e="middleware";t.MIDDLEWARE=e;let n="request_handler";t.REQUEST_HANDLER=n})(ad||(ad={}));var cd;(function(t){let e="middleware";t.MIDDLEWARE=e;let n="request handler";t.REQUEST_HANDLER=n})(cd||(cd={}));b();var ud=Symbol("opentelemetry.instrumentation.fastify.request_active_span");function AN(t,e,n,r={}){let o=e.startSpan(n,{attributes:r}),s=t[ud]||[];return s.push(o),Object.defineProperty(t,ud,{enumerable:!1,configurable:!0,value:s}),o}function LT(t,e){let n=t[ud]||[];n.length&&(n.forEach(r=>{e&&(r.setStatus({code:Be.ERROR,message:e.message}),r.recordException(e)),r.end()}),delete t[ud])}function Y$(t,e,n){let r,o;try{o=t(),$$(o)&&o.then(s=>e(void 0,s),s=>e(s))}catch(s){r=s}finally{if(!$$(o)&&(e(r,o),r))throw r;return o}}function $$(t){return typeof t=="object"&&t&&typeof Object.getOwnPropertyDescriptor(t,"then")?.value=="function"||!1}var pSe="0.1.0",dSe="@sentry/instrumentation-fastify-v3",W$="anonymous",_Se=new Set(["onTimeout","onRequest","preParsing","preValidation","preSerialization","preHandler","onSend","onResponse","onError"]),DT=class extends _a.InstrumentationBase{constructor(e={}){super(dSe,pSe,e)}init(){return[new _a.InstrumentationNodeModuleDefinition("fastify",[">=3.0.0 <4"],e=>this._patchConstructor(e))]}_hookOnRequest(){let e=this;return function(r,o,s){if(!e.isEnabled())return s();e._wrap(o,"send",e._patchSend());let i=r,a=(0,UT.getRPCMetadata)(P.active()),c=i.routeOptions?i.routeOptions.url:r.routerPath;c&&a?.type===UT.RPCType.HTTP&&(a.route=c);let l=r.method||"GET";ue().setTransactionName(`${l} ${c}`),s()}}_wrapHandler(e,n,r,o){let s=this;return this._diag.debug("Patching fastify route.handler function"),function(...i){if(!s.isEnabled())return r.apply(this,i);let a=r.name||e||W$,c=`${cd.MIDDLEWARE} - ${a}`,l=i[1],p=AN(l,s.tracer,c,{[$o.FASTIFY_TYPE]:ad.MIDDLEWARE,[$o.PLUGIN_NAME]:e,[$o.HOOK_NAME]:n}),d=o&&i[i.length-1];return d&&(i[i.length-1]=function(..._){LT(l),d.apply(this,_)}),P.with(X.setSpan(P.active(),p),()=>Y$(()=>r.apply(this,i),_=>{_ instanceof Error&&(p.setStatus({code:Be.ERROR,message:_.message}),p.recordException(_)),o||LT(l)}))}}_wrapAddHook(){let e=this;return this._diag.debug("Patching fastify server.addHook function"),function(n){return function(...o){let s=o[0],i=o[1],a=this.pluginName;if(!_Se.has(s))return n.apply(this,o);let c=typeof o[o.length-1]=="function"&&i.constructor.name!=="AsyncFunction";return n.apply(this,[s,e._wrapHandler(a,s,i,c)])}}}_patchConstructor(e){let n=this;function r(...o){let s=e.fastify.apply(this,o);return s.addHook("onRequest",n._hookOnRequest()),s.addHook("preHandler",n._hookPreHandler()),fSe(),n._wrap(s,"addHook",n._wrapAddHook()),s}return e.errorCodes!==void 0&&(r.errorCodes=e.errorCodes),r.fastify=r,r.default=r,r}_patchSend(){let e=this;return this._diag.debug("Patching fastify reply.send function"),function(r){return function(...s){let i=s[0];return e.isEnabled()?(0,_a.safeExecuteInTheMiddle)(()=>r.apply(this,s),a=>{!a&&i instanceof Error&&(a=i),LT(this,a)}):r.apply(this,s)}}}_hookPreHandler(){let e=this;return this._diag.debug("Patching fastify preHandler function"),function(r,o,s){if(!e.isEnabled())return s();let i=r,a=i.routeOptions?.handler||i.context?.handler,c=a?.name.startsWith("bound ")?a.name.substring(6):a?.name,l=`${cd.REQUEST_HANDLER} - ${c||this.pluginName||W$}`,p={[$o.PLUGIN_NAME]:this.pluginName,[$o.FASTIFY_TYPE]:ad.REQUEST_HANDLER,[oA]:i.routeOptions?i.routeOptions.url:r.routerPath};c&&(p[$o.FASTIFY_NAME]=c);let d=AN(o,e.tracer,l,p);z$(d);let{requestHook:_}=e.getConfig();return _&&(0,_a.safeExecuteInTheMiddle)(()=>_(d,{request:r}),f=>{f&&e._diag.error("request hook failed",f)},!0),P.with(X.setSpan(P.active(),d),()=>{s()})}}};function fSe(){let t=H();t&&t.on("spanStart",e=>{z$(e)})}function z$(t){let e=Y(t).data,n=e["fastify.type"];if(e[ee]||!n)return;t.setAttributes({[W]:"auto.http.otel.fastify",[ee]:`${n}.fastify`});let r=e["fastify.name"]||e["plugin.name"]||e["hook.name"];if(typeof r=="string"){let o=r.replace(/^fastify -> /,"").replace(/^@fastify\/otel -> /,"");t.updateName(o)}}var wT="Fastify",X$=w(`${wT}.v3`,()=>new DT);function mSe(){let t=H();if(t)return t.getIntegrationByName(wT)}function K$(t,e,n,r){let o=mSe()?.getShouldHandleError()||eY;if(r==="diagnostics-channel"&&(this.diagnosticsChannelExists=!0),this.diagnosticsChannelExists&&r==="onError-hook"){mt&&g.warn("Fastify error handler was already registered via diagnostics channel.","You can safely remove `setupFastifyErrorHandler` call and set `shouldHandleError` on the integration options.");return}o(t,e,n)&&te(t,{mechanism:{handled:!1,type:"auto.function.fastify"}})}var J$=w(`${wT}.v5`,()=>{let t=new Q$.FastifyOtelInstrumentation,e=t.plugin();return RN.subscribe("fastify.initialization",n=>{let r=n.fastify;r?.register(e).after(o=>{o?mt&&g.error("Failed to setup Fastify instrumentation",o):(TSe(),r&&ESe(r))})}),RN.subscribe("tracing:fastify.request.handler:error",n=>{let{error:r,request:o,reply:s}=n;K$.call(K$,r,o,s,"diagnostics-channel")}),t}),hSe=({shouldHandleError:t})=>{let e;return{name:wT,setupOnce(){e=t||eY,X$(),J$()},getShouldHandleError(){return e},setShouldHandleError(n){e=n}}},Z$=(t={})=>hSe(t);function eY(t,e,n){let r=n.statusCode;return r>=500||r<=299}function tY(t){let e=Y(t),n=e.description,r=e.data,o=r["fastify.type"],s=o==="hook",i=o===n?.startsWith("handler -"),a=n==="request"||o==="request-handler";if(r[ee]||!i&&!a&&!s)return;let c=s?"hook":i?"middleware":a?"request_handler":"<unknown>";t.setAttributes({[W]:"auto.http.otel.fastify",[ee]:`${c}.fastify`});let l=r["fastify.name"]||r["plugin.name"]||r["hook.name"];if(typeof l=="string"){let p=l.replace(/^fastify -> /,"").replace(/^@fastify\/otel -> /,"");t.updateName(p)}}function TSe(){let t=H();t&&t.on("spanStart",e=>{tY(e)})}function ESe(t){t.addHook("onRequest",async(e,n)=>{if(e.opentelemetry){let{span:s}=e.opentelemetry();s&&tY(s)}let r=e.routeOptions?.url,o=e.method||"GET";ue().setTransactionName(`${o} ${r}`)})}b();var RY=K(AY(),1);var yY="Graphql",IY=w(yY,RY.GraphQLInstrumentation,t=>{let e=NY(t);return{...e,responseHook(n,r){Re(n,"auto.graphql.otel.graphql"),r.errors?.length&&!Y(n).status&&n.setStatus({code:Be.ERROR});let s=Y(n).data,i=s["graphql.operation.type"],a=s["graphql.operation.name"];if(e.useOperationNameForRootSpan&&i){let c=je(n),p=Y(c).data[au]||[],d=a?`${i} ${a}`:`${i}`;Array.isArray(p)?(p.push(d),c.setAttribute(au,p)):typeof p=="string"?c.setAttribute(au,[p,d]):c.setAttribute(au,d),Y(c).data["original-description"]||c.setAttribute("original-description",Y(c).description),c.updateName(`${Y(c).data["original-description"]} (${BSe(p)})`)}}}}),GSe=(t={})=>({name:yY,setupOnce(){IY(NY(t))}}),OY=GSe;function NY(t){return{ignoreResolveSpans:!0,ignoreTrivialResolveSpans:!0,useOperationNameForRootSpan:!0,...t}}function BSe(t){if(Array.isArray(t)){let e=t.slice().sort();return e.length<=5?e.join(", "):`${e.slice(0,5).join(", ")}, +${e.length-5}`}return`${t}`}var GY=K(kY(),1);var BY="Kafka",jY=w(BY,()=>new GY.KafkaJsInstrumentation({consumerHook(t){Re(t,"auto.kafkajs.otel.consumer")},producerHook(t){Re(t,"auto.kafkajs.otel.producer")}})),HSe=()=>({name:BY,setupOnce(){jY()}}),HY=HSe;var zY=K(WY(),1);var KY="LruMemoizer",QY=w(KY,()=>new zY.LruMemoizerInstrumentation),VSe=()=>({name:KY,setupOnce(){QY()}}),XY=VSe;var iW=K(sW(),1);var aW="Mongo",cW=w(aW,()=>new iW.MongoDBInstrumentation({dbStatementSerializer:zSe,responseHook(t){Re(t,"auto.db.otel.mongo")}}));function zSe(t){let e=xN(t);return JSON.stringify(e)}function xN(t){if(Array.isArray(t))return t.map(e=>xN(e));if(KSe(t)){let e={};return Object.entries(t).map(([n,r])=>[n,xN(r)]).reduce((n,r)=>(XSe(r)&&(n[r[0]]=r[1]),n),e)}return"?"}function KSe(t){return typeof t=="object"&&t!==null&&!QSe(t)}function QSe(t){let e=!1;return typeof Buffer<"u"&&(e=Buffer.isBuffer(t)),e}function XSe(t){return Array.isArray(t)}var JSe=()=>({name:aW,setupOnce(){cW()}}),uW=JSe;var gW=K(SW(),1);var AW="Mongoose",RW=w(AW,()=>new gW.MongooseInstrumentation({responseHook(t){Re(t,"auto.db.otel.mongoose")}})),age=()=>({name:AW,setupOnce(){RW()}}),yW=age;var xW=K(MW(),1);var vW="Mysql",LW=w(vW,()=>new xW.MySQLInstrumentation({})),Tge=()=>({name:vW,setupOnce(){LW()}}),DW=Tge;var FW=K(HW(),1);var VW="Mysql2",qW=w(VW,()=>new FW.MySQL2Instrumentation({responseHook(t){Re(t,"auto.db.otel.mysql2")}})),vge=()=>({name:VW,setupOnce(){qW()}}),$W=vge;var Tz=K(ZW(),1),Ez=K(dz(),1);var Xge=["get","set","setex"],JN=["get","mget"],Jge=["set","setex"];function yd(t,e){return t.includes(e.toLowerCase())}function ZN(t){return yd(JN,t)?"cache.get":yd(Jge,t)?"cache.put":void 0}function Zge(t,e){return e.some(n=>t.startsWith(n))}function fz(t,e){try{if(e.length===0)return;let n=o=>typeof o=="string"||typeof o=="number"||Buffer.isBuffer(o)?[o.toString()]:Array.isArray(o)?_z(o.map(s=>n(s))):["<unknown>"],r=e[0];return yd(Xge,t)&&r!=null?n(r):_z(e.map(o=>n(o)))}catch{return}}function mz(t,e,n){if(!ZN(t))return!1;for(let r of e)if(Zge(r,n))return!0;return!1}function hz(t){let e=n=>{try{return Buffer.isBuffer(n)?n.byteLength:typeof n=="string"?n.length:typeof n=="number"?n.toString().length:n==null?0:JSON.stringify(n).length}catch{return}};return Array.isArray(t)?t.reduce((n,r)=>{let o=e(r);return typeof o=="number"?n!==void 0?n+o:o:n},0):e(t)}function _z(t){let e=[],n=r=>{r.forEach(o=>{Array.isArray(o)?n(o):e.push(o)})};return n(t),e}var SE="Redis",Id={},Sz=(t,e,n,r)=>{t.setAttribute(W,"auto.db.otel.redis");let o=fz(e,n),s=ZN(e);if(!o||!s||!Id.cachePrefixes||!mz(e,o,Id.cachePrefixes))return;let i=Y(t).data["net.peer.name"],a=Y(t).data["net.peer.port"];a&&i&&t.setAttributes({"network.peer.address":i,"network.peer.port":a});let c=hz(r);c&&t.setAttribute(KR,c),yd(JN,e)&&c!==void 0&&t.setAttribute(WR,c>0),t.setAttributes({[ee]:s,[zR]:o});let l=o.join(", ");t.updateName(Id.maxCacheKeyLength?hs(l,Id.maxCacheKeyLength):l)},eAe=w(`${SE}.IORedis`,()=>new Tz.IORedisInstrumentation({responseHook:Sz})),tAe=w(`${SE}.Redis`,()=>new Ez.RedisInstrumentation({responseHook:Sz})),gz=Object.assign(()=>{eAe(),tAe()},{id:SE}),nAe=(t={})=>({name:SE,setupOnce(){Id=t,gz()}}),Az=nAe;var Gz=K(kz(),1);var Bz="Postgres",jz=w(Bz,Gz.PgInstrumentation,t=>({requireParentSpan:!0,requestHook(e){Re(e,"auto.db.otel.postgres")},ignoreConnectSpans:t?.ignoreConnectSpans??!1})),TAe=t=>({name:Bz,setupOnce(){jz(t)}}),Hz=TAe;b();var ei=K(ne(),1);le();var ib="PostgresJs",Fz=[">=3.0.0 <4"],EAe=/^(SELECT|INSERT|UPDATE|DELETE|CREATE|DROP|ALTER)/i,SAe=Symbol.for("sentry.query.from.instrumented.sql"),Vz=w(ib,t=>new sb({requireParentSpan:t?.requireParentSpan??!0,requestHook:t?.requestHook})),sb=class extends ei.InstrumentationBase{constructor(e){super("sentry-postgres-js",pe,e)}init(){let e=new ei.InstrumentationNodeModuleDefinition("postgres",Fz,n=>{try{return this._patchPostgres(n)}catch(r){return mt&&g.error("Failed to patch postgres module:",r),n}},n=>n);return["src","cf/src","cjs/src"].forEach(n=>{e.files.push(new ei.InstrumentationNodeModuleFile(`postgres/${n}/query.js`,Fz,this._patchQueryPrototype.bind(this),this._unpatchQueryPrototype.bind(this)))}),e}_patchPostgres(e){let n=typeof e=="function",r=n?e:e.default;if(typeof r!="function")return mt&&g.warn("postgres module does not export a function. Skipping instrumentation."),e;let o=this,s=function(...i){let a=Reflect.construct(r,i);if(!a||typeof a!="function")return mt&&g.warn("postgres() did not return a valid instance"),a;let c=o.getConfig();return Ly(a,{requireParentSpan:c.requireParentSpan,requestHook:c.requestHook})};Object.setPrototypeOf(s,r),Object.setPrototypeOf(s.prototype,r.prototype);for(let i of Object.getOwnPropertyNames(r))if(!["length","name","prototype"].includes(i)){let a=Object.getOwnPropertyDescriptor(r,i);a&&Object.defineProperty(s,i,a)}return n?s:(Rp(e,"default",s),e)}_shouldCreateSpans(){let e=this.getConfig();return X.getSpan(P.active())!==void 0||!e.requireParentSpan}_setOperationName(e,n,r){if(r){e.setAttribute(ec,r);return}let o=n?.match(EAe);o?.[1]&&e.setAttribute(ec,o[1].toUpperCase())}_reconstructQuery(e){if(e?.length)return e.length===1?e[0]||void 0:e.reduce((n,r,o)=>o===0?r:`${n}$${o}${r}`,"")}_sanitizeSqlQuery(e){return e?e.replace(/--.*$/gm,"").replace(/\/\*[\s\S]*?\*\//g,"").replace(/;\s*$/,"").replace(/\s+/g," ").trim().replace(/\bX'[0-9A-Fa-f]*'/gi,"?").replace(/\bB'[01]*'/gi,"?").replace(/'(?:[^']|'')*'/g,"?").replace(/\b0x[0-9A-Fa-f]+/gi,"?").replace(/\b(?:TRUE|FALSE)\b/gi,"?").replace(/-?\b\d+\.?\d*[eE][+-]?\d+\b/g,"?").replace(/-?\b\d+\.\d+\b/g,"?").replace(/-?\.\d+\b/g,"?").replace(/(?<!\$)-?\b\d+\b/g,"?").replace(/\bIN\b\s*\(\s*\?(?:\s*,\s*\?)*\s*\)/gi,"IN (?)").replace(/\bIN\b\s*\(\s*\$\d+(?:\s*,\s*\$\d+)*\s*\)/gi,"IN ($?)"):"Unknown SQL Query"}_patchQueryPrototype(e){let n=this,r=e.Query.prototype.handle;return e.Query.prototype.handle=async function(...o){if(this[SAe])return r.apply(this,o);if(!n._shouldCreateSpans())return r.apply(this,o);let s=n._reconstructQuery(this.strings),i=n._sanitizeSqlQuery(s);return It({name:i||"postgresjs.query",op:"db"},a=>{Re(a,"auto.db.postgresjs"),a.setAttributes({[Mi]:"postgres",[pA]:i});let c=n.getConfig(),{requestHook:l}=c;l&&(0,ei.safeExecuteInTheMiddle)(()=>l(a,i,void 0),_=>{_&&(a.setAttribute("sentry.hook.error","requestHook failed"),mt&&g.error(`Error in requestHook for ${ib} integration:`,_))},!0);let p=this.resolve;this.resolve=new Proxy(p,{apply:(_,f,m)=>{try{n._setOperationName(a,i,m?.[0]?.command),a.end()}catch(h){mt&&g.error("Error ending span in resolve callback:",h)}return Reflect.apply(_,f,m)}});let d=this.reject;this.reject=new Proxy(d,{apply:(_,f,m)=>{try{a.setStatus({code:2,message:m?.[0]?.message||"unknown_error"}),a.setAttribute(dA,m?.[0]?.code||"unknown"),a.setAttribute(_A,m?.[0]?.name||"unknown"),n._setOperationName(a,i),a.end()}catch(h){mt&&g.error("Error ending span in reject callback:",h)}return Reflect.apply(_,f,m)}});try{return r.apply(this,o)}catch(_){throw a.setStatus({code:2,message:_ instanceof Error?_.message:"unknown_error"}),a.end(),_}})},e.Query.prototype.handle.__sentry_original__=r,e}_unpatchQueryPrototype(e){return e.Query.prototype.handle.__sentry_original__&&(e.Query.prototype.handle=e.Query.prototype.handle.__sentry_original__),e}},gAe=t=>({name:ib,setupOnce(){Vz(t)}}),qz=gAe;b();b();var WE=K(bK(),1);b();var HRe={name:"@prisma/instrumentation-contract",version:"7.6.0",description:"Shared types and utilities for Prisma instrumentation",main:"dist/index.js",module:"dist/index.mjs",types:"dist/index.d.ts",exports:{".":{require:{types:"./dist/index.d.ts",default:"./dist/index.js"},import:{types:"./dist/index.d.mts",default:"./dist/index.mjs"}}},license:"Apache-2.0",homepage:"https://www.prisma.io",repository:{type:"git",url:"https://github.com/prisma/prisma.git",directory:"packages/instrumentation-contract"},bugs:"https://github.com/prisma/prisma/issues",scripts:{dev:"DEV=true tsx helpers/build.ts",build:"tsx helpers/build.ts",prepublishOnly:"pnpm run build",test:"vitest run"},files:["dist"],sideEffects:!1,devDependencies:{"@opentelemetry/api":"1.9.0"},peerDependencies:{"@opentelemetry/api":"^1.8"}},FRe=HRe.version.split(".")[0],Mb="PRISMA_INSTRUMENTATION",xb=`V${FRe}_PRISMA_INSTRUMENTATION`,Yu=globalThis;function VRe(){let t=Yu[xb];return t?.helper?t.helper:Yu[Mb]?.helper}function qRe(t){let e={helper:t};Yu[xb]=e,Yu[Mb]=e}function $Re(){delete Yu[xb],delete Yu[Mb]}var YRe=process.env.PRISMA_SHOW_ALL_TRACES==="true",WRe="00-10-10-00";function zRe(t){switch(t){case"client":return Ne.CLIENT;case"internal":default:return Ne.INTERNAL}}var KRe=class{tracerProvider;ignoreSpanTypes;constructor({tracerProvider:t,ignoreSpanTypes:e}){this.tracerProvider=t,this.ignoreSpanTypes=e}isEnabled(){return!0}getTraceParent(t){let e=X.getSpanContext(t??P.active());return e?`00-${e.traceId}-${e.spanId}-0${e.traceFlags}`:WRe}dispatchEngineSpans(t){let e=this.tracerProvider.getTracer("prisma"),n=new Map,r=t.filter(o=>o.parentId===null);for(let o of r)MK(e,o,t,n,this.ignoreSpanTypes)}getActiveContext(){return P.active()}runInChildSpan(t,e){if(typeof t=="string"&&(t={name:t}),t.internal&&!YRe)return e();let n=this.tracerProvider.getTracer("prisma"),r=t.context??this.getActiveContext(),o=`prisma:client:${t.name}`;if(xK(o,this.ignoreSpanTypes))return e();if(t.active===!1){let s=n.startSpan(o,t,r);return CK(s,e(s,r))}return n.startActiveSpan(o,t,s=>CK(s,e(s,r)))}};function MK(t,e,n,r,o){if(xK(e.name,o))return;let s={attributes:e.attributes,kind:zRe(e.kind),startTime:e.startTime};t.startActiveSpan(e.name,s,i=>{r.set(e.id,i.spanContext().spanId),e.links&&i.addLinks(e.links.flatMap(c=>{let l=r.get(c);return l?{context:{spanId:l,traceId:i.spanContext().traceId,traceFlags:i.spanContext().traceFlags}}:[]}));let a=n.filter(c=>c.parentId===e.id);for(let c of a)MK(t,c,n,r,o);i.end(e.endTime)})}function CK(t,e){return QRe(e)?e.then(n=>(t.end(),n),n=>{throw t.end(),n}):(t.end(),e)}function QRe(t){return t!=null&&typeof t.then=="function"}function xK(t,e){return e.some(n=>typeof n=="string"?n===t:n.test(t))}var vK={name:"@prisma/instrumentation",version:"7.6.0",description:"OpenTelemetry compliant instrumentation for Prisma Client",main:"dist/index.js",module:"dist/index.mjs",types:"dist/index.d.ts",exports:{".":{require:{types:"./dist/index.d.ts",default:"./dist/index.js"},import:{types:"./dist/index.d.ts",default:"./dist/index.mjs"}}},license:"Apache-2.0",homepage:"https://www.prisma.io",repository:{type:"git",url:"https://github.com/prisma/prisma.git",directory:"packages/instrumentation"},bugs:"https://github.com/prisma/prisma/issues",devDependencies:{"@opentelemetry/api":"1.9.0","@prisma/instrumentation-contract":"workspace:*","@types/node":"~20.19.24",typescript:"5.4.5"},dependencies:{"@opentelemetry/instrumentation":"^0.207.0"},peerDependencies:{"@opentelemetry/api":"^1.8"},files:["dist"],keywords:["prisma","instrumentation","opentelemetry","otel"],scripts:{dev:"DEV=true tsx helpers/build.ts",build:"tsx helpers/build.ts",prepublishOnly:"pnpm run build",test:"vitest run"},sideEffects:!1},PK=vK.version,XRe=vK.name,JRe="@prisma/client",LK=class extends WE.InstrumentationBase{tracerProvider;constructor(t={}){super(XRe,PK,t)}setTracerProvider(t){this.tracerProvider=t}init(){return[new WE.InstrumentationNodeModuleDefinition(JRe,[PK])]}enable(){let t=this._config;qRe(new KRe({tracerProvider:this.tracerProvider??X.getTracerProvider(),ignoreSpanTypes:t.ignoreSpanTypes??[]}))}disable(){$Re()}isEnabled(){return VRe()!==void 0}};var DK="Prisma";function ZRe(t){return!!t&&typeof t=="object"&&"dispatchEngineSpans"in t}function UK(){let t=globalThis.PRISMA_INSTRUMENTATION;return t&&typeof t=="object"&&"helper"in t?t.helper:void 0}var vb=class extends LK{constructor(e){super(e?.instrumentationConfig)}enable(){super.enable();let e=UK();ZRe(e)&&(e.createEngineSpan=n=>{let r=X.getTracer("prismaV5Compatibility"),o=r._idGenerator;if(!o){Qe(()=>{console.warn("[Sentry] Could not find _idGenerator on tracer, skipping Prisma v5 compatibility - some Prisma spans may be missing!")});return}try{n.spans.forEach(s=>{let i=eye(s.kind),a=s.parent_span_id,c=s.span_id,l=s.trace_id,p=s.links?.map(_=>({context:{traceId:_.trace_id,spanId:_.span_id,traceFlags:Vt.SAMPLED}})),d=X.setSpanContext(P.active(),{traceId:l,spanId:a,traceFlags:Vt.SAMPLED});P.with(d,()=>{let _={generateTraceId:()=>l,generateSpanId:()=>c};r._idGenerator=_,r.startSpan(s.name,{kind:i,links:p,startTime:s.start_time,attributes:s.attributes}).end(s.end_time),r._idGenerator=o})})}finally{r._idGenerator=o}})}};function eye(t){switch(t){case"client":return Ne.CLIENT;case"internal":default:return Ne.INTERNAL}}var tye=w(DK,t=>new vb(t)),wK=t=>({name:DK,setupOnce(){tye(t)},setup(e){UK()&&e.on("spanStart",n=>{let r=Y(n);r.description?.startsWith("prisma:")&&n.setAttribute(W,"auto.db.otel.prisma"),r.description==="prisma:engine:db_query"&&r.data["db.query.text"]&&n.updateName(r.data["db.query.text"]),r.description==="prisma:engine:db_query"&&!r.data["db.system"]&&n.setAttribute("db.system","prisma")})}});var YK=K($K(),1);var WK="Hapi",zK=w(WK,()=>new YK.HapiInstrumentation),fye=()=>({name:WK,setupOnce(){zK()}}),KK=fye;le();var oi={HONO_TYPE:"hono.type",HONO_NAME:"hono.name"},Gd={MIDDLEWARE:"middleware",REQUEST_HANDLER:"request_handler"};b();var XE=K(ne(),1);var mye="@sentry/instrumentation-hono",hye="0.0.1",QE=class extends XE.InstrumentationBase{constructor(e={}){super(mye,hye,e)}init(){return[new XE.InstrumentationNodeModuleDefinition("hono",[">=4.0.0 <5"],e=>this._patch(e))]}_patch(e){let n=this;class r extends e.Hono{constructor(...s){super(...s),n._wrap(this,"get",n._patchHandler()),n._wrap(this,"post",n._patchHandler()),n._wrap(this,"put",n._patchHandler()),n._wrap(this,"delete",n._patchHandler()),n._wrap(this,"options",n._patchHandler()),n._wrap(this,"patch",n._patchHandler()),n._wrap(this,"all",n._patchHandler()),n._wrap(this,"on",n._patchOnHandler()),n._wrap(this,"use",n._patchMiddlewareHandler())}}try{e.Hono=r}catch{return{...e,Hono:r}}return e}_patchHandler(){let e=this;return function(n){return function(...o){if(typeof o[0]=="string"){let s=o[0];if(o.length===1)return n.apply(this,[s]);let i=o.slice(1);return n.apply(this,[s,...i.map(a=>e._wrapHandler(a))])}return n.apply(this,o.map(s=>e._wrapHandler(s)))}}}_patchOnHandler(){let e=this;return function(n){return function(...o){let s=o.slice(2);return n.apply(this,[...o.slice(0,2),...s.map(i=>e._wrapHandler(i))])}}}_patchMiddlewareHandler(){let e=this;return function(n){return function(...o){if(typeof o[0]=="string"){let s=o[0];if(o.length===1)return n.apply(this,[s]);let i=o.slice(1);return n.apply(this,[s,...i.map(a=>e._wrapHandler(a))])}return n.apply(this,o.map(s=>e._wrapHandler(s)))}}}_wrapHandler(e){let n=this;return function(r,o){if(!n.isEnabled())return e.apply(this,[r,o]);let s=r.req.path,i=n.tracer.startSpan(s);return P.with(X.setSpan(P.active(),i),()=>n._safeExecute(()=>{let a=e.apply(this,[r,o]);if(Lt(a))return a.then(c=>{let l=n._determineHandlerType(c);return i.setAttributes({[oi.HONO_TYPE]:l,[oi.HONO_NAME]:l===Gd.REQUEST_HANDLER?s:e.name||"anonymous"}),n.getConfig().responseHook?.(i),c});{let c=n._determineHandlerType(a);return i.setAttributes({[oi.HONO_TYPE]:c,[oi.HONO_NAME]:c===Gd.REQUEST_HANDLER?s:e.name||"anonymous"}),n.getConfig().responseHook?.(i),a}},()=>i.end(),a=>{n._handleError(i,a),i.end()}))}}_safeExecute(e,n,r){try{let o=e();return Lt(o)?o.then(()=>n(),s=>r(s)):n(),o}catch(o){throw r(o),o}}_determineHandlerType(e){return e===void 0?Gd.MIDDLEWARE:Gd.REQUEST_HANDLER}_handleError(e,n){n instanceof Error&&(e.setStatus({code:Be.ERROR,message:n.message}),e.recordException(n))}};var QK="Hono";function Tye(t){let e=Y(t).data,n=e[oi.HONO_TYPE];if(e[ee]||!n)return;t.setAttributes({[W]:"auto.http.otel.hono",[ee]:`${n}.hono`});let r=e[oi.HONO_NAME];if(typeof r=="string"&&t.updateName(r),ue()===er()){mt&&g.warn("Isolation scope is default isolation scope - skipping setting transactionName");return}let o=e[Co],s=e[xi];typeof o=="string"&&typeof s=="string"&&ue().setTransactionName(`${s} ${o}`)}var XK=w(QK,()=>new QE({responseHook:t=>{Tye(t)}})),Eye=()=>({name:QK,setupOnce(){XK()}}),JK=Eye;var l2=K(u2(),1);le();var p2="Koa",d2=w(p2,l2.KoaInstrumentation,(t={})=>({ignoreLayersType:t.ignoreLayersType,requestHook(e,n){Re(e,"auto.http.otel.koa");let r=Y(e).data,o=r["koa.type"];o&&e.setAttribute(ee,`${o}.koa`);let s=r["koa.name"];if(typeof s=="string"&&e.updateName(s||"< unknown >"),ue()===er()){mt&&g.warn("Isolation scope is default isolation scope - skipping setting transactionName");return}let i=r[Co],a=n.context?.request?.method?.toUpperCase()||"GET";i&&ue().setTransactionName(`${a} ${i}`)}})),bye=(t={})=>({name:p2,setupOnce(){d2(t)}}),_2=bye;var R2=K(A2(),1);var y2="Connect",I2=w(y2,()=>new R2.ConnectInstrumentation),kye=()=>({name:y2,setupOnce(){I2()}}),O2=kye;var U2=K(D2(),1);var Fye=new Set(["callProcedure","execSql","execSqlBatch","execBulkLoad","prepare","execute"]),w2="Tedious",k2=w(w2,()=>new U2.TediousInstrumentation({})),Vye=()=>{let t;return{name:w2,setupOnce(){let e=k2();t=Ip(e)},setup(e){t?.(()=>e.on("spanStart",n=>{let{description:r,data:o}=Y(n);if(!r||o["db.system"]!=="mssql")return;let s=r.split(" ")[0]||"";Fye.has(s)&&n.setAttribute(W,"auto.db.otel.tedious")}))}}},G2=Vye;var V2=K(F2(),1);var q2="GenericPool",$2=w(q2,()=>new V2.GenericPoolInstrumentation({})),$ye=()=>{let t;return{name:q2,setupOnce(){let e=$2();t=Ip(e)},setup(e){t?.(()=>e.on("spanStart",n=>{let o=Y(n).description;(o==="generic-pool.aquire"||o==="generic-pool.acquire")&&n.setAttribute(W,"auto.db.otel.generic_pool")}))}}},Y2=$ye;var n4=K(t4(),1);var r4="Amqplib",nIe={consumeEndHook:t=>{Re(t,"auto.amqplib.otel.consumer")},publishHook:t=>{Re(t,"auto.amqplib.otel.publisher")}},o4=w(r4,()=>new n4.AmqplibInstrumentation(nIe)),rIe=()=>({name:r4,setupOnce(){o4()}}),s4=rIe;var Vd="VercelAI";var fS=K(ne(),1);var oIe=[">=3.0.0 <7"],i4=["generateText","streamText","generateObject","streamObject","embed","embedMany","rerank"];function sIe(t){if(typeof t!="object"||t===null)return!1;let e=t;return"type"in e&&"error"in e&&"toolName"in e&&"toolCallId"in e&&e.type==="tool-error"&&e.error instanceof Error}function iIe(t){if(typeof t!="object"||t===null||!("content"in t))return;let e=t;Array.isArray(e.content)&&(aIe(e.content),cIe(e.content))}function aIe(t){for(let e of t){if(!sIe(e))continue;let n=Zy(e.toolCallId);n?Gn(r=>{r.setContext("trace",{trace_id:n.traceId,span_id:n.spanId}),r.setTag("vercel.ai.tool.name",e.toolName),r.setTag("vercel.ai.tool.callId",e.toolCallId),r.setLevel("error"),te(e.error,{mechanism:{type:"auto.vercelai.otel",handled:!1}})}):Gn(r=>{r.setTag("vercel.ai.tool.name",e.toolName),r.setTag("vercel.ai.tool.callId",e.toolCallId),r.setLevel("error"),te(e.error,{mechanism:{type:"auto.vercelai.otel",handled:!1}})})}}function cIe(t){for(let e of t)typeof e=="object"&&e!==null&&"toolCallId"in e&&typeof e.toolCallId=="string"&&eI(e.toolCallId)}function uIe(t,e,n,r){let o=t?.recordInputs!==void 0?t.recordInputs:e.recordInputs!==void 0?e.recordInputs:n===!0?!0:r,s=t?.recordOutputs!==void 0?t.recordOutputs:e.recordOutputs!==void 0?e.recordOutputs:n===!0?!0:r;return{recordInputs:o,recordOutputs:s}}var _S=class t extends fS.InstrumentationBase{__init(){this._isPatched=!1}__init2(){this._callbacks=[]}constructor(e={}){super("@sentry/instrumentation-vercel-ai",pe,e),t.prototype.__init.call(this),t.prototype.__init2.call(this)}init(){return new fS.InstrumentationNodeModuleDefinition("ai",oIe,this._patch.bind(this))}callWhenPatched(e){this._isPatched?e():this._callbacks.push(e)}_patch(e){this._isPatched=!0,this._callbacks.forEach(r=>r()),this._callbacks=[];let n=r=>new Proxy(r,{apply:(o,s,i)=>{let a=i[0].experimental_telemetry||{},c=a.isEnabled,l=H(),p=l?.getIntegrationByName(Vd),d=p?.options,_=p?!!l?.getOptions().sendDefaultPii:!1,{recordInputs:f,recordOutputs:m}=uIe(d,a,c,_);return i[0].experimental_telemetry={...a,isEnabled:c!==void 0?c:!0,recordInputs:f,recordOutputs:m},Mr(()=>Reflect.apply(o,s,i),h=>{h&&typeof h=="object"&&nt(h,"_sentry_active_span",nr())},()=>{},h=>{iIe(h)})}});if(Object.prototype.toString.call(e)==="[object Module]"){for(let r of i4)e[r]!=null&&(e[r]=n(e[r]));return e}else{let r=i4.reduce((o,s)=>(e[s]!=null&&(o[s]=n(e[s])),o),{});return{...e,...r}}}};var a4=w(Vd,()=>new _S({}));function lIe(t){return!!t.getIntegrationByName("Modules")?.getModules?.()?.ai}var pIe=(t={})=>{let e;return{name:Vd,options:t,setupOnce(){e=a4()},afterAllSetup(n){t.force??lIe(n)?Nm(n):e?.callWhenPatched(()=>Nm(n))}}},c4=pIe;var hS=K(ne(),1);var dIe=[">=4.0.0 <7"],mS=class extends hS.InstrumentationBase{constructor(e={}){super("@sentry/instrumentation-openai",pe,e)}init(){return new hS.InstrumentationNodeModuleDefinition("openai",dIe,this._patch.bind(this))}_patch(e){let n=e;return n=this._patchClient(n,"OpenAI"),n=this._patchClient(n,"AzureOpenAI"),n}_patchClient(e,n){let r=e[n];if(!r)return e;let o=this.getConfig(),s=function(...i){if(zi(ws))return Reflect.construct(r,i);let a=Reflect.construct(r,i);return Cm(a,o)};Object.setPrototypeOf(s,r),Object.setPrototypeOf(s.prototype,r.prototype);for(let i of Object.getOwnPropertyNames(r))if(!["length","name","prototype"].includes(i)){let a=Object.getOwnPropertyDescriptor(r,i);a&&Object.defineProperty(s,i,a)}try{e[n]=s}catch{Object.defineProperty(e,n,{value:s,writable:!0,configurable:!0,enumerable:!0})}if(e.default===r)try{e.default=s}catch{Object.defineProperty(e,"default",{value:s,writable:!0,configurable:!0,enumerable:!0})}return e}};var u4=w(ws,t=>new mS(t)),_Ie=(t={})=>({name:ws,setupOnce(){u4(t)}}),l4=_Ie;var ES=K(ne(),1);var fIe=[">=0.19.2 <1.0.0"],TS=class extends ES.InstrumentationBase{constructor(e={}){super("@sentry/instrumentation-anthropic-ai",pe,e)}init(){return new ES.InstrumentationNodeModuleDefinition("@anthropic-ai/sdk",fIe,this._patch.bind(this))}_patch(e){let n=e.Anthropic,r=this.getConfig(),o=function(...s){if(zi(ks))return Reflect.construct(n,s);let i=Reflect.construct(n,s);return Pm(i,r)};Object.setPrototypeOf(o,n),Object.setPrototypeOf(o.prototype,n.prototype);for(let s of Object.getOwnPropertyNames(n))if(!["length","name","prototype"].includes(s)){let i=Object.getOwnPropertyDescriptor(n,s);i&&Object.defineProperty(o,s,i)}try{e.Anthropic=o}catch{Object.defineProperty(e,"Anthropic",{value:o,writable:!0,configurable:!0,enumerable:!0})}if(e.default===n)try{e.default=o}catch{Object.defineProperty(e,"default",{value:o,writable:!0,configurable:!0,enumerable:!0})}return e}};var p4=w(ks,t=>new TS(t)),mIe=(t={})=>({name:ks,options:t,setupOnce(){p4(t)}}),d4=mIe;var sl=K(ne(),1);var _4=[">=0.10.0 <2"],SS=class extends sl.InstrumentationBase{constructor(e={}){super("@sentry/instrumentation-google-genai",pe,e)}init(){return new sl.InstrumentationNodeModuleDefinition("@google/genai",_4,n=>this._patch(n),n=>n,[new sl.InstrumentationNodeModuleFile("@google/genai/dist/node/index.cjs",_4,n=>this._patch(n),n=>n)])}_patch(e){let n=e.GoogleGenAI,r=this.getConfig();if(typeof n!="function")return e;let o=function(...s){if(zi(Gs))return Reflect.construct(n,s);let i=Reflect.construct(n,s);return Mm(i,r)};Object.setPrototypeOf(o,n),Object.setPrototypeOf(o.prototype,n.prototype);for(let s of Object.getOwnPropertyNames(n))if(!["length","name","prototype"].includes(s)){let i=Object.getOwnPropertyDescriptor(n,s);i&&Object.defineProperty(o,s,i)}return Rp(e,"GoogleGenAI",o),e}};var f4=w(Gs,t=>new SS(t)),hIe=(t={})=>({name:Gs,setupOnce(){f4(t)}}),m4=hIe;var _i=K(ne(),1);var gS=[">=0.1.0 <2.0.0"];function TIe(t,e){return t?Array.isArray(t)?t.includes(e)?t:[...t,e]:typeof t=="object"?[t,e]:t:[e]}function EIe(t,e,n){return new Proxy(t,{apply(r,o,s){let a=s[1];(!a||typeof a!="object"||Array.isArray(a))&&(a={},s[1]=a);let c=a.callbacks,l=TIe(c,e);return a.callbacks=l,Reflect.apply(r,o,s)}})}var AS=class extends _i.InstrumentationBase{constructor(e={}){super("@sentry/instrumentation-langchain",pe,e)}init(){let e=[],n=["@langchain/anthropic","@langchain/openai","@langchain/google-genai","@langchain/mistralai","@langchain/google-vertexai","@langchain/groq"];for(let r of n)e.push(new _i.InstrumentationNodeModuleDefinition(r,gS,this._patch.bind(this),o=>o,[new _i.InstrumentationNodeModuleFile(`${r}/dist/index.cjs`,gS,this._patch.bind(this),o=>o)]));return e.push(new _i.InstrumentationNodeModuleDefinition("langchain",gS,this._patch.bind(this),r=>r,[new _i.InstrumentationNodeModuleFile("langchain/dist/chat_models/universal.cjs",gS,this._patch.bind(this),r=>r)])),e}_patch(e){Ry([ws,ks,Gs]);let n=vm(this.getConfig());return this._patchRunnableMethods(e,n),e}_patchRunnableMethods(e,n){let r=["ChatAnthropic","ChatOpenAI","ChatGoogleGenerativeAI","ChatMistralAI","ChatVertexAI","ChatGroq","ConfigurableModel"],o=e.universal_exports??e,s=Object.values(o).find(c=>typeof c=="function"&&r.includes(c.name));if(!s)return;let i=s.prototype;if(i.__sentry_patched__)return;i.__sentry_patched__=!0;let a=["invoke","stream","batch"];for(let c of a){let l=i[c];typeof l=="function"&&(i[c]=EIe(l,n))}}};var h4=w(xm,t=>new AS(t)),SIe=(t={})=>({name:xm,setupOnce(){h4(t)}}),T4=SIe;var il=K(ne(),1);var E4=[">=0.0.0 <2.0.0"],RS=class extends il.InstrumentationBase{constructor(e={}){super("@sentry/instrumentation-langgraph",pe,e)}init(){return new il.InstrumentationNodeModuleDefinition("@langchain/langgraph",E4,this._patch.bind(this),n=>n,[new il.InstrumentationNodeModuleFile("@langchain/langgraph/dist/index.cjs",E4,this._patch.bind(this),n=>n)])}_patch(e){return e.StateGraph&&typeof e.StateGraph=="function"&&Dm(e.StateGraph.prototype,this.getConfig()),e}};var S4=w(Lm,t=>new RS(t)),gIe=(t={})=>({name:Lm,setupOnce(){S4(t)}}),g4=gIe;var C4=K(ne(),1);b();var Xo=K(ne(),1);le();import*as R4 from"node:net";function y4(t,e,n,r,o){let i=()=>{},a=o.firestoreSpanCreationHook;typeof a=="function"&&(i=p=>{(0,Xo.safeExecuteInTheMiddle)(()=>a(p),d=>{d&&wn.error(d?.message)},!0)});let c=new Xo.InstrumentationNodeModuleDefinition("@firebase/firestore",e,p=>A4(p,n,r,t,i)),l=["@firebase/firestore/dist/lite/index.node.cjs.js","@firebase/firestore/dist/lite/index.node.mjs.js","@firebase/firestore/dist/lite/index.rn.esm2017.js","@firebase/firestore/dist/lite/index.cjs.js"];for(let p of l)c.files.push(new Xo.InstrumentationNodeModuleFile(p,e,d=>A4(d,n,r,t,i),d=>I4(d,r)));return c}function A4(t,e,n,r,o){return I4(t,n),e(t,"addDoc",AIe(r,o)),e(t,"getDocs",yIe(r,o)),e(t,"setDoc",IIe(r,o)),e(t,"deleteDoc",RIe(r,o)),t}function I4(t,e){for(let n of["addDoc","getDocs","setDoc","deleteDoc"])(0,Xo.isWrapped)(t[n])&&e(t,n);return t}function AIe(t,e){return function(r){return function(o,s){let i=IS(t,"addDoc",o);return e(i),yS(i,()=>r(o,s))}}}function RIe(t,e){return function(r){return function(o){let s=IS(t,"deleteDoc",o.parent||o);return e(s),yS(s,()=>r(o))}}}function yIe(t,e){return function(r){return function(o){let s=IS(t,"getDocs",o);return e(s),yS(s,()=>r(o))}}}function IIe(t,e){return function(r){return function(o,s,i){let a=IS(t,"setDoc",o.parent||o);return e(a),yS(a,()=>typeof i<"u"?r(o,s,i):r(o,s))}}}function yS(t,e){return P.with(X.setSpan(P.active(),t),()=>(0,Xo.safeExecuteInTheMiddle)(()=>e(),n=>{n&&t.recordException(n),t.end()},!0))}function IS(t,e,n){let r=t.startSpan(`${e} ${n.path}`,{kind:Ne.CLIENT});return NIe(r,n),r.setAttribute(ec,e),r}function OIe(t){let e,n;if(typeof t.host=="string")if(t.host.startsWith("[")){if(t.host.endsWith("]"))e=t.host.replace(/^\[|\]$/g,"");else if(t.host.includes("]:")){let r=t.host.lastIndexOf(":");r!==-1&&(e=t.host.slice(1,r).replace(/^\[|\]$/g,""),n=t.host.slice(r+1))}}else if(R4.isIPv6(t.host))e=t.host;else{let r=t.host.lastIndexOf(":");r!==-1?(e=t.host.slice(0,r),n=t.host.slice(r+1)):e=t.host}return{address:e,port:n?parseInt(n,10):void 0}}function NIe(t,e){let n=e.firestore.app,r=n.options,s=(e.firestore.toJSON()||{}).settings||{},i={[uA]:e.path,[lA]:n.name,[Mi]:"firebase.firestore","firebase.firestore.type":e.type,"firebase.firestore.options.projectId":r.projectId,"firebase.firestore.options.appId":r.appId,"firebase.firestore.options.messagingSenderId":r.messagingSenderId,"firebase.firestore.options.storageBucket":r.storageBucket},{address:a,port:c}=OIe(s);a&&(i[EA]=a),c&&(i[SA]=c),t.setAttributes(i)}b();var Jo=K(ne(),1);function O4(t,e,n,r,o){let s=()=>{},i=()=>{},a=o.functions?.errorHook,c=o.functions?.requestHook,l=o.functions?.responseHook;typeof l=="function"&&(i=(_,f)=>{(0,Jo.safeExecuteInTheMiddle)(()=>l(_,f),m=>{m&&wn.error(m?.message)},!0)}),typeof c=="function"&&(s=_=>{(0,Jo.safeExecuteInTheMiddle)(()=>c(_),f=>{f&&wn.error(f?.message)},!0)});let p=new Jo.InstrumentationNodeModuleDefinition("firebase-functions",e);return[{name:"firebase-functions/lib/v2/providers/https.js",triggerType:"function"},{name:"firebase-functions/lib/v2/providers/firestore.js",triggerType:"firestore"},{name:"firebase-functions/lib/v2/providers/scheduler.js",triggerType:"scheduler"},{name:"firebase-functions/lib/v2/storage.js",triggerType:"storage"}].forEach(({name:_,triggerType:f})=>{p.files.push(new Jo.InstrumentationNodeModuleFile(_,e,m=>bIe(m,n,r,t,{requestHook:s,responseHook:i,errorHook:a},f),m=>N4(m,r)))}),p}function Sn(t,e,n){return function(o){return function(...s){let i=typeof s[0]=="function"?s[0]:s[1],a=typeof s[0]=="function"?void 0:s[0];if(!i)return o.call(this,...s);let c=async function(...l){let p=process.env.FUNCTION_TARGET||process.env.K_SERVICE||"unknown",d=t.startSpan(`firebase.function.${n}`,{kind:Ne.SERVER}),_={"faas.name":p,"faas.trigger":n,"faas.provider":"firebase"};return process.env.GCLOUD_PROJECT&&(_["cloud.project_id"]=process.env.GCLOUD_PROJECT),process.env.EVENTARC_CLOUD_EVENT_SOURCE&&(_["cloud.event_source"]=process.env.EVENTARC_CLOUD_EVENT_SOURCE),d.setAttributes(_),e?.requestHook?.(d),P.with(X.setSpan(P.active(),d),async()=>{let f,m;try{m=await i.apply(this,l)}catch(h){f=h}if(e?.responseHook?.(d,f),f&&d.recordException(f),d.end(),f)throw await e?.errorHook?.(d,f),f;return m})};return a?o.call(this,a,c):o.call(this,c)}}}function bIe(t,e,n,r,o,s){switch(N4(t,n),s){case"function":e(t,"onRequest",Sn(r,o,"http.request")),e(t,"onCall",Sn(r,o,"http.call"));break;case"firestore":e(t,"onDocumentCreated",Sn(r,o,"firestore.document.created")),e(t,"onDocumentUpdated",Sn(r,o,"firestore.document.updated")),e(t,"onDocumentDeleted",Sn(r,o,"firestore.document.deleted")),e(t,"onDocumentWritten",Sn(r,o,"firestore.document.written")),e(t,"onDocumentCreatedWithAuthContext",Sn(r,o,"firestore.document.created")),e(t,"onDocumentUpdatedWithAuthContext",Sn(r,o,"firestore.document.updated")),e(t,"onDocumentDeletedWithAuthContext",Sn(r,o,"firestore.document.deleted")),e(t,"onDocumentWrittenWithAuthContext",Sn(r,o,"firestore.document.written"));break;case"scheduler":e(t,"onSchedule",Sn(r,o,"scheduler.scheduled"));break;case"storage":e(t,"onObjectFinalized",Sn(r,o,"storage.object.finalized")),e(t,"onObjectArchived",Sn(r,o,"storage.object.archived")),e(t,"onObjectDeleted",Sn(r,o,"storage.object.deleted")),e(t,"onObjectMetadataUpdated",Sn(r,o,"storage.object.metadataUpdated"));break}return t}function N4(t,e){let n=["onSchedule","onRequest","onCall","onObjectFinalized","onObjectArchived","onObjectDeleted","onObjectMetadataUpdated","onDocumentCreated","onDocumentUpdated","onDocumentDeleted","onDocumentWritten","onDocumentCreatedWithAuthContext","onDocumentUpdatedWithAuthContext","onDocumentDeletedWithAuthContext","onDocumentWrittenWithAuthContext"];for(let r of n)(0,Jo.isWrapped)(t[r])&&e(t,r);return t}var b4={},CIe=[">=3.0.0 <5"],PIe=[">=6.0.0 <7"],OS=class extends C4.InstrumentationBase{constructor(e=b4){super("@sentry/instrumentation-firebase",pe,e)}setConfig(e={}){super.setConfig({...b4,...e})}init(){let e=[];return e.push(y4(this.tracer,CIe,this._wrap,this._unwrap,this.getConfig())),e.push(O4(this.tracer,PIe,this._wrap,this._unwrap,this.getConfig())),e}};var P4="Firebase",MIe={firestoreSpanCreationHook:t=>{Re(t,"auto.firebase.otel.firestore"),t.setAttribute(ee,"db.query")},functions:{requestHook:t=>{Re(t,"auto.firebase.otel.functions"),t.setAttribute(ee,"http.request")},errorHook:async(t,e)=>{e&&(te(e,{mechanism:{type:"auto.firebase.otel.functions",handled:!1}}),await nm(2e3))}}},M4=w(P4,()=>new OS(MIe)),xIe=()=>({name:P4,setupOnce(){M4()}}),x4=xIe;function v4(){return[Iq(),Z$(),OY(),JK(),uW(),yW(),DW(),$W(),Az(),Hz(),wK(),KK(),_2(),O2(),G2(),Y2(),HY(),s4(),XY(),T4(),g4(),c4(),l4(),d4(),m4(),qz(),x4()]}b();var NS=K(DI(),1),L4=K(iO(),1);le();var Xb=1e6;function D4(t,e={}){t.getOptions().debug&&RO();let[n,r]=vIe(t,e);t.traceProvider=n,t.asyncLocalStorageLookup=r}function vIe(t,e={}){let n=new L4.BasicTracerProvider({sampler:new Gh(t),resource:(0,NS.defaultResource)().merge((0,NS.resourceFromAttributes)({[gA]:"node",[cA]:"sentry",[AA]:pe})),forceFlushTimeoutMillis:500,spanProcessors:[new kh({timeout:LIe(t.getOptions().maxSpanWaitDuration)}),...e.spanProcessors||[]]});X.setGlobalTracerProvider(n),Ar.setGlobalPropagator(new wh);let r=new AO;return P.setGlobalContextManager(r),[n,r.getAsyncLocalStorageLookup()]}function LIe(t){if(t!=null){if(t>Xb)return mt&&g.warn(`\`maxSpanWaitDuration\` is too high, using the maximum value of ${Xb}`),Xb;if(t<=0||Number.isNaN(t)){mt&&g.warn("`maxSpanWaitDuration` must be a positive number, using default value instead.");return}return t}}function U4(){return Yh().filter(e=>e.name!=="Http"&&e.name!=="NodeFetch").concat(nq(),lq())}function w4(t){return[...U4(),...Xe(t)?v4():[]]}function Jb(t={}){return DIe(t,w4)}function DIe(t={},e){Ki(t,"node");let n=xO({...t,defaultIntegrations:t.defaultIntegrations??e(t)});return n&&!t.skipOpenTelemetrySetup&&(D4(n,{spanProcessors:t.openTelemetrySpanProcessors}),vO()),n}var UIe="prod",G4="0.1.13",wIe=`@tanagram/lore/${G4}`;function xt(){return UIe}function bS(){return G4}function B4(){return wIe}Jb({dsn:"https://583674b382128b1b30b9fa1f0581daab@o4509017064472576.ingest.us.sentry.io/4511344717529088",environment:xt(),release:bS(),sendDefaultPii:!0});tm("service_name","lore-cli");import{realpathSync as hxe}from"node:fs";import{fileURLToPath as Txe,pathToFileURL as w9}from"node:url";var kIe=/\d/,GIe=["-","_","/","."];function BIe(t=""){if(!kIe.test(t))return t!==t.toLowerCase()}function j4(t,e){let n=e??GIe,r=[];if(!t||typeof t!="string")return r;let o="",s,i;for(let a of t){let c=n.includes(a);if(c===!0){r.push(o),o="",s=void 0;continue}let l=BIe(a);if(i===!1){if(s===!1&&l===!0){r.push(o),o=a,s=l;continue}if(s===!0&&l===!1&&o.length>1){let p=o.at(-1);r.push(o.slice(0,Math.max(0,o.length-1))),o=p+a,s=l;continue}}o+=a,s=l,i=c}return r.push(o),r}function jIe(t){return t?t[0].toUpperCase()+t.slice(1):""}function HIe(t){return t?t[0].toLowerCase()+t.slice(1):""}function FIe(t,e){return t?(Array.isArray(t)?t:j4(t)).map(n=>jIe(e?.normalize?n.toLowerCase():n)).join(""):""}function qd(t,e){return HIe(FIe(t||"",e))}function CS(t,e){return t?(Array.isArray(t)?t:j4(t)).map(n=>n.toLowerCase()).join(e??"-"):""}function H4(t){return CS(t||"","_")}import{parseArgs as VIe}from"node:util";function LS(t){return Array.isArray(t)?t:t===void 0?[]:[t]}function Zb(t,e=""){let n=[];for(let r of t)for(let[o,s]of r.entries())n[o]=Math.max(n[o]||0,s.length);return t.map(r=>r.map((o,s)=>e+o[s===0?"padStart":"padEnd"](n[s])).join(" ")).join(`
|
|
39
39
|
`)}function Kn(t){return typeof t=="function"?t():t}var Ia=class extends Error{code;constructor(t,e){super(t),this.name="CLIError",this.code=e}};function qIe(t=[],e={}){let n=new Set(e.boolean||[]),r=new Set(e.string||[]),o=e.alias||{},s=e.default||{},i=new Map,a=new Map;for(let[T,S]of Object.entries(o)){let R=S;for(let I of R)i.set(T,I),a.has(I)||a.set(I,[]),a.get(I).push(T),i.set(I,T),a.has(T)||a.set(T,[]),a.get(T).push(I)}let c={};function l(T){if(n.has(T))return"boolean";let S=a.get(T)||[];for(let R of S)if(n.has(R))return"boolean";return"string"}function p(T){if(r.has(T))return!0;let S=a.get(T)||[];for(let R of S)if(r.has(R))return!0;return!1}let d=new Set([...n,...r,...Object.keys(o),...Object.values(o).flat(),...Object.keys(s)]);for(let T of d)c[T]||(c[T]={type:l(T),default:s[T]});for(let[T,S]of i.entries())T.length===1&&c[S]&&!c[S].short&&(c[S].short=T);let _=[],f={};for(let T=0;T<t.length;T++){let S=t[T];if(S==="--"){_.push(...t.slice(T));break}if(S.startsWith("--no-")){let R=S.slice(5);f[R]=!0;continue}_.push(S)}let m;try{m=VIe({args:_,options:Object.keys(c).length>0?c:void 0,allowPositionals:!0,strict:!1})}catch{m={values:{},positionals:_}}let h={_:[]};h._=m.positionals;for(let[T,S]of Object.entries(m.values)){let R=S;l(T)==="boolean"&&typeof S=="string"?R=S!=="false":p(T)&&typeof S=="boolean"&&(R=""),h[T]=R}for(let[T]of Object.entries(f)){h[T]=!1;let S=i.get(T);S&&(h[S]=!1);let R=a.get(T);if(R)for(let I of R)h[I]=!1}for(let[T,S]of i.entries())h[T]!==void 0&&h[S]===void 0&&(h[S]=h[T]),h[S]!==void 0&&h[T]===void 0&&(h[T]=h[S]),h[T]!==h[S]&&s[S]===h[S]&&(h[S]=h[T]);return h}var $Ie=(()=>{let t=globalThis.process?.env??{};return t.NO_COLOR==="1"||t.TERM==="dumb"||t.TEST||t.CI})(),DS=(t,e=39)=>n=>$Ie?n:`\x1B[${t}m${n}\x1B[${e}m`,PS=DS(1,22),Gr=DS(36),xS=DS(90),MS=DS(4,24);function YIe(t,e){let n={boolean:[],string:[],alias:{},default:{}},r=q4(e);for(let a of r){if(a.type==="positional")continue;a.type==="string"||a.type==="enum"?n.string.push(a.name):a.type==="boolean"&&n.boolean.push(a.name),a.default!==void 0&&(n.default[a.name]=a.default),a.alias&&(n.alias[a.name]=a.alias);let c=qd(a.name),l=CS(a.name);if(c!==a.name||l!==a.name){let p=LS(n.alias[a.name]||[]);c!==a.name&&!p.includes(c)&&p.push(c),l!==a.name&&!p.includes(l)&&p.push(l),p.length>0&&(n.alias[a.name]=p)}}let o=qIe(t,n),[...s]=o._,i=new Proxy(o,{get(a,c){return a[c]??a[qd(c)]??a[CS(c)]}});for(let[,a]of r.entries())if(a.type==="positional"){let c=s.shift();if(c!==void 0)i[a.name]=c;else{if(a.default===void 0&&a.required!==!1)throw new Ia(`Missing required positional argument: ${a.name.toUpperCase()}`,"EARG");i[a.name]=a.default}}else if(a.type==="enum"){let c=i[a.name],l=a.options||[];if(c!==void 0&&l.length>0&&!l.includes(c))throw new Ia(`Invalid value for argument: ${Gr(`--${a.name}`)} (${Gr(c)}). Expected one of: ${l.map(p=>Gr(p)).join(", ")}.`,"EARG")}else if(a.required&&i[a.name]===void 0)throw new Ia(`Missing required argument: --${a.name}`,"EARG");return i}function q4(t){let e=[];for(let[n,r]of Object.entries(t||{}))e.push({...r,name:n,alias:LS(r.alias)});return e}async function WIe(t){return Promise.all(t.map(e=>Kn(e)))}async function vS(t,e){let n=await Kn(t.args||{}),r=YIe(e.rawArgs,n),o={rawArgs:e.rawArgs,args:r,data:e.data,cmd:t},s=await WIe(t.plugins??[]),i,a;try{for(let p of s)await p.setup?.(o);typeof t.setup=="function"&&await t.setup(o);let l=await Kn(t.subCommands);if(l&&Object.keys(l).length>0){let p=zIe(e.rawArgs,n),d=e.rawArgs[p];if(d){let _=await F4(l,d);if(!_)throw new Ia(`Unknown command ${Gr(d)}`,"E_UNKNOWN_COMMAND");await vS(_,{rawArgs:e.rawArgs.slice(p+1)})}else{let _=await Kn(t.default);if(_){if(t.run)throw new Ia("Cannot specify both 'run' and 'default' on the same command.","E_DEFAULT_CONFLICT");let f=await F4(l,_);if(!f)throw new Ia(`Default sub command ${Gr(_)} not found in subCommands.`,"E_UNKNOWN_COMMAND");await vS(f,{rawArgs:e.rawArgs})}else if(!t.run)throw new Ia("No command specified.","E_NO_COMMAND")}}typeof t.run=="function"&&(i=await t.run(o))}catch(l){a=l}let c=[];if(typeof t.cleanup=="function")try{await t.cleanup(o)}catch(l){c.push(l)}for(let l of[...s].reverse())try{await l.cleanup?.(o)}catch(p){c.push(p)}if(a)throw a;if(c.length===1)throw c[0];if(c.length>1)throw new Error("Multiple cleanup errors",{cause:c});return{result:i}}async function F4(t,e){if(e in t)return Kn(t[e]);for(let n of Object.values(t)){let r=await Kn(n),o=await Kn(r?.meta);if(o?.alias&&LS(o.alias).includes(e))return r}}function zIe(t,e){for(let n=0;n<t.length;n++){let r=t[n];if(r==="--")return-1;if(r.startsWith("-")){!r.includes("=")&&KIe(r,e)&&n++;continue}return n}return-1}function KIe(t,e){let n=t.replace(/^-{1,2}/,""),r=qd(n);for(let[o,s]of Object.entries(e))if(!(s.type!=="string"&&s.type!=="enum")&&(r===qd(o)||(Array.isArray(s.alias)?s.alias:s.alias?[s.alias]:[]).includes(n)))return!0;return!1}var QIe=/^no[-A-Z]/;async function $4(t,e){let n=await Kn(t.meta||{}),r=q4(await Kn(t.args||{})),o=await Kn(e?.meta||{}),s=`${o.name?`${o.name} `:""}`+(n.name||process.argv[1]),i=[],a=[],c=[],l=[];for(let f of r)if(f.type==="positional"){let m=f.name.toUpperCase(),h=f.required!==!1&&f.default===void 0;a.push([Gr(m+eC(f)),V4(f,h)]),l.push(h?`<${m}>`:`[${m}]`)}else{let m=f.required===!0&&f.default===void 0,h=[...(f.alias||[]).map(T=>`-${T}`),`--${f.name}`].join(", ")+eC(f);if(i.push([Gr(h),V4(f,m)]),f.type==="boolean"&&(f.default===!0||f.negativeDescription)&&!QIe.test(f.name)){let T=[...(f.alias||[]).map(S=>`--no-${S}`),`--no-${f.name}`].join(", ");i.push([Gr(T),[f.negativeDescription,m?xS("(Required)"):""].filter(Boolean).join(" ")])}m&&l.push(`--${f.name}`+eC(f))}if(t.subCommands){let f=[],m=await Kn(t.subCommands);for(let[h,T]of Object.entries(m)){let S=await Kn((await Kn(T))?.meta);if(S?.hidden)continue;let R=LS(S?.alias),I=[h,...R].join(", ");c.push([Gr(I),S?.description||""]),f.push(h,...R)}l.push(f.join("|"))}let p=[],d=n.version||o.version;p.push(xS(`${n.description} (${s+(d?` v${d}`:"")})`),"");let _=i.length>0||a.length>0;return p.push(`${MS(PS("USAGE"))} ${Gr(`${s}${_?" [OPTIONS]":""} ${l.join(" ")}`)}`,""),a.length>0&&(p.push(MS(PS("ARGUMENTS")),""),p.push(Zb(a," ")),p.push("")),i.length>0&&(p.push(MS(PS("OPTIONS")),""),p.push(Zb(i," ")),p.push("")),c.length>0&&(p.push(MS(PS("COMMANDS")),""),p.push(Zb(c," ")),p.push("",`Use ${Gr(`${s} <command> --help`)} for more information about a command.`)),p.filter(f=>typeof f=="string").join(`
|
|
40
40
|
`)}function eC(t){let e=t.valueHint?`=<${t.valueHint}>`:"",n=e||`=<${H4(t.name)}>`;return!t.type||t.type==="positional"||t.type==="boolean"?e:t.type==="enum"&&t.options?.length?`=<${t.options.join("|")}>`:n}function V4(t,e){let n=e?xS("(Required)"):"",r=t.default===void 0?"":xS(`(Default: ${t.default})`);return[t.description,n,r].filter(Boolean).join(" ")}import{execFile as TOe}from"node:child_process";import tn from"node:fs/promises";import EOe from"node:os";import So from"node:path";import{promisify as SOe}from"node:util";import Y4 from"node:os";import Oa from"node:path";function Zo(){let t=xt()==="dev"?".lore-dev":".lore";return Oa.join(Y4.homedir(),t)}function US(){return Oa.join(Zo(),"log.txt")}function tC(){return Oa.join(Zo(),"sync_state.json")}function wS(){return Oa.join(Zo(),"status.json")}function $d(){return Oa.join(Zo(),"install_source.json")}function Yd(){return Oa.join(Zo(),"bin","lore")}function Wd(){let t=xt();return t==="prod"?"ai.tanagram.lore":`ai.tanagram.lore.${t}`}function zd(){return Oa.join(Y4.homedir(),"Library","LaunchAgents",`${Wd()}.plist`)}import al from"node:fs/promises";import GS from"node:os";import en from"node:path";function fi(t,e){return t!==null&&typeof t=="object"&&"code"in t&&t.code===e}import z4 from"node:fs";var W4=null;function XIe(){let t=Zo();W4!==t&&(z4.mkdirSync(t,{recursive:!0}),W4=t)}function JIe(t){let e=typeof t=="string"?t:JSON.stringify(t);return/[\s"=]/.test(e)?JSON.stringify(e):e}function ZIe(t,e,n){let r=`${new Date().toISOString()} ${t} ${e}`;if(!n)return`${r}
|
|
41
41
|
`;let o=Object.entries(n).map(([s,i])=>`${s}=${JIe(i)}`).join(" ");return o?`${r} ${o}
|
|
@@ -78,7 +78,7 @@ cd ${aC(e)}
|
|
|
78
78
|
exec ${aC(n)} ${aC(t)} "$@"
|
|
79
79
|
`}function aC(t){return`'${t.replaceAll("'","'\\''")}'`}async function POe(t){let e=$d();await tn.mkdir(So.dirname(e),{recursive:!0,mode:448}),await tn.writeFile(e,`${JSON.stringify({binary_path:t,updated_at:new Date().toISOString()},null,2)}
|
|
80
80
|
`,{mode:384})}async function u3(){try{await FS("bootout",uC(),zd())}catch(t){if(d3(t)||!(await l3().catch(()=>({loaded:!0}))).loaded)return;throw t}}async function MOe(t){await FS("bootstrap",uC(),t)}async function xOe(){await FS("kickstart","-k",p3())}async function l3(){try{let t=await FS("print",p3());return vOe(t)}catch(t){if(d3(t))return{loaded:!1,running:!1,pid:0,raw:""};throw t}}function vOe(t){let e={loaded:t.trim().length>0,running:!1,pid:0,raw:t},n;for(let r of t.split(`
|
|
81
|
-
`)){let o=r.trim();if(o.startsWith("state =")&&(n=o.slice(7).trim()==="running"),o.startsWith("pid =")){let s=Number.parseInt(o.slice(5).trim(),10);Number.isNaN(s)||(e.pid=s)}}return e.running=n??e.pid>0,e}async function FS(...t){try{let e=await gOe("launchctl",t);return`${e.stdout}${e.stderr}`.trim()}catch(e){if(kOe(e)){let n=`${e.stdout??""}${e.stderr??""}`.trim();throw new Error(n?`launchctl ${t.join(" ")}: ${e.message}: ${n}`:`launchctl ${t.join(" ")}: ${e.message}`)}throw e}}function LOe(t,e,n,r){return t?e.loaded?n.state==="logged_out"?{health:"logged_out",healthy:!1}:n.state==="error"?{health:"error",healthy:!1}:e.running?r?{health:"running",healthy:!0}:{health:"stale",healthy:!1}:n.last_heartbeat_at?{health:"healthy",healthy:!0}:{health:"waiting_for_first_run",healthy:!1}:{health:"not_loaded",healthy:!1}:{health:"disabled",healthy:!1}}function DOe(t,e){if(!t.last_heartbeat_at)return!1;let n=Date.parse(t.last_heartbeat_at);return Number.isNaN(n)?!1:n+AOe>=e.getTime()}function uC(){return`gui/${process.getuid?.()??EOe.userInfo().uid}`}function p3(){return`${uC()}/${Wd()}`}function UOe(){let t=["/opt/homebrew/bin","/usr/local/bin","/usr/bin","/bin","/usr/sbin","/sbin"];return Array.from(new Set([...process.env.PATH?.split(So.delimiter)??[],...t].filter(Boolean))).join(So.delimiter)}async function wOe(t){try{return await tn.stat(t),!0}catch{return!1}}function HS(t){return t.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'")}function lC(){if(process.platform!=="darwin")throw new Error("Lore background uploads are currently supported only on macOS")}function d3(t){let e=t instanceof Error?t.message.toLowerCase():String(t).toLowerCase();return e.includes("could not find service")||e.includes("service could not be found")||e.includes("no such process")||e.includes("bad request")}function kOe(t){return t instanceof Error}var _3={meta:{name:"enable",description:"Install and start background uploads"},async run(){let{plistPath:t,binaryPath:e}=await cC();console.log("Lore background uploads enabled."),console.log(`LaunchAgent: ${t}`),console.log(`Stable binary: ${e}`)}},f3={meta:{name:"disable",description:"Stop and remove background uploads"},async run(){await a3(),console.log("Lore background uploads disabled.")}},m3={meta:{name:"restart",description:"Restart background uploads"},async run(){await cC(),console.log("Lore background uploads restarted.")}},h3={meta:{name:"status",description:"Show background upload status"},args:{json:{type:"boolean",description:"Output status as JSON"}},async run({args:t}){let e=await c3();if(t.json){console.log(JSON.stringify(e,null,2));return}console.log(`Lore: ${e.health}`),console.log(`Enabled: ${e.enabled}`),console.log(`Loaded: ${e.loaded}`),console.log(`Running: ${e.running}`),console.log(`Healthy: ${e.healthy}`),e.status?.last_heartbeat_at&&console.log(`Last heartbeat: ${e.status.last_heartbeat_at}`),e.status?.last_success_at&&console.log(`Last success: ${e.status.last_success_at}`),e.status?.last_error&&console.log(`Last error: ${e.status.last_error}`),console.log(`LaunchAgent: ${e.plist_path}`),console.log(`Stable binary: ${e.binary_path}`),console.log(`Status file: ${e.status_path}`)}};var u={};sg(u,{BRAND:()=>uNe,DIRTY:()=>Na,EMPTY_PATH:()=>HOe,INVALID:()=>Q,NEVER:()=>WNe,OK:()=>nn,ParseStatus:()=>Ft,Schema:()=>ce,ZodAny:()=>Ti,ZodArray:()=>os,ZodBigInt:()=>Ca,ZodBoolean:()=>Pa,ZodBranded:()=>Zd,ZodCatch:()=>ja,ZodDate:()=>Ma,ZodDefault:()=>Ba,ZodDiscriminatedUnion:()=>$S,ZodEffects:()=>Sr,ZodEnum:()=>ka,ZodError:()=>vn,ZodFirstPartyTypeKind:()=>Z,ZodFunction:()=>WS,ZodIntersection:()=>Da,ZodIssueCode:()=>N,ZodLazy:()=>Ua,ZodLiteral:()=>wa,ZodMap:()=>_l,ZodNaN:()=>ml,ZodNativeEnum:()=>Ga,ZodNever:()=>Br,ZodNull:()=>va,ZodNullable:()=>Ro,ZodNumber:()=>ba,ZodObject:()=>Ln,ZodOptional:()=>Tr,ZodParsedType:()=>D,ZodPipeline:()=>e_,ZodPromise:()=>Ei,ZodReadonly:()=>Ha,ZodRecord:()=>YS,ZodSchema:()=>ce,ZodSet:()=>fl,ZodString:()=>hi,ZodSymbol:()=>pl,ZodTransformer:()=>Sr,ZodTuple:()=>Ao,ZodType:()=>ce,ZodUndefined:()=>xa,ZodUnion:()=>La,ZodUnknown:()=>rs,ZodVoid:()=>dl,addIssueToContext:()=>M,any:()=>ENe,array:()=>RNe,bigint:()=>_Ne,boolean:()=>b3,coerce:()=>YNe,custom:()=>I3,date:()=>fNe,datetimeRegex:()=>R3,defaultErrorMap:()=>ts,discriminatedUnion:()=>NNe,effect:()=>GNe,enum:()=>UNe,function:()=>vNe,getErrorMap:()=>cl,getParsedType:()=>go,instanceof:()=>pNe,intersection:()=>bNe,isAborted:()=>VS,isAsync:()=>ul,isDirty:()=>qS,isValid:()=>mi,late:()=>lNe,lazy:()=>LNe,literal:()=>DNe,makeIssue:()=>Jd,map:()=>MNe,nan:()=>dNe,nativeEnum:()=>wNe,never:()=>gNe,null:()=>TNe,nullable:()=>jNe,number:()=>N3,object:()=>yNe,objectUtil:()=>pC,oboolean:()=>$Ne,onumber:()=>qNe,optional:()=>BNe,ostring:()=>VNe,pipeline:()=>FNe,preprocess:()=>HNe,promise:()=>kNe,quotelessJson:()=>GOe,record:()=>PNe,set:()=>xNe,setErrorMap:()=>jOe,strictObject:()=>INe,string:()=>O3,symbol:()=>mNe,transformer:()=>GNe,tuple:()=>CNe,undefined:()=>hNe,union:()=>ONe,unknown:()=>SNe,util:()=>de,void:()=>ANe});var de;(function(t){t.assertEqual=o=>{};function e(o){}t.assertIs=e;function n(o){throw new Error}t.assertNever=n,t.arrayToEnum=o=>{let s={};for(let i of o)s[i]=i;return s},t.getValidEnumValues=o=>{let s=t.objectKeys(o).filter(a=>typeof o[o[a]]!="number"),i={};for(let a of s)i[a]=o[a];return t.objectValues(i)},t.objectValues=o=>t.objectKeys(o).map(function(s){return o[s]}),t.objectKeys=typeof Object.keys=="function"?o=>Object.keys(o):o=>{let s=[];for(let i in o)Object.prototype.hasOwnProperty.call(o,i)&&s.push(i);return s},t.find=(o,s)=>{for(let i of o)if(s(i))return i},t.isInteger=typeof Number.isInteger=="function"?o=>Number.isInteger(o):o=>typeof o=="number"&&Number.isFinite(o)&&Math.floor(o)===o;function r(o,s=" | "){return o.map(i=>typeof i=="string"?`'${i}'`:i).join(s)}t.joinValues=r,t.jsonStringifyReplacer=(o,s)=>typeof s=="bigint"?s.toString():s})(de||(de={}));var pC;(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(pC||(pC={}));var D=de.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),go=t=>{switch(typeof t){case"undefined":return D.undefined;case"string":return D.string;case"number":return Number.isNaN(t)?D.nan:D.number;case"boolean":return D.boolean;case"function":return D.function;case"bigint":return D.bigint;case"symbol":return D.symbol;case"object":return Array.isArray(t)?D.array:t===null?D.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?D.promise:typeof Map<"u"&&t instanceof Map?D.map:typeof Set<"u"&&t instanceof Set?D.set:typeof Date<"u"&&t instanceof Date?D.date:D.object;default:return D.unknown}};var N=de.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"]),GOe=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),vn=class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};let n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=e}format(e){let n=e||function(s){return s.message},r={_errors:[]},o=s=>{for(let i of s.issues)if(i.code==="invalid_union")i.unionErrors.map(o);else if(i.code==="invalid_return_type")o(i.returnTypeError);else if(i.code==="invalid_arguments")o(i.argumentsError);else if(i.path.length===0)r._errors.push(n(i));else{let a=r,c=0;for(;c<i.path.length;){let l=i.path[c];c===i.path.length-1?(a[l]=a[l]||{_errors:[]},a[l]._errors.push(n(i))):a[l]=a[l]||{_errors:[]},a=a[l],c++}}};return o(this),r}static assert(e){if(!(e instanceof t))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,de.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=n=>n.message){let n={},r=[];for(let o of this.issues)if(o.path.length>0){let s=o.path[0];n[s]=n[s]||[],n[s].push(e(o))}else r.push(e(o));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}};vn.create=t=>new vn(t);var BOe=(t,e)=>{let n;switch(t.code){case N.invalid_type:t.received===D.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case N.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,de.jsonStringifyReplacer)}`;break;case N.unrecognized_keys:n=`Unrecognized key(s) in object: ${de.joinValues(t.keys,", ")}`;break;case N.invalid_union:n="Invalid input";break;case N.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${de.joinValues(t.options)}`;break;case N.invalid_enum_value:n=`Invalid enum value. Expected ${de.joinValues(t.options)}, received '${t.received}'`;break;case N.invalid_arguments:n="Invalid function arguments";break;case N.invalid_return_type:n="Invalid function return type";break;case N.invalid_date:n="Invalid date";break;case N.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(n=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?n=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?n=`Invalid input: must end with "${t.validation.endsWith}"`:de.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case N.too_small:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:n="Invalid input";break;case N.too_big:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?n=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:n="Invalid input";break;case N.custom:n="Invalid input";break;case N.invalid_intersection_types:n="Intersection results could not be merged";break;case N.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case N.not_finite:n="Number must be finite";break;default:n=e.defaultError,de.assertNever(t)}return{message:n}},ts=BOe;var T3=ts;function jOe(t){T3=t}function cl(){return T3}var Jd=t=>{let{data:e,path:n,errorMaps:r,issueData:o}=t,s=[...n,...o.path||[]],i={...o,path:s};if(o.message!==void 0)return{...o,path:s,message:o.message};let a="",c=r.filter(l=>!!l).slice().reverse();for(let l of c)a=l(i,{data:e,defaultError:a}).message;return{...o,path:s,message:a}},HOe=[];function M(t,e){let n=cl(),r=Jd({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===ts?void 0:ts].filter(o=>!!o)});t.common.issues.push(r)}var Ft=class t{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,n){let r=[];for(let o of n){if(o.status==="aborted")return Q;o.status==="dirty"&&e.dirty(),r.push(o.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,n){let r=[];for(let o of n){let s=await o.key,i=await o.value;r.push({key:s,value:i})}return t.mergeObjectSync(e,r)}static mergeObjectSync(e,n){let r={};for(let o of n){let{key:s,value:i}=o;if(s.status==="aborted"||i.status==="aborted")return Q;s.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),s.value!=="__proto__"&&(typeof i.value<"u"||o.alwaysSet)&&(r[s.value]=i.value)}return{status:e.value,value:r}}},Q=Object.freeze({status:"aborted"}),Na=t=>({status:"dirty",value:t}),nn=t=>({status:"valid",value:t}),VS=t=>t.status==="aborted",qS=t=>t.status==="dirty",mi=t=>t.status==="valid",ul=t=>typeof Promise<"u"&&t instanceof Promise;var j;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(j||(j={}));var Er=class{constructor(e,n,r,o){this._cachedPath=[],this.parent=e,this.data=n,this._path=r,this._key=o}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}},E3=(t,e)=>{if(mi(e))return{success:!0,data:e.value};if(!t.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 vn(t.common.issues);return this._error=n,this._error}}};function ie(t){if(!t)return{};let{errorMap:e,invalid_type_error:n,required_error:r,description:o}=t;if(e&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:o}:{errorMap:(i,a)=>{let{message:c}=t;return i.code==="invalid_enum_value"?{message:c??a.defaultError}:typeof a.data>"u"?{message:c??r??a.defaultError}:i.code!=="invalid_type"?{message:a.defaultError}:{message:c??n??a.defaultError}},description:o}}var ce=class{get description(){return this._def.description}_getType(e){return go(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:go(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Ft,ctx:{common:e.parent.common,data:e.data,parsedType:go(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let n=this._parse(e);if(ul(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(e){let n=this._parse(e);return Promise.resolve(n)}parse(e,n){let r=this.safeParse(e,n);if(r.success)return r.data;throw r.error}safeParse(e,n){let r={common:{issues:[],async:n?.async??!1,contextualErrorMap:n?.errorMap},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:go(e)},o=this._parseSync({data:e,path:r.path,parent:r});return E3(r,o)}"~validate"(e){let n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:go(e)};if(!this["~standard"].async)try{let r=this._parseSync({data:e,path:[],parent:n});return mi(r)?{value:r.value}:{issues:n.common.issues}}catch(r){r?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:n}).then(r=>mi(r)?{value:r.value}:{issues:n.common.issues})}async parseAsync(e,n){let r=await this.safeParseAsync(e,n);if(r.success)return r.data;throw r.error}async safeParseAsync(e,n){let r={common:{issues:[],contextualErrorMap:n?.errorMap,async:!0},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:go(e)},o=this._parse({data:e,path:r.path,parent:r}),s=await(ul(o)?o:Promise.resolve(o));return E3(r,s)}refine(e,n){let r=o=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(o):n;return this._refinement((o,s)=>{let i=e(o),a=()=>s.addIssue({code:N.custom,...r(o)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?!0:(a(),!1)):i?!0:(a(),!1)})}refinement(e,n){return this._refinement((r,o)=>e(r)?!0:(o.addIssue(typeof n=="function"?n(r,o):n),!1))}_refinement(e){return new Sr({schema:this,typeName:Z.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.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 Tr.create(this,this._def)}nullable(){return Ro.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return os.create(this)}promise(){return Ei.create(this,this._def)}or(e){return La.create([this,e],this._def)}and(e){return Da.create(this,e,this._def)}transform(e){return new Sr({...ie(this._def),schema:this,typeName:Z.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let n=typeof e=="function"?e:()=>e;return new Ba({...ie(this._def),innerType:this,defaultValue:n,typeName:Z.ZodDefault})}brand(){return new Zd({typeName:Z.ZodBranded,type:this,...ie(this._def)})}catch(e){let n=typeof e=="function"?e:()=>e;return new ja({...ie(this._def),innerType:this,catchValue:n,typeName:Z.ZodCatch})}describe(e){let n=this.constructor;return new n({...this._def,description:e})}pipe(e){return e_.create(this,e)}readonly(){return Ha.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},FOe=/^c[^\s-]{8,}$/i,VOe=/^[0-9a-z]+$/,qOe=/^[0-9A-HJKMNP-TV-Z]{26}$/i,$Oe=/^[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,YOe=/^[a-z0-9_-]{21}$/i,WOe=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,zOe=/^[-+]?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)?)??$/,KOe=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,QOe="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",dC,XOe=/^(?:(?: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])$/,JOe=/^(?:(?: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])$/,ZOe=/^(([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]))$/,eNe=/^(([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])$/,tNe=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,nNe=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,g3="((\\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])))",rNe=new RegExp(`^${g3}$`);function A3(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);let n=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${n}`}function oNe(t){return new RegExp(`^${A3(t)}$`)}function R3(t){let e=`${g3}T${A3(t)}`,n=[];return n.push(t.local?"Z?":"Z"),t.offset&&n.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${n.join("|")})`,new RegExp(`^${e}$`)}function sNe(t,e){return!!((e==="v4"||!e)&&XOe.test(t)||(e==="v6"||!e)&&ZOe.test(t))}function iNe(t,e){if(!WOe.test(t))return!1;try{let[n]=t.split(".");if(!n)return!1;let r=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),o=JSON.parse(atob(r));return!(typeof o!="object"||o===null||"typ"in o&&o?.typ!=="JWT"||!o.alg||e&&o.alg!==e)}catch{return!1}}function aNe(t,e){return!!((e==="v4"||!e)&&JOe.test(t)||(e==="v6"||!e)&&eNe.test(t))}var hi=class t extends ce{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==D.string){let s=this._getOrReturnCtx(e);return M(s,{code:N.invalid_type,expected:D.string,received:s.parsedType}),Q}let r=new Ft,o;for(let s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(o=this._getOrReturnCtx(e,o),M(o,{code:N.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),r.dirty());else if(s.kind==="max")e.data.length>s.value&&(o=this._getOrReturnCtx(e,o),M(o,{code:N.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),r.dirty());else if(s.kind==="length"){let i=e.data.length>s.value,a=e.data.length<s.value;(i||a)&&(o=this._getOrReturnCtx(e,o),i?M(o,{code:N.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):a&&M(o,{code:N.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),r.dirty())}else if(s.kind==="email")KOe.test(e.data)||(o=this._getOrReturnCtx(e,o),M(o,{validation:"email",code:N.invalid_string,message:s.message}),r.dirty());else if(s.kind==="emoji")dC||(dC=new RegExp(QOe,"u")),dC.test(e.data)||(o=this._getOrReturnCtx(e,o),M(o,{validation:"emoji",code:N.invalid_string,message:s.message}),r.dirty());else if(s.kind==="uuid")$Oe.test(e.data)||(o=this._getOrReturnCtx(e,o),M(o,{validation:"uuid",code:N.invalid_string,message:s.message}),r.dirty());else if(s.kind==="nanoid")YOe.test(e.data)||(o=this._getOrReturnCtx(e,o),M(o,{validation:"nanoid",code:N.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid")FOe.test(e.data)||(o=this._getOrReturnCtx(e,o),M(o,{validation:"cuid",code:N.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid2")VOe.test(e.data)||(o=this._getOrReturnCtx(e,o),M(o,{validation:"cuid2",code:N.invalid_string,message:s.message}),r.dirty());else if(s.kind==="ulid")qOe.test(e.data)||(o=this._getOrReturnCtx(e,o),M(o,{validation:"ulid",code:N.invalid_string,message:s.message}),r.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{o=this._getOrReturnCtx(e,o),M(o,{validation:"url",code:N.invalid_string,message:s.message}),r.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(o=this._getOrReturnCtx(e,o),M(o,{validation:"regex",code:N.invalid_string,message:s.message}),r.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(o=this._getOrReturnCtx(e,o),M(o,{code:N.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),r.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(o=this._getOrReturnCtx(e,o),M(o,{code:N.invalid_string,validation:{startsWith:s.value},message:s.message}),r.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(o=this._getOrReturnCtx(e,o),M(o,{code:N.invalid_string,validation:{endsWith:s.value},message:s.message}),r.dirty()):s.kind==="datetime"?R3(s).test(e.data)||(o=this._getOrReturnCtx(e,o),M(o,{code:N.invalid_string,validation:"datetime",message:s.message}),r.dirty()):s.kind==="date"?rNe.test(e.data)||(o=this._getOrReturnCtx(e,o),M(o,{code:N.invalid_string,validation:"date",message:s.message}),r.dirty()):s.kind==="time"?oNe(s).test(e.data)||(o=this._getOrReturnCtx(e,o),M(o,{code:N.invalid_string,validation:"time",message:s.message}),r.dirty()):s.kind==="duration"?zOe.test(e.data)||(o=this._getOrReturnCtx(e,o),M(o,{validation:"duration",code:N.invalid_string,message:s.message}),r.dirty()):s.kind==="ip"?sNe(e.data,s.version)||(o=this._getOrReturnCtx(e,o),M(o,{validation:"ip",code:N.invalid_string,message:s.message}),r.dirty()):s.kind==="jwt"?iNe(e.data,s.alg)||(o=this._getOrReturnCtx(e,o),M(o,{validation:"jwt",code:N.invalid_string,message:s.message}),r.dirty()):s.kind==="cidr"?aNe(e.data,s.version)||(o=this._getOrReturnCtx(e,o),M(o,{validation:"cidr",code:N.invalid_string,message:s.message}),r.dirty()):s.kind==="base64"?tNe.test(e.data)||(o=this._getOrReturnCtx(e,o),M(o,{validation:"base64",code:N.invalid_string,message:s.message}),r.dirty()):s.kind==="base64url"?nNe.test(e.data)||(o=this._getOrReturnCtx(e,o),M(o,{validation:"base64url",code:N.invalid_string,message:s.message}),r.dirty()):de.assertNever(s);return{status:r.value,value:e.data}}_regex(e,n,r){return this.refinement(o=>e.test(o),{validation:n,code:N.invalid_string,...j.errToObj(r)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...j.errToObj(e)})}url(e){return this._addCheck({kind:"url",...j.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...j.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...j.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...j.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...j.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...j.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...j.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...j.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...j.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...j.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...j.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...j.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...j.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...j.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...j.errToObj(e)})}regex(e,n){return this._addCheck({kind:"regex",regex:e,...j.errToObj(n)})}includes(e,n){return this._addCheck({kind:"includes",value:e,position:n?.position,...j.errToObj(n?.message)})}startsWith(e,n){return this._addCheck({kind:"startsWith",value:e,...j.errToObj(n)})}endsWith(e,n){return this._addCheck({kind:"endsWith",value:e,...j.errToObj(n)})}min(e,n){return this._addCheck({kind:"min",value:e,...j.errToObj(n)})}max(e,n){return this._addCheck({kind:"max",value:e,...j.errToObj(n)})}length(e,n){return this._addCheck({kind:"length",value:e,...j.errToObj(n)})}nonempty(e){return this.min(1,j.errToObj(e))}trim(){return new t({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxLength(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}};hi.create=t=>new hi({checks:[],typeName:Z.ZodString,coerce:t?.coerce??!1,...ie(t)});function cNe(t,e){let n=(t.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,o=n>r?n:r,s=Number.parseInt(t.toFixed(o).replace(".","")),i=Number.parseInt(e.toFixed(o).replace(".",""));return s%i/10**o}var ba=class t extends ce{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==D.number){let s=this._getOrReturnCtx(e);return M(s,{code:N.invalid_type,expected:D.number,received:s.parsedType}),Q}let r,o=new Ft;for(let s of this._def.checks)s.kind==="int"?de.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),M(r,{code:N.invalid_type,expected:"integer",received:"float",message:s.message}),o.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(r=this._getOrReturnCtx(e,r),M(r,{code:N.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),o.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(r=this._getOrReturnCtx(e,r),M(r,{code:N.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),o.dirty()):s.kind==="multipleOf"?cNe(e.data,s.value)!==0&&(r=this._getOrReturnCtx(e,r),M(r,{code:N.not_multiple_of,multipleOf:s.value,message:s.message}),o.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),M(r,{code:N.not_finite,message:s.message}),o.dirty()):de.assertNever(s);return{status:o.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,j.toString(n))}gt(e,n){return this.setLimit("min",e,!1,j.toString(n))}lte(e,n){return this.setLimit("max",e,!0,j.toString(n))}lt(e,n){return this.setLimit("max",e,!1,j.toString(n))}setLimit(e,n,r,o){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:j.toString(o)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:j.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:j.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:j.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:j.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:j.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:j.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:j.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:j.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:j.toString(e)})}get minValue(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&de.isInteger(e.value))}get isFinite(){let e=null,n=null;for(let r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(n)&&Number.isFinite(e)}};ba.create=t=>new ba({checks:[],typeName:Z.ZodNumber,coerce:t?.coerce||!1,...ie(t)});var Ca=class t extends ce{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==D.bigint)return this._getInvalidInput(e);let r,o=new Ft;for(let s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(r=this._getOrReturnCtx(e,r),M(r,{code:N.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),o.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(r=this._getOrReturnCtx(e,r),M(r,{code:N.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),o.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),M(r,{code:N.not_multiple_of,multipleOf:s.value,message:s.message}),o.dirty()):de.assertNever(s);return{status:o.value,value:e.data}}_getInvalidInput(e){let n=this._getOrReturnCtx(e);return M(n,{code:N.invalid_type,expected:D.bigint,received:n.parsedType}),Q}gte(e,n){return this.setLimit("min",e,!0,j.toString(n))}gt(e,n){return this.setLimit("min",e,!1,j.toString(n))}lte(e,n){return this.setLimit("max",e,!0,j.toString(n))}lt(e,n){return this.setLimit("max",e,!1,j.toString(n))}setLimit(e,n,r,o){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:j.toString(o)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:j.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:j.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:j.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:j.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:j.toString(n)})}get minValue(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}};Ca.create=t=>new Ca({checks:[],typeName:Z.ZodBigInt,coerce:t?.coerce??!1,...ie(t)});var Pa=class extends ce{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==D.boolean){let r=this._getOrReturnCtx(e);return M(r,{code:N.invalid_type,expected:D.boolean,received:r.parsedType}),Q}return nn(e.data)}};Pa.create=t=>new Pa({typeName:Z.ZodBoolean,coerce:t?.coerce||!1,...ie(t)});var Ma=class t extends ce{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==D.date){let s=this._getOrReturnCtx(e);return M(s,{code:N.invalid_type,expected:D.date,received:s.parsedType}),Q}if(Number.isNaN(e.data.getTime())){let s=this._getOrReturnCtx(e);return M(s,{code:N.invalid_date}),Q}let r=new Ft,o;for(let s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(o=this._getOrReturnCtx(e,o),M(o,{code:N.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),r.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(o=this._getOrReturnCtx(e,o),M(o,{code:N.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),r.dirty()):de.assertNever(s);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,n){return this._addCheck({kind:"min",value:e.getTime(),message:j.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:j.toString(n)})}get minDate(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e!=null?new Date(e):null}};Ma.create=t=>new Ma({checks:[],coerce:t?.coerce||!1,typeName:Z.ZodDate,...ie(t)});var pl=class extends ce{_parse(e){if(this._getType(e)!==D.symbol){let r=this._getOrReturnCtx(e);return M(r,{code:N.invalid_type,expected:D.symbol,received:r.parsedType}),Q}return nn(e.data)}};pl.create=t=>new pl({typeName:Z.ZodSymbol,...ie(t)});var xa=class extends ce{_parse(e){if(this._getType(e)!==D.undefined){let r=this._getOrReturnCtx(e);return M(r,{code:N.invalid_type,expected:D.undefined,received:r.parsedType}),Q}return nn(e.data)}};xa.create=t=>new xa({typeName:Z.ZodUndefined,...ie(t)});var va=class extends ce{_parse(e){if(this._getType(e)!==D.null){let r=this._getOrReturnCtx(e);return M(r,{code:N.invalid_type,expected:D.null,received:r.parsedType}),Q}return nn(e.data)}};va.create=t=>new va({typeName:Z.ZodNull,...ie(t)});var Ti=class extends ce{constructor(){super(...arguments),this._any=!0}_parse(e){return nn(e.data)}};Ti.create=t=>new Ti({typeName:Z.ZodAny,...ie(t)});var rs=class extends ce{constructor(){super(...arguments),this._unknown=!0}_parse(e){return nn(e.data)}};rs.create=t=>new rs({typeName:Z.ZodUnknown,...ie(t)});var Br=class extends ce{_parse(e){let n=this._getOrReturnCtx(e);return M(n,{code:N.invalid_type,expected:D.never,received:n.parsedType}),Q}};Br.create=t=>new Br({typeName:Z.ZodNever,...ie(t)});var dl=class extends ce{_parse(e){if(this._getType(e)!==D.undefined){let r=this._getOrReturnCtx(e);return M(r,{code:N.invalid_type,expected:D.void,received:r.parsedType}),Q}return nn(e.data)}};dl.create=t=>new dl({typeName:Z.ZodVoid,...ie(t)});var os=class t extends ce{_parse(e){let{ctx:n,status:r}=this._processInputParams(e),o=this._def;if(n.parsedType!==D.array)return M(n,{code:N.invalid_type,expected:D.array,received:n.parsedType}),Q;if(o.exactLength!==null){let i=n.data.length>o.exactLength.value,a=n.data.length<o.exactLength.value;(i||a)&&(M(n,{code:i?N.too_big:N.too_small,minimum:a?o.exactLength.value:void 0,maximum:i?o.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:o.exactLength.message}),r.dirty())}if(o.minLength!==null&&n.data.length<o.minLength.value&&(M(n,{code:N.too_small,minimum:o.minLength.value,type:"array",inclusive:!0,exact:!1,message:o.minLength.message}),r.dirty()),o.maxLength!==null&&n.data.length>o.maxLength.value&&(M(n,{code:N.too_big,maximum:o.maxLength.value,type:"array",inclusive:!0,exact:!1,message:o.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((i,a)=>o.type._parseAsync(new Er(n,i,n.path,a)))).then(i=>Ft.mergeArray(r,i));let s=[...n.data].map((i,a)=>o.type._parseSync(new Er(n,i,n.path,a)));return Ft.mergeArray(r,s)}get element(){return this._def.type}min(e,n){return new t({...this._def,minLength:{value:e,message:j.toString(n)}})}max(e,n){return new t({...this._def,maxLength:{value:e,message:j.toString(n)}})}length(e,n){return new t({...this._def,exactLength:{value:e,message:j.toString(n)}})}nonempty(e){return this.min(1,e)}};os.create=(t,e)=>new os({type:t,minLength:null,maxLength:null,exactLength:null,typeName:Z.ZodArray,...ie(e)});function ll(t){if(t instanceof Ln){let e={};for(let n in t.shape){let r=t.shape[n];e[n]=Tr.create(ll(r))}return new Ln({...t._def,shape:()=>e})}else return t instanceof os?new os({...t._def,type:ll(t.element)}):t instanceof Tr?Tr.create(ll(t.unwrap())):t instanceof Ro?Ro.create(ll(t.unwrap())):t instanceof Ao?Ao.create(t.items.map(e=>ll(e))):t}var Ln=class t extends ce{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),n=de.objectKeys(e);return this._cached={shape:e,keys:n},this._cached}_parse(e){if(this._getType(e)!==D.object){let l=this._getOrReturnCtx(e);return M(l,{code:N.invalid_type,expected:D.object,received:l.parsedType}),Q}let{status:r,ctx:o}=this._processInputParams(e),{shape:s,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof Br&&this._def.unknownKeys==="strip"))for(let l in o.data)i.includes(l)||a.push(l);let c=[];for(let l of i){let p=s[l],d=o.data[l];c.push({key:{status:"valid",value:l},value:p._parse(new Er(o,d,o.path,l)),alwaysSet:l in o.data})}if(this._def.catchall instanceof Br){let l=this._def.unknownKeys;if(l==="passthrough")for(let p of a)c.push({key:{status:"valid",value:p},value:{status:"valid",value:o.data[p]}});else if(l==="strict")a.length>0&&(M(o,{code:N.unrecognized_keys,keys:a}),r.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let l=this._def.catchall;for(let p of a){let d=o.data[p];c.push({key:{status:"valid",value:p},value:l._parse(new Er(o,d,o.path,p)),alwaysSet:p in o.data})}}return o.common.async?Promise.resolve().then(async()=>{let l=[];for(let p of c){let d=await p.key,_=await p.value;l.push({key:d,value:_,alwaysSet:p.alwaysSet})}return l}).then(l=>Ft.mergeObjectSync(r,l)):Ft.mergeObjectSync(r,c)}get shape(){return this._def.shape()}strict(e){return j.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(n,r)=>{let o=this._def.errorMap?.(n,r).message??r.defaultError;return n.code==="unrecognized_keys"?{message:j.errToObj(e).message??o}:{message:o}}}:{}})}strip(){return new t({...this._def,unknownKeys:"strip"})}passthrough(){return new t({...this._def,unknownKeys:"passthrough"})}extend(e){return new t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:Z.ZodObject})}setKey(e,n){return this.augment({[e]:n})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let n={};for(let r of de.objectKeys(e))e[r]&&this.shape[r]&&(n[r]=this.shape[r]);return new t({...this._def,shape:()=>n})}omit(e){let n={};for(let r of de.objectKeys(this.shape))e[r]||(n[r]=this.shape[r]);return new t({...this._def,shape:()=>n})}deepPartial(){return ll(this)}partial(e){let n={};for(let r of de.objectKeys(this.shape)){let o=this.shape[r];e&&!e[r]?n[r]=o:n[r]=o.optional()}return new t({...this._def,shape:()=>n})}required(e){let n={};for(let r of de.objectKeys(this.shape))if(e&&!e[r])n[r]=this.shape[r];else{let s=this.shape[r];for(;s instanceof Tr;)s=s._def.innerType;n[r]=s}return new t({...this._def,shape:()=>n})}keyof(){return y3(de.objectKeys(this.shape))}};Ln.create=(t,e)=>new Ln({shape:()=>t,unknownKeys:"strip",catchall:Br.create(),typeName:Z.ZodObject,...ie(e)});Ln.strictCreate=(t,e)=>new Ln({shape:()=>t,unknownKeys:"strict",catchall:Br.create(),typeName:Z.ZodObject,...ie(e)});Ln.lazycreate=(t,e)=>new Ln({shape:t,unknownKeys:"strip",catchall:Br.create(),typeName:Z.ZodObject,...ie(e)});var La=class extends ce{_parse(e){let{ctx:n}=this._processInputParams(e),r=this._def.options;function o(s){for(let a of s)if(a.result.status==="valid")return a.result;for(let a of s)if(a.result.status==="dirty")return n.common.issues.push(...a.ctx.common.issues),a.result;let i=s.map(a=>new vn(a.ctx.common.issues));return M(n,{code:N.invalid_union,unionErrors:i}),Q}if(n.common.async)return Promise.all(r.map(async s=>{let i={...n,common:{...n.common,issues:[]},parent:null};return{result:await s._parseAsync({data:n.data,path:n.path,parent:i}),ctx:i}})).then(o);{let s,i=[];for(let c of r){let l={...n,common:{...n.common,issues:[]},parent:null},p=c._parseSync({data:n.data,path:n.path,parent:l});if(p.status==="valid")return p;p.status==="dirty"&&!s&&(s={result:p,ctx:l}),l.common.issues.length&&i.push(l.common.issues)}if(s)return n.common.issues.push(...s.ctx.common.issues),s.result;let a=i.map(c=>new vn(c));return M(n,{code:N.invalid_union,unionErrors:a}),Q}}get options(){return this._def.options}};La.create=(t,e)=>new La({options:t,typeName:Z.ZodUnion,...ie(e)});var ns=t=>t instanceof Ua?ns(t.schema):t instanceof Sr?ns(t.innerType()):t instanceof wa?[t.value]:t instanceof ka?t.options:t instanceof Ga?de.objectValues(t.enum):t instanceof Ba?ns(t._def.innerType):t instanceof xa?[void 0]:t instanceof va?[null]:t instanceof Tr?[void 0,...ns(t.unwrap())]:t instanceof Ro?[null,...ns(t.unwrap())]:t instanceof Zd||t instanceof Ha?ns(t.unwrap()):t instanceof ja?ns(t._def.innerType):[],$S=class t extends ce{_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==D.object)return M(n,{code:N.invalid_type,expected:D.object,received:n.parsedType}),Q;let r=this.discriminator,o=n.data[r],s=this.optionsMap.get(o);return s?n.common.async?s._parseAsync({data:n.data,path:n.path,parent:n}):s._parseSync({data:n.data,path:n.path,parent:n}):(M(n,{code:N.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),Q)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,n,r){let o=new Map;for(let s of n){let i=ns(s.shape[e]);if(!i.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let a of i){if(o.has(a))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);o.set(a,s)}}return new t({typeName:Z.ZodDiscriminatedUnion,discriminator:e,options:n,optionsMap:o,...ie(r)})}};function _C(t,e){let n=go(t),r=go(e);if(t===e)return{valid:!0,data:t};if(n===D.object&&r===D.object){let o=de.objectKeys(e),s=de.objectKeys(t).filter(a=>o.indexOf(a)!==-1),i={...t,...e};for(let a of s){let c=_C(t[a],e[a]);if(!c.valid)return{valid:!1};i[a]=c.data}return{valid:!0,data:i}}else if(n===D.array&&r===D.array){if(t.length!==e.length)return{valid:!1};let o=[];for(let s=0;s<t.length;s++){let i=t[s],a=e[s],c=_C(i,a);if(!c.valid)return{valid:!1};o.push(c.data)}return{valid:!0,data:o}}else return n===D.date&&r===D.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}var Da=class extends ce{_parse(e){let{status:n,ctx:r}=this._processInputParams(e),o=(s,i)=>{if(VS(s)||VS(i))return Q;let a=_C(s.value,i.value);return a.valid?((qS(s)||qS(i))&&n.dirty(),{status:n.value,value:a.data}):(M(r,{code:N.invalid_intersection_types}),Q)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([s,i])=>o(s,i)):o(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}};Da.create=(t,e,n)=>new Da({left:t,right:e,typeName:Z.ZodIntersection,...ie(n)});var Ao=class t extends ce{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==D.array)return M(r,{code:N.invalid_type,expected:D.array,received:r.parsedType}),Q;if(r.data.length<this._def.items.length)return M(r,{code:N.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Q;!this._def.rest&&r.data.length>this._def.items.length&&(M(r,{code:N.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());let s=[...r.data].map((i,a)=>{let c=this._def.items[a]||this._def.rest;return c?c._parse(new Er(r,i,r.path,a)):null}).filter(i=>!!i);return r.common.async?Promise.all(s).then(i=>Ft.mergeArray(n,i)):Ft.mergeArray(n,s)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};Ao.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Ao({items:t,typeName:Z.ZodTuple,rest:null,...ie(e)})};var YS=class t extends ce{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==D.object)return M(r,{code:N.invalid_type,expected:D.object,received:r.parsedType}),Q;let o=[],s=this._def.keyType,i=this._def.valueType;for(let a in r.data)o.push({key:s._parse(new Er(r,a,r.path,a)),value:i._parse(new Er(r,r.data[a],r.path,a)),alwaysSet:a in r.data});return r.common.async?Ft.mergeObjectAsync(n,o):Ft.mergeObjectSync(n,o)}get element(){return this._def.valueType}static create(e,n,r){return n instanceof ce?new t({keyType:e,valueType:n,typeName:Z.ZodRecord,...ie(r)}):new t({keyType:hi.create(),valueType:e,typeName:Z.ZodRecord,...ie(n)})}},_l=class extends ce{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==D.map)return M(r,{code:N.invalid_type,expected:D.map,received:r.parsedType}),Q;let o=this._def.keyType,s=this._def.valueType,i=[...r.data.entries()].map(([a,c],l)=>({key:o._parse(new Er(r,a,r.path,[l,"key"])),value:s._parse(new Er(r,c,r.path,[l,"value"]))}));if(r.common.async){let a=new Map;return Promise.resolve().then(async()=>{for(let c of i){let l=await c.key,p=await c.value;if(l.status==="aborted"||p.status==="aborted")return Q;(l.status==="dirty"||p.status==="dirty")&&n.dirty(),a.set(l.value,p.value)}return{status:n.value,value:a}})}else{let a=new Map;for(let c of i){let l=c.key,p=c.value;if(l.status==="aborted"||p.status==="aborted")return Q;(l.status==="dirty"||p.status==="dirty")&&n.dirty(),a.set(l.value,p.value)}return{status:n.value,value:a}}}};_l.create=(t,e,n)=>new _l({valueType:e,keyType:t,typeName:Z.ZodMap,...ie(n)});var fl=class t extends ce{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==D.set)return M(r,{code:N.invalid_type,expected:D.set,received:r.parsedType}),Q;let o=this._def;o.minSize!==null&&r.data.size<o.minSize.value&&(M(r,{code:N.too_small,minimum:o.minSize.value,type:"set",inclusive:!0,exact:!1,message:o.minSize.message}),n.dirty()),o.maxSize!==null&&r.data.size>o.maxSize.value&&(M(r,{code:N.too_big,maximum:o.maxSize.value,type:"set",inclusive:!0,exact:!1,message:o.maxSize.message}),n.dirty());let s=this._def.valueType;function i(c){let l=new Set;for(let p of c){if(p.status==="aborted")return Q;p.status==="dirty"&&n.dirty(),l.add(p.value)}return{status:n.value,value:l}}let a=[...r.data.values()].map((c,l)=>s._parse(new Er(r,c,r.path,l)));return r.common.async?Promise.all(a).then(c=>i(c)):i(a)}min(e,n){return new t({...this._def,minSize:{value:e,message:j.toString(n)}})}max(e,n){return new t({...this._def,maxSize:{value:e,message:j.toString(n)}})}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}};fl.create=(t,e)=>new fl({valueType:t,minSize:null,maxSize:null,typeName:Z.ZodSet,...ie(e)});var WS=class t extends ce{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==D.function)return M(n,{code:N.invalid_type,expected:D.function,received:n.parsedType}),Q;function r(a,c){return Jd({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,cl(),ts].filter(l=>!!l),issueData:{code:N.invalid_arguments,argumentsError:c}})}function o(a,c){return Jd({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,cl(),ts].filter(l=>!!l),issueData:{code:N.invalid_return_type,returnTypeError:c}})}let s={errorMap:n.common.contextualErrorMap},i=n.data;if(this._def.returns instanceof Ei){let a=this;return nn(async function(...c){let l=new vn([]),p=await a._def.args.parseAsync(c,s).catch(f=>{throw l.addIssue(r(c,f)),l}),d=await Reflect.apply(i,this,p);return await a._def.returns._def.type.parseAsync(d,s).catch(f=>{throw l.addIssue(o(d,f)),l})})}else{let a=this;return nn(function(...c){let l=a._def.args.safeParse(c,s);if(!l.success)throw new vn([r(c,l.error)]);let p=Reflect.apply(i,this,l.data),d=a._def.returns.safeParse(p,s);if(!d.success)throw new vn([o(p,d.error)]);return d.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:Ao.create(e).rest(rs.create())})}returns(e){return new t({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,n,r){return new t({args:e||Ao.create([]).rest(rs.create()),returns:n||rs.create(),typeName:Z.ZodFunction,...ie(r)})}},Ua=class extends ce{get schema(){return this._def.getter()}_parse(e){let{ctx:n}=this._processInputParams(e);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}};Ua.create=(t,e)=>new Ua({getter:t,typeName:Z.ZodLazy,...ie(e)});var wa=class extends ce{_parse(e){if(e.data!==this._def.value){let n=this._getOrReturnCtx(e);return M(n,{received:n.data,code:N.invalid_literal,expected:this._def.value}),Q}return{status:"valid",value:e.data}}get value(){return this._def.value}};wa.create=(t,e)=>new wa({value:t,typeName:Z.ZodLiteral,...ie(e)});function y3(t,e){return new ka({values:t,typeName:Z.ZodEnum,...ie(e)})}var ka=class t extends ce{_parse(e){if(typeof e.data!="string"){let n=this._getOrReturnCtx(e),r=this._def.values;return M(n,{expected:de.joinValues(r),received:n.parsedType,code:N.invalid_type}),Q}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let n=this._getOrReturnCtx(e),r=this._def.values;return M(n,{received:n.data,code:N.invalid_enum_value,options:r}),Q}return nn(e.data)}get options(){return this._def.values}get enum(){let e={};for(let n of this._def.values)e[n]=n;return e}get Values(){let e={};for(let n of this._def.values)e[n]=n;return e}get Enum(){let e={};for(let n of this._def.values)e[n]=n;return e}extract(e,n=this._def){return t.create(e,{...this._def,...n})}exclude(e,n=this._def){return t.create(this.options.filter(r=>!e.includes(r)),{...this._def,...n})}};ka.create=y3;var Ga=class extends ce{_parse(e){let n=de.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==D.string&&r.parsedType!==D.number){let o=de.objectValues(n);return M(r,{expected:de.joinValues(o),received:r.parsedType,code:N.invalid_type}),Q}if(this._cache||(this._cache=new Set(de.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let o=de.objectValues(n);return M(r,{received:r.data,code:N.invalid_enum_value,options:o}),Q}return nn(e.data)}get enum(){return this._def.values}};Ga.create=(t,e)=>new Ga({values:t,typeName:Z.ZodNativeEnum,...ie(e)});var Ei=class extends ce{unwrap(){return this._def.type}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==D.promise&&n.common.async===!1)return M(n,{code:N.invalid_type,expected:D.promise,received:n.parsedType}),Q;let r=n.parsedType===D.promise?n.data:Promise.resolve(n.data);return nn(r.then(o=>this._def.type.parseAsync(o,{path:n.path,errorMap:n.common.contextualErrorMap})))}};Ei.create=(t,e)=>new Ei({type:t,typeName:Z.ZodPromise,...ie(e)});var Sr=class extends ce{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Z.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:n,ctx:r}=this._processInputParams(e),o=this._def.effect||null,s={addIssue:i=>{M(r,i),i.fatal?n.abort():n.dirty()},get path(){return r.path}};if(s.addIssue=s.addIssue.bind(s),o.type==="preprocess"){let i=o.transform(r.data,s);if(r.common.async)return Promise.resolve(i).then(async a=>{if(n.value==="aborted")return Q;let c=await this._def.schema._parseAsync({data:a,path:r.path,parent:r});return c.status==="aborted"?Q:c.status==="dirty"?Na(c.value):n.value==="dirty"?Na(c.value):c});{if(n.value==="aborted")return Q;let a=this._def.schema._parseSync({data:i,path:r.path,parent:r});return a.status==="aborted"?Q:a.status==="dirty"?Na(a.value):n.value==="dirty"?Na(a.value):a}}if(o.type==="refinement"){let i=a=>{let c=o.refinement(a,s);if(r.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(r.common.async===!1){let a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?Q:(a.status==="dirty"&&n.dirty(),i(a.value),{status:n.value,value:a.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>a.status==="aborted"?Q:(a.status==="dirty"&&n.dirty(),i(a.value).then(()=>({status:n.value,value:a.value}))))}if(o.type==="transform")if(r.common.async===!1){let i=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!mi(i))return Q;let a=o.transform(i.value,s);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:a}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(i=>mi(i)?Promise.resolve(o.transform(i.value,s)).then(a=>({status:n.value,value:a})):Q);de.assertNever(o)}};Sr.create=(t,e,n)=>new Sr({schema:t,typeName:Z.ZodEffects,effect:e,...ie(n)});Sr.createWithPreprocess=(t,e,n)=>new Sr({schema:e,effect:{type:"preprocess",transform:t},typeName:Z.ZodEffects,...ie(n)});var Tr=class extends ce{_parse(e){return this._getType(e)===D.undefined?nn(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Tr.create=(t,e)=>new Tr({innerType:t,typeName:Z.ZodOptional,...ie(e)});var Ro=class extends ce{_parse(e){return this._getType(e)===D.null?nn(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Ro.create=(t,e)=>new Ro({innerType:t,typeName:Z.ZodNullable,...ie(e)});var Ba=class extends ce{_parse(e){let{ctx:n}=this._processInputParams(e),r=n.data;return n.parsedType===D.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}};Ba.create=(t,e)=>new Ba({innerType:t,typeName:Z.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...ie(e)});var ja=class extends ce{_parse(e){let{ctx:n}=this._processInputParams(e),r={...n,common:{...n.common,issues:[]}},o=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return ul(o)?o.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new vn(r.common.issues)},input:r.data})})):{status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new vn(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}};ja.create=(t,e)=>new ja({innerType:t,typeName:Z.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...ie(e)});var ml=class extends ce{_parse(e){if(this._getType(e)!==D.nan){let r=this._getOrReturnCtx(e);return M(r,{code:N.invalid_type,expected:D.nan,received:r.parsedType}),Q}return{status:"valid",value:e.data}}};ml.create=t=>new ml({typeName:Z.ZodNaN,...ie(t)});var uNe=Symbol("zod_brand"),Zd=class extends ce{_parse(e){let{ctx:n}=this._processInputParams(e),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}},e_=class t extends ce{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{let s=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?Q:s.status==="dirty"?(n.dirty(),Na(s.value)):this._def.out._parseAsync({data:s.value,path:r.path,parent:r})})();{let o=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return o.status==="aborted"?Q:o.status==="dirty"?(n.dirty(),{status:"dirty",value:o.value}):this._def.out._parseSync({data:o.value,path:r.path,parent:r})}}static create(e,n){return new t({in:e,out:n,typeName:Z.ZodPipeline})}},Ha=class extends ce{_parse(e){let n=this._def.innerType._parse(e),r=o=>(mi(o)&&(o.value=Object.freeze(o.value)),o);return ul(n)?n.then(o=>r(o)):r(n)}unwrap(){return this._def.innerType}};Ha.create=(t,e)=>new Ha({innerType:t,typeName:Z.ZodReadonly,...ie(e)});function S3(t,e){let n=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof n=="string"?{message:n}:n}function I3(t,e={},n){return t?Ti.create().superRefine((r,o)=>{let s=t(r);if(s instanceof Promise)return s.then(i=>{if(!i){let a=S3(e,r),c=a.fatal??n??!0;o.addIssue({code:"custom",...a,fatal:c})}});if(!s){let i=S3(e,r),a=i.fatal??n??!0;o.addIssue({code:"custom",...i,fatal:a})}}):Ti.create()}var lNe={object:Ln.lazycreate},Z;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(Z||(Z={}));var pNe=(t,e={message:`Input not instance of ${t.name}`})=>I3(n=>n instanceof t,e),O3=hi.create,N3=ba.create,dNe=ml.create,_Ne=Ca.create,b3=Pa.create,fNe=Ma.create,mNe=pl.create,hNe=xa.create,TNe=va.create,ENe=Ti.create,SNe=rs.create,gNe=Br.create,ANe=dl.create,RNe=os.create,yNe=Ln.create,INe=Ln.strictCreate,ONe=La.create,NNe=$S.create,bNe=Da.create,CNe=Ao.create,PNe=YS.create,MNe=_l.create,xNe=fl.create,vNe=WS.create,LNe=Ua.create,DNe=wa.create,UNe=ka.create,wNe=Ga.create,kNe=Ei.create,GNe=Sr.create,BNe=Tr.create,jNe=Ro.create,HNe=Sr.createWithPreprocess,FNe=e_.create,VNe=()=>O3().optional(),qNe=()=>N3().optional(),$Ne=()=>b3().optional(),YNe={string:t=>hi.create({...t,coerce:!0}),number:t=>ba.create({...t,coerce:!0}),boolean:t=>Pa.create({...t,coerce:!0}),bigint:t=>Ca.create({...t,coerce:!0}),date:t=>Ma.create({...t,coerce:!0})};var WNe=Q;var zNe=t=>typeof t?.safeParse=="function";var fC=t=>typeof t?.passthrough=="function";var KNe=(t,e)=>fC(t)?fC(e)?t.merge(e):t:fC(e)?e:Object.assign({},t,e);var p5e=u.object({name:u.literal("ZodError"),issues:u.array(u.object({path:u.array(u.union([u.string(),u.number()])),message:u.string().optional(),code:u.nativeEnum(u.ZodIssueCode)}).catchall(u.any()))}),QNe=Symbol("ContractNoBody"),P3=t=>"method"in t&&"path"in t;var M3=(t,e)=>Object.fromEntries(Object.entries(t).map(([n,r])=>{var o,s,i;return P3(r)?[n,{...r,path:e?.pathPrefix?e.pathPrefix+r.path:r.path,headers:KNe(e?.baseHeaders,r.headers),strictStatusCodes:(o=r.strictStatusCodes)!==null&&o!==void 0?o:e?.strictStatusCodes,validateResponseOnClient:(s=r.validateResponseOnClient)!==null&&s!==void 0?s:e?.validateResponseOnClient,responses:{...e?.commonResponses,...r.responses},metadata:e?.metadata?{...e?.metadata,...(i=r.metadata)!==null&&i!==void 0?i:{}}:r.metadata}]:[n,M3(r,e)]})),mC=Symbol("ContractPlainType"),gr=()=>({router:(t,e)=>M3(t,e),query:t=>t,mutation:t=>t,responses:t=>t,response:()=>mC,body:()=>mC,type:()=>mC,otherResponse:({contentType:t,body:e})=>({contentType:t,body:e}),noBody:()=>QNe}),XNe=({path:t,params:e})=>{let n=e;return t.replace(/\/?:([^/?]+)\??/g,(r,o)=>n[o]?`${r.startsWith("/")?"/":""}${n[o]}`:"")},JNe=(t,e=!1)=>{let n=e?ZNe(t):ebe(t);return n?.length>0?"?"+n:""},ZNe=t=>t?Object.entries(t).filter(([,e])=>e!==void 0).map(([e,n])=>{let r;return typeof n=="string"&&!["true","false","null"].includes(n.trim())&&isNaN(Number(n))?r=n:r=JSON.stringify(n),`${encodeURIComponent(e)}=${encodeURIComponent(r)}`}).join("&"):"",ebe=t=>t?Object.keys(t).flatMap(e=>hC(e,t[e])).map(([e,n])=>`${encodeURIComponent(e)}=${encodeURIComponent(n)}`).join("&"):"",hC=(t,e)=>Array.isArray(e)?e.flatMap((n,r)=>hC(`${t}[${r}]`,n)):e instanceof Date?[[`${t}`,e.toISOString()]]:e===null?[[`${t}`,""]]:e===void 0?[]:typeof e=="object"?Object.keys(e).flatMap(n=>hC(`${t}[${n}]`,e[n])):[[`${t}`,`${e}`]];var TC=class extends Error{constructor(e,n){let r=n.join(",");super(`Server returned unexpected response. Expected one of: ${r} got: ${e.status}`),this.response=e}};var tbe=async({route:t,path:e,method:n,headers:r,body:o,validateResponse:s,fetchOptions:i})=>{let a=await fetch(e,{...i,method:n,headers:r,body:o}),c=a.headers.get("content-type");if(c?.includes("application/")&&c?.includes("json")){let l={status:a.status,body:await a.json(),headers:a.headers},p=t.responses[l.status];return(s??t.validateResponseOnClient)&&zNe(p)?{...l,body:p.parse(l.body)}:l}return c?.includes("text/")?{status:a.status,body:await a.text(),headers:a.headers}:{status:a.status,body:await a.blob(),headers:a.headers}},nbe=t=>{let e=new FormData,n=(r,o)=>{o instanceof File?e.append(r,o):e.append(r,JSON.stringify(o))};return Object.entries(t).forEach(([r,o])=>{if(Array.isArray(o))for(let s of o)n(r,s);else n(r,o)}),e},C3=t=>Object.fromEntries(Object.entries(t).map(([e,n])=>[e.toLowerCase(),n])),rbe=t=>{let{path:e,clientArgs:n,route:r,body:o,query:s,extraInputArgs:i,headers:a,fetchOptions:c}=t,l=n.api||tbe,p=n.baseHeaders&&Object.fromEntries(Object.entries(n.baseHeaders).map(([f,m])=>typeof m=="function"?[f,m(t)]:[f,m])),d={...p&&C3(p),...C3(a)};Object.keys(d).forEach(f=>{d[f]===void 0&&delete d[f]});let _={route:r,path:e,method:r.method,headers:d,body:void 0,rawBody:o,rawQuery:s,contentType:void 0,validateResponse:n.validateResponse,fetchOptions:{...n.credentials&&{credentials:n.credentials},...c},...c?.signal&&{signal:c.signal},...c?.cache&&{cache:c.cache},...c&&"next"in c&&!!c?.next&&{next:c.next}};return r.method!=="GET"&&("contentType"in r&&r.contentType==="multipart/form-data"?_={..._,contentType:"multipart/form-data",body:o instanceof FormData?o:nbe(o)}:"contentType"in r&&r.contentType==="application/x-www-form-urlencoded"?_={..._,contentType:"application/x-www-form-urlencoded",headers:{"content-type":"application/x-www-form-urlencoded",..._.headers},body:typeof o=="string"?o:new URLSearchParams(o)}:o!=null&&(_={..._,contentType:"application/json",headers:{"content-type":"application/json",..._.headers},body:JSON.stringify(o)})),l({..._,...i})},obe=(t,e,n)=>{let{query:r,params:o,body:s,headers:i,extraHeaders:a,overrideClientOptions:c,fetchOptions:l,cache:p,next:d,..._}=n||{},f={...e,...c};return{path:sbe(r,f.baseUrl,o,t,!!f.jsonQuery),clientArgs:f,route:t,body:s,query:r,extraInputArgs:_,fetchOptions:{...p&&{cache:p},...d&&{next:d},...l},headers:{...a,...i}}},sbe=(t,e,n,r,o)=>{let s=XNe({path:r.path,params:n}),i=JNe(t,o);return`${e}${s}${i}`},ibe=(t,e)=>{let n=Object.keys(t.responses);return async r=>{let o=obe(t,e,r),s=await rbe(o);if(!e.throwOnUnknownStatus||n.includes(s.status.toString()))return s;throw new TC(s,n)}},EC=(t,e)=>Object.fromEntries(Object.entries(t).map(([n,r])=>P3(r)?[n,ibe(r,e)]:[n,EC(r,e)]));var SC=["free","creator","team"],x3=typeof process<"u"&&process.env?.NODE_ENV!=="production",abe={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:x3?"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:x3?"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 v3=abe.stripe.plans,_5e=Object.freeze(Object.fromEntries(v3.map(t=>[t.tier,t])));var cbe=gr(),rn=u.object({message:u.string()}),gC=u.record(u.unknown()),Fa=u.string().regex(/^doc_[0-9A-Za-z]{22}$/),zS=u.string().regex(/^proj_[0-9A-Za-z]{22}$/),ube=["active","archived"],KS=u.enum(ube),L3=u.object({id:u.string().min(1),display_name:u.string().min(1)}),D3=u.object({id:zS,name:u.string().min(1)}),AC=u.object({id:Fa,title:u.string().min(1),status:KS,author:L3,project:D3.nullable(),created_at:u.string().datetime(),updated_at:u.string().datetime(),archived_at:u.string().datetime().nullable()}),lbe=u.object({type:u.literal("list"),list_type:u.literal("doc"),objects:u.array(AC)}),pbe=u.object({project_id:zS.optional(),status:KS.optional()}),dbe=u.object({title:u.string().trim().min(1).max(300).optional(),prosemirror_json:gC.optional(),project_id:zS.nullable().optional()}),_be=u.object({id:Fa,created_at:u.string().datetime()}),fbe=u.object({title:u.string().trim().min(1).max(300).optional(),prosemirror_json:gC.optional(),project_id:zS.nullable().optional(),status:KS.optional()}).refine(t=>Object.keys(t).length>0,{message:"At least one field must be provided"}),mbe=u.object({id:Fa,updated_at:u.string().datetime()}),hbe=u.object({id:Fa,title:u.string().min(1),prosemirror_json:gC,status:KS,author:L3,project:D3.nullable(),created_at:u.string().datetime(),updated_at:u.string().datetime(),archived_at:u.string().datetime().nullable()}),U3=cbe.router({listDocs:{method:"GET",path:"/docs",headers:u.object({authorization:u.string().min(1).optional()}),query:pbe,responses:{200:lbe,401:rn,403:rn},summary:"List docs in the authenticated user\u2019s organization. Optional project_id filter scopes to a single project."},createDoc:{method:"POST",path:"/docs",headers:u.object({authorization:u.string().min(1).optional()}),body:dbe,responses:{201:_be,401:rn,403:rn,404:rn,422:rn},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:u.object({docId:Fa}),headers:u.object({authorization:u.string().min(1).optional()}),responses:{200:hbe,401:rn,403:rn,404:rn},summary:"Get a doc by id with its rich-text body and parent project (if any)"},updateDoc:{method:"PATCH",path:"/docs/:docId",pathParams:u.object({docId:Fa}),headers:u.object({authorization:u.string().min(1).optional()}),body:fbe,responses:{200:mbe,401:rn,403:rn,404:rn,422:rn},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:u.object({docId:Fa}),headers:u.object({authorization:u.string().min(1).optional()}),body:u.object({}).optional(),responses:{204:u.object({}),401:rn,403:rn,404:rn},summary:"Hard-delete a doc and any mention references it owns"}});var Tbe=gr(),et=u.object({message:u.string()}),RC=u.record(u.unknown()),yo=u.string().regex(/^proj_[0-9A-Za-z]{22}$/),Ebe=["active","archived"],QS=u.enum(Ebe),yC=u.object({id:u.string().min(1),display_name:u.string().min(1)}),w3=u.object({thread_id:u.string().min(1),title:u.string().min(1),added_at:u.string().datetime(),added_by:yC}),Sbe=u.object({id:yo,name:u.string().min(1),status:QS,author:yC,thread_count:u.number().int().nonnegative(),doc_count:u.number().int().nonnegative(),created_at:u.string().datetime(),updated_at:u.string().datetime(),archived_at:u.string().datetime().nullable()}),gbe=u.object({type:u.literal("list"),list_type:u.literal("project"),objects:u.array(Sbe)}),Abe=u.object({status:QS.optional()}),Rbe=u.object({name:u.string().trim().min(1).max(200),prosemirror_json:RC.optional()}),ybe=u.object({id:yo,created_at:u.string().datetime()}),Ibe=u.object({name:u.string().trim().min(1).max(200).optional(),prosemirror_json:RC.optional()}).refine(t=>Object.keys(t).length>0,{message:"At least one field must be provided"}),Obe=u.object({id:yo,updated_at:u.string().datetime()}),Nbe=u.object({archived:u.boolean()}),bbe=u.object({id:yo,status:QS,archived_at:u.string().datetime().nullable()}),Cbe=u.object({id:yo,name:u.string().min(1),prosemirror_json:RC,status:QS,author:yC,created_at:u.string().datetime(),updated_at:u.string().datetime(),archived_at:u.string().datetime().nullable(),threads:u.array(w3),docs:u.array(AC)}),Pbe=u.object({thread_id:u.string().min(1).max(64)}),Mbe=w3,k3=Tbe.router({listProjects:{method:"GET",path:"/projects",headers:u.object({authorization:u.string().min(1).optional()}),query:Abe,responses:{200:gbe,401:et},summary:"List projects in the authenticated user\u2019s organization"},createProject:{method:"POST",path:"/projects",headers:u.object({authorization:u.string().min(1).optional()}),body:Rbe,responses:{201:ybe,401:et,422:et},summary:"Create a new project in the authenticated user\u2019s organization"},getProject:{method:"GET",path:"/projects/:projectId",pathParams:u.object({projectId:yo}),headers:u.object({authorization:u.string().min(1).optional()}),responses:{200:Cbe,401:et,403:et,404:et},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:u.object({projectId:yo}),headers:u.object({authorization:u.string().min(1).optional()}),body:Ibe,responses:{200:Obe,401:et,403:et,404:et,422:et},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:u.object({projectId:yo}),headers:u.object({authorization:u.string().min(1).optional()}),body:Nbe,responses:{200:bbe,401:et,403:et,404:et},summary:"Archive (soft-delete) or unarchive a project"},addProjectThread:{method:"POST",path:"/projects/:projectId/threads",pathParams:u.object({projectId:yo}),headers:u.object({authorization:u.string().min(1).optional()}),body:Pbe,responses:{201:Mbe,401:et,403:et,404:et,409:et,422:et},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:u.object({projectId:yo,threadId:u.string().min(1).max(64)}),headers:u.object({authorization:u.string().min(1).optional()}),body:u.object({}).optional(),responses:{204:u.object({}),401:et,403:et,404:et},summary:"Remove a thread membership from a project"}});var xbe=gr(),XS=u.object({message:u.string()}),vbe=["thread","plan","doc","user"],JS=u.enum(vbe),Lbe=["doc","project"],Dbe=u.enum(Lbe),Ube=u.object({kind:JS,id:u.string().min(1),title:u.string().min(1),href:u.string().min(1)}),wbe=u.object({type:u.literal("list"),list_type:u.literal("mention"),objects:u.array(Ube)}),kbe=u.object({q:u.string().trim().min(1).max(50),kinds:u.string().optional().transform(t=>{if(!t)return;let e=t.split(",").map(n=>n.trim()).filter(n=>n.length>0);return e.length>0?e:void 0}).pipe(u.array(JS).optional())}),Gbe=u.object({source_kind:Dbe,source_id:u.string().min(1),source_title:u.string().min(1),source_href:u.string().min(1),target_kind:JS,target_id:u.string().min(1),created_at:u.string().datetime()}),Bbe=u.object({type:u.literal("list"),list_type:u.literal("backlink"),objects:u.array(Gbe)}),jbe=u.object({target_kind:JS,target_id:u.string().min(1).max(64)}),G3=xbe.router({searchMentions:{method:"GET",path:"/mentions/search",headers:u.object({authorization:u.string().min(1).optional()}),query:kbe,responses:{200:wbe,401:XS,422:XS},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:u.object({authorization:u.string().min(1).optional()}),query:jbe,responses:{200:Bbe,401:XS,403:XS},summary:"List every doc/project body in the caller\u2019s organization that mentions the given target. Newest-first."}});var Hbe=gr(),Fbe=u.object({type:u.literal("list"),list_type:u.literal("thread"),has_more:u.boolean(),objects:u.array(u.unknown())}),Si=u.object({message:u.string()}),B3=u.object({thread_id:u.string().min(1),is_favorited:u.boolean(),favorited_at:u.string().datetime().nullable()}),Vbe=u.object({before:u.string().min(1).max(64).optional()}),j3=Hbe.router({addThreadFavorite:{method:"POST",path:"/threads/:id/favorite",pathParams:u.object({id:u.string().min(1).max(64)}),headers:u.object({authorization:u.string().min(1).optional()}),body:u.object({}).optional(),responses:{201:B3,401:Si,403:Si,404:Si},summary:"Bookmark a thread for the authenticated user. Idempotent \u2014 re-favoriting returns the existing membership."},removeThreadFavorite:{method:"DELETE",path:"/threads/:id/favorite",pathParams:u.object({id:u.string().min(1).max(64)}),headers:u.object({authorization:u.string().min(1).optional()}),body:u.object({}).optional(),responses:{200:B3,401:Si,403:Si,404:Si},summary:"Remove a thread bookmark for the authenticated user (no-op if absent)."},listFavoriteThreads:{method:"GET",path:"/favorites/threads",headers:u.object({authorization:u.string().min(1).optional()}),query:Vbe,responses:{200:Fbe,401:Si,403:Si},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 qbe=gr(),IC=u.object({message:u.string()}),$be=u.object({id:u.string().min(1),title:u.string(),href:u.string().min(1),author_display_name:u.string().nullable(),author_handle:u.string().nullable()}),Ybe=u.object({name:u.string().min(1),usage_count:u.number().int().nonnegative(),href:u.string().min(1)}),Wbe=u.object({id:u.string().min(1),display_name:u.string(),handle:u.string().nullable(),avatar_url:u.string().nullable(),href:u.string().min(1)}),zbe=u.object({type:u.literal("global_search"),threads:u.array($be),skills:u.array(Ybe),people:u.array(Wbe)}),Kbe=u.object({q:u.string().trim().min(1).max(80)}),H3=qbe.router({globalSearch:{method:"GET",path:"/search",headers:u.object({authorization:u.string().min(1).optional()}),query:Kbe,responses:{200:zbe,401:IC,403:IC,422:IC},summary:"Global navbar search across threads, skills, and people. Org-scoped, max 5 results per kind."}});var Qbe=gr(),Xbe=u.object({id:u.string().uuid(),role:u.enum(["user","assistant"]),content:u.string().min(1),timestamp:u.string().datetime()}),Jbe=u.object({id:u.string().uuid(),title:u.string().min(1),author:u.string().min(1),authorAvatar:u.string().min(1).max(4),model:u.string().min(1),turnCount:u.number().int().nonnegative(),createdAt:u.string().datetime(),preview:u.string()}),Q5e=Jbe.extend({messages:u.array(Xbe)}),A=u.object({message:u.string()}),Zbe=/^[a-zA-Z0-9_-]{2,32}$/,K3=u.string().regex(Zbe,"Handle must be 2\u201332 characters: letters, numbers, dashes, or underscores."),OC=u.object({id:u.string(),first_name:u.string().min(1),last_name:u.string().min(1),display_name:u.string().min(1),stytch_id:u.string().nullable(),handle:u.string().nullable(),bio:u.string().max(280).nullable(),avatar_url:u.string().nullable(),banner_url:u.string().nullable(),share_new_threads_to_workspace:u.boolean(),experimental_features_enabled:u.boolean(),onboarded_at:u.string().nullable()}),eCe=u.object({stytchMemberId:u.string().min(1).optional(),emailAddress:u.string().email(),name:u.string().nullable(),user:OC,is_admin:u.boolean()}),tCe=u.object({share_new_threads_to_workspace:u.boolean().optional(),experimental_features_enabled:u.boolean().optional(),onboarded_at:u.union([u.literal("now"),u.null()]).optional(),display_name:u.string().min(1).max(120).optional(),handle:K3.optional(),bio:u.string().max(280).nullable().optional(),avatar_storage_url:u.string().min(1).nullable().optional(),banner_storage_url:u.string().min(1).nullable().optional()}).refine(t=>Object.keys(t).length>0,{message:"At least one field must be provided"}),nCe=u.object({id:u.string(),display_name:u.string(),handle:u.string().nullable(),avatar_url:u.string().nullable(),visible_thread_count:u.number().int().nonnegative(),last_active_at:u.string().datetime().nullable()}),Q3=u.object({id:u.string().min(1),display_name:u.string().min(1),handle:u.string().nullable(),bio:u.string().max(280).nullable(),avatar_url:u.string().nullable(),banner_url:u.string().nullable(),organization_name:u.string().min(1).nullable(),created_at:u.string().min(1),visible_thread_count:u.number().int().nonnegative(),follower_count:u.number().int().nonnegative(),following_count:u.number().int().nonnegative(),published_project_count:u.number().int().nonnegative(),is_following:u.boolean(),is_self:u.boolean()}),rCe=u.object({type:u.literal("list"),list_type:u.literal("organization_member"),objects:u.array(nCe)}),oCe=u.object({email_address:u.string().email()}),sCe=u.object({email_address:u.string().email(),member_id:u.string().min(1)}),iCe=u.object({location:u.string().trim().min(1),contact:u.string().trim().email()}),aCe=u.object({location:u.string().min(1),contact:u.string().email(),created_at:u.string().datetime()}),cCe=u.object({first_name:u.string().min(1),last_name:u.string().min(1),display_name:u.string().min(1),stytch_id:u.string().min(1).optional()}),uCe=u.object({name:u.string().min(1),email_domains:u.array(u.string().min(1)).nonempty(),stytch_org_id:u.string().min(1)}),lCe=u.object({user:cCe,organization:uCe}),pCe=u.object({path_glob:u.string().min(1),name:u.string().min(1),description:u.string().min(1)}),dCe=u.object({repo_origin_path:u.string().min(1),building_blocks:u.array(pCe)}),X3=u.string().regex(/^th_[0-9A-Za-z]{22}$/),eg=u.string().regex(/^tb_[0-9A-Za-z]{22}$/),_Ce=u.object({id:X3,author:u.object({id:u.string().min(1),display_name:u.string().min(1)}),body:u.string(),created_at:u.string().datetime(),repo_origin_path:u.string().min(1),latest_revision_id:eg,revision_count:u.number().int().positive()}),fCe=u.object({id:u.string().min(1),display_name:u.string().min(1)}),mCe=u.object({id:u.string().min(1),author_id:u.string().min(1).nullable(),author:fCe.nullable(),created_at:u.string().datetime(),deleted_at:u.string().datetime().nullable(),content:u.string().min(1)}),hCe=u.object({id:u.string().min(1),thread_block_id:u.string().min(1),created_at:u.string().datetime(),resolved_at:u.string().datetime().nullable(),comments:u.array(mCe)}),TCe=u.object({thread_block_id:eg,from_position:u.number().int().positive(),to_position:u.number().int().positive(),selected_text:u.string().min(1),content:u.string().trim().min(1)}),ECe=u.object({id:u.string().min(1)}),SCe=u.object({content:u.string().trim().min(1)}),gCe=u.object({id:u.string().min(1)}),ACe=u.object({content:u.string().trim().min(1)}),RCe=u.object({id:u.string().min(1)}),yCe=u.object({content:u.string().trim().min(1)}),ICe=u.object({id:u.string().min(1)}),OCe=u.object({resolved:u.boolean()}),NCe=u.object({id:u.string().min(1),resolved_at:u.string().datetime().nullable()}),bCe=u.object({resolved:u.boolean()}),CCe=u.object({id:u.string().min(1),resolved_at:u.string().datetime().nullable()}),J3=u.record(u.unknown()),PCe=u.object({id:eg,body:u.string(),created_at:u.string().datetime(),prosemirror_json:J3,comment_threads:u.array(hCe)}),MCe=u.object({id:X3,created_at:u.string().datetime(),repo_origin_path:u.string().min(1),author:u.object({id:u.string().min(1),display_name:u.string().min(1)}),latest_revision_id:eg,revision_count:u.number().int().positive(),revisions:u.array(PCe)}),xCe=u.object({type:u.literal("list"),list_type:u.literal("plan"),has_more:u.boolean(),objects:u.array(_Ce)}),vCe=u.object({before:u.string().min(1).optional(),after:u.string().min(1).optional(),author_id:u.string().min(1).optional(),repo_origin_path:u.string().min(1).optional()}),Z3=u.object({id:u.string().min(1),organization_id:u.string().min(1),created_at:u.string().min(1),repo_origin_path:u.string().min(1),path_glob:u.string().min(1),name:u.string().min(1),description:u.string().min(1)}),LCe=u.array(Z3),DCe=u.object({type:u.literal("list"),list_type:u.literal("building_block"),has_more:u.boolean(),objects:u.array(Z3)}),UCe=u.object({repo_origin_path:u.string().min(1),before:u.string().min(1).optional(),after:u.string().min(1).optional()}),wCe=u.enum(["thread","building_block"]),kCe=u.object({repo_origin_path:u.string().min(1),sources:u.array(wCe).nonempty()}),GCe=u.object({type:u.literal("list"),list_type:u.literal("repository"),has_more:u.boolean(),objects:u.array(kCe)}),gi=u.enum(["claudeCode","codex","amp","cursor","unspecified"]),BCe=["transcript","plan"],jCe=u.enum(BCe),HCe=u.object({md5:u.string().min(1),harness:gi,filename:u.string().min(1).optional(),repo_origin_path:u.string().min(1).optional(),harness_internal_id:u.string().min(1).optional(),file_type:jCe.optional()}).refine(t=>(t.filename?.trim().length??0)>0||(t.harness_internal_id?.trim().length??0)>0,{path:["harness_internal_id"],message:"filename or harness_internal_id is required"}),bC=u.object({id:u.string().min(1),display_name:u.string().min(1)}),FCe=u.object({id:u.string().min(1),display_name:u.string().min(1)}),e9=u.object({id:u.string().min(1),author_id:u.string().min(1).nullable(),author:FCe.nullable(),created_at:u.string().datetime(),deleted_at:u.string().datetime().nullable(),content:u.string().min(1)}),t9=u.object({id:u.string().min(1),thread_block_id:u.string().min(1),created_at:u.string().datetime(),resolved_at:u.string().datetime().nullable()}),VCe=t9.extend({comments:u.array(e9)}),t_=u.object({id:u.string().min(1),type:u.string().min(1),index_in_thread:u.number().int().nonnegative(),isCritiqued:u.boolean(),comment_threads:u.array(VCe).optional()}).passthrough(),n9=u.object({type:u.literal("list"),list_type:u.literal("thread_block"),has_more:u.boolean(),objects:u.array(t_)}),F3=t_.extend({type:u.literal("plan"),prosemirror_json:J3,thread_file_id:u.string().min(1)}),qCe=u.union([u.literal(-1),u.literal(1)]),r9=u.union([u.literal(-1),u.literal(0),u.literal(1)]),V3=u.object({score:u.number().int(),up_count:u.number().int().nonnegative(),down_count:u.number().int().nonnegative(),viewer_vote:r9}),$Ce=u.object({value:qCe}),YCe=u.object({id:u.string().min(1),display_name:u.string().min(1),avatar_url:u.string().nullable()}),Va=u.object({id:u.string().min(1),thread_id:u.string().min(1),author_id:u.string().min(1).nullable(),author:YCe.nullable(),parent_comment_id:u.string().min(1).nullable(),content:u.string(),created_at:u.string().datetime(),updated_at:u.string().datetime(),deleted_at:u.string().datetime().nullable()}),WCe=u.object({type:u.literal("list"),list_type:u.literal("thread_comment"),objects:u.array(Va)}),zCe=u.object({content:u.string().trim().min(1).max(4e3),parent_comment_id:u.string().min(1).optional()}),KCe=Va,QCe=u.object({content:u.string().trim().min(1).max(4e3)}),XCe=Va,JCe=Va,X5e=u.discriminatedUnion("kind",[u.object({kind:u.literal("created"),thread_id:u.string().min(1),actor_user_id:u.string().min(1),version:u.number(),comment:Va}),u.object({kind:u.literal("updated"),thread_id:u.string().min(1),actor_user_id:u.string().min(1),version:u.number(),comment:Va}),u.object({kind:u.literal("deleted"),thread_id:u.string().min(1),actor_user_id:u.string().min(1),version:u.number(),comment:Va})]),ZCe=u.enum(["pending","generating","ready","failed"]),ePe=u.enum(["pending","generating","ready","failed"]),tPe=u.enum(["pending","placeholder","ai","user"]),o9=u.enum(["pending","generating","ready","failed"]),s9=u.enum(["pending","generating","ready","failed","disabled"]),i9=u.enum(["pending","generating","ready","failed"]),nPe=u.object({title:u.string().min(1),body:u.string().min(1),files:u.array(u.string()).optional()}),rPe=u.object({status:s9,url:u.string().nullable(),url_expires_at:u.string().nullable(),generated_at:u.string().nullable(),model:u.string().nullable()}),oPe=u.object({status:i9,steps:u.array(nPe),generated_at:u.string().nullable()}),sPe=u.object({remix_of_thread_id:u.string().nullable(),remix_count:u.number().int().nonnegative()}),iPe=u.object({cover:rPe,how_to:oPe,lineage:sPe}),aPe=u.enum(["asked","requested","decided","corrected","shared"]),cPe=u.object({id:u.string().min(1),kind:aPe,summary:u.string().min(1),block_id:u.string().min(1)}),uPe=u.object({type:u.literal("list"),list_type:u.literal("thread_decision"),status:o9,generated_at:u.string().nullable(),objects:u.array(cPe)}),hl=u.object({id:u.string().min(1),thread_file_id:u.string().min(1),organization_id:u.string().min(1),author:bC,repo:u.string().min(1),title:u.string().min(1),started_at:u.string().min(1),blocks:n9,user_message_count:u.number().int().nonnegative(),files_touched:u.array(u.string()),skills_invoked:u.array(u.string()),harness:gi,transcript_parsing_state:u.enum(["pending","parsed","too_large_to_parse"]),visibility:u.enum(["private","workspace","public"]),has_plan:u.boolean().optional(),summary:u.string().nullable(),summary_status:ZCe,summary_generated_at:u.string().nullable(),title_status:ePe,title_generated_at:u.string().nullable(),title_source:tPe,decisions_status:o9,decisions_generated_at:u.string().nullable(),score:u.number().int(),up_count:u.number().int().nonnegative(),down_count:u.number().int().nonnegative(),viewer_vote:r9,comment_count:u.number().int().nonnegative(),is_favorited:u.boolean(),card:iPe}),lPe=u.object({storage_url:u.string().min(1)}),pPe=u.object({storage_url:u.string(),harness:gi,thread:hl.nullable()}),dPe=u.object({status:u.literal("complete"),thread_files:u.array(pPe)}),_Pe=u.object({id:u.string(),presigned_url:u.string().nullable(),presigned_url_expires_at:u.string().nullable(),storage_url:u.string(),harness:gi,expected_md5:u.string(),error:u.string().nullable(),thread:hl.nullable()}),fPe=u.object({id:u.string(),substrate:u.enum(["s3","filesystem"]),status:u.enum(["incomplete","locked_for_parsing","complete","error"]),thread_files:u.array(_Pe)}),mPe=u.object({visibility:u.enum(["private","workspace","public"]).optional(),title:u.string().trim().min(1).max(200).optional()}).refine(t=>t.visibility!==void 0||t.title!==void 0,{message:"At least one of visibility or title must be provided"}),hPe=u.discriminatedUnion("visibility",[u.object({visibility:u.literal("private")}),u.object({visibility:u.literal("workspace")}),u.object({visibility:u.literal("public"),title:u.string().min(1),author_display_name:u.string().min(1),first_user_message:u.string().nullable(),summary:u.string().nullable(),started_at:u.string().min(1),harness:gi})]),TPe=hl,q3=u.object({type:u.literal("list"),list_type:u.literal("thread"),has_more:u.boolean(),objects:u.array(TPe)}),EPe=u.enum(["recent","popular"]),SPe=hl,gPe=u.object({type:u.literal("list"),list_type:u.literal("discover_thread"),has_more:u.boolean(),objects:u.array(SPe)}),APe=u.object({before:u.string().min(1).optional(),after:u.string().min(1).optional(),sort:EPe.optional(),harness:gi.optional(),search:u.string().max(200).optional()}),RPe=u.object({thread_count:u.number().int().nonnegative(),author_count:u.number().int().nonnegative(),organization_count:u.number().int().nonnegative(),harness_breakdown:u.record(gi,u.number().int().nonnegative())}),yPe=u.object({id:u.string(),status:u.enum(["incomplete","locked_for_parsing","complete","error"]),created_at:u.string(),thread_count:u.number().int().nonnegative()}),IPe=u.object({type:u.literal("list"),list_type:u.literal("upload_session"),objects:u.array(yPe)}),OPe=u.object({before:u.string().min(1).optional(),after:u.string().min(1).optional()}),NPe=u.object({before:u.string().min(1).optional(),after:u.string().min(1).optional(),author_ids:u.string().min(1).optional(),created_at:u.string().min(1).optional(),filepath_prefixes:u.string().min(1).optional()}),bPe=u.object({path:u.string().min(1),start_offset:u.number().int().nonnegative(),end_offset:u.number().int().positive()}),CPe=u.object({name:u.string(),usage_count:u.number().int().nonnegative(),author_count:u.number().int().nonnegative(),first_used_at:u.string().nullable(),last_used_at:u.string().nullable(),usage_count_last_24h:u.number().int().nonnegative(),usage_count_last_7d:u.number().int().nonnegative()}),PPe=u.object({type:u.literal("list"),list_type:u.literal("skill"),objects:u.array(CPe)}),MPe=u.object({id:u.string(),title:u.string(),visibility:u.enum(["private","workspace","public"]),started_at:u.string(),author:bC,skills_invoked:u.array(u.string())}),xPe=u.object({name:u.string(),usage_count:u.number().int().nonnegative(),author_count:u.number().int().nonnegative(),first_used_at:u.string().nullable(),last_used_at:u.string().nullable(),threads:u.array(MPe)}),vPe=u.object({path:u.string().min(1),text:u.string().max(64e3)}),LPe=u.enum(["text_edit","redact","delete_block"]),DPe=u.object({id:u.string(),thread_block_id:u.string(),editor:u.object({id:u.string(),display_name:u.string()}),kind:LPe,path:u.string().nullable(),previous_text:u.string().nullable(),new_text:u.string().nullable(),created_at:u.string()}),UPe=u.object({type:u.literal("list"),list_type:u.literal("thread_block_edit"),objects:u.array(DPe)}),wPe=u.object({organization_count:u.number().int().nonnegative(),user_count:u.number().int().nonnegative(),thread_count:u.number().int().nonnegative(),thread_count_last_24h:u.number().int().nonnegative(),user_count_last_24h:u.number().int().nonnegative()}),kPe=u.object({id:u.string(),name:u.string(),email_domains:u.array(u.string()),stytch_org_id:u.string(),member_count:u.number().int().nonnegative(),thread_count:u.number().int().nonnegative(),default_thread_visibility:u.enum(["private","workspace","public"]),created_at:u.string()}),GPe=u.object({type:u.literal("list"),list_type:u.literal("admin_organization"),objects:u.array(kPe)}),a9=u.object({id:u.string(),name:u.string()}),BPe=u.object({id:u.string(),display_name:u.string(),stytch_id:u.string().nullable(),thread_count:u.number().int().nonnegative(),onboarded_at:u.string().nullable(),created_at:u.string(),organizations:u.array(a9)}),jPe=u.object({type:u.literal("list"),list_type:u.literal("admin_user"),objects:u.array(BPe)}),HPe=u.object({id:u.string(),title:u.string(),started_at:u.string(),created_at:u.string(),deleted_at:u.string().nullable(),visibility:u.enum(["private","workspace","public"]),harness:gi,author:bC,organization:a9}),FPe=u.object({type:u.literal("list"),list_type:u.literal("admin_thread"),has_more:u.boolean(),objects:u.array(HPe)}),VPe=u.object({before:u.string().min(1).optional(),after:u.string().min(1).optional()}),$3=u.object({token:u.string().min(1),thread_id:u.string().min(1)}),qPe=u.object({visitor:u.string().min(1).max(64).optional()}),$Pe=u.object({user_id:u.string(),display_name:u.string(),shares_sent:u.number().int().nonnegative(),unique_viewers:u.number().int().nonnegative(),attributed_signups:u.number().int().nonnegative()}),YPe=u.object({window_days:u.number().int().positive(),shares_sent:u.number().int().nonnegative(),unique_viewers:u.number().int().nonnegative(),attributed_signups:u.number().int().nonnegative(),active_sharers:u.number().int().nonnegative(),k_factor:u.number().nullable(),shares_sent_sparkline:u.array(u.number().int().nonnegative()),top_sharers:u.array($Pe)}),WPe=u.object({windows:u.array(YPe)}),zPe=u.object({quoted_text:u.string().min(1),comment:u.string().nullable(),type:u.enum(["comment","highlight:trapdoor"])}),KPe=t9,QPe=e9.extend({comment_thread_id:u.string().min(1)}),XPe=u.object({markdown:u.string().min(1)}),JPe=u.object({storage_url:u.string().min(1),thread_file_id:u.string().min(1),parsed_plan_block:F3,critiqued_plan_block:F3,annotations:u.array(zPe),comment_threads:u.array(KPe),comments:u.array(QPe)}),Tl=u.enum(SC),c9=u.object({skills:u.boolean(),workspace_scope:u.boolean(),review:u.boolean(),shared_thread_ttl_days:u.number().int().positive().nullable()}),NC=u.object({subject_type:u.enum(["user","organization"]),subject_id:u.string().min(1),effective_plan:Tl,admin_override:Tl.nullable(),stripe_subscription_status:u.string().nullable(),cancel_at_period_end:u.boolean(),current_period_end:u.string().nullable(),seat_quantity:u.number().int().positive(),member_count:u.number().int().nonnegative().nullable(),features:c9}),ZPe=u.object({effective_plan:Tl,features:c9,user:NC,organization:NC.nullable()}),eMe=u.object({plan:u.enum(["creator","team"]),seat_quantity:u.number().int().positive().optional()}),tMe=u.object({checkout_url:u.string().min(1)}),nMe=u.object({portal_url:u.string().min(1)}),rMe=u.object({seat_quantity:u.number().int().positive()}),Y3=u.object({plan:Tl.nullable()}),ZS=u.object({subject_type:u.enum(["user","organization"]),subject_id:u.string().min(1),label:u.string().min(1),effective_plan:Tl,admin_override:Tl.nullable(),stripe_subscription_status:u.string().nullable(),seat_quantity:u.number().int().positive()}),oMe=u.object({users:u.array(ZS),organizations:u.array(ZS)}),sMe=u.object({id:u.string().min(1),display_name:u.string().min(1),handle:u.string().nullable(),avatar_url:u.string().nullable()}),iMe=u.object({thread_id:u.string().min(1),title:u.string().min(1),author:sMe,last_active_at:u.string().datetime(),last_block_excerpt:u.string().nullable(),last_block_kind:u.string().min(1).nullable(),is_streaming:u.boolean()}),aMe=u.object({type:u.literal("list"),list_type:u.literal("live_thread"),objects:u.array(iMe)}),cMe=u.object({thread_id:u.string().min(1)}),uMe=u.object({thread_id:u.string().min(1),last_seen_at:u.string().datetime(),started_at:u.string().datetime()}),lMe=u.object({follower_id:u.string().min(1),followee_id:u.string().min(1),is_following:u.literal(!0),follower_count:u.number().int().nonnegative()}),pMe=u.object({follower_id:u.string().min(1),followee_id:u.string().min(1),is_following:u.literal(!1),follower_count:u.number().int().nonnegative()}),u9=u.object({id:u.string().min(1),display_name:u.string().min(1),handle:u.string().nullable(),avatar_url:u.string().nullable(),bio:u.string().max(280).nullable(),is_following:u.boolean(),is_self:u.boolean()}),W3=u.object({type:u.literal("list"),list_type:u.literal("user_follow"),objects:u.array(u9)}),dMe=u.object({date:u.string().regex(/^\d{4}-\d{2}-\d{2}$/),count:u.number().int().nonnegative()}),_Me=u.object({window_start:u.string().datetime(),window_end:u.string().datetime(),total_contributions:u.number().int().nonnegative(),days_active:u.number().int().nonnegative(),daily_average:u.number().nonnegative(),current_streak_days:u.number().int().nonnegative(),days:u.array(dMe)}),fMe=u.object({type:u.literal("thread_created"),occurred_at:u.string().datetime(),id:u.string().min(1),thread:u.object({id:u.string().min(1),title:u.string(),visibility:u.enum(["private","workspace","public"])})}),mMe=u.object({type:u.literal("comment_posted"),occurred_at:u.string().datetime(),id:u.string().min(1),comment_excerpt:u.string(),thread:u.object({id:u.string().min(1),title:u.string(),visibility:u.enum(["private","workspace","public"])})}),hMe=u.object({type:u.literal("project_published"),occurred_at:u.string().datetime(),id:u.string().min(1),project:u.object({id:u.string().min(1),name:u.string().min(1)})}),TMe=u.object({type:u.literal("user_followed"),occurred_at:u.string().datetime(),id:u.string().min(1),followee:u9}),EMe=u.discriminatedUnion("type",[fMe,mMe,hMe,TMe]),SMe=u.object({type:u.literal("list"),list_type:u.literal("user_activity"),objects:u.array(EMe)}),gMe=u.object({id:u.string().min(1),name:u.string().min(1),excerpt:u.string(),published_at:u.string().datetime(),updated_at:u.string().datetime()}),AMe=u.object({type:u.literal("list"),list_type:u.literal("profile_published_project"),objects:u.array(gMe)}),z3=u.object({id:u.string().min(1),published_at:u.string().datetime().nullable()}),RMe=u.enum(["avatar","banner"]),yMe=u.enum(["image/png","image/jpeg","image/webp","image/gif"]),IMe=u.object({kind:RMe,content_type:yMe,base64_data:u.string().min(1)}),OMe=u.object({substrate:u.enum(["s3","filesystem"]),storage_url:u.string().min(1)}),NMe=Q3,l9=Qbe.router({health:{method:"GET",path:"/health",responses:{200:u.object({status:u.literal("ok")})},summary:"Health check"},whoAmI:{method:"GET",path:"/whoami",headers:u.object({authorization:u.string().min(1).optional(),"x-lore-referral-token":u.string().min(1).max(16).optional()}),responses:{200:eCe,401:A},summary:"Validate a Stytch B2B Bearer token and return member plus user fields"},recordHeartbeat:{method:"POST",path:"/heartbeat",headers:u.object({authorization:u.string().min(1).optional()}),body:cMe,responses:{200:uMe,401:A,403:A,404:A,422:A},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:u.object({authorization:u.string().min(1).optional()}),responses:{200:aMe,401:A,403:A},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:u.object({authorization:u.string().min(1).optional()}),query:NPe,responses:{200:q3,401:A},summary:"List threads visible to the authenticated user"},getThread:{method:"GET",path:"/threads/:id",pathParams:u.object({id:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),responses:{200:hl,404:A},summary:"Load a visible thread by id"},getSimilarThreads:{method:"GET",path:"/threads/:id/similar",pathParams:u.object({id:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),responses:{200:q3,404:A,409:A},summary:"List the top 20 visible threads with the closest summary embedding"},listThreadBlocks:{method:"GET",path:"/threads/:id/blocks",pathParams:u.object({id:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),query:OPe,responses:{200:n9,401:A},summary:"List blocks for a visible thread"},createThreadBlockCommentThread:{method:"POST",path:"/threads/:threadId/blocks/:blockId/comment-threads",pathParams:u.object({threadId:u.string().min(1),blockId:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),body:SCe,responses:{201:gCe,401:A,404:A},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:u.object({threadId:u.string().min(1),blockId:u.string().min(1),commentThreadId:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),body:yCe,responses:{201:ICe,401:A,404:A,409:A},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:u.object({threadId:u.string().min(1),blockId:u.string().min(1),commentThreadId:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),body:bCe,responses:{200:CCe,401:A,404:A},summary:"Resolve or reopen a block-level comment thread on a visible thread block"},listSkills:{method:"GET",path:"/skills",headers:u.object({authorization:u.string().min(1).optional()}),responses:{200:PPe,401:A},summary:"Aggregate skill usage across threads the viewer can see"},getSkillDetail:{method:"GET",path:"/skills/:name",pathParams:u.object({name:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),responses:{200:xPe,401:A,404:A},summary:"Per-skill detail: usage stats + visible threads that invoked it"},redactThreadBlock:{method:"POST",path:"/threads/:threadId/blocks/:blockId/redactions",pathParams:u.object({threadId:u.string().min(1),blockId:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),body:bPe,responses:{200:t_,401:A,403:A,404:A,422:A},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:u.object({threadId:u.string().min(1),blockId:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),body:vPe,responses:{200:t_,401:A,403:A,404:A,422:A},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:u.object({threadId:u.string().min(1),blockId:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),body:u.object({}).optional(),responses:{200:t_,401:A,403:A,404:A,409:A,422:A},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:u.object({threadId:u.string().min(1),blockId:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),body:u.object({}).optional(),responses:{204:u.null(),401:A,403:A,404:A},summary:"Soft-delete a thread block (author only)"},listThreadBlockEdits:{method:"GET",path:"/threads/:threadId/blocks/:blockId/edits",pathParams:u.object({threadId:u.string().min(1),blockId:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),responses:{200:UPe,401:A,404:A},summary:"List edits made to a thread block (visible to anyone who can see the thread)"},listThreadDecisions:{method:"GET",path:"/threads/:id/decisions",pathParams:u.object({id:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),responses:{200:uPe,401:A,404:A},summary:"List AI-extracted user decisions for a thread, in chronological order"},updateThread:{method:"PATCH",path:"/threads/:id",pathParams:u.object({id:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),body:mPe,responses:{200:hl,401:A,403:A,404:A},summary:"Update thread visibility (author only)"},deleteThread:{method:"DELETE",path:"/threads/:id",pathParams:u.object({id:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),body:u.object({}).optional(),responses:{204:u.null(),401:A,403:A,404:A},summary:"Soft-delete a thread (author only)"},generateThreadCard:{method:"POST",path:"/threads/:id/card/generate",pathParams:u.object({id:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),body:u.object({}).optional(),responses:{200:u.object({cover_status:s9,how_to_status:i9}),401:A,403:A,404:A,429:A.extend({retry_after_seconds:u.number().int().nonnegative()})},summary:"Enqueue cover image + how-to recipe generation for the thread. Author-only. Idempotent \u2014 recently-fired statuses are not double-enqueued. Rate-limited: at most one cover generation per minute per thread (cooldown begins when the previous cover finishes). Used to populate cards on legacy threads (created before Lore Cards) and to retry after a 'failed' status or opt back in from 'disabled'."},castThreadVote:{method:"PUT",path:"/threads/:id/vote",pathParams:u.object({id:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),body:$Ce,responses:{200:V3,401:A,403:A,404:A,422:A},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:u.object({id:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),body:u.object({}).optional(),responses:{200:V3,401:A,404:A},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:u.object({threadId:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),responses:{200:WCe,403:A,404:A},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:u.object({threadId:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),body:zCe,responses:{201:KCe,401:A,403:A,404:A,422:A},summary:"Post a top-level or reply comment on a public thread."},updateThreadComment:{method:"PATCH",path:"/threads/:threadId/comments/:commentId",pathParams:u.object({threadId:u.string().min(1),commentId:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),body:QCe,responses:{200:XCe,401:A,403:A,404:A,422:A},summary:"Edit your own thread comment (author only; rejects edits to soft-deleted rows)."},deleteThreadComment:{method:"DELETE",path:"/threads/:threadId/comments/:commentId",pathParams:u.object({threadId:u.string().min(1),commentId:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),body:u.object({}).optional(),responses:{200:JCe,401:A,403:A,404:A},summary:"Soft-delete your own thread comment (author only). Idempotent."},getThreadPreview:{method:"GET",path:"/threads/:id/preview",pathParams:u.object({id:u.string().min(1)}),responses:{200:hPe,404:A},summary:"Unauthenticated, visibility-redacted metadata for OG / social preview consumers"},createUser:{method:"POST",path:"/users",headers:u.object({authorization:u.string().min(1).optional()}),body:lCe,responses:{201:OC,401:A},summary:"Create a user record with ApiKey authentication"},getUser:{method:"GET",path:"/users/:id",pathParams:u.object({id:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),responses:{200:Q3,404:A},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:u.object({authorization:u.string().min(1).optional()}),body:tCe,responses:{200:OC,401:A,409:A,422:A},summary:"Update the authenticated user profile"},getUserByHandle:{method:"GET",path:"/users/by-handle/:handle",pathParams:u.object({handle:K3}),headers:u.object({authorization:u.string().min(1).optional()}),responses:{200:NMe,404:A},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:u.object({id:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),query:u.object({limit:u.coerce.number().int().positive().max(100).optional()}),responses:{200:SMe,404:A},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:u.object({id:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),responses:{200:_Me,404:A},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:u.object({id:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),responses:{200:W3,404:A},summary:"List the users following a given user."},listUserFollowing:{method:"GET",path:"/users/:id/following",pathParams:u.object({id:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),responses:{200:W3,404:A},summary:"List the users a given user is following."},followUser:{method:"POST",path:"/users/:id/follow",pathParams:u.object({id:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),body:u.object({}).optional(),responses:{200:lMe,401:A,404:A,409:A,422:A},summary:"Follow another user. Idempotent \u2014 repeating the call is a no-op."},unfollowUser:{method:"DELETE",path:"/users/:id/follow",pathParams:u.object({id:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),body:u.object({}).optional(),responses:{200:pMe,401:A,404:A},summary:"Unfollow a user. Idempotent \u2014 repeating the call is a no-op."},listProfilePublishedProjects:{method:"GET",path:"/users/:id/projects",pathParams:u.object({id:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),responses:{200:AMe,404:A},summary:"Projects the user has published to their public profile."},publishProject:{method:"POST",path:"/projects/:id/publish",pathParams:u.object({id:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),body:u.object({}).optional(),responses:{200:z3,401:A,403:A,404:A},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:u.object({id:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),body:u.object({}).optional(),responses:{200:z3,401:A,403:A,404:A},summary:"Remove a project from the author's public profile."},uploadProfileImage:{method:"POST",path:"/users/me/profile-image",headers:u.object({authorization:u.string().min(1).optional()}),body:IMe,responses:{200:OMe,401:A,413:A,422:A},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:u.object({authorization:u.string().min(1).optional()}),responses:{200:rCe,401:A},summary:"List members of the authenticated user\u2019s organization"},createOrganizationInvite:{method:"POST",path:"/organization/invites",headers:u.object({authorization:u.string().min(1).optional()}),body:oCe,responses:{201:sCe,401:A,403:A,409:A,422:A},summary:"Invite a teammate to the authenticated user\u2019s workspace via Stytch B2B"},listRepositories:{method:"GET",path:"/repositories",headers:u.object({authorization:u.string().min(1).optional()}),responses:{200:GCe,401:A,403:A},summary:"List repositories known to the authenticated user\u2019s organization across threads and building blocks"},createBuildingBlockSnapshots:{method:"POST",path:"/building_blocks",headers:u.object({authorization:u.string().min(1).optional()}),body:dCe,responses:{201:LCe,401:A,403:A},summary:"Create building block snapshots for the authenticated user\u2019s organization"},getPlan:{method:"GET",path:"/plans/:id",pathParams:u.object({id:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),responses:{200:MCe,401:A,403:A,404:A},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:u.object({id:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),body:TCe,responses:{201:ECe,401:A,403:A,404:A,422:A},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:u.object({id:u.string().min(1),threadId:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),body:ACe,responses:{201:RCe,401:A,403:A,404:A,409:A},summary:"Reply to an inline comment thread on a thread-backed plan container"},updatePlanCommentThread:{method:"PATCH",path:"/plans/:id/comment-threads/:threadId",pathParams:u.object({id:u.string().min(1),threadId:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),body:OCe,responses:{200:NCe,401:A,403:A,404:A},summary:"Resolve or reopen an inline comment thread on a thread-backed plan container"},listPlans:{method:"GET",path:"/plans",headers:u.object({authorization:u.string().min(1).optional()}),query:vCe,responses:{200:xCe,401:A,403:A},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:u.object({authorization:u.string().min(1).optional()}),query:UCe,responses:{200:DCe,401:A,403:A},summary:"List building block snapshots for the authenticated user\u2019s organization and repo origin path"},listUploadSessions:{method:"GET",path:"/upload_sessions",headers:u.object({authorization:u.string().min(1).optional()}),responses:{200:IPe,401:A},summary:"List recent upload sessions for the authenticated user"},createUploadSession:{method:"POST",path:"/upload_sessions",headers:u.object({authorization:u.string().min(1).optional()}),body:u.object({thread_files:u.array(HCe).nonempty()}),responses:{201:fPe,400:A,401:A},summary:"Create an upload session with presigned URLs for file uploads"},completeUploadSession:{method:"POST",path:"/upload_sessions/:id/complete",pathParams:u.object({id:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),body:u.object({thread_files:u.array(lPe).nonempty()}),responses:{200:dPe,400:A,401:A,404:A,409:A,422:A},summary:"Complete an upload session after files have been uploaded to storage"},adminStats:{method:"GET",path:"/admin/stats",headers:u.object({authorization:u.string().min(1).optional()}),responses:{200:wPe,401:A,403:A},summary:"Cross-org operational counts. Tanagram admins only."},adminListOrganizations:{method:"GET",path:"/admin/organizations",headers:u.object({authorization:u.string().min(1).optional()}),responses:{200:GPe,401:A,403:A},summary:"List every organization with member and thread counts. Tanagram admins only."},adminListUsers:{method:"GET",path:"/admin/users",headers:u.object({authorization:u.string().min(1).optional()}),responses:{200:jPe,401:A,403:A},summary:"List every user with their org memberships and thread count. Tanagram admins only."},adminListThreads:{method:"GET",path:"/admin/threads",headers:u.object({authorization:u.string().min(1).optional()}),query:VPe,responses:{200:FPe,401:A,403:A},summary:"List live threads across every organization. Tanagram admins only."},adminHardDeleteThread:{method:"DELETE",path:"/admin/threads/:id",pathParams:u.object({id:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),body:u.object({}).optional(),responses:{204:u.null(),401:A,403:A,404:A},summary:"Permanently remove a thread. Tanagram admins only."},listDiscoverThreads:{method:"GET",path:"/discover/threads",headers:u.object({authorization:u.string().min(1).optional()}),query:APe,responses:{200:gPe},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:RPe},summary:"Unauthenticated rollup of public-thread counts for the Discover header."},createWaitlistEntry:{method:"POST",path:"/waitlist_entries",body:iCe,responses:{201:aCe,409:A},summary:"Create an unauthenticated waitlist entry keyed by (location, contact)."},createShareToken:{method:"POST",path:"/threads/:id/share-token",pathParams:u.object({id:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),body:u.object({}).optional(),responses:{201:$3,401:A,403:A,404:A,409:A},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:u.object({token:u.string().min(1).max(16)}),query:qPe,responses:{200:$3,404:A},summary:"Resolve a share-link token to its thread and record the view. Unauthenticated by design."},adminGrowth:{method:"GET",path:"/admin/growth",headers:u.object({authorization:u.string().min(1).optional()}),responses:{200:WPe,401:A,403:A},summary:"Share-link k-factor, funnel, sparkline, and top sharers by window. Tanagram admins only."},adminRunCritiquePlayground:{method:"POST",path:"/admin/critique-playground/run",headers:u.object({authorization:u.string().min(1).optional()}),body:XPe,responses:{200:JPe,401:A,403:A,409:A},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:u.object({authorization:u.string().min(1).optional()}),responses:{200:ZPe,401:A},summary:"Resolve the caller's plan, features, seat count, and any admin override."},createBillingCheckout:{method:"POST",path:"/billing/checkout",headers:u.object({authorization:u.string().min(1).optional()}),body:eMe,responses:{200:tMe,400:A,401:A,403:A,503:A},summary:"Start a Stripe Checkout session for Creator ($29/mo) or Team ($19/seat/mo, min 2)."},createBillingPortal:{method:"POST",path:"/billing/portal",headers:u.object({authorization:u.string().min(1).optional()}),body:u.object({subject_type:u.enum(["user","organization"]).default("user")}).optional(),responses:{200:nMe,401:A,404:A,503:A},summary:"Open the Stripe customer portal so the subject can manage their subscription."},updateTeamSeats:{method:"PATCH",path:"/billing/team-seats",headers:u.object({authorization:u.string().min(1).optional()}),body:rMe,responses:{200:NC,400:A,401:A,403:A,404:A,503:A},summary:"Adjust the caller-organization's Team seat quantity (admin of that org only)."},adminListBilling:{method:"GET",path:"/admin/billing",headers:u.object({authorization:u.string().min(1).optional()}),responses:{200:oMe,401:A,403:A},summary:"List every user and org with current plan + override for the admin panel."},adminSetUserPlanOverride:{method:"PUT",path:"/admin/billing/users/:id/override",pathParams:u.object({id:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),body:Y3,responses:{200:ZS,401:A,403:A,404:A},summary:"Admin override for a user's plan tier. Null clears the override."},adminSetOrganizationPlanOverride:{method:"PUT",path:"/admin/billing/organizations/:id/override",pathParams:u.object({id:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),body:Y3,responses:{200:ZS,401:A,403:A,404:A},summary:"Admin override for an organization's plan tier. Null clears the override."},projects:k3,docs:U3,mentions:G3,favorites:j3,search:H3},{pathPrefix:"/api"});import n_ from"node:fs";import p9 from"node:path";function tg(){return p9.join(Zo(),"token")}function CC(){let t;try{t=n_.readFileSync(tg(),"utf8")}catch(n){if(n&&typeof n=="object"&&"code"in n&&n.code==="ENOENT")return{token:"",source:"none"};throw n}let e=t.trim();return!e||CMe(e,new Date)?{token:"",source:"none"}:{token:e,source:"file"}}function ng(){return CC().token}function d9(){return n_.existsSync(tg())}function _9(t){let e=tg();n_.mkdirSync(p9.dirname(e),{recursive:!0,mode:448}),n_.writeFileSync(e,t,{mode:384})}function f9(){try{n_.rmSync(tg())}catch(t){if(t&&typeof t=="object"&&"code"in t&&t.code==="ENOENT")return;throw t}}function bMe(t){let e=t.split(".");if(e.length<2)throw new Error("invalid JWT format");return JSON.parse(Buffer.from(e[1],"base64url").toString("utf8"))}function CMe(t,e){let n;try{n=bMe(t)}catch{return!1}let r=n["https://stytch.com/session"]?.expires_at;if(typeof r!="string")return!1;let o=Date.parse(r.trim());return Number.isNaN(o)?!1:e.getTime()>=o}var PMe={dev:"http://localhost:4000",prod:"https://lore.tanagram.ai"};function Ai(t={}){let e=t.token??ng();return EC(l9,{baseUrl:PMe[xt()],baseHeaders:{"User-Agent":B4(),...e?{authorization:`Bearer ${e}`}:{}}})}var m9={meta:{name:"health",description:"Check API health"},async run({data:t}){pt.info("command_start",{command:"health"});let n=await(t?.client??Ai()).health();if(n.status===200){console.log(n.body.status);return}throw pt.error("health_failed",{status:n.status}),console.error(`health check failed: HTTP ${n.status}`),new Error(`health check failed: HTTP ${n.status}`)}};var h9={meta:{name:"hello",description:"Print a friendly greeting"},run(){pt.info("command_start",{command:"hello"}),console.log("hello world")}};import{spawn as xMe}from"node:child_process";import S9 from"node:crypto";import vMe from"node:http";var MMe={dev:"http://localhost:8080",prod:"https://lore.tanagram.ai"};function T9(){return MMe[xt()]}var LMe=5*60*1e3;function DMe(){return S9.randomBytes(32).toString("base64url")}function UMe(t){return S9.createHash("sha256").update(t).digest("base64url")}function wMe(t){let e;try{e=JSON.parse(Buffer.from(t.trim(),"base64url").toString("utf8"))}catch(n){throw new Error(`decoding: ${n instanceof Error?n.message:String(n)}`)}if(typeof e.session_jwt!="string"||!e.session_jwt)throw new Error("missing session token");if(typeof e.code_challenge!="string"||!e.code_challenge)throw new Error("missing code challenge");return{sessionJwt:e.session_jwt,codeChallenge:e.code_challenge}}function kMe(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function E9(t,e,n){let r=e==="success";t.writeHead(200,{"Content-Type":"text/html"}),t.end(`<!DOCTYPE html>
|
|
81
|
+
`)){let o=r.trim();if(o.startsWith("state =")&&(n=o.slice(7).trim()==="running"),o.startsWith("pid =")){let s=Number.parseInt(o.slice(5).trim(),10);Number.isNaN(s)||(e.pid=s)}}return e.running=n??e.pid>0,e}async function FS(...t){try{let e=await gOe("launchctl",t);return`${e.stdout}${e.stderr}`.trim()}catch(e){if(kOe(e)){let n=`${e.stdout??""}${e.stderr??""}`.trim();throw new Error(n?`launchctl ${t.join(" ")}: ${e.message}: ${n}`:`launchctl ${t.join(" ")}: ${e.message}`)}throw e}}function LOe(t,e,n,r){return t?e.loaded?n.state==="logged_out"?{health:"logged_out",healthy:!1}:n.state==="error"?{health:"error",healthy:!1}:e.running?r?{health:"running",healthy:!0}:{health:"stale",healthy:!1}:n.last_heartbeat_at?{health:"healthy",healthy:!0}:{health:"waiting_for_first_run",healthy:!1}:{health:"not_loaded",healthy:!1}:{health:"disabled",healthy:!1}}function DOe(t,e){if(!t.last_heartbeat_at)return!1;let n=Date.parse(t.last_heartbeat_at);return Number.isNaN(n)?!1:n+AOe>=e.getTime()}function uC(){return`gui/${process.getuid?.()??EOe.userInfo().uid}`}function p3(){return`${uC()}/${Wd()}`}function UOe(){let t=["/opt/homebrew/bin","/usr/local/bin","/usr/bin","/bin","/usr/sbin","/sbin"];return Array.from(new Set([...process.env.PATH?.split(So.delimiter)??[],...t].filter(Boolean))).join(So.delimiter)}async function wOe(t){try{return await tn.stat(t),!0}catch{return!1}}function HS(t){return t.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'")}function lC(){if(process.platform!=="darwin")throw new Error("Lore background uploads are currently supported only on macOS")}function d3(t){let e=t instanceof Error?t.message.toLowerCase():String(t).toLowerCase();return e.includes("could not find service")||e.includes("service could not be found")||e.includes("no such process")||e.includes("bad request")}function kOe(t){return t instanceof Error}var _3={meta:{name:"enable",description:"Install and start background uploads"},async run(){let{plistPath:t,binaryPath:e}=await cC();console.log("Lore background uploads enabled."),console.log(`LaunchAgent: ${t}`),console.log(`Stable binary: ${e}`)}},f3={meta:{name:"disable",description:"Stop and remove background uploads"},async run(){await a3(),console.log("Lore background uploads disabled.")}},m3={meta:{name:"restart",description:"Restart background uploads"},async run(){await cC(),console.log("Lore background uploads restarted.")}},h3={meta:{name:"status",description:"Show background upload status"},args:{json:{type:"boolean",description:"Output status as JSON"}},async run({args:t}){let e=await c3();if(t.json){console.log(JSON.stringify(e,null,2));return}console.log(`Lore: ${e.health}`),console.log(`Enabled: ${e.enabled}`),console.log(`Loaded: ${e.loaded}`),console.log(`Running: ${e.running}`),console.log(`Healthy: ${e.healthy}`),e.status?.last_heartbeat_at&&console.log(`Last heartbeat: ${e.status.last_heartbeat_at}`),e.status?.last_success_at&&console.log(`Last success: ${e.status.last_success_at}`),e.status?.last_error&&console.log(`Last error: ${e.status.last_error}`),console.log(`LaunchAgent: ${e.plist_path}`),console.log(`Stable binary: ${e.binary_path}`),console.log(`Status file: ${e.status_path}`)}};var u={};sg(u,{BRAND:()=>uNe,DIRTY:()=>Na,EMPTY_PATH:()=>HOe,INVALID:()=>Q,NEVER:()=>WNe,OK:()=>nn,ParseStatus:()=>Ft,Schema:()=>ce,ZodAny:()=>Ti,ZodArray:()=>os,ZodBigInt:()=>Ca,ZodBoolean:()=>Pa,ZodBranded:()=>Zd,ZodCatch:()=>ja,ZodDate:()=>Ma,ZodDefault:()=>Ba,ZodDiscriminatedUnion:()=>$S,ZodEffects:()=>Sr,ZodEnum:()=>ka,ZodError:()=>vn,ZodFirstPartyTypeKind:()=>Z,ZodFunction:()=>WS,ZodIntersection:()=>Da,ZodIssueCode:()=>N,ZodLazy:()=>Ua,ZodLiteral:()=>wa,ZodMap:()=>_l,ZodNaN:()=>ml,ZodNativeEnum:()=>Ga,ZodNever:()=>Br,ZodNull:()=>va,ZodNullable:()=>Ro,ZodNumber:()=>ba,ZodObject:()=>Ln,ZodOptional:()=>Tr,ZodParsedType:()=>D,ZodPipeline:()=>e_,ZodPromise:()=>Ei,ZodReadonly:()=>Ha,ZodRecord:()=>YS,ZodSchema:()=>ce,ZodSet:()=>fl,ZodString:()=>hi,ZodSymbol:()=>pl,ZodTransformer:()=>Sr,ZodTuple:()=>Ao,ZodType:()=>ce,ZodUndefined:()=>xa,ZodUnion:()=>La,ZodUnknown:()=>rs,ZodVoid:()=>dl,addIssueToContext:()=>M,any:()=>ENe,array:()=>RNe,bigint:()=>_Ne,boolean:()=>b3,coerce:()=>YNe,custom:()=>I3,date:()=>fNe,datetimeRegex:()=>R3,defaultErrorMap:()=>ts,discriminatedUnion:()=>NNe,effect:()=>GNe,enum:()=>UNe,function:()=>vNe,getErrorMap:()=>cl,getParsedType:()=>go,instanceof:()=>pNe,intersection:()=>bNe,isAborted:()=>VS,isAsync:()=>ul,isDirty:()=>qS,isValid:()=>mi,late:()=>lNe,lazy:()=>LNe,literal:()=>DNe,makeIssue:()=>Jd,map:()=>MNe,nan:()=>dNe,nativeEnum:()=>wNe,never:()=>gNe,null:()=>TNe,nullable:()=>jNe,number:()=>N3,object:()=>yNe,objectUtil:()=>pC,oboolean:()=>$Ne,onumber:()=>qNe,optional:()=>BNe,ostring:()=>VNe,pipeline:()=>FNe,preprocess:()=>HNe,promise:()=>kNe,quotelessJson:()=>GOe,record:()=>PNe,set:()=>xNe,setErrorMap:()=>jOe,strictObject:()=>INe,string:()=>O3,symbol:()=>mNe,transformer:()=>GNe,tuple:()=>CNe,undefined:()=>hNe,union:()=>ONe,unknown:()=>SNe,util:()=>de,void:()=>ANe});var de;(function(t){t.assertEqual=o=>{};function e(o){}t.assertIs=e;function n(o){throw new Error}t.assertNever=n,t.arrayToEnum=o=>{let s={};for(let i of o)s[i]=i;return s},t.getValidEnumValues=o=>{let s=t.objectKeys(o).filter(a=>typeof o[o[a]]!="number"),i={};for(let a of s)i[a]=o[a];return t.objectValues(i)},t.objectValues=o=>t.objectKeys(o).map(function(s){return o[s]}),t.objectKeys=typeof Object.keys=="function"?o=>Object.keys(o):o=>{let s=[];for(let i in o)Object.prototype.hasOwnProperty.call(o,i)&&s.push(i);return s},t.find=(o,s)=>{for(let i of o)if(s(i))return i},t.isInteger=typeof Number.isInteger=="function"?o=>Number.isInteger(o):o=>typeof o=="number"&&Number.isFinite(o)&&Math.floor(o)===o;function r(o,s=" | "){return o.map(i=>typeof i=="string"?`'${i}'`:i).join(s)}t.joinValues=r,t.jsonStringifyReplacer=(o,s)=>typeof s=="bigint"?s.toString():s})(de||(de={}));var pC;(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(pC||(pC={}));var D=de.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),go=t=>{switch(typeof t){case"undefined":return D.undefined;case"string":return D.string;case"number":return Number.isNaN(t)?D.nan:D.number;case"boolean":return D.boolean;case"function":return D.function;case"bigint":return D.bigint;case"symbol":return D.symbol;case"object":return Array.isArray(t)?D.array:t===null?D.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?D.promise:typeof Map<"u"&&t instanceof Map?D.map:typeof Set<"u"&&t instanceof Set?D.set:typeof Date<"u"&&t instanceof Date?D.date:D.object;default:return D.unknown}};var N=de.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"]),GOe=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),vn=class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};let n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=e}format(e){let n=e||function(s){return s.message},r={_errors:[]},o=s=>{for(let i of s.issues)if(i.code==="invalid_union")i.unionErrors.map(o);else if(i.code==="invalid_return_type")o(i.returnTypeError);else if(i.code==="invalid_arguments")o(i.argumentsError);else if(i.path.length===0)r._errors.push(n(i));else{let a=r,c=0;for(;c<i.path.length;){let l=i.path[c];c===i.path.length-1?(a[l]=a[l]||{_errors:[]},a[l]._errors.push(n(i))):a[l]=a[l]||{_errors:[]},a=a[l],c++}}};return o(this),r}static assert(e){if(!(e instanceof t))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,de.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=n=>n.message){let n={},r=[];for(let o of this.issues)if(o.path.length>0){let s=o.path[0];n[s]=n[s]||[],n[s].push(e(o))}else r.push(e(o));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}};vn.create=t=>new vn(t);var BOe=(t,e)=>{let n;switch(t.code){case N.invalid_type:t.received===D.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case N.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,de.jsonStringifyReplacer)}`;break;case N.unrecognized_keys:n=`Unrecognized key(s) in object: ${de.joinValues(t.keys,", ")}`;break;case N.invalid_union:n="Invalid input";break;case N.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${de.joinValues(t.options)}`;break;case N.invalid_enum_value:n=`Invalid enum value. Expected ${de.joinValues(t.options)}, received '${t.received}'`;break;case N.invalid_arguments:n="Invalid function arguments";break;case N.invalid_return_type:n="Invalid function return type";break;case N.invalid_date:n="Invalid date";break;case N.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(n=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?n=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?n=`Invalid input: must end with "${t.validation.endsWith}"`:de.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case N.too_small:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:n="Invalid input";break;case N.too_big:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?n=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:n="Invalid input";break;case N.custom:n="Invalid input";break;case N.invalid_intersection_types:n="Intersection results could not be merged";break;case N.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case N.not_finite:n="Number must be finite";break;default:n=e.defaultError,de.assertNever(t)}return{message:n}},ts=BOe;var T3=ts;function jOe(t){T3=t}function cl(){return T3}var Jd=t=>{let{data:e,path:n,errorMaps:r,issueData:o}=t,s=[...n,...o.path||[]],i={...o,path:s};if(o.message!==void 0)return{...o,path:s,message:o.message};let a="",c=r.filter(l=>!!l).slice().reverse();for(let l of c)a=l(i,{data:e,defaultError:a}).message;return{...o,path:s,message:a}},HOe=[];function M(t,e){let n=cl(),r=Jd({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===ts?void 0:ts].filter(o=>!!o)});t.common.issues.push(r)}var Ft=class t{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,n){let r=[];for(let o of n){if(o.status==="aborted")return Q;o.status==="dirty"&&e.dirty(),r.push(o.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,n){let r=[];for(let o of n){let s=await o.key,i=await o.value;r.push({key:s,value:i})}return t.mergeObjectSync(e,r)}static mergeObjectSync(e,n){let r={};for(let o of n){let{key:s,value:i}=o;if(s.status==="aborted"||i.status==="aborted")return Q;s.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),s.value!=="__proto__"&&(typeof i.value<"u"||o.alwaysSet)&&(r[s.value]=i.value)}return{status:e.value,value:r}}},Q=Object.freeze({status:"aborted"}),Na=t=>({status:"dirty",value:t}),nn=t=>({status:"valid",value:t}),VS=t=>t.status==="aborted",qS=t=>t.status==="dirty",mi=t=>t.status==="valid",ul=t=>typeof Promise<"u"&&t instanceof Promise;var j;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(j||(j={}));var Er=class{constructor(e,n,r,o){this._cachedPath=[],this.parent=e,this.data=n,this._path=r,this._key=o}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}},E3=(t,e)=>{if(mi(e))return{success:!0,data:e.value};if(!t.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 vn(t.common.issues);return this._error=n,this._error}}};function ie(t){if(!t)return{};let{errorMap:e,invalid_type_error:n,required_error:r,description:o}=t;if(e&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:o}:{errorMap:(i,a)=>{let{message:c}=t;return i.code==="invalid_enum_value"?{message:c??a.defaultError}:typeof a.data>"u"?{message:c??r??a.defaultError}:i.code!=="invalid_type"?{message:a.defaultError}:{message:c??n??a.defaultError}},description:o}}var ce=class{get description(){return this._def.description}_getType(e){return go(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:go(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Ft,ctx:{common:e.parent.common,data:e.data,parsedType:go(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let n=this._parse(e);if(ul(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(e){let n=this._parse(e);return Promise.resolve(n)}parse(e,n){let r=this.safeParse(e,n);if(r.success)return r.data;throw r.error}safeParse(e,n){let r={common:{issues:[],async:n?.async??!1,contextualErrorMap:n?.errorMap},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:go(e)},o=this._parseSync({data:e,path:r.path,parent:r});return E3(r,o)}"~validate"(e){let n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:go(e)};if(!this["~standard"].async)try{let r=this._parseSync({data:e,path:[],parent:n});return mi(r)?{value:r.value}:{issues:n.common.issues}}catch(r){r?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:n}).then(r=>mi(r)?{value:r.value}:{issues:n.common.issues})}async parseAsync(e,n){let r=await this.safeParseAsync(e,n);if(r.success)return r.data;throw r.error}async safeParseAsync(e,n){let r={common:{issues:[],contextualErrorMap:n?.errorMap,async:!0},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:go(e)},o=this._parse({data:e,path:r.path,parent:r}),s=await(ul(o)?o:Promise.resolve(o));return E3(r,s)}refine(e,n){let r=o=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(o):n;return this._refinement((o,s)=>{let i=e(o),a=()=>s.addIssue({code:N.custom,...r(o)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?!0:(a(),!1)):i?!0:(a(),!1)})}refinement(e,n){return this._refinement((r,o)=>e(r)?!0:(o.addIssue(typeof n=="function"?n(r,o):n),!1))}_refinement(e){return new Sr({schema:this,typeName:Z.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.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 Tr.create(this,this._def)}nullable(){return Ro.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return os.create(this)}promise(){return Ei.create(this,this._def)}or(e){return La.create([this,e],this._def)}and(e){return Da.create(this,e,this._def)}transform(e){return new Sr({...ie(this._def),schema:this,typeName:Z.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let n=typeof e=="function"?e:()=>e;return new Ba({...ie(this._def),innerType:this,defaultValue:n,typeName:Z.ZodDefault})}brand(){return new Zd({typeName:Z.ZodBranded,type:this,...ie(this._def)})}catch(e){let n=typeof e=="function"?e:()=>e;return new ja({...ie(this._def),innerType:this,catchValue:n,typeName:Z.ZodCatch})}describe(e){let n=this.constructor;return new n({...this._def,description:e})}pipe(e){return e_.create(this,e)}readonly(){return Ha.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},FOe=/^c[^\s-]{8,}$/i,VOe=/^[0-9a-z]+$/,qOe=/^[0-9A-HJKMNP-TV-Z]{26}$/i,$Oe=/^[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,YOe=/^[a-z0-9_-]{21}$/i,WOe=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,zOe=/^[-+]?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)?)??$/,KOe=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,QOe="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",dC,XOe=/^(?:(?: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])$/,JOe=/^(?:(?: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])$/,ZOe=/^(([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]))$/,eNe=/^(([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])$/,tNe=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,nNe=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,g3="((\\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])))",rNe=new RegExp(`^${g3}$`);function A3(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);let n=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${n}`}function oNe(t){return new RegExp(`^${A3(t)}$`)}function R3(t){let e=`${g3}T${A3(t)}`,n=[];return n.push(t.local?"Z?":"Z"),t.offset&&n.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${n.join("|")})`,new RegExp(`^${e}$`)}function sNe(t,e){return!!((e==="v4"||!e)&&XOe.test(t)||(e==="v6"||!e)&&ZOe.test(t))}function iNe(t,e){if(!WOe.test(t))return!1;try{let[n]=t.split(".");if(!n)return!1;let r=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),o=JSON.parse(atob(r));return!(typeof o!="object"||o===null||"typ"in o&&o?.typ!=="JWT"||!o.alg||e&&o.alg!==e)}catch{return!1}}function aNe(t,e){return!!((e==="v4"||!e)&&JOe.test(t)||(e==="v6"||!e)&&eNe.test(t))}var hi=class t extends ce{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==D.string){let s=this._getOrReturnCtx(e);return M(s,{code:N.invalid_type,expected:D.string,received:s.parsedType}),Q}let r=new Ft,o;for(let s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(o=this._getOrReturnCtx(e,o),M(o,{code:N.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),r.dirty());else if(s.kind==="max")e.data.length>s.value&&(o=this._getOrReturnCtx(e,o),M(o,{code:N.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),r.dirty());else if(s.kind==="length"){let i=e.data.length>s.value,a=e.data.length<s.value;(i||a)&&(o=this._getOrReturnCtx(e,o),i?M(o,{code:N.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):a&&M(o,{code:N.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),r.dirty())}else if(s.kind==="email")KOe.test(e.data)||(o=this._getOrReturnCtx(e,o),M(o,{validation:"email",code:N.invalid_string,message:s.message}),r.dirty());else if(s.kind==="emoji")dC||(dC=new RegExp(QOe,"u")),dC.test(e.data)||(o=this._getOrReturnCtx(e,o),M(o,{validation:"emoji",code:N.invalid_string,message:s.message}),r.dirty());else if(s.kind==="uuid")$Oe.test(e.data)||(o=this._getOrReturnCtx(e,o),M(o,{validation:"uuid",code:N.invalid_string,message:s.message}),r.dirty());else if(s.kind==="nanoid")YOe.test(e.data)||(o=this._getOrReturnCtx(e,o),M(o,{validation:"nanoid",code:N.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid")FOe.test(e.data)||(o=this._getOrReturnCtx(e,o),M(o,{validation:"cuid",code:N.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid2")VOe.test(e.data)||(o=this._getOrReturnCtx(e,o),M(o,{validation:"cuid2",code:N.invalid_string,message:s.message}),r.dirty());else if(s.kind==="ulid")qOe.test(e.data)||(o=this._getOrReturnCtx(e,o),M(o,{validation:"ulid",code:N.invalid_string,message:s.message}),r.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{o=this._getOrReturnCtx(e,o),M(o,{validation:"url",code:N.invalid_string,message:s.message}),r.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(o=this._getOrReturnCtx(e,o),M(o,{validation:"regex",code:N.invalid_string,message:s.message}),r.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(o=this._getOrReturnCtx(e,o),M(o,{code:N.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),r.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(o=this._getOrReturnCtx(e,o),M(o,{code:N.invalid_string,validation:{startsWith:s.value},message:s.message}),r.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(o=this._getOrReturnCtx(e,o),M(o,{code:N.invalid_string,validation:{endsWith:s.value},message:s.message}),r.dirty()):s.kind==="datetime"?R3(s).test(e.data)||(o=this._getOrReturnCtx(e,o),M(o,{code:N.invalid_string,validation:"datetime",message:s.message}),r.dirty()):s.kind==="date"?rNe.test(e.data)||(o=this._getOrReturnCtx(e,o),M(o,{code:N.invalid_string,validation:"date",message:s.message}),r.dirty()):s.kind==="time"?oNe(s).test(e.data)||(o=this._getOrReturnCtx(e,o),M(o,{code:N.invalid_string,validation:"time",message:s.message}),r.dirty()):s.kind==="duration"?zOe.test(e.data)||(o=this._getOrReturnCtx(e,o),M(o,{validation:"duration",code:N.invalid_string,message:s.message}),r.dirty()):s.kind==="ip"?sNe(e.data,s.version)||(o=this._getOrReturnCtx(e,o),M(o,{validation:"ip",code:N.invalid_string,message:s.message}),r.dirty()):s.kind==="jwt"?iNe(e.data,s.alg)||(o=this._getOrReturnCtx(e,o),M(o,{validation:"jwt",code:N.invalid_string,message:s.message}),r.dirty()):s.kind==="cidr"?aNe(e.data,s.version)||(o=this._getOrReturnCtx(e,o),M(o,{validation:"cidr",code:N.invalid_string,message:s.message}),r.dirty()):s.kind==="base64"?tNe.test(e.data)||(o=this._getOrReturnCtx(e,o),M(o,{validation:"base64",code:N.invalid_string,message:s.message}),r.dirty()):s.kind==="base64url"?nNe.test(e.data)||(o=this._getOrReturnCtx(e,o),M(o,{validation:"base64url",code:N.invalid_string,message:s.message}),r.dirty()):de.assertNever(s);return{status:r.value,value:e.data}}_regex(e,n,r){return this.refinement(o=>e.test(o),{validation:n,code:N.invalid_string,...j.errToObj(r)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...j.errToObj(e)})}url(e){return this._addCheck({kind:"url",...j.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...j.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...j.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...j.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...j.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...j.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...j.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...j.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...j.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...j.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...j.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...j.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...j.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...j.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...j.errToObj(e)})}regex(e,n){return this._addCheck({kind:"regex",regex:e,...j.errToObj(n)})}includes(e,n){return this._addCheck({kind:"includes",value:e,position:n?.position,...j.errToObj(n?.message)})}startsWith(e,n){return this._addCheck({kind:"startsWith",value:e,...j.errToObj(n)})}endsWith(e,n){return this._addCheck({kind:"endsWith",value:e,...j.errToObj(n)})}min(e,n){return this._addCheck({kind:"min",value:e,...j.errToObj(n)})}max(e,n){return this._addCheck({kind:"max",value:e,...j.errToObj(n)})}length(e,n){return this._addCheck({kind:"length",value:e,...j.errToObj(n)})}nonempty(e){return this.min(1,j.errToObj(e))}trim(){return new t({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxLength(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}};hi.create=t=>new hi({checks:[],typeName:Z.ZodString,coerce:t?.coerce??!1,...ie(t)});function cNe(t,e){let n=(t.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,o=n>r?n:r,s=Number.parseInt(t.toFixed(o).replace(".","")),i=Number.parseInt(e.toFixed(o).replace(".",""));return s%i/10**o}var ba=class t extends ce{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==D.number){let s=this._getOrReturnCtx(e);return M(s,{code:N.invalid_type,expected:D.number,received:s.parsedType}),Q}let r,o=new Ft;for(let s of this._def.checks)s.kind==="int"?de.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),M(r,{code:N.invalid_type,expected:"integer",received:"float",message:s.message}),o.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(r=this._getOrReturnCtx(e,r),M(r,{code:N.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),o.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(r=this._getOrReturnCtx(e,r),M(r,{code:N.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),o.dirty()):s.kind==="multipleOf"?cNe(e.data,s.value)!==0&&(r=this._getOrReturnCtx(e,r),M(r,{code:N.not_multiple_of,multipleOf:s.value,message:s.message}),o.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),M(r,{code:N.not_finite,message:s.message}),o.dirty()):de.assertNever(s);return{status:o.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,j.toString(n))}gt(e,n){return this.setLimit("min",e,!1,j.toString(n))}lte(e,n){return this.setLimit("max",e,!0,j.toString(n))}lt(e,n){return this.setLimit("max",e,!1,j.toString(n))}setLimit(e,n,r,o){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:j.toString(o)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:j.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:j.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:j.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:j.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:j.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:j.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:j.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:j.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:j.toString(e)})}get minValue(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&de.isInteger(e.value))}get isFinite(){let e=null,n=null;for(let r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(n)&&Number.isFinite(e)}};ba.create=t=>new ba({checks:[],typeName:Z.ZodNumber,coerce:t?.coerce||!1,...ie(t)});var Ca=class t extends ce{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==D.bigint)return this._getInvalidInput(e);let r,o=new Ft;for(let s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(r=this._getOrReturnCtx(e,r),M(r,{code:N.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),o.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(r=this._getOrReturnCtx(e,r),M(r,{code:N.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),o.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),M(r,{code:N.not_multiple_of,multipleOf:s.value,message:s.message}),o.dirty()):de.assertNever(s);return{status:o.value,value:e.data}}_getInvalidInput(e){let n=this._getOrReturnCtx(e);return M(n,{code:N.invalid_type,expected:D.bigint,received:n.parsedType}),Q}gte(e,n){return this.setLimit("min",e,!0,j.toString(n))}gt(e,n){return this.setLimit("min",e,!1,j.toString(n))}lte(e,n){return this.setLimit("max",e,!0,j.toString(n))}lt(e,n){return this.setLimit("max",e,!1,j.toString(n))}setLimit(e,n,r,o){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:j.toString(o)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:j.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:j.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:j.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:j.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:j.toString(n)})}get minValue(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}};Ca.create=t=>new Ca({checks:[],typeName:Z.ZodBigInt,coerce:t?.coerce??!1,...ie(t)});var Pa=class extends ce{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==D.boolean){let r=this._getOrReturnCtx(e);return M(r,{code:N.invalid_type,expected:D.boolean,received:r.parsedType}),Q}return nn(e.data)}};Pa.create=t=>new Pa({typeName:Z.ZodBoolean,coerce:t?.coerce||!1,...ie(t)});var Ma=class t extends ce{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==D.date){let s=this._getOrReturnCtx(e);return M(s,{code:N.invalid_type,expected:D.date,received:s.parsedType}),Q}if(Number.isNaN(e.data.getTime())){let s=this._getOrReturnCtx(e);return M(s,{code:N.invalid_date}),Q}let r=new Ft,o;for(let s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(o=this._getOrReturnCtx(e,o),M(o,{code:N.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),r.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(o=this._getOrReturnCtx(e,o),M(o,{code:N.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),r.dirty()):de.assertNever(s);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,n){return this._addCheck({kind:"min",value:e.getTime(),message:j.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:j.toString(n)})}get minDate(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e!=null?new Date(e):null}};Ma.create=t=>new Ma({checks:[],coerce:t?.coerce||!1,typeName:Z.ZodDate,...ie(t)});var pl=class extends ce{_parse(e){if(this._getType(e)!==D.symbol){let r=this._getOrReturnCtx(e);return M(r,{code:N.invalid_type,expected:D.symbol,received:r.parsedType}),Q}return nn(e.data)}};pl.create=t=>new pl({typeName:Z.ZodSymbol,...ie(t)});var xa=class extends ce{_parse(e){if(this._getType(e)!==D.undefined){let r=this._getOrReturnCtx(e);return M(r,{code:N.invalid_type,expected:D.undefined,received:r.parsedType}),Q}return nn(e.data)}};xa.create=t=>new xa({typeName:Z.ZodUndefined,...ie(t)});var va=class extends ce{_parse(e){if(this._getType(e)!==D.null){let r=this._getOrReturnCtx(e);return M(r,{code:N.invalid_type,expected:D.null,received:r.parsedType}),Q}return nn(e.data)}};va.create=t=>new va({typeName:Z.ZodNull,...ie(t)});var Ti=class extends ce{constructor(){super(...arguments),this._any=!0}_parse(e){return nn(e.data)}};Ti.create=t=>new Ti({typeName:Z.ZodAny,...ie(t)});var rs=class extends ce{constructor(){super(...arguments),this._unknown=!0}_parse(e){return nn(e.data)}};rs.create=t=>new rs({typeName:Z.ZodUnknown,...ie(t)});var Br=class extends ce{_parse(e){let n=this._getOrReturnCtx(e);return M(n,{code:N.invalid_type,expected:D.never,received:n.parsedType}),Q}};Br.create=t=>new Br({typeName:Z.ZodNever,...ie(t)});var dl=class extends ce{_parse(e){if(this._getType(e)!==D.undefined){let r=this._getOrReturnCtx(e);return M(r,{code:N.invalid_type,expected:D.void,received:r.parsedType}),Q}return nn(e.data)}};dl.create=t=>new dl({typeName:Z.ZodVoid,...ie(t)});var os=class t extends ce{_parse(e){let{ctx:n,status:r}=this._processInputParams(e),o=this._def;if(n.parsedType!==D.array)return M(n,{code:N.invalid_type,expected:D.array,received:n.parsedType}),Q;if(o.exactLength!==null){let i=n.data.length>o.exactLength.value,a=n.data.length<o.exactLength.value;(i||a)&&(M(n,{code:i?N.too_big:N.too_small,minimum:a?o.exactLength.value:void 0,maximum:i?o.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:o.exactLength.message}),r.dirty())}if(o.minLength!==null&&n.data.length<o.minLength.value&&(M(n,{code:N.too_small,minimum:o.minLength.value,type:"array",inclusive:!0,exact:!1,message:o.minLength.message}),r.dirty()),o.maxLength!==null&&n.data.length>o.maxLength.value&&(M(n,{code:N.too_big,maximum:o.maxLength.value,type:"array",inclusive:!0,exact:!1,message:o.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((i,a)=>o.type._parseAsync(new Er(n,i,n.path,a)))).then(i=>Ft.mergeArray(r,i));let s=[...n.data].map((i,a)=>o.type._parseSync(new Er(n,i,n.path,a)));return Ft.mergeArray(r,s)}get element(){return this._def.type}min(e,n){return new t({...this._def,minLength:{value:e,message:j.toString(n)}})}max(e,n){return new t({...this._def,maxLength:{value:e,message:j.toString(n)}})}length(e,n){return new t({...this._def,exactLength:{value:e,message:j.toString(n)}})}nonempty(e){return this.min(1,e)}};os.create=(t,e)=>new os({type:t,minLength:null,maxLength:null,exactLength:null,typeName:Z.ZodArray,...ie(e)});function ll(t){if(t instanceof Ln){let e={};for(let n in t.shape){let r=t.shape[n];e[n]=Tr.create(ll(r))}return new Ln({...t._def,shape:()=>e})}else return t instanceof os?new os({...t._def,type:ll(t.element)}):t instanceof Tr?Tr.create(ll(t.unwrap())):t instanceof Ro?Ro.create(ll(t.unwrap())):t instanceof Ao?Ao.create(t.items.map(e=>ll(e))):t}var Ln=class t extends ce{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),n=de.objectKeys(e);return this._cached={shape:e,keys:n},this._cached}_parse(e){if(this._getType(e)!==D.object){let l=this._getOrReturnCtx(e);return M(l,{code:N.invalid_type,expected:D.object,received:l.parsedType}),Q}let{status:r,ctx:o}=this._processInputParams(e),{shape:s,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof Br&&this._def.unknownKeys==="strip"))for(let l in o.data)i.includes(l)||a.push(l);let c=[];for(let l of i){let p=s[l],d=o.data[l];c.push({key:{status:"valid",value:l},value:p._parse(new Er(o,d,o.path,l)),alwaysSet:l in o.data})}if(this._def.catchall instanceof Br){let l=this._def.unknownKeys;if(l==="passthrough")for(let p of a)c.push({key:{status:"valid",value:p},value:{status:"valid",value:o.data[p]}});else if(l==="strict")a.length>0&&(M(o,{code:N.unrecognized_keys,keys:a}),r.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let l=this._def.catchall;for(let p of a){let d=o.data[p];c.push({key:{status:"valid",value:p},value:l._parse(new Er(o,d,o.path,p)),alwaysSet:p in o.data})}}return o.common.async?Promise.resolve().then(async()=>{let l=[];for(let p of c){let d=await p.key,_=await p.value;l.push({key:d,value:_,alwaysSet:p.alwaysSet})}return l}).then(l=>Ft.mergeObjectSync(r,l)):Ft.mergeObjectSync(r,c)}get shape(){return this._def.shape()}strict(e){return j.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(n,r)=>{let o=this._def.errorMap?.(n,r).message??r.defaultError;return n.code==="unrecognized_keys"?{message:j.errToObj(e).message??o}:{message:o}}}:{}})}strip(){return new t({...this._def,unknownKeys:"strip"})}passthrough(){return new t({...this._def,unknownKeys:"passthrough"})}extend(e){return new t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:Z.ZodObject})}setKey(e,n){return this.augment({[e]:n})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let n={};for(let r of de.objectKeys(e))e[r]&&this.shape[r]&&(n[r]=this.shape[r]);return new t({...this._def,shape:()=>n})}omit(e){let n={};for(let r of de.objectKeys(this.shape))e[r]||(n[r]=this.shape[r]);return new t({...this._def,shape:()=>n})}deepPartial(){return ll(this)}partial(e){let n={};for(let r of de.objectKeys(this.shape)){let o=this.shape[r];e&&!e[r]?n[r]=o:n[r]=o.optional()}return new t({...this._def,shape:()=>n})}required(e){let n={};for(let r of de.objectKeys(this.shape))if(e&&!e[r])n[r]=this.shape[r];else{let s=this.shape[r];for(;s instanceof Tr;)s=s._def.innerType;n[r]=s}return new t({...this._def,shape:()=>n})}keyof(){return y3(de.objectKeys(this.shape))}};Ln.create=(t,e)=>new Ln({shape:()=>t,unknownKeys:"strip",catchall:Br.create(),typeName:Z.ZodObject,...ie(e)});Ln.strictCreate=(t,e)=>new Ln({shape:()=>t,unknownKeys:"strict",catchall:Br.create(),typeName:Z.ZodObject,...ie(e)});Ln.lazycreate=(t,e)=>new Ln({shape:t,unknownKeys:"strip",catchall:Br.create(),typeName:Z.ZodObject,...ie(e)});var La=class extends ce{_parse(e){let{ctx:n}=this._processInputParams(e),r=this._def.options;function o(s){for(let a of s)if(a.result.status==="valid")return a.result;for(let a of s)if(a.result.status==="dirty")return n.common.issues.push(...a.ctx.common.issues),a.result;let i=s.map(a=>new vn(a.ctx.common.issues));return M(n,{code:N.invalid_union,unionErrors:i}),Q}if(n.common.async)return Promise.all(r.map(async s=>{let i={...n,common:{...n.common,issues:[]},parent:null};return{result:await s._parseAsync({data:n.data,path:n.path,parent:i}),ctx:i}})).then(o);{let s,i=[];for(let c of r){let l={...n,common:{...n.common,issues:[]},parent:null},p=c._parseSync({data:n.data,path:n.path,parent:l});if(p.status==="valid")return p;p.status==="dirty"&&!s&&(s={result:p,ctx:l}),l.common.issues.length&&i.push(l.common.issues)}if(s)return n.common.issues.push(...s.ctx.common.issues),s.result;let a=i.map(c=>new vn(c));return M(n,{code:N.invalid_union,unionErrors:a}),Q}}get options(){return this._def.options}};La.create=(t,e)=>new La({options:t,typeName:Z.ZodUnion,...ie(e)});var ns=t=>t instanceof Ua?ns(t.schema):t instanceof Sr?ns(t.innerType()):t instanceof wa?[t.value]:t instanceof ka?t.options:t instanceof Ga?de.objectValues(t.enum):t instanceof Ba?ns(t._def.innerType):t instanceof xa?[void 0]:t instanceof va?[null]:t instanceof Tr?[void 0,...ns(t.unwrap())]:t instanceof Ro?[null,...ns(t.unwrap())]:t instanceof Zd||t instanceof Ha?ns(t.unwrap()):t instanceof ja?ns(t._def.innerType):[],$S=class t extends ce{_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==D.object)return M(n,{code:N.invalid_type,expected:D.object,received:n.parsedType}),Q;let r=this.discriminator,o=n.data[r],s=this.optionsMap.get(o);return s?n.common.async?s._parseAsync({data:n.data,path:n.path,parent:n}):s._parseSync({data:n.data,path:n.path,parent:n}):(M(n,{code:N.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),Q)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,n,r){let o=new Map;for(let s of n){let i=ns(s.shape[e]);if(!i.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let a of i){if(o.has(a))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);o.set(a,s)}}return new t({typeName:Z.ZodDiscriminatedUnion,discriminator:e,options:n,optionsMap:o,...ie(r)})}};function _C(t,e){let n=go(t),r=go(e);if(t===e)return{valid:!0,data:t};if(n===D.object&&r===D.object){let o=de.objectKeys(e),s=de.objectKeys(t).filter(a=>o.indexOf(a)!==-1),i={...t,...e};for(let a of s){let c=_C(t[a],e[a]);if(!c.valid)return{valid:!1};i[a]=c.data}return{valid:!0,data:i}}else if(n===D.array&&r===D.array){if(t.length!==e.length)return{valid:!1};let o=[];for(let s=0;s<t.length;s++){let i=t[s],a=e[s],c=_C(i,a);if(!c.valid)return{valid:!1};o.push(c.data)}return{valid:!0,data:o}}else return n===D.date&&r===D.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}var Da=class extends ce{_parse(e){let{status:n,ctx:r}=this._processInputParams(e),o=(s,i)=>{if(VS(s)||VS(i))return Q;let a=_C(s.value,i.value);return a.valid?((qS(s)||qS(i))&&n.dirty(),{status:n.value,value:a.data}):(M(r,{code:N.invalid_intersection_types}),Q)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([s,i])=>o(s,i)):o(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}};Da.create=(t,e,n)=>new Da({left:t,right:e,typeName:Z.ZodIntersection,...ie(n)});var Ao=class t extends ce{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==D.array)return M(r,{code:N.invalid_type,expected:D.array,received:r.parsedType}),Q;if(r.data.length<this._def.items.length)return M(r,{code:N.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Q;!this._def.rest&&r.data.length>this._def.items.length&&(M(r,{code:N.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());let s=[...r.data].map((i,a)=>{let c=this._def.items[a]||this._def.rest;return c?c._parse(new Er(r,i,r.path,a)):null}).filter(i=>!!i);return r.common.async?Promise.all(s).then(i=>Ft.mergeArray(n,i)):Ft.mergeArray(n,s)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};Ao.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Ao({items:t,typeName:Z.ZodTuple,rest:null,...ie(e)})};var YS=class t extends ce{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==D.object)return M(r,{code:N.invalid_type,expected:D.object,received:r.parsedType}),Q;let o=[],s=this._def.keyType,i=this._def.valueType;for(let a in r.data)o.push({key:s._parse(new Er(r,a,r.path,a)),value:i._parse(new Er(r,r.data[a],r.path,a)),alwaysSet:a in r.data});return r.common.async?Ft.mergeObjectAsync(n,o):Ft.mergeObjectSync(n,o)}get element(){return this._def.valueType}static create(e,n,r){return n instanceof ce?new t({keyType:e,valueType:n,typeName:Z.ZodRecord,...ie(r)}):new t({keyType:hi.create(),valueType:e,typeName:Z.ZodRecord,...ie(n)})}},_l=class extends ce{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==D.map)return M(r,{code:N.invalid_type,expected:D.map,received:r.parsedType}),Q;let o=this._def.keyType,s=this._def.valueType,i=[...r.data.entries()].map(([a,c],l)=>({key:o._parse(new Er(r,a,r.path,[l,"key"])),value:s._parse(new Er(r,c,r.path,[l,"value"]))}));if(r.common.async){let a=new Map;return Promise.resolve().then(async()=>{for(let c of i){let l=await c.key,p=await c.value;if(l.status==="aborted"||p.status==="aborted")return Q;(l.status==="dirty"||p.status==="dirty")&&n.dirty(),a.set(l.value,p.value)}return{status:n.value,value:a}})}else{let a=new Map;for(let c of i){let l=c.key,p=c.value;if(l.status==="aborted"||p.status==="aborted")return Q;(l.status==="dirty"||p.status==="dirty")&&n.dirty(),a.set(l.value,p.value)}return{status:n.value,value:a}}}};_l.create=(t,e,n)=>new _l({valueType:e,keyType:t,typeName:Z.ZodMap,...ie(n)});var fl=class t extends ce{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==D.set)return M(r,{code:N.invalid_type,expected:D.set,received:r.parsedType}),Q;let o=this._def;o.minSize!==null&&r.data.size<o.minSize.value&&(M(r,{code:N.too_small,minimum:o.minSize.value,type:"set",inclusive:!0,exact:!1,message:o.minSize.message}),n.dirty()),o.maxSize!==null&&r.data.size>o.maxSize.value&&(M(r,{code:N.too_big,maximum:o.maxSize.value,type:"set",inclusive:!0,exact:!1,message:o.maxSize.message}),n.dirty());let s=this._def.valueType;function i(c){let l=new Set;for(let p of c){if(p.status==="aborted")return Q;p.status==="dirty"&&n.dirty(),l.add(p.value)}return{status:n.value,value:l}}let a=[...r.data.values()].map((c,l)=>s._parse(new Er(r,c,r.path,l)));return r.common.async?Promise.all(a).then(c=>i(c)):i(a)}min(e,n){return new t({...this._def,minSize:{value:e,message:j.toString(n)}})}max(e,n){return new t({...this._def,maxSize:{value:e,message:j.toString(n)}})}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}};fl.create=(t,e)=>new fl({valueType:t,minSize:null,maxSize:null,typeName:Z.ZodSet,...ie(e)});var WS=class t extends ce{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==D.function)return M(n,{code:N.invalid_type,expected:D.function,received:n.parsedType}),Q;function r(a,c){return Jd({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,cl(),ts].filter(l=>!!l),issueData:{code:N.invalid_arguments,argumentsError:c}})}function o(a,c){return Jd({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,cl(),ts].filter(l=>!!l),issueData:{code:N.invalid_return_type,returnTypeError:c}})}let s={errorMap:n.common.contextualErrorMap},i=n.data;if(this._def.returns instanceof Ei){let a=this;return nn(async function(...c){let l=new vn([]),p=await a._def.args.parseAsync(c,s).catch(f=>{throw l.addIssue(r(c,f)),l}),d=await Reflect.apply(i,this,p);return await a._def.returns._def.type.parseAsync(d,s).catch(f=>{throw l.addIssue(o(d,f)),l})})}else{let a=this;return nn(function(...c){let l=a._def.args.safeParse(c,s);if(!l.success)throw new vn([r(c,l.error)]);let p=Reflect.apply(i,this,l.data),d=a._def.returns.safeParse(p,s);if(!d.success)throw new vn([o(p,d.error)]);return d.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:Ao.create(e).rest(rs.create())})}returns(e){return new t({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,n,r){return new t({args:e||Ao.create([]).rest(rs.create()),returns:n||rs.create(),typeName:Z.ZodFunction,...ie(r)})}},Ua=class extends ce{get schema(){return this._def.getter()}_parse(e){let{ctx:n}=this._processInputParams(e);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}};Ua.create=(t,e)=>new Ua({getter:t,typeName:Z.ZodLazy,...ie(e)});var wa=class extends ce{_parse(e){if(e.data!==this._def.value){let n=this._getOrReturnCtx(e);return M(n,{received:n.data,code:N.invalid_literal,expected:this._def.value}),Q}return{status:"valid",value:e.data}}get value(){return this._def.value}};wa.create=(t,e)=>new wa({value:t,typeName:Z.ZodLiteral,...ie(e)});function y3(t,e){return new ka({values:t,typeName:Z.ZodEnum,...ie(e)})}var ka=class t extends ce{_parse(e){if(typeof e.data!="string"){let n=this._getOrReturnCtx(e),r=this._def.values;return M(n,{expected:de.joinValues(r),received:n.parsedType,code:N.invalid_type}),Q}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let n=this._getOrReturnCtx(e),r=this._def.values;return M(n,{received:n.data,code:N.invalid_enum_value,options:r}),Q}return nn(e.data)}get options(){return this._def.values}get enum(){let e={};for(let n of this._def.values)e[n]=n;return e}get Values(){let e={};for(let n of this._def.values)e[n]=n;return e}get Enum(){let e={};for(let n of this._def.values)e[n]=n;return e}extract(e,n=this._def){return t.create(e,{...this._def,...n})}exclude(e,n=this._def){return t.create(this.options.filter(r=>!e.includes(r)),{...this._def,...n})}};ka.create=y3;var Ga=class extends ce{_parse(e){let n=de.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==D.string&&r.parsedType!==D.number){let o=de.objectValues(n);return M(r,{expected:de.joinValues(o),received:r.parsedType,code:N.invalid_type}),Q}if(this._cache||(this._cache=new Set(de.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let o=de.objectValues(n);return M(r,{received:r.data,code:N.invalid_enum_value,options:o}),Q}return nn(e.data)}get enum(){return this._def.values}};Ga.create=(t,e)=>new Ga({values:t,typeName:Z.ZodNativeEnum,...ie(e)});var Ei=class extends ce{unwrap(){return this._def.type}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==D.promise&&n.common.async===!1)return M(n,{code:N.invalid_type,expected:D.promise,received:n.parsedType}),Q;let r=n.parsedType===D.promise?n.data:Promise.resolve(n.data);return nn(r.then(o=>this._def.type.parseAsync(o,{path:n.path,errorMap:n.common.contextualErrorMap})))}};Ei.create=(t,e)=>new Ei({type:t,typeName:Z.ZodPromise,...ie(e)});var Sr=class extends ce{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Z.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:n,ctx:r}=this._processInputParams(e),o=this._def.effect||null,s={addIssue:i=>{M(r,i),i.fatal?n.abort():n.dirty()},get path(){return r.path}};if(s.addIssue=s.addIssue.bind(s),o.type==="preprocess"){let i=o.transform(r.data,s);if(r.common.async)return Promise.resolve(i).then(async a=>{if(n.value==="aborted")return Q;let c=await this._def.schema._parseAsync({data:a,path:r.path,parent:r});return c.status==="aborted"?Q:c.status==="dirty"?Na(c.value):n.value==="dirty"?Na(c.value):c});{if(n.value==="aborted")return Q;let a=this._def.schema._parseSync({data:i,path:r.path,parent:r});return a.status==="aborted"?Q:a.status==="dirty"?Na(a.value):n.value==="dirty"?Na(a.value):a}}if(o.type==="refinement"){let i=a=>{let c=o.refinement(a,s);if(r.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(r.common.async===!1){let a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?Q:(a.status==="dirty"&&n.dirty(),i(a.value),{status:n.value,value:a.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>a.status==="aborted"?Q:(a.status==="dirty"&&n.dirty(),i(a.value).then(()=>({status:n.value,value:a.value}))))}if(o.type==="transform")if(r.common.async===!1){let i=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!mi(i))return Q;let a=o.transform(i.value,s);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:a}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(i=>mi(i)?Promise.resolve(o.transform(i.value,s)).then(a=>({status:n.value,value:a})):Q);de.assertNever(o)}};Sr.create=(t,e,n)=>new Sr({schema:t,typeName:Z.ZodEffects,effect:e,...ie(n)});Sr.createWithPreprocess=(t,e,n)=>new Sr({schema:e,effect:{type:"preprocess",transform:t},typeName:Z.ZodEffects,...ie(n)});var Tr=class extends ce{_parse(e){return this._getType(e)===D.undefined?nn(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Tr.create=(t,e)=>new Tr({innerType:t,typeName:Z.ZodOptional,...ie(e)});var Ro=class extends ce{_parse(e){return this._getType(e)===D.null?nn(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Ro.create=(t,e)=>new Ro({innerType:t,typeName:Z.ZodNullable,...ie(e)});var Ba=class extends ce{_parse(e){let{ctx:n}=this._processInputParams(e),r=n.data;return n.parsedType===D.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}};Ba.create=(t,e)=>new Ba({innerType:t,typeName:Z.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...ie(e)});var ja=class extends ce{_parse(e){let{ctx:n}=this._processInputParams(e),r={...n,common:{...n.common,issues:[]}},o=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return ul(o)?o.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new vn(r.common.issues)},input:r.data})})):{status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new vn(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}};ja.create=(t,e)=>new ja({innerType:t,typeName:Z.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...ie(e)});var ml=class extends ce{_parse(e){if(this._getType(e)!==D.nan){let r=this._getOrReturnCtx(e);return M(r,{code:N.invalid_type,expected:D.nan,received:r.parsedType}),Q}return{status:"valid",value:e.data}}};ml.create=t=>new ml({typeName:Z.ZodNaN,...ie(t)});var uNe=Symbol("zod_brand"),Zd=class extends ce{_parse(e){let{ctx:n}=this._processInputParams(e),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}},e_=class t extends ce{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{let s=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?Q:s.status==="dirty"?(n.dirty(),Na(s.value)):this._def.out._parseAsync({data:s.value,path:r.path,parent:r})})();{let o=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return o.status==="aborted"?Q:o.status==="dirty"?(n.dirty(),{status:"dirty",value:o.value}):this._def.out._parseSync({data:o.value,path:r.path,parent:r})}}static create(e,n){return new t({in:e,out:n,typeName:Z.ZodPipeline})}},Ha=class extends ce{_parse(e){let n=this._def.innerType._parse(e),r=o=>(mi(o)&&(o.value=Object.freeze(o.value)),o);return ul(n)?n.then(o=>r(o)):r(n)}unwrap(){return this._def.innerType}};Ha.create=(t,e)=>new Ha({innerType:t,typeName:Z.ZodReadonly,...ie(e)});function S3(t,e){let n=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof n=="string"?{message:n}:n}function I3(t,e={},n){return t?Ti.create().superRefine((r,o)=>{let s=t(r);if(s instanceof Promise)return s.then(i=>{if(!i){let a=S3(e,r),c=a.fatal??n??!0;o.addIssue({code:"custom",...a,fatal:c})}});if(!s){let i=S3(e,r),a=i.fatal??n??!0;o.addIssue({code:"custom",...i,fatal:a})}}):Ti.create()}var lNe={object:Ln.lazycreate},Z;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(Z||(Z={}));var pNe=(t,e={message:`Input not instance of ${t.name}`})=>I3(n=>n instanceof t,e),O3=hi.create,N3=ba.create,dNe=ml.create,_Ne=Ca.create,b3=Pa.create,fNe=Ma.create,mNe=pl.create,hNe=xa.create,TNe=va.create,ENe=Ti.create,SNe=rs.create,gNe=Br.create,ANe=dl.create,RNe=os.create,yNe=Ln.create,INe=Ln.strictCreate,ONe=La.create,NNe=$S.create,bNe=Da.create,CNe=Ao.create,PNe=YS.create,MNe=_l.create,xNe=fl.create,vNe=WS.create,LNe=Ua.create,DNe=wa.create,UNe=ka.create,wNe=Ga.create,kNe=Ei.create,GNe=Sr.create,BNe=Tr.create,jNe=Ro.create,HNe=Sr.createWithPreprocess,FNe=e_.create,VNe=()=>O3().optional(),qNe=()=>N3().optional(),$Ne=()=>b3().optional(),YNe={string:t=>hi.create({...t,coerce:!0}),number:t=>ba.create({...t,coerce:!0}),boolean:t=>Pa.create({...t,coerce:!0}),bigint:t=>Ca.create({...t,coerce:!0}),date:t=>Ma.create({...t,coerce:!0})};var WNe=Q;var zNe=t=>typeof t?.safeParse=="function";var fC=t=>typeof t?.passthrough=="function";var KNe=(t,e)=>fC(t)?fC(e)?t.merge(e):t:fC(e)?e:Object.assign({},t,e);var p5e=u.object({name:u.literal("ZodError"),issues:u.array(u.object({path:u.array(u.union([u.string(),u.number()])),message:u.string().optional(),code:u.nativeEnum(u.ZodIssueCode)}).catchall(u.any()))}),QNe=Symbol("ContractNoBody"),P3=t=>"method"in t&&"path"in t;var M3=(t,e)=>Object.fromEntries(Object.entries(t).map(([n,r])=>{var o,s,i;return P3(r)?[n,{...r,path:e?.pathPrefix?e.pathPrefix+r.path:r.path,headers:KNe(e?.baseHeaders,r.headers),strictStatusCodes:(o=r.strictStatusCodes)!==null&&o!==void 0?o:e?.strictStatusCodes,validateResponseOnClient:(s=r.validateResponseOnClient)!==null&&s!==void 0?s:e?.validateResponseOnClient,responses:{...e?.commonResponses,...r.responses},metadata:e?.metadata?{...e?.metadata,...(i=r.metadata)!==null&&i!==void 0?i:{}}:r.metadata}]:[n,M3(r,e)]})),mC=Symbol("ContractPlainType"),gr=()=>({router:(t,e)=>M3(t,e),query:t=>t,mutation:t=>t,responses:t=>t,response:()=>mC,body:()=>mC,type:()=>mC,otherResponse:({contentType:t,body:e})=>({contentType:t,body:e}),noBody:()=>QNe}),XNe=({path:t,params:e})=>{let n=e;return t.replace(/\/?:([^/?]+)\??/g,(r,o)=>n[o]?`${r.startsWith("/")?"/":""}${n[o]}`:"")},JNe=(t,e=!1)=>{let n=e?ZNe(t):ebe(t);return n?.length>0?"?"+n:""},ZNe=t=>t?Object.entries(t).filter(([,e])=>e!==void 0).map(([e,n])=>{let r;return typeof n=="string"&&!["true","false","null"].includes(n.trim())&&isNaN(Number(n))?r=n:r=JSON.stringify(n),`${encodeURIComponent(e)}=${encodeURIComponent(r)}`}).join("&"):"",ebe=t=>t?Object.keys(t).flatMap(e=>hC(e,t[e])).map(([e,n])=>`${encodeURIComponent(e)}=${encodeURIComponent(n)}`).join("&"):"",hC=(t,e)=>Array.isArray(e)?e.flatMap((n,r)=>hC(`${t}[${r}]`,n)):e instanceof Date?[[`${t}`,e.toISOString()]]:e===null?[[`${t}`,""]]:e===void 0?[]:typeof e=="object"?Object.keys(e).flatMap(n=>hC(`${t}[${n}]`,e[n])):[[`${t}`,`${e}`]];var TC=class extends Error{constructor(e,n){let r=n.join(",");super(`Server returned unexpected response. Expected one of: ${r} got: ${e.status}`),this.response=e}};var tbe=async({route:t,path:e,method:n,headers:r,body:o,validateResponse:s,fetchOptions:i})=>{let a=await fetch(e,{...i,method:n,headers:r,body:o}),c=a.headers.get("content-type");if(c?.includes("application/")&&c?.includes("json")){let l={status:a.status,body:await a.json(),headers:a.headers},p=t.responses[l.status];return(s??t.validateResponseOnClient)&&zNe(p)?{...l,body:p.parse(l.body)}:l}return c?.includes("text/")?{status:a.status,body:await a.text(),headers:a.headers}:{status:a.status,body:await a.blob(),headers:a.headers}},nbe=t=>{let e=new FormData,n=(r,o)=>{o instanceof File?e.append(r,o):e.append(r,JSON.stringify(o))};return Object.entries(t).forEach(([r,o])=>{if(Array.isArray(o))for(let s of o)n(r,s);else n(r,o)}),e},C3=t=>Object.fromEntries(Object.entries(t).map(([e,n])=>[e.toLowerCase(),n])),rbe=t=>{let{path:e,clientArgs:n,route:r,body:o,query:s,extraInputArgs:i,headers:a,fetchOptions:c}=t,l=n.api||tbe,p=n.baseHeaders&&Object.fromEntries(Object.entries(n.baseHeaders).map(([f,m])=>typeof m=="function"?[f,m(t)]:[f,m])),d={...p&&C3(p),...C3(a)};Object.keys(d).forEach(f=>{d[f]===void 0&&delete d[f]});let _={route:r,path:e,method:r.method,headers:d,body:void 0,rawBody:o,rawQuery:s,contentType:void 0,validateResponse:n.validateResponse,fetchOptions:{...n.credentials&&{credentials:n.credentials},...c},...c?.signal&&{signal:c.signal},...c?.cache&&{cache:c.cache},...c&&"next"in c&&!!c?.next&&{next:c.next}};return r.method!=="GET"&&("contentType"in r&&r.contentType==="multipart/form-data"?_={..._,contentType:"multipart/form-data",body:o instanceof FormData?o:nbe(o)}:"contentType"in r&&r.contentType==="application/x-www-form-urlencoded"?_={..._,contentType:"application/x-www-form-urlencoded",headers:{"content-type":"application/x-www-form-urlencoded",..._.headers},body:typeof o=="string"?o:new URLSearchParams(o)}:o!=null&&(_={..._,contentType:"application/json",headers:{"content-type":"application/json",..._.headers},body:JSON.stringify(o)})),l({..._,...i})},obe=(t,e,n)=>{let{query:r,params:o,body:s,headers:i,extraHeaders:a,overrideClientOptions:c,fetchOptions:l,cache:p,next:d,..._}=n||{},f={...e,...c};return{path:sbe(r,f.baseUrl,o,t,!!f.jsonQuery),clientArgs:f,route:t,body:s,query:r,extraInputArgs:_,fetchOptions:{...p&&{cache:p},...d&&{next:d},...l},headers:{...a,...i}}},sbe=(t,e,n,r,o)=>{let s=XNe({path:r.path,params:n}),i=JNe(t,o);return`${e}${s}${i}`},ibe=(t,e)=>{let n=Object.keys(t.responses);return async r=>{let o=obe(t,e,r),s=await rbe(o);if(!e.throwOnUnknownStatus||n.includes(s.status.toString()))return s;throw new TC(s,n)}},EC=(t,e)=>Object.fromEntries(Object.entries(t).map(([n,r])=>P3(r)?[n,ibe(r,e)]:[n,EC(r,e)]));var SC=["free","creator","team"],x3=typeof process<"u"&&process.env?.NODE_ENV!=="production",abe={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:x3?"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:x3?"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 v3=abe.stripe.plans,_5e=Object.freeze(Object.fromEntries(v3.map(t=>[t.tier,t])));var cbe=gr(),rn=u.object({message:u.string()}),gC=u.record(u.unknown()),Fa=u.string().regex(/^doc_[0-9A-Za-z]{22}$/),zS=u.string().regex(/^proj_[0-9A-Za-z]{22}$/),ube=["active","archived"],KS=u.enum(ube),L3=u.object({id:u.string().min(1),display_name:u.string().min(1)}),D3=u.object({id:zS,name:u.string().min(1)}),AC=u.object({id:Fa,title:u.string().min(1),status:KS,author:L3,project:D3.nullable(),created_at:u.string().datetime(),updated_at:u.string().datetime(),archived_at:u.string().datetime().nullable()}),lbe=u.object({type:u.literal("list"),list_type:u.literal("doc"),objects:u.array(AC)}),pbe=u.object({project_id:zS.optional(),status:KS.optional()}),dbe=u.object({title:u.string().trim().min(1).max(300).optional(),prosemirror_json:gC.optional(),project_id:zS.nullable().optional()}),_be=u.object({id:Fa,created_at:u.string().datetime()}),fbe=u.object({title:u.string().trim().min(1).max(300).optional(),prosemirror_json:gC.optional(),project_id:zS.nullable().optional(),status:KS.optional()}).refine(t=>Object.keys(t).length>0,{message:"At least one field must be provided"}),mbe=u.object({id:Fa,updated_at:u.string().datetime()}),hbe=u.object({id:Fa,title:u.string().min(1),prosemirror_json:gC,status:KS,author:L3,project:D3.nullable(),created_at:u.string().datetime(),updated_at:u.string().datetime(),archived_at:u.string().datetime().nullable()}),U3=cbe.router({listDocs:{method:"GET",path:"/docs",headers:u.object({authorization:u.string().min(1).optional()}),query:pbe,responses:{200:lbe,401:rn,403:rn},summary:"List docs in the authenticated user\u2019s organization. Optional project_id filter scopes to a single project."},createDoc:{method:"POST",path:"/docs",headers:u.object({authorization:u.string().min(1).optional()}),body:dbe,responses:{201:_be,401:rn,403:rn,404:rn,422:rn},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:u.object({docId:Fa}),headers:u.object({authorization:u.string().min(1).optional()}),responses:{200:hbe,401:rn,403:rn,404:rn},summary:"Get a doc by id with its rich-text body and parent project (if any)"},updateDoc:{method:"PATCH",path:"/docs/:docId",pathParams:u.object({docId:Fa}),headers:u.object({authorization:u.string().min(1).optional()}),body:fbe,responses:{200:mbe,401:rn,403:rn,404:rn,422:rn},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:u.object({docId:Fa}),headers:u.object({authorization:u.string().min(1).optional()}),body:u.object({}).optional(),responses:{204:u.object({}),401:rn,403:rn,404:rn},summary:"Hard-delete a doc and any mention references it owns"}});var Tbe=gr(),et=u.object({message:u.string()}),RC=u.record(u.unknown()),yo=u.string().regex(/^proj_[0-9A-Za-z]{22}$/),Ebe=["active","archived"],QS=u.enum(Ebe),yC=u.object({id:u.string().min(1),display_name:u.string().min(1)}),w3=u.object({thread_id:u.string().min(1),title:u.string().min(1),added_at:u.string().datetime(),added_by:yC}),Sbe=u.object({id:yo,name:u.string().min(1),status:QS,author:yC,thread_count:u.number().int().nonnegative(),doc_count:u.number().int().nonnegative(),created_at:u.string().datetime(),updated_at:u.string().datetime(),archived_at:u.string().datetime().nullable()}),gbe=u.object({type:u.literal("list"),list_type:u.literal("project"),objects:u.array(Sbe)}),Abe=u.object({status:QS.optional()}),Rbe=u.object({name:u.string().trim().min(1).max(200),prosemirror_json:RC.optional()}),ybe=u.object({id:yo,created_at:u.string().datetime()}),Ibe=u.object({name:u.string().trim().min(1).max(200).optional(),prosemirror_json:RC.optional()}).refine(t=>Object.keys(t).length>0,{message:"At least one field must be provided"}),Obe=u.object({id:yo,updated_at:u.string().datetime()}),Nbe=u.object({archived:u.boolean()}),bbe=u.object({id:yo,status:QS,archived_at:u.string().datetime().nullable()}),Cbe=u.object({id:yo,name:u.string().min(1),prosemirror_json:RC,status:QS,author:yC,created_at:u.string().datetime(),updated_at:u.string().datetime(),archived_at:u.string().datetime().nullable(),threads:u.array(w3),docs:u.array(AC)}),Pbe=u.object({thread_id:u.string().min(1).max(64)}),Mbe=w3,k3=Tbe.router({listProjects:{method:"GET",path:"/projects",headers:u.object({authorization:u.string().min(1).optional()}),query:Abe,responses:{200:gbe,401:et},summary:"List projects in the authenticated user\u2019s organization"},createProject:{method:"POST",path:"/projects",headers:u.object({authorization:u.string().min(1).optional()}),body:Rbe,responses:{201:ybe,401:et,422:et},summary:"Create a new project in the authenticated user\u2019s organization"},getProject:{method:"GET",path:"/projects/:projectId",pathParams:u.object({projectId:yo}),headers:u.object({authorization:u.string().min(1).optional()}),responses:{200:Cbe,401:et,403:et,404:et},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:u.object({projectId:yo}),headers:u.object({authorization:u.string().min(1).optional()}),body:Ibe,responses:{200:Obe,401:et,403:et,404:et,422:et},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:u.object({projectId:yo}),headers:u.object({authorization:u.string().min(1).optional()}),body:Nbe,responses:{200:bbe,401:et,403:et,404:et},summary:"Archive (soft-delete) or unarchive a project"},addProjectThread:{method:"POST",path:"/projects/:projectId/threads",pathParams:u.object({projectId:yo}),headers:u.object({authorization:u.string().min(1).optional()}),body:Pbe,responses:{201:Mbe,401:et,403:et,404:et,409:et,422:et},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:u.object({projectId:yo,threadId:u.string().min(1).max(64)}),headers:u.object({authorization:u.string().min(1).optional()}),body:u.object({}).optional(),responses:{204:u.object({}),401:et,403:et,404:et},summary:"Remove a thread membership from a project"}});var xbe=gr(),XS=u.object({message:u.string()}),vbe=["thread","plan","doc","user"],JS=u.enum(vbe),Lbe=["doc","project"],Dbe=u.enum(Lbe),Ube=u.object({kind:JS,id:u.string().min(1),title:u.string().min(1),href:u.string().min(1)}),wbe=u.object({type:u.literal("list"),list_type:u.literal("mention"),objects:u.array(Ube)}),kbe=u.object({q:u.string().trim().min(1).max(50),kinds:u.string().optional().transform(t=>{if(!t)return;let e=t.split(",").map(n=>n.trim()).filter(n=>n.length>0);return e.length>0?e:void 0}).pipe(u.array(JS).optional())}),Gbe=u.object({source_kind:Dbe,source_id:u.string().min(1),source_title:u.string().min(1),source_href:u.string().min(1),target_kind:JS,target_id:u.string().min(1),created_at:u.string().datetime()}),Bbe=u.object({type:u.literal("list"),list_type:u.literal("backlink"),objects:u.array(Gbe)}),jbe=u.object({target_kind:JS,target_id:u.string().min(1).max(64)}),G3=xbe.router({searchMentions:{method:"GET",path:"/mentions/search",headers:u.object({authorization:u.string().min(1).optional()}),query:kbe,responses:{200:wbe,401:XS,422:XS},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:u.object({authorization:u.string().min(1).optional()}),query:jbe,responses:{200:Bbe,401:XS,403:XS},summary:"List every doc/project body in the caller\u2019s organization that mentions the given target. Newest-first."}});var Hbe=gr(),Fbe=u.object({type:u.literal("list"),list_type:u.literal("thread"),has_more:u.boolean(),objects:u.array(u.unknown())}),Si=u.object({message:u.string()}),B3=u.object({thread_id:u.string().min(1),is_favorited:u.boolean(),favorited_at:u.string().datetime().nullable()}),Vbe=u.object({before:u.string().min(1).max(64).optional()}),j3=Hbe.router({addThreadFavorite:{method:"POST",path:"/threads/:id/favorite",pathParams:u.object({id:u.string().min(1).max(64)}),headers:u.object({authorization:u.string().min(1).optional()}),body:u.object({}).optional(),responses:{201:B3,401:Si,403:Si,404:Si},summary:"Bookmark a thread for the authenticated user. Idempotent \u2014 re-favoriting returns the existing membership."},removeThreadFavorite:{method:"DELETE",path:"/threads/:id/favorite",pathParams:u.object({id:u.string().min(1).max(64)}),headers:u.object({authorization:u.string().min(1).optional()}),body:u.object({}).optional(),responses:{200:B3,401:Si,403:Si,404:Si},summary:"Remove a thread bookmark for the authenticated user (no-op if absent)."},listFavoriteThreads:{method:"GET",path:"/favorites/threads",headers:u.object({authorization:u.string().min(1).optional()}),query:Vbe,responses:{200:Fbe,401:Si,403:Si},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 qbe=gr(),IC=u.object({message:u.string()}),$be=u.object({id:u.string().min(1),title:u.string(),href:u.string().min(1),author_display_name:u.string().nullable(),author_handle:u.string().nullable()}),Ybe=u.object({name:u.string().min(1),usage_count:u.number().int().nonnegative(),href:u.string().min(1)}),Wbe=u.object({id:u.string().min(1),display_name:u.string(),handle:u.string().nullable(),avatar_url:u.string().nullable(),href:u.string().min(1)}),zbe=u.object({type:u.literal("global_search"),threads:u.array($be),skills:u.array(Ybe),people:u.array(Wbe)}),Kbe=u.object({q:u.string().trim().min(1).max(80)}),H3=qbe.router({globalSearch:{method:"GET",path:"/search",headers:u.object({authorization:u.string().min(1).optional()}),query:Kbe,responses:{200:zbe,401:IC,403:IC,422:IC},summary:"Global navbar search across threads, skills, and people. Org-scoped, max 5 results per kind."}});var Qbe=gr(),Xbe=u.object({id:u.string().uuid(),role:u.enum(["user","assistant"]),content:u.string().min(1),timestamp:u.string().datetime()}),Jbe=u.object({id:u.string().uuid(),title:u.string().min(1),author:u.string().min(1),authorAvatar:u.string().min(1).max(4),model:u.string().min(1),turnCount:u.number().int().nonnegative(),createdAt:u.string().datetime(),preview:u.string()}),Q5e=Jbe.extend({messages:u.array(Xbe)}),A=u.object({message:u.string()}),Zbe=/^[a-zA-Z0-9_-]{2,32}$/,K3=u.string().regex(Zbe,"Handle must be 2\u201332 characters: letters, numbers, dashes, or underscores."),OC=u.object({id:u.string(),first_name:u.string().min(1),last_name:u.string().min(1),display_name:u.string().min(1),stytch_id:u.string().nullable(),handle:u.string().nullable(),bio:u.string().max(280).nullable(),avatar_url:u.string().nullable(),banner_url:u.string().nullable(),share_new_threads_to_workspace:u.boolean(),experimental_features_enabled:u.boolean(),onboarded_at:u.string().nullable()}),eCe=u.object({stytchMemberId:u.string().min(1).optional(),emailAddress:u.string().email(),name:u.string().nullable(),user:OC,is_admin:u.boolean()}),tCe=u.object({share_new_threads_to_workspace:u.boolean().optional(),experimental_features_enabled:u.boolean().optional(),onboarded_at:u.union([u.literal("now"),u.null()]).optional(),display_name:u.string().min(1).max(120).optional(),handle:K3.optional(),bio:u.string().max(280).nullable().optional(),avatar_storage_url:u.string().min(1).nullable().optional(),banner_storage_url:u.string().min(1).nullable().optional()}).refine(t=>Object.keys(t).length>0,{message:"At least one field must be provided"}),nCe=u.object({id:u.string(),display_name:u.string(),handle:u.string().nullable(),avatar_url:u.string().nullable(),visible_thread_count:u.number().int().nonnegative(),last_active_at:u.string().datetime().nullable()}),Q3=u.object({id:u.string().min(1),display_name:u.string().min(1),handle:u.string().nullable(),bio:u.string().max(280).nullable(),avatar_url:u.string().nullable(),banner_url:u.string().nullable(),organization_name:u.string().min(1).nullable(),created_at:u.string().min(1),visible_thread_count:u.number().int().nonnegative(),follower_count:u.number().int().nonnegative(),following_count:u.number().int().nonnegative(),published_project_count:u.number().int().nonnegative(),is_following:u.boolean(),is_self:u.boolean()}),rCe=u.object({type:u.literal("list"),list_type:u.literal("organization_member"),objects:u.array(nCe)}),oCe=u.object({email_address:u.string().email()}),sCe=u.object({email_address:u.string().email(),member_id:u.string().min(1)}),iCe=u.object({location:u.string().trim().min(1),contact:u.string().trim().email()}),aCe=u.object({location:u.string().min(1),contact:u.string().email(),created_at:u.string().datetime()}),cCe=u.object({first_name:u.string().min(1),last_name:u.string().min(1),display_name:u.string().min(1),stytch_id:u.string().min(1).optional()}),uCe=u.object({name:u.string().min(1),email_domains:u.array(u.string().min(1)).nonempty(),stytch_org_id:u.string().min(1)}),lCe=u.object({user:cCe,organization:uCe}),pCe=u.object({path_glob:u.string().min(1),name:u.string().min(1),description:u.string().min(1)}),dCe=u.object({repo_origin_path:u.string().min(1),building_blocks:u.array(pCe)}),X3=u.string().regex(/^th_[0-9A-Za-z]{22}$/),eg=u.string().regex(/^tb_[0-9A-Za-z]{22}$/),_Ce=u.object({id:X3,author:u.object({id:u.string().min(1),display_name:u.string().min(1)}),body:u.string(),created_at:u.string().datetime(),repo_origin_path:u.string().min(1),latest_revision_id:eg,revision_count:u.number().int().positive()}),fCe=u.object({id:u.string().min(1),display_name:u.string().min(1)}),mCe=u.object({id:u.string().min(1),author_id:u.string().min(1).nullable(),author:fCe.nullable(),created_at:u.string().datetime(),deleted_at:u.string().datetime().nullable(),content:u.string().min(1)}),hCe=u.object({id:u.string().min(1),thread_block_id:u.string().min(1),created_at:u.string().datetime(),resolved_at:u.string().datetime().nullable(),comments:u.array(mCe)}),TCe=u.object({thread_block_id:eg,from_position:u.number().int().positive(),to_position:u.number().int().positive(),selected_text:u.string().min(1),content:u.string().trim().min(1)}),ECe=u.object({id:u.string().min(1)}),SCe=u.object({content:u.string().trim().min(1)}),gCe=u.object({id:u.string().min(1)}),ACe=u.object({content:u.string().trim().min(1)}),RCe=u.object({id:u.string().min(1)}),yCe=u.object({content:u.string().trim().min(1)}),ICe=u.object({id:u.string().min(1)}),OCe=u.object({resolved:u.boolean()}),NCe=u.object({id:u.string().min(1),resolved_at:u.string().datetime().nullable()}),bCe=u.object({resolved:u.boolean()}),CCe=u.object({id:u.string().min(1),resolved_at:u.string().datetime().nullable()}),J3=u.record(u.unknown()),PCe=u.object({id:eg,body:u.string(),created_at:u.string().datetime(),prosemirror_json:J3,comment_threads:u.array(hCe)}),MCe=u.object({id:X3,created_at:u.string().datetime(),repo_origin_path:u.string().min(1),author:u.object({id:u.string().min(1),display_name:u.string().min(1)}),latest_revision_id:eg,revision_count:u.number().int().positive(),revisions:u.array(PCe)}),xCe=u.object({type:u.literal("list"),list_type:u.literal("plan"),has_more:u.boolean(),objects:u.array(_Ce)}),vCe=u.object({before:u.string().min(1).optional(),after:u.string().min(1).optional(),author_id:u.string().min(1).optional(),repo_origin_path:u.string().min(1).optional()}),Z3=u.object({id:u.string().min(1),organization_id:u.string().min(1),created_at:u.string().min(1),repo_origin_path:u.string().min(1),path_glob:u.string().min(1),name:u.string().min(1),description:u.string().min(1)}),LCe=u.array(Z3),DCe=u.object({type:u.literal("list"),list_type:u.literal("building_block"),has_more:u.boolean(),objects:u.array(Z3)}),UCe=u.object({repo_origin_path:u.string().min(1),before:u.string().min(1).optional(),after:u.string().min(1).optional()}),wCe=u.enum(["thread","building_block"]),kCe=u.object({repo_origin_path:u.string().min(1),sources:u.array(wCe).nonempty()}),GCe=u.object({type:u.literal("list"),list_type:u.literal("repository"),has_more:u.boolean(),objects:u.array(kCe)}),gi=u.enum(["claudeCode","codex","amp","cursor","unspecified"]),BCe=["transcript","plan"],jCe=u.enum(BCe),HCe=u.object({md5:u.string().min(1),harness:gi,filename:u.string().min(1).optional(),repo_origin_path:u.string().min(1).optional(),harness_internal_id:u.string().min(1).optional(),file_type:jCe.optional()}).refine(t=>(t.filename?.trim().length??0)>0||(t.harness_internal_id?.trim().length??0)>0,{path:["harness_internal_id"],message:"filename or harness_internal_id is required"}),bC=u.object({id:u.string().min(1),display_name:u.string().min(1)}),FCe=u.object({id:u.string().min(1),display_name:u.string().min(1)}),e9=u.object({id:u.string().min(1),author_id:u.string().min(1).nullable(),author:FCe.nullable(),created_at:u.string().datetime(),deleted_at:u.string().datetime().nullable(),content:u.string().min(1)}),t9=u.object({id:u.string().min(1),thread_block_id:u.string().min(1),created_at:u.string().datetime(),resolved_at:u.string().datetime().nullable()}),VCe=t9.extend({comments:u.array(e9)}),t_=u.object({id:u.string().min(1),type:u.string().min(1),index_in_thread:u.number().int().nonnegative(),isCritiqued:u.boolean(),comment_threads:u.array(VCe).optional()}).passthrough(),n9=u.object({type:u.literal("list"),list_type:u.literal("thread_block"),has_more:u.boolean(),objects:u.array(t_)}),F3=t_.extend({type:u.literal("plan"),prosemirror_json:J3,thread_file_id:u.string().min(1)}),qCe=u.union([u.literal(-1),u.literal(1)]),r9=u.union([u.literal(-1),u.literal(0),u.literal(1)]),V3=u.object({score:u.number().int(),up_count:u.number().int().nonnegative(),down_count:u.number().int().nonnegative(),viewer_vote:r9}),$Ce=u.object({value:qCe}),YCe=u.object({id:u.string().min(1),display_name:u.string().min(1),avatar_url:u.string().nullable()}),Va=u.object({id:u.string().min(1),thread_id:u.string().min(1),author_id:u.string().min(1).nullable(),author:YCe.nullable(),parent_comment_id:u.string().min(1).nullable(),content:u.string(),created_at:u.string().datetime(),updated_at:u.string().datetime(),deleted_at:u.string().datetime().nullable()}),WCe=u.object({type:u.literal("list"),list_type:u.literal("thread_comment"),objects:u.array(Va)}),zCe=u.object({content:u.string().trim().min(1).max(4e3),parent_comment_id:u.string().min(1).optional()}),KCe=Va,QCe=u.object({content:u.string().trim().min(1).max(4e3)}),XCe=Va,JCe=Va,X5e=u.discriminatedUnion("kind",[u.object({kind:u.literal("created"),thread_id:u.string().min(1),actor_user_id:u.string().min(1),version:u.number(),comment:Va}),u.object({kind:u.literal("updated"),thread_id:u.string().min(1),actor_user_id:u.string().min(1),version:u.number(),comment:Va}),u.object({kind:u.literal("deleted"),thread_id:u.string().min(1),actor_user_id:u.string().min(1),version:u.number(),comment:Va})]),ZCe=u.enum(["pending","generating","ready","failed"]),ePe=u.enum(["pending","generating","ready","failed"]),tPe=u.enum(["pending","placeholder","ai","user"]),o9=u.enum(["pending","generating","ready","failed"]),s9=u.enum(["pending","generating","ready","failed","disabled"]),i9=u.enum(["pending","generating","ready","failed"]),nPe=u.object({title:u.string().min(1),body:u.string().min(1),files:u.array(u.string()).optional()}),rPe=u.object({status:s9,url:u.string().nullable(),url_expires_at:u.string().nullable(),generated_at:u.string().nullable(),model:u.string().nullable()}),oPe=u.object({status:i9,steps:u.array(nPe),generated_at:u.string().nullable()}),sPe=u.object({remix_of_thread_id:u.string().nullable(),remix_count:u.number().int().nonnegative()}),iPe=u.object({cover:rPe,how_to:oPe,lineage:sPe}),aPe=u.enum(["asked","requested","decided","corrected","shared"]),cPe=u.object({id:u.string().min(1),kind:aPe,summary:u.string().min(1),block_id:u.string().min(1)}),uPe=u.object({type:u.literal("list"),list_type:u.literal("thread_decision"),status:o9,generated_at:u.string().nullable(),objects:u.array(cPe)}),hl=u.object({id:u.string().min(1),thread_file_id:u.string().min(1),organization_id:u.string().min(1),author:bC,repo:u.string().min(1),title:u.string().min(1),started_at:u.string().min(1),blocks:n9,user_message_count:u.number().int().nonnegative(),files_touched:u.array(u.string()),skills_invoked:u.array(u.string()),harness:gi,transcript_parsing_state:u.enum(["pending","parsed","too_large_to_parse"]),visibility:u.enum(["private","workspace","public"]),has_plan:u.boolean().optional(),summary:u.string().nullable(),summary_status:ZCe,summary_generated_at:u.string().nullable(),title_status:ePe,title_generated_at:u.string().nullable(),title_source:tPe,decisions_status:o9,decisions_generated_at:u.string().nullable(),score:u.number().int(),up_count:u.number().int().nonnegative(),down_count:u.number().int().nonnegative(),viewer_vote:r9,comment_count:u.number().int().nonnegative(),is_favorited:u.boolean(),card:iPe}),lPe=u.object({storage_url:u.string().min(1)}),pPe=u.object({storage_url:u.string(),harness:gi,thread:hl.nullable()}),dPe=u.object({status:u.literal("complete"),thread_files:u.array(pPe)}),_Pe=u.object({id:u.string(),presigned_url:u.string().nullable(),presigned_url_expires_at:u.string().nullable(),storage_url:u.string(),harness:gi,expected_md5:u.string(),error:u.string().nullable(),thread:hl.nullable()}),fPe=u.object({id:u.string(),substrate:u.enum(["s3","filesystem"]),status:u.enum(["incomplete","locked_for_parsing","complete","error"]),thread_files:u.array(_Pe)}),mPe=u.object({visibility:u.enum(["private","workspace","public"]).optional(),title:u.string().trim().min(1).max(200).optional()}).refine(t=>t.visibility!==void 0||t.title!==void 0,{message:"At least one of visibility or title must be provided"}),hPe=u.discriminatedUnion("visibility",[u.object({visibility:u.literal("private")}),u.object({visibility:u.literal("workspace")}),u.object({visibility:u.literal("public"),title:u.string().min(1),author_display_name:u.string().min(1),first_user_message:u.string().nullable(),summary:u.string().nullable(),started_at:u.string().min(1),harness:gi})]),TPe=hl,q3=u.object({type:u.literal("list"),list_type:u.literal("thread"),has_more:u.boolean(),objects:u.array(TPe)}),EPe=u.enum(["recent","popular"]),SPe=hl,gPe=u.object({type:u.literal("list"),list_type:u.literal("discover_thread"),has_more:u.boolean(),objects:u.array(SPe)}),APe=u.object({before:u.string().min(1).optional(),after:u.string().min(1).optional(),sort:EPe.optional(),harness:gi.optional(),search:u.string().max(200).optional()}),RPe=u.object({thread_count:u.number().int().nonnegative(),author_count:u.number().int().nonnegative(),organization_count:u.number().int().nonnegative(),harness_breakdown:u.record(gi,u.number().int().nonnegative())}),yPe=u.object({id:u.string(),status:u.enum(["incomplete","locked_for_parsing","complete","error"]),created_at:u.string(),thread_count:u.number().int().nonnegative()}),IPe=u.object({type:u.literal("list"),list_type:u.literal("upload_session"),objects:u.array(yPe)}),OPe=u.object({before:u.string().min(1).optional(),after:u.string().min(1).optional()}),NPe=u.object({before:u.string().min(1).optional(),after:u.string().min(1).optional(),author_ids:u.string().min(1).optional(),created_at:u.string().min(1).optional(),filepath_prefixes:u.string().min(1).optional()}),bPe=u.object({path:u.string().min(1),start_offset:u.number().int().nonnegative(),end_offset:u.number().int().positive()}),CPe=u.object({name:u.string(),usage_count:u.number().int().nonnegative(),author_count:u.number().int().nonnegative(),first_used_at:u.string().nullable(),last_used_at:u.string().nullable(),usage_count_last_24h:u.number().int().nonnegative(),usage_count_last_7d:u.number().int().nonnegative()}),PPe=u.object({type:u.literal("list"),list_type:u.literal("skill"),objects:u.array(CPe)}),MPe=u.object({id:u.string(),title:u.string(),visibility:u.enum(["private","workspace","public"]),started_at:u.string(),author:bC,skills_invoked:u.array(u.string())}),xPe=u.object({name:u.string(),usage_count:u.number().int().nonnegative(),author_count:u.number().int().nonnegative(),first_used_at:u.string().nullable(),last_used_at:u.string().nullable(),threads:u.array(MPe)}),vPe=u.object({path:u.string().min(1),text:u.string().max(64e3)}),LPe=u.enum(["text_edit","redact","delete_block"]),DPe=u.object({id:u.string(),thread_block_id:u.string(),editor:u.object({id:u.string(),display_name:u.string()}),kind:LPe,path:u.string().nullable(),previous_text:u.string().nullable(),new_text:u.string().nullable(),created_at:u.string()}),UPe=u.object({type:u.literal("list"),list_type:u.literal("thread_block_edit"),objects:u.array(DPe)}),wPe=u.object({organization_count:u.number().int().nonnegative(),user_count:u.number().int().nonnegative(),thread_count:u.number().int().nonnegative(),thread_count_last_24h:u.number().int().nonnegative(),user_count_last_24h:u.number().int().nonnegative()}),kPe=u.object({id:u.string(),name:u.string(),email_domains:u.array(u.string()),stytch_org_id:u.string(),member_count:u.number().int().nonnegative(),thread_count:u.number().int().nonnegative(),default_thread_visibility:u.enum(["private","workspace","public"]),created_at:u.string()}),GPe=u.object({type:u.literal("list"),list_type:u.literal("admin_organization"),objects:u.array(kPe)}),a9=u.object({id:u.string(),name:u.string()}),BPe=u.object({id:u.string(),display_name:u.string(),stytch_id:u.string().nullable(),thread_count:u.number().int().nonnegative(),onboarded_at:u.string().nullable(),created_at:u.string(),organizations:u.array(a9)}),jPe=u.object({type:u.literal("list"),list_type:u.literal("admin_user"),objects:u.array(BPe)}),HPe=u.object({id:u.string(),title:u.string(),started_at:u.string(),created_at:u.string(),deleted_at:u.string().nullable(),visibility:u.enum(["private","workspace","public"]),harness:gi,author:bC,organization:a9}),FPe=u.object({type:u.literal("list"),list_type:u.literal("admin_thread"),has_more:u.boolean(),objects:u.array(HPe)}),VPe=u.object({before:u.string().min(1).optional(),after:u.string().min(1).optional()}),$3=u.object({token:u.string().min(1),thread_id:u.string().min(1)}),qPe=u.object({visitor:u.string().min(1).max(64).optional()}),$Pe=u.object({user_id:u.string(),display_name:u.string(),shares_sent:u.number().int().nonnegative(),unique_viewers:u.number().int().nonnegative(),attributed_signups:u.number().int().nonnegative()}),YPe=u.object({window_days:u.number().int().positive(),shares_sent:u.number().int().nonnegative(),unique_viewers:u.number().int().nonnegative(),attributed_signups:u.number().int().nonnegative(),active_sharers:u.number().int().nonnegative(),k_factor:u.number().nullable(),shares_sent_sparkline:u.array(u.number().int().nonnegative()),top_sharers:u.array($Pe)}),WPe=u.object({windows:u.array(YPe)}),zPe=u.object({quoted_text:u.string().min(1),comment:u.string().nullable(),type:u.enum(["comment","highlight:trapdoor"])}),KPe=t9,QPe=e9.extend({comment_thread_id:u.string().min(1)}),XPe=u.object({markdown:u.string().min(1)}),JPe=u.object({storage_url:u.string().min(1),thread_file_id:u.string().min(1),parsed_plan_block:F3,critiqued_plan_block:F3,annotations:u.array(zPe),comment_threads:u.array(KPe),comments:u.array(QPe)}),Tl=u.enum(SC),c9=u.object({skills:u.boolean(),workspace_scope:u.boolean(),review:u.boolean(),shared_thread_ttl_days:u.number().int().positive().nullable()}),NC=u.object({subject_type:u.enum(["user","organization"]),subject_id:u.string().min(1),effective_plan:Tl,admin_override:Tl.nullable(),stripe_subscription_status:u.string().nullable(),cancel_at_period_end:u.boolean(),current_period_end:u.string().nullable(),seat_quantity:u.number().int().positive(),member_count:u.number().int().nonnegative().nullable(),features:c9}),ZPe=u.object({effective_plan:Tl,features:c9,user:NC,organization:NC.nullable()}),eMe=u.object({plan:u.enum(["creator","team"]),seat_quantity:u.number().int().positive().optional()}),tMe=u.object({checkout_url:u.string().min(1)}),nMe=u.object({portal_url:u.string().min(1)}),rMe=u.object({seat_quantity:u.number().int().positive()}),Y3=u.object({plan:Tl.nullable()}),ZS=u.object({subject_type:u.enum(["user","organization"]),subject_id:u.string().min(1),label:u.string().min(1),effective_plan:Tl,admin_override:Tl.nullable(),stripe_subscription_status:u.string().nullable(),seat_quantity:u.number().int().positive()}),oMe=u.object({users:u.array(ZS),organizations:u.array(ZS)}),sMe=u.object({id:u.string().min(1),display_name:u.string().min(1),handle:u.string().nullable(),avatar_url:u.string().nullable()}),iMe=u.object({thread_id:u.string().min(1),title:u.string().min(1),author:sMe,last_active_at:u.string().datetime(),last_block_excerpt:u.string().nullable(),last_block_kind:u.string().min(1).nullable(),is_streaming:u.boolean()}),aMe=u.object({type:u.literal("list"),list_type:u.literal("live_thread"),objects:u.array(iMe)}),cMe=u.object({thread_id:u.string().min(1)}),uMe=u.object({thread_id:u.string().min(1),last_seen_at:u.string().datetime(),started_at:u.string().datetime()}),lMe=u.object({follower_id:u.string().min(1),followee_id:u.string().min(1),is_following:u.literal(!0),follower_count:u.number().int().nonnegative()}),pMe=u.object({follower_id:u.string().min(1),followee_id:u.string().min(1),is_following:u.literal(!1),follower_count:u.number().int().nonnegative()}),u9=u.object({id:u.string().min(1),display_name:u.string().min(1),handle:u.string().nullable(),avatar_url:u.string().nullable(),bio:u.string().max(280).nullable(),is_following:u.boolean(),is_self:u.boolean()}),W3=u.object({type:u.literal("list"),list_type:u.literal("user_follow"),objects:u.array(u9)}),dMe=u.object({date:u.string().regex(/^\d{4}-\d{2}-\d{2}$/),count:u.number().int().nonnegative()}),_Me=u.object({window_start:u.string().datetime(),window_end:u.string().datetime(),total_contributions:u.number().int().nonnegative(),days_active:u.number().int().nonnegative(),daily_average:u.number().nonnegative(),current_streak_days:u.number().int().nonnegative(),days:u.array(dMe)}),fMe=u.object({type:u.literal("thread_created"),occurred_at:u.string().datetime(),id:u.string().min(1),thread:u.object({id:u.string().min(1),title:u.string(),visibility:u.enum(["private","workspace","public"])})}),mMe=u.object({type:u.literal("comment_posted"),occurred_at:u.string().datetime(),id:u.string().min(1),comment_excerpt:u.string(),thread:u.object({id:u.string().min(1),title:u.string(),visibility:u.enum(["private","workspace","public"])})}),hMe=u.object({type:u.literal("project_published"),occurred_at:u.string().datetime(),id:u.string().min(1),project:u.object({id:u.string().min(1),name:u.string().min(1)})}),TMe=u.object({type:u.literal("user_followed"),occurred_at:u.string().datetime(),id:u.string().min(1),followee:u9}),EMe=u.discriminatedUnion("type",[fMe,mMe,hMe,TMe]),SMe=u.object({type:u.literal("list"),list_type:u.literal("user_activity"),objects:u.array(EMe)}),gMe=u.object({id:u.string().min(1),name:u.string().min(1),excerpt:u.string(),published_at:u.string().datetime(),updated_at:u.string().datetime()}),AMe=u.object({type:u.literal("list"),list_type:u.literal("profile_published_project"),objects:u.array(gMe)}),z3=u.object({id:u.string().min(1),published_at:u.string().datetime().nullable()}),RMe=u.enum(["avatar","banner"]),yMe=u.enum(["image/png","image/jpeg","image/webp","image/gif"]),IMe=u.object({kind:RMe,content_type:yMe,base64_data:u.string().min(1)}),OMe=u.object({substrate:u.enum(["s3","filesystem"]),storage_url:u.string().min(1)}),NMe=Q3,l9=Qbe.router({health:{method:"GET",path:"/health",responses:{200:u.object({status:u.literal("ok")})},summary:"Health check"},whoAmI:{method:"GET",path:"/whoami",headers:u.object({authorization:u.string().min(1).optional(),"x-lore-referral-token":u.string().min(1).max(16).optional()}),responses:{200:eCe,401:A},summary:"Validate a Stytch B2B Bearer token and return member plus user fields"},recordHeartbeat:{method:"POST",path:"/heartbeat",headers:u.object({authorization:u.string().min(1).optional()}),body:cMe,responses:{200:uMe,401:A,403:A,404:A,422:A},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:u.object({authorization:u.string().min(1).optional()}),responses:{200:aMe,401:A,403:A},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:u.object({authorization:u.string().min(1).optional()}),query:NPe,responses:{200:q3,401:A},summary:"List threads visible to the authenticated user"},getThread:{method:"GET",path:"/threads/:id",pathParams:u.object({id:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),responses:{200:hl,404:A},summary:"Load a visible thread by id"},getSimilarThreads:{method:"GET",path:"/threads/:id/similar",pathParams:u.object({id:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),responses:{200:q3,404:A,409:A},summary:"List the top 20 visible threads with the closest summary embedding"},listThreadBlocks:{method:"GET",path:"/threads/:id/blocks",pathParams:u.object({id:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),query:OPe,responses:{200:n9,401:A},summary:"List blocks for a visible thread"},createThreadBlockCommentThread:{method:"POST",path:"/threads/:threadId/blocks/:blockId/comment-threads",pathParams:u.object({threadId:u.string().min(1),blockId:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),body:SCe,responses:{201:gCe,401:A,404:A},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:u.object({threadId:u.string().min(1),blockId:u.string().min(1),commentThreadId:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),body:yCe,responses:{201:ICe,401:A,404:A,409:A},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:u.object({threadId:u.string().min(1),blockId:u.string().min(1),commentThreadId:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),body:bCe,responses:{200:CCe,401:A,404:A},summary:"Resolve or reopen a block-level comment thread on a visible thread block"},listSkills:{method:"GET",path:"/skills",headers:u.object({authorization:u.string().min(1).optional()}),responses:{200:PPe,401:A},summary:"Aggregate skill usage across threads the viewer can see"},getSkillDetail:{method:"GET",path:"/skills/:name",pathParams:u.object({name:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),responses:{200:xPe,401:A,404:A},summary:"Per-skill detail: usage stats + visible threads that invoked it"},redactThreadBlock:{method:"POST",path:"/threads/:threadId/blocks/:blockId/redactions",pathParams:u.object({threadId:u.string().min(1),blockId:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),body:bPe,responses:{200:t_,401:A,403:A,404:A,422:A},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:u.object({threadId:u.string().min(1),blockId:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),body:vPe,responses:{200:t_,401:A,403:A,404:A,422:A},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:u.object({threadId:u.string().min(1),blockId:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),body:u.object({}).optional(),responses:{200:t_,401:A,403:A,404:A,409:A,422:A},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:u.object({threadId:u.string().min(1),blockId:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),body:u.object({}).optional(),responses:{204:u.null(),401:A,403:A,404:A},summary:"Soft-delete a thread block (author only)"},listThreadBlockEdits:{method:"GET",path:"/threads/:threadId/blocks/:blockId/edits",pathParams:u.object({threadId:u.string().min(1),blockId:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),responses:{200:UPe,401:A,404:A},summary:"List edits made to a thread block (visible to anyone who can see the thread)"},listThreadDecisions:{method:"GET",path:"/threads/:id/decisions",pathParams:u.object({id:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),responses:{200:uPe,401:A,404:A},summary:"List AI-extracted user decisions for a thread, in chronological order"},updateThread:{method:"PATCH",path:"/threads/:id",pathParams:u.object({id:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),body:mPe,responses:{200:hl,401:A,403:A,404:A},summary:"Update thread visibility (author only)"},deleteThread:{method:"DELETE",path:"/threads/:id",pathParams:u.object({id:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),body:u.object({}).optional(),responses:{204:u.null(),401:A,403:A,404:A},summary:"Soft-delete a thread (author only)"},generateThreadCard:{method:"POST",path:"/threads/:id/card/generate",pathParams:u.object({id:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),body:u.object({}).optional(),responses:{200:u.object({cover_status:s9,how_to_status:i9}),401:A,403:A,404:A,429:A.extend({retry_after_seconds:u.number().int().nonnegative()})},summary:"Enqueue cover image + how-to recipe generation for the thread. Author-only. Idempotent \u2014 recently-fired statuses are not double-enqueued. Rate-limited: at most one cover generation per minute per thread (cooldown begins when the previous cover finishes). Used to populate cards on legacy threads (created before Lore Cards) and to retry after a 'failed' status or opt back in from 'disabled'."},castThreadVote:{method:"PUT",path:"/threads/:id/vote",pathParams:u.object({id:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),body:$Ce,responses:{200:V3,401:A,403:A,404:A,422:A},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:u.object({id:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),body:u.object({}).optional(),responses:{200:V3,401:A,404:A},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:u.object({threadId:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),responses:{200:WCe,403:A,404:A},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:u.object({threadId:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),body:zCe,responses:{201:KCe,401:A,403:A,404:A,422:A},summary:"Post a top-level or reply comment on a public thread."},updateThreadComment:{method:"PATCH",path:"/threads/:threadId/comments/:commentId",pathParams:u.object({threadId:u.string().min(1),commentId:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),body:QCe,responses:{200:XCe,401:A,403:A,404:A,422:A},summary:"Edit your own thread comment (author only; rejects edits to soft-deleted rows)."},deleteThreadComment:{method:"DELETE",path:"/threads/:threadId/comments/:commentId",pathParams:u.object({threadId:u.string().min(1),commentId:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),body:u.object({}).optional(),responses:{200:JCe,401:A,403:A,404:A},summary:"Soft-delete your own thread comment (author only). Idempotent."},getThreadPreview:{method:"GET",path:"/threads/:id/preview",pathParams:u.object({id:u.string().min(1)}),responses:{200:hPe,404:A},summary:"Unauthenticated, visibility-redacted metadata for OG / social preview consumers"},createUser:{method:"POST",path:"/users",headers:u.object({authorization:u.string().min(1).optional()}),body:lCe,responses:{201:OC,401:A},summary:"Create a user record with ApiKey authentication"},getUser:{method:"GET",path:"/users/:id",pathParams:u.object({id:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),responses:{200:Q3,404:A},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:u.object({authorization:u.string().min(1).optional()}),body:tCe,responses:{200:OC,401:A,409:A,422:A},summary:"Update the authenticated user profile"},getUserByHandle:{method:"GET",path:"/users/by-handle/:handle",pathParams:u.object({handle:K3}),headers:u.object({authorization:u.string().min(1).optional()}),responses:{200:NMe,404:A},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:u.object({id:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),query:u.object({limit:u.coerce.number().int().positive().max(100).optional()}),responses:{200:SMe,404:A},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:u.object({id:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),responses:{200:_Me,404:A},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:u.object({id:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),responses:{200:W3,404:A},summary:"List the users following a given user."},listUserFollowing:{method:"GET",path:"/users/:id/following",pathParams:u.object({id:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),responses:{200:W3,404:A},summary:"List the users a given user is following."},followUser:{method:"POST",path:"/users/:id/follow",pathParams:u.object({id:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),body:u.object({}).optional(),responses:{200:lMe,401:A,404:A,409:A,422:A},summary:"Follow another user. Idempotent \u2014 repeating the call is a no-op."},unfollowUser:{method:"DELETE",path:"/users/:id/follow",pathParams:u.object({id:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),body:u.object({}).optional(),responses:{200:pMe,401:A,404:A},summary:"Unfollow a user. Idempotent \u2014 repeating the call is a no-op."},listProfilePublishedProjects:{method:"GET",path:"/users/:id/projects",pathParams:u.object({id:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),responses:{200:AMe,404:A},summary:"Projects the user has published to their public profile."},publishProject:{method:"POST",path:"/projects/:id/publish",pathParams:u.object({id:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),body:u.object({}).optional(),responses:{200:z3,401:A,403:A,404:A},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:u.object({id:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),body:u.object({}).optional(),responses:{200:z3,401:A,403:A,404:A},summary:"Remove a project from the author's public profile."},uploadProfileImage:{method:"POST",path:"/users/me/profile-image",headers:u.object({authorization:u.string().min(1).optional()}),body:IMe,responses:{200:OMe,401:A,413:A,422:A},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:u.object({authorization:u.string().min(1).optional()}),responses:{200:rCe,401:A},summary:"List members of the authenticated user\u2019s organization"},createOrganizationInvite:{method:"POST",path:"/organization/invites",headers:u.object({authorization:u.string().min(1).optional()}),body:oCe,responses:{201:sCe,401:A,403:A,409:A,422:A},summary:"Invite a teammate to the authenticated user\u2019s workspace via Stytch B2B"},listRepositories:{method:"GET",path:"/repositories",headers:u.object({authorization:u.string().min(1).optional()}),responses:{200:GCe,401:A,403:A},summary:"List repositories known to the authenticated user\u2019s organization across threads and building blocks"},createBuildingBlockSnapshots:{method:"POST",path:"/building_blocks",headers:u.object({authorization:u.string().min(1).optional()}),body:dCe,responses:{201:LCe,401:A,403:A},summary:"Create building block snapshots for the authenticated user\u2019s organization"},getPlan:{method:"GET",path:"/plans/:id",pathParams:u.object({id:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),responses:{200:MCe,401:A,403:A,404:A},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:u.object({id:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),body:TCe,responses:{201:ECe,401:A,403:A,404:A,422:A},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:u.object({id:u.string().min(1),threadId:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),body:ACe,responses:{201:RCe,401:A,403:A,404:A,409:A},summary:"Reply to an inline comment thread on a thread-backed plan container"},updatePlanCommentThread:{method:"PATCH",path:"/plans/:id/comment-threads/:threadId",pathParams:u.object({id:u.string().min(1),threadId:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),body:OCe,responses:{200:NCe,401:A,403:A,404:A},summary:"Resolve or reopen an inline comment thread on a thread-backed plan container"},listPlans:{method:"GET",path:"/plans",headers:u.object({authorization:u.string().min(1).optional()}),query:vCe,responses:{200:xCe,401:A,403:A},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:u.object({authorization:u.string().min(1).optional()}),query:UCe,responses:{200:DCe,401:A,403:A},summary:"List building block snapshots for the authenticated user\u2019s organization and repo origin path"},listUploadSessions:{method:"GET",path:"/upload_sessions",headers:u.object({authorization:u.string().min(1).optional()}),responses:{200:IPe,401:A},summary:"List recent upload sessions for the authenticated user"},createUploadSession:{method:"POST",path:"/upload_sessions",headers:u.object({authorization:u.string().min(1).optional()}),body:u.object({thread_files:u.array(HCe).nonempty()}),responses:{201:fPe,400:A,401:A},summary:"Create an upload session with presigned URLs for file uploads"},completeUploadSession:{method:"POST",path:"/upload_sessions/:id/complete",pathParams:u.object({id:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),body:u.object({thread_files:u.array(lPe).nonempty()}),responses:{200:dPe,400:A,401:A,404:A,409:A,422:A},summary:"Complete an upload session after files have been uploaded to storage"},adminStats:{method:"GET",path:"/admin/stats",headers:u.object({authorization:u.string().min(1).optional()}),responses:{200:wPe,401:A,403:A},summary:"Cross-org operational counts. Tanagram admins only."},adminListOrganizations:{method:"GET",path:"/admin/organizations",headers:u.object({authorization:u.string().min(1).optional()}),responses:{200:GPe,401:A,403:A},summary:"List every organization with member and thread counts. Tanagram admins only."},adminListUsers:{method:"GET",path:"/admin/users",headers:u.object({authorization:u.string().min(1).optional()}),responses:{200:jPe,401:A,403:A},summary:"List every user with their org memberships and thread count. Tanagram admins only."},adminListThreads:{method:"GET",path:"/admin/threads",headers:u.object({authorization:u.string().min(1).optional()}),query:VPe,responses:{200:FPe,401:A,403:A},summary:"List live threads across every organization. Tanagram admins only."},adminHardDeleteThread:{method:"DELETE",path:"/admin/threads/:id",pathParams:u.object({id:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),body:u.object({}).optional(),responses:{204:u.null(),401:A,403:A,404:A},summary:"Permanently remove a thread. Tanagram admins only."},listDiscoverThreads:{method:"GET",path:"/discover/threads",headers:u.object({authorization:u.string().min(1).optional()}),query:APe,responses:{200:gPe},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:RPe},summary:"Unauthenticated rollup of public-thread counts for the Discover header."},createWaitlistEntry:{method:"POST",path:"/waitlist_entries",body:iCe,responses:{201:aCe,409:A},summary:"Create an unauthenticated waitlist entry keyed by (location, contact)."},createShareToken:{method:"POST",path:"/threads/:id/share-token",pathParams:u.object({id:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),body:u.object({}).optional(),responses:{201:$3,401:A,403:A,404:A,409:A},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:u.object({token:u.string().min(1).max(16)}),query:qPe,responses:{200:$3,404:A},summary:"Resolve a share-link token to its thread and record the view. Unauthenticated by design."},adminGrowth:{method:"GET",path:"/admin/growth",headers:u.object({authorization:u.string().min(1).optional()}),responses:{200:WPe,401:A,403:A},summary:"Share-link k-factor, funnel, sparkline, and top sharers by window. Tanagram admins only."},adminRunCritiquePlayground:{method:"POST",path:"/admin/critique-playground/run",headers:u.object({authorization:u.string().min(1).optional()}),body:XPe,responses:{200:JPe,401:A,403:A,409:A},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:u.object({authorization:u.string().min(1).optional()}),responses:{200:ZPe,401:A},summary:"Resolve the caller's plan, features, seat count, and any admin override."},createBillingCheckout:{method:"POST",path:"/billing/checkout",headers:u.object({authorization:u.string().min(1).optional()}),body:eMe,responses:{200:tMe,400:A,401:A,403:A,503:A},summary:"Start a Stripe Checkout session for Creator ($29/mo) or Team ($19/seat/mo, min 2)."},createBillingPortal:{method:"POST",path:"/billing/portal",headers:u.object({authorization:u.string().min(1).optional()}),body:u.object({subject_type:u.enum(["user","organization"]).default("user")}).optional(),responses:{200:nMe,401:A,404:A,503:A},summary:"Open the Stripe customer portal so the subject can manage their subscription."},updateTeamSeats:{method:"PATCH",path:"/billing/team-seats",headers:u.object({authorization:u.string().min(1).optional()}),body:rMe,responses:{200:NC,400:A,401:A,403:A,404:A,503:A},summary:"Adjust the caller-organization's Team seat quantity (admin of that org only)."},adminListBilling:{method:"GET",path:"/admin/billing",headers:u.object({authorization:u.string().min(1).optional()}),responses:{200:oMe,401:A,403:A},summary:"List every user and org with current plan + override for the admin panel."},adminSetUserPlanOverride:{method:"PUT",path:"/admin/billing/users/:id/override",pathParams:u.object({id:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),body:Y3,responses:{200:ZS,401:A,403:A,404:A},summary:"Admin override for a user's plan tier. Null clears the override."},adminSetOrganizationPlanOverride:{method:"PUT",path:"/admin/billing/organizations/:id/override",pathParams:u.object({id:u.string().min(1)}),headers:u.object({authorization:u.string().min(1).optional()}),body:Y3,responses:{200:ZS,401:A,403:A,404:A},summary:"Admin override for an organization's plan tier. Null clears the override."},projects:k3,docs:U3,mentions:G3,favorites:j3,search:H3},{pathPrefix:"/api"});import n_ from"node:fs";import p9 from"node:path";function tg(){return p9.join(Zo(),"token")}function CC(){let t;try{t=n_.readFileSync(tg(),"utf8")}catch(n){if(n&&typeof n=="object"&&"code"in n&&n.code==="ENOENT")return{token:"",source:"none"};throw n}let e=t.trim();return!e||CMe(e,new Date)?{token:"",source:"none"}:{token:e,source:"file"}}function ng(){return CC().token}function d9(){return n_.existsSync(tg())}function _9(t){let e=tg();n_.mkdirSync(p9.dirname(e),{recursive:!0,mode:448}),n_.writeFileSync(e,t,{mode:384})}function f9(){try{n_.rmSync(tg())}catch(t){if(t&&typeof t=="object"&&"code"in t&&t.code==="ENOENT")return;throw t}}function bMe(t){let e=t.split(".");if(e.length<2)throw new Error("invalid JWT format");return JSON.parse(Buffer.from(e[1],"base64url").toString("utf8"))}function CMe(t,e){let n;try{n=bMe(t)}catch{return!1}let r=n["https://stytch.com/session"]?.expires_at;if(typeof r!="string")return!1;let o=Date.parse(r.trim());return Number.isNaN(o)?!1:e.getTime()>=o}var PMe={dev:"http://localhost:4000",prod:"https://lore-api.tanagram.ai"};function Ai(t={}){let e=t.token??ng();return EC(l9,{baseUrl:PMe[xt()],baseHeaders:{"User-Agent":B4(),...e?{authorization:`Bearer ${e}`}:{}}})}var m9={meta:{name:"health",description:"Check API health"},async run({data:t}){pt.info("command_start",{command:"health"});let n=await(t?.client??Ai()).health();if(n.status===200){console.log(n.body.status);return}throw pt.error("health_failed",{status:n.status}),console.error(`health check failed: HTTP ${n.status}`),new Error(`health check failed: HTTP ${n.status}`)}};var h9={meta:{name:"hello",description:"Print a friendly greeting"},run(){pt.info("command_start",{command:"hello"}),console.log("hello world")}};import{spawn as xMe}from"node:child_process";import S9 from"node:crypto";import vMe from"node:http";var MMe={dev:"http://localhost:8080",prod:"https://lore.tanagram.ai"};function T9(){return MMe[xt()]}var LMe=5*60*1e3;function DMe(){return S9.randomBytes(32).toString("base64url")}function UMe(t){return S9.createHash("sha256").update(t).digest("base64url")}function wMe(t){let e;try{e=JSON.parse(Buffer.from(t.trim(),"base64url").toString("utf8"))}catch(n){throw new Error(`decoding: ${n instanceof Error?n.message:String(n)}`)}if(typeof e.session_jwt!="string"||!e.session_jwt)throw new Error("missing session token");if(typeof e.code_challenge!="string"||!e.code_challenge)throw new Error("missing code challenge");return{sessionJwt:e.session_jwt,codeChallenge:e.code_challenge}}function kMe(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function E9(t,e,n){let r=e==="success";t.writeHead(200,{"Content-Type":"text/html"}),t.end(`<!DOCTYPE html>
|
|
82
82
|
<html><head><meta charset="utf-8"><title>Lore CLI</title></head>
|
|
83
83
|
<body style="font-family:system-ui;display:flex;justify-content:center;align-items:center;min-height:100vh;margin:0;background:#fafafa">
|
|
84
84
|
<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)">
|