@tanagram/lore 0.1.34 → 0.1.35
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 +3 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -35,9 +35,9 @@ Url: ${kh(t)}`),!0}return!1}function s_e(t,e){return e?.length?Nh(t).some(n=>Ws(
|
|
|
35
35
|
`),_=m.shift();if(!_)return t.destroy(),n(new Error("No header received from proxy CONNECT response"));let h=_.split(" "),g=+(h[1]||0),E=h.slice(2).join(" "),S={};for(let b of m){if(!b)continue;let R=b.indexOf(":");if(R===-1)return t.destroy(),n(new Error(`Invalid header from proxy CONNECT response: "${b}"`));let I=b.slice(0,R).toLowerCase(),C=b.slice(R+1).trimStart(),H=S[I];typeof H=="string"?S[I]=[H,C]:Array.isArray(H)?H.push(C):S[I]=C}dT("got proxy server response: %o %o",_,S),i(),e({connect:{statusCode:g,statusText:E,headers:S},buffered:p})}t.on("error",u),t.on("end",a),s()})}function Kp(...t){y.log("[https-proxy-agent]",...t)}var Qp=class extends lT{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??{},Kp("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?EV(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:"){Kp("Creating `tls.Socket`: %o",this.connectOpts);let f=this.connectOpts.servername||this.connectOpts.host;o=NO.connect({...this.connectOpts,servername:f&&hs.isIP(f)?void 0:f})}else Kp("Creating `net.Socket`: %o",this.connectOpts),o=hs.connect(this.connectOpts);let s=typeof this.proxyHeaders=="function"?this.proxyHeaders():{...this.proxyHeaders},i=hs.isIPv6(n.host)?`[${n.host}]`:n.host,a=`CONNECT ${i}:${n.port} HTTP/1.1\r
|
|
36
36
|
`;if(r.username||r.password){let f=`${decodeURIComponent(r.username)}:${decodeURIComponent(r.password)}`;s["Proxy-Authorization"]=`Basic ${Buffer.from(f).toString("base64")}`}s.Host=`${i}:${n.port}`,s["Proxy-Connection"]||(s["Proxy-Connection"]=this.keepAlive?"Keep-Alive":"close");for(let f of Object.keys(s))a+=`${f}: ${s[f]}\r
|
|
37
37
|
`;let u=TV(o);o.write(`${a}\r
|
|
38
|
-
`);let{connect:l,buffered:d}=await u;if(e.emit("proxyConnect",l),this.emit("proxyConnect",l,e),l.statusCode===200){if(e.once("socket",L0e),n.secureEndpoint){Kp("Upgrading socket connection to TLS");let f=n.servername||n.host;return NO.connect({...EV(n,"host","path","port"),socket:o,servername:hs.isIP(f)?void 0:f})}return o}o.destroy();let p=new hs.Socket({writable:!1});return p.readable=!0,e.once("socket",f=>{Kp("Replaying proxy buffer for failed request"),f.push(d),f.push(null)}),p}};Qp.__initStatic();function L0e(t){t.resume()}function EV(t,...e){let n={},r;for(r in t)e.includes(r)||(n[r]=t[r]);return n}var F0e=1024*32;function G0e(t){return new U0e({read(){this.push(t),this.push(null)}})}function SV(t){let e;try{e=new URL(t.url)}catch{return nt(()=>{console.warn("[@sentry/node]: Invalid dsn or tunnel option, will not send any events. The tunnel option must be a full URL when used.")}),hp(t,()=>Promise.resolve({}))}let n=e.protocol==="https:",r=j0e(e,t.proxy||(n?process.env.https_proxy:void 0)||process.env.http_proxy),o=n?D0e:w0e,s=t.keepAlive===void 0?!1:t.keepAlive,i=r?new Qp(r):new o.Agent({keepAlive:s,maxSockets:30,timeout:2e3}),a=H0e(t,t.httpModule??o,i);return hp(t,a)}function j0e(t,e){let{no_proxy:n}=process.env;if(!n?.split(",").some(o=>t.host.endsWith(o)||t.hostname.endsWith(o)))return e}function H0e(t,e,n){let{hostname:r,pathname:o,port:s,protocol:i,search:a}=new URL(t.url);return function(l){return new Promise((d,p)=>{Ac(()=>{let f=G0e(l.body),m={...t.headers};l.body.length>F0e&&(m["content-encoding"]="gzip",f=f.pipe(B0e()));let _=r.startsWith("["),h=e.request({method:"POST",agent:n,headers:m,hostname:_?r.slice(1,-1):r,path:`${o}${a}`,port:s,protocol:i,ca:t.caCerts},g=>{g.on("data",()=>{}),g.on("end",()=>{}),g.setEncoding("utf8");let E=g.headers["retry-after"]??null,S=g.headers["x-sentry-rate-limits"]??null;d({statusCode:g.statusCode,headers:{"retry-after":E,"x-sentry-rate-limits":Array.isArray(S)?S[0]||null:S}})});h.on("error",p),f.pipe(h)})})}}function AV(t){if(t===!1)return!1;if(typeof t=="string")return t;let e=Ic(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 V0e,sep as q0e}from"node:path";function yV(t){return t.replace(/^[A-Z]:/,"").replace(/\\/g,"/")}function bV(t=process.argv[1]?xR(process.argv[1]):process.cwd(),e=q0e==="\\"){let n=e?yV(t):t;return r=>{if(!r)return;let o=e?yV(r):r,{dir:s,base:i,ext:a}=V0e.parse(o);(a===".js"||a===".mjs"||a===".cjs")&&(i=i.slice(0,a.length*-1));let u=decodeURIComponent(i);s||(s=".");let l=s.lastIndexOf("/node_modules");if(l>-1)return`${s.slice(l+14).replace(/\//g,".")}:${u}`;if(s.startsWith(n)){let d=s.slice(n.length+1).replace(/\//g,".");return d?`${d}:${u}`:u}return u}}function RV(t){if(process.env.SENTRY_RELEASE)return process.env.SENTRY_RELEASE;if(Z.SENTRY_RELEASE?.id)return Z.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 IV=X_(aI(bV()));P();var CV=Q(re(),1);import*as OV from"node:os";import{threadId as $0e,isMainThread as z0e}from"worker_threads";var Y0e=6e4,pT=class extends gp{constructor(e){let n=e.includeServerName===!1?void 0:e.serverName||global.process.env.SENTRY_NAME||OV.hostname(),r={...e,platform:"node",runtime:e.runtime||{name:"node",version:global.process.version},serverName:n};e.openTelemetryInstrumentations&&(0,CV.registerInstrumentations)({instrumentations:e.openTelemetryInstrumentations}),Oa(r,"node"),y.log(`Initializing Sentry: process: ${process.pid}, thread: ${z0e?"main":`worker-${$0e}`}.`),super(r),this.getOptions().enableLogs&&(this._logOnExitFlushListener=()=>{bc(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(()=>{oe&&y.log("Flushing client reports based on interval."),this._flushOutcomes()},e.clientReportFlushInterval??Y0e).unref(),process.on("beforeExit",this._clientReportOnExitFlushListener))}_setupIntegrations(){yR(),super._setupIntegrations()}_getTraceInfoFromScope(e){return e?PH(this,e):[void 0,void 0]}};var NV=Q(ab(),1);import*as xV from"module";function xO(){if(iV()&&!Z._sentryEsmLoaderHookRegistered){Z._sentryEsmLoaderHookRegistered=!0;try{let{addHookMessagePort:t}=(0,NV.createAddHookMessageChannel)();xV.register("import-in-the-middle/hook.mjs",import.meta.url,{data:{addHookMessagePort:t,include:[]},transferList:[t]})}catch(t){y.warn("Failed to register 'import-in-the-middle' hook",t)}}}function fT(){return[Lh(),vh(),wh(),Dh(),gV(),kR(),Bh(),Zj(),o6(),dV(),pV(),QH(),oV(),qH(),jH(),fV(),lV()]}function PO(t={}){return W0e(t,fT)}function W0e(t={},e){let n=K0e(t,e);n.debug===!0&&(oe?y.enable():nt(()=>{console.warn("[Sentry] Cannot initialize SDK with `debug` option using a non-debug bundle.")})),n.registerEsmLoaderHooks!==!1&&xO(),kH(),Ee().update(n.initialScope),n.spotlight&&!n.integrations.some(({name:s})=>s===OO)&&n.integrations.push(_V({sidecarUrl:typeof n.spotlight=="string"?n.spotlight:void 0})),Oa(n,"node-core");let o=new pT(n);return Ee().setClient(o),o.init(),y.log(`SDK initialized from ${Yp()?"CommonJS":"ESM"}`),o.startClientReportTracking(),X0e(),hH(o),vH(o),process.env.VERCEL&&process.on("SIGTERM",async()=>{await o.flush(200)}),o}function MO(){if(!oe)return;let t=SH(),e=["SentryContextManager","SentryPropagator"];rt()&&e.push("SentrySpanProcessor");for(let n of e)t.includes(n)||y.error(`You have to set up the ${n}. Without this, the OpenTelemetry & Sentry integration will not work properly.`);t.includes("SentrySampler")||y.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 K0e(t,e){let n=Q0e(t.release),r=AV(t.spotlight),o=J0e(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??SV,stackParser:yb(t.stackParser||IV),release:n,tracesSampleRate:o,spotlight:r,debug:Ic(t.debug??process.env.SENTRY_DEBUG)},i=t.integrations,a=t.defaultIntegrations??e(s);return{...s,integrations:mR({defaultIntegrations:a,integrations:i})}}function Q0e(t){if(t!==void 0)return t;let e=RV();if(e!==void 0)return e}function J0e(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 X0e(){if(Ic(process.env.SENTRY_USE_ENVIRONMENT)!==!1){let t=process.env.SENTRY_TRACE,e=process.env.SENTRY_BAGGAGE,n=np(t,e);Ee().setPropagationContext(n)}}function Oe(t,e){t.setAttribute(W,e)}function Jp(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 vO="Http",PV="@opentelemetry_sentry-patched/instrumentation-http",mT=Qr.major===22&&Qr.minor>=12||Qr.major===23&&Qr.minor>=2||Qr.major>=24,Z0e=B(`${vO}.sentry`,t=>new La(t)),eAe=B(vO,t=>{let e=new MV.HttpInstrumentation({...t,disableIncomingRequestInstrumentation:!0});try{e._diag=Wn.createComponentLogger({namespace:PV}),e.instrumentationName=PV}catch{}try{let n={get:()=>!1,set:()=>{}};Object.defineProperty(e,"_httpPatched",n),Object.defineProperty(e,"_httpsPatched",n)}catch{}return e});function tAe(t,e={}){return typeof t.spans=="boolean"?t.spans:!(e.skipOpenTelemetrySetup||!rt(e)&&mT)}var vV=(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=vp(r),i=kp(o),a=e&&!n;return{name:vO,setup(u){let l=u.getOptions();a&&rt(l)&&i.setup(u)},setupOnce(){let u=V()?.getOptions()||{},l=tAe(t,u);s.setupOnce();let d={breadcrumbs:t.breadcrumbs,propagateTraceInOutgoingRequests:typeof t.tracePropagation=="boolean"?t.tracePropagation:mT||!l,createSpansForOutgoingRequests:mT,spans:t.spans,ignoreOutgoingRequests:t.ignoreOutgoingRequests,outgoingRequestHook:(p,f)=>{let m=Jp(f);if(m.startsWith("data:")){let _=Oc(m);p.setAttribute("http.url",_),p.setAttribute(Xs,_),p.updateName(`${f.method||"GET"} ${_}`)}t.instrumentation?.requestHook?.(p,f)},outgoingResponseHook:t.instrumentation?.responseHook,outgoingRequestApplyCustomAttributes:t.instrumentation?.applyCustomAttributesOnSpan};if(Z0e(d),l){let p=nAe(t);eAe(p)}},processEvent(u){return i.processEvent(u)}}};function nAe(t={}){return{disableOutgoingRequestInstrumentation:mT,ignoreOutgoingRequestHook:n=>{let r=Jp(n);if(!r)return!1;let o=t.ignoreOutgoingRequests;return!!o?.(r,n)},requireParentforOutgoingSpans:!1,requestHook:(n,r)=>{Oe(n,"auto.http.otel.http");let o=Jp(r);if(o.startsWith("data:")){let s=Oc(o);n.setAttribute("http.url",s),n.setAttribute(Xs,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 BV=Q(DV(),1);var FV="NodeFetch",sAe=B(FV,BV.UndiciInstrumentation,t=>cAe(t)),iAe=B(`${FV}.sentry`,wa,t=>t),aAe=(t={})=>({name:"NodeFetch",setupOnce(){uAe(t,V()?.getOptions())&&sAe(t),iAe(t)}}),GV=aAe;function UV(t,e="/"){let n=`${t}`;return n.endsWith("/")&&e.startsWith("/")?`${n}${e.slice(1)}`:!n.endsWith("/")&&!e.startsWith("/")?`${n}/${e}`:`${n}${e}`}function uAe(t,e={}){return typeof t.spans=="boolean"?t.spans:!e.skipOpenTelemetrySetup&&rt(e)}function cAe(t={}){return{requireParentforSpans:!1,ignoreRequestHook:n=>{let r=UV(n.origin,n.path),o=t.ignoreOutgoingRequests;return!!(o&&r&&o(r))},startSpanHook:n=>{let r=UV(n.origin,n.path);if(r.startsWith("data:")){let o=Oc(r);return{[W]:"auto.http.otel.node_fetch","http.url":o,[Xs]:o,[gr]:`${n.method||"GET"} ${o}`}}return{[W]:"auto.http.otel.node_fetch"}},requestHook:t.requestHook,responseHook:t.responseHook,headersToSpanAttributes:t.headersToSpanAttributes}}var JV=Q(QV(),1);var yt=typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__;var XV="Express";function IAe(t){Oe(t,"auto.http.otel.express");let e=Y(t).data,n=e["express.type"];n&&t.setAttribute(te,`${n}.express`);let r=e["express.name"];typeof r=="string"&&t.updateName(r)}function OAe(t,e){if(le()===hr())return yt&&y.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";le().setTransactionName(`${r} ${t.route}`)}return e}var ZV=B(XV,()=>new JV.ExpressInstrumentation({requestHook:t=>IAe(t),spanNameHook:(t,e)=>OAe(t,e)})),CAe=()=>({name:XV,setupOnce(){ZV()}}),e8=CAe;var Oq=Q(Sq(),1);import*as AC from"node:diagnostics_channel";P();var nE=Q(Ae(),1),qa=Q(re(),1);de();var Ts;(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})(Ts||(Ts={}));var _f;(function(t){let e="middleware";t.MIDDLEWARE=e;let n="request_handler";t.REQUEST_HANDLER=n})(_f||(_f={}));var hf;(function(t){let e="middleware";t.MIDDLEWARE=e;let n="request handler";t.REQUEST_HANDLER=n})(hf||(hf={}));P();var gf=Symbol("opentelemetry.instrumentation.fastify.request_active_span");function SC(t,e,n,r={}){let o=e.startSpan(n,{attributes:r}),s=t[gf]||[];return s.push(o),Object.defineProperty(t,gf,{enumerable:!1,configurable:!0,value:s}),o}function eE(t,e){let n=t[gf]||[];n.length&&(n.forEach(r=>{e&&(r.setStatus({code:qe.ERROR,message:e.message}),r.recordException(e)),r.end()}),delete t[gf])}function yq(t,e,n){let r,o;try{o=t(),Aq(o)&&o.then(s=>e(void 0,s),s=>e(s))}catch(s){r=s}finally{if(!Aq(o)&&(e(r,o),r))throw r;return o}}function Aq(t){return typeof t=="object"&&t&&typeof Object.getOwnPropertyDescriptor(t,"then")?.value=="function"||!1}var RRe="0.1.0",IRe="@sentry/instrumentation-fastify-v3",bq="anonymous",ORe=new Set(["onTimeout","onRequest","preParsing","preValidation","preSerialization","preHandler","onSend","onResponse","onError"]),tE=class extends qa.InstrumentationBase{constructor(e={}){super(IRe,RRe,e)}init(){return[new qa.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,nE.getRPCMetadata)(v.active()),u=i.routeOptions?i.routeOptions.url:r.routerPath;u&&a?.type===nE.RPCType.HTTP&&(a.route=u);let l=r.method||"GET";le().setTransactionName(`${l} ${u}`),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||bq,u=`${hf.MIDDLEWARE} - ${a}`,l=i[1],d=SC(l,s.tracer,u,{[Ts.FASTIFY_TYPE]:_f.MIDDLEWARE,[Ts.PLUGIN_NAME]:e,[Ts.HOOK_NAME]:n}),p=o&&i[i.length-1];return p&&(i[i.length-1]=function(...f){eE(l),p.apply(this,f)}),v.with(X.setSpan(v.active(),d),()=>yq(()=>r.apply(this,i),f=>{f instanceof Error&&(d.setStatus({code:qe.ERROR,message:f.message}),d.recordException(f)),o||eE(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(!ORe.has(s))return n.apply(this,o);let u=typeof o[o.length-1]=="function"&&i.constructor.name!=="AsyncFunction";return n.apply(this,[s,e._wrapHandler(a,s,i,u)])}}}_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()),CRe(),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,qa.safeExecuteInTheMiddle)(()=>r.apply(this,s),a=>{!a&&i instanceof Error&&(a=i),eE(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,u=a?.name.startsWith("bound ")?a.name.substring(6):a?.name,l=`${hf.REQUEST_HANDLER} - ${u||this.pluginName||bq}`,d={[Ts.PLUGIN_NAME]:this.pluginName,[Ts.FASTIFY_TYPE]:_f.REQUEST_HANDLER,[ry]:i.routeOptions?i.routeOptions.url:r.routerPath};u&&(d[Ts.FASTIFY_NAME]=u);let p=SC(o,e.tracer,l,d);Rq(p);let{requestHook:f}=e.getConfig();return f&&(0,qa.safeExecuteInTheMiddle)(()=>f(p,{request:r}),m=>{m&&e._diag.error("request hook failed",m)},!0),v.with(X.setSpan(v.active(),p),()=>{s()})}}};function CRe(){let t=V();t&&t.on("spanStart",e=>{Rq(e)})}function Rq(t){let e=Y(t).data,n=e["fastify.type"];if(e[te]||!n)return;t.setAttributes({[W]:"auto.http.otel.fastify",[te]:`${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 rE="Fastify",Cq=B(`${rE}.v3`,()=>new tE);function NRe(){let t=V();if(t)return t.getIntegrationByName(rE)}function Iq(t,e,n,r){let o=NRe()?.getShouldHandleError()||Pq;if(r==="diagnostics-channel"&&(this.diagnosticsChannelExists=!0),this.diagnosticsChannelExists&&r==="onError-hook"){yt&&y.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)&&ne(t,{mechanism:{handled:!1,type:"auto.function.fastify"}})}var Nq=B(`${rE}.v5`,()=>{let t=new Oq.FastifyOtelInstrumentation,e=t.plugin();return AC.subscribe("fastify.initialization",n=>{let r=n.fastify;r?.register(e).after(o=>{o?yt&&y.error("Failed to setup Fastify instrumentation",o):(PRe(),r&&MRe(r))})}),AC.subscribe("tracing:fastify.request.handler:error",n=>{let{error:r,request:o,reply:s}=n;Iq.call(Iq,r,o,s,"diagnostics-channel")}),t}),xRe=({shouldHandleError:t})=>{let e;return{name:rE,setupOnce(){e=t||Pq,Cq(),Nq()},getShouldHandleError(){return e},setShouldHandleError(n){e=n}}},xq=(t={})=>xRe(t);function Pq(t,e,n){let r=n.statusCode;return r>=500||r<=299}function Mq(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[te]||!i&&!a&&!s)return;let u=s?"hook":i?"middleware":a?"request_handler":"<unknown>";t.setAttributes({[W]:"auto.http.otel.fastify",[te]:`${u}.fastify`});let l=r["fastify.name"]||r["plugin.name"]||r["hook.name"];if(typeof l=="string"){let d=l.replace(/^fastify -> /,"").replace(/^@fastify\/otel -> /,"");t.updateName(d)}}function PRe(){let t=V();t&&t.on("spanStart",e=>{Mq(e)})}function MRe(t){t.addHook("onRequest",async(e,n)=>{if(e.opentelemetry){let{span:s}=e.opentelemetry();s&&Mq(s)}let r=e.routeOptions?.url,o=e.method||"GET";le().setTransactionName(`${o} ${r}`)})}P();var Xq=Q(Jq(),1);var Zq="Graphql",e5=B(Zq,Xq.GraphQLInstrumentation,t=>{let e=n5(t);return{...e,responseHook(n,r){Oe(n,"auto.graphql.otel.graphql"),r.errors?.length&&!Y(n).status&&n.setStatus({code:qe.ERROR});let s=Y(n).data,i=s["graphql.operation.type"],a=s["graphql.operation.name"];if(e.useOperationNameForRootSpan&&i){let u=$e(n),d=Y(u).data[Jc]||[],p=a?`${i} ${a}`:`${i}`;Array.isArray(d)?(d.push(p),u.setAttribute(Jc,d)):typeof d=="string"?u.setAttribute(Jc,[d,p]):u.setAttribute(Jc,p),Y(u).data["original-description"]||u.setAttribute("original-description",Y(u).description),u.updateName(`${Y(u).data["original-description"]} (${XRe(d)})`)}}}}),JRe=(t={})=>({name:Zq,setupOnce(){e5(n5(t))}}),t5=JRe;function n5(t){return{ignoreResolveSpans:!0,ignoreTrivialResolveSpans:!0,useOperationNameForRootSpan:!0,...t}}function XRe(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 m5=Q(f5(),1);var _5="Kafka",h5=B(_5,()=>new m5.KafkaJsInstrumentation({consumerHook(t){Oe(t,"auto.kafkajs.otel.consumer")},producerHook(t){Oe(t,"auto.kafkajs.otel.producer")}})),eIe=()=>({name:_5,setupOnce(){h5()}}),g5=eIe;var R5=Q(b5(),1);var I5="LruMemoizer",O5=B(I5,()=>new R5.LruMemoizerInstrumentation),nIe=()=>({name:I5,setupOnce(){O5()}}),C5=nIe;var D5=Q(w5(),1);var U5="Mongo",B5=B(U5,()=>new D5.MongoDBInstrumentation({dbStatementSerializer:aIe,responseHook(t){Oe(t,"auto.db.otel.mongo")}}));function aIe(t){let e=PC(t);return JSON.stringify(e)}function PC(t){if(Array.isArray(t))return t.map(e=>PC(e));if(uIe(t)){let e={};return Object.entries(t).map(([n,r])=>[n,PC(r)]).reduce((n,r)=>(lIe(r)&&(n[r[0]]=r[1]),n),e)}return"?"}function uIe(t){return typeof t=="object"&&t!==null&&!cIe(t)}function cIe(t){let e=!1;return typeof Buffer<"u"&&(e=Buffer.isBuffer(t)),e}function lIe(t){return Array.isArray(t)}var dIe=()=>({name:U5,setupOnce(){B5()}}),F5=dIe;var Q5=Q(K5(),1);var J5="Mongoose",X5=B(J5,()=>new Q5.MongooseInstrumentation({responseHook(t){Oe(t,"auto.db.otel.mongoose")}})),SIe=()=>({name:J5,setupOnce(){X5()}}),Z5=SIe;var a9=Q(i9(),1);var u9="Mysql",c9=B(u9,()=>new a9.MySQLInstrumentation({})),PIe=()=>({name:u9,setupOnce(){c9()}}),l9=PIe;var T9=Q(g9(),1);var E9="Mysql2",S9=B(E9,()=>new T9.MySQL2Instrumentation({responseHook(t){Oe(t,"auto.db.otel.mysql2")}})),$Ie=()=>({name:E9,setupOnce(){S9()}}),A9=$Ie;var Y9=Q(x9(),1),W9=Q(H9(),1);var lOe=["get","set","setex"],JC=["get","mget"],dOe=["set","setex"];function Mf(t,e){return t.includes(e.toLowerCase())}function XC(t){return Mf(JC,t)?"cache.get":Mf(dOe,t)?"cache.put":void 0}function pOe(t,e){return e.some(n=>t.startsWith(n))}function q9(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)?V9(o.map(s=>n(s))):["<unknown>"],r=e[0];return Mf(lOe,t)&&r!=null?n(r):V9(e.map(o=>n(o)))}catch{return}}function $9(t,e,n){if(!XC(t))return!1;for(let r of e)if(pOe(r,n))return!0;return!1}function z9(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 V9(t){let e=[],n=r=>{r.forEach(o=>{Array.isArray(o)?n(o):e.push(o)})};return n(t),e}var GE="Redis",vf={},K9=(t,e,n,r)=>{t.setAttribute(W,"auto.db.otel.redis");let o=q9(e,n),s=XC(e);if(!o||!s||!vf.cachePrefixes||!$9(e,o,vf.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 u=z9(r);u&&t.setAttribute(Wb,u),Mf(JC,e)&&u!==void 0&&t.setAttribute(zb,u>0),t.setAttributes({[te]:s,[Yb]:o});let l=o.join(", ");t.updateName(vf.maxCacheKeyLength?Ys(l,vf.maxCacheKeyLength):l)},fOe=B(`${GE}.IORedis`,()=>new Y9.IORedisInstrumentation({responseHook:K9})),mOe=B(`${GE}.Redis`,()=>new W9.RedisInstrumentation({responseHook:K9})),Q9=Object.assign(()=>{fOe(),mOe()},{id:GE}),_Oe=(t={})=>({name:GE,setupOnce(){vf=t,Q9()}}),J9=_Oe;var m$=Q(f$(),1);var _$="Postgres",h$=B(_$,m$.PgInstrumentation,t=>({requireParentSpan:!0,requestHook(e){Oe(e,"auto.db.otel.postgres")},ignoreConnectSpans:t?.ignoreConnectSpans??!1})),POe=t=>({name:_$,setupOnce(){h$(t)}}),g$=POe;P();var Mi=Q(re(),1);de();var sN="PostgresJs",T$=[">=3.0.0 <4"],MOe=/^(SELECT|INSERT|UPDATE|DELETE|CREATE|DROP|ALTER)/i,vOe=Symbol.for("sentry.query.from.instrumented.sql"),E$=B(sN,t=>new oN({requireParentSpan:t?.requireParentSpan??!0,requestHook:t?.requestHook})),oN=class extends Mi.InstrumentationBase{constructor(e){super("sentry-postgres-js",pe,e)}init(){let e=new Mi.InstrumentationNodeModuleDefinition("postgres",T$,n=>{try{return this._patchPostgres(n)}catch(r){return yt&&y.error("Failed to patch postgres module:",r),n}},n=>n);return["src","cf/src","cjs/src"].forEach(n=>{e.files.push(new Mi.InstrumentationNodeModuleFile(`postgres/${n}/query.js`,T$,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 yt&&y.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 yt&&y.warn("postgres() did not return a valid instance"),a;let u=o.getConfig();return vR(a,{requireParentSpan:u.requireParentSpan,requestHook:u.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:(xp(e,"default",s),e)}_shouldCreateSpans(){let e=this.getConfig();return X.getSpan(v.active())!==void 0||!e.requireParentSpan}_setOperationName(e,n,r){if(r){e.setAttribute(qu,r);return}let o=n?.match(MOe);o?.[1]&&e.setAttribute(qu,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[vOe])return r.apply(this,o);if(!n._shouldCreateSpans())return r.apply(this,o);let s=n._reconstructQuery(this.strings),i=n._sanitizeSqlQuery(s);return Pt({name:i||"postgresjs.query",op:"db"},a=>{Oe(a,"auto.db.postgresjs"),a.setAttributes({[aa]:"postgres",[ly]:i});let u=n.getConfig(),{requestHook:l}=u;l&&(0,Mi.safeExecuteInTheMiddle)(()=>l(a,i,void 0),f=>{f&&(a.setAttribute("sentry.hook.error","requestHook failed"),yt&&y.error(`Error in requestHook for ${sN} integration:`,f))},!0);let d=this.resolve;this.resolve=new Proxy(d,{apply:(f,m,_)=>{try{n._setOperationName(a,i,_?.[0]?.command),a.end()}catch(h){yt&&y.error("Error ending span in resolve callback:",h)}return Reflect.apply(f,m,_)}});let p=this.reject;this.reject=new Proxy(p,{apply:(f,m,_)=>{try{a.setStatus({code:2,message:_?.[0]?.message||"unknown_error"}),a.setAttribute(dy,_?.[0]?.code||"unknown"),a.setAttribute(py,_?.[0]?.name||"unknown"),n._setOperationName(a,i),a.end()}catch(h){yt&&y.error("Error ending span in reject callback:",h)}return Reflect.apply(f,m,_)}});try{return r.apply(this,o)}catch(f){throw a.setStatus({code:2,message:f instanceof Error?f.message:"unknown_error"}),a.end(),f}})},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}},kOe=t=>({name:sN,setupOnce(){E$(t)}}),S$=kOe;P();P();var mS=Q(rz(),1);P();var eNe={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"}},tNe=eNe.version.split(".")[0],xN="PRISMA_INSTRUMENTATION",PN=`V${tNe}_PRISMA_INSTRUMENTATION`,Dl=globalThis;function nNe(){let t=Dl[PN];return t?.helper?t.helper:Dl[xN]?.helper}function rNe(t){let e={helper:t};Dl[PN]=e,Dl[xN]=e}function oNe(){delete Dl[PN],delete Dl[xN]}var sNe=process.env.PRISMA_SHOW_ALL_TRACES==="true",iNe="00-10-10-00";function aNe(t){switch(t){case"client":return Pe.CLIENT;case"internal":default:return Pe.INTERNAL}}var uNe=class{tracerProvider;ignoreSpanTypes;constructor({tracerProvider:t,ignoreSpanTypes:e}){this.tracerProvider=t,this.ignoreSpanTypes=e}isEnabled(){return!0}getTraceParent(t){let e=X.getSpanContext(t??v.active());return e?`00-${e.traceId}-${e.spanId}-0${e.traceFlags}`:iNe}dispatchEngineSpans(t){let e=this.tracerProvider.getTracer("prisma"),n=new Map,r=t.filter(o=>o.parentId===null);for(let o of r)iz(e,o,t,n,this.ignoreSpanTypes)}getActiveContext(){return v.active()}runInChildSpan(t,e){if(typeof t=="string"&&(t={name:t}),t.internal&&!sNe)return e();let n=this.tracerProvider.getTracer("prisma"),r=t.context??this.getActiveContext(),o=`prisma:client:${t.name}`;if(az(o,this.ignoreSpanTypes))return e();if(t.active===!1){let s=n.startSpan(o,t,r);return oz(s,e(s,r))}return n.startActiveSpan(o,t,s=>oz(s,e(s,r)))}};function iz(t,e,n,r,o){if(az(e.name,o))return;let s={attributes:e.attributes,kind:aNe(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(u=>{let l=r.get(u);return l?{context:{spanId:l,traceId:i.spanContext().traceId,traceFlags:i.spanContext().traceFlags}}:[]}));let a=n.filter(u=>u.parentId===e.id);for(let u of a)iz(t,u,n,r,o);i.end(e.endTime)})}function oz(t,e){return cNe(e)?e.then(n=>(t.end(),n),n=>{throw t.end(),n}):(t.end(),e)}function cNe(t){return t!=null&&typeof t.then=="function"}function az(t,e){return e.some(n=>typeof n=="string"?n===t:n.test(t))}var uz={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},sz=uz.version,lNe=uz.name,dNe="@prisma/client",cz=class extends mS.InstrumentationBase{tracerProvider;constructor(t={}){super(lNe,sz,t)}setTracerProvider(t){this.tracerProvider=t}init(){return[new mS.InstrumentationNodeModuleDefinition(dNe,[sz])]}enable(){let t=this._config;rNe(new uNe({tracerProvider:this.tracerProvider??X.getTracerProvider(),ignoreSpanTypes:t.ignoreSpanTypes??[]}))}disable(){oNe()}isEnabled(){return nNe()!==void 0}};var lz="Prisma";function pNe(t){return!!t&&typeof t=="object"&&"dispatchEngineSpans"in t}function dz(){let t=globalThis.PRISMA_INSTRUMENTATION;return t&&typeof t=="object"&&"helper"in t?t.helper:void 0}var MN=class extends cz{constructor(e){super(e?.instrumentationConfig)}enable(){super.enable();let e=dz();pNe(e)&&(e.createEngineSpan=n=>{let r=X.getTracer("prismaV5Compatibility"),o=r._idGenerator;if(!o){nt(()=>{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=fNe(s.kind),a=s.parent_span_id,u=s.span_id,l=s.trace_id,d=s.links?.map(f=>({context:{traceId:f.trace_id,spanId:f.span_id,traceFlags:Zt.SAMPLED}})),p=X.setSpanContext(v.active(),{traceId:l,spanId:a,traceFlags:Zt.SAMPLED});v.with(p,()=>{let f={generateTraceId:()=>l,generateSpanId:()=>u};r._idGenerator=f,r.startSpan(s.name,{kind:i,links:d,startTime:s.start_time,attributes:s.attributes}).end(s.end_time),r._idGenerator=o})})}finally{r._idGenerator=o}})}};function fNe(t){switch(t){case"client":return Pe.CLIENT;case"internal":default:return Pe.INTERNAL}}var mNe=B(lz,t=>new MN(t)),pz=t=>({name:lz,setupOnce(){mNe(t)},setup(e){dz()&&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 yz=Q(Az(),1);var bz="Hapi",Rz=B(bz,()=>new yz.HapiInstrumentation),CNe=()=>({name:bz,setupOnce(){Rz()}}),Iz=CNe;de();var wi={HONO_TYPE:"hono.type",HONO_NAME:"hono.name"},zf={MIDDLEWARE:"middleware",REQUEST_HANDLER:"request_handler"};P();var TS=Q(re(),1);var NNe="@sentry/instrumentation-hono",xNe="0.0.1",gS=class extends TS.InstrumentationBase{constructor(e={}){super(NNe,xNe,e)}init(){return[new TS.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 v.with(X.setSpan(v.active(),i),()=>n._safeExecute(()=>{let a=e.apply(this,[r,o]);if(Ht(a))return a.then(u=>{let l=n._determineHandlerType(u);return i.setAttributes({[wi.HONO_TYPE]:l,[wi.HONO_NAME]:l===zf.REQUEST_HANDLER?s:e.name||"anonymous"}),n.getConfig().responseHook?.(i),u});{let u=n._determineHandlerType(a);return i.setAttributes({[wi.HONO_TYPE]:u,[wi.HONO_NAME]:u===zf.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 Ht(o)?o.then(()=>n(),s=>r(s)):n(),o}catch(o){throw r(o),o}}_determineHandlerType(e){return e===void 0?zf.MIDDLEWARE:zf.REQUEST_HANDLER}_handleError(e,n){n instanceof Error&&(e.setStatus({code:qe.ERROR,message:n.message}),e.recordException(n))}};var Oz="Hono";function PNe(t){let e=Y(t).data,n=e[wi.HONO_TYPE];if(e[te]||!n)return;t.setAttributes({[W]:"auto.http.otel.hono",[te]:`${n}.hono`});let r=e[wi.HONO_NAME];if(typeof r=="string"&&t.updateName(r),le()===hr()){yt&&y.warn("Isolation scope is default isolation scope - skipping setting transactionName");return}let o=e[ts],s=e[ua];typeof o=="string"&&typeof s=="string"&&le().setTransactionName(`${s} ${o}`)}var Cz=B(Oz,()=>new gS({responseHook:t=>{PNe(t)}})),MNe=()=>({name:Oz,setupOnce(){Cz()}}),Nz=MNe;var Gz=Q(Fz(),1);de();var jz="Koa",Hz=B(jz,Gz.KoaInstrumentation,(t={})=>({ignoreLayersType:t.ignoreLayersType,requestHook(e,n){Oe(e,"auto.http.otel.koa");let r=Y(e).data,o=r["koa.type"];o&&e.setAttribute(te,`${o}.koa`);let s=r["koa.name"];if(typeof s=="string"&&e.updateName(s||"< unknown >"),le()===hr()){yt&&y.warn("Isolation scope is default isolation scope - skipping setting transactionName");return}let i=r[ts],a=n.context?.request?.method?.toUpperCase()||"GET";i&&le().setTransactionName(`${a} ${i}`)}})),GNe=(t={})=>({name:jz,setupOnce(){Hz(t)}}),Vz=GNe;var Xz=Q(Jz(),1);var Zz="Connect",eY=B(Zz,()=>new Xz.ConnectInstrumentation),QNe=()=>({name:Zz,setupOnce(){eY()}}),tY=QNe;var dY=Q(lY(),1);var txe=new Set(["callProcedure","execSql","execSqlBatch","execBulkLoad","prepare","execute"]),pY="Tedious",fY=B(pY,()=>new dY.TediousInstrumentation({})),nxe=()=>{let t;return{name:pY,setupOnce(){let e=fY();t=Mp(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]||"";txe.has(s)&&n.setAttribute(W,"auto.db.otel.tedious")}))}}},mY=nxe;var EY=Q(TY(),1);var SY="GenericPool",AY=B(SY,()=>new EY.GenericPoolInstrumentation({})),oxe=()=>{let t;return{name:SY,setupOnce(){let e=AY();t=Mp(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")}))}}},yY=oxe;var vY=Q(MY(),1);var kY="Amqplib",_xe={consumeEndHook:t=>{Oe(t,"auto.amqplib.otel.consumer")},publishHook:t=>{Oe(t,"auto.amqplib.otel.publisher")}},LY=B(kY,()=>new vY.AmqplibInstrumentation(_xe)),hxe=()=>({name:kY,setupOnce(){LY()}}),wY=hxe;var Jf="VercelAI";var wS=Q(re(),1);var gxe=[">=3.0.0 <7"],DY=["generateText","streamText","generateObject","streamObject","embed","embedMany","rerank"];function Txe(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 Exe(t){if(typeof t!="object"||t===null||!("content"in t))return;let e=t;Array.isArray(e.content)&&(Sxe(e.content),Axe(e.content))}function Sxe(t){for(let e of t){if(!Txe(e))continue;let n=XR(e.toolCallId);n?Qn(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"),ne(e.error,{mechanism:{type:"auto.vercelai.otel",handled:!1}})}):Qn(r=>{r.setTag("vercel.ai.tool.name",e.toolName),r.setTag("vercel.ai.tool.callId",e.toolCallId),r.setLevel("error"),ne(e.error,{mechanism:{type:"auto.vercelai.otel",handled:!1}})})}}function Axe(t){for(let e of t)typeof e=="object"&&e!==null&&"toolCallId"in e&&typeof e.toolCallId=="string"&&ZR(e.toolCallId)}function yxe(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 LS=class t extends wS.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 wS.InstrumentationNodeModuleDefinition("ai",gxe,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||{},u=a.isEnabled,l=V(),d=l?.getIntegrationByName(Jf),p=d?.options,f=d?!!l?.getOptions().sendDefaultPii:!1,{recordInputs:m,recordOutputs:_}=yxe(p,a,u,f);return i[0].experimental_telemetry={...a,isEnabled:u!==void 0?u:!0,recordInputs:m,recordOutputs:_},Yr(()=>Reflect.apply(o,s,i),h=>{h&&typeof h=="object"&<(h,"_sentry_active_span",Tr())},()=>{},h=>{Exe(h)})}});if(Object.prototype.toString.call(e)==="[object Module]"){for(let r of DY)e[r]!=null&&(e[r]=n(e[r]));return e}else{let r=DY.reduce((o,s)=>(e[s]!=null&&(o[s]=n(e[s])),o),{});return{...e,...r}}}};var UY=B(Jf,()=>new LS({}));function bxe(t){return!!t.getIntegrationByName("Modules")?.getModules?.()?.ai}var Rxe=(t={})=>{let e;return{name:Jf,options:t,setupOnce(){e=UY()},afterAllSetup(n){t.force??bxe(n)?Yh(n):e?.callWhenPatched(()=>Yh(n))}}},BY=Rxe;var US=Q(re(),1);var Ixe=[">=4.0.0 <7"],DS=class extends US.InstrumentationBase{constructor(e={}){super("@sentry/instrumentation-openai",pe,e)}init(){return new US.InstrumentationNodeModuleDefinition("openai",Ixe,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(Ia(fi))return Reflect.construct(r,i);let a=Reflect.construct(r,i);return Kh(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 FY=B(fi,t=>new DS(t)),Oxe=(t={})=>({name:fi,setupOnce(){FY(t)}}),GY=Oxe;var FS=Q(re(),1);var Cxe=[">=0.19.2 <1.0.0"],BS=class extends FS.InstrumentationBase{constructor(e={}){super("@sentry/instrumentation-anthropic-ai",pe,e)}init(){return new FS.InstrumentationNodeModuleDefinition("@anthropic-ai/sdk",Cxe,this._patch.bind(this))}_patch(e){let n=e.Anthropic,r=this.getConfig(),o=function(...s){if(Ia(mi))return Reflect.construct(n,s);let i=Reflect.construct(n,s);return Qh(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 jY=B(mi,t=>new BS(t)),Nxe=(t={})=>({name:mi,options:t,setupOnce(){jY(t)}}),HY=Nxe;var Kl=Q(re(),1);var VY=[">=0.10.0 <2"],GS=class extends Kl.InstrumentationBase{constructor(e={}){super("@sentry/instrumentation-google-genai",pe,e)}init(){return new Kl.InstrumentationNodeModuleDefinition("@google/genai",VY,n=>this._patch(n),n=>n,[new Kl.InstrumentationNodeModuleFile("@google/genai/dist/node/index.cjs",VY,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(Ia(_i))return Reflect.construct(n,s);let i=Reflect.construct(n,s);return Jh(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 xp(e,"GoogleGenAI",o),e}};var qY=B(_i,t=>new GS(t)),xxe=(t={})=>({name:_i,setupOnce(){qY(t)}}),$Y=xxe;var qi=Q(re(),1);var jS=[">=0.1.0 <2.0.0"];function Pxe(t,e){return t?Array.isArray(t)?t.includes(e)?t:[...t,e]:typeof t=="object"?[t,e]:t:[e]}function Mxe(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 u=a.callbacks,l=Pxe(u,e);return a.callbacks=l,Reflect.apply(r,o,s)}})}var HS=class extends qi.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 qi.InstrumentationNodeModuleDefinition(r,jS,this._patch.bind(this),o=>o,[new qi.InstrumentationNodeModuleFile(`${r}/dist/index.cjs`,jS,this._patch.bind(this),o=>o)]));return e.push(new qi.InstrumentationNodeModuleDefinition("langchain",jS,this._patch.bind(this),r=>r,[new qi.InstrumentationNodeModuleFile("langchain/dist/chat_models/universal.cjs",jS,this._patch.bind(this),r=>r)])),e}_patch(e){AR([fi,mi,_i]);let n=Zh(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(u=>typeof u=="function"&&r.includes(u.name));if(!s)return;let i=s.prototype;if(i.__sentry_patched__)return;i.__sentry_patched__=!0;let a=["invoke","stream","batch"];for(let u of a){let l=i[u];typeof l=="function"&&(i[u]=Mxe(l,n))}}};var zY=B(Xh,t=>new HS(t)),vxe=(t={})=>({name:Xh,setupOnce(){zY(t)}}),YY=vxe;var Ql=Q(re(),1);var WY=[">=0.0.0 <2.0.0"],VS=class extends Ql.InstrumentationBase{constructor(e={}){super("@sentry/instrumentation-langgraph",pe,e)}init(){return new Ql.InstrumentationNodeModuleDefinition("@langchain/langgraph",WY,this._patch.bind(this),n=>n,[new Ql.InstrumentationNodeModuleFile("@langchain/langgraph/dist/index.cjs",WY,this._patch.bind(this),n=>n)])}_patch(e){return e.StateGraph&&typeof e.StateGraph=="function"&&tg(e.StateGraph.prototype,this.getConfig()),e}};var KY=B(eg,t=>new VS(t)),kxe=(t={})=>({name:eg,setupOnce(){KY(t)}}),QY=kxe;var o7=Q(re(),1);P();var Rs=Q(re(),1);de();import*as XY from"node:net";function ZY(t,e,n,r,o){let i=()=>{},a=o.firestoreSpanCreationHook;typeof a=="function"&&(i=d=>{(0,Rs.safeExecuteInTheMiddle)(()=>a(d),p=>{p&&Wn.error(p?.message)},!0)});let u=new Rs.InstrumentationNodeModuleDefinition("@firebase/firestore",e,d=>JY(d,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 d of l)u.files.push(new Rs.InstrumentationNodeModuleFile(d,e,p=>JY(p,n,r,t,i),p=>e7(p,r)));return u}function JY(t,e,n,r,o){return e7(t,n),e(t,"addDoc",Lxe(r,o)),e(t,"getDocs",Dxe(r,o)),e(t,"setDoc",Uxe(r,o)),e(t,"deleteDoc",wxe(r,o)),t}function e7(t,e){for(let n of["addDoc","getDocs","setDoc","deleteDoc"])(0,Rs.isWrapped)(t[n])&&e(t,n);return t}function Lxe(t,e){return function(r){return function(o,s){let i=$S(t,"addDoc",o);return e(i),qS(i,()=>r(o,s))}}}function wxe(t,e){return function(r){return function(o){let s=$S(t,"deleteDoc",o.parent||o);return e(s),qS(s,()=>r(o))}}}function Dxe(t,e){return function(r){return function(o){let s=$S(t,"getDocs",o);return e(s),qS(s,()=>r(o))}}}function Uxe(t,e){return function(r){return function(o,s,i){let a=$S(t,"setDoc",o.parent||o);return e(a),qS(a,()=>typeof i<"u"?r(o,s,i):r(o,s))}}}function qS(t,e){return v.with(X.setSpan(v.active(),t),()=>(0,Rs.safeExecuteInTheMiddle)(()=>e(),n=>{n&&t.recordException(n),t.end()},!0))}function $S(t,e,n){let r=t.startSpan(`${e} ${n.path}`,{kind:Pe.CLIENT});return Fxe(r,n),r.setAttribute(qu,e),r}function Bxe(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(XY.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 Fxe(t,e){let n=e.firestore.app,r=n.options,s=(e.firestore.toJSON()||{}).settings||{},i={[uy]:e.path,[cy]:n.name,[aa]:"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:u}=Bxe(s);a&&(i[gy]=a),u&&(i[Ty]=u),t.setAttributes(i)}P();var Is=Q(re(),1);function t7(t,e,n,r,o){let s=()=>{},i=()=>{},a=o.functions?.errorHook,u=o.functions?.requestHook,l=o.functions?.responseHook;typeof l=="function"&&(i=(f,m)=>{(0,Is.safeExecuteInTheMiddle)(()=>l(f,m),_=>{_&&Wn.error(_?.message)},!0)}),typeof u=="function"&&(s=f=>{(0,Is.safeExecuteInTheMiddle)(()=>u(f),m=>{m&&Wn.error(m?.message)},!0)});let d=new Is.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:f,triggerType:m})=>{d.files.push(new Is.InstrumentationNodeModuleFile(f,e,_=>Gxe(_,n,r,t,{requestHook:s,responseHook:i,errorHook:a},m),_=>n7(_,r)))}),d}function xn(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 u=async function(...l){let d=process.env.FUNCTION_TARGET||process.env.K_SERVICE||"unknown",p=t.startSpan(`firebase.function.${n}`,{kind:Pe.SERVER}),f={"faas.name":d,"faas.trigger":n,"faas.provider":"firebase"};return process.env.GCLOUD_PROJECT&&(f["cloud.project_id"]=process.env.GCLOUD_PROJECT),process.env.EVENTARC_CLOUD_EVENT_SOURCE&&(f["cloud.event_source"]=process.env.EVENTARC_CLOUD_EVENT_SOURCE),p.setAttributes(f),e?.requestHook?.(p),v.with(X.setSpan(v.active(),p),async()=>{let m,_;try{_=await i.apply(this,l)}catch(h){m=h}if(e?.responseHook?.(p,m),m&&p.recordException(m),p.end(),m)throw await e?.errorHook?.(p,m),m;return _})};return a?o.call(this,a,u):o.call(this,u)}}}function Gxe(t,e,n,r,o,s){switch(n7(t,n),s){case"function":e(t,"onRequest",xn(r,o,"http.request")),e(t,"onCall",xn(r,o,"http.call"));break;case"firestore":e(t,"onDocumentCreated",xn(r,o,"firestore.document.created")),e(t,"onDocumentUpdated",xn(r,o,"firestore.document.updated")),e(t,"onDocumentDeleted",xn(r,o,"firestore.document.deleted")),e(t,"onDocumentWritten",xn(r,o,"firestore.document.written")),e(t,"onDocumentCreatedWithAuthContext",xn(r,o,"firestore.document.created")),e(t,"onDocumentUpdatedWithAuthContext",xn(r,o,"firestore.document.updated")),e(t,"onDocumentDeletedWithAuthContext",xn(r,o,"firestore.document.deleted")),e(t,"onDocumentWrittenWithAuthContext",xn(r,o,"firestore.document.written"));break;case"scheduler":e(t,"onSchedule",xn(r,o,"scheduler.scheduled"));break;case"storage":e(t,"onObjectFinalized",xn(r,o,"storage.object.finalized")),e(t,"onObjectArchived",xn(r,o,"storage.object.archived")),e(t,"onObjectDeleted",xn(r,o,"storage.object.deleted")),e(t,"onObjectMetadataUpdated",xn(r,o,"storage.object.metadataUpdated"));break}return t}function n7(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,Is.isWrapped)(t[r])&&e(t,r);return t}var r7={},jxe=[">=3.0.0 <5"],Hxe=[">=6.0.0 <7"],zS=class extends o7.InstrumentationBase{constructor(e=r7){super("@sentry/instrumentation-firebase",pe,e)}setConfig(e={}){super.setConfig({...r7,...e})}init(){let e=[];return e.push(ZY(this.tracer,jxe,this._wrap,this._unwrap,this.getConfig())),e.push(t7(this.tracer,Hxe,this._wrap,this._unwrap,this.getConfig())),e}};var s7="Firebase",Vxe={firestoreSpanCreationHook:t=>{Oe(t,"auto.firebase.otel.firestore"),t.setAttribute(te,"db.query")},functions:{requestHook:t=>{Oe(t,"auto.firebase.otel.functions"),t.setAttribute(te,"http.request")},errorHook:async(t,e)=>{e&&(ne(e,{mechanism:{type:"auto.firebase.otel.functions",handled:!1}}),await bh(2e3))}}},i7=B(s7,()=>new zS(Vxe)),qxe=()=>({name:s7,setupOnce(){i7()}}),a7=qxe;function u7(){return[e8(),xq(),t5(),Nz(),F5(),Z5(),l9(),A9(),J9(),g$(),pz(),Iz(),Vz(),tY(),mY(),yY(),g5(),wY(),C5(),YY(),QY(),BY(),GY(),HY(),$Y(),S$(),a7()]}P();var YS=Q(kI(),1),c7=Q(sO(),1);de();var QN=1e6;function l7(t,e={}){t.getOptions().debug&&AO();let[n,r]=$xe(t,e);t.traceProvider=n,t.asyncLocalStorageLookup=r}function $xe(t,e={}){let n=new c7.BasicTracerProvider({sampler:new sT(t),resource:(0,YS.defaultResource)().merge((0,YS.resourceFromAttributes)({[Ey]:"node",[ay]:"sentry",[Sy]:pe})),forceFlushTimeoutMillis:500,spanProcessors:[new oT({timeout:zxe(t.getOptions().maxSpanWaitDuration)}),...e.spanProcessors||[]]});X.setGlobalTracerProvider(n),Br.setGlobalPropagator(new rT);let r=new SO;return v.setGlobalContextManager(r),[n,r.getAsyncLocalStorageLookup()]}function zxe(t){if(t!=null){if(t>QN)return yt&&y.warn(`\`maxSpanWaitDuration\` is too high, using the maximum value of ${QN}`),QN;if(t<=0||Number.isNaN(t)){yt&&y.warn("`maxSpanWaitDuration` must be a positive number, using default value instead.");return}return t}}function d7(){return fT().filter(e=>e.name!=="Http"&&e.name!=="NodeFetch").concat(vV(),GV())}function p7(t){return[...d7(),...rt(t)?u7():[]]}function JN(t={}){return Yxe(t,p7)}function Yxe(t={},e){Oa(t,"node");let n=PO({...t,defaultIntegrations:t.defaultIntegrations??e(t)});return n&&!t.skipOpenTelemetrySetup&&(l7(n,{spanProcessors:t.openTelemetrySpanProcessors}),MO()),n}var Wxe="prod",m7="0.1.34",Kxe=`@tanagram/lore/${m7}`;function Ve(){return Wxe}function to(){return m7}function _7(){return Kxe}JN({dsn:"https://583674b382128b1b30b9fa1f0581daab@o4509017064472576.ingest.us.sentry.io/4511344717529088",environment:Ve(),release:to(),sendDefaultPii:!0});yh("service_name","lore-cli");import{realpathSync as HBe}from"node:fs";import{fileURLToPath as VBe,pathToFileURL as QJ}from"node:url";var Qxe=/\d/,Jxe=["-","_","/","."];function Xxe(t=""){if(!Qxe.test(t))return t!==t.toLowerCase()}function h7(t,e){let n=e??Jxe,r=[];if(!t||typeof t!="string")return r;let o="",s,i;for(let a of t){let u=n.includes(a);if(u===!0){r.push(o),o="",s=void 0;continue}let l=Xxe(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 d=o.at(-1);r.push(o.slice(0,Math.max(0,o.length-1))),o=d+a,s=l;continue}}o+=a,s=l,i=u}return r.push(o),r}function Zxe(t){return t?t[0].toUpperCase()+t.slice(1):""}function ePe(t){return t?t[0].toLowerCase()+t.slice(1):""}function tPe(t,e){return t?(Array.isArray(t)?t:h7(t)).map(n=>Zxe(e?.normalize?n.toLowerCase():n)).join(""):""}function Xf(t,e){return ePe(tPe(t||"",e))}function WS(t,e){return t?(Array.isArray(t)?t:h7(t)).map(n=>n.toLowerCase()).join(e??"-"):""}function g7(t){return WS(t||"","_")}import{parseArgs as nPe}from"node:util";function ZS(t){return Array.isArray(t)?t:t===void 0?[]:[t]}function XN(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:d}=await u;if(e.emit("proxyConnect",l),this.emit("proxyConnect",l,e),l.statusCode===200){if(e.once("socket",L0e),n.secureEndpoint){Kp("Upgrading socket connection to TLS");let f=n.servername||n.host;return NO.connect({...EV(n,"host","path","port"),socket:o,servername:hs.isIP(f)?void 0:f})}return o}o.destroy();let p=new hs.Socket({writable:!1});return p.readable=!0,e.once("socket",f=>{Kp("Replaying proxy buffer for failed request"),f.push(d),f.push(null)}),p}};Qp.__initStatic();function L0e(t){t.resume()}function EV(t,...e){let n={},r;for(r in t)e.includes(r)||(n[r]=t[r]);return n}var F0e=1024*32;function G0e(t){return new U0e({read(){this.push(t),this.push(null)}})}function SV(t){let e;try{e=new URL(t.url)}catch{return nt(()=>{console.warn("[@sentry/node]: Invalid dsn or tunnel option, will not send any events. The tunnel option must be a full URL when used.")}),hp(t,()=>Promise.resolve({}))}let n=e.protocol==="https:",r=j0e(e,t.proxy||(n?process.env.https_proxy:void 0)||process.env.http_proxy),o=n?D0e:w0e,s=t.keepAlive===void 0?!1:t.keepAlive,i=r?new Qp(r):new o.Agent({keepAlive:s,maxSockets:30,timeout:2e3}),a=H0e(t,t.httpModule??o,i);return hp(t,a)}function j0e(t,e){let{no_proxy:n}=process.env;if(!n?.split(",").some(o=>t.host.endsWith(o)||t.hostname.endsWith(o)))return e}function H0e(t,e,n){let{hostname:r,pathname:o,port:s,protocol:i,search:a}=new URL(t.url);return function(l){return new Promise((d,p)=>{Ac(()=>{let f=G0e(l.body),m={...t.headers};l.body.length>F0e&&(m["content-encoding"]="gzip",f=f.pipe(B0e()));let _=r.startsWith("["),h=e.request({method:"POST",agent:n,headers:m,hostname:_?r.slice(1,-1):r,path:`${o}${a}`,port:s,protocol:i,ca:t.caCerts},g=>{g.on("data",()=>{}),g.on("end",()=>{}),g.setEncoding("utf8");let E=g.headers["retry-after"]??null,S=g.headers["x-sentry-rate-limits"]??null;d({statusCode:g.statusCode,headers:{"retry-after":E,"x-sentry-rate-limits":Array.isArray(S)?S[0]||null:S}})});h.on("error",p),f.pipe(h)})})}}function AV(t){if(t===!1)return!1;if(typeof t=="string")return t;let e=Ic(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 V0e,sep as q0e}from"node:path";function yV(t){return t.replace(/^[A-Z]:/,"").replace(/\\/g,"/")}function bV(t=process.argv[1]?xR(process.argv[1]):process.cwd(),e=q0e==="\\"){let n=e?yV(t):t;return r=>{if(!r)return;let o=e?yV(r):r,{dir:s,base:i,ext:a}=V0e.parse(o);(a===".js"||a===".mjs"||a===".cjs")&&(i=i.slice(0,a.length*-1));let u=decodeURIComponent(i);s||(s=".");let l=s.lastIndexOf("/node_modules");if(l>-1)return`${s.slice(l+14).replace(/\//g,".")}:${u}`;if(s.startsWith(n)){let d=s.slice(n.length+1).replace(/\//g,".");return d?`${d}:${u}`:u}return u}}function RV(t){if(process.env.SENTRY_RELEASE)return process.env.SENTRY_RELEASE;if(Z.SENTRY_RELEASE?.id)return Z.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 IV=X_(aI(bV()));P();var CV=Q(re(),1);import*as OV from"node:os";import{threadId as $0e,isMainThread as z0e}from"worker_threads";var Y0e=6e4,pT=class extends gp{constructor(e){let n=e.includeServerName===!1?void 0:e.serverName||global.process.env.SENTRY_NAME||OV.hostname(),r={...e,platform:"node",runtime:e.runtime||{name:"node",version:global.process.version},serverName:n};e.openTelemetryInstrumentations&&(0,CV.registerInstrumentations)({instrumentations:e.openTelemetryInstrumentations}),Oa(r,"node"),y.log(`Initializing Sentry: process: ${process.pid}, thread: ${z0e?"main":`worker-${$0e}`}.`),super(r),this.getOptions().enableLogs&&(this._logOnExitFlushListener=()=>{bc(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(()=>{oe&&y.log("Flushing client reports based on interval."),this._flushOutcomes()},e.clientReportFlushInterval??Y0e).unref(),process.on("beforeExit",this._clientReportOnExitFlushListener))}_setupIntegrations(){yR(),super._setupIntegrations()}_getTraceInfoFromScope(e){return e?PH(this,e):[void 0,void 0]}};var NV=Q(ab(),1);import*as xV from"module";function xO(){if(iV()&&!Z._sentryEsmLoaderHookRegistered){Z._sentryEsmLoaderHookRegistered=!0;try{let{addHookMessagePort:t}=(0,NV.createAddHookMessageChannel)();xV.register("import-in-the-middle/hook.mjs",import.meta.url,{data:{addHookMessagePort:t,include:[]},transferList:[t]})}catch(t){y.warn("Failed to register 'import-in-the-middle' hook",t)}}}function fT(){return[Lh(),vh(),wh(),Dh(),gV(),kR(),Bh(),Zj(),o6(),dV(),pV(),QH(),oV(),qH(),jH(),fV(),lV()]}function PO(t={}){return W0e(t,fT)}function W0e(t={},e){let n=K0e(t,e);n.debug===!0&&(oe?y.enable():nt(()=>{console.warn("[Sentry] Cannot initialize SDK with `debug` option using a non-debug bundle.")})),n.registerEsmLoaderHooks!==!1&&xO(),kH(),Ee().update(n.initialScope),n.spotlight&&!n.integrations.some(({name:s})=>s===OO)&&n.integrations.push(_V({sidecarUrl:typeof n.spotlight=="string"?n.spotlight:void 0})),Oa(n,"node-core");let o=new pT(n);return Ee().setClient(o),o.init(),y.log(`SDK initialized from ${Yp()?"CommonJS":"ESM"}`),o.startClientReportTracking(),X0e(),hH(o),vH(o),process.env.VERCEL&&process.on("SIGTERM",async()=>{await o.flush(200)}),o}function MO(){if(!oe)return;let t=SH(),e=["SentryContextManager","SentryPropagator"];rt()&&e.push("SentrySpanProcessor");for(let n of e)t.includes(n)||y.error(`You have to set up the ${n}. Without this, the OpenTelemetry & Sentry integration will not work properly.`);t.includes("SentrySampler")||y.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 K0e(t,e){let n=Q0e(t.release),r=AV(t.spotlight),o=J0e(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??SV,stackParser:yb(t.stackParser||IV),release:n,tracesSampleRate:o,spotlight:r,debug:Ic(t.debug??process.env.SENTRY_DEBUG)},i=t.integrations,a=t.defaultIntegrations??e(s);return{...s,integrations:mR({defaultIntegrations:a,integrations:i})}}function Q0e(t){if(t!==void 0)return t;let e=RV();if(e!==void 0)return e}function J0e(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 X0e(){if(Ic(process.env.SENTRY_USE_ENVIRONMENT)!==!1){let t=process.env.SENTRY_TRACE,e=process.env.SENTRY_BAGGAGE,n=np(t,e);Ee().setPropagationContext(n)}}function Oe(t,e){t.setAttribute(W,e)}function Jp(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 vO="Http",PV="@opentelemetry_sentry-patched/instrumentation-http",mT=Qr.major===22&&Qr.minor>=12||Qr.major===23&&Qr.minor>=2||Qr.major>=24,Z0e=B(`${vO}.sentry`,t=>new La(t)),eAe=B(vO,t=>{let e=new MV.HttpInstrumentation({...t,disableIncomingRequestInstrumentation:!0});try{e._diag=Wn.createComponentLogger({namespace:PV}),e.instrumentationName=PV}catch{}try{let n={get:()=>!1,set:()=>{}};Object.defineProperty(e,"_httpPatched",n),Object.defineProperty(e,"_httpsPatched",n)}catch{}return e});function tAe(t,e={}){return typeof t.spans=="boolean"?t.spans:!(e.skipOpenTelemetrySetup||!rt(e)&&mT)}var vV=(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=vp(r),i=kp(o),a=e&&!n;return{name:vO,setup(u){let l=u.getOptions();a&&rt(l)&&i.setup(u)},setupOnce(){let u=V()?.getOptions()||{},l=tAe(t,u);s.setupOnce();let d={breadcrumbs:t.breadcrumbs,propagateTraceInOutgoingRequests:typeof t.tracePropagation=="boolean"?t.tracePropagation:mT||!l,createSpansForOutgoingRequests:mT,spans:t.spans,ignoreOutgoingRequests:t.ignoreOutgoingRequests,outgoingRequestHook:(p,f)=>{let m=Jp(f);if(m.startsWith("data:")){let _=Oc(m);p.setAttribute("http.url",_),p.setAttribute(Xs,_),p.updateName(`${f.method||"GET"} ${_}`)}t.instrumentation?.requestHook?.(p,f)},outgoingResponseHook:t.instrumentation?.responseHook,outgoingRequestApplyCustomAttributes:t.instrumentation?.applyCustomAttributesOnSpan};if(Z0e(d),l){let p=nAe(t);eAe(p)}},processEvent(u){return i.processEvent(u)}}};function nAe(t={}){return{disableOutgoingRequestInstrumentation:mT,ignoreOutgoingRequestHook:n=>{let r=Jp(n);if(!r)return!1;let o=t.ignoreOutgoingRequests;return!!o?.(r,n)},requireParentforOutgoingSpans:!1,requestHook:(n,r)=>{Oe(n,"auto.http.otel.http");let o=Jp(r);if(o.startsWith("data:")){let s=Oc(o);n.setAttribute("http.url",s),n.setAttribute(Xs,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 BV=Q(DV(),1);var FV="NodeFetch",sAe=B(FV,BV.UndiciInstrumentation,t=>cAe(t)),iAe=B(`${FV}.sentry`,wa,t=>t),aAe=(t={})=>({name:"NodeFetch",setupOnce(){uAe(t,V()?.getOptions())&&sAe(t),iAe(t)}}),GV=aAe;function UV(t,e="/"){let n=`${t}`;return n.endsWith("/")&&e.startsWith("/")?`${n}${e.slice(1)}`:!n.endsWith("/")&&!e.startsWith("/")?`${n}/${e}`:`${n}${e}`}function uAe(t,e={}){return typeof t.spans=="boolean"?t.spans:!e.skipOpenTelemetrySetup&&rt(e)}function cAe(t={}){return{requireParentforSpans:!1,ignoreRequestHook:n=>{let r=UV(n.origin,n.path),o=t.ignoreOutgoingRequests;return!!(o&&r&&o(r))},startSpanHook:n=>{let r=UV(n.origin,n.path);if(r.startsWith("data:")){let o=Oc(r);return{[W]:"auto.http.otel.node_fetch","http.url":o,[Xs]:o,[gr]:`${n.method||"GET"} ${o}`}}return{[W]:"auto.http.otel.node_fetch"}},requestHook:t.requestHook,responseHook:t.responseHook,headersToSpanAttributes:t.headersToSpanAttributes}}var JV=Q(QV(),1);var yt=typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__;var XV="Express";function IAe(t){Oe(t,"auto.http.otel.express");let e=Y(t).data,n=e["express.type"];n&&t.setAttribute(te,`${n}.express`);let r=e["express.name"];typeof r=="string"&&t.updateName(r)}function OAe(t,e){if(le()===hr())return yt&&y.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";le().setTransactionName(`${r} ${t.route}`)}return e}var ZV=B(XV,()=>new JV.ExpressInstrumentation({requestHook:t=>IAe(t),spanNameHook:(t,e)=>OAe(t,e)})),CAe=()=>({name:XV,setupOnce(){ZV()}}),e8=CAe;var Oq=Q(Sq(),1);import*as AC from"node:diagnostics_channel";P();var nE=Q(Ae(),1),qa=Q(re(),1);de();var Ts;(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})(Ts||(Ts={}));var _f;(function(t){let e="middleware";t.MIDDLEWARE=e;let n="request_handler";t.REQUEST_HANDLER=n})(_f||(_f={}));var hf;(function(t){let e="middleware";t.MIDDLEWARE=e;let n="request handler";t.REQUEST_HANDLER=n})(hf||(hf={}));P();var gf=Symbol("opentelemetry.instrumentation.fastify.request_active_span");function SC(t,e,n,r={}){let o=e.startSpan(n,{attributes:r}),s=t[gf]||[];return s.push(o),Object.defineProperty(t,gf,{enumerable:!1,configurable:!0,value:s}),o}function eE(t,e){let n=t[gf]||[];n.length&&(n.forEach(r=>{e&&(r.setStatus({code:qe.ERROR,message:e.message}),r.recordException(e)),r.end()}),delete t[gf])}function yq(t,e,n){let r,o;try{o=t(),Aq(o)&&o.then(s=>e(void 0,s),s=>e(s))}catch(s){r=s}finally{if(!Aq(o)&&(e(r,o),r))throw r;return o}}function Aq(t){return typeof t=="object"&&t&&typeof Object.getOwnPropertyDescriptor(t,"then")?.value=="function"||!1}var RRe="0.1.0",IRe="@sentry/instrumentation-fastify-v3",bq="anonymous",ORe=new Set(["onTimeout","onRequest","preParsing","preValidation","preSerialization","preHandler","onSend","onResponse","onError"]),tE=class extends qa.InstrumentationBase{constructor(e={}){super(IRe,RRe,e)}init(){return[new qa.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,nE.getRPCMetadata)(v.active()),u=i.routeOptions?i.routeOptions.url:r.routerPath;u&&a?.type===nE.RPCType.HTTP&&(a.route=u);let l=r.method||"GET";le().setTransactionName(`${l} ${u}`),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||bq,u=`${hf.MIDDLEWARE} - ${a}`,l=i[1],d=SC(l,s.tracer,u,{[Ts.FASTIFY_TYPE]:_f.MIDDLEWARE,[Ts.PLUGIN_NAME]:e,[Ts.HOOK_NAME]:n}),p=o&&i[i.length-1];return p&&(i[i.length-1]=function(...f){eE(l),p.apply(this,f)}),v.with(X.setSpan(v.active(),d),()=>yq(()=>r.apply(this,i),f=>{f instanceof Error&&(d.setStatus({code:qe.ERROR,message:f.message}),d.recordException(f)),o||eE(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(!ORe.has(s))return n.apply(this,o);let u=typeof o[o.length-1]=="function"&&i.constructor.name!=="AsyncFunction";return n.apply(this,[s,e._wrapHandler(a,s,i,u)])}}}_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()),CRe(),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,qa.safeExecuteInTheMiddle)(()=>r.apply(this,s),a=>{!a&&i instanceof Error&&(a=i),eE(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,u=a?.name.startsWith("bound ")?a.name.substring(6):a?.name,l=`${hf.REQUEST_HANDLER} - ${u||this.pluginName||bq}`,d={[Ts.PLUGIN_NAME]:this.pluginName,[Ts.FASTIFY_TYPE]:_f.REQUEST_HANDLER,[ry]:i.routeOptions?i.routeOptions.url:r.routerPath};u&&(d[Ts.FASTIFY_NAME]=u);let p=SC(o,e.tracer,l,d);Rq(p);let{requestHook:f}=e.getConfig();return f&&(0,qa.safeExecuteInTheMiddle)(()=>f(p,{request:r}),m=>{m&&e._diag.error("request hook failed",m)},!0),v.with(X.setSpan(v.active(),p),()=>{s()})}}};function CRe(){let t=V();t&&t.on("spanStart",e=>{Rq(e)})}function Rq(t){let e=Y(t).data,n=e["fastify.type"];if(e[te]||!n)return;t.setAttributes({[W]:"auto.http.otel.fastify",[te]:`${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 rE="Fastify",Cq=B(`${rE}.v3`,()=>new tE);function NRe(){let t=V();if(t)return t.getIntegrationByName(rE)}function Iq(t,e,n,r){let o=NRe()?.getShouldHandleError()||Pq;if(r==="diagnostics-channel"&&(this.diagnosticsChannelExists=!0),this.diagnosticsChannelExists&&r==="onError-hook"){yt&&y.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)&&ne(t,{mechanism:{handled:!1,type:"auto.function.fastify"}})}var Nq=B(`${rE}.v5`,()=>{let t=new Oq.FastifyOtelInstrumentation,e=t.plugin();return AC.subscribe("fastify.initialization",n=>{let r=n.fastify;r?.register(e).after(o=>{o?yt&&y.error("Failed to setup Fastify instrumentation",o):(PRe(),r&&MRe(r))})}),AC.subscribe("tracing:fastify.request.handler:error",n=>{let{error:r,request:o,reply:s}=n;Iq.call(Iq,r,o,s,"diagnostics-channel")}),t}),xRe=({shouldHandleError:t})=>{let e;return{name:rE,setupOnce(){e=t||Pq,Cq(),Nq()},getShouldHandleError(){return e},setShouldHandleError(n){e=n}}},xq=(t={})=>xRe(t);function Pq(t,e,n){let r=n.statusCode;return r>=500||r<=299}function Mq(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[te]||!i&&!a&&!s)return;let u=s?"hook":i?"middleware":a?"request_handler":"<unknown>";t.setAttributes({[W]:"auto.http.otel.fastify",[te]:`${u}.fastify`});let l=r["fastify.name"]||r["plugin.name"]||r["hook.name"];if(typeof l=="string"){let d=l.replace(/^fastify -> /,"").replace(/^@fastify\/otel -> /,"");t.updateName(d)}}function PRe(){let t=V();t&&t.on("spanStart",e=>{Mq(e)})}function MRe(t){t.addHook("onRequest",async(e,n)=>{if(e.opentelemetry){let{span:s}=e.opentelemetry();s&&Mq(s)}let r=e.routeOptions?.url,o=e.method||"GET";le().setTransactionName(`${o} ${r}`)})}P();var Xq=Q(Jq(),1);var Zq="Graphql",e5=B(Zq,Xq.GraphQLInstrumentation,t=>{let e=n5(t);return{...e,responseHook(n,r){Oe(n,"auto.graphql.otel.graphql"),r.errors?.length&&!Y(n).status&&n.setStatus({code:qe.ERROR});let s=Y(n).data,i=s["graphql.operation.type"],a=s["graphql.operation.name"];if(e.useOperationNameForRootSpan&&i){let u=$e(n),d=Y(u).data[Jc]||[],p=a?`${i} ${a}`:`${i}`;Array.isArray(d)?(d.push(p),u.setAttribute(Jc,d)):typeof d=="string"?u.setAttribute(Jc,[d,p]):u.setAttribute(Jc,p),Y(u).data["original-description"]||u.setAttribute("original-description",Y(u).description),u.updateName(`${Y(u).data["original-description"]} (${XRe(d)})`)}}}}),JRe=(t={})=>({name:Zq,setupOnce(){e5(n5(t))}}),t5=JRe;function n5(t){return{ignoreResolveSpans:!0,ignoreTrivialResolveSpans:!0,useOperationNameForRootSpan:!0,...t}}function XRe(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 m5=Q(f5(),1);var _5="Kafka",h5=B(_5,()=>new m5.KafkaJsInstrumentation({consumerHook(t){Oe(t,"auto.kafkajs.otel.consumer")},producerHook(t){Oe(t,"auto.kafkajs.otel.producer")}})),eIe=()=>({name:_5,setupOnce(){h5()}}),g5=eIe;var R5=Q(b5(),1);var I5="LruMemoizer",O5=B(I5,()=>new R5.LruMemoizerInstrumentation),nIe=()=>({name:I5,setupOnce(){O5()}}),C5=nIe;var D5=Q(w5(),1);var U5="Mongo",B5=B(U5,()=>new D5.MongoDBInstrumentation({dbStatementSerializer:aIe,responseHook(t){Oe(t,"auto.db.otel.mongo")}}));function aIe(t){let e=PC(t);return JSON.stringify(e)}function PC(t){if(Array.isArray(t))return t.map(e=>PC(e));if(uIe(t)){let e={};return Object.entries(t).map(([n,r])=>[n,PC(r)]).reduce((n,r)=>(lIe(r)&&(n[r[0]]=r[1]),n),e)}return"?"}function uIe(t){return typeof t=="object"&&t!==null&&!cIe(t)}function cIe(t){let e=!1;return typeof Buffer<"u"&&(e=Buffer.isBuffer(t)),e}function lIe(t){return Array.isArray(t)}var dIe=()=>({name:U5,setupOnce(){B5()}}),F5=dIe;var Q5=Q(K5(),1);var J5="Mongoose",X5=B(J5,()=>new Q5.MongooseInstrumentation({responseHook(t){Oe(t,"auto.db.otel.mongoose")}})),SIe=()=>({name:J5,setupOnce(){X5()}}),Z5=SIe;var a9=Q(i9(),1);var u9="Mysql",c9=B(u9,()=>new a9.MySQLInstrumentation({})),PIe=()=>({name:u9,setupOnce(){c9()}}),l9=PIe;var T9=Q(g9(),1);var E9="Mysql2",S9=B(E9,()=>new T9.MySQL2Instrumentation({responseHook(t){Oe(t,"auto.db.otel.mysql2")}})),$Ie=()=>({name:E9,setupOnce(){S9()}}),A9=$Ie;var Y9=Q(x9(),1),W9=Q(H9(),1);var lOe=["get","set","setex"],JC=["get","mget"],dOe=["set","setex"];function Mf(t,e){return t.includes(e.toLowerCase())}function XC(t){return Mf(JC,t)?"cache.get":Mf(dOe,t)?"cache.put":void 0}function pOe(t,e){return e.some(n=>t.startsWith(n))}function q9(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)?V9(o.map(s=>n(s))):["<unknown>"],r=e[0];return Mf(lOe,t)&&r!=null?n(r):V9(e.map(o=>n(o)))}catch{return}}function $9(t,e,n){if(!XC(t))return!1;for(let r of e)if(pOe(r,n))return!0;return!1}function z9(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 V9(t){let e=[],n=r=>{r.forEach(o=>{Array.isArray(o)?n(o):e.push(o)})};return n(t),e}var GE="Redis",vf={},K9=(t,e,n,r)=>{t.setAttribute(W,"auto.db.otel.redis");let o=q9(e,n),s=XC(e);if(!o||!s||!vf.cachePrefixes||!$9(e,o,vf.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 u=z9(r);u&&t.setAttribute(Wb,u),Mf(JC,e)&&u!==void 0&&t.setAttribute(zb,u>0),t.setAttributes({[te]:s,[Yb]:o});let l=o.join(", ");t.updateName(vf.maxCacheKeyLength?Ys(l,vf.maxCacheKeyLength):l)},fOe=B(`${GE}.IORedis`,()=>new Y9.IORedisInstrumentation({responseHook:K9})),mOe=B(`${GE}.Redis`,()=>new W9.RedisInstrumentation({responseHook:K9})),Q9=Object.assign(()=>{fOe(),mOe()},{id:GE}),_Oe=(t={})=>({name:GE,setupOnce(){vf=t,Q9()}}),J9=_Oe;var m$=Q(f$(),1);var _$="Postgres",h$=B(_$,m$.PgInstrumentation,t=>({requireParentSpan:!0,requestHook(e){Oe(e,"auto.db.otel.postgres")},ignoreConnectSpans:t?.ignoreConnectSpans??!1})),POe=t=>({name:_$,setupOnce(){h$(t)}}),g$=POe;P();var Mi=Q(re(),1);de();var sN="PostgresJs",T$=[">=3.0.0 <4"],MOe=/^(SELECT|INSERT|UPDATE|DELETE|CREATE|DROP|ALTER)/i,vOe=Symbol.for("sentry.query.from.instrumented.sql"),E$=B(sN,t=>new oN({requireParentSpan:t?.requireParentSpan??!0,requestHook:t?.requestHook})),oN=class extends Mi.InstrumentationBase{constructor(e){super("sentry-postgres-js",pe,e)}init(){let e=new Mi.InstrumentationNodeModuleDefinition("postgres",T$,n=>{try{return this._patchPostgres(n)}catch(r){return yt&&y.error("Failed to patch postgres module:",r),n}},n=>n);return["src","cf/src","cjs/src"].forEach(n=>{e.files.push(new Mi.InstrumentationNodeModuleFile(`postgres/${n}/query.js`,T$,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 yt&&y.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 yt&&y.warn("postgres() did not return a valid instance"),a;let u=o.getConfig();return vR(a,{requireParentSpan:u.requireParentSpan,requestHook:u.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:(xp(e,"default",s),e)}_shouldCreateSpans(){let e=this.getConfig();return X.getSpan(v.active())!==void 0||!e.requireParentSpan}_setOperationName(e,n,r){if(r){e.setAttribute(qu,r);return}let o=n?.match(MOe);o?.[1]&&e.setAttribute(qu,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[vOe])return r.apply(this,o);if(!n._shouldCreateSpans())return r.apply(this,o);let s=n._reconstructQuery(this.strings),i=n._sanitizeSqlQuery(s);return Pt({name:i||"postgresjs.query",op:"db"},a=>{Oe(a,"auto.db.postgresjs"),a.setAttributes({[aa]:"postgres",[ly]:i});let u=n.getConfig(),{requestHook:l}=u;l&&(0,Mi.safeExecuteInTheMiddle)(()=>l(a,i,void 0),f=>{f&&(a.setAttribute("sentry.hook.error","requestHook failed"),yt&&y.error(`Error in requestHook for ${sN} integration:`,f))},!0);let d=this.resolve;this.resolve=new Proxy(d,{apply:(f,m,_)=>{try{n._setOperationName(a,i,_?.[0]?.command),a.end()}catch(h){yt&&y.error("Error ending span in resolve callback:",h)}return Reflect.apply(f,m,_)}});let p=this.reject;this.reject=new Proxy(p,{apply:(f,m,_)=>{try{a.setStatus({code:2,message:_?.[0]?.message||"unknown_error"}),a.setAttribute(dy,_?.[0]?.code||"unknown"),a.setAttribute(py,_?.[0]?.name||"unknown"),n._setOperationName(a,i),a.end()}catch(h){yt&&y.error("Error ending span in reject callback:",h)}return Reflect.apply(f,m,_)}});try{return r.apply(this,o)}catch(f){throw a.setStatus({code:2,message:f instanceof Error?f.message:"unknown_error"}),a.end(),f}})},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}},kOe=t=>({name:sN,setupOnce(){E$(t)}}),S$=kOe;P();P();var mS=Q(rz(),1);P();var eNe={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"}},tNe=eNe.version.split(".")[0],xN="PRISMA_INSTRUMENTATION",PN=`V${tNe}_PRISMA_INSTRUMENTATION`,Dl=globalThis;function nNe(){let t=Dl[PN];return t?.helper?t.helper:Dl[xN]?.helper}function rNe(t){let e={helper:t};Dl[PN]=e,Dl[xN]=e}function oNe(){delete Dl[PN],delete Dl[xN]}var sNe=process.env.PRISMA_SHOW_ALL_TRACES==="true",iNe="00-10-10-00";function aNe(t){switch(t){case"client":return Pe.CLIENT;case"internal":default:return Pe.INTERNAL}}var uNe=class{tracerProvider;ignoreSpanTypes;constructor({tracerProvider:t,ignoreSpanTypes:e}){this.tracerProvider=t,this.ignoreSpanTypes=e}isEnabled(){return!0}getTraceParent(t){let e=X.getSpanContext(t??v.active());return e?`00-${e.traceId}-${e.spanId}-0${e.traceFlags}`:iNe}dispatchEngineSpans(t){let e=this.tracerProvider.getTracer("prisma"),n=new Map,r=t.filter(o=>o.parentId===null);for(let o of r)iz(e,o,t,n,this.ignoreSpanTypes)}getActiveContext(){return v.active()}runInChildSpan(t,e){if(typeof t=="string"&&(t={name:t}),t.internal&&!sNe)return e();let n=this.tracerProvider.getTracer("prisma"),r=t.context??this.getActiveContext(),o=`prisma:client:${t.name}`;if(az(o,this.ignoreSpanTypes))return e();if(t.active===!1){let s=n.startSpan(o,t,r);return oz(s,e(s,r))}return n.startActiveSpan(o,t,s=>oz(s,e(s,r)))}};function iz(t,e,n,r,o){if(az(e.name,o))return;let s={attributes:e.attributes,kind:aNe(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(u=>{let l=r.get(u);return l?{context:{spanId:l,traceId:i.spanContext().traceId,traceFlags:i.spanContext().traceFlags}}:[]}));let a=n.filter(u=>u.parentId===e.id);for(let u of a)iz(t,u,n,r,o);i.end(e.endTime)})}function oz(t,e){return cNe(e)?e.then(n=>(t.end(),n),n=>{throw t.end(),n}):(t.end(),e)}function cNe(t){return t!=null&&typeof t.then=="function"}function az(t,e){return e.some(n=>typeof n=="string"?n===t:n.test(t))}var uz={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},sz=uz.version,lNe=uz.name,dNe="@prisma/client",cz=class extends mS.InstrumentationBase{tracerProvider;constructor(t={}){super(lNe,sz,t)}setTracerProvider(t){this.tracerProvider=t}init(){return[new mS.InstrumentationNodeModuleDefinition(dNe,[sz])]}enable(){let t=this._config;rNe(new uNe({tracerProvider:this.tracerProvider??X.getTracerProvider(),ignoreSpanTypes:t.ignoreSpanTypes??[]}))}disable(){oNe()}isEnabled(){return nNe()!==void 0}};var lz="Prisma";function pNe(t){return!!t&&typeof t=="object"&&"dispatchEngineSpans"in t}function dz(){let t=globalThis.PRISMA_INSTRUMENTATION;return t&&typeof t=="object"&&"helper"in t?t.helper:void 0}var MN=class extends cz{constructor(e){super(e?.instrumentationConfig)}enable(){super.enable();let e=dz();pNe(e)&&(e.createEngineSpan=n=>{let r=X.getTracer("prismaV5Compatibility"),o=r._idGenerator;if(!o){nt(()=>{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=fNe(s.kind),a=s.parent_span_id,u=s.span_id,l=s.trace_id,d=s.links?.map(f=>({context:{traceId:f.trace_id,spanId:f.span_id,traceFlags:Zt.SAMPLED}})),p=X.setSpanContext(v.active(),{traceId:l,spanId:a,traceFlags:Zt.SAMPLED});v.with(p,()=>{let f={generateTraceId:()=>l,generateSpanId:()=>u};r._idGenerator=f,r.startSpan(s.name,{kind:i,links:d,startTime:s.start_time,attributes:s.attributes}).end(s.end_time),r._idGenerator=o})})}finally{r._idGenerator=o}})}};function fNe(t){switch(t){case"client":return Pe.CLIENT;case"internal":default:return Pe.INTERNAL}}var mNe=B(lz,t=>new MN(t)),pz=t=>({name:lz,setupOnce(){mNe(t)},setup(e){dz()&&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 yz=Q(Az(),1);var bz="Hapi",Rz=B(bz,()=>new yz.HapiInstrumentation),CNe=()=>({name:bz,setupOnce(){Rz()}}),Iz=CNe;de();var wi={HONO_TYPE:"hono.type",HONO_NAME:"hono.name"},zf={MIDDLEWARE:"middleware",REQUEST_HANDLER:"request_handler"};P();var TS=Q(re(),1);var NNe="@sentry/instrumentation-hono",xNe="0.0.1",gS=class extends TS.InstrumentationBase{constructor(e={}){super(NNe,xNe,e)}init(){return[new TS.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 v.with(X.setSpan(v.active(),i),()=>n._safeExecute(()=>{let a=e.apply(this,[r,o]);if(Ht(a))return a.then(u=>{let l=n._determineHandlerType(u);return i.setAttributes({[wi.HONO_TYPE]:l,[wi.HONO_NAME]:l===zf.REQUEST_HANDLER?s:e.name||"anonymous"}),n.getConfig().responseHook?.(i),u});{let u=n._determineHandlerType(a);return i.setAttributes({[wi.HONO_TYPE]:u,[wi.HONO_NAME]:u===zf.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 Ht(o)?o.then(()=>n(),s=>r(s)):n(),o}catch(o){throw r(o),o}}_determineHandlerType(e){return e===void 0?zf.MIDDLEWARE:zf.REQUEST_HANDLER}_handleError(e,n){n instanceof Error&&(e.setStatus({code:qe.ERROR,message:n.message}),e.recordException(n))}};var Oz="Hono";function PNe(t){let e=Y(t).data,n=e[wi.HONO_TYPE];if(e[te]||!n)return;t.setAttributes({[W]:"auto.http.otel.hono",[te]:`${n}.hono`});let r=e[wi.HONO_NAME];if(typeof r=="string"&&t.updateName(r),le()===hr()){yt&&y.warn("Isolation scope is default isolation scope - skipping setting transactionName");return}let o=e[ts],s=e[ua];typeof o=="string"&&typeof s=="string"&&le().setTransactionName(`${s} ${o}`)}var Cz=B(Oz,()=>new gS({responseHook:t=>{PNe(t)}})),MNe=()=>({name:Oz,setupOnce(){Cz()}}),Nz=MNe;var Gz=Q(Fz(),1);de();var jz="Koa",Hz=B(jz,Gz.KoaInstrumentation,(t={})=>({ignoreLayersType:t.ignoreLayersType,requestHook(e,n){Oe(e,"auto.http.otel.koa");let r=Y(e).data,o=r["koa.type"];o&&e.setAttribute(te,`${o}.koa`);let s=r["koa.name"];if(typeof s=="string"&&e.updateName(s||"< unknown >"),le()===hr()){yt&&y.warn("Isolation scope is default isolation scope - skipping setting transactionName");return}let i=r[ts],a=n.context?.request?.method?.toUpperCase()||"GET";i&&le().setTransactionName(`${a} ${i}`)}})),GNe=(t={})=>({name:jz,setupOnce(){Hz(t)}}),Vz=GNe;var Xz=Q(Jz(),1);var Zz="Connect",eY=B(Zz,()=>new Xz.ConnectInstrumentation),QNe=()=>({name:Zz,setupOnce(){eY()}}),tY=QNe;var dY=Q(lY(),1);var txe=new Set(["callProcedure","execSql","execSqlBatch","execBulkLoad","prepare","execute"]),pY="Tedious",fY=B(pY,()=>new dY.TediousInstrumentation({})),nxe=()=>{let t;return{name:pY,setupOnce(){let e=fY();t=Mp(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]||"";txe.has(s)&&n.setAttribute(W,"auto.db.otel.tedious")}))}}},mY=nxe;var EY=Q(TY(),1);var SY="GenericPool",AY=B(SY,()=>new EY.GenericPoolInstrumentation({})),oxe=()=>{let t;return{name:SY,setupOnce(){let e=AY();t=Mp(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")}))}}},yY=oxe;var vY=Q(MY(),1);var kY="Amqplib",_xe={consumeEndHook:t=>{Oe(t,"auto.amqplib.otel.consumer")},publishHook:t=>{Oe(t,"auto.amqplib.otel.publisher")}},LY=B(kY,()=>new vY.AmqplibInstrumentation(_xe)),hxe=()=>({name:kY,setupOnce(){LY()}}),wY=hxe;var Jf="VercelAI";var wS=Q(re(),1);var gxe=[">=3.0.0 <7"],DY=["generateText","streamText","generateObject","streamObject","embed","embedMany","rerank"];function Txe(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 Exe(t){if(typeof t!="object"||t===null||!("content"in t))return;let e=t;Array.isArray(e.content)&&(Sxe(e.content),Axe(e.content))}function Sxe(t){for(let e of t){if(!Txe(e))continue;let n=XR(e.toolCallId);n?Qn(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"),ne(e.error,{mechanism:{type:"auto.vercelai.otel",handled:!1}})}):Qn(r=>{r.setTag("vercel.ai.tool.name",e.toolName),r.setTag("vercel.ai.tool.callId",e.toolCallId),r.setLevel("error"),ne(e.error,{mechanism:{type:"auto.vercelai.otel",handled:!1}})})}}function Axe(t){for(let e of t)typeof e=="object"&&e!==null&&"toolCallId"in e&&typeof e.toolCallId=="string"&&ZR(e.toolCallId)}function yxe(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 LS=class t extends wS.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 wS.InstrumentationNodeModuleDefinition("ai",gxe,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||{},u=a.isEnabled,l=V(),d=l?.getIntegrationByName(Jf),p=d?.options,f=d?!!l?.getOptions().sendDefaultPii:!1,{recordInputs:m,recordOutputs:_}=yxe(p,a,u,f);return i[0].experimental_telemetry={...a,isEnabled:u!==void 0?u:!0,recordInputs:m,recordOutputs:_},Yr(()=>Reflect.apply(o,s,i),h=>{h&&typeof h=="object"&<(h,"_sentry_active_span",Tr())},()=>{},h=>{Exe(h)})}});if(Object.prototype.toString.call(e)==="[object Module]"){for(let r of DY)e[r]!=null&&(e[r]=n(e[r]));return e}else{let r=DY.reduce((o,s)=>(e[s]!=null&&(o[s]=n(e[s])),o),{});return{...e,...r}}}};var UY=B(Jf,()=>new LS({}));function bxe(t){return!!t.getIntegrationByName("Modules")?.getModules?.()?.ai}var Rxe=(t={})=>{let e;return{name:Jf,options:t,setupOnce(){e=UY()},afterAllSetup(n){t.force??bxe(n)?Yh(n):e?.callWhenPatched(()=>Yh(n))}}},BY=Rxe;var US=Q(re(),1);var Ixe=[">=4.0.0 <7"],DS=class extends US.InstrumentationBase{constructor(e={}){super("@sentry/instrumentation-openai",pe,e)}init(){return new US.InstrumentationNodeModuleDefinition("openai",Ixe,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(Ia(fi))return Reflect.construct(r,i);let a=Reflect.construct(r,i);return Kh(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 FY=B(fi,t=>new DS(t)),Oxe=(t={})=>({name:fi,setupOnce(){FY(t)}}),GY=Oxe;var FS=Q(re(),1);var Cxe=[">=0.19.2 <1.0.0"],BS=class extends FS.InstrumentationBase{constructor(e={}){super("@sentry/instrumentation-anthropic-ai",pe,e)}init(){return new FS.InstrumentationNodeModuleDefinition("@anthropic-ai/sdk",Cxe,this._patch.bind(this))}_patch(e){let n=e.Anthropic,r=this.getConfig(),o=function(...s){if(Ia(mi))return Reflect.construct(n,s);let i=Reflect.construct(n,s);return Qh(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 jY=B(mi,t=>new BS(t)),Nxe=(t={})=>({name:mi,options:t,setupOnce(){jY(t)}}),HY=Nxe;var Kl=Q(re(),1);var VY=[">=0.10.0 <2"],GS=class extends Kl.InstrumentationBase{constructor(e={}){super("@sentry/instrumentation-google-genai",pe,e)}init(){return new Kl.InstrumentationNodeModuleDefinition("@google/genai",VY,n=>this._patch(n),n=>n,[new Kl.InstrumentationNodeModuleFile("@google/genai/dist/node/index.cjs",VY,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(Ia(_i))return Reflect.construct(n,s);let i=Reflect.construct(n,s);return Jh(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 xp(e,"GoogleGenAI",o),e}};var qY=B(_i,t=>new GS(t)),xxe=(t={})=>({name:_i,setupOnce(){qY(t)}}),$Y=xxe;var qi=Q(re(),1);var jS=[">=0.1.0 <2.0.0"];function Pxe(t,e){return t?Array.isArray(t)?t.includes(e)?t:[...t,e]:typeof t=="object"?[t,e]:t:[e]}function Mxe(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 u=a.callbacks,l=Pxe(u,e);return a.callbacks=l,Reflect.apply(r,o,s)}})}var HS=class extends qi.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 qi.InstrumentationNodeModuleDefinition(r,jS,this._patch.bind(this),o=>o,[new qi.InstrumentationNodeModuleFile(`${r}/dist/index.cjs`,jS,this._patch.bind(this),o=>o)]));return e.push(new qi.InstrumentationNodeModuleDefinition("langchain",jS,this._patch.bind(this),r=>r,[new qi.InstrumentationNodeModuleFile("langchain/dist/chat_models/universal.cjs",jS,this._patch.bind(this),r=>r)])),e}_patch(e){AR([fi,mi,_i]);let n=Zh(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(u=>typeof u=="function"&&r.includes(u.name));if(!s)return;let i=s.prototype;if(i.__sentry_patched__)return;i.__sentry_patched__=!0;let a=["invoke","stream","batch"];for(let u of a){let l=i[u];typeof l=="function"&&(i[u]=Mxe(l,n))}}};var zY=B(Xh,t=>new HS(t)),vxe=(t={})=>({name:Xh,setupOnce(){zY(t)}}),YY=vxe;var Ql=Q(re(),1);var WY=[">=0.0.0 <2.0.0"],VS=class extends Ql.InstrumentationBase{constructor(e={}){super("@sentry/instrumentation-langgraph",pe,e)}init(){return new Ql.InstrumentationNodeModuleDefinition("@langchain/langgraph",WY,this._patch.bind(this),n=>n,[new Ql.InstrumentationNodeModuleFile("@langchain/langgraph/dist/index.cjs",WY,this._patch.bind(this),n=>n)])}_patch(e){return e.StateGraph&&typeof e.StateGraph=="function"&&tg(e.StateGraph.prototype,this.getConfig()),e}};var KY=B(eg,t=>new VS(t)),kxe=(t={})=>({name:eg,setupOnce(){KY(t)}}),QY=kxe;var o7=Q(re(),1);P();var Rs=Q(re(),1);de();import*as XY from"node:net";function ZY(t,e,n,r,o){let i=()=>{},a=o.firestoreSpanCreationHook;typeof a=="function"&&(i=d=>{(0,Rs.safeExecuteInTheMiddle)(()=>a(d),p=>{p&&Wn.error(p?.message)},!0)});let u=new Rs.InstrumentationNodeModuleDefinition("@firebase/firestore",e,d=>JY(d,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 d of l)u.files.push(new Rs.InstrumentationNodeModuleFile(d,e,p=>JY(p,n,r,t,i),p=>e7(p,r)));return u}function JY(t,e,n,r,o){return e7(t,n),e(t,"addDoc",Lxe(r,o)),e(t,"getDocs",Dxe(r,o)),e(t,"setDoc",Uxe(r,o)),e(t,"deleteDoc",wxe(r,o)),t}function e7(t,e){for(let n of["addDoc","getDocs","setDoc","deleteDoc"])(0,Rs.isWrapped)(t[n])&&e(t,n);return t}function Lxe(t,e){return function(r){return function(o,s){let i=$S(t,"addDoc",o);return e(i),qS(i,()=>r(o,s))}}}function wxe(t,e){return function(r){return function(o){let s=$S(t,"deleteDoc",o.parent||o);return e(s),qS(s,()=>r(o))}}}function Dxe(t,e){return function(r){return function(o){let s=$S(t,"getDocs",o);return e(s),qS(s,()=>r(o))}}}function Uxe(t,e){return function(r){return function(o,s,i){let a=$S(t,"setDoc",o.parent||o);return e(a),qS(a,()=>typeof i<"u"?r(o,s,i):r(o,s))}}}function qS(t,e){return v.with(X.setSpan(v.active(),t),()=>(0,Rs.safeExecuteInTheMiddle)(()=>e(),n=>{n&&t.recordException(n),t.end()},!0))}function $S(t,e,n){let r=t.startSpan(`${e} ${n.path}`,{kind:Pe.CLIENT});return Fxe(r,n),r.setAttribute(qu,e),r}function Bxe(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(XY.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 Fxe(t,e){let n=e.firestore.app,r=n.options,s=(e.firestore.toJSON()||{}).settings||{},i={[uy]:e.path,[cy]:n.name,[aa]:"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:u}=Bxe(s);a&&(i[gy]=a),u&&(i[Ty]=u),t.setAttributes(i)}P();var Is=Q(re(),1);function t7(t,e,n,r,o){let s=()=>{},i=()=>{},a=o.functions?.errorHook,u=o.functions?.requestHook,l=o.functions?.responseHook;typeof l=="function"&&(i=(f,m)=>{(0,Is.safeExecuteInTheMiddle)(()=>l(f,m),_=>{_&&Wn.error(_?.message)},!0)}),typeof u=="function"&&(s=f=>{(0,Is.safeExecuteInTheMiddle)(()=>u(f),m=>{m&&Wn.error(m?.message)},!0)});let d=new Is.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:f,triggerType:m})=>{d.files.push(new Is.InstrumentationNodeModuleFile(f,e,_=>Gxe(_,n,r,t,{requestHook:s,responseHook:i,errorHook:a},m),_=>n7(_,r)))}),d}function xn(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 u=async function(...l){let d=process.env.FUNCTION_TARGET||process.env.K_SERVICE||"unknown",p=t.startSpan(`firebase.function.${n}`,{kind:Pe.SERVER}),f={"faas.name":d,"faas.trigger":n,"faas.provider":"firebase"};return process.env.GCLOUD_PROJECT&&(f["cloud.project_id"]=process.env.GCLOUD_PROJECT),process.env.EVENTARC_CLOUD_EVENT_SOURCE&&(f["cloud.event_source"]=process.env.EVENTARC_CLOUD_EVENT_SOURCE),p.setAttributes(f),e?.requestHook?.(p),v.with(X.setSpan(v.active(),p),async()=>{let m,_;try{_=await i.apply(this,l)}catch(h){m=h}if(e?.responseHook?.(p,m),m&&p.recordException(m),p.end(),m)throw await e?.errorHook?.(p,m),m;return _})};return a?o.call(this,a,u):o.call(this,u)}}}function Gxe(t,e,n,r,o,s){switch(n7(t,n),s){case"function":e(t,"onRequest",xn(r,o,"http.request")),e(t,"onCall",xn(r,o,"http.call"));break;case"firestore":e(t,"onDocumentCreated",xn(r,o,"firestore.document.created")),e(t,"onDocumentUpdated",xn(r,o,"firestore.document.updated")),e(t,"onDocumentDeleted",xn(r,o,"firestore.document.deleted")),e(t,"onDocumentWritten",xn(r,o,"firestore.document.written")),e(t,"onDocumentCreatedWithAuthContext",xn(r,o,"firestore.document.created")),e(t,"onDocumentUpdatedWithAuthContext",xn(r,o,"firestore.document.updated")),e(t,"onDocumentDeletedWithAuthContext",xn(r,o,"firestore.document.deleted")),e(t,"onDocumentWrittenWithAuthContext",xn(r,o,"firestore.document.written"));break;case"scheduler":e(t,"onSchedule",xn(r,o,"scheduler.scheduled"));break;case"storage":e(t,"onObjectFinalized",xn(r,o,"storage.object.finalized")),e(t,"onObjectArchived",xn(r,o,"storage.object.archived")),e(t,"onObjectDeleted",xn(r,o,"storage.object.deleted")),e(t,"onObjectMetadataUpdated",xn(r,o,"storage.object.metadataUpdated"));break}return t}function n7(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,Is.isWrapped)(t[r])&&e(t,r);return t}var r7={},jxe=[">=3.0.0 <5"],Hxe=[">=6.0.0 <7"],zS=class extends o7.InstrumentationBase{constructor(e=r7){super("@sentry/instrumentation-firebase",pe,e)}setConfig(e={}){super.setConfig({...r7,...e})}init(){let e=[];return e.push(ZY(this.tracer,jxe,this._wrap,this._unwrap,this.getConfig())),e.push(t7(this.tracer,Hxe,this._wrap,this._unwrap,this.getConfig())),e}};var s7="Firebase",Vxe={firestoreSpanCreationHook:t=>{Oe(t,"auto.firebase.otel.firestore"),t.setAttribute(te,"db.query")},functions:{requestHook:t=>{Oe(t,"auto.firebase.otel.functions"),t.setAttribute(te,"http.request")},errorHook:async(t,e)=>{e&&(ne(e,{mechanism:{type:"auto.firebase.otel.functions",handled:!1}}),await bh(2e3))}}},i7=B(s7,()=>new zS(Vxe)),qxe=()=>({name:s7,setupOnce(){i7()}}),a7=qxe;function u7(){return[e8(),xq(),t5(),Nz(),F5(),Z5(),l9(),A9(),J9(),g$(),pz(),Iz(),Vz(),tY(),mY(),yY(),g5(),wY(),C5(),YY(),QY(),BY(),GY(),HY(),$Y(),S$(),a7()]}P();var YS=Q(kI(),1),c7=Q(sO(),1);de();var QN=1e6;function l7(t,e={}){t.getOptions().debug&&AO();let[n,r]=$xe(t,e);t.traceProvider=n,t.asyncLocalStorageLookup=r}function $xe(t,e={}){let n=new c7.BasicTracerProvider({sampler:new sT(t),resource:(0,YS.defaultResource)().merge((0,YS.resourceFromAttributes)({[Ey]:"node",[ay]:"sentry",[Sy]:pe})),forceFlushTimeoutMillis:500,spanProcessors:[new oT({timeout:zxe(t.getOptions().maxSpanWaitDuration)}),...e.spanProcessors||[]]});X.setGlobalTracerProvider(n),Br.setGlobalPropagator(new rT);let r=new SO;return v.setGlobalContextManager(r),[n,r.getAsyncLocalStorageLookup()]}function zxe(t){if(t!=null){if(t>QN)return yt&&y.warn(`\`maxSpanWaitDuration\` is too high, using the maximum value of ${QN}`),QN;if(t<=0||Number.isNaN(t)){yt&&y.warn("`maxSpanWaitDuration` must be a positive number, using default value instead.");return}return t}}function d7(){return fT().filter(e=>e.name!=="Http"&&e.name!=="NodeFetch").concat(vV(),GV())}function p7(t){return[...d7(),...rt(t)?u7():[]]}function JN(t={}){return Yxe(t,p7)}function Yxe(t={},e){Oa(t,"node");let n=PO({...t,defaultIntegrations:t.defaultIntegrations??e(t)});return n&&!t.skipOpenTelemetrySetup&&(l7(n,{spanProcessors:t.openTelemetrySpanProcessors}),MO()),n}var Wxe="prod",m7="0.1.35",Kxe=`@tanagram/lore/${m7}`;function Ve(){return Wxe}function to(){return m7}function _7(){return Kxe}JN({dsn:"https://583674b382128b1b30b9fa1f0581daab@o4509017064472576.ingest.us.sentry.io/4511344717529088",environment:Ve(),release:to(),sendDefaultPii:!0});yh("service_name","lore-cli");import{realpathSync as HBe}from"node:fs";import{fileURLToPath as VBe,pathToFileURL as QJ}from"node:url";var Qxe=/\d/,Jxe=["-","_","/","."];function Xxe(t=""){if(!Qxe.test(t))return t!==t.toLowerCase()}function h7(t,e){let n=e??Jxe,r=[];if(!t||typeof t!="string")return r;let o="",s,i;for(let a of t){let u=n.includes(a);if(u===!0){r.push(o),o="",s=void 0;continue}let l=Xxe(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 d=o.at(-1);r.push(o.slice(0,Math.max(0,o.length-1))),o=d+a,s=l;continue}}o+=a,s=l,i=u}return r.push(o),r}function Zxe(t){return t?t[0].toUpperCase()+t.slice(1):""}function ePe(t){return t?t[0].toLowerCase()+t.slice(1):""}function tPe(t,e){return t?(Array.isArray(t)?t:h7(t)).map(n=>Zxe(e?.normalize?n.toLowerCase():n)).join(""):""}function Xf(t,e){return ePe(tPe(t||"",e))}function WS(t,e){return t?(Array.isArray(t)?t:h7(t)).map(n=>n.toLowerCase()).join(e??"-"):""}function g7(t){return WS(t||"","_")}import{parseArgs as nPe}from"node:util";function ZS(t){return Array.isArray(t)?t:t===void 0?[]:[t]}function XN(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 ar(t){return typeof t=="function"?t():t}var tu=class extends Error{code;constructor(t,e){super(t),this.name="CLIError",this.code=e}};function rPe(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[g,E]of Object.entries(o)){let S=E;for(let b of S)i.set(g,b),a.has(b)||a.set(b,[]),a.get(b).push(g),i.set(b,g),a.has(g)||a.set(g,[]),a.get(g).push(b)}let u={};function l(g){if(n.has(g))return"boolean";let E=a.get(g)||[];for(let S of E)if(n.has(S))return"boolean";return"string"}function d(g){if(r.has(g))return!0;let E=a.get(g)||[];for(let S of E)if(r.has(S))return!0;return!1}let p=new Set([...n,...r,...Object.keys(o),...Object.values(o).flat(),...Object.keys(s)]);for(let g of p)u[g]||(u[g]={type:l(g),default:s[g]});for(let[g,E]of i.entries())g.length===1&&u[E]&&!u[E].short&&(u[E].short=g);let f=[],m={};for(let g=0;g<t.length;g++){let E=t[g];if(E==="--"){f.push(...t.slice(g));break}if(E.startsWith("--no-")){let S=E.slice(5);m[S]=!0;continue}f.push(E)}let _;try{_=nPe({args:f,options:Object.keys(u).length>0?u:void 0,allowPositionals:!0,strict:!1})}catch{_={values:{},positionals:f}}let h={_:[]};h._=_.positionals;for(let[g,E]of Object.entries(_.values)){let S=E;l(g)==="boolean"&&typeof E=="string"?S=E!=="false":d(g)&&typeof E=="boolean"&&(S=""),h[g]=S}for(let[g]of Object.entries(m)){h[g]=!1;let E=i.get(g);E&&(h[E]=!1);let S=a.get(g);if(S)for(let b of S)h[b]=!1}for(let[g,E]of i.entries())h[g]!==void 0&&h[E]===void 0&&(h[E]=h[g]),h[E]!==void 0&&h[g]===void 0&&(h[g]=h[E]),h[g]!==h[E]&&s[E]===h[E]&&(h[E]=h[g]);return h}var oPe=(()=>{let t=globalThis.process?.env??{};return t.NO_COLOR==="1"||t.TERM==="dumb"||t.TEST||t.CI})(),e0=(t,e=39)=>n=>oPe?n:`\x1B[${t}m${n}\x1B[${e}m`,KS=e0(1,22),no=e0(36),JS=e0(90),QS=e0(4,24);function sPe(t,e){let n={boolean:[],string:[],alias:{},default:{}},r=S7(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 u=Xf(a.name),l=WS(a.name);if(u!==a.name||l!==a.name){let d=ZS(n.alias[a.name]||[]);u!==a.name&&!d.includes(u)&&d.push(u),l!==a.name&&!d.includes(l)&&d.push(l),d.length>0&&(n.alias[a.name]=d)}}let o=rPe(t,n),[...s]=o._,i=new Proxy(o,{get(a,u){return a[u]??a[Xf(u)]??a[WS(u)]}});for(let[,a]of r.entries())if(a.type==="positional"){let u=s.shift();if(u!==void 0)i[a.name]=u;else{if(a.default===void 0&&a.required!==!1)throw new tu(`Missing required positional argument: ${a.name.toUpperCase()}`,"EARG");i[a.name]=a.default}}else if(a.type==="enum"){let u=i[a.name],l=a.options||[];if(u!==void 0&&l.length>0&&!l.includes(u))throw new tu(`Invalid value for argument: ${no(`--${a.name}`)} (${no(u)}). Expected one of: ${l.map(d=>no(d)).join(", ")}.`,"EARG")}else if(a.required&&i[a.name]===void 0)throw new tu(`Missing required argument: --${a.name}`,"EARG");return i}function S7(t){let e=[];for(let[n,r]of Object.entries(t||{}))e.push({...r,name:n,alias:ZS(r.alias)});return e}async function iPe(t){return Promise.all(t.map(e=>ar(e)))}async function XS(t,e){let n=await ar(t.args||{}),r=sPe(e.rawArgs,n),o={rawArgs:e.rawArgs,args:r,data:e.data,cmd:t},s=await iPe(t.plugins??[]),i,a;try{for(let d of s)await d.setup?.(o);typeof t.setup=="function"&&await t.setup(o);let l=await ar(t.subCommands);if(l&&Object.keys(l).length>0){let d=aPe(e.rawArgs,n),p=e.rawArgs[d];if(p){let f=await T7(l,p);if(!f)throw new tu(`Unknown command ${no(p)}`,"E_UNKNOWN_COMMAND");await XS(f,{rawArgs:e.rawArgs.slice(d+1)})}else{let f=await ar(t.default);if(f){if(t.run)throw new tu("Cannot specify both 'run' and 'default' on the same command.","E_DEFAULT_CONFLICT");let m=await T7(l,f);if(!m)throw new tu(`Default sub command ${no(f)} not found in subCommands.`,"E_UNKNOWN_COMMAND");await XS(m,{rawArgs:e.rawArgs})}else if(!t.run)throw new tu("No command specified.","E_NO_COMMAND")}}typeof t.run=="function"&&(i=await t.run(o))}catch(l){a=l}let u=[];if(typeof t.cleanup=="function")try{await t.cleanup(o)}catch(l){u.push(l)}for(let l of[...s].reverse())try{await l.cleanup?.(o)}catch(d){u.push(d)}if(a)throw a;if(u.length===1)throw u[0];if(u.length>1)throw new Error("Multiple cleanup errors",{cause:u});return{result:i}}async function T7(t,e){if(e in t)return ar(t[e]);for(let n of Object.values(t)){let r=await ar(n),o=await ar(r?.meta);if(o?.alias&&ZS(o.alias).includes(e))return r}}function aPe(t,e){for(let n=0;n<t.length;n++){let r=t[n];if(r==="--")return-1;if(r.startsWith("-")){!r.includes("=")&&uPe(r,e)&&n++;continue}return n}return-1}function uPe(t,e){let n=t.replace(/^-{1,2}/,""),r=Xf(n);for(let[o,s]of Object.entries(e))if(!(s.type!=="string"&&s.type!=="enum")&&(r===Xf(o)||(Array.isArray(s.alias)?s.alias:s.alias?[s.alias]:[]).includes(n)))return!0;return!1}var cPe=/^no[-A-Z]/;async function t0(t,e){let n=await ar(t.meta||{}),r=S7(await ar(t.args||{})),o=await ar(e?.meta||{}),s=`${o.name?`${o.name} `:""}`+(n.name||process.argv[1]),i=[],a=[],u=[],l=[];for(let m of r)if(m.type==="positional"){let _=m.name.toUpperCase(),h=m.required!==!1&&m.default===void 0;a.push([no(_+ZN(m)),E7(m,h)]),l.push(h?`<${_}>`:`[${_}]`)}else{let _=m.required===!0&&m.default===void 0,h=[...(m.alias||[]).map(g=>`-${g}`),`--${m.name}`].join(", ")+ZN(m);if(i.push([no(h),E7(m,_)]),m.type==="boolean"&&(m.default===!0||m.negativeDescription)&&!cPe.test(m.name)){let g=[...(m.alias||[]).map(E=>`--no-${E}`),`--no-${m.name}`].join(", ");i.push([no(g),[m.negativeDescription,_?JS("(Required)"):""].filter(Boolean).join(" ")])}_&&l.push(`--${m.name}`+ZN(m))}if(t.subCommands){let m=[],_=await ar(t.subCommands);for(let[h,g]of Object.entries(_)){let E=await ar((await ar(g))?.meta);if(E?.hidden)continue;let S=ZS(E?.alias),b=[h,...S].join(", ");u.push([no(b),E?.description||""]),m.push(h,...S)}l.push(m.join("|"))}let d=[],p=n.version||o.version;d.push(JS(`${n.description} (${s+(p?` v${p}`:"")})`),"");let f=i.length>0||a.length>0;return d.push(`${QS(KS("USAGE"))} ${no(`${s}${f?" [OPTIONS]":""} ${l.join(" ")}`)}`,""),a.length>0&&(d.push(QS(KS("ARGUMENTS")),""),d.push(XN(a," ")),d.push("")),i.length>0&&(d.push(QS(KS("OPTIONS")),""),d.push(XN(i," ")),d.push("")),u.length>0&&(d.push(QS(KS("COMMANDS")),""),d.push(XN(u," ")),d.push("",`Use ${no(`${s} <command> --help`)} for more information about a command.`)),d.filter(m=>typeof m=="string").join(`
|
|
40
|
-
`)}function ZN(t){let e=t.valueHint?`=<${t.valueHint}>`:"",n=e||`=<${g7(t.name)}>`;return!t.type||t.type==="positional"||t.type==="boolean"?e:t.type==="enum"&&t.options?.length?`=<${t.options.join("|")}>`:n}function E7(t,e){let n=e?JS("(Required)"):"",r=t.default===void 0?"":JS(`(Default: ${t.default})`);return[t.description,n,r].filter(Boolean).join(" ")}import{spawn as oUe}from"node:child_process";var c={};ea(c,{BRAND:()=>wPe,DIRTY:()=>nu,EMPTY_PATH:()=>fPe,INVALID:()=>J,NEVER:()=>E1e,OK:()=>dn,ParseStatus:()=>Jt,Schema:()=>ce,ZodAny:()=>Yi,ZodArray:()=>xs,ZodBigInt:()=>ou,ZodBoolean:()=>su,ZodBranded:()=>em,ZodCatch:()=>hu,ZodDate:()=>iu,ZodDefault:()=>_u,ZodDiscriminatedUnion:()=>o0,ZodEffects:()=>wr,ZodEnum:()=>fu,ZodError:()=>Hn,ZodFirstPartyTypeKind:()=>ee,ZodFunction:()=>i0,ZodIntersection:()=>lu,ZodIssueCode:()=>x,ZodLazy:()=>du,ZodLiteral:()=>pu,ZodMap:()=>nd,ZodNaN:()=>od,ZodNativeEnum:()=>mu,ZodNever:()=>ro,ZodNull:()=>uu,ZodNullable:()=>Ho,ZodNumber:()=>ru,ZodObject:()=>Vn,ZodOptional:()=>kr,ZodParsedType:()=>D,ZodPipeline:()=>tm,ZodPromise:()=>Wi,ZodReadonly:()=>gu,ZodRecord:()=>s0,ZodSchema:()=>ce,ZodSet:()=>rd,ZodString:()=>zi,ZodSymbol:()=>ed,ZodTransformer:()=>wr,ZodTuple:()=>jo,ZodType:()=>ce,ZodUndefined:()=>au,ZodUnion:()=>cu,ZodUnknown:()=>Ns,ZodVoid:()=>td,addIssueToContext:()=>k,any:()=>qPe,array:()=>WPe,bigint:()=>FPe,boolean:()=>M7,coerce:()=>T1e,custom:()=>N7,date:()=>GPe,datetimeRegex:()=>O7,defaultErrorMap:()=>Os,discriminatedUnion:()=>XPe,effect:()=>l1e,enum:()=>a1e,function:()=>o1e,getErrorMap:()=>Jl,getParsedType:()=>Go,instanceof:()=>UPe,intersection:()=>ZPe,isAborted:()=>n0,isAsync:()=>Xl,isDirty:()=>r0,isValid:()=>$i,late:()=>DPe,lazy:()=>s1e,literal:()=>i1e,makeIssue:()=>Zf,map:()=>n1e,nan:()=>BPe,nativeEnum:()=>u1e,never:()=>zPe,null:()=>VPe,nullable:()=>p1e,number:()=>P7,object:()=>KPe,objectUtil:()=>ex,oboolean:()=>g1e,onumber:()=>h1e,optional:()=>d1e,ostring:()=>_1e,pipeline:()=>m1e,preprocess:()=>f1e,promise:()=>c1e,quotelessJson:()=>lPe,record:()=>t1e,set:()=>r1e,setErrorMap:()=>pPe,strictObject:()=>QPe,string:()=>x7,symbol:()=>jPe,transformer:()=>l1e,tuple:()=>e1e,undefined:()=>HPe,union:()=>JPe,unknown:()=>$Pe,util:()=>fe,void:()=>YPe});var fe;(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})(fe||(fe={}));var ex;(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(ex||(ex={}));var D=fe.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 x=fe.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"]),lPe=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),Hn=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,u=0;for(;u<i.path.length;){let l=i.path[u];u===i.path.length-1?(a[l]=a[l]||{_errors:[]},a[l]._errors.push(n(i))):a[l]=a[l]||{_errors:[]},a=a[l],u++}}};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,fe.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()}};Hn.create=t=>new Hn(t);var dPe=(t,e)=>{let n;switch(t.code){case x.invalid_type:t.received===D.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case x.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,fe.jsonStringifyReplacer)}`;break;case x.unrecognized_keys:n=`Unrecognized key(s) in object: ${fe.joinValues(t.keys,", ")}`;break;case x.invalid_union:n="Invalid input";break;case x.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${fe.joinValues(t.options)}`;break;case x.invalid_enum_value:n=`Invalid enum value. Expected ${fe.joinValues(t.options)}, received '${t.received}'`;break;case x.invalid_arguments:n="Invalid function arguments";break;case x.invalid_return_type:n="Invalid function return type";break;case x.invalid_date:n="Invalid date";break;case x.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}"`:fe.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case x.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 x.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 x.custom:n="Invalid input";break;case x.invalid_intersection_types:n="Intersection results could not be merged";break;case x.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case x.not_finite:n="Number must be finite";break;default:n=e.defaultError,fe.assertNever(t)}return{message:n}},Os=dPe;var A7=Os;function pPe(t){A7=t}function Jl(){return A7}var Zf=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="",u=r.filter(l=>!!l).slice().reverse();for(let l of u)a=l(i,{data:e,defaultError:a}).message;return{...o,path:s,message:a}},fPe=[];function k(t,e){let n=Jl(),r=Zf({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===Os?void 0:Os].filter(o=>!!o)});t.common.issues.push(r)}var Jt=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 J;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 J;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}}},J=Object.freeze({status:"aborted"}),nu=t=>({status:"dirty",value:t}),dn=t=>({status:"valid",value:t}),n0=t=>t.status==="aborted",r0=t=>t.status==="dirty",$i=t=>t.status==="valid",Xl=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 Lr=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}},y7=(t,e)=>{if($i(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 Hn(t.common.issues);return this._error=n,this._error}}};function ae(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:u}=t;return i.code==="invalid_enum_value"?{message:u??a.defaultError}:typeof a.data>"u"?{message:u??r??a.defaultError}:i.code!=="invalid_type"?{message:a.defaultError}:{message:u??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 Jt,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(Xl(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 y7(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 $i(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=>$i(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(Xl(o)?o:Promise.resolve(o));return y7(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:x.custom,...r(o)});return typeof Promise<"u"&&i instanceof Promise?i.then(u=>u?!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 wr({schema:this,typeName:ee.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 kr.create(this,this._def)}nullable(){return Ho.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return xs.create(this)}promise(){return Wi.create(this,this._def)}or(e){return cu.create([this,e],this._def)}and(e){return lu.create(this,e,this._def)}transform(e){return new wr({...ae(this._def),schema:this,typeName:ee.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let n=typeof e=="function"?e:()=>e;return new _u({...ae(this._def),innerType:this,defaultValue:n,typeName:ee.ZodDefault})}brand(){return new em({typeName:ee.ZodBranded,type:this,...ae(this._def)})}catch(e){let n=typeof e=="function"?e:()=>e;return new hu({...ae(this._def),innerType:this,catchValue:n,typeName:ee.ZodCatch})}describe(e){let n=this.constructor;return new n({...this._def,description:e})}pipe(e){return tm.create(this,e)}readonly(){return gu.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},mPe=/^c[^\s-]{8,}$/i,_Pe=/^[0-9a-z]+$/,hPe=/^[0-9A-HJKMNP-TV-Z]{26}$/i,gPe=/^[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,TPe=/^[a-z0-9_-]{21}$/i,EPe=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,SPe=/^[-+]?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)?)??$/,APe=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,yPe="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",tx,bPe=/^(?:(?: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])$/,RPe=/^(?:(?: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])$/,IPe=/^(([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]))$/,OPe=/^(([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])$/,CPe=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,NPe=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,R7="((\\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])))",xPe=new RegExp(`^${R7}$`);function I7(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 PPe(t){return new RegExp(`^${I7(t)}$`)}function O7(t){let e=`${R7}T${I7(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 MPe(t,e){return!!((e==="v4"||!e)&&bPe.test(t)||(e==="v6"||!e)&&IPe.test(t))}function vPe(t,e){if(!EPe.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 kPe(t,e){return!!((e==="v4"||!e)&&RPe.test(t)||(e==="v6"||!e)&&OPe.test(t))}var zi=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 k(s,{code:x.invalid_type,expected:D.string,received:s.parsedType}),J}let r=new Jt,o;for(let s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(o=this._getOrReturnCtx(e,o),k(o,{code:x.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),k(o,{code:x.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?k(o,{code:x.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):a&&k(o,{code:x.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),r.dirty())}else if(s.kind==="email")APe.test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"email",code:x.invalid_string,message:s.message}),r.dirty());else if(s.kind==="emoji")tx||(tx=new RegExp(yPe,"u")),tx.test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"emoji",code:x.invalid_string,message:s.message}),r.dirty());else if(s.kind==="uuid")gPe.test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"uuid",code:x.invalid_string,message:s.message}),r.dirty());else if(s.kind==="nanoid")TPe.test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"nanoid",code:x.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid")mPe.test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"cuid",code:x.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid2")_Pe.test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"cuid2",code:x.invalid_string,message:s.message}),r.dirty());else if(s.kind==="ulid")hPe.test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"ulid",code:x.invalid_string,message:s.message}),r.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{o=this._getOrReturnCtx(e,o),k(o,{validation:"url",code:x.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),k(o,{validation:"regex",code:x.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),k(o,{code:x.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),k(o,{code:x.invalid_string,validation:{startsWith:s.value},message:s.message}),r.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(o=this._getOrReturnCtx(e,o),k(o,{code:x.invalid_string,validation:{endsWith:s.value},message:s.message}),r.dirty()):s.kind==="datetime"?O7(s).test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{code:x.invalid_string,validation:"datetime",message:s.message}),r.dirty()):s.kind==="date"?xPe.test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{code:x.invalid_string,validation:"date",message:s.message}),r.dirty()):s.kind==="time"?PPe(s).test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{code:x.invalid_string,validation:"time",message:s.message}),r.dirty()):s.kind==="duration"?SPe.test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"duration",code:x.invalid_string,message:s.message}),r.dirty()):s.kind==="ip"?MPe(e.data,s.version)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"ip",code:x.invalid_string,message:s.message}),r.dirty()):s.kind==="jwt"?vPe(e.data,s.alg)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"jwt",code:x.invalid_string,message:s.message}),r.dirty()):s.kind==="cidr"?kPe(e.data,s.version)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"cidr",code:x.invalid_string,message:s.message}),r.dirty()):s.kind==="base64"?CPe.test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"base64",code:x.invalid_string,message:s.message}),r.dirty()):s.kind==="base64url"?NPe.test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"base64url",code:x.invalid_string,message:s.message}),r.dirty()):fe.assertNever(s);return{status:r.value,value:e.data}}_regex(e,n,r){return this.refinement(o=>e.test(o),{validation:n,code:x.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}};zi.create=t=>new zi({checks:[],typeName:ee.ZodString,coerce:t?.coerce??!1,...ae(t)});function LPe(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 ru=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 k(s,{code:x.invalid_type,expected:D.number,received:s.parsedType}),J}let r,o=new Jt;for(let s of this._def.checks)s.kind==="int"?fe.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),k(r,{code:x.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),k(r,{code:x.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),k(r,{code:x.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),o.dirty()):s.kind==="multipleOf"?LPe(e.data,s.value)!==0&&(r=this._getOrReturnCtx(e,r),k(r,{code:x.not_multiple_of,multipleOf:s.value,message:s.message}),o.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),k(r,{code:x.not_finite,message:s.message}),o.dirty()):fe.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"&&fe.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)}};ru.create=t=>new ru({checks:[],typeName:ee.ZodNumber,coerce:t?.coerce||!1,...ae(t)});var ou=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 Jt;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),k(r,{code:x.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),k(r,{code:x.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),k(r,{code:x.not_multiple_of,multipleOf:s.value,message:s.message}),o.dirty()):fe.assertNever(s);return{status:o.value,value:e.data}}_getInvalidInput(e){let n=this._getOrReturnCtx(e);return k(n,{code:x.invalid_type,expected:D.bigint,received:n.parsedType}),J}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}};ou.create=t=>new ou({checks:[],typeName:ee.ZodBigInt,coerce:t?.coerce??!1,...ae(t)});var su=class extends ce{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==D.boolean){let r=this._getOrReturnCtx(e);return k(r,{code:x.invalid_type,expected:D.boolean,received:r.parsedType}),J}return dn(e.data)}};su.create=t=>new su({typeName:ee.ZodBoolean,coerce:t?.coerce||!1,...ae(t)});var iu=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 k(s,{code:x.invalid_type,expected:D.date,received:s.parsedType}),J}if(Number.isNaN(e.data.getTime())){let s=this._getOrReturnCtx(e);return k(s,{code:x.invalid_date}),J}let r=new Jt,o;for(let s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(o=this._getOrReturnCtx(e,o),k(o,{code:x.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),k(o,{code:x.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),r.dirty()):fe.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}};iu.create=t=>new iu({checks:[],coerce:t?.coerce||!1,typeName:ee.ZodDate,...ae(t)});var ed=class extends ce{_parse(e){if(this._getType(e)!==D.symbol){let r=this._getOrReturnCtx(e);return k(r,{code:x.invalid_type,expected:D.symbol,received:r.parsedType}),J}return dn(e.data)}};ed.create=t=>new ed({typeName:ee.ZodSymbol,...ae(t)});var au=class extends ce{_parse(e){if(this._getType(e)!==D.undefined){let r=this._getOrReturnCtx(e);return k(r,{code:x.invalid_type,expected:D.undefined,received:r.parsedType}),J}return dn(e.data)}};au.create=t=>new au({typeName:ee.ZodUndefined,...ae(t)});var uu=class extends ce{_parse(e){if(this._getType(e)!==D.null){let r=this._getOrReturnCtx(e);return k(r,{code:x.invalid_type,expected:D.null,received:r.parsedType}),J}return dn(e.data)}};uu.create=t=>new uu({typeName:ee.ZodNull,...ae(t)});var Yi=class extends ce{constructor(){super(...arguments),this._any=!0}_parse(e){return dn(e.data)}};Yi.create=t=>new Yi({typeName:ee.ZodAny,...ae(t)});var Ns=class extends ce{constructor(){super(...arguments),this._unknown=!0}_parse(e){return dn(e.data)}};Ns.create=t=>new Ns({typeName:ee.ZodUnknown,...ae(t)});var ro=class extends ce{_parse(e){let n=this._getOrReturnCtx(e);return k(n,{code:x.invalid_type,expected:D.never,received:n.parsedType}),J}};ro.create=t=>new ro({typeName:ee.ZodNever,...ae(t)});var td=class extends ce{_parse(e){if(this._getType(e)!==D.undefined){let r=this._getOrReturnCtx(e);return k(r,{code:x.invalid_type,expected:D.void,received:r.parsedType}),J}return dn(e.data)}};td.create=t=>new td({typeName:ee.ZodVoid,...ae(t)});var xs=class t extends ce{_parse(e){let{ctx:n,status:r}=this._processInputParams(e),o=this._def;if(n.parsedType!==D.array)return k(n,{code:x.invalid_type,expected:D.array,received:n.parsedType}),J;if(o.exactLength!==null){let i=n.data.length>o.exactLength.value,a=n.data.length<o.exactLength.value;(i||a)&&(k(n,{code:i?x.too_big:x.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&&(k(n,{code:x.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&&(k(n,{code:x.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 Lr(n,i,n.path,a)))).then(i=>Jt.mergeArray(r,i));let s=[...n.data].map((i,a)=>o.type._parseSync(new Lr(n,i,n.path,a)));return Jt.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)}};xs.create=(t,e)=>new xs({type:t,minLength:null,maxLength:null,exactLength:null,typeName:ee.ZodArray,...ae(e)});function Zl(t){if(t instanceof Vn){let e={};for(let n in t.shape){let r=t.shape[n];e[n]=kr.create(Zl(r))}return new Vn({...t._def,shape:()=>e})}else return t instanceof xs?new xs({...t._def,type:Zl(t.element)}):t instanceof kr?kr.create(Zl(t.unwrap())):t instanceof Ho?Ho.create(Zl(t.unwrap())):t instanceof jo?jo.create(t.items.map(e=>Zl(e))):t}var Vn=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=fe.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 k(l,{code:x.invalid_type,expected:D.object,received:l.parsedType}),J}let{status:r,ctx:o}=this._processInputParams(e),{shape:s,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof ro&&this._def.unknownKeys==="strip"))for(let l in o.data)i.includes(l)||a.push(l);let u=[];for(let l of i){let d=s[l],p=o.data[l];u.push({key:{status:"valid",value:l},value:d._parse(new Lr(o,p,o.path,l)),alwaysSet:l in o.data})}if(this._def.catchall instanceof ro){let l=this._def.unknownKeys;if(l==="passthrough")for(let d of a)u.push({key:{status:"valid",value:d},value:{status:"valid",value:o.data[d]}});else if(l==="strict")a.length>0&&(k(o,{code:x.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 d of a){let p=o.data[d];u.push({key:{status:"valid",value:d},value:l._parse(new Lr(o,p,o.path,d)),alwaysSet:d in o.data})}}return o.common.async?Promise.resolve().then(async()=>{let l=[];for(let d of u){let p=await d.key,f=await d.value;l.push({key:p,value:f,alwaysSet:d.alwaysSet})}return l}).then(l=>Jt.mergeObjectSync(r,l)):Jt.mergeObjectSync(r,u)}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:ee.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 fe.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 fe.objectKeys(this.shape))e[r]||(n[r]=this.shape[r]);return new t({...this._def,shape:()=>n})}deepPartial(){return Zl(this)}partial(e){let n={};for(let r of fe.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 fe.objectKeys(this.shape))if(e&&!e[r])n[r]=this.shape[r];else{let s=this.shape[r];for(;s instanceof kr;)s=s._def.innerType;n[r]=s}return new t({...this._def,shape:()=>n})}keyof(){return C7(fe.objectKeys(this.shape))}};Vn.create=(t,e)=>new Vn({shape:()=>t,unknownKeys:"strip",catchall:ro.create(),typeName:ee.ZodObject,...ae(e)});Vn.strictCreate=(t,e)=>new Vn({shape:()=>t,unknownKeys:"strict",catchall:ro.create(),typeName:ee.ZodObject,...ae(e)});Vn.lazycreate=(t,e)=>new Vn({shape:t,unknownKeys:"strip",catchall:ro.create(),typeName:ee.ZodObject,...ae(e)});var cu=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 Hn(a.ctx.common.issues));return k(n,{code:x.invalid_union,unionErrors:i}),J}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 u of r){let l={...n,common:{...n.common,issues:[]},parent:null},d=u._parseSync({data:n.data,path:n.path,parent:l});if(d.status==="valid")return d;d.status==="dirty"&&!s&&(s={result:d,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(u=>new Hn(u));return k(n,{code:x.invalid_union,unionErrors:a}),J}}get options(){return this._def.options}};cu.create=(t,e)=>new cu({options:t,typeName:ee.ZodUnion,...ae(e)});var Cs=t=>t instanceof du?Cs(t.schema):t instanceof wr?Cs(t.innerType()):t instanceof pu?[t.value]:t instanceof fu?t.options:t instanceof mu?fe.objectValues(t.enum):t instanceof _u?Cs(t._def.innerType):t instanceof au?[void 0]:t instanceof uu?[null]:t instanceof kr?[void 0,...Cs(t.unwrap())]:t instanceof Ho?[null,...Cs(t.unwrap())]:t instanceof em||t instanceof gu?Cs(t.unwrap()):t instanceof hu?Cs(t._def.innerType):[],o0=class t extends ce{_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==D.object)return k(n,{code:x.invalid_type,expected:D.object,received:n.parsedType}),J;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}):(k(n,{code:x.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),J)}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=Cs(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:ee.ZodDiscriminatedUnion,discriminator:e,options:n,optionsMap:o,...ae(r)})}};function nx(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=fe.objectKeys(e),s=fe.objectKeys(t).filter(a=>o.indexOf(a)!==-1),i={...t,...e};for(let a of s){let u=nx(t[a],e[a]);if(!u.valid)return{valid:!1};i[a]=u.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],u=nx(i,a);if(!u.valid)return{valid:!1};o.push(u.data)}return{valid:!0,data:o}}else return n===D.date&&r===D.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}var lu=class extends ce{_parse(e){let{status:n,ctx:r}=this._processInputParams(e),o=(s,i)=>{if(n0(s)||n0(i))return J;let a=nx(s.value,i.value);return a.valid?((r0(s)||r0(i))&&n.dirty(),{status:n.value,value:a.data}):(k(r,{code:x.invalid_intersection_types}),J)};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}))}};lu.create=(t,e,n)=>new lu({left:t,right:e,typeName:ee.ZodIntersection,...ae(n)});var jo=class t extends ce{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==D.array)return k(r,{code:x.invalid_type,expected:D.array,received:r.parsedType}),J;if(r.data.length<this._def.items.length)return k(r,{code:x.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),J;!this._def.rest&&r.data.length>this._def.items.length&&(k(r,{code:x.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());let s=[...r.data].map((i,a)=>{let u=this._def.items[a]||this._def.rest;return u?u._parse(new Lr(r,i,r.path,a)):null}).filter(i=>!!i);return r.common.async?Promise.all(s).then(i=>Jt.mergeArray(n,i)):Jt.mergeArray(n,s)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};jo.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new jo({items:t,typeName:ee.ZodTuple,rest:null,...ae(e)})};var s0=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 k(r,{code:x.invalid_type,expected:D.object,received:r.parsedType}),J;let o=[],s=this._def.keyType,i=this._def.valueType;for(let a in r.data)o.push({key:s._parse(new Lr(r,a,r.path,a)),value:i._parse(new Lr(r,r.data[a],r.path,a)),alwaysSet:a in r.data});return r.common.async?Jt.mergeObjectAsync(n,o):Jt.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:ee.ZodRecord,...ae(r)}):new t({keyType:zi.create(),valueType:e,typeName:ee.ZodRecord,...ae(n)})}},nd=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 k(r,{code:x.invalid_type,expected:D.map,received:r.parsedType}),J;let o=this._def.keyType,s=this._def.valueType,i=[...r.data.entries()].map(([a,u],l)=>({key:o._parse(new Lr(r,a,r.path,[l,"key"])),value:s._parse(new Lr(r,u,r.path,[l,"value"]))}));if(r.common.async){let a=new Map;return Promise.resolve().then(async()=>{for(let u of i){let l=await u.key,d=await u.value;if(l.status==="aborted"||d.status==="aborted")return J;(l.status==="dirty"||d.status==="dirty")&&n.dirty(),a.set(l.value,d.value)}return{status:n.value,value:a}})}else{let a=new Map;for(let u of i){let l=u.key,d=u.value;if(l.status==="aborted"||d.status==="aborted")return J;(l.status==="dirty"||d.status==="dirty")&&n.dirty(),a.set(l.value,d.value)}return{status:n.value,value:a}}}};nd.create=(t,e,n)=>new nd({valueType:e,keyType:t,typeName:ee.ZodMap,...ae(n)});var rd=class t extends ce{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==D.set)return k(r,{code:x.invalid_type,expected:D.set,received:r.parsedType}),J;let o=this._def;o.minSize!==null&&r.data.size<o.minSize.value&&(k(r,{code:x.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&&(k(r,{code:x.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(u){let l=new Set;for(let d of u){if(d.status==="aborted")return J;d.status==="dirty"&&n.dirty(),l.add(d.value)}return{status:n.value,value:l}}let a=[...r.data.values()].map((u,l)=>s._parse(new Lr(r,u,r.path,l)));return r.common.async?Promise.all(a).then(u=>i(u)):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)}};rd.create=(t,e)=>new rd({valueType:t,minSize:null,maxSize:null,typeName:ee.ZodSet,...ae(e)});var i0=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 k(n,{code:x.invalid_type,expected:D.function,received:n.parsedType}),J;function r(a,u){return Zf({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Jl(),Os].filter(l=>!!l),issueData:{code:x.invalid_arguments,argumentsError:u}})}function o(a,u){return Zf({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Jl(),Os].filter(l=>!!l),issueData:{code:x.invalid_return_type,returnTypeError:u}})}let s={errorMap:n.common.contextualErrorMap},i=n.data;if(this._def.returns instanceof Wi){let a=this;return dn(async function(...u){let l=new Hn([]),d=await a._def.args.parseAsync(u,s).catch(m=>{throw l.addIssue(r(u,m)),l}),p=await Reflect.apply(i,this,d);return await a._def.returns._def.type.parseAsync(p,s).catch(m=>{throw l.addIssue(o(p,m)),l})})}else{let a=this;return dn(function(...u){let l=a._def.args.safeParse(u,s);if(!l.success)throw new Hn([r(u,l.error)]);let d=Reflect.apply(i,this,l.data),p=a._def.returns.safeParse(d,s);if(!p.success)throw new Hn([o(d,p.error)]);return p.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:jo.create(e).rest(Ns.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||jo.create([]).rest(Ns.create()),returns:n||Ns.create(),typeName:ee.ZodFunction,...ae(r)})}},du=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})}};du.create=(t,e)=>new du({getter:t,typeName:ee.ZodLazy,...ae(e)});var pu=class extends ce{_parse(e){if(e.data!==this._def.value){let n=this._getOrReturnCtx(e);return k(n,{received:n.data,code:x.invalid_literal,expected:this._def.value}),J}return{status:"valid",value:e.data}}get value(){return this._def.value}};pu.create=(t,e)=>new pu({value:t,typeName:ee.ZodLiteral,...ae(e)});function C7(t,e){return new fu({values:t,typeName:ee.ZodEnum,...ae(e)})}var fu=class t extends ce{_parse(e){if(typeof e.data!="string"){let n=this._getOrReturnCtx(e),r=this._def.values;return k(n,{expected:fe.joinValues(r),received:n.parsedType,code:x.invalid_type}),J}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 k(n,{received:n.data,code:x.invalid_enum_value,options:r}),J}return dn(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})}};fu.create=C7;var mu=class extends ce{_parse(e){let n=fe.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==D.string&&r.parsedType!==D.number){let o=fe.objectValues(n);return k(r,{expected:fe.joinValues(o),received:r.parsedType,code:x.invalid_type}),J}if(this._cache||(this._cache=new Set(fe.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let o=fe.objectValues(n);return k(r,{received:r.data,code:x.invalid_enum_value,options:o}),J}return dn(e.data)}get enum(){return this._def.values}};mu.create=(t,e)=>new mu({values:t,typeName:ee.ZodNativeEnum,...ae(e)});var Wi=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 k(n,{code:x.invalid_type,expected:D.promise,received:n.parsedType}),J;let r=n.parsedType===D.promise?n.data:Promise.resolve(n.data);return dn(r.then(o=>this._def.type.parseAsync(o,{path:n.path,errorMap:n.common.contextualErrorMap})))}};Wi.create=(t,e)=>new Wi({type:t,typeName:ee.ZodPromise,...ae(e)});var wr=class extends ce{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===ee.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=>{k(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 J;let u=await this._def.schema._parseAsync({data:a,path:r.path,parent:r});return u.status==="aborted"?J:u.status==="dirty"?nu(u.value):n.value==="dirty"?nu(u.value):u});{if(n.value==="aborted")return J;let a=this._def.schema._parseSync({data:i,path:r.path,parent:r});return a.status==="aborted"?J:a.status==="dirty"?nu(a.value):n.value==="dirty"?nu(a.value):a}}if(o.type==="refinement"){let i=a=>{let u=o.refinement(a,s);if(r.common.async)return Promise.resolve(u);if(u 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"?J:(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"?J:(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(!$i(i))return J;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=>$i(i)?Promise.resolve(o.transform(i.value,s)).then(a=>({status:n.value,value:a})):J);fe.assertNever(o)}};wr.create=(t,e,n)=>new wr({schema:t,typeName:ee.ZodEffects,effect:e,...ae(n)});wr.createWithPreprocess=(t,e,n)=>new wr({schema:e,effect:{type:"preprocess",transform:t},typeName:ee.ZodEffects,...ae(n)});var kr=class extends ce{_parse(e){return this._getType(e)===D.undefined?dn(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};kr.create=(t,e)=>new kr({innerType:t,typeName:ee.ZodOptional,...ae(e)});var Ho=class extends ce{_parse(e){return this._getType(e)===D.null?dn(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Ho.create=(t,e)=>new Ho({innerType:t,typeName:ee.ZodNullable,...ae(e)});var _u=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}};_u.create=(t,e)=>new _u({innerType:t,typeName:ee.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...ae(e)});var hu=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 Xl(o)?o.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Hn(r.common.issues)},input:r.data})})):{status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new Hn(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}};hu.create=(t,e)=>new hu({innerType:t,typeName:ee.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...ae(e)});var od=class extends ce{_parse(e){if(this._getType(e)!==D.nan){let r=this._getOrReturnCtx(e);return k(r,{code:x.invalid_type,expected:D.nan,received:r.parsedType}),J}return{status:"valid",value:e.data}}};od.create=t=>new od({typeName:ee.ZodNaN,...ae(t)});var wPe=Symbol("zod_brand"),em=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}},tm=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"?J:s.status==="dirty"?(n.dirty(),nu(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"?J: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:ee.ZodPipeline})}},gu=class extends ce{_parse(e){let n=this._def.innerType._parse(e),r=o=>($i(o)&&(o.value=Object.freeze(o.value)),o);return Xl(n)?n.then(o=>r(o)):r(n)}unwrap(){return this._def.innerType}};gu.create=(t,e)=>new gu({innerType:t,typeName:ee.ZodReadonly,...ae(e)});function b7(t,e){let n=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof n=="string"?{message:n}:n}function N7(t,e={},n){return t?Yi.create().superRefine((r,o)=>{let s=t(r);if(s instanceof Promise)return s.then(i=>{if(!i){let a=b7(e,r),u=a.fatal??n??!0;o.addIssue({code:"custom",...a,fatal:u})}});if(!s){let i=b7(e,r),a=i.fatal??n??!0;o.addIssue({code:"custom",...i,fatal:a})}}):Yi.create()}var DPe={object:Vn.lazycreate},ee;(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"})(ee||(ee={}));var UPe=(t,e={message:`Input not instance of ${t.name}`})=>N7(n=>n instanceof t,e),x7=zi.create,P7=ru.create,BPe=od.create,FPe=ou.create,M7=su.create,GPe=iu.create,jPe=ed.create,HPe=au.create,VPe=uu.create,qPe=Yi.create,$Pe=Ns.create,zPe=ro.create,YPe=td.create,WPe=xs.create,KPe=Vn.create,QPe=Vn.strictCreate,JPe=cu.create,XPe=o0.create,ZPe=lu.create,e1e=jo.create,t1e=s0.create,n1e=nd.create,r1e=rd.create,o1e=i0.create,s1e=du.create,i1e=pu.create,a1e=fu.create,u1e=mu.create,c1e=Wi.create,l1e=wr.create,d1e=kr.create,p1e=Ho.create,f1e=wr.createWithPreprocess,m1e=tm.create,_1e=()=>x7().optional(),h1e=()=>P7().optional(),g1e=()=>M7().optional(),T1e={string:t=>zi.create({...t,coerce:!0}),number:t=>ru.create({...t,coerce:!0}),boolean:t=>su.create({...t,coerce:!0}),bigint:t=>ou.create({...t,coerce:!0}),date:t=>iu.create({...t,coerce:!0})};var E1e=J;var S1e=t=>typeof t?.safeParse=="function";var rx=t=>typeof t?.passthrough=="function";var A1e=(t,e)=>rx(t)?rx(e)?t.merge(e):t:rx(e)?e:Object.assign({},t,e);var est=c.object({name:c.literal("ZodError"),issues:c.array(c.object({path:c.array(c.union([c.string(),c.number()])),message:c.string().optional(),code:c.nativeEnum(c.ZodIssueCode)}).catchall(c.any()))}),y1e=Symbol("ContractNoBody"),k7=t=>"method"in t&&"path"in t;var L7=(t,e)=>Object.fromEntries(Object.entries(t).map(([n,r])=>{var o,s,i;return k7(r)?[n,{...r,path:e?.pathPrefix?e.pathPrefix+r.path:r.path,headers:A1e(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,L7(r,e)]})),ox=Symbol("ContractPlainType"),Dr=()=>({router:(t,e)=>L7(t,e),query:t=>t,mutation:t=>t,responses:t=>t,response:()=>ox,body:()=>ox,type:()=>ox,otherResponse:({contentType:t,body:e})=>({contentType:t,body:e}),noBody:()=>y1e}),b1e=({path:t,params:e})=>{let n=e;return t.replace(/\/?:([^/?]+)\??/g,(r,o)=>n[o]?`${r.startsWith("/")?"/":""}${n[o]}`:"")},R1e=(t,e=!1)=>{let n=e?I1e(t):O1e(t);return n?.length>0?"?"+n:""},I1e=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("&"):"",O1e=t=>t?Object.keys(t).flatMap(e=>sx(e,t[e])).map(([e,n])=>`${encodeURIComponent(e)}=${encodeURIComponent(n)}`).join("&"):"",sx=(t,e)=>Array.isArray(e)?e.flatMap((n,r)=>sx(`${t}[${r}]`,n)):e instanceof Date?[[`${t}`,e.toISOString()]]:e===null?[[`${t}`,""]]:e===void 0?[]:typeof e=="object"?Object.keys(e).flatMap(n=>sx(`${t}[${n}]`,e[n])):[[`${t}`,`${e}`]];var ix=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 C1e=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}),u=a.headers.get("content-type");if(u?.includes("application/")&&u?.includes("json")){let l={status:a.status,body:await a.json(),headers:a.headers},d=t.responses[l.status];return(s??t.validateResponseOnClient)&&S1e(d)?{...l,body:d.parse(l.body)}:l}return u?.includes("text/")?{status:a.status,body:await a.text(),headers:a.headers}:{status:a.status,body:await a.blob(),headers:a.headers}},N1e=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},v7=t=>Object.fromEntries(Object.entries(t).map(([e,n])=>[e.toLowerCase(),n])),x1e=t=>{let{path:e,clientArgs:n,route:r,body:o,query:s,extraInputArgs:i,headers:a,fetchOptions:u}=t,l=n.api||C1e,d=n.baseHeaders&&Object.fromEntries(Object.entries(n.baseHeaders).map(([m,_])=>typeof _=="function"?[m,_(t)]:[m,_])),p={...d&&v7(d),...v7(a)};Object.keys(p).forEach(m=>{p[m]===void 0&&delete p[m]});let f={route:r,path:e,method:r.method,headers:p,body:void 0,rawBody:o,rawQuery:s,contentType:void 0,validateResponse:n.validateResponse,fetchOptions:{...n.credentials&&{credentials:n.credentials},...u},...u?.signal&&{signal:u.signal},...u?.cache&&{cache:u.cache},...u&&"next"in u&&!!u?.next&&{next:u.next}};return r.method!=="GET"&&("contentType"in r&&r.contentType==="multipart/form-data"?f={...f,contentType:"multipart/form-data",body:o instanceof FormData?o:N1e(o)}:"contentType"in r&&r.contentType==="application/x-www-form-urlencoded"?f={...f,contentType:"application/x-www-form-urlencoded",headers:{"content-type":"application/x-www-form-urlencoded",...f.headers},body:typeof o=="string"?o:new URLSearchParams(o)}:o!=null&&(f={...f,contentType:"application/json",headers:{"content-type":"application/json",...f.headers},body:JSON.stringify(o)})),l({...f,...i})},P1e=(t,e,n)=>{let{query:r,params:o,body:s,headers:i,extraHeaders:a,overrideClientOptions:u,fetchOptions:l,cache:d,next:p,...f}=n||{},m={...e,...u};return{path:M1e(r,m.baseUrl,o,t,!!m.jsonQuery),clientArgs:m,route:t,body:s,query:r,extraInputArgs:f,fetchOptions:{...d&&{cache:d},...p&&{next:p},...l},headers:{...a,...i}}},M1e=(t,e,n,r,o)=>{let s=b1e({path:r.path,params:n}),i=R1e(t,o);return`${e}${s}${i}`},v1e=(t,e)=>{let n=Object.keys(t.responses);return async r=>{let o=P1e(t,e,r),s=await x1e(o);if(!e.throwOnUnknownStatus||n.includes(s.status.toString()))return s;throw new ix(s,n)}},ax=(t,e)=>Object.fromEntries(Object.entries(t).map(([n,r])=>k7(r)?[n,v1e(r,e)]:[n,ax(r,e)]));var ux=["free","creator","team"],w7=typeof process<"u"&&process.env?.NODE_ENV!=="production",k1e={stripe:{plans:[{tier:"free",subjectType:"user",name:"Free",description:"Share any thread from Claude Code, Codex, or Cowork. Share with friends or keep private. Share skills with your team instantly.",price:0,priceId:null,features:[{name:"Share threads from Claude Code, Codex, and Cowork"},{name:"Share with friends or keep private"},{name:"Share skills with your team instantly"}],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:w7?"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:w7?"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 D7=k1e.stripe.plans,nst=Object.freeze(Object.fromEntries(D7.map(t=>[t.tier,t])));var L1e=Dr(),pn=c.object({message:c.string()}),cx=c.record(c.unknown()),Tu=c.string().regex(/^doc_[0-9A-Za-z]{22}$/),a0=c.string().regex(/^proj_[0-9A-Za-z]{22}$/),w1e=["active","archived"],u0=c.enum(w1e),U7=c.object({id:c.string().min(1),display_name:c.string().min(1)}),B7=c.object({id:a0,name:c.string().min(1)}),lx=c.object({id:Tu,title:c.string().min(1),status:u0,author:U7,project:B7.nullable(),created_at:c.string().datetime(),updated_at:c.string().datetime(),archived_at:c.string().datetime().nullable()}),D1e=c.object({type:c.literal("list"),list_type:c.literal("doc"),objects:c.array(lx)}),U1e=c.object({project_id:a0.optional(),status:u0.optional()}),B1e=c.object({title:c.string().trim().min(1).max(300).optional(),prosemirror_json:cx.optional(),project_id:a0.nullable().optional()}),F1e=c.object({id:Tu,created_at:c.string().datetime()}),G1e=c.object({title:c.string().trim().min(1).max(300).optional(),prosemirror_json:cx.optional(),project_id:a0.nullable().optional(),status:u0.optional()}).refine(t=>Object.keys(t).length>0,{message:"At least one field must be provided"}),j1e=c.object({id:Tu,updated_at:c.string().datetime()}),H1e=c.object({id:Tu,title:c.string().min(1),prosemirror_json:cx,status:u0,author:U7,project:B7.nullable(),created_at:c.string().datetime(),updated_at:c.string().datetime(),archived_at:c.string().datetime().nullable()}),F7=L1e.router({listDocs:{method:"GET",path:"/docs",headers:c.object({authorization:c.string().min(1).optional()}),query:U1e,responses:{200:D1e,401:pn,403:pn},summary:"List docs in the authenticated user\u2019s organization. Optional project_id filter scopes to a single project."},createDoc:{method:"POST",path:"/docs",headers:c.object({authorization:c.string().min(1).optional()}),body:B1e,responses:{201:F1e,401:pn,403:pn,404:pn,422:pn},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:c.object({docId:Tu}),headers:c.object({authorization:c.string().min(1).optional()}),responses:{200:H1e,401:pn,403:pn,404:pn},summary:"Get a doc by id with its rich-text body and parent project (if any)"},updateDoc:{method:"PATCH",path:"/docs/:docId",pathParams:c.object({docId:Tu}),headers:c.object({authorization:c.string().min(1).optional()}),body:G1e,responses:{200:j1e,401:pn,403:pn,404:pn,422:pn},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:c.object({docId:Tu}),headers:c.object({authorization:c.string().min(1).optional()}),body:c.object({}).optional(),responses:{204:c.object({}),401:pn,403:pn,404:pn},summary:"Hard-delete a doc and any mention references it owns"}});var V1e=Dr(),it=c.object({message:c.string()}),dx=c.record(c.unknown()),Vo=c.string().regex(/^proj_[0-9A-Za-z]{22}$/),q1e=["active","archived"],c0=c.enum(q1e),px=c.object({id:c.string().min(1),display_name:c.string().min(1)}),G7=c.object({thread_id:c.string().min(1),title:c.string().min(1),added_at:c.string().datetime(),added_by:px}),$1e=c.object({id:Vo,name:c.string().min(1),status:c0,author:px,thread_count:c.number().int().nonnegative(),doc_count:c.number().int().nonnegative(),created_at:c.string().datetime(),updated_at:c.string().datetime(),archived_at:c.string().datetime().nullable()}),z1e=c.object({type:c.literal("list"),list_type:c.literal("project"),objects:c.array($1e)}),Y1e=c.object({status:c0.optional()}),W1e=c.object({name:c.string().trim().min(1).max(200),prosemirror_json:dx.optional()}),K1e=c.object({id:Vo,created_at:c.string().datetime()}),Q1e=c.object({name:c.string().trim().min(1).max(200).optional(),prosemirror_json:dx.optional()}).refine(t=>Object.keys(t).length>0,{message:"At least one field must be provided"}),J1e=c.object({id:Vo,updated_at:c.string().datetime()}),X1e=c.object({archived:c.boolean()}),Z1e=c.object({id:Vo,status:c0,archived_at:c.string().datetime().nullable()}),eMe=c.object({id:Vo,name:c.string().min(1),prosemirror_json:dx,status:c0,author:px,created_at:c.string().datetime(),updated_at:c.string().datetime(),archived_at:c.string().datetime().nullable(),threads:c.array(G7),docs:c.array(lx)}),tMe=c.object({thread_id:c.string().min(1).max(64)}),nMe=G7,j7=V1e.router({listProjects:{method:"GET",path:"/projects",headers:c.object({authorization:c.string().min(1).optional()}),query:Y1e,responses:{200:z1e,401:it},summary:"List projects in the authenticated user\u2019s organization"},createProject:{method:"POST",path:"/projects",headers:c.object({authorization:c.string().min(1).optional()}),body:W1e,responses:{201:K1e,401:it,422:it},summary:"Create a new project in the authenticated user\u2019s organization"},getProject:{method:"GET",path:"/projects/:projectId",pathParams:c.object({projectId:Vo}),headers:c.object({authorization:c.string().min(1).optional()}),responses:{200:eMe,401:it,403:it,404:it},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:c.object({projectId:Vo}),headers:c.object({authorization:c.string().min(1).optional()}),body:Q1e,responses:{200:J1e,401:it,403:it,404:it,422:it},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:c.object({projectId:Vo}),headers:c.object({authorization:c.string().min(1).optional()}),body:X1e,responses:{200:Z1e,401:it,403:it,404:it},summary:"Archive (soft-delete) or unarchive a project"},addProjectThread:{method:"POST",path:"/projects/:projectId/threads",pathParams:c.object({projectId:Vo}),headers:c.object({authorization:c.string().min(1).optional()}),body:tMe,responses:{201:nMe,401:it,403:it,404:it,409:it,422:it},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:c.object({projectId:Vo,threadId:c.string().min(1).max(64)}),headers:c.object({authorization:c.string().min(1).optional()}),body:c.object({}).optional(),responses:{204:c.object({}),401:it,403:it,404:it},summary:"Remove a thread membership from a project"}});var rMe=Dr(),l0=c.object({message:c.string()}),oMe=["thread","plan","doc","user"],d0=c.enum(oMe),sMe=["doc","project"],iMe=c.enum(sMe),aMe=c.object({kind:d0,id:c.string().min(1),title:c.string().min(1),href:c.string().min(1)}),uMe=c.object({type:c.literal("list"),list_type:c.literal("mention"),objects:c.array(aMe)}),cMe=c.object({q:c.string().trim().min(1).max(50),kinds:c.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(c.array(d0).optional())}),lMe=c.object({source_kind:iMe,source_id:c.string().min(1),source_title:c.string().min(1),source_href:c.string().min(1),target_kind:d0,target_id:c.string().min(1),created_at:c.string().datetime()}),dMe=c.object({type:c.literal("list"),list_type:c.literal("backlink"),objects:c.array(lMe)}),pMe=c.object({target_kind:d0,target_id:c.string().min(1).max(64)}),H7=rMe.router({searchMentions:{method:"GET",path:"/mentions/search",headers:c.object({authorization:c.string().min(1).optional()}),query:cMe,responses:{200:uMe,401:l0,422:l0},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:c.object({authorization:c.string().min(1).optional()}),query:pMe,responses:{200:dMe,401:l0,403:l0},summary:"List every doc/project body in the caller\u2019s organization that mentions the given target. Newest-first."}});var fMe=Dr(),mMe=c.object({type:c.literal("list"),list_type:c.literal("thread"),has_more:c.boolean(),objects:c.array(c.unknown())}),Ut=c.object({message:c.string()}),V7=c.object({thread_id:c.string().min(1),is_favorited:c.boolean(),favorited_at:c.string().datetime().nullable()}),_Me=c.object({before:c.string().min(1).max(64).optional()}),hMe=c.object({id:c.string().min(1),display_name:c.string().min(1)}),gMe=c.object({block_id:c.string().min(1),thread_id:c.string().min(1),thread_title:c.string(),thread_visibility:c.enum(["private","workspace","public"]),author:hMe,preview:c.string(),prompted_at:c.string().datetime().nullable(),favorited_at:c.string().datetime()}),TMe=c.object({type:c.literal("list"),list_type:c.literal("favorite_prompt"),has_more:c.boolean(),objects:c.array(gMe)}),q7=c.object({block_id:c.string().min(1),thread_id:c.string().min(1).nullable(),is_favorited:c.boolean(),favorited_at:c.string().datetime().nullable()}),EMe=c.object({before:c.string().min(1).max(64).optional()}),SMe=c.object({block_ids:c.array(c.string().min(1))}),$7=fMe.router({addThreadFavorite:{method:"POST",path:"/threads/:id/favorite",pathParams:c.object({id:c.string().min(1).max(64)}),headers:c.object({authorization:c.string().min(1).optional()}),body:c.object({}).optional(),responses:{201:V7,401:Ut,403:Ut,404:Ut},summary:"Bookmark a thread for the authenticated user. Idempotent \u2014 re-favoriting returns the existing membership."},removeThreadFavorite:{method:"DELETE",path:"/threads/:id/favorite",pathParams:c.object({id:c.string().min(1).max(64)}),headers:c.object({authorization:c.string().min(1).optional()}),body:c.object({}).optional(),responses:{200:V7,401:Ut,403:Ut,404:Ut},summary:"Remove a thread bookmark for the authenticated user (no-op if absent)."},listFavoriteThreads:{method:"GET",path:"/favorites/threads",headers:c.object({authorization:c.string().min(1).optional()}),query:_Me,responses:{200:mMe,401:Ut,403:Ut},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."},addPromptFavorite:{method:"POST",path:"/thread-blocks/:id/favorite",pathParams:c.object({id:c.string().min(1).max(64)}),headers:c.object({authorization:c.string().min(1).optional()}),body:c.object({}).optional(),responses:{201:q7,401:Ut,403:Ut,404:Ut,409:Ut},summary:'Bookmark a single user prompt (a thread_blocks row with type="user") for the authenticated user. Idempotent.'},removePromptFavorite:{method:"DELETE",path:"/thread-blocks/:id/favorite",pathParams:c.object({id:c.string().min(1).max(64)}),headers:c.object({authorization:c.string().min(1).optional()}),body:c.object({}).optional(),responses:{200:q7,401:Ut,404:Ut},summary:"Remove a prompt bookmark for the authenticated user (no-op if absent)."},listFavoritePrompts:{method:"GET",path:"/favorites/prompts",headers:c.object({authorization:c.string().min(1).optional()}),query:EMe,responses:{200:TMe,401:Ut},summary:"List the user's favorited prompts, newest first. Prompts whose parent thread the viewer can no longer see (visibility downgraded) are filtered out at read time."},listFavoritedBlockIdsInThread:{method:"GET",path:"/threads/:id/favorited-blocks",pathParams:c.object({id:c.string().min(1).max(64)}),headers:c.object({authorization:c.string().min(1).optional()}),responses:{200:SMe,401:Ut,403:Ut,404:Ut},summary:"Returns the set of thread_block ids the authenticated viewer has favorited within a single thread, used to bootstrap per-prompt star state on the SessionView."}});var AMe=Dr(),z7=c.object({message:c.string()}),yMe=c.object({id:c.string().min(1),title:c.string(),href:c.string().min(1),author_display_name:c.string().nullable(),author_handle:c.string().nullable()}),bMe=c.object({name:c.string().min(1),usage_count:c.number().int().nonnegative(),href:c.string().min(1)}),RMe=c.object({id:c.string().min(1),display_name:c.string(),handle:c.string().nullable(),avatar_url:c.string().nullable(),href:c.string().min(1)}),IMe=c.object({type:c.literal("global_search"),threads:c.array(yMe),skills:c.array(bMe),people:c.array(RMe)}),OMe=c.object({q:c.string().trim().min(1).max(80)}),Y7=AMe.router({globalSearch:{method:"GET",path:"/search",headers:c.object({authorization:c.string().min(1).optional()}),query:OMe,responses:{200:IMe,401:z7,422:z7},summary:"Global navbar search. Threads and people are searched globally (subject to thread visibility); skills are scoped to the viewer workspace. Max 5 results per kind."}});var CMe=Dr(),NMe=["gmail.com","googlemail.com","hotmail.com","outlook.com","live.com","msn.com","yahoo.com","ymail.com","rocketmail.com","icloud.com","me.com","mac.com","aol.com","proton.me","protonmail.com","pm.me","tutanota.com","tuta.io","fastmail.com","hey.com","mail.com","gmx.com","gmx.net","zoho.com","zohomail.com","hushmail.com","lycos.com","inbox.com","yandex.com","yandex.ru","mail.ru","inbox.ru","bk.ru","list.ru","rambler.ru","qq.com","163.com","126.com","yeah.net","sina.com","naver.com","daum.net","hanmail.net","kakao.com","rediffmail.com","comcast.net","verizon.net","att.net","sbcglobal.net","bellsouth.net","earthlink.net","charter.net","cox.net","roadrunner.com","spectrum.net","btinternet.com","virginmedia.com","sky.com","orange.fr","wanadoo.fr","free.fr","laposte.net","web.de","t-online.de","gmx.de","libero.it","virgilio.it","alice.it","seznam.cz","centrum.cz","wp.pl","interia.pl","o2.pl","onet.pl"],Fst=new Set(NMe);var xMe=c.object({id:c.string().uuid(),role:c.enum(["user","assistant"]),content:c.string().min(1),timestamp:c.string().datetime()}),PMe=c.object({id:c.string().uuid(),title:c.string().min(1),author:c.string().min(1),authorAvatar:c.string().min(1).max(4),model:c.string().min(1),turnCount:c.number().int().nonnegative(),createdAt:c.string().datetime(),preview:c.string()}),Gst=PMe.extend({messages:c.array(xMe)}),A=c.object({message:c.string()}),MMe=/^[a-zA-Z0-9_-]{2,32}$/,tW=c.string().regex(MMe,"Handle must be 2\u201332 characters: letters, numbers, dashes, or underscores."),fx=c.object({id:c.string(),first_name:c.string().min(1),last_name:c.string().min(1),display_name:c.string().min(1),stytch_id:c.string().nullable(),handle:c.string().nullable(),bio:c.string().max(280).nullable(),avatar_url:c.string().nullable(),banner_url:c.string().nullable(),share_new_threads_to_workspace:c.boolean(),experimental_features_enabled:c.boolean(),onboarded_at:c.string().nullable()}),vMe=c.object({authProviderUserId:c.string().min(1).optional(),organizationId:c.string().min(1).optional(),org_name:c.string().min(1).optional(),emailAddress:c.string().email(),name:c.string().nullable(),user:fx,is_admin:c.boolean()}),kMe=c.object({workos_client_id:c.string().min(1),workos_api_origin:c.string().url()}),LMe=c.object({share_new_threads_to_workspace:c.boolean().optional(),experimental_features_enabled:c.boolean().optional(),onboarded_at:c.union([c.literal("now"),c.null()]).optional(),display_name:c.string().min(1).max(120).optional(),handle:tW.optional(),bio:c.string().max(280).nullable().optional(),avatar_storage_url:c.string().min(1).nullable().optional(),banner_storage_url:c.string().min(1).nullable().optional()}).refine(t=>Object.keys(t).length>0,{message:"At least one field must be provided"}),wMe=c.object({id:c.string(),display_name:c.string(),handle:c.string().nullable(),avatar_url:c.string().nullable(),visible_thread_count:c.number().int().nonnegative(),last_active_at:c.string().datetime().nullable()}),nW=c.object({id:c.string().min(1),display_name:c.string().min(1),handle:c.string().nullable(),bio:c.string().max(280).nullable(),avatar_url:c.string().nullable(),banner_url:c.string().nullable(),organization_name:c.string().min(1).nullable(),created_at:c.string().min(1),visible_thread_count:c.number().int().nonnegative(),follower_count:c.number().int().nonnegative(),following_count:c.number().int().nonnegative(),published_project_count:c.number().int().nonnegative(),is_following:c.boolean(),is_self:c.boolean()}),DMe=c.object({type:c.literal("list"),list_type:c.literal("organization_member"),objects:c.array(wMe)}),UMe=c.object({email_address:c.string().email()}),BMe=c.object({email_address:c.string().email(),invitation_id:c.string().min(1)}),FMe=c.object({organization_id:c.string().min(1),organization_name:c.string().min(1),domain:c.string().min(1),created:c.boolean()}),GMe=c.object({location:c.string().trim().min(1),contact:c.string().trim().email()}),jMe=c.object({location:c.string().min(1),contact:c.string().email(),created_at:c.string().datetime()}),HMe=c.object({first_name:c.string().min(1),last_name:c.string().min(1),display_name:c.string().min(1),stytch_id:c.string().min(1).optional()}),VMe=c.object({name:c.string().min(1),email_domains:c.array(c.string().min(1)).nonempty(),stytch_org_id:c.string().min(1)}),qMe=c.object({user:HMe,organization:VMe}),$Me=c.object({path_glob:c.string().min(1),name:c.string().min(1),description:c.string().min(1)}),zMe=c.object({repo_origin_path:c.string().min(1),building_blocks:c.array($Me)}),rW=c.string().regex(/^th_[0-9A-Za-z]{22}$/),f0=c.string().regex(/^tb_[0-9A-Za-z]{22}$/),YMe=c.object({id:rW,author:c.object({id:c.string().min(1),display_name:c.string().min(1)}),body:c.string(),created_at:c.string().datetime(),repo_origin_path:c.string().min(1),latest_revision_id:f0,revision_count:c.number().int().positive()}),WMe=c.object({id:c.string().min(1),display_name:c.string().min(1)}),KMe=c.object({id:c.string().min(1),author_id:c.string().min(1).nullable(),author:WMe.nullable(),created_at:c.string().datetime(),deleted_at:c.string().datetime().nullable(),content:c.string().min(1)}),QMe=c.object({id:c.string().min(1),thread_block_id:c.string().min(1),created_at:c.string().datetime(),resolved_at:c.string().datetime().nullable(),comments:c.array(KMe)}),JMe=c.object({thread_block_id:f0,from_position:c.number().int().positive(),to_position:c.number().int().positive(),selected_text:c.string().min(1),content:c.string().trim().min(1)}),XMe=c.object({id:c.string().min(1)}),ZMe=c.object({content:c.string().trim().min(1)}),eve=c.object({id:c.string().min(1)}),tve=c.object({content:c.string().trim().min(1)}),nve=c.object({id:c.string().min(1)}),rve=c.object({content:c.string().trim().min(1)}),ove=c.object({id:c.string().min(1)}),sve=c.object({resolved:c.boolean()}),ive=c.object({id:c.string().min(1),resolved_at:c.string().datetime().nullable()}),ave=c.object({resolved:c.boolean()}),uve=c.object({id:c.string().min(1),resolved_at:c.string().datetime().nullable()}),oW=c.record(c.unknown()),cve=c.object({id:f0,body:c.string(),created_at:c.string().datetime(),prosemirror_json:oW,comment_threads:c.array(QMe)}),lve=c.object({id:rW,created_at:c.string().datetime(),repo_origin_path:c.string().min(1),author:c.object({id:c.string().min(1),display_name:c.string().min(1)}),latest_revision_id:f0,revision_count:c.number().int().positive(),revisions:c.array(cve)}),dve=c.object({type:c.literal("list"),list_type:c.literal("plan"),has_more:c.boolean(),objects:c.array(YMe)}),pve=c.object({before:c.string().min(1).optional(),after:c.string().min(1).optional(),author_id:c.string().min(1).optional(),repo_origin_path:c.string().min(1).optional()}),sW=c.object({id:c.string().min(1),organization_id:c.string().min(1),created_at:c.string().min(1),repo_origin_path:c.string().min(1),path_glob:c.string().min(1),name:c.string().min(1),description:c.string().min(1)}),fve=c.array(sW),mve=c.object({type:c.literal("list"),list_type:c.literal("building_block"),has_more:c.boolean(),objects:c.array(sW)}),_ve=c.object({repo_origin_path:c.string().min(1),before:c.string().min(1).optional(),after:c.string().min(1).optional()}),hve=c.enum(["thread","building_block"]),gve=c.object({repo_origin_path:c.string().min(1),sources:c.array(hve).nonempty()}),Tve=c.object({type:c.literal("list"),list_type:c.literal("repository"),has_more:c.boolean(),objects:c.array(gve)}),qo=c.enum(["claudeCode","codex","amp","cursor","cowork","unspecified"]),Eve=c.object({uploads:c.array(c.string()),outputs:c.array(c.string())}),Sve=c.object({connected:c.boolean(),last_upload_at:c.string().nullable(),harnesses:c.array(qo)}),Ave=["transcript","plan"],yve=c.enum(Ave),bve=c.object({md5:c.string().min(1),harness:qo,filename:c.string().min(1).optional(),repo_origin_path:c.string().min(1).optional(),harness_internal_id:c.string().min(1).optional(),file_type:yve.optional(),remix_of_thread_id:c.string().min(1).optional(),artifact_metadata:Eve.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"}),_x=c.object({id:c.string().min(1),display_name:c.string().min(1),avatar_url:c.string().nullable()}),Rve=c.object({id:c.string().min(1),display_name:c.string().min(1)}),iW=c.object({id:c.string().min(1),author_id:c.string().min(1).nullable(),author:Rve.nullable(),created_at:c.string().datetime(),deleted_at:c.string().datetime().nullable(),content:c.string().min(1)}),aW=c.object({id:c.string().min(1),thread_block_id:c.string().min(1),created_at:c.string().datetime(),resolved_at:c.string().datetime().nullable()}),Ive=aW.extend({comments:c.array(iW)}),nm=c.object({id:c.string().min(1),type:c.string().min(1),index_in_thread:c.number().int().nonnegative(),isCritiqued:c.boolean(),comment_threads:c.array(Ive).optional()}).passthrough(),uW=c.object({type:c.literal("list"),list_type:c.literal("thread_block"),has_more:c.boolean(),objects:c.array(nm)}),W7=nm.extend({type:c.literal("plan"),prosemirror_json:oW,thread_file_id:c.string().min(1)}),Ove=c.union([c.literal(-1),c.literal(1)]),cW=c.union([c.literal(-1),c.literal(0),c.literal(1)]),K7=c.object({score:c.number().int(),up_count:c.number().int().nonnegative(),down_count:c.number().int().nonnegative(),viewer_vote:cW}),Cve=c.object({value:Ove}),Nve=c.object({id:c.string().min(1),display_name:c.string().min(1),avatar_url:c.string().nullable()}),Eu=c.object({id:c.string().min(1),thread_id:c.string().min(1),author_id:c.string().min(1).nullable(),author:Nve.nullable(),parent_comment_id:c.string().min(1).nullable(),content:c.string(),created_at:c.string().datetime(),updated_at:c.string().datetime(),deleted_at:c.string().datetime().nullable()}),xve=c.object({type:c.literal("list"),list_type:c.literal("thread_comment"),objects:c.array(Eu)}),Pve=c.object({content:c.string().trim().min(1).max(4e3),parent_comment_id:c.string().min(1).optional()}),Mve=Eu,vve=c.object({content:c.string().trim().min(1).max(4e3)}),kve=Eu,Lve=Eu,jst=c.discriminatedUnion("kind",[c.object({kind:c.literal("created"),thread_id:c.string().min(1),actor_user_id:c.string().min(1),version:c.number(),comment:Eu}),c.object({kind:c.literal("updated"),thread_id:c.string().min(1),actor_user_id:c.string().min(1),version:c.number(),comment:Eu}),c.object({kind:c.literal("deleted"),thread_id:c.string().min(1),actor_user_id:c.string().min(1),version:c.number(),comment:Eu})]),wve=c.enum(["pending","generating","ready","failed"]),Dve=c.enum(["pending","generating","ready","failed"]),Uve=c.enum(["pending","placeholder","ai","user"]),lW=c.enum(["pending","generating","ready","failed"]),hx=c.enum(["pending","generating","ready","failed","disabled"]),dW=c.enum(["pending","generating","ready","failed"]),Bve=c.object({title:c.string().min(1),body:c.string().min(1),files:c.array(c.string()).optional()}),Fve=c.object({status:hx,url:c.string().nullable(),url_expires_at:c.string().nullable(),generated_at:c.string().nullable(),model:c.string().nullable()}),Gve=c.object({status:dW,steps:c.array(Bve),generated_at:c.string().nullable()}),jve=c.object({remix_of_thread_id:c.string().nullable(),remix_count:c.number().int().nonnegative()}),Hve=c.object({cover:Fve,how_to:Gve,lineage:jve}),Vve=c.object({id:c.string().min(1),title:c.string().min(1),author:c.object({id:c.string().min(1),display_name:c.string(),handle:c.string().nullable(),avatar_url:c.string().nullable()}),cover:c.object({url:c.string(),url_expires_at:c.string()}),remix_count:c.number().int().nonnegative(),started_at:c.string(),cover_generated_at:c.string()}),qve=c.object({type:c.literal("list"),list_type:c.literal("card_feed_item"),has_more:c.boolean(),objects:c.array(Vve)}),pW=c.enum(["asked","requested","decided","corrected","shared"]),$ve=c.object({id:c.string().min(1),kind:pW,summary:c.string().min(1),block_id:c.string().min(1)}),zve=c.object({type:c.literal("list"),list_type:c.literal("thread_decision"),status:lW,generated_at:c.string().nullable(),objects:c.array($ve)}),Yve=c.object({thread_id:c.string().min(1),source_url:c.string().min(1),title:c.string().min(1),summary:c.string().nullable(),harness:qo,visibility:c.enum(["private","workspace","public"]),started_at:c.string().min(1),author:c.object({display_name:c.string().min(1),handle:c.string().nullable()}),original_user_prompt:c.string().nullable(),last_assistant_message:c.string().nullable(),decisions:c.array(c.object({kind:pW,summary:c.string().min(1)})),files_touched:c.array(c.string()),truncated:c.boolean()}),sd=c.object({id:c.string().min(1),thread_file_id:c.string().min(1),organization_id:c.string().min(1),author:_x,repo:c.string().min(1),title:c.string().min(1),started_at:c.string().min(1),blocks:uW,user_message_count:c.number().int().nonnegative(),files_touched:c.array(c.string()),skills_invoked:c.array(c.string()),harness:qo,transcript_parsing_state:c.enum(["pending","parsed","too_large_to_parse"]),visibility:c.enum(["private","workspace","public"]),has_plan:c.boolean().optional(),summary:c.string().nullable(),summary_status:wve,summary_generated_at:c.string().nullable(),title_status:Dve,title_generated_at:c.string().nullable(),title_source:Uve,decisions_status:lW,decisions_generated_at:c.string().nullable(),score:c.number().int(),up_count:c.number().int().nonnegative(),down_count:c.number().int().nonnegative(),viewer_vote:cW,comment_count:c.number().int().nonnegative(),is_favorited:c.boolean(),card:Hve}),Wve=c.object({storage_url:c.string().min(1)}),Kve=c.object({storage_url:c.string(),harness:qo,thread:sd.nullable()}),Qve=c.object({status:c.literal("complete"),thread_files:c.array(Kve)}),Jve=c.object({id:c.string(),presigned_url:c.string().nullable(),presigned_url_expires_at:c.string().nullable(),storage_url:c.string(),harness:qo,expected_md5:c.string(),error:c.string().nullable(),thread:sd.nullable(),remix_parent_dropped:c.boolean().optional()}),Xve=c.object({id:c.string(),substrate:c.enum(["s3","filesystem"]),status:c.enum(["incomplete","locked_for_parsing","complete","error"]),thread_files:c.array(Jve)}),Zve=c.object({visibility:c.enum(["private","workspace","public"]).optional(),title:c.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"}),eke=c.discriminatedUnion("visibility",[c.object({visibility:c.literal("private")}),c.object({visibility:c.literal("workspace")}),c.object({visibility:c.literal("public"),title:c.string().min(1),author_display_name:c.string().min(1),author_avatar_url:c.string().nullable(),first_user_message:c.string().nullable(),summary:c.string().nullable(),started_at:c.string().min(1),harness:qo,cover_url:c.string().nullable()})]),tke=sd,Q7=c.object({type:c.literal("list"),list_type:c.literal("thread"),has_more:c.boolean(),objects:c.array(tke)}),nke=c.enum(["recent","popular"]),rke=c.enum(["everyone","following"]),oke=sd,ske=c.object({type:c.literal("list"),list_type:c.literal("discover_thread"),has_more:c.boolean(),objects:c.array(oke)}),ike=c.object({before:c.string().min(1).optional(),after:c.string().min(1).optional(),sort:nke.optional(),scope:rke.optional(),harness:qo.optional(),search:c.string().max(200).optional()}),ake=c.object({thread_count:c.number().int().nonnegative(),author_count:c.number().int().nonnegative(),organization_count:c.number().int().nonnegative(),harness_breakdown:c.record(qo,c.number().int().nonnegative())}),uke=c.object({id:c.string(),status:c.enum(["incomplete","locked_for_parsing","complete","error"]),created_at:c.string(),thread_count:c.number().int().nonnegative()}),cke=c.object({type:c.literal("list"),list_type:c.literal("upload_session"),objects:c.array(uke)}),lke=c.object({before:c.string().min(1).optional(),after:c.string().min(1).optional()}),dke=c.object({before:c.string().min(1).optional(),after:c.string().min(1).optional(),author_ids:c.string().min(1).optional(),created_at:c.string().min(1).optional(),filepath_prefixes:c.string().min(1).optional()}),pke=c.object({path:c.string().min(1),start_offset:c.number().int().nonnegative(),end_offset:c.number().int().positive()}),gx=c.enum(["captured","published"]),fke=c.enum(["workspace","link"]),fW=c.object({id:c.string(),display_name:c.string(),avatar_url:c.string().nullable()}),mke=c.object({name:c.string(),usage_count:c.number().int().nonnegative(),author_count:c.number().int().nonnegative(),first_used_at:c.string().nullable(),last_used_at:c.string().nullable(),usage_count_last_24h:c.number().int().nonnegative(),usage_count_last_7d:c.number().int().nonnegative(),id:c.string().nullable(),description:c.string().nullable(),source:gx.nullable(),has_content:c.boolean()}),_ke=c.object({type:c.literal("list"),list_type:c.literal("skill"),objects:c.array(mke)}),hke=c.object({id:c.string(),title:c.string(),visibility:c.enum(["private","workspace","public"]),started_at:c.string(),author:_x,skills_invoked:c.array(c.string())}),gke=c.object({id:c.string().nullable(),name:c.string(),description:c.string().nullable(),body_md:c.string().nullable(),source:gx.nullable(),visibility:fke.nullable(),share_url:c.string().nullable(),latest_version:c.number().int().nonnegative().nullable(),author:fW.nullable(),usage_count:c.number().int().nonnegative(),author_count:c.number().int().nonnegative(),first_used_at:c.string().nullable(),last_used_at:c.string().nullable(),threads:c.array(hke)}),Tke=c.object({description:c.string().nullable().optional(),body_md:c.string().min(1),display_name:c.string().nullable().optional(),published:c.boolean().optional()}),Eke=c.object({id:c.string(),name:c.string(),latest_version:c.number().int().positive(),source:gx,content_hash:c.string()}),Ske=c.object({share_url:c.string(),share_token:c.string()}),Ake=c.object({id:c.string(),name:c.string(),description:c.string().nullable(),body_md:c.string(),latest_version:c.number().int().positive(),author:fW.nullable(),shared_at:c.string()}),yke=c.object({path:c.string().min(1),text:c.string().max(64e3)}),bke=c.enum(["text_edit","redact","delete_block"]),Rke=c.object({id:c.string(),thread_block_id:c.string(),editor:c.object({id:c.string(),display_name:c.string()}),kind:bke,path:c.string().nullable(),previous_text:c.string().nullable(),new_text:c.string().nullable(),created_at:c.string()}),Ike=c.object({type:c.literal("list"),list_type:c.literal("thread_block_edit"),objects:c.array(Rke)}),Oke=c.object({organization_count:c.number().int().nonnegative(),user_count:c.number().int().nonnegative(),thread_count:c.number().int().nonnegative(),thread_count_last_24h:c.number().int().nonnegative(),user_count_last_24h:c.number().int().nonnegative()}),Cke=c.object({id:c.string(),name:c.string(),email_domains:c.array(c.string()),stytch_org_id:c.string(),member_count:c.number().int().nonnegative(),thread_count:c.number().int().nonnegative(),default_thread_visibility:c.enum(["private","workspace","public"]),created_at:c.string()}),Nke=c.object({type:c.literal("list"),list_type:c.literal("admin_organization"),objects:c.array(Cke)}),mW=c.object({id:c.string(),name:c.string()}),xke=c.object({id:c.string(),display_name:c.string(),stytch_id:c.string().nullable(),thread_count:c.number().int().nonnegative(),onboarded_at:c.string().nullable(),created_at:c.string(),organizations:c.array(mW)}),Pke=c.object({q:c.string().trim().min(1).max(120).optional()}),Mke=c.object({follower_id:c.string().min(1),followee_id:c.string().min(1)}),vke=c.object({follower_id:c.string().min(1),followee_id:c.string().min(1),is_following:c.literal(!0)}),kke=c.object({type:c.literal("list"),list_type:c.literal("admin_user"),objects:c.array(xke)}),Lke=c.object({id:c.string(),title:c.string(),started_at:c.string(),created_at:c.string(),deleted_at:c.string().nullable(),visibility:c.enum(["private","workspace","public"]),harness:qo,author:_x,organization:mW}),wke=c.object({type:c.literal("list"),list_type:c.literal("admin_thread"),has_more:c.boolean(),objects:c.array(Lke)}),Dke=c.object({before:c.string().min(1).optional(),after:c.string().min(1).optional()}),J7=c.object({token:c.string().min(1),thread_id:c.string().min(1)}),Uke=c.object({visitor:c.string().min(1).max(64).optional()}),Bke=c.object({user_id:c.string(),display_name:c.string(),shares_sent:c.number().int().nonnegative(),unique_viewers:c.number().int().nonnegative(),attributed_signups:c.number().int().nonnegative()}),Fke=c.object({window_days:c.number().int().positive(),shares_sent:c.number().int().nonnegative(),unique_viewers:c.number().int().nonnegative(),attributed_signups:c.number().int().nonnegative(),active_sharers:c.number().int().nonnegative(),k_factor:c.number().nullable(),shares_sent_sparkline:c.array(c.number().int().nonnegative()),top_sharers:c.array(Bke)}),Gke=c.object({windows:c.array(Fke)}),jke=c.object({quoted_text:c.string().min(1),comment:c.string().nullable(),type:c.enum(["comment","highlight:trapdoor"])}),Hke=aW,Vke=iW.extend({comment_thread_id:c.string().min(1)}),qke=c.object({markdown:c.string().min(1)}),$ke=c.object({storage_url:c.string().min(1),thread_file_id:c.string().min(1),parsed_plan_block:W7,critiqued_plan_block:W7,annotations:c.array(jke),comment_threads:c.array(Hke),comments:c.array(Vke)}),id=c.enum(ux),_W=c.object({skills:c.boolean(),workspace_scope:c.boolean(),review:c.boolean(),shared_thread_ttl_days:c.number().int().positive().nullable()}),mx=c.object({subject_type:c.enum(["user","organization"]),subject_id:c.string().min(1),effective_plan:id,admin_override:id.nullable(),stripe_subscription_status:c.string().nullable(),cancel_at_period_end:c.boolean(),current_period_end:c.string().nullable(),seat_quantity:c.number().int().positive(),member_count:c.number().int().nonnegative().nullable(),features:_W}),zke=c.object({effective_plan:id,features:_W,user:mx,organization:mx.nullable()}),Yke=c.object({plan:c.enum(["creator","team"]),seat_quantity:c.number().int().positive().optional()}),Wke=c.object({checkout_url:c.string().min(1)}),Kke=c.object({portal_url:c.string().min(1)}),Qke=c.object({seat_quantity:c.number().int().positive()}),X7=c.object({plan:id.nullable()}),p0=c.object({subject_type:c.enum(["user","organization"]),subject_id:c.string().min(1),label:c.string().min(1),effective_plan:id,admin_override:id.nullable(),stripe_subscription_status:c.string().nullable(),seat_quantity:c.number().int().positive()}),Jke=c.object({users:c.array(p0),organizations:c.array(p0)}),Xke=c.object({id:c.string().min(1),display_name:c.string().min(1),handle:c.string().nullable(),avatar_url:c.string().nullable()}),Zke=c.object({thread_id:c.string().min(1),title:c.string().min(1),author:Xke,last_active_at:c.string().datetime(),last_block_excerpt:c.string().nullable(),last_block_kind:c.string().min(1).nullable(),is_streaming:c.boolean()}),eLe=c.object({type:c.literal("list"),list_type:c.literal("live_thread"),objects:c.array(Zke)}),tLe=c.object({thread_id:c.string().min(1)}),nLe=c.object({thread_id:c.string().min(1),last_seen_at:c.string().datetime(),started_at:c.string().datetime()}),rLe=c.object({follower_id:c.string().min(1),followee_id:c.string().min(1),is_following:c.literal(!0),follower_count:c.number().int().nonnegative()}),oLe=c.object({follower_id:c.string().min(1),followee_id:c.string().min(1),is_following:c.literal(!1),follower_count:c.number().int().nonnegative()}),hW=c.object({id:c.string().min(1),display_name:c.string().min(1),handle:c.string().nullable(),avatar_url:c.string().nullable(),bio:c.string().max(280).nullable(),is_following:c.boolean(),is_self:c.boolean()}),Z7=c.object({type:c.literal("list"),list_type:c.literal("user_follow"),objects:c.array(hW)}),sLe=c.object({date:c.string().regex(/^\d{4}-\d{2}-\d{2}$/),count:c.number().int().nonnegative()}),iLe=c.object({window_start:c.string().datetime(),window_end:c.string().datetime(),total_contributions:c.number().int().nonnegative(),days_active:c.number().int().nonnegative(),daily_average:c.number().nonnegative(),current_streak_days:c.number().int().nonnegative(),days:c.array(sLe)}),aLe=c.object({type:c.literal("thread_created"),occurred_at:c.string().datetime(),id:c.string().min(1),thread:c.object({id:c.string().min(1),title:c.string(),visibility:c.enum(["private","workspace","public"])})}),uLe=c.object({type:c.literal("comment_posted"),occurred_at:c.string().datetime(),id:c.string().min(1),comment_excerpt:c.string(),thread:c.object({id:c.string().min(1),title:c.string(),visibility:c.enum(["private","workspace","public"])})}),cLe=c.object({type:c.literal("project_published"),occurred_at:c.string().datetime(),id:c.string().min(1),project:c.object({id:c.string().min(1),name:c.string().min(1)})}),lLe=c.object({type:c.literal("user_followed"),occurred_at:c.string().datetime(),id:c.string().min(1),followee:hW}),dLe=c.discriminatedUnion("type",[aLe,uLe,cLe,lLe]),pLe=c.object({type:c.literal("list"),list_type:c.literal("user_activity"),objects:c.array(dLe)}),fLe=c.object({id:c.string().min(1),name:c.string().min(1),excerpt:c.string(),published_at:c.string().datetime(),updated_at:c.string().datetime()}),mLe=c.object({type:c.literal("list"),list_type:c.literal("profile_published_project"),objects:c.array(fLe)}),eW=c.object({id:c.string().min(1),published_at:c.string().datetime().nullable()}),_Le=c.enum(["avatar","banner"]),gW=c.enum(["image/png","image/jpeg","image/webp","image/gif"]),hLe=c.object({kind:_Le,content_type:gW,base64_data:c.string().min(1)}),gLe=c.object({substrate:c.enum(["s3","filesystem"]),storage_url:c.string().min(1)}),TLe=c.object({content_type:gW,base64_data:c.string().min(1)}),ELe=c.object({cover_status:hx,cover_url:c.string().min(1),cover_url_expires_at:c.string().min(1),cover_generated_at:c.string().min(1)}),SLe=nW,TW=CMe.router({health:{method:"GET",path:"/health",responses:{200:c.object({status:c.literal("ok")})},summary:"Health check"},whoAmI:{method:"GET",path:"/whoami",headers:c.object({authorization:c.string().min(1).optional(),"x-lore-referral-token":c.string().min(1).max(16).optional()}),responses:{200:vMe,401:A},summary:"Validate a WorkOS Bearer token and return member plus user fields"},getCliAuthConfig:{method:"GET",path:"/cli-auth/config",responses:{200:kMe,503:A},summary:"Return public WorkOS CLI Auth configuration for the Lore CLI"},getCliStatus:{method:"GET",path:"/users/me/cli-status",headers:c.object({authorization:c.string().min(1).optional()}),responses:{200:Sve,401:A},summary:"Return whether the viewer has connected the Lore CLI (i.e., uploaded any thread under a non-unspecified harness), plus the latest upload timestamp."},recordHeartbeat:{method:"POST",path:"/heartbeat",headers:c.object({authorization:c.string().min(1).optional()}),body:tLe,responses:{200:nLe,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:c.object({authorization:c.string().min(1).optional()}),responses:{200:eLe,401:A,403:A},summary:"List members with user-block activity in the last 10 minutes. Org-scoped, deduped per author, max 10."},listThreads:{method:"GET",path:"/threads",headers:c.object({authorization:c.string().min(1).optional()}),query:dke,responses:{200:Q7,401:A},summary:"List threads visible to the authenticated user"},getThread:{method:"GET",path:"/threads/:id",pathParams:c.object({id:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),responses:{200:sd,404:A},summary:"Load a visible thread by id"},getSimilarThreads:{method:"GET",path:"/threads/:id/similar",pathParams:c.object({id:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),responses:{200:Q7,404:A,409:A},summary:"List the top 20 visible threads with the closest summary embedding"},getThreadRemixBrief:{method:"GET",path:"/threads/:id/remix",pathParams:c.object({id:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),responses:{200:Yve,401:A,403:A,404:A},summary:"Fetch a portable handoff brief that lets another agent continue this thread"},listThreadBlocks:{method:"GET",path:"/threads/:id/blocks",pathParams:c.object({id:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),query:lke,responses:{200:uW,401:A},summary:"List blocks for a visible thread"},createThreadBlockCommentThread:{method:"POST",path:"/threads/:threadId/blocks/:blockId/comment-threads",pathParams:c.object({threadId:c.string().min(1),blockId:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),body:ZMe,responses:{201:eve,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:c.object({threadId:c.string().min(1),blockId:c.string().min(1),commentThreadId:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),body:rve,responses:{201:ove,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:c.object({threadId:c.string().min(1),blockId:c.string().min(1),commentThreadId:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),body:ave,responses:{200:uve,401:A,404:A},summary:"Resolve or reopen a block-level comment thread on a visible thread block"},listSkills:{method:"GET",path:"/skills",headers:c.object({authorization:c.string().min(1).optional()}),responses:{200:_ke,401:A},summary:"Aggregate skill usage across threads the viewer can see"},getSkillDetail:{method:"GET",path:"/skills/:name",pathParams:c.object({name:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),responses:{200:gke,401:A,404:A},summary:"Per-skill detail: usage stats + visible threads that invoked it"},getSkillRaw:{method:"GET",path:"/skills/:name/raw",pathParams:c.object({name:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),responses:{200:c.string(),401:A,403:A,404:A},summary:"Raw SKILL.md body for a skill (download / install path)"},publishSkill:{method:"PUT",path:"/skills/:name",pathParams:c.object({name:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),body:Tke,responses:{200:Eke,401:A,403:A,422:A},summary:"Publish or capture a skill body for the caller\u2019s workspace"},mintSkillShare:{method:"POST",path:"/skills/:name/share",pathParams:c.object({name:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),body:c.object({}).optional(),responses:{200:Ske,401:A,403:A,404:A},summary:"Mint (or rotate) a public share token for a skill"},revokeSkillShare:{method:"DELETE",path:"/skills/:name/share",pathParams:c.object({name:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),responses:{204:c.null(),401:A,403:A,404:A},summary:"Revoke an active share token for a skill"},getSharedSkill:{method:"GET",path:"/shared-skills/:token",pathParams:c.object({token:c.string().min(1)}),responses:{200:Ake,404:A},summary:"Read a shared skill by its public share token (no auth)"},redactThreadBlock:{method:"POST",path:"/threads/:threadId/blocks/:blockId/redactions",pathParams:c.object({threadId:c.string().min(1),blockId:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),body:pke,responses:{200:nm,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:c.object({threadId:c.string().min(1),blockId:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),body:yke,responses:{200:nm,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:c.object({threadId:c.string().min(1),blockId:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),body:c.object({}).optional(),responses:{200:nm,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:c.object({threadId:c.string().min(1),blockId:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),body:c.object({}).optional(),responses:{204:c.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:c.object({threadId:c.string().min(1),blockId:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),responses:{200:Ike,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:c.object({id:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),responses:{200:zve,401:A,404:A},summary:"List AI-extracted user decisions for a thread, in chronological order"},updateThread:{method:"PATCH",path:"/threads/:id",pathParams:c.object({id:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),body:Zve,responses:{200:sd,401:A,403:A,404:A},summary:"Update thread visibility (author only)"},deleteThread:{method:"DELETE",path:"/threads/:id",pathParams:c.object({id:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),body:c.object({}).optional(),responses:{204:c.null(),401:A,403:A,404:A},summary:"Soft-delete a thread (author only)"},generateThreadCard:{method:"POST",path:"/threads/:id/card/generate",pathParams:c.object({id:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),body:c.object({}).optional(),responses:{200:c.object({cover_status:hx,how_to_status:dW}),401:A,403:A,404:A,429:A.extend({retry_after_seconds:c.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'."},uploadThreadCover:{method:"POST",path:"/threads/:id/card/cover/upload",pathParams:c.object({id:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),body:TLe,responses:{200:ELe,401:A,403:A,404:A,413:A,422:A},summary:"Upload a custom cover image for a thread. Author or Tanagram admin only. Bytes go to the same storage substrate the AI cover uses (S3 in prod, filesystem in dev), and the threads row is updated atomically with the new cover_storage_url, cover_status='ready', cover_generated_at=now, cover_model='user-uploaded' so subsequent re-rolls / how-to fan-outs treat the upload like any other ready cover."},castThreadVote:{method:"PUT",path:"/threads/:id/vote",pathParams:c.object({id:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),body:Cve,responses:{200:K7,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:c.object({id:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),body:c.object({}).optional(),responses:{200:K7,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:c.object({threadId:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),responses:{200:xve,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:c.object({threadId:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),body:Pve,responses:{201:Mve,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:c.object({threadId:c.string().min(1),commentId:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),body:vve,responses:{200:kve,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:c.object({threadId:c.string().min(1),commentId:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),body:c.object({}).optional(),responses:{200:Lve,401:A,403:A,404:A},summary:"Soft-delete your own thread comment (author only). Idempotent."},getThreadPreview:{method:"GET",path:"/threads/:id/preview",pathParams:c.object({id:c.string().min(1)}),responses:{200:eke,404:A},summary:"Unauthenticated, visibility-redacted metadata for OG / social preview consumers"},createUser:{method:"POST",path:"/users",headers:c.object({authorization:c.string().min(1).optional()}),body:qMe,responses:{201:fx,401:A},summary:"Create a user record with ApiKey authentication"},getUser:{method:"GET",path:"/users/:id",pathParams:c.object({id:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),responses:{200:nW,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:c.object({authorization:c.string().min(1).optional()}),body:LMe,responses:{200:fx,401:A,409:A,422:A},summary:"Update the authenticated user profile"},getUserByHandle:{method:"GET",path:"/users/by-handle/:handle",pathParams:c.object({handle:tW}),headers:c.object({authorization:c.string().min(1).optional()}),responses:{200:SLe,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:c.object({id:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),query:c.object({limit:c.coerce.number().int().positive().max(100).optional()}),responses:{200:pLe,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:c.object({id:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),responses:{200:iLe,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:c.object({id:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),responses:{200:Z7,404:A},summary:"List the users following a given user."},listUserFollowing:{method:"GET",path:"/users/:id/following",pathParams:c.object({id:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),responses:{200:Z7,404:A},summary:"List the users a given user is following."},followUser:{method:"POST",path:"/users/:id/follow",pathParams:c.object({id:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),body:c.object({}).optional(),responses:{200:rLe,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:c.object({id:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),body:c.object({}).optional(),responses:{200:oLe,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:c.object({id:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),responses:{200:mLe,404:A},summary:"Projects the user has published to their public profile."},publishProject:{method:"POST",path:"/projects/:id/publish",pathParams:c.object({id:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),body:c.object({}).optional(),responses:{200:eW,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:c.object({id:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),body:c.object({}).optional(),responses:{200:eW,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:c.object({authorization:c.string().min(1).optional()}),body:hLe,responses:{200:gLe,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:c.object({authorization:c.string().min(1).optional()}),responses:{200:DMe,401:A},summary:"List members of the authenticated user\u2019s organization"},createOrganizationInvite:{method:"POST",path:"/organization/invites",headers:c.object({authorization:c.string().min(1).optional()}),body:UMe,responses:{201:BMe,401:A,403:A,409:A,422:A},summary:"Invite a teammate to the authenticated user\u2019s workspace via WorkOS AuthKit"},ensureWorkOSOrganization:{method:"POST",path:"/organization/workos/ensure",headers:c.object({authorization:c.string().min(1).optional()}),body:c.object({}).optional(),responses:{200:FMe,401:A,422:A,503:A},summary:"Create or reuse a WorkOS organization for the authenticated user\u2019s non-public email domain and add the user as a member."},listRepositories:{method:"GET",path:"/repositories",headers:c.object({authorization:c.string().min(1).optional()}),responses:{200:Tve,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:c.object({authorization:c.string().min(1).optional()}),body:zMe,responses:{201:fve,401:A,403:A},summary:"Create building block snapshots for the authenticated user\u2019s organization"},getPlan:{method:"GET",path:"/plans/:id",pathParams:c.object({id:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),responses:{200:lve,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:c.object({id:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),body:JMe,responses:{201:XMe,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:c.object({id:c.string().min(1),threadId:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),body:tve,responses:{201:nve,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:c.object({id:c.string().min(1),threadId:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),body:sve,responses:{200:ive,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:c.object({authorization:c.string().min(1).optional()}),query:pve,responses:{200:dve,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:c.object({authorization:c.string().min(1).optional()}),query:_ve,responses:{200:mve,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:c.object({authorization:c.string().min(1).optional()}),responses:{200:cke,401:A},summary:"List recent upload sessions for the authenticated user"},createUploadSession:{method:"POST",path:"/upload_sessions",headers:c.object({authorization:c.string().min(1).optional()}),body:c.object({thread_files:c.array(bve).nonempty()}),responses:{201:Xve,400:A,401:A},summary:"Create an upload session with presigned URLs for file uploads"},completeUploadSession:{method:"POST",path:"/upload_sessions/:id/complete",pathParams:c.object({id:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),body:c.object({thread_files:c.array(Wve).nonempty()}),responses:{200:Qve,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:c.object({authorization:c.string().min(1).optional()}),responses:{200:Oke,401:A,403:A},summary:"Cross-org operational counts. Tanagram admins only."},adminListOrganizations:{method:"GET",path:"/admin/organizations",headers:c.object({authorization:c.string().min(1).optional()}),responses:{200:Nke,401:A,403:A},summary:"List every organization with member and thread counts. Tanagram admins only."},adminListUsers:{method:"GET",path:"/admin/users",query:Pke,headers:c.object({authorization:c.string().min(1).optional()}),responses:{200:kke,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:c.object({authorization:c.string().min(1).optional()}),query:Dke,responses:{200:wke,401:A,403:A},summary:"List live threads across every organization. Tanagram admins only."},adminForceFollow:{method:"POST",path:"/admin/connections/follow",headers:c.object({authorization:c.string().min(1).optional()}),body:Mke,responses:{200:vke,401:A,403:A,404:A,422:A},summary:"Force follower->followee edge. Admin-only and non-destructive."},adminHardDeleteThread:{method:"DELETE",path:"/admin/threads/:id",pathParams:c.object({id:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),body:c.object({}).optional(),responses:{204:c.null(),401:A,403:A,404:A},summary:"Permanently remove a thread. Tanagram admins only."},listCardFeed:{method:"GET",path:"/cards/feed",query:c.object({limit:c.coerce.number().int().min(1).max(48).optional()}),responses:{200:qve},summary:"Slim feed of public threads with a ready cover image, ordered by cover_generated_at descending. Powers the landing-page UGC card scroll. Returns presigned cover URLs inline so the grid renders without a follow-up round trip per card."},listDiscoverThreads:{method:"GET",path:"/discover/threads",headers:c.object({authorization:c.string().min(1).optional()}),query:ike,responses:{200:ske},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:ake},summary:"Unauthenticated rollup of public-thread counts for the Discover header."},createWaitlistEntry:{method:"POST",path:"/waitlist_entries",body:GMe,responses:{201:jMe,409:A},summary:"Create an unauthenticated waitlist entry keyed by (location, contact)."},createShareToken:{method:"POST",path:"/threads/:id/share-token",pathParams:c.object({id:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),body:c.object({}).optional(),responses:{201:J7,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:c.object({token:c.string().min(1).max(16)}),query:Uke,responses:{200:J7,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:c.object({authorization:c.string().min(1).optional()}),responses:{200:Gke,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:c.object({authorization:c.string().min(1).optional()}),body:qke,responses:{200:$ke,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:c.object({authorization:c.string().min(1).optional()}),responses:{200:zke,401:A},summary:"Resolve the caller's plan, features, seat count, and any admin override."},createBillingCheckout:{method:"POST",path:"/billing/checkout",headers:c.object({authorization:c.string().min(1).optional()}),body:Yke,responses:{200:Wke,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:c.object({authorization:c.string().min(1).optional()}),body:c.object({subject_type:c.enum(["user","organization"]).default("user")}).optional(),responses:{200:Kke,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:c.object({authorization:c.string().min(1).optional()}),body:Qke,responses:{200:mx,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:c.object({authorization:c.string().min(1).optional()}),responses:{200:Jke,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:c.object({id:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),body:X7,responses:{200:p0,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:c.object({id:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),body:X7,responses:{200:p0,401:A,403:A,404:A},summary:"Admin override for an organization's plan tier. Null clears the override."},projects:j7,docs:F7,mentions:H7,favorites:$7,search:Y7},{pathPrefix:"/api"});import sm from"node:fs";import AW from"node:path";import EW from"node:os";import Ps from"node:path";function oo(){let t=Ve()==="dev"?".lore-dev":".lore";return Ps.join(EW.homedir(),t)}function rm(){return Ps.join(oo(),"log.txt")}function Tx(){return Ps.join(oo(),"sync_state.json")}function SW(){return Ps.join(oo(),"upload_filters.json")}function m0(){return Ps.join(oo(),"status.json")}function Su(){return Ps.join(oo(),"install_source.json")}function _0(){return Ps.join(oo(),"skill_sync_state.json")}function Au(){return Ps.join(oo(),"bin","lore")}function om(){let t=Ve();return t==="prod"?"ai.tanagram.lore":`ai.tanagram.lore.${t}`}function ad(){return Ps.join(EW.homedir(),"Library","LaunchAgents",`${om()}.plist`)}function h0(){return AW.join(oo(),"token")}function im(){let t;try{t=sm.readFileSync(h0(),"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||ALe(e,new Date)?{token:"",source:"none"}:{token:e,source:"file"}}function fn(){return im().token}function yW(){return sm.existsSync(h0())}function bW(t){let e=h0();sm.mkdirSync(AW.dirname(e),{recursive:!0,mode:448}),sm.writeFileSync(e,t,{mode:384})}function RW(){try{sm.rmSync(h0())}catch(t){if(t&&typeof t=="object"&&"code"in t&&t.code==="ENOENT")return;throw t}}function Ex(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 ALe(t,e){let n;try{n=Ex(t)}catch{return!1}return typeof n.exp!="number"?!1:e.getTime()>=n.exp*1e3}var yLe={dev:"http://localhost:4000",prod:"https://lore-api.tanagram.ai"};function bLe(t=Ve(),e=process.env.LORE_API_ORIGIN){let n=e?.trim();return n?n.replace(/\/$/,""):yLe[t]}function Xe(t={}){let e=t.token??fn();return ax(TW,{baseUrl:bLe(),baseHeaders:{"User-Agent":_7(),...e?{authorization:`Bearer ${e}`}:{}}})}import OW from"node:fs";var IW=null;function RLe(){let t=oo();IW!==t&&(OW.mkdirSync(t,{recursive:!0}),IW=t)}function ILe(t){let e=typeof t=="string"?t:JSON.stringify(t);return/[\s"=]/.test(e)?JSON.stringify(e):e}function OLe(t,e,n){let r=`${new Date().toISOString()} ${t} ${e}`;if(!n)return`${r}
|
|
40
|
+
`)}function ZN(t){let e=t.valueHint?`=<${t.valueHint}>`:"",n=e||`=<${g7(t.name)}>`;return!t.type||t.type==="positional"||t.type==="boolean"?e:t.type==="enum"&&t.options?.length?`=<${t.options.join("|")}>`:n}function E7(t,e){let n=e?JS("(Required)"):"",r=t.default===void 0?"":JS(`(Default: ${t.default})`);return[t.description,n,r].filter(Boolean).join(" ")}import{spawn as oUe}from"node:child_process";var c={};ea(c,{BRAND:()=>wPe,DIRTY:()=>nu,EMPTY_PATH:()=>fPe,INVALID:()=>J,NEVER:()=>E1e,OK:()=>dn,ParseStatus:()=>Jt,Schema:()=>ce,ZodAny:()=>Yi,ZodArray:()=>xs,ZodBigInt:()=>ou,ZodBoolean:()=>su,ZodBranded:()=>em,ZodCatch:()=>hu,ZodDate:()=>iu,ZodDefault:()=>_u,ZodDiscriminatedUnion:()=>o0,ZodEffects:()=>wr,ZodEnum:()=>fu,ZodError:()=>Hn,ZodFirstPartyTypeKind:()=>ee,ZodFunction:()=>i0,ZodIntersection:()=>lu,ZodIssueCode:()=>x,ZodLazy:()=>du,ZodLiteral:()=>pu,ZodMap:()=>nd,ZodNaN:()=>od,ZodNativeEnum:()=>mu,ZodNever:()=>ro,ZodNull:()=>uu,ZodNullable:()=>Ho,ZodNumber:()=>ru,ZodObject:()=>Vn,ZodOptional:()=>kr,ZodParsedType:()=>D,ZodPipeline:()=>tm,ZodPromise:()=>Wi,ZodReadonly:()=>gu,ZodRecord:()=>s0,ZodSchema:()=>ce,ZodSet:()=>rd,ZodString:()=>zi,ZodSymbol:()=>ed,ZodTransformer:()=>wr,ZodTuple:()=>jo,ZodType:()=>ce,ZodUndefined:()=>au,ZodUnion:()=>cu,ZodUnknown:()=>Ns,ZodVoid:()=>td,addIssueToContext:()=>k,any:()=>qPe,array:()=>WPe,bigint:()=>FPe,boolean:()=>M7,coerce:()=>T1e,custom:()=>N7,date:()=>GPe,datetimeRegex:()=>O7,defaultErrorMap:()=>Os,discriminatedUnion:()=>XPe,effect:()=>l1e,enum:()=>a1e,function:()=>o1e,getErrorMap:()=>Jl,getParsedType:()=>Go,instanceof:()=>UPe,intersection:()=>ZPe,isAborted:()=>n0,isAsync:()=>Xl,isDirty:()=>r0,isValid:()=>$i,late:()=>DPe,lazy:()=>s1e,literal:()=>i1e,makeIssue:()=>Zf,map:()=>n1e,nan:()=>BPe,nativeEnum:()=>u1e,never:()=>zPe,null:()=>VPe,nullable:()=>p1e,number:()=>P7,object:()=>KPe,objectUtil:()=>ex,oboolean:()=>g1e,onumber:()=>h1e,optional:()=>d1e,ostring:()=>_1e,pipeline:()=>m1e,preprocess:()=>f1e,promise:()=>c1e,quotelessJson:()=>lPe,record:()=>t1e,set:()=>r1e,setErrorMap:()=>pPe,strictObject:()=>QPe,string:()=>x7,symbol:()=>jPe,transformer:()=>l1e,tuple:()=>e1e,undefined:()=>HPe,union:()=>JPe,unknown:()=>$Pe,util:()=>fe,void:()=>YPe});var fe;(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})(fe||(fe={}));var ex;(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(ex||(ex={}));var D=fe.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 x=fe.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"]),lPe=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),Hn=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,u=0;for(;u<i.path.length;){let l=i.path[u];u===i.path.length-1?(a[l]=a[l]||{_errors:[]},a[l]._errors.push(n(i))):a[l]=a[l]||{_errors:[]},a=a[l],u++}}};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,fe.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()}};Hn.create=t=>new Hn(t);var dPe=(t,e)=>{let n;switch(t.code){case x.invalid_type:t.received===D.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case x.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,fe.jsonStringifyReplacer)}`;break;case x.unrecognized_keys:n=`Unrecognized key(s) in object: ${fe.joinValues(t.keys,", ")}`;break;case x.invalid_union:n="Invalid input";break;case x.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${fe.joinValues(t.options)}`;break;case x.invalid_enum_value:n=`Invalid enum value. Expected ${fe.joinValues(t.options)}, received '${t.received}'`;break;case x.invalid_arguments:n="Invalid function arguments";break;case x.invalid_return_type:n="Invalid function return type";break;case x.invalid_date:n="Invalid date";break;case x.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}"`:fe.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case x.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 x.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 x.custom:n="Invalid input";break;case x.invalid_intersection_types:n="Intersection results could not be merged";break;case x.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case x.not_finite:n="Number must be finite";break;default:n=e.defaultError,fe.assertNever(t)}return{message:n}},Os=dPe;var A7=Os;function pPe(t){A7=t}function Jl(){return A7}var Zf=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="",u=r.filter(l=>!!l).slice().reverse();for(let l of u)a=l(i,{data:e,defaultError:a}).message;return{...o,path:s,message:a}},fPe=[];function k(t,e){let n=Jl(),r=Zf({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===Os?void 0:Os].filter(o=>!!o)});t.common.issues.push(r)}var Jt=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 J;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 J;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}}},J=Object.freeze({status:"aborted"}),nu=t=>({status:"dirty",value:t}),dn=t=>({status:"valid",value:t}),n0=t=>t.status==="aborted",r0=t=>t.status==="dirty",$i=t=>t.status==="valid",Xl=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 Lr=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}},y7=(t,e)=>{if($i(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 Hn(t.common.issues);return this._error=n,this._error}}};function ae(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:u}=t;return i.code==="invalid_enum_value"?{message:u??a.defaultError}:typeof a.data>"u"?{message:u??r??a.defaultError}:i.code!=="invalid_type"?{message:a.defaultError}:{message:u??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 Jt,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(Xl(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 y7(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 $i(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=>$i(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(Xl(o)?o:Promise.resolve(o));return y7(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:x.custom,...r(o)});return typeof Promise<"u"&&i instanceof Promise?i.then(u=>u?!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 wr({schema:this,typeName:ee.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 kr.create(this,this._def)}nullable(){return Ho.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return xs.create(this)}promise(){return Wi.create(this,this._def)}or(e){return cu.create([this,e],this._def)}and(e){return lu.create(this,e,this._def)}transform(e){return new wr({...ae(this._def),schema:this,typeName:ee.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let n=typeof e=="function"?e:()=>e;return new _u({...ae(this._def),innerType:this,defaultValue:n,typeName:ee.ZodDefault})}brand(){return new em({typeName:ee.ZodBranded,type:this,...ae(this._def)})}catch(e){let n=typeof e=="function"?e:()=>e;return new hu({...ae(this._def),innerType:this,catchValue:n,typeName:ee.ZodCatch})}describe(e){let n=this.constructor;return new n({...this._def,description:e})}pipe(e){return tm.create(this,e)}readonly(){return gu.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},mPe=/^c[^\s-]{8,}$/i,_Pe=/^[0-9a-z]+$/,hPe=/^[0-9A-HJKMNP-TV-Z]{26}$/i,gPe=/^[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,TPe=/^[a-z0-9_-]{21}$/i,EPe=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,SPe=/^[-+]?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)?)??$/,APe=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,yPe="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",tx,bPe=/^(?:(?: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])$/,RPe=/^(?:(?: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])$/,IPe=/^(([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]))$/,OPe=/^(([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])$/,CPe=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,NPe=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,R7="((\\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])))",xPe=new RegExp(`^${R7}$`);function I7(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 PPe(t){return new RegExp(`^${I7(t)}$`)}function O7(t){let e=`${R7}T${I7(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 MPe(t,e){return!!((e==="v4"||!e)&&bPe.test(t)||(e==="v6"||!e)&&IPe.test(t))}function vPe(t,e){if(!EPe.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 kPe(t,e){return!!((e==="v4"||!e)&&RPe.test(t)||(e==="v6"||!e)&&OPe.test(t))}var zi=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 k(s,{code:x.invalid_type,expected:D.string,received:s.parsedType}),J}let r=new Jt,o;for(let s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(o=this._getOrReturnCtx(e,o),k(o,{code:x.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),k(o,{code:x.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?k(o,{code:x.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):a&&k(o,{code:x.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),r.dirty())}else if(s.kind==="email")APe.test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"email",code:x.invalid_string,message:s.message}),r.dirty());else if(s.kind==="emoji")tx||(tx=new RegExp(yPe,"u")),tx.test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"emoji",code:x.invalid_string,message:s.message}),r.dirty());else if(s.kind==="uuid")gPe.test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"uuid",code:x.invalid_string,message:s.message}),r.dirty());else if(s.kind==="nanoid")TPe.test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"nanoid",code:x.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid")mPe.test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"cuid",code:x.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid2")_Pe.test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"cuid2",code:x.invalid_string,message:s.message}),r.dirty());else if(s.kind==="ulid")hPe.test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"ulid",code:x.invalid_string,message:s.message}),r.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{o=this._getOrReturnCtx(e,o),k(o,{validation:"url",code:x.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),k(o,{validation:"regex",code:x.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),k(o,{code:x.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),k(o,{code:x.invalid_string,validation:{startsWith:s.value},message:s.message}),r.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(o=this._getOrReturnCtx(e,o),k(o,{code:x.invalid_string,validation:{endsWith:s.value},message:s.message}),r.dirty()):s.kind==="datetime"?O7(s).test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{code:x.invalid_string,validation:"datetime",message:s.message}),r.dirty()):s.kind==="date"?xPe.test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{code:x.invalid_string,validation:"date",message:s.message}),r.dirty()):s.kind==="time"?PPe(s).test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{code:x.invalid_string,validation:"time",message:s.message}),r.dirty()):s.kind==="duration"?SPe.test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"duration",code:x.invalid_string,message:s.message}),r.dirty()):s.kind==="ip"?MPe(e.data,s.version)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"ip",code:x.invalid_string,message:s.message}),r.dirty()):s.kind==="jwt"?vPe(e.data,s.alg)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"jwt",code:x.invalid_string,message:s.message}),r.dirty()):s.kind==="cidr"?kPe(e.data,s.version)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"cidr",code:x.invalid_string,message:s.message}),r.dirty()):s.kind==="base64"?CPe.test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"base64",code:x.invalid_string,message:s.message}),r.dirty()):s.kind==="base64url"?NPe.test(e.data)||(o=this._getOrReturnCtx(e,o),k(o,{validation:"base64url",code:x.invalid_string,message:s.message}),r.dirty()):fe.assertNever(s);return{status:r.value,value:e.data}}_regex(e,n,r){return this.refinement(o=>e.test(o),{validation:n,code:x.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}};zi.create=t=>new zi({checks:[],typeName:ee.ZodString,coerce:t?.coerce??!1,...ae(t)});function LPe(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 ru=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 k(s,{code:x.invalid_type,expected:D.number,received:s.parsedType}),J}let r,o=new Jt;for(let s of this._def.checks)s.kind==="int"?fe.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),k(r,{code:x.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),k(r,{code:x.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),k(r,{code:x.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),o.dirty()):s.kind==="multipleOf"?LPe(e.data,s.value)!==0&&(r=this._getOrReturnCtx(e,r),k(r,{code:x.not_multiple_of,multipleOf:s.value,message:s.message}),o.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),k(r,{code:x.not_finite,message:s.message}),o.dirty()):fe.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"&&fe.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)}};ru.create=t=>new ru({checks:[],typeName:ee.ZodNumber,coerce:t?.coerce||!1,...ae(t)});var ou=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 Jt;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),k(r,{code:x.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),k(r,{code:x.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),k(r,{code:x.not_multiple_of,multipleOf:s.value,message:s.message}),o.dirty()):fe.assertNever(s);return{status:o.value,value:e.data}}_getInvalidInput(e){let n=this._getOrReturnCtx(e);return k(n,{code:x.invalid_type,expected:D.bigint,received:n.parsedType}),J}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}};ou.create=t=>new ou({checks:[],typeName:ee.ZodBigInt,coerce:t?.coerce??!1,...ae(t)});var su=class extends ce{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==D.boolean){let r=this._getOrReturnCtx(e);return k(r,{code:x.invalid_type,expected:D.boolean,received:r.parsedType}),J}return dn(e.data)}};su.create=t=>new su({typeName:ee.ZodBoolean,coerce:t?.coerce||!1,...ae(t)});var iu=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 k(s,{code:x.invalid_type,expected:D.date,received:s.parsedType}),J}if(Number.isNaN(e.data.getTime())){let s=this._getOrReturnCtx(e);return k(s,{code:x.invalid_date}),J}let r=new Jt,o;for(let s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(o=this._getOrReturnCtx(e,o),k(o,{code:x.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),k(o,{code:x.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),r.dirty()):fe.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}};iu.create=t=>new iu({checks:[],coerce:t?.coerce||!1,typeName:ee.ZodDate,...ae(t)});var ed=class extends ce{_parse(e){if(this._getType(e)!==D.symbol){let r=this._getOrReturnCtx(e);return k(r,{code:x.invalid_type,expected:D.symbol,received:r.parsedType}),J}return dn(e.data)}};ed.create=t=>new ed({typeName:ee.ZodSymbol,...ae(t)});var au=class extends ce{_parse(e){if(this._getType(e)!==D.undefined){let r=this._getOrReturnCtx(e);return k(r,{code:x.invalid_type,expected:D.undefined,received:r.parsedType}),J}return dn(e.data)}};au.create=t=>new au({typeName:ee.ZodUndefined,...ae(t)});var uu=class extends ce{_parse(e){if(this._getType(e)!==D.null){let r=this._getOrReturnCtx(e);return k(r,{code:x.invalid_type,expected:D.null,received:r.parsedType}),J}return dn(e.data)}};uu.create=t=>new uu({typeName:ee.ZodNull,...ae(t)});var Yi=class extends ce{constructor(){super(...arguments),this._any=!0}_parse(e){return dn(e.data)}};Yi.create=t=>new Yi({typeName:ee.ZodAny,...ae(t)});var Ns=class extends ce{constructor(){super(...arguments),this._unknown=!0}_parse(e){return dn(e.data)}};Ns.create=t=>new Ns({typeName:ee.ZodUnknown,...ae(t)});var ro=class extends ce{_parse(e){let n=this._getOrReturnCtx(e);return k(n,{code:x.invalid_type,expected:D.never,received:n.parsedType}),J}};ro.create=t=>new ro({typeName:ee.ZodNever,...ae(t)});var td=class extends ce{_parse(e){if(this._getType(e)!==D.undefined){let r=this._getOrReturnCtx(e);return k(r,{code:x.invalid_type,expected:D.void,received:r.parsedType}),J}return dn(e.data)}};td.create=t=>new td({typeName:ee.ZodVoid,...ae(t)});var xs=class t extends ce{_parse(e){let{ctx:n,status:r}=this._processInputParams(e),o=this._def;if(n.parsedType!==D.array)return k(n,{code:x.invalid_type,expected:D.array,received:n.parsedType}),J;if(o.exactLength!==null){let i=n.data.length>o.exactLength.value,a=n.data.length<o.exactLength.value;(i||a)&&(k(n,{code:i?x.too_big:x.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&&(k(n,{code:x.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&&(k(n,{code:x.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 Lr(n,i,n.path,a)))).then(i=>Jt.mergeArray(r,i));let s=[...n.data].map((i,a)=>o.type._parseSync(new Lr(n,i,n.path,a)));return Jt.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)}};xs.create=(t,e)=>new xs({type:t,minLength:null,maxLength:null,exactLength:null,typeName:ee.ZodArray,...ae(e)});function Zl(t){if(t instanceof Vn){let e={};for(let n in t.shape){let r=t.shape[n];e[n]=kr.create(Zl(r))}return new Vn({...t._def,shape:()=>e})}else return t instanceof xs?new xs({...t._def,type:Zl(t.element)}):t instanceof kr?kr.create(Zl(t.unwrap())):t instanceof Ho?Ho.create(Zl(t.unwrap())):t instanceof jo?jo.create(t.items.map(e=>Zl(e))):t}var Vn=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=fe.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 k(l,{code:x.invalid_type,expected:D.object,received:l.parsedType}),J}let{status:r,ctx:o}=this._processInputParams(e),{shape:s,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof ro&&this._def.unknownKeys==="strip"))for(let l in o.data)i.includes(l)||a.push(l);let u=[];for(let l of i){let d=s[l],p=o.data[l];u.push({key:{status:"valid",value:l},value:d._parse(new Lr(o,p,o.path,l)),alwaysSet:l in o.data})}if(this._def.catchall instanceof ro){let l=this._def.unknownKeys;if(l==="passthrough")for(let d of a)u.push({key:{status:"valid",value:d},value:{status:"valid",value:o.data[d]}});else if(l==="strict")a.length>0&&(k(o,{code:x.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 d of a){let p=o.data[d];u.push({key:{status:"valid",value:d},value:l._parse(new Lr(o,p,o.path,d)),alwaysSet:d in o.data})}}return o.common.async?Promise.resolve().then(async()=>{let l=[];for(let d of u){let p=await d.key,f=await d.value;l.push({key:p,value:f,alwaysSet:d.alwaysSet})}return l}).then(l=>Jt.mergeObjectSync(r,l)):Jt.mergeObjectSync(r,u)}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:ee.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 fe.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 fe.objectKeys(this.shape))e[r]||(n[r]=this.shape[r]);return new t({...this._def,shape:()=>n})}deepPartial(){return Zl(this)}partial(e){let n={};for(let r of fe.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 fe.objectKeys(this.shape))if(e&&!e[r])n[r]=this.shape[r];else{let s=this.shape[r];for(;s instanceof kr;)s=s._def.innerType;n[r]=s}return new t({...this._def,shape:()=>n})}keyof(){return C7(fe.objectKeys(this.shape))}};Vn.create=(t,e)=>new Vn({shape:()=>t,unknownKeys:"strip",catchall:ro.create(),typeName:ee.ZodObject,...ae(e)});Vn.strictCreate=(t,e)=>new Vn({shape:()=>t,unknownKeys:"strict",catchall:ro.create(),typeName:ee.ZodObject,...ae(e)});Vn.lazycreate=(t,e)=>new Vn({shape:t,unknownKeys:"strip",catchall:ro.create(),typeName:ee.ZodObject,...ae(e)});var cu=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 Hn(a.ctx.common.issues));return k(n,{code:x.invalid_union,unionErrors:i}),J}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 u of r){let l={...n,common:{...n.common,issues:[]},parent:null},d=u._parseSync({data:n.data,path:n.path,parent:l});if(d.status==="valid")return d;d.status==="dirty"&&!s&&(s={result:d,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(u=>new Hn(u));return k(n,{code:x.invalid_union,unionErrors:a}),J}}get options(){return this._def.options}};cu.create=(t,e)=>new cu({options:t,typeName:ee.ZodUnion,...ae(e)});var Cs=t=>t instanceof du?Cs(t.schema):t instanceof wr?Cs(t.innerType()):t instanceof pu?[t.value]:t instanceof fu?t.options:t instanceof mu?fe.objectValues(t.enum):t instanceof _u?Cs(t._def.innerType):t instanceof au?[void 0]:t instanceof uu?[null]:t instanceof kr?[void 0,...Cs(t.unwrap())]:t instanceof Ho?[null,...Cs(t.unwrap())]:t instanceof em||t instanceof gu?Cs(t.unwrap()):t instanceof hu?Cs(t._def.innerType):[],o0=class t extends ce{_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==D.object)return k(n,{code:x.invalid_type,expected:D.object,received:n.parsedType}),J;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}):(k(n,{code:x.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),J)}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=Cs(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:ee.ZodDiscriminatedUnion,discriminator:e,options:n,optionsMap:o,...ae(r)})}};function nx(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=fe.objectKeys(e),s=fe.objectKeys(t).filter(a=>o.indexOf(a)!==-1),i={...t,...e};for(let a of s){let u=nx(t[a],e[a]);if(!u.valid)return{valid:!1};i[a]=u.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],u=nx(i,a);if(!u.valid)return{valid:!1};o.push(u.data)}return{valid:!0,data:o}}else return n===D.date&&r===D.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}var lu=class extends ce{_parse(e){let{status:n,ctx:r}=this._processInputParams(e),o=(s,i)=>{if(n0(s)||n0(i))return J;let a=nx(s.value,i.value);return a.valid?((r0(s)||r0(i))&&n.dirty(),{status:n.value,value:a.data}):(k(r,{code:x.invalid_intersection_types}),J)};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}))}};lu.create=(t,e,n)=>new lu({left:t,right:e,typeName:ee.ZodIntersection,...ae(n)});var jo=class t extends ce{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==D.array)return k(r,{code:x.invalid_type,expected:D.array,received:r.parsedType}),J;if(r.data.length<this._def.items.length)return k(r,{code:x.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),J;!this._def.rest&&r.data.length>this._def.items.length&&(k(r,{code:x.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());let s=[...r.data].map((i,a)=>{let u=this._def.items[a]||this._def.rest;return u?u._parse(new Lr(r,i,r.path,a)):null}).filter(i=>!!i);return r.common.async?Promise.all(s).then(i=>Jt.mergeArray(n,i)):Jt.mergeArray(n,s)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};jo.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new jo({items:t,typeName:ee.ZodTuple,rest:null,...ae(e)})};var s0=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 k(r,{code:x.invalid_type,expected:D.object,received:r.parsedType}),J;let o=[],s=this._def.keyType,i=this._def.valueType;for(let a in r.data)o.push({key:s._parse(new Lr(r,a,r.path,a)),value:i._parse(new Lr(r,r.data[a],r.path,a)),alwaysSet:a in r.data});return r.common.async?Jt.mergeObjectAsync(n,o):Jt.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:ee.ZodRecord,...ae(r)}):new t({keyType:zi.create(),valueType:e,typeName:ee.ZodRecord,...ae(n)})}},nd=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 k(r,{code:x.invalid_type,expected:D.map,received:r.parsedType}),J;let o=this._def.keyType,s=this._def.valueType,i=[...r.data.entries()].map(([a,u],l)=>({key:o._parse(new Lr(r,a,r.path,[l,"key"])),value:s._parse(new Lr(r,u,r.path,[l,"value"]))}));if(r.common.async){let a=new Map;return Promise.resolve().then(async()=>{for(let u of i){let l=await u.key,d=await u.value;if(l.status==="aborted"||d.status==="aborted")return J;(l.status==="dirty"||d.status==="dirty")&&n.dirty(),a.set(l.value,d.value)}return{status:n.value,value:a}})}else{let a=new Map;for(let u of i){let l=u.key,d=u.value;if(l.status==="aborted"||d.status==="aborted")return J;(l.status==="dirty"||d.status==="dirty")&&n.dirty(),a.set(l.value,d.value)}return{status:n.value,value:a}}}};nd.create=(t,e,n)=>new nd({valueType:e,keyType:t,typeName:ee.ZodMap,...ae(n)});var rd=class t extends ce{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==D.set)return k(r,{code:x.invalid_type,expected:D.set,received:r.parsedType}),J;let o=this._def;o.minSize!==null&&r.data.size<o.minSize.value&&(k(r,{code:x.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&&(k(r,{code:x.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(u){let l=new Set;for(let d of u){if(d.status==="aborted")return J;d.status==="dirty"&&n.dirty(),l.add(d.value)}return{status:n.value,value:l}}let a=[...r.data.values()].map((u,l)=>s._parse(new Lr(r,u,r.path,l)));return r.common.async?Promise.all(a).then(u=>i(u)):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)}};rd.create=(t,e)=>new rd({valueType:t,minSize:null,maxSize:null,typeName:ee.ZodSet,...ae(e)});var i0=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 k(n,{code:x.invalid_type,expected:D.function,received:n.parsedType}),J;function r(a,u){return Zf({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Jl(),Os].filter(l=>!!l),issueData:{code:x.invalid_arguments,argumentsError:u}})}function o(a,u){return Zf({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Jl(),Os].filter(l=>!!l),issueData:{code:x.invalid_return_type,returnTypeError:u}})}let s={errorMap:n.common.contextualErrorMap},i=n.data;if(this._def.returns instanceof Wi){let a=this;return dn(async function(...u){let l=new Hn([]),d=await a._def.args.parseAsync(u,s).catch(m=>{throw l.addIssue(r(u,m)),l}),p=await Reflect.apply(i,this,d);return await a._def.returns._def.type.parseAsync(p,s).catch(m=>{throw l.addIssue(o(p,m)),l})})}else{let a=this;return dn(function(...u){let l=a._def.args.safeParse(u,s);if(!l.success)throw new Hn([r(u,l.error)]);let d=Reflect.apply(i,this,l.data),p=a._def.returns.safeParse(d,s);if(!p.success)throw new Hn([o(d,p.error)]);return p.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:jo.create(e).rest(Ns.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||jo.create([]).rest(Ns.create()),returns:n||Ns.create(),typeName:ee.ZodFunction,...ae(r)})}},du=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})}};du.create=(t,e)=>new du({getter:t,typeName:ee.ZodLazy,...ae(e)});var pu=class extends ce{_parse(e){if(e.data!==this._def.value){let n=this._getOrReturnCtx(e);return k(n,{received:n.data,code:x.invalid_literal,expected:this._def.value}),J}return{status:"valid",value:e.data}}get value(){return this._def.value}};pu.create=(t,e)=>new pu({value:t,typeName:ee.ZodLiteral,...ae(e)});function C7(t,e){return new fu({values:t,typeName:ee.ZodEnum,...ae(e)})}var fu=class t extends ce{_parse(e){if(typeof e.data!="string"){let n=this._getOrReturnCtx(e),r=this._def.values;return k(n,{expected:fe.joinValues(r),received:n.parsedType,code:x.invalid_type}),J}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 k(n,{received:n.data,code:x.invalid_enum_value,options:r}),J}return dn(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})}};fu.create=C7;var mu=class extends ce{_parse(e){let n=fe.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==D.string&&r.parsedType!==D.number){let o=fe.objectValues(n);return k(r,{expected:fe.joinValues(o),received:r.parsedType,code:x.invalid_type}),J}if(this._cache||(this._cache=new Set(fe.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let o=fe.objectValues(n);return k(r,{received:r.data,code:x.invalid_enum_value,options:o}),J}return dn(e.data)}get enum(){return this._def.values}};mu.create=(t,e)=>new mu({values:t,typeName:ee.ZodNativeEnum,...ae(e)});var Wi=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 k(n,{code:x.invalid_type,expected:D.promise,received:n.parsedType}),J;let r=n.parsedType===D.promise?n.data:Promise.resolve(n.data);return dn(r.then(o=>this._def.type.parseAsync(o,{path:n.path,errorMap:n.common.contextualErrorMap})))}};Wi.create=(t,e)=>new Wi({type:t,typeName:ee.ZodPromise,...ae(e)});var wr=class extends ce{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===ee.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=>{k(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 J;let u=await this._def.schema._parseAsync({data:a,path:r.path,parent:r});return u.status==="aborted"?J:u.status==="dirty"?nu(u.value):n.value==="dirty"?nu(u.value):u});{if(n.value==="aborted")return J;let a=this._def.schema._parseSync({data:i,path:r.path,parent:r});return a.status==="aborted"?J:a.status==="dirty"?nu(a.value):n.value==="dirty"?nu(a.value):a}}if(o.type==="refinement"){let i=a=>{let u=o.refinement(a,s);if(r.common.async)return Promise.resolve(u);if(u 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"?J:(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"?J:(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(!$i(i))return J;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=>$i(i)?Promise.resolve(o.transform(i.value,s)).then(a=>({status:n.value,value:a})):J);fe.assertNever(o)}};wr.create=(t,e,n)=>new wr({schema:t,typeName:ee.ZodEffects,effect:e,...ae(n)});wr.createWithPreprocess=(t,e,n)=>new wr({schema:e,effect:{type:"preprocess",transform:t},typeName:ee.ZodEffects,...ae(n)});var kr=class extends ce{_parse(e){return this._getType(e)===D.undefined?dn(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};kr.create=(t,e)=>new kr({innerType:t,typeName:ee.ZodOptional,...ae(e)});var Ho=class extends ce{_parse(e){return this._getType(e)===D.null?dn(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Ho.create=(t,e)=>new Ho({innerType:t,typeName:ee.ZodNullable,...ae(e)});var _u=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}};_u.create=(t,e)=>new _u({innerType:t,typeName:ee.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...ae(e)});var hu=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 Xl(o)?o.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Hn(r.common.issues)},input:r.data})})):{status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new Hn(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}};hu.create=(t,e)=>new hu({innerType:t,typeName:ee.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...ae(e)});var od=class extends ce{_parse(e){if(this._getType(e)!==D.nan){let r=this._getOrReturnCtx(e);return k(r,{code:x.invalid_type,expected:D.nan,received:r.parsedType}),J}return{status:"valid",value:e.data}}};od.create=t=>new od({typeName:ee.ZodNaN,...ae(t)});var wPe=Symbol("zod_brand"),em=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}},tm=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"?J:s.status==="dirty"?(n.dirty(),nu(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"?J: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:ee.ZodPipeline})}},gu=class extends ce{_parse(e){let n=this._def.innerType._parse(e),r=o=>($i(o)&&(o.value=Object.freeze(o.value)),o);return Xl(n)?n.then(o=>r(o)):r(n)}unwrap(){return this._def.innerType}};gu.create=(t,e)=>new gu({innerType:t,typeName:ee.ZodReadonly,...ae(e)});function b7(t,e){let n=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof n=="string"?{message:n}:n}function N7(t,e={},n){return t?Yi.create().superRefine((r,o)=>{let s=t(r);if(s instanceof Promise)return s.then(i=>{if(!i){let a=b7(e,r),u=a.fatal??n??!0;o.addIssue({code:"custom",...a,fatal:u})}});if(!s){let i=b7(e,r),a=i.fatal??n??!0;o.addIssue({code:"custom",...i,fatal:a})}}):Yi.create()}var DPe={object:Vn.lazycreate},ee;(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"})(ee||(ee={}));var UPe=(t,e={message:`Input not instance of ${t.name}`})=>N7(n=>n instanceof t,e),x7=zi.create,P7=ru.create,BPe=od.create,FPe=ou.create,M7=su.create,GPe=iu.create,jPe=ed.create,HPe=au.create,VPe=uu.create,qPe=Yi.create,$Pe=Ns.create,zPe=ro.create,YPe=td.create,WPe=xs.create,KPe=Vn.create,QPe=Vn.strictCreate,JPe=cu.create,XPe=o0.create,ZPe=lu.create,e1e=jo.create,t1e=s0.create,n1e=nd.create,r1e=rd.create,o1e=i0.create,s1e=du.create,i1e=pu.create,a1e=fu.create,u1e=mu.create,c1e=Wi.create,l1e=wr.create,d1e=kr.create,p1e=Ho.create,f1e=wr.createWithPreprocess,m1e=tm.create,_1e=()=>x7().optional(),h1e=()=>P7().optional(),g1e=()=>M7().optional(),T1e={string:t=>zi.create({...t,coerce:!0}),number:t=>ru.create({...t,coerce:!0}),boolean:t=>su.create({...t,coerce:!0}),bigint:t=>ou.create({...t,coerce:!0}),date:t=>iu.create({...t,coerce:!0})};var E1e=J;var S1e=t=>typeof t?.safeParse=="function";var rx=t=>typeof t?.passthrough=="function";var A1e=(t,e)=>rx(t)?rx(e)?t.merge(e):t:rx(e)?e:Object.assign({},t,e);var est=c.object({name:c.literal("ZodError"),issues:c.array(c.object({path:c.array(c.union([c.string(),c.number()])),message:c.string().optional(),code:c.nativeEnum(c.ZodIssueCode)}).catchall(c.any()))}),y1e=Symbol("ContractNoBody"),k7=t=>"method"in t&&"path"in t;var L7=(t,e)=>Object.fromEntries(Object.entries(t).map(([n,r])=>{var o,s,i;return k7(r)?[n,{...r,path:e?.pathPrefix?e.pathPrefix+r.path:r.path,headers:A1e(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,L7(r,e)]})),ox=Symbol("ContractPlainType"),Dr=()=>({router:(t,e)=>L7(t,e),query:t=>t,mutation:t=>t,responses:t=>t,response:()=>ox,body:()=>ox,type:()=>ox,otherResponse:({contentType:t,body:e})=>({contentType:t,body:e}),noBody:()=>y1e}),b1e=({path:t,params:e})=>{let n=e;return t.replace(/\/?:([^/?]+)\??/g,(r,o)=>n[o]?`${r.startsWith("/")?"/":""}${n[o]}`:"")},R1e=(t,e=!1)=>{let n=e?I1e(t):O1e(t);return n?.length>0?"?"+n:""},I1e=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("&"):"",O1e=t=>t?Object.keys(t).flatMap(e=>sx(e,t[e])).map(([e,n])=>`${encodeURIComponent(e)}=${encodeURIComponent(n)}`).join("&"):"",sx=(t,e)=>Array.isArray(e)?e.flatMap((n,r)=>sx(`${t}[${r}]`,n)):e instanceof Date?[[`${t}`,e.toISOString()]]:e===null?[[`${t}`,""]]:e===void 0?[]:typeof e=="object"?Object.keys(e).flatMap(n=>sx(`${t}[${n}]`,e[n])):[[`${t}`,`${e}`]];var ix=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 C1e=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}),u=a.headers.get("content-type");if(u?.includes("application/")&&u?.includes("json")){let l={status:a.status,body:await a.json(),headers:a.headers},d=t.responses[l.status];return(s??t.validateResponseOnClient)&&S1e(d)?{...l,body:d.parse(l.body)}:l}return u?.includes("text/")?{status:a.status,body:await a.text(),headers:a.headers}:{status:a.status,body:await a.blob(),headers:a.headers}},N1e=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},v7=t=>Object.fromEntries(Object.entries(t).map(([e,n])=>[e.toLowerCase(),n])),x1e=t=>{let{path:e,clientArgs:n,route:r,body:o,query:s,extraInputArgs:i,headers:a,fetchOptions:u}=t,l=n.api||C1e,d=n.baseHeaders&&Object.fromEntries(Object.entries(n.baseHeaders).map(([m,_])=>typeof _=="function"?[m,_(t)]:[m,_])),p={...d&&v7(d),...v7(a)};Object.keys(p).forEach(m=>{p[m]===void 0&&delete p[m]});let f={route:r,path:e,method:r.method,headers:p,body:void 0,rawBody:o,rawQuery:s,contentType:void 0,validateResponse:n.validateResponse,fetchOptions:{...n.credentials&&{credentials:n.credentials},...u},...u?.signal&&{signal:u.signal},...u?.cache&&{cache:u.cache},...u&&"next"in u&&!!u?.next&&{next:u.next}};return r.method!=="GET"&&("contentType"in r&&r.contentType==="multipart/form-data"?f={...f,contentType:"multipart/form-data",body:o instanceof FormData?o:N1e(o)}:"contentType"in r&&r.contentType==="application/x-www-form-urlencoded"?f={...f,contentType:"application/x-www-form-urlencoded",headers:{"content-type":"application/x-www-form-urlencoded",...f.headers},body:typeof o=="string"?o:new URLSearchParams(o)}:o!=null&&(f={...f,contentType:"application/json",headers:{"content-type":"application/json",...f.headers},body:JSON.stringify(o)})),l({...f,...i})},P1e=(t,e,n)=>{let{query:r,params:o,body:s,headers:i,extraHeaders:a,overrideClientOptions:u,fetchOptions:l,cache:d,next:p,...f}=n||{},m={...e,...u};return{path:M1e(r,m.baseUrl,o,t,!!m.jsonQuery),clientArgs:m,route:t,body:s,query:r,extraInputArgs:f,fetchOptions:{...d&&{cache:d},...p&&{next:p},...l},headers:{...a,...i}}},M1e=(t,e,n,r,o)=>{let s=b1e({path:r.path,params:n}),i=R1e(t,o);return`${e}${s}${i}`},v1e=(t,e)=>{let n=Object.keys(t.responses);return async r=>{let o=P1e(t,e,r),s=await x1e(o);if(!e.throwOnUnknownStatus||n.includes(s.status.toString()))return s;throw new ix(s,n)}},ax=(t,e)=>Object.fromEntries(Object.entries(t).map(([n,r])=>k7(r)?[n,v1e(r,e)]:[n,ax(r,e)]));var ux=["free","creator","team"],w7=typeof process<"u"&&process.env?.NODE_ENV!=="production",k1e={stripe:{plans:[{tier:"free",subjectType:"user",name:"Free",description:"Share any thread from Claude Code, Codex, or Cowork. Share with friends or keep private. Share skills with your team instantly.",price:0,priceId:null,features:[{name:"Share threads from Claude Code, Codex, and Cowork"},{name:"Share with friends or keep private"},{name:"Skills tab \u2014 tool usage across every thread"},{name:"Share skills with your team instantly"}],entitlements:{workspaceScope:!1,review:!1,sharedThreadTtlDays:3}},{tier:"creator",subjectType:"user",name:"Creator",description:"For builders who share a lot. Permanent share links that never expire.",price:29,isFeatured:!0,priceId:w7?"price_1TP9BSKwvRM43sh64waIrvjj":"price_1TPA2gKwvRM43sh6Kp4ZCpJZ",features:[{name:"Everything in Free"},{name:"Shared threads live forever"}],entitlements:{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:w7?"price_1TP9MpKwvRM43sh6TBIFxVCd":"price_1TPA3CKwvRM43sh6k0bgPTsQ",features:[{name:"Everything in Creator"},{name:"Workspace-wide thread sharing"},{name:"Minimum 2 seats"},{name:"Review feature (beta)"}],entitlements:{workspaceScope:!0,review:!0,sharedThreadTtlDays:null}}]}};var D7=k1e.stripe.plans,nst=Object.freeze(Object.fromEntries(D7.map(t=>[t.tier,t])));var L1e=Dr(),pn=c.object({message:c.string()}),cx=c.record(c.unknown()),Tu=c.string().regex(/^doc_[0-9A-Za-z]{22}$/),a0=c.string().regex(/^proj_[0-9A-Za-z]{22}$/),w1e=["active","archived"],u0=c.enum(w1e),U7=c.object({id:c.string().min(1),display_name:c.string().min(1)}),B7=c.object({id:a0,name:c.string().min(1)}),lx=c.object({id:Tu,title:c.string().min(1),status:u0,author:U7,project:B7.nullable(),created_at:c.string().datetime(),updated_at:c.string().datetime(),archived_at:c.string().datetime().nullable()}),D1e=c.object({type:c.literal("list"),list_type:c.literal("doc"),objects:c.array(lx)}),U1e=c.object({project_id:a0.optional(),status:u0.optional()}),B1e=c.object({title:c.string().trim().min(1).max(300).optional(),prosemirror_json:cx.optional(),project_id:a0.nullable().optional()}),F1e=c.object({id:Tu,created_at:c.string().datetime()}),G1e=c.object({title:c.string().trim().min(1).max(300).optional(),prosemirror_json:cx.optional(),project_id:a0.nullable().optional(),status:u0.optional()}).refine(t=>Object.keys(t).length>0,{message:"At least one field must be provided"}),j1e=c.object({id:Tu,updated_at:c.string().datetime()}),H1e=c.object({id:Tu,title:c.string().min(1),prosemirror_json:cx,status:u0,author:U7,project:B7.nullable(),created_at:c.string().datetime(),updated_at:c.string().datetime(),archived_at:c.string().datetime().nullable()}),F7=L1e.router({listDocs:{method:"GET",path:"/docs",headers:c.object({authorization:c.string().min(1).optional()}),query:U1e,responses:{200:D1e,401:pn,403:pn},summary:"List docs in the authenticated user\u2019s organization. Optional project_id filter scopes to a single project."},createDoc:{method:"POST",path:"/docs",headers:c.object({authorization:c.string().min(1).optional()}),body:B1e,responses:{201:F1e,401:pn,403:pn,404:pn,422:pn},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:c.object({docId:Tu}),headers:c.object({authorization:c.string().min(1).optional()}),responses:{200:H1e,401:pn,403:pn,404:pn},summary:"Get a doc by id with its rich-text body and parent project (if any)"},updateDoc:{method:"PATCH",path:"/docs/:docId",pathParams:c.object({docId:Tu}),headers:c.object({authorization:c.string().min(1).optional()}),body:G1e,responses:{200:j1e,401:pn,403:pn,404:pn,422:pn},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:c.object({docId:Tu}),headers:c.object({authorization:c.string().min(1).optional()}),body:c.object({}).optional(),responses:{204:c.object({}),401:pn,403:pn,404:pn},summary:"Hard-delete a doc and any mention references it owns"}});var V1e=Dr(),it=c.object({message:c.string()}),dx=c.record(c.unknown()),Vo=c.string().regex(/^proj_[0-9A-Za-z]{22}$/),q1e=["active","archived"],c0=c.enum(q1e),px=c.object({id:c.string().min(1),display_name:c.string().min(1)}),G7=c.object({thread_id:c.string().min(1),title:c.string().min(1),added_at:c.string().datetime(),added_by:px}),$1e=c.object({id:Vo,name:c.string().min(1),status:c0,author:px,thread_count:c.number().int().nonnegative(),doc_count:c.number().int().nonnegative(),created_at:c.string().datetime(),updated_at:c.string().datetime(),archived_at:c.string().datetime().nullable()}),z1e=c.object({type:c.literal("list"),list_type:c.literal("project"),objects:c.array($1e)}),Y1e=c.object({status:c0.optional()}),W1e=c.object({name:c.string().trim().min(1).max(200),prosemirror_json:dx.optional()}),K1e=c.object({id:Vo,created_at:c.string().datetime()}),Q1e=c.object({name:c.string().trim().min(1).max(200).optional(),prosemirror_json:dx.optional()}).refine(t=>Object.keys(t).length>0,{message:"At least one field must be provided"}),J1e=c.object({id:Vo,updated_at:c.string().datetime()}),X1e=c.object({archived:c.boolean()}),Z1e=c.object({id:Vo,status:c0,archived_at:c.string().datetime().nullable()}),eMe=c.object({id:Vo,name:c.string().min(1),prosemirror_json:dx,status:c0,author:px,created_at:c.string().datetime(),updated_at:c.string().datetime(),archived_at:c.string().datetime().nullable(),threads:c.array(G7),docs:c.array(lx)}),tMe=c.object({thread_id:c.string().min(1).max(64)}),nMe=G7,j7=V1e.router({listProjects:{method:"GET",path:"/projects",headers:c.object({authorization:c.string().min(1).optional()}),query:Y1e,responses:{200:z1e,401:it},summary:"List projects in the authenticated user\u2019s organization"},createProject:{method:"POST",path:"/projects",headers:c.object({authorization:c.string().min(1).optional()}),body:W1e,responses:{201:K1e,401:it,422:it},summary:"Create a new project in the authenticated user\u2019s organization"},getProject:{method:"GET",path:"/projects/:projectId",pathParams:c.object({projectId:Vo}),headers:c.object({authorization:c.string().min(1).optional()}),responses:{200:eMe,401:it,403:it,404:it},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:c.object({projectId:Vo}),headers:c.object({authorization:c.string().min(1).optional()}),body:Q1e,responses:{200:J1e,401:it,403:it,404:it,422:it},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:c.object({projectId:Vo}),headers:c.object({authorization:c.string().min(1).optional()}),body:X1e,responses:{200:Z1e,401:it,403:it,404:it},summary:"Archive (soft-delete) or unarchive a project"},addProjectThread:{method:"POST",path:"/projects/:projectId/threads",pathParams:c.object({projectId:Vo}),headers:c.object({authorization:c.string().min(1).optional()}),body:tMe,responses:{201:nMe,401:it,403:it,404:it,409:it,422:it},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:c.object({projectId:Vo,threadId:c.string().min(1).max(64)}),headers:c.object({authorization:c.string().min(1).optional()}),body:c.object({}).optional(),responses:{204:c.object({}),401:it,403:it,404:it},summary:"Remove a thread membership from a project"}});var rMe=Dr(),l0=c.object({message:c.string()}),oMe=["thread","plan","doc","user"],d0=c.enum(oMe),sMe=["doc","project"],iMe=c.enum(sMe),aMe=c.object({kind:d0,id:c.string().min(1),title:c.string().min(1),href:c.string().min(1)}),uMe=c.object({type:c.literal("list"),list_type:c.literal("mention"),objects:c.array(aMe)}),cMe=c.object({q:c.string().trim().min(1).max(50),kinds:c.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(c.array(d0).optional())}),lMe=c.object({source_kind:iMe,source_id:c.string().min(1),source_title:c.string().min(1),source_href:c.string().min(1),target_kind:d0,target_id:c.string().min(1),created_at:c.string().datetime()}),dMe=c.object({type:c.literal("list"),list_type:c.literal("backlink"),objects:c.array(lMe)}),pMe=c.object({target_kind:d0,target_id:c.string().min(1).max(64)}),H7=rMe.router({searchMentions:{method:"GET",path:"/mentions/search",headers:c.object({authorization:c.string().min(1).optional()}),query:cMe,responses:{200:uMe,401:l0,422:l0},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:c.object({authorization:c.string().min(1).optional()}),query:pMe,responses:{200:dMe,401:l0,403:l0},summary:"List every doc/project body in the caller\u2019s organization that mentions the given target. Newest-first."}});var fMe=Dr(),mMe=c.object({type:c.literal("list"),list_type:c.literal("thread"),has_more:c.boolean(),objects:c.array(c.unknown())}),Ut=c.object({message:c.string()}),V7=c.object({thread_id:c.string().min(1),is_favorited:c.boolean(),favorited_at:c.string().datetime().nullable()}),_Me=c.object({before:c.string().min(1).max(64).optional()}),hMe=c.object({id:c.string().min(1),display_name:c.string().min(1)}),gMe=c.object({block_id:c.string().min(1),thread_id:c.string().min(1),thread_title:c.string(),thread_visibility:c.enum(["private","workspace","public"]),author:hMe,preview:c.string(),prompted_at:c.string().datetime().nullable(),favorited_at:c.string().datetime()}),TMe=c.object({type:c.literal("list"),list_type:c.literal("favorite_prompt"),has_more:c.boolean(),objects:c.array(gMe)}),q7=c.object({block_id:c.string().min(1),thread_id:c.string().min(1).nullable(),is_favorited:c.boolean(),favorited_at:c.string().datetime().nullable()}),EMe=c.object({before:c.string().min(1).max(64).optional()}),SMe=c.object({block_ids:c.array(c.string().min(1))}),$7=fMe.router({addThreadFavorite:{method:"POST",path:"/threads/:id/favorite",pathParams:c.object({id:c.string().min(1).max(64)}),headers:c.object({authorization:c.string().min(1).optional()}),body:c.object({}).optional(),responses:{201:V7,401:Ut,403:Ut,404:Ut},summary:"Bookmark a thread for the authenticated user. Idempotent \u2014 re-favoriting returns the existing membership."},removeThreadFavorite:{method:"DELETE",path:"/threads/:id/favorite",pathParams:c.object({id:c.string().min(1).max(64)}),headers:c.object({authorization:c.string().min(1).optional()}),body:c.object({}).optional(),responses:{200:V7,401:Ut,403:Ut,404:Ut},summary:"Remove a thread bookmark for the authenticated user (no-op if absent)."},listFavoriteThreads:{method:"GET",path:"/favorites/threads",headers:c.object({authorization:c.string().min(1).optional()}),query:_Me,responses:{200:mMe,401:Ut,403:Ut},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."},addPromptFavorite:{method:"POST",path:"/thread-blocks/:id/favorite",pathParams:c.object({id:c.string().min(1).max(64)}),headers:c.object({authorization:c.string().min(1).optional()}),body:c.object({}).optional(),responses:{201:q7,401:Ut,403:Ut,404:Ut,409:Ut},summary:'Bookmark a single user prompt (a thread_blocks row with type="user") for the authenticated user. Idempotent.'},removePromptFavorite:{method:"DELETE",path:"/thread-blocks/:id/favorite",pathParams:c.object({id:c.string().min(1).max(64)}),headers:c.object({authorization:c.string().min(1).optional()}),body:c.object({}).optional(),responses:{200:q7,401:Ut,404:Ut},summary:"Remove a prompt bookmark for the authenticated user (no-op if absent)."},listFavoritePrompts:{method:"GET",path:"/favorites/prompts",headers:c.object({authorization:c.string().min(1).optional()}),query:EMe,responses:{200:TMe,401:Ut},summary:"List the user's favorited prompts, newest first. Prompts whose parent thread the viewer can no longer see (visibility downgraded) are filtered out at read time."},listFavoritedBlockIdsInThread:{method:"GET",path:"/threads/:id/favorited-blocks",pathParams:c.object({id:c.string().min(1).max(64)}),headers:c.object({authorization:c.string().min(1).optional()}),responses:{200:SMe,401:Ut,403:Ut,404:Ut},summary:"Returns the set of thread_block ids the authenticated viewer has favorited within a single thread, used to bootstrap per-prompt star state on the SessionView."}});var AMe=Dr(),z7=c.object({message:c.string()}),yMe=c.object({id:c.string().min(1),title:c.string(),href:c.string().min(1),author_display_name:c.string().nullable(),author_handle:c.string().nullable()}),bMe=c.object({name:c.string().min(1),usage_count:c.number().int().nonnegative(),href:c.string().min(1)}),RMe=c.object({id:c.string().min(1),display_name:c.string(),handle:c.string().nullable(),avatar_url:c.string().nullable(),href:c.string().min(1)}),IMe=c.object({type:c.literal("global_search"),threads:c.array(yMe),skills:c.array(bMe),people:c.array(RMe)}),OMe=c.object({q:c.string().trim().min(1).max(80)}),Y7=AMe.router({globalSearch:{method:"GET",path:"/search",headers:c.object({authorization:c.string().min(1).optional()}),query:OMe,responses:{200:IMe,401:z7,422:z7},summary:"Global navbar search. Threads and people are searched globally (subject to thread visibility); skills are scoped to the viewer workspace. Max 5 results per kind."}});var CMe=Dr(),NMe=["gmail.com","googlemail.com","hotmail.com","outlook.com","live.com","msn.com","yahoo.com","ymail.com","rocketmail.com","icloud.com","me.com","mac.com","aol.com","proton.me","protonmail.com","pm.me","tutanota.com","tuta.io","fastmail.com","hey.com","mail.com","gmx.com","gmx.net","zoho.com","zohomail.com","hushmail.com","lycos.com","inbox.com","yandex.com","yandex.ru","mail.ru","inbox.ru","bk.ru","list.ru","rambler.ru","qq.com","163.com","126.com","yeah.net","sina.com","naver.com","daum.net","hanmail.net","kakao.com","rediffmail.com","comcast.net","verizon.net","att.net","sbcglobal.net","bellsouth.net","earthlink.net","charter.net","cox.net","roadrunner.com","spectrum.net","btinternet.com","virginmedia.com","sky.com","orange.fr","wanadoo.fr","free.fr","laposte.net","web.de","t-online.de","gmx.de","libero.it","virgilio.it","alice.it","seznam.cz","centrum.cz","wp.pl","interia.pl","o2.pl","onet.pl"],Fst=new Set(NMe);var xMe=c.object({id:c.string().uuid(),role:c.enum(["user","assistant"]),content:c.string().min(1),timestamp:c.string().datetime()}),PMe=c.object({id:c.string().uuid(),title:c.string().min(1),author:c.string().min(1),authorAvatar:c.string().min(1).max(4),model:c.string().min(1),turnCount:c.number().int().nonnegative(),createdAt:c.string().datetime(),preview:c.string()}),Gst=PMe.extend({messages:c.array(xMe)}),A=c.object({message:c.string()}),MMe=/^[a-zA-Z0-9_-]{2,32}$/,tW=c.string().regex(MMe,"Handle must be 2\u201332 characters: letters, numbers, dashes, or underscores."),fx=c.object({id:c.string(),first_name:c.string().min(1),last_name:c.string().min(1),display_name:c.string().min(1),stytch_id:c.string().nullable(),handle:c.string().nullable(),bio:c.string().max(280).nullable(),avatar_url:c.string().nullable(),banner_url:c.string().nullable(),share_new_threads_to_workspace:c.boolean(),experimental_features_enabled:c.boolean(),onboarded_at:c.string().nullable()}),vMe=c.object({authProviderUserId:c.string().min(1).optional(),organizationId:c.string().min(1).optional(),org_name:c.string().min(1).optional(),emailAddress:c.string().email(),name:c.string().nullable(),user:fx,is_admin:c.boolean()}),kMe=c.object({workos_client_id:c.string().min(1),workos_api_origin:c.string().url()}),LMe=c.object({share_new_threads_to_workspace:c.boolean().optional(),experimental_features_enabled:c.boolean().optional(),onboarded_at:c.union([c.literal("now"),c.null()]).optional(),display_name:c.string().min(1).max(120).optional(),handle:tW.optional(),bio:c.string().max(280).nullable().optional(),avatar_storage_url:c.string().min(1).nullable().optional(),banner_storage_url:c.string().min(1).nullable().optional()}).refine(t=>Object.keys(t).length>0,{message:"At least one field must be provided"}),wMe=c.object({id:c.string(),display_name:c.string(),handle:c.string().nullable(),avatar_url:c.string().nullable(),visible_thread_count:c.number().int().nonnegative(),last_active_at:c.string().datetime().nullable()}),nW=c.object({id:c.string().min(1),display_name:c.string().min(1),handle:c.string().nullable(),bio:c.string().max(280).nullable(),avatar_url:c.string().nullable(),banner_url:c.string().nullable(),organization_name:c.string().min(1).nullable(),created_at:c.string().min(1),visible_thread_count:c.number().int().nonnegative(),follower_count:c.number().int().nonnegative(),following_count:c.number().int().nonnegative(),published_project_count:c.number().int().nonnegative(),is_following:c.boolean(),is_self:c.boolean()}),DMe=c.object({type:c.literal("list"),list_type:c.literal("organization_member"),objects:c.array(wMe)}),UMe=c.object({email_address:c.string().email()}),BMe=c.object({email_address:c.string().email(),invitation_id:c.string().min(1)}),FMe=c.object({organization_id:c.string().min(1),organization_name:c.string().min(1),domain:c.string().min(1),created:c.boolean()}),GMe=c.object({location:c.string().trim().min(1),contact:c.string().trim().email()}),jMe=c.object({location:c.string().min(1),contact:c.string().email(),created_at:c.string().datetime()}),HMe=c.object({first_name:c.string().min(1),last_name:c.string().min(1),display_name:c.string().min(1),stytch_id:c.string().min(1).optional()}),VMe=c.object({name:c.string().min(1),email_domains:c.array(c.string().min(1)).nonempty(),stytch_org_id:c.string().min(1)}),qMe=c.object({user:HMe,organization:VMe}),$Me=c.object({path_glob:c.string().min(1),name:c.string().min(1),description:c.string().min(1)}),zMe=c.object({repo_origin_path:c.string().min(1),building_blocks:c.array($Me)}),rW=c.string().regex(/^th_[0-9A-Za-z]{22}$/),f0=c.string().regex(/^tb_[0-9A-Za-z]{22}$/),YMe=c.object({id:rW,author:c.object({id:c.string().min(1),display_name:c.string().min(1)}),body:c.string(),created_at:c.string().datetime(),repo_origin_path:c.string().min(1),latest_revision_id:f0,revision_count:c.number().int().positive()}),WMe=c.object({id:c.string().min(1),display_name:c.string().min(1)}),KMe=c.object({id:c.string().min(1),author_id:c.string().min(1).nullable(),author:WMe.nullable(),created_at:c.string().datetime(),deleted_at:c.string().datetime().nullable(),content:c.string().min(1)}),QMe=c.object({id:c.string().min(1),thread_block_id:c.string().min(1),created_at:c.string().datetime(),resolved_at:c.string().datetime().nullable(),comments:c.array(KMe)}),JMe=c.object({thread_block_id:f0,from_position:c.number().int().positive(),to_position:c.number().int().positive(),selected_text:c.string().min(1),content:c.string().trim().min(1)}),XMe=c.object({id:c.string().min(1)}),ZMe=c.object({content:c.string().trim().min(1)}),eve=c.object({id:c.string().min(1)}),tve=c.object({content:c.string().trim().min(1)}),nve=c.object({id:c.string().min(1)}),rve=c.object({content:c.string().trim().min(1)}),ove=c.object({id:c.string().min(1)}),sve=c.object({resolved:c.boolean()}),ive=c.object({id:c.string().min(1),resolved_at:c.string().datetime().nullable()}),ave=c.object({resolved:c.boolean()}),uve=c.object({id:c.string().min(1),resolved_at:c.string().datetime().nullable()}),oW=c.record(c.unknown()),cve=c.object({id:f0,body:c.string(),created_at:c.string().datetime(),prosemirror_json:oW,comment_threads:c.array(QMe)}),lve=c.object({id:rW,created_at:c.string().datetime(),repo_origin_path:c.string().min(1),author:c.object({id:c.string().min(1),display_name:c.string().min(1)}),latest_revision_id:f0,revision_count:c.number().int().positive(),revisions:c.array(cve)}),dve=c.object({type:c.literal("list"),list_type:c.literal("plan"),has_more:c.boolean(),objects:c.array(YMe)}),pve=c.object({before:c.string().min(1).optional(),after:c.string().min(1).optional(),author_id:c.string().min(1).optional(),repo_origin_path:c.string().min(1).optional()}),sW=c.object({id:c.string().min(1),organization_id:c.string().min(1),created_at:c.string().min(1),repo_origin_path:c.string().min(1),path_glob:c.string().min(1),name:c.string().min(1),description:c.string().min(1)}),fve=c.array(sW),mve=c.object({type:c.literal("list"),list_type:c.literal("building_block"),has_more:c.boolean(),objects:c.array(sW)}),_ve=c.object({repo_origin_path:c.string().min(1),before:c.string().min(1).optional(),after:c.string().min(1).optional()}),hve=c.enum(["thread","building_block"]),gve=c.object({repo_origin_path:c.string().min(1),sources:c.array(hve).nonempty()}),Tve=c.object({type:c.literal("list"),list_type:c.literal("repository"),has_more:c.boolean(),objects:c.array(gve)}),qo=c.enum(["claudeCode","codex","amp","cursor","cowork","unspecified"]),Eve=c.object({uploads:c.array(c.string()),outputs:c.array(c.string())}),Sve=c.object({connected:c.boolean(),last_upload_at:c.string().nullable(),harnesses:c.array(qo)}),Ave=["transcript","plan"],yve=c.enum(Ave),bve=c.object({md5:c.string().min(1),harness:qo,filename:c.string().min(1).optional(),repo_origin_path:c.string().min(1).optional(),harness_internal_id:c.string().min(1).optional(),file_type:yve.optional(),remix_of_thread_id:c.string().min(1).optional(),artifact_metadata:Eve.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"}),_x=c.object({id:c.string().min(1),display_name:c.string().min(1),avatar_url:c.string().nullable()}),Rve=c.object({id:c.string().min(1),display_name:c.string().min(1)}),iW=c.object({id:c.string().min(1),author_id:c.string().min(1).nullable(),author:Rve.nullable(),created_at:c.string().datetime(),deleted_at:c.string().datetime().nullable(),content:c.string().min(1)}),aW=c.object({id:c.string().min(1),thread_block_id:c.string().min(1),created_at:c.string().datetime(),resolved_at:c.string().datetime().nullable()}),Ive=aW.extend({comments:c.array(iW)}),nm=c.object({id:c.string().min(1),type:c.string().min(1),index_in_thread:c.number().int().nonnegative(),isCritiqued:c.boolean(),comment_threads:c.array(Ive).optional()}).passthrough(),uW=c.object({type:c.literal("list"),list_type:c.literal("thread_block"),has_more:c.boolean(),objects:c.array(nm)}),W7=nm.extend({type:c.literal("plan"),prosemirror_json:oW,thread_file_id:c.string().min(1)}),Ove=c.union([c.literal(-1),c.literal(1)]),cW=c.union([c.literal(-1),c.literal(0),c.literal(1)]),K7=c.object({score:c.number().int(),up_count:c.number().int().nonnegative(),down_count:c.number().int().nonnegative(),viewer_vote:cW}),Cve=c.object({value:Ove}),Nve=c.object({id:c.string().min(1),display_name:c.string().min(1),avatar_url:c.string().nullable()}),Eu=c.object({id:c.string().min(1),thread_id:c.string().min(1),author_id:c.string().min(1).nullable(),author:Nve.nullable(),parent_comment_id:c.string().min(1).nullable(),content:c.string(),created_at:c.string().datetime(),updated_at:c.string().datetime(),deleted_at:c.string().datetime().nullable()}),xve=c.object({type:c.literal("list"),list_type:c.literal("thread_comment"),objects:c.array(Eu)}),Pve=c.object({content:c.string().trim().min(1).max(4e3),parent_comment_id:c.string().min(1).optional()}),Mve=Eu,vve=c.object({content:c.string().trim().min(1).max(4e3)}),kve=Eu,Lve=Eu,jst=c.discriminatedUnion("kind",[c.object({kind:c.literal("created"),thread_id:c.string().min(1),actor_user_id:c.string().min(1),version:c.number(),comment:Eu}),c.object({kind:c.literal("updated"),thread_id:c.string().min(1),actor_user_id:c.string().min(1),version:c.number(),comment:Eu}),c.object({kind:c.literal("deleted"),thread_id:c.string().min(1),actor_user_id:c.string().min(1),version:c.number(),comment:Eu})]),wve=c.enum(["pending","generating","ready","failed"]),Dve=c.enum(["pending","generating","ready","failed"]),Uve=c.enum(["pending","placeholder","ai","user"]),lW=c.enum(["pending","generating","ready","failed"]),hx=c.enum(["pending","generating","ready","failed","disabled"]),dW=c.enum(["pending","generating","ready","failed"]),Bve=c.object({title:c.string().min(1),body:c.string().min(1),files:c.array(c.string()).optional()}),Fve=c.object({status:hx,url:c.string().nullable(),url_expires_at:c.string().nullable(),generated_at:c.string().nullable(),model:c.string().nullable()}),Gve=c.object({status:dW,steps:c.array(Bve),generated_at:c.string().nullable()}),jve=c.object({remix_of_thread_id:c.string().nullable(),remix_count:c.number().int().nonnegative()}),Hve=c.object({cover:Fve,how_to:Gve,lineage:jve}),Vve=c.object({id:c.string().min(1),title:c.string().min(1),author:c.object({id:c.string().min(1),display_name:c.string(),handle:c.string().nullable(),avatar_url:c.string().nullable()}),cover:c.object({url:c.string(),url_expires_at:c.string()}),remix_count:c.number().int().nonnegative(),started_at:c.string(),cover_generated_at:c.string()}),qve=c.object({type:c.literal("list"),list_type:c.literal("card_feed_item"),has_more:c.boolean(),objects:c.array(Vve)}),pW=c.enum(["asked","requested","decided","corrected","shared"]),$ve=c.object({id:c.string().min(1),kind:pW,summary:c.string().min(1),block_id:c.string().min(1)}),zve=c.object({type:c.literal("list"),list_type:c.literal("thread_decision"),status:lW,generated_at:c.string().nullable(),objects:c.array($ve)}),Yve=c.object({thread_id:c.string().min(1),source_url:c.string().min(1),title:c.string().min(1),summary:c.string().nullable(),harness:qo,visibility:c.enum(["private","workspace","public"]),started_at:c.string().min(1),author:c.object({display_name:c.string().min(1),handle:c.string().nullable()}),original_user_prompt:c.string().nullable(),last_assistant_message:c.string().nullable(),decisions:c.array(c.object({kind:pW,summary:c.string().min(1)})),files_touched:c.array(c.string()),truncated:c.boolean()}),sd=c.object({id:c.string().min(1),thread_file_id:c.string().min(1),organization_id:c.string().min(1),author:_x,repo:c.string().min(1),title:c.string().min(1),started_at:c.string().min(1),blocks:uW,user_message_count:c.number().int().nonnegative(),files_touched:c.array(c.string()),skills_invoked:c.array(c.string()),harness:qo,transcript_parsing_state:c.enum(["pending","parsed","too_large_to_parse"]),visibility:c.enum(["private","workspace","public"]),has_plan:c.boolean().optional(),summary:c.string().nullable(),summary_status:wve,summary_generated_at:c.string().nullable(),title_status:Dve,title_generated_at:c.string().nullable(),title_source:Uve,decisions_status:lW,decisions_generated_at:c.string().nullable(),score:c.number().int(),up_count:c.number().int().nonnegative(),down_count:c.number().int().nonnegative(),viewer_vote:cW,comment_count:c.number().int().nonnegative(),is_favorited:c.boolean(),card:Hve}),Wve=c.object({storage_url:c.string().min(1)}),Kve=c.object({storage_url:c.string(),harness:qo,thread:sd.nullable()}),Qve=c.object({status:c.literal("complete"),thread_files:c.array(Kve)}),Jve=c.object({id:c.string(),presigned_url:c.string().nullable(),presigned_url_expires_at:c.string().nullable(),storage_url:c.string(),harness:qo,expected_md5:c.string(),error:c.string().nullable(),thread:sd.nullable(),remix_parent_dropped:c.boolean().optional()}),Xve=c.object({id:c.string(),substrate:c.enum(["s3","filesystem"]),status:c.enum(["incomplete","locked_for_parsing","complete","error"]),thread_files:c.array(Jve)}),Zve=c.object({visibility:c.enum(["private","workspace","public"]).optional(),title:c.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"}),eke=c.discriminatedUnion("visibility",[c.object({visibility:c.literal("private")}),c.object({visibility:c.literal("workspace")}),c.object({visibility:c.literal("public"),title:c.string().min(1),author_display_name:c.string().min(1),author_avatar_url:c.string().nullable(),first_user_message:c.string().nullable(),summary:c.string().nullable(),started_at:c.string().min(1),harness:qo,cover_url:c.string().nullable()})]),tke=sd,Q7=c.object({type:c.literal("list"),list_type:c.literal("thread"),has_more:c.boolean(),objects:c.array(tke)}),nke=c.enum(["recent","popular"]),rke=c.enum(["everyone","following"]),oke=sd,ske=c.object({type:c.literal("list"),list_type:c.literal("discover_thread"),has_more:c.boolean(),objects:c.array(oke)}),ike=c.object({before:c.string().min(1).optional(),after:c.string().min(1).optional(),sort:nke.optional(),scope:rke.optional(),harness:qo.optional(),search:c.string().max(200).optional()}),ake=c.object({thread_count:c.number().int().nonnegative(),author_count:c.number().int().nonnegative(),organization_count:c.number().int().nonnegative(),harness_breakdown:c.record(qo,c.number().int().nonnegative())}),uke=c.object({id:c.string(),status:c.enum(["incomplete","locked_for_parsing","complete","error"]),created_at:c.string(),thread_count:c.number().int().nonnegative()}),cke=c.object({type:c.literal("list"),list_type:c.literal("upload_session"),objects:c.array(uke)}),lke=c.object({before:c.string().min(1).optional(),after:c.string().min(1).optional()}),dke=c.object({before:c.string().min(1).optional(),after:c.string().min(1).optional(),author_ids:c.string().min(1).optional(),created_at:c.string().min(1).optional(),filepath_prefixes:c.string().min(1).optional()}),pke=c.object({path:c.string().min(1),start_offset:c.number().int().nonnegative(),end_offset:c.number().int().positive()}),gx=c.enum(["captured","published"]),fke=c.enum(["workspace","link"]),fW=c.object({id:c.string(),display_name:c.string(),avatar_url:c.string().nullable()}),mke=c.object({name:c.string(),usage_count:c.number().int().nonnegative(),author_count:c.number().int().nonnegative(),first_used_at:c.string().nullable(),last_used_at:c.string().nullable(),usage_count_last_24h:c.number().int().nonnegative(),usage_count_last_7d:c.number().int().nonnegative(),id:c.string().nullable(),description:c.string().nullable(),source:gx.nullable(),has_content:c.boolean()}),_ke=c.object({type:c.literal("list"),list_type:c.literal("skill"),objects:c.array(mke)}),hke=c.object({id:c.string(),title:c.string(),visibility:c.enum(["private","workspace","public"]),started_at:c.string(),author:_x,skills_invoked:c.array(c.string())}),gke=c.object({id:c.string().nullable(),name:c.string(),description:c.string().nullable(),body_md:c.string().nullable(),source:gx.nullable(),visibility:fke.nullable(),share_url:c.string().nullable(),latest_version:c.number().int().nonnegative().nullable(),author:fW.nullable(),usage_count:c.number().int().nonnegative(),author_count:c.number().int().nonnegative(),first_used_at:c.string().nullable(),last_used_at:c.string().nullable(),threads:c.array(hke)}),Tke=c.object({description:c.string().nullable().optional(),body_md:c.string().min(1),display_name:c.string().nullable().optional(),published:c.boolean().optional()}),Eke=c.object({id:c.string(),name:c.string(),latest_version:c.number().int().positive(),source:gx,content_hash:c.string()}),Ske=c.object({share_url:c.string(),share_token:c.string()}),Ake=c.object({id:c.string(),name:c.string(),description:c.string().nullable(),body_md:c.string(),latest_version:c.number().int().positive(),author:fW.nullable(),shared_at:c.string()}),yke=c.object({path:c.string().min(1),text:c.string().max(64e3)}),bke=c.enum(["text_edit","redact","delete_block"]),Rke=c.object({id:c.string(),thread_block_id:c.string(),editor:c.object({id:c.string(),display_name:c.string()}),kind:bke,path:c.string().nullable(),previous_text:c.string().nullable(),new_text:c.string().nullable(),created_at:c.string()}),Ike=c.object({type:c.literal("list"),list_type:c.literal("thread_block_edit"),objects:c.array(Rke)}),Oke=c.object({organization_count:c.number().int().nonnegative(),user_count:c.number().int().nonnegative(),thread_count:c.number().int().nonnegative(),thread_count_last_24h:c.number().int().nonnegative(),user_count_last_24h:c.number().int().nonnegative()}),Cke=c.object({id:c.string(),name:c.string(),email_domains:c.array(c.string()),stytch_org_id:c.string(),member_count:c.number().int().nonnegative(),thread_count:c.number().int().nonnegative(),default_thread_visibility:c.enum(["private","workspace","public"]),created_at:c.string()}),Nke=c.object({type:c.literal("list"),list_type:c.literal("admin_organization"),objects:c.array(Cke)}),mW=c.object({id:c.string(),name:c.string()}),xke=c.object({id:c.string(),display_name:c.string(),stytch_id:c.string().nullable(),thread_count:c.number().int().nonnegative(),onboarded_at:c.string().nullable(),created_at:c.string(),organizations:c.array(mW)}),Pke=c.object({q:c.string().trim().min(1).max(120).optional()}),Mke=c.object({follower_id:c.string().min(1),followee_id:c.string().min(1)}),vke=c.object({follower_id:c.string().min(1),followee_id:c.string().min(1),is_following:c.literal(!0)}),kke=c.object({type:c.literal("list"),list_type:c.literal("admin_user"),objects:c.array(xke)}),Lke=c.object({id:c.string(),title:c.string(),started_at:c.string(),created_at:c.string(),deleted_at:c.string().nullable(),visibility:c.enum(["private","workspace","public"]),harness:qo,author:_x,organization:mW}),wke=c.object({type:c.literal("list"),list_type:c.literal("admin_thread"),has_more:c.boolean(),objects:c.array(Lke)}),Dke=c.object({before:c.string().min(1).optional(),after:c.string().min(1).optional()}),J7=c.object({token:c.string().min(1),thread_id:c.string().min(1)}),Uke=c.object({visitor:c.string().min(1).max(64).optional()}),Bke=c.object({user_id:c.string(),display_name:c.string(),shares_sent:c.number().int().nonnegative(),unique_viewers:c.number().int().nonnegative(),attributed_signups:c.number().int().nonnegative()}),Fke=c.object({window_days:c.number().int().positive(),shares_sent:c.number().int().nonnegative(),unique_viewers:c.number().int().nonnegative(),attributed_signups:c.number().int().nonnegative(),active_sharers:c.number().int().nonnegative(),k_factor:c.number().nullable(),shares_sent_sparkline:c.array(c.number().int().nonnegative()),top_sharers:c.array(Bke)}),Gke=c.object({windows:c.array(Fke)}),jke=c.object({quoted_text:c.string().min(1),comment:c.string().nullable(),type:c.enum(["comment","highlight:trapdoor"])}),Hke=aW,Vke=iW.extend({comment_thread_id:c.string().min(1)}),qke=c.object({markdown:c.string().min(1)}),$ke=c.object({storage_url:c.string().min(1),thread_file_id:c.string().min(1),parsed_plan_block:W7,critiqued_plan_block:W7,annotations:c.array(jke),comment_threads:c.array(Hke),comments:c.array(Vke)}),id=c.enum(ux),_W=c.object({workspace_scope:c.boolean(),review:c.boolean(),shared_thread_ttl_days:c.number().int().positive().nullable()}),mx=c.object({subject_type:c.enum(["user","organization"]),subject_id:c.string().min(1),effective_plan:id,admin_override:id.nullable(),stripe_subscription_status:c.string().nullable(),cancel_at_period_end:c.boolean(),current_period_end:c.string().nullable(),seat_quantity:c.number().int().positive(),member_count:c.number().int().nonnegative().nullable(),features:_W}),zke=c.object({effective_plan:id,features:_W,user:mx,organization:mx.nullable()}),Yke=c.object({plan:c.enum(["creator","team"]),seat_quantity:c.number().int().positive().optional()}),Wke=c.object({checkout_url:c.string().min(1)}),Kke=c.object({portal_url:c.string().min(1)}),Qke=c.object({seat_quantity:c.number().int().positive()}),X7=c.object({plan:id.nullable()}),p0=c.object({subject_type:c.enum(["user","organization"]),subject_id:c.string().min(1),label:c.string().min(1),effective_plan:id,admin_override:id.nullable(),stripe_subscription_status:c.string().nullable(),seat_quantity:c.number().int().positive()}),Jke=c.object({users:c.array(p0),organizations:c.array(p0)}),Xke=c.object({id:c.string().min(1),display_name:c.string().min(1),handle:c.string().nullable(),avatar_url:c.string().nullable()}),Zke=c.object({thread_id:c.string().min(1),title:c.string().min(1),author:Xke,last_active_at:c.string().datetime(),last_block_excerpt:c.string().nullable(),last_block_kind:c.string().min(1).nullable(),is_streaming:c.boolean()}),eLe=c.object({type:c.literal("list"),list_type:c.literal("live_thread"),objects:c.array(Zke)}),tLe=c.object({thread_id:c.string().min(1)}),nLe=c.object({thread_id:c.string().min(1),last_seen_at:c.string().datetime(),started_at:c.string().datetime()}),rLe=c.object({follower_id:c.string().min(1),followee_id:c.string().min(1),is_following:c.literal(!0),follower_count:c.number().int().nonnegative()}),oLe=c.object({follower_id:c.string().min(1),followee_id:c.string().min(1),is_following:c.literal(!1),follower_count:c.number().int().nonnegative()}),hW=c.object({id:c.string().min(1),display_name:c.string().min(1),handle:c.string().nullable(),avatar_url:c.string().nullable(),bio:c.string().max(280).nullable(),is_following:c.boolean(),is_self:c.boolean()}),Z7=c.object({type:c.literal("list"),list_type:c.literal("user_follow"),objects:c.array(hW)}),sLe=c.object({date:c.string().regex(/^\d{4}-\d{2}-\d{2}$/),count:c.number().int().nonnegative()}),iLe=c.object({window_start:c.string().datetime(),window_end:c.string().datetime(),total_contributions:c.number().int().nonnegative(),days_active:c.number().int().nonnegative(),daily_average:c.number().nonnegative(),current_streak_days:c.number().int().nonnegative(),days:c.array(sLe)}),aLe=c.object({type:c.literal("thread_created"),occurred_at:c.string().datetime(),id:c.string().min(1),thread:c.object({id:c.string().min(1),title:c.string(),visibility:c.enum(["private","workspace","public"])})}),uLe=c.object({type:c.literal("comment_posted"),occurred_at:c.string().datetime(),id:c.string().min(1),comment_excerpt:c.string(),thread:c.object({id:c.string().min(1),title:c.string(),visibility:c.enum(["private","workspace","public"])})}),cLe=c.object({type:c.literal("project_published"),occurred_at:c.string().datetime(),id:c.string().min(1),project:c.object({id:c.string().min(1),name:c.string().min(1)})}),lLe=c.object({type:c.literal("user_followed"),occurred_at:c.string().datetime(),id:c.string().min(1),followee:hW}),dLe=c.discriminatedUnion("type",[aLe,uLe,cLe,lLe]),pLe=c.object({type:c.literal("list"),list_type:c.literal("user_activity"),objects:c.array(dLe)}),fLe=c.object({id:c.string().min(1),name:c.string().min(1),excerpt:c.string(),published_at:c.string().datetime(),updated_at:c.string().datetime()}),mLe=c.object({type:c.literal("list"),list_type:c.literal("profile_published_project"),objects:c.array(fLe)}),eW=c.object({id:c.string().min(1),published_at:c.string().datetime().nullable()}),_Le=c.enum(["avatar","banner"]),gW=c.enum(["image/png","image/jpeg","image/webp","image/gif"]),hLe=c.object({kind:_Le,content_type:gW,base64_data:c.string().min(1)}),gLe=c.object({substrate:c.enum(["s3","filesystem"]),storage_url:c.string().min(1)}),TLe=c.object({content_type:gW,base64_data:c.string().min(1)}),ELe=c.object({cover_status:hx,cover_url:c.string().min(1),cover_url_expires_at:c.string().min(1),cover_generated_at:c.string().min(1)}),SLe=nW,TW=CMe.router({health:{method:"GET",path:"/health",responses:{200:c.object({status:c.literal("ok")})},summary:"Health check"},whoAmI:{method:"GET",path:"/whoami",headers:c.object({authorization:c.string().min(1).optional(),"x-lore-referral-token":c.string().min(1).max(16).optional()}),responses:{200:vMe,401:A},summary:"Validate a WorkOS Bearer token and return member plus user fields"},getCliAuthConfig:{method:"GET",path:"/cli-auth/config",responses:{200:kMe,503:A},summary:"Return public WorkOS CLI Auth configuration for the Lore CLI"},getCliStatus:{method:"GET",path:"/users/me/cli-status",headers:c.object({authorization:c.string().min(1).optional()}),responses:{200:Sve,401:A},summary:"Return whether the viewer has connected the Lore CLI (i.e., uploaded any thread under a non-unspecified harness), plus the latest upload timestamp."},recordHeartbeat:{method:"POST",path:"/heartbeat",headers:c.object({authorization:c.string().min(1).optional()}),body:tLe,responses:{200:nLe,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:c.object({authorization:c.string().min(1).optional()}),responses:{200:eLe,401:A,403:A},summary:"List members with user-block activity in the last 10 minutes. Org-scoped, deduped per author, max 10."},listThreads:{method:"GET",path:"/threads",headers:c.object({authorization:c.string().min(1).optional()}),query:dke,responses:{200:Q7,401:A},summary:"List threads visible to the authenticated user"},getThread:{method:"GET",path:"/threads/:id",pathParams:c.object({id:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),responses:{200:sd,404:A},summary:"Load a visible thread by id"},getSimilarThreads:{method:"GET",path:"/threads/:id/similar",pathParams:c.object({id:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),responses:{200:Q7,404:A,409:A},summary:"List the top 20 visible threads with the closest summary embedding"},getThreadRemixBrief:{method:"GET",path:"/threads/:id/remix",pathParams:c.object({id:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),responses:{200:Yve,401:A,403:A,404:A},summary:"Fetch a portable handoff brief that lets another agent continue this thread"},listThreadBlocks:{method:"GET",path:"/threads/:id/blocks",pathParams:c.object({id:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),query:lke,responses:{200:uW,401:A},summary:"List blocks for a visible thread"},createThreadBlockCommentThread:{method:"POST",path:"/threads/:threadId/blocks/:blockId/comment-threads",pathParams:c.object({threadId:c.string().min(1),blockId:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),body:ZMe,responses:{201:eve,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:c.object({threadId:c.string().min(1),blockId:c.string().min(1),commentThreadId:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),body:rve,responses:{201:ove,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:c.object({threadId:c.string().min(1),blockId:c.string().min(1),commentThreadId:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),body:ave,responses:{200:uve,401:A,404:A},summary:"Resolve or reopen a block-level comment thread on a visible thread block"},listSkills:{method:"GET",path:"/skills",headers:c.object({authorization:c.string().min(1).optional()}),responses:{200:_ke,401:A},summary:"Aggregate skill usage across threads the viewer can see"},getSkillDetail:{method:"GET",path:"/skills/:name",pathParams:c.object({name:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),responses:{200:gke,401:A,404:A},summary:"Per-skill detail: usage stats + visible threads that invoked it"},getSkillRaw:{method:"GET",path:"/skills/:name/raw",pathParams:c.object({name:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),responses:{200:c.string(),401:A,403:A,404:A},summary:"Raw SKILL.md body for a skill (download / install path)"},publishSkill:{method:"PUT",path:"/skills/:name",pathParams:c.object({name:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),body:Tke,responses:{200:Eke,401:A,403:A,422:A},summary:"Publish or capture a skill body for the caller\u2019s workspace"},mintSkillShare:{method:"POST",path:"/skills/:name/share",pathParams:c.object({name:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),body:c.object({}).optional(),responses:{200:Ske,401:A,403:A,404:A},summary:"Mint (or rotate) a public share token for a skill"},revokeSkillShare:{method:"DELETE",path:"/skills/:name/share",pathParams:c.object({name:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),responses:{204:c.null(),401:A,403:A,404:A},summary:"Revoke an active share token for a skill"},getSharedSkill:{method:"GET",path:"/shared-skills/:token",pathParams:c.object({token:c.string().min(1)}),responses:{200:Ake,404:A},summary:"Read a shared skill by its public share token (no auth)"},redactThreadBlock:{method:"POST",path:"/threads/:threadId/blocks/:blockId/redactions",pathParams:c.object({threadId:c.string().min(1),blockId:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),body:pke,responses:{200:nm,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:c.object({threadId:c.string().min(1),blockId:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),body:yke,responses:{200:nm,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:c.object({threadId:c.string().min(1),blockId:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),body:c.object({}).optional(),responses:{200:nm,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:c.object({threadId:c.string().min(1),blockId:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),body:c.object({}).optional(),responses:{204:c.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:c.object({threadId:c.string().min(1),blockId:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),responses:{200:Ike,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:c.object({id:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),responses:{200:zve,401:A,404:A},summary:"List AI-extracted user decisions for a thread, in chronological order"},updateThread:{method:"PATCH",path:"/threads/:id",pathParams:c.object({id:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),body:Zve,responses:{200:sd,401:A,403:A,404:A},summary:"Update thread visibility (author only)"},deleteThread:{method:"DELETE",path:"/threads/:id",pathParams:c.object({id:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),body:c.object({}).optional(),responses:{204:c.null(),401:A,403:A,404:A},summary:"Soft-delete a thread (author only)"},generateThreadCard:{method:"POST",path:"/threads/:id/card/generate",pathParams:c.object({id:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),body:c.object({}).optional(),responses:{200:c.object({cover_status:hx,how_to_status:dW}),401:A,403:A,404:A,429:A.extend({retry_after_seconds:c.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'."},uploadThreadCover:{method:"POST",path:"/threads/:id/card/cover/upload",pathParams:c.object({id:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),body:TLe,responses:{200:ELe,401:A,403:A,404:A,413:A,422:A},summary:"Upload a custom cover image for a thread. Author or Tanagram admin only. Bytes go to the same storage substrate the AI cover uses (S3 in prod, filesystem in dev), and the threads row is updated atomically with the new cover_storage_url, cover_status='ready', cover_generated_at=now, cover_model='user-uploaded' so subsequent re-rolls / how-to fan-outs treat the upload like any other ready cover."},castThreadVote:{method:"PUT",path:"/threads/:id/vote",pathParams:c.object({id:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),body:Cve,responses:{200:K7,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:c.object({id:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),body:c.object({}).optional(),responses:{200:K7,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:c.object({threadId:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),responses:{200:xve,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:c.object({threadId:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),body:Pve,responses:{201:Mve,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:c.object({threadId:c.string().min(1),commentId:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),body:vve,responses:{200:kve,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:c.object({threadId:c.string().min(1),commentId:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),body:c.object({}).optional(),responses:{200:Lve,401:A,403:A,404:A},summary:"Soft-delete your own thread comment (author only). Idempotent."},getThreadPreview:{method:"GET",path:"/threads/:id/preview",pathParams:c.object({id:c.string().min(1)}),responses:{200:eke,404:A},summary:"Unauthenticated, visibility-redacted metadata for OG / social preview consumers"},createUser:{method:"POST",path:"/users",headers:c.object({authorization:c.string().min(1).optional()}),body:qMe,responses:{201:fx,401:A},summary:"Create a user record with ApiKey authentication"},getUser:{method:"GET",path:"/users/:id",pathParams:c.object({id:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),responses:{200:nW,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:c.object({authorization:c.string().min(1).optional()}),body:LMe,responses:{200:fx,401:A,409:A,422:A},summary:"Update the authenticated user profile"},getUserByHandle:{method:"GET",path:"/users/by-handle/:handle",pathParams:c.object({handle:tW}),headers:c.object({authorization:c.string().min(1).optional()}),responses:{200:SLe,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:c.object({id:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),query:c.object({limit:c.coerce.number().int().positive().max(100).optional()}),responses:{200:pLe,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:c.object({id:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),responses:{200:iLe,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:c.object({id:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),responses:{200:Z7,404:A},summary:"List the users following a given user."},listUserFollowing:{method:"GET",path:"/users/:id/following",pathParams:c.object({id:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),responses:{200:Z7,404:A},summary:"List the users a given user is following."},followUser:{method:"POST",path:"/users/:id/follow",pathParams:c.object({id:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),body:c.object({}).optional(),responses:{200:rLe,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:c.object({id:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),body:c.object({}).optional(),responses:{200:oLe,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:c.object({id:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),responses:{200:mLe,404:A},summary:"Projects the user has published to their public profile."},publishProject:{method:"POST",path:"/projects/:id/publish",pathParams:c.object({id:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),body:c.object({}).optional(),responses:{200:eW,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:c.object({id:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),body:c.object({}).optional(),responses:{200:eW,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:c.object({authorization:c.string().min(1).optional()}),body:hLe,responses:{200:gLe,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:c.object({authorization:c.string().min(1).optional()}),responses:{200:DMe,401:A},summary:"List members of the authenticated user\u2019s organization"},createOrganizationInvite:{method:"POST",path:"/organization/invites",headers:c.object({authorization:c.string().min(1).optional()}),body:UMe,responses:{201:BMe,401:A,403:A,409:A,422:A},summary:"Invite a teammate to the authenticated user\u2019s workspace via WorkOS AuthKit"},ensureWorkOSOrganization:{method:"POST",path:"/organization/workos/ensure",headers:c.object({authorization:c.string().min(1).optional()}),body:c.object({}).optional(),responses:{200:FMe,401:A,422:A,503:A},summary:"Create or reuse a WorkOS organization for the authenticated user\u2019s non-public email domain and add the user as a member."},listRepositories:{method:"GET",path:"/repositories",headers:c.object({authorization:c.string().min(1).optional()}),responses:{200:Tve,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:c.object({authorization:c.string().min(1).optional()}),body:zMe,responses:{201:fve,401:A,403:A},summary:"Create building block snapshots for the authenticated user\u2019s organization"},getPlan:{method:"GET",path:"/plans/:id",pathParams:c.object({id:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),responses:{200:lve,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:c.object({id:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),body:JMe,responses:{201:XMe,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:c.object({id:c.string().min(1),threadId:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),body:tve,responses:{201:nve,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:c.object({id:c.string().min(1),threadId:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),body:sve,responses:{200:ive,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:c.object({authorization:c.string().min(1).optional()}),query:pve,responses:{200:dve,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:c.object({authorization:c.string().min(1).optional()}),query:_ve,responses:{200:mve,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:c.object({authorization:c.string().min(1).optional()}),responses:{200:cke,401:A},summary:"List recent upload sessions for the authenticated user"},createUploadSession:{method:"POST",path:"/upload_sessions",headers:c.object({authorization:c.string().min(1).optional()}),body:c.object({thread_files:c.array(bve).nonempty()}),responses:{201:Xve,400:A,401:A},summary:"Create an upload session with presigned URLs for file uploads"},completeUploadSession:{method:"POST",path:"/upload_sessions/:id/complete",pathParams:c.object({id:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),body:c.object({thread_files:c.array(Wve).nonempty()}),responses:{200:Qve,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:c.object({authorization:c.string().min(1).optional()}),responses:{200:Oke,401:A,403:A},summary:"Cross-org operational counts. Tanagram admins only."},adminListOrganizations:{method:"GET",path:"/admin/organizations",headers:c.object({authorization:c.string().min(1).optional()}),responses:{200:Nke,401:A,403:A},summary:"List every organization with member and thread counts. Tanagram admins only."},adminListUsers:{method:"GET",path:"/admin/users",query:Pke,headers:c.object({authorization:c.string().min(1).optional()}),responses:{200:kke,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:c.object({authorization:c.string().min(1).optional()}),query:Dke,responses:{200:wke,401:A,403:A},summary:"List live threads across every organization. Tanagram admins only."},adminForceFollow:{method:"POST",path:"/admin/connections/follow",headers:c.object({authorization:c.string().min(1).optional()}),body:Mke,responses:{200:vke,401:A,403:A,404:A,422:A},summary:"Force follower->followee edge. Admin-only and non-destructive."},adminHardDeleteThread:{method:"DELETE",path:"/admin/threads/:id",pathParams:c.object({id:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),body:c.object({}).optional(),responses:{204:c.null(),401:A,403:A,404:A},summary:"Permanently remove a thread. Tanagram admins only."},listCardFeed:{method:"GET",path:"/cards/feed",query:c.object({limit:c.coerce.number().int().min(1).max(48).optional()}),responses:{200:qve},summary:"Slim feed of public threads with a ready cover image, ordered by cover_generated_at descending. Powers the landing-page UGC card scroll. Returns presigned cover URLs inline so the grid renders without a follow-up round trip per card."},listDiscoverThreads:{method:"GET",path:"/discover/threads",headers:c.object({authorization:c.string().min(1).optional()}),query:ike,responses:{200:ske},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:ake},summary:"Unauthenticated rollup of public-thread counts for the Discover header."},createWaitlistEntry:{method:"POST",path:"/waitlist_entries",body:GMe,responses:{201:jMe,409:A},summary:"Create an unauthenticated waitlist entry keyed by (location, contact)."},createShareToken:{method:"POST",path:"/threads/:id/share-token",pathParams:c.object({id:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),body:c.object({}).optional(),responses:{201:J7,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:c.object({token:c.string().min(1).max(16)}),query:Uke,responses:{200:J7,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:c.object({authorization:c.string().min(1).optional()}),responses:{200:Gke,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:c.object({authorization:c.string().min(1).optional()}),body:qke,responses:{200:$ke,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:c.object({authorization:c.string().min(1).optional()}),responses:{200:zke,401:A},summary:"Resolve the caller's plan, features, seat count, and any admin override."},createBillingCheckout:{method:"POST",path:"/billing/checkout",headers:c.object({authorization:c.string().min(1).optional()}),body:Yke,responses:{200:Wke,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:c.object({authorization:c.string().min(1).optional()}),body:c.object({subject_type:c.enum(["user","organization"]).default("user")}).optional(),responses:{200:Kke,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:c.object({authorization:c.string().min(1).optional()}),body:Qke,responses:{200:mx,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:c.object({authorization:c.string().min(1).optional()}),responses:{200:Jke,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:c.object({id:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),body:X7,responses:{200:p0,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:c.object({id:c.string().min(1)}),headers:c.object({authorization:c.string().min(1).optional()}),body:X7,responses:{200:p0,401:A,403:A,404:A},summary:"Admin override for an organization's plan tier. Null clears the override."},projects:j7,docs:F7,mentions:H7,favorites:$7,search:Y7},{pathPrefix:"/api"});import sm from"node:fs";import AW from"node:path";import EW from"node:os";import Ps from"node:path";function oo(){let t=Ve()==="dev"?".lore-dev":".lore";return Ps.join(EW.homedir(),t)}function rm(){return Ps.join(oo(),"log.txt")}function Tx(){return Ps.join(oo(),"sync_state.json")}function SW(){return Ps.join(oo(),"upload_filters.json")}function m0(){return Ps.join(oo(),"status.json")}function Su(){return Ps.join(oo(),"install_source.json")}function _0(){return Ps.join(oo(),"skill_sync_state.json")}function Au(){return Ps.join(oo(),"bin","lore")}function om(){let t=Ve();return t==="prod"?"ai.tanagram.lore":`ai.tanagram.lore.${t}`}function ad(){return Ps.join(EW.homedir(),"Library","LaunchAgents",`${om()}.plist`)}function h0(){return AW.join(oo(),"token")}function im(){let t;try{t=sm.readFileSync(h0(),"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||ALe(e,new Date)?{token:"",source:"none"}:{token:e,source:"file"}}function fn(){return im().token}function yW(){return sm.existsSync(h0())}function bW(t){let e=h0();sm.mkdirSync(AW.dirname(e),{recursive:!0,mode:448}),sm.writeFileSync(e,t,{mode:384})}function RW(){try{sm.rmSync(h0())}catch(t){if(t&&typeof t=="object"&&"code"in t&&t.code==="ENOENT")return;throw t}}function Ex(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 ALe(t,e){let n;try{n=Ex(t)}catch{return!1}return typeof n.exp!="number"?!1:e.getTime()>=n.exp*1e3}var yLe={dev:"http://localhost:4000",prod:"https://lore-api.tanagram.ai"};function bLe(t=Ve(),e=process.env.LORE_API_ORIGIN){let n=e?.trim();return n?n.replace(/\/$/,""):yLe[t]}function Xe(t={}){let e=t.token??fn();return ax(TW,{baseUrl:bLe(),baseHeaders:{"User-Agent":_7(),...e?{authorization:`Bearer ${e}`}:{}}})}import OW from"node:fs";var IW=null;function RLe(){let t=oo();IW!==t&&(OW.mkdirSync(t,{recursive:!0}),IW=t)}function ILe(t){let e=typeof t=="string"?t:JSON.stringify(t);return/[\s"=]/.test(e)?JSON.stringify(e):e}function OLe(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}=${ILe(i)}`).join(" ");return o?`${r} ${o}
|
|
42
42
|
`:`${r}
|
|
43
43
|
`}function Sx(t,e,n){try{let r=OLe(t,e,n);RLe(),OW.appendFileSync(rm(),r),Ve()==="dev"&&process.stderr.write(r)}catch{}}var se={info(t,e){Sx("info",t,e)},warn(t,e){Sx("warn",t,e)},error(t,e){Sx("error",t,e)}};import{execFile as H2e}from"node:child_process";import qn from"node:fs/promises";import V2e from"node:os";import ws from"node:path";import{promisify as q2e}from"node:util";import g0 from"node:fs/promises";import CLe from"node:path";var T0=class{status={};async markRunning(){let e=new Date().toISOString();this.status={pid:process.pid,state:"running",started_at:e,last_heartbeat_at:e},await this.persist()}async heartbeat(){this.status.pid=process.pid,this.status.last_heartbeat_at=new Date().toISOString(),await this.persist()}async markAuthenticated(){this.status.auth="logged_in",await this.heartbeat()}async markSyncSuccess(e){let n=new Date().toISOString();this.status.pid=process.pid,this.status.auth="logged_in",this.status.last_heartbeat_at=n,this.status.last_completed_at=n,this.status.last_success_at=n,this.status.last_error=void 0,this.status.last_thread_ids=[...e],await this.persist()}async setPendingWatchers(e){this.status.pid=process.pid,this.status.state="running",this.status.pending_watchers=e.map(n=>({session_id:n.sessionId||void 0,project:n.project||void 0,transcript_path:n.transcriptPath||void 0,expires_at:n.expiresAt.toISOString()})),await this.heartbeat()}async markLoggedOut(){let e=new Date().toISOString();this.status.pid=process.pid,this.status.state="logged_out",this.status.auth="logged_out",this.status.last_heartbeat_at=e,this.status.last_completed_at=e,this.status.last_error=void 0,this.status.last_thread_ids=void 0,this.status.pending_watchers=void 0,await this.persist()}async markSuccess(e){let n=new Date().toISOString();this.status.pid=process.pid,this.status.state="idle",this.status.auth="logged_in",this.status.last_heartbeat_at=n,this.status.last_completed_at=n,this.status.last_success_at=n,this.status.last_error=void 0,this.status.last_thread_ids=[...e],this.status.pending_watchers=void 0,await this.persist()}async markError(e){let n=new Date().toISOString();this.status.pid=process.pid,this.status.state="error",this.status.last_heartbeat_at=n,this.status.last_completed_at=n,this.status.last_error=e instanceof Error?e.message:String(e),this.status.pending_watchers=void 0,await this.persist()}async persist(){let e=m0();await g0.mkdir(CLe.dirname(e),{recursive:!0,mode:448}),await g0.writeFile(e,`${JSON.stringify(NLe(this.status),null,2)}
|
|
@@ -107,7 +107,7 @@ set -eu
|
|
|
107
107
|
cd ${JP(e)}
|
|
108
108
|
exec ${JP(n)} ${JP(t)} "$@"
|
|
109
109
|
`}function JP(t){return`'${t.replaceAll("'","'\\''")}'`}async function UQ(t){await vW({package_manager:bx(t),binary_path:t,updated_at:new Date().toISOString()})}async function BQ(){try{await K0("bootout",ZP(),ad())}catch(t){if(t1(t)||!(await GQ().catch(()=>({loaded:!0}))).loaded)return;throw t}}async function FQ(t){await K0("bootstrap",ZP(),t)}async function XP(){await K0("kickstart","-k",jQ())}async function X2e(t){try{await XP();return}catch(e){if(!t1(e))throw e}await FQ(t),await XP()}async function GQ(){try{let t=await K0("print",jQ());return Z2e(t)}catch(t){if(t1(t))return{loaded:!1,running:!1,pid:0,raw:""};throw t}}function Z2e(t){let e={loaded:t.trim().length>0,running:!1,pid:0,raw:t},n;for(let r of t.split(`
|
|
110
|
-
`)){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 K0(...t){try{let e=await $2e("launchctl",t);return`${e.stdout}${e.stderr}`.trim()}catch(e){if(rUe(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 eUe(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 tUe(t,e){if(!t.last_heartbeat_at)return!1;let n=Date.parse(t.last_heartbeat_at);return Number.isNaN(n)?!1:n+z2e>=e.getTime()}function ZP(){return`gui/${process.getuid?.()??V2e.userInfo().uid}`}function jQ(){return`${ZP()}/${om()}`}function nUe(){let t=["/opt/homebrew/bin","/usr/local/bin","/usr/bin","/bin","/usr/sbin","/sbin"];return Array.from(new Set([...process.env.PATH?.split(ws.delimiter)??[],...t].filter(Boolean))).join(ws.delimiter)}async function HQ(t){try{return await qn.stat(t),!0}catch{return!1}}function W0(t){return t.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'")}function e1(){if(process.platform!=="darwin")throw new Error("Lore background uploads are currently supported only on macOS")}function t1(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 rUe(t){return t instanceof Error}var sUe=5*60*1e3,iUe="urn:ietf:params:oauth:grant-type:device_code",VQ=t=>new Promise(e=>setTimeout(e,t));async function qQ(t){try{return await t.json()}catch{throw new Error(`WorkOS returned an invalid JSON response: HTTP ${t.status}`)}}function $Q(t){return[t.error_description,t.error].find(e=>typeof e=="string"&&e.length>0)??"Authorization failed"}function zQ(t,e){return new URL(e,t).toString()}async function aUe({clientId:t,workosApiOrigin:e}){let n=await fetch(zQ(e,"/user_management/authorize/device"),{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({client_id:t})}),r=await qQ(n);if(!n.ok)throw new Error($Q(r));return r}async function uUe({clientId:t,deviceCode:e,expiresIn:n,interval:r,timeoutMs:o,workosApiOrigin:s}){let i=AbortSignal.timeout(Math.min(o,n*1e3)),a=r;for(;;){let u;try{u=await fetch(zQ(s,"/user_management/authenticate"),{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:iUe,device_code:e,client_id:t}),signal:i})}catch(p){throw p instanceof Error&&p.name==="TimeoutError"?new Error("authorization timed out"):p}let l=await qQ(u);if(u.ok)return l;let d=l;switch(d.error){case"authorization_pending":await VQ(a*1e3);break;case"slow_down":a+=1,await VQ(a*1e3);break;case"access_denied":throw new Error("Authorization denied");case"expired_token":throw new Error("Authorization expired");default:throw new Error($Q(d))}}}async function cUe(t){let{command:e,args:n}=lUe(process.platform,t);await new Promise((r,o)=>{let s=oUe(e,n,{detached:!0,stdio:"ignore"});s.once("error",o),s.once("spawn",()=>{s.unref(),r()})})}function lUe(t,e){return t==="win32"?{command:"rundll32",args:["url.dll,FileProtocolHandler",e]}:t==="darwin"?{command:"open",args:[e]}:{command:"xdg-open",args:[e]}}async function dUe(t){if(im().source==="none")return!1;try{return(await t.whoAmI({headers:{}})).status===200}catch{return!1}}async function pUe(t,e){if(e==="darwin")try{console.log(" Enabling Lore background uploads automatically (this can take
|
|
110
|
+
`)){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 K0(...t){try{let e=await $2e("launchctl",t);return`${e.stdout}${e.stderr}`.trim()}catch(e){if(rUe(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 eUe(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 tUe(t,e){if(!t.last_heartbeat_at)return!1;let n=Date.parse(t.last_heartbeat_at);return Number.isNaN(n)?!1:n+z2e>=e.getTime()}function ZP(){return`gui/${process.getuid?.()??V2e.userInfo().uid}`}function jQ(){return`${ZP()}/${om()}`}function nUe(){let t=["/opt/homebrew/bin","/usr/local/bin","/usr/bin","/bin","/usr/sbin","/sbin"];return Array.from(new Set([...process.env.PATH?.split(ws.delimiter)??[],...t].filter(Boolean))).join(ws.delimiter)}async function HQ(t){try{return await qn.stat(t),!0}catch{return!1}}function W0(t){return t.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'")}function e1(){if(process.platform!=="darwin")throw new Error("Lore background uploads are currently supported only on macOS")}function t1(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 rUe(t){return t instanceof Error}var sUe=5*60*1e3,iUe="urn:ietf:params:oauth:grant-type:device_code",VQ=t=>new Promise(e=>setTimeout(e,t));async function qQ(t){try{return await t.json()}catch{throw new Error(`WorkOS returned an invalid JSON response: HTTP ${t.status}`)}}function $Q(t){return[t.error_description,t.error].find(e=>typeof e=="string"&&e.length>0)??"Authorization failed"}function zQ(t,e){return new URL(e,t).toString()}async function aUe({clientId:t,workosApiOrigin:e}){let n=await fetch(zQ(e,"/user_management/authorize/device"),{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({client_id:t})}),r=await qQ(n);if(!n.ok)throw new Error($Q(r));return r}async function uUe({clientId:t,deviceCode:e,expiresIn:n,interval:r,timeoutMs:o,workosApiOrigin:s}){let i=AbortSignal.timeout(Math.min(o,n*1e3)),a=r;for(;;){let u;try{u=await fetch(zQ(s,"/user_management/authenticate"),{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({grant_type:iUe,device_code:e,client_id:t}),signal:i})}catch(p){throw p instanceof Error&&p.name==="TimeoutError"?new Error("authorization timed out"):p}let l=await qQ(u);if(u.ok)return l;let d=l;switch(d.error){case"authorization_pending":await VQ(a*1e3);break;case"slow_down":a+=1,await VQ(a*1e3);break;case"access_denied":throw new Error("Authorization denied");case"expired_token":throw new Error("Authorization expired");default:throw new Error($Q(d))}}}async function cUe(t){let{command:e,args:n}=lUe(process.platform,t);await new Promise((r,o)=>{let s=oUe(e,n,{detached:!0,stdio:"ignore"});s.once("error",o),s.once("spawn",()=>{s.unref(),r()})})}function lUe(t,e){return t==="win32"?{command:"rundll32",args:["url.dll,FileProtocolHandler",e]}:t==="darwin"?{command:"open",args:[e]}:{command:"xdg-open",args:[e]}}async function dUe(t){if(im().source==="none")return!1;try{return(await t.whoAmI({headers:{}})).status===200}catch{return!1}}async function pUe(t,e){if(e==="darwin")try{console.log(" Enabling Lore background uploads automatically (this can take up to a minute)..."),console.log(" Please keep this terminal open and do not cancel.");let{plistPath:n,binaryPath:r}=await t();console.log(" Lore background uploads enabled."),console.log(` LaunchAgent: ${n}`),console.log(` Stable binary: ${r}
|
|
111
111
|
`)}catch(n){se.warn("auto_enable_failed",{error:n instanceof Error?n.message:String(n)}),console.log(` Could not enable background uploads automatically. Run 'lore enable' to retry.
|
|
112
112
|
`)}}async function fUe({client:t=Xe(),enableLaunchAgent:e=Em,openBrowser:n=cUe,platform:r=process.platform,pollForTokens:o=uUe,requestDeviceAuthorization:s=aUe,setAccessToken:i=bW,timeoutMs:a=sUe}={}){if(await dUe(t)){console.log(`
|
|
113
113
|
Already logged in. Use 'lore logout' if you want to sign out.
|