1!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._posthogChunkIds=e._posthogChunkIds||{},e._posthogChunkIds[n]="01a0d0df-a62f-7371-9d48-5a5eac5e21c0")}catch(e){}}();;!function(){try { var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&((e._debugIds|| (e._debugIds={}))[n]="128bda12-bcc6-d6ef-2c33-af66f45d8140")}catch(e){}}(); 2(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,212757,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(){function e(e,t,r){this.depth=0,this.depth=e,this.path=t,this.object=r}return e.prototype.flatten=function(){var t=this.object;return"object"==typeof this.object&&Array.isArray(this.object)&&this.depth>0&&(t=this.object.flat(this.depth)),new e(0,this.path,t)},e}()},397530,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.SimpleKeyPathComponent=void 0;var n=e.r(212757);r.SimpleKeyPathComponent=function(){function e(e){this.isArray=!1,this.keyName=e;var t=parseInt(this.keyName,10);isNaN(t)||!Number.isInteger(t)||t<0||(this.isArray=!0)}return e.fromString=function(t){var r=t;return e.unescapeExpressions.forEach(function(e){r=r.replace(e.search,e.replacement)}),new e(r)},e.prototype.toString=function(){var t=this.keyName;return e.escapeExpressions.forEach(function(e){t=t.replace(e.search,e.replacement)}),t},e.prototype.jsonPointer=function(){var e=this.keyName;return(e=e.replace(/(\~)/g,"~0")).replace(/(\/)/g,"~1")},e.prototype.query=function(e){for(var t=[],r=0;r<e.length;r++){var i=e[r],a=i.object;if("object"==typeof a){var s=a[this.keyName];if(null!==s){var o=new n.default(i.depth,i.path.child(this.keyName),s);t.push(o)}}}return t},e.escapeExpressions=[{search:new RegExp(/(\\)/g),replacement:"\\"},{search:new RegExp(/(\.)/g),replacement:"\\."}],e.unescapeExpressions=[{search:new RegExp(/(\\\.)/g),replacement:"."},{search:new RegExp(/(\\\\)/g),replacement:"\\"},{search:"~1",replacement:"/"}],e}()},705303,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.WildcardPathComponent=void 0;var n=e.r(212757);r.WildcardPathComponent=function(){function e(){this.keyName="*",this.isArray=!0}return e.fromString=function(t){return"*"===t?new e:null},e.prototype.toString=function(){return this.keyName},e.prototype.jsonPointer=function(){throw Error("JSON Pointers don't work with wildcards")},e.prototype.query=function(e){for(var t=[],r=0;r<e.length;r++){var i=e[r],a=i.object;if("object"==typeof a)for(var s in a){var o=a[s],l=new n.default(i.depth+1,i.path.child(s),o);t.push(l)}}return t},e}()},770908,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(){function e(){this.keyName="$",this.isArray=!1}return e.fromString=function(t){return"$"===t?new e:null},e.prototype.toString=function(){return this.keyName},e.prototype.jsonPointer=function(){return""},e.prototype.query=function(e){return e},e}()},403239,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.SlicePathComponent=void 0;var n=e.r(212757);r.SlicePathComponent=function(){function e(e,t){this.endIndex=null,this.isArray=!0,this.startIndex=e,this.endIndex=t}return e.fromString=function(t){if(!e.regex.test(t))return null;e.regex.lastIndex=0;var r=e.regex.exec(t);if(null==r||null==r.groups)return null;var n=r.groups.startIndex,i=r.groups.endIndex,a=null==n||""===n?0:parseInt(n,10),s=null==i?null:parseInt(i,10);return(null!=a||null!=s)&&Number.isInteger(a)?new e(a,s):null},e.prototype.toString=function(){return"[".concat(this.startIndex).concat(null==this.endIndex?"":":"+this.endIndex,"]")},e.prototype.jsonPointer=function(){throw Error("JSON Pointers don't work with wildcards")},e.prototype.query=function(e){for(var t=[],r=0;r<e.length;r++){var i=e[r],a=i.object;if("object"==typeof a&&Array.isArray(a)){var s=void 0;s=null==this.endIndex?a.slice(this.startIndex):a.slice(this.startIndex,this.endIndex);for(var o=0;o<s.length;o++){var l=s[o];t.push(new n.default(i.depth+1,i.path.child("".concat(o+this.startIndex)),l))}}}return t},e.regex=/^\[(?<startIndex>[0-9]*):(?<endIndex>
2\-?[0-9]*)?\]$/g,e}()},230839,(e,t,r)=>{"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=e.r(397530),i=e.r(705303),a=e.r(770908),s=e.r(403239);r.default=function(){function e(){}return e.prototype.parse=function(t){e.pathPattern.lastIndex=0;var r=t.match(e.pathPattern),n=[new a.default];if(null==r||0==r.length||1==r.length&&""==r[0])return n;var i=0;"$"==r[0]&&(i=1);for(var s=i;s<r.length;s++){var o=r[s],l=this.parseComponent(o);n.push(l)}return n},e.prototype.parsePointer=function(t){e.pathPattern.lastIndex=0;var r=t.match(e.pointerPattern),n=[new a.default];if(null==r||0==r.length||1==r.length&&""==r[0])return n;for(var i=0;i<r.length;i++){var s=r[i];n.push(this.parseComponent(s))}return n},e.prototype.parseComponent=function(e){var t=i.WildcardPathComponent.fromString(e);if(null!=t)return t;if(null==e)throw SyntaxError("Cannot create a path from null");if(""==e)throw SyntaxError("Cannot create a path from an empty string");var r=s.SlicePathComponent.fromString(e);return null!=r?r:n.SimpleKeyPathComponent.fromString(e)},e.pathPattern=/(?:[^\.\\]|\\.)+/g,e.pointerPattern=/(?:[^\/\\]|\\\/)+/g,e}()},721092,(e,t,r)=>{"use strict";var n=e.e&&e.e.__spreadArray||function(e,t,r){if(r||2==arguments.length)for(var n,i=0,a=t.length;i<a;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))};Object.defineProperty(r,"__esModule",{value:!0}),r.JSONHeroPath=void 0;var i=e.r(230839),a=e.r(212757),s=e.r(770908);r.JSONHeroPath=function(){function e(e){if("string"==typeof e){var t=new i.default;this.components=t.parse(e);return}0==e.length&&e.push(new s.default),e[0]instanceof s.default||e.unshift(new s.default),this.components=e}return e.fromPointer=function(t){return new e(new i.default().parsePointer(t))},Object.defineProperty(e.prototype,"root",{get:function(){return new e(this.components.slice(0,1))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isRoot",{get:function(){return!(this.components.length>1)&&this.components[0]instanceof s.default},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"parent",{get:function(){return 1==this.components.length?null:new e(this.components.slice(0,-1))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"lastComponent",{get:function(){if(0!==this.components.length)return this.components[this.components.length-1]},enumerable:!1,configurable:!0}),e.prototype.child=function(t){return new e(this.toString().concat(".".concat(t)))},e.prototype.replaceComponent=function(t,r){var a=new i.default().parseComponent(r),s=n([],this.components,!0);return s[t]=a,new e(s)},e.prototype.toString=function(){return this.components.map(function(e){return e.toString()}).join(".")},e.prototype.jsonPointer=function(){return 1===this.components.length?"":this.components.map(function(e){return e.jsonPointer()}).join("/")},e.prototype.first=function(e,t){void 0===t&&(t={includePath:!1});var r=this.all(e,t);return null===r||0===r.length?null:r[0]},e.prototype.all=function(e,t){if(void 0===t&&(t={includePath:!1}),0==this.components.length||1==this.components.length&&this.components[0]instanceof s.default)return[e];var r=[],n=new a.default(0,this.root,e);r.push(n);for(var i=0;i<this.components.length;i++)if(null===(r=this.components[i].query(r))||0===r.length)return[];var o=r.map(function(e){return e.flatten()});if(!t.includePath)return o.map(function(e){return e.object});for(var l=[],i=0;i<o.length;i++){var u=o[i],d={value:u.object};t.includePath&&(d.path=u.path),l.push(d)}return l},e.prototype.set=function(e,t){this.all(e,{includePath:!0}).forEach(function(r){var n=r.path,i=n.parent,a=null==i?void 0:i.first(e);n.lastComponent&&(a[n.lastComponent.toString()]=t)})},e.prototype.merge=function(e,t){this.all(e,{includePath:!0}).forEach(function(r){var n=r.path,i=n.parent,a=null==i?void 0:i.first(e);if(n.lastComponent){var s=a[n.lastComponent.toString()];if(Array.isArray(s))a[n.lastComponent.toString()]=s.concat([t].flat());else{if("object"!=typeof t||Array.isArray(t))return;
2for(var o in t)s[o]=t[o]}}})},e}()},911,895397,e=>{"use strict";let t,r;var n,i,a,s,o,l,u,d,c,p,h,m,g,f,y,b,v,_,E,T,w,I,S,k,R,A,x,C,O,j,P,N,U,D,$,L,M,Z,G,q,H,K,B,W,F,V,z,Y,J,X,Q,ee,et,er,en,ei,ea,es,eo=e.i(237355);function el(e,t){if(!e)throw"string"==typeof t?Error(t):Error(`${t.displayName} not found`)}let[eu,ed,ec]=((e,t)=>{let{assertCtxFn:r=el}=t||{},n=eo.default.createContext(void 0);return n.displayName=e,[n,()=>{let t=eo.default.useContext(n);return r(t,`${e} not found`),t},()=>eo.default.useContext(n)||{}]})("TriggerAuthContext");e.s([],180703),e.i(180703),(or=oa||(oa={})).assertEqual=e=>{},or.assertIs=function(e){},or.assertNever=function(e){throw Error()},or.arrayToEnum=e=>{let t={};for(let r of e)t[r]=r;return t},or.getValidEnumValues=e=>{let t=or.objectKeys(e).filter(t=>"number"!=typeof e[e[t]]),r={};for(let n of t)r[n]=e[n];return or.objectValues(r)},or.objectValues=e=>or.objectKeys(e).map(function(t){return e[t]}),or.objectKeys="function"==typeof Object.keys?e=>Object.keys(e):e=>{let t=[];for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.push(r);return t},or.find=(e,t)=>{for(let r of e)if(t(r))return r},or.isInteger="function"==typeof Number.isInteger?e=>Number.isInteger(e):e=>"number"==typeof e&&Number.isFinite(e)&&Math.floor(e)===e,or.joinValues=function(e,t=" | "){return e.map(e=>"string"==typeof e?`'${e}'`:e).join(t)},or.jsonStringifyReplacer=(e,t)=>"bigint"==typeof t?t.toString():t,(os||(os={})).mergeShapes=(e,t)=>({...e,...t});let ep=oa.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),eh=e=>{switch(typeof e){case"undefined":return ep.undefined;case"string":return ep.string;case"number":return Number.isNaN(e)?ep.nan:ep.number;case"boolean":return ep.boolean;case"function":return ep.function;case"bigint":return ep.bigint;case"symbol":return ep.symbol;case"object":if(Array.isArray(e))return ep.array;if(null===e)return ep.null;if(e.then&&"function"==typeof e.then&&e.catch&&"function"==typeof e.catch)return ep.promise;if("u">typeof Map&&e instanceof Map)return ep.map;if("u">typeof Set&&e instanceof Set)return ep.set;if("u">typeof Date&&e instanceof Date)return ep.date;return ep.object;default:return ep.unknown}};e.s(["ZodParsedType",0,ep,"getParsedType",0,eh,"objectUtil",0,os,"util",0,oa],458728);
2let em=oa.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"]),eg=e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:");class ef extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){let t=e||function(e){return e.message},r={_errors:[]},n=e=>{for(let i of e.issues)if("invalid_union"===i.code)i.unionErrors.map(n);else if("invalid_return_type"===i.code)n(i.returnTypeError);else if("invalid_arguments"===i.code)n(i.argumentsError);else if(0===i.path.length)r._errors.push(t(i));else{let e=r,n=0;for(;n<i.path.length;){let r=i.path[n];n===i.path.length-1?(e[r]=e[r]||{_errors:[]},e[r]._errors.push(t(i))):e[r]=e[r]||{_errors:[]},e=e[r],n++}}};return n(this),r}static assert(e){if(!(e instanceof ef))throw Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,oa.jsonStringifyReplacer,2)}get isEmpty(){return 0===this.issues.length}flatten(e=e=>e.message){let t={},r=[];for(let n of this.issues)if(n.path.length>0){let r=n.path[0];t[r]=t[r]||[],t[r].push(e(n))}else r.push(e(n));return{formErrors:r,fieldErrors:t}}get formErrors(){return this.flatten()}}ef.create=e=>new ef(e),e.s(["ZodError",0,ef,"ZodIssueCode",0,em,"quotelessJson",0,eg],559413);let ey=(e,t)=>{let r;switch(e.code){case em.invalid_type:r=e.received===ep.undefined?"Required":`Expected ${e.expected}, received ${e.received}`;break;case em.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(e.expected,oa.jsonStringifyReplacer)}`;break;case em.unrecognized_keys:r=`Unrecognized key(s) in object: ${oa.joinValues(e.keys,", ")}`;break;case em.invalid_union:r="Invalid input";break;case em.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${oa.joinValues(e.options)}`;break;case em.invalid_enum_value:r=`Invalid enum value. Expected ${oa.joinValues(e.options)}, received '${e.received}'`;break;case em.invalid_arguments:r="Invalid function arguments";break;case em.invalid_return_type:r="Invalid function return type";break;case em.invalid_date:r="Invalid date";break;case em.invalid_string:"object"==typeof e.validation?"includes"in e.validation?(r=`Invalid input: must include "${e.validation.includes}"`,"number"==typeof e.validation.position&&(r=`${r} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?r=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?r=`Invalid input: must end with "${e.validation.endsWith}"`:oa.assertNever(e.validation):r="regex"!==e.validation?`Invalid ${e.validation}`:"Invalid";break;case em.too_small:r="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:"number"===e.type||"bigint"===e.type?`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:"date"===e.type?`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:"Invalid input";break;case em.too_big:r="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:"number"===e.type?`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"bigint"===e.type?`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"date"===e.type?`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:"Invalid input";break;case em.custom:r="Invalid input";break;
2case em.invalid_intersection_types:r="Intersection results could not be merged";break;case em.not_multiple_of:r=`Number must be a multiple of ${e.multipleOf}`;break;case em.not_finite:r="Number must be finite";break;default:r=t.defaultError,oa.assertNever(e)}return{message:r}},eb=ey;function ev(e){eb=e}function e_(){return eb}e.s(["getErrorMap",0,e_,"setErrorMap",0,ev],725827),e.i(725827),e.s(["defaultErrorMap",0,ey,"getErrorMap",0,e_,"setErrorMap",0,ev],279407),e.i(279407);let eE=e=>{let{data:t,path:r,errorMaps:n,issueData:i}=e,a=[...r,...i.path||[]],s={...i,path:a};if(void 0!==i.message)return{...i,path:a,message:i.message};let o="";for(let e of n.filter(e=>!!e).slice().reverse())o=e(s,{data:t,defaultError:o}).message;return{...i,path:a,message:o}},eT=[];function ew(e,t){let r=e_(),n=eE({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,r,r===ey?void 0:ey].filter(e=>!!e)});e.common.issues.push(n)}class eI{constructor(){this.value="valid"}dirty(){"valid"===this.value&&(this.value="dirty")}abort(){"aborted"!==this.value&&(this.value="aborted")}static mergeArray(e,t){let r=[];for(let n of t){if("aborted"===n.status)return eS;"dirty"===n.status&&e.dirty(),r.push(n.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,t){let r=[];for(let e of t){let t=await e.key,n=await e.value;r.push({key:t,value:n})}return eI.mergeObjectSync(e,r)}static mergeObjectSync(e,t){let r={};for(let n of t){let{key:t,value:i}=n;if("aborted"===t.status||"aborted"===i.status)return eS;"dirty"===t.status&&e.dirty(),"dirty"===i.status&&e.dirty(),"__proto__"!==t.value&&(void 0!==i.value||n.alwaysSet)&&(r[t.value]=i.value)}return{status:e.value,value:r}}}let eS=Object.freeze({status:"aborted"}),ek=e=>({status:"dirty",value:e}),eR=e=>({status:"valid",value:e}),eA=e=>"aborted"===e.status,ex=e=>"dirty"===e.status,eC=e=>"valid"===e.status,eO=e=>"u">typeof Promise&&e instanceof Promise;e.s(["DIRTY",0,ek,"EMPTY_PATH",0,eT,"INVALID",0,eS,"OK",0,eR,"ParseStatus",0,eI,"addIssueToContext",0,ew,"isAborted",0,eA,"isAsync",0,eO,"isDirty",0,ex,"isValid",0,eC,"makeIssue",0,eE],696555),e.i(696555),e.s([],924326),e.i(924326),e.i(458728),(on=oo||(oo={})).errToObj=e=>"string"==typeof e?{message:e}:e||{},on.toString=e=>"string"==typeof e?e:e?.message;class ej{constructor(e,t,r,n){this._cachedPath=[],this.parent=e,this.data=t,this._path=r,this._key=n}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}}let eP=(e,t)=>{if(eC(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let t=new ef(e.common.issues);return this._error=t,this._error}}};function eN(e){if(!e)return{};let{errorMap:t,invalid_type_error:r,required_error:n,description:i}=e;if(t&&(r||n))throw Error('Can\'t use "invalid_type_error" or "required_error" in conjunction with custom error map.');return t?{errorMap:t,description:i}:{errorMap:(t,i)=>{let{message:a}=e;return"invalid_enum_value"===t.code?{message:a??i.defaultError}:void 0===i.data?{message:a??n??i.defaultError}:"invalid_type"!==t.code?{message:i.defaultError}:{message:a??r??i.defaultError}},description:i}}class eU{get description(){return this._def.description}_getType(e){return eh(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:eh(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new eI,ctx:{common:e.parent.common,data:e.data,parsedType:eh(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(eO(t))throw Error("Synchronous parse encountered promise.");return t}_parseAsync(e){return Promise.resolve(this._parse(e))}parse(e,t){let r=this.safeParse(e,t);if(r.success)return r.data;throw r.error}safeParse(e,t){let r={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:eh(e)},n=this._parseSync({data:e,path:r.path,parent:r});return eP(r,n)}"~validate"(e){let t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:eh(e)};if(!this["~standard"].async)try{let r=this._parseSync({data:e,path:[],parent:t});return eC(r)?{value:r.value}:{issues:t.common.issues}}catch(e){e?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(e=>eC(e)?{value:e.value}:{issues:t.common.issues})}async parseAsync(e,t){let r=await this.safeParseAsync(e,t);if(r.success)return r.data;throw r.error}async safeParseAsync(e,t){let r={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:eh(e)},n=this._parse({data:e,path:r.path,parent:r});return eP(r,await (eO(n)?n:Promise.resolve(n)))}refine(e,t){return this._refinement((r,n)=>{let i=e(r),a=()=>n.addIssue({code:em.custom,..."string"==typeof t||void 0===t?{message:t}:"function"==typeof t?t(r):t});return"u">typeof Promise&&i instanceof Promise?i.then(e=>!!e||(a(),!1)):!!i||(a(),!1)})}refinement(e,t){return this._refinement((r,n)=>!!e(r)||(n.addIssue("function"==typeof t?t(r,n):t),!1))}_refinement(e){return new tv({schema:this,typeName:ol.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:e=>this["~validate"](e)}}optional(){return t_.create(this,this._def)}nullable(){return tE.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return tr.create(this)}promise(){return tb.create(this,this._def)}or(e){return ti.create([this,e],this._def)}and(e){return to.create(this,e,this._def)}transform(e){return new tv({...eN(this._def),schema:this,typeName:ol.ZodEffects,effect:{type:"transform",transform:e}})}default(e){return new tT({...eN(this._def),innerType:this,defaultValue:"function"==typeof e?e:()=>e,typeName:ol.ZodDefault})}brand(){return new tk({typeName:ol.ZodBranded,type:this,...eN(this._def)})}catch(e){return new tw({...eN(this._def),innerType:this,catchValue:"function"==typeof e?e:()=>e,typeName:ol.ZodCatch})}describe(e){return new this.constructor({...this._def,description:e})}pipe(e){return tR.create(this,e)}readonly(){return tA.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}let eD=/^c[^\s-]{8,}
2$/i,e$=/^[0-9a-z]+$/,eL=/^[0-9A-HJKMNP-TV-Z]{26}$/i,eM=/^[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,eZ=/^[a-z0-9_-]{21}$/i,eG=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,eq=/^[-+]?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)?)??$/,eH=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,eK=/^(?:(?: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])$/,eB=/^(?:(?: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])$/,eW=/^(([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]))$/,eF=/^(([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])$/,eV=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,ez=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,eY="((\\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])))",eJ=RegExp(`^${eY}$`);function eX(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:null==e.precision&&(t=`${t}(\\.\\d+)?`);let r=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${r}`}function eQ(e){let t=`${eY}T${eX(e)}`,r=[];return r.push(e.local?"Z?":"Z"),e.offset&&r.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${r.join("|")})`,RegExp(`^${t}$`)}class e0 extends eU{_parse(e){var r,n,i,a;let s;if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==ep.string){let t=this._getOrReturnCtx(e);return ew(t,{code:em.invalid_type,expected:ep.string,received:t.parsedType}),eS}let o=new eI;for(let l of this._def.checks)if("min"===l.kind)e.data.length<l.value&&(ew(s=this._getOrReturnCtx(e,s),{code:em.too_small,minimum:l.value,type:"string",inclusive:!0,exact:!1,message:l.message}),o.dirty());else if("max"===l.kind)e.data.length>l.value&&(ew(s=this._getOrReturnCtx(e,s),{code:em.too_big,maximum:l.value,type:"string",inclusive:!0,exact:!1,message:l.message}),o.dirty());else if("length"===l.kind){let t=e.data.length>l.value,r=e.data.length<l.value;(t||r)&&(s=this._getOrReturnCtx(e,s),t?ew(s,{code:em.too_big,maximum:l.value,type:"string",inclusive:!0,exact:!0,message:l.message}):r&&ew(s,{code:em.too_small,minimum:l.value,type:"string",inclusive:!0,exact:!0,message:l.message}),o.dirty())}else if("email"===l.kind)eH.test(e.data)||(ew(s=this._getOrReturnCtx(e,s),{validation:"email",code:em.invalid_string,message:l.message}),o.dirty());else if("emoji"===l.kind)t||(t=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),t.test(e.data)||(ew(s=this._getOrReturnCtx(e,s),{validation:"emoji",code:em.invali
2d_string,message:l.message}),o.dirty());else if("uuid"===l.kind)eM.test(e.data)||(ew(s=this._getOrReturnCtx(e,s),{validation:"uuid",code:em.invalid_string,message:l.message}),o.dirty());else if("nanoid"===l.kind)eZ.test(e.data)||(ew(s=this._getOrReturnCtx(e,s),{validation:"nanoid",code:em.invalid_string,message:l.message}),o.dirty());else if("cuid"===l.kind)eD.test(e.data)||(ew(s=this._getOrReturnCtx(e,s),{validation:"cuid",code:em.invalid_string,message:l.message}),o.dirty());else if("cuid2"===l.kind)e$.test(e.data)||(ew(s=this._getOrReturnCtx(e,s),{validation:"cuid2",code:em.invalid_string,message:l.message}),o.dirty());else if("ulid"===l.kind)eL.test(e.data)||(ew(s=this._getOrReturnCtx(e,s),{validation:"ulid",code:em.invalid_string,message:l.message}),o.dirty());else if("url"===l.kind)try{new URL(e.data)}catch{ew(s=this._getOrReturnCtx(e,s),{validation:"url",code:em.invalid_string,message:l.message}),o.dirty()}else"regex"===l.kind?(l.regex.lastIndex=0,l.regex.test(e.data)||(ew(s=this._getOrReturnCtx(e,s),{validation:"regex",code:em.invalid_string,message:l.message}),o.dirty())):"trim"===l.kind?e.data=e.data.trim():"includes"===l.kind?e.data.includes(l.value,l.position)||(ew(s=this._getOrReturnCtx(e,s),{code:em.invalid_string,validation:{includes:l.value,position:l.position},message:l.message}),o.dirty()):"toLowerCase"===l.kind?e.data=e.data.toLowerCase():"toUpperCase"===l.kind?e.data=e.data.toUpperCase():"startsWith"===l.kind?e.data.startsWith(l.value)||(ew(s=this._getOrReturnCtx(e,s),{code:em.invalid_string,validation:{startsWith:l.value},message:l.message}),o.dirty()):"endsWith"===l.kind?e.data.endsWith(l.value)||(ew(s=this._getOrReturnCtx(e,s),{code:em.invalid_string,validation:{endsWith:l.value},message:l.message}),o.dirty()):"datetime"===l.kind?eQ(l).test(e.data)||(ew(s=this._getOrReturnCtx(e,s),{code:em.invalid_string,validation:"datetime",message:l.message}),o.dirty()):"date"===l.kind?eJ.test(e.data)||(ew(s=this._getOrReturnCtx(e,s),{code:em.invalid_string,validation:"date",message:l.message}),o.dirty()):"time"===l.kind?RegExp(`^${eX(l)}$`).test(e.data)||(ew(s=this._getOrReturnCtx(e,s),{code:em.invalid_string,validation:"time",message:l.message}),o.dirty()):"duration"===l.kind?eq.test(e.data)||(ew(s=this._getOrReturnCtx(e,s),{validation:"duration",code:em.invalid_string,message:l.message}),o.dirty()):"ip"===l.kind?(r=e.data,!(("v4"===(n=l.version)||!n)&&eK.test(r)||("v6"===n||!n)&&eW.test(r))&&1&&(ew(s=this._getOrReturnCtx(e,s),{validation:"ip",code:em.invalid_string,message:l.message}),o.dirty())):"jwt"===l.kind?!function(e,t){if(!eG.test(e))return!1;try{let[r]=e.split(".");if(!r)return!1;let n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),i=JSON.parse(atob(n));if("object"!=typeof i||null===i||"typ"in i&&i?.typ!=="JWT"||!i.alg||t&&i.alg!==t)return!1;return!0}catch{return!1}}(e.data,l.alg)&&(ew(s=this._getOrReturnCtx(e,s),{validation:"jwt",code:em.invalid_string,message:l.message}),o.dirty()):"cidr"===l.kind?(i=e.data,!(("v4"===(a=l.version)||!a)&&eB.test(i)||("v6"===a||
2!a)&&eF.test(i))&&1&&(ew(s=this._getOrReturnCtx(e,s),{validation:"cidr",code:em.invalid_string,message:l.message}),o.dirty())):"base64"===l.kind?eV.test(e.data)||(ew(s=this._getOrReturnCtx(e,s),{validation:"base64",code:em.invalid_string,message:l.message}),o.dirty()):"base64url"===l.kind?ez.test(e.data)||(ew(s=this._getOrReturnCtx(e,s),{validation:"base64url",code:em.invalid_string,message:l.message}),o.dirty()):oa.assertNever(l);return{status:o.value,value:e.data}}_regex(e,t,r){return this.refinement(t=>e.test(t),{validation:t,code:em.invalid_string,...oo.errToObj(r)})}_addCheck(e){return new e0({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...oo.errToObj(e)})}url(e){return this._addCheck({kind:"url",...oo.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...oo.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...oo.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...oo.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...oo.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...oo.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...oo.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...oo.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...oo.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...oo.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...oo.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...oo.errToObj(e)})}datetime(e){return"string"==typeof e?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:void 0===e?.precision?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...oo.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return"string"==typeof e?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:void 0===e?.precision?null:e?.precision,...oo.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...oo.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...oo.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...oo.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...oo.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...oo.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...oo.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...oo.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...oo.errToObj(t)})}nonempty(e){return this.min(1,oo.errToObj(e))}trim(){return new e0({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new e0({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new e0({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>"datetime"===e.kind)}get isDate(){return!!this._def.checks.find(e=>"date"===e.kind)}get isTime(){return!!this._def.checks.find(e=>"time"===e.kind)}get isDuration(){return!!this._def.checks.find(e=>"duration"===e.kind)}get isEmail(){return!!this._def.checks.find(e=>"email"===e.kind)}get isURL(){return!!this._def.checks.find(e=>"url"===e.kind)}get isEmoji(){return!!this._def.checks.find(e=>"emoji"===e.kind)}get isUUID(){return!!this._def.checks.find(e=>"uuid"===e.kind)}get isNANOID(){return!!this._def.checks.find(e=>"nanoid"===e.kind)}get isCUID(){return!!this._def.checks.find(e=>"cuid"===e.kind)}get isCUID2(){return!!this._def.checks.find(e=>"cuid2"===e.kind)}get isULID(){return!!this._def.checks.find(e=>"ulid"===e.kind)}get isIP(){return!!this._def.checks.find(e=>"ip"===e.kind)}get isCIDR(){return!!this._def.checks.find(e=>"cidr"===e.kind)}get isBase64(){return!!this._def.checks.find(e=>"base64"===e.kind)}get isBase64url(){return!!this._def.checks.find(e=>"base64url"===e.kind)}get minLength(){let e=null;for(let t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}e0.create=e=>new e0({checks:[],typeName:ol.ZodString,coerce:e?.coerce??!1,...eN(e)});class e1 extends eU{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){let t;if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==ep.number){let t=this._getOrReturnCtx(e);
2return ew(t,{code:em.invalid_type,expected:ep.number,received:t.parsedType}),eS}let r=new eI;for(let n of this._def.checks)"int"===n.kind?oa.isInteger(e.data)||(ew(t=this._getOrReturnCtx(e,t),{code:em.invalid_type,expected:"integer",received:"float",message:n.message}),r.dirty()):"min"===n.kind?(n.inclusive?e.data<n.value:e.data<=n.value)&&(ew(t=this._getOrReturnCtx(e,t),{code:em.too_small,minimum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),r.dirty()):"max"===n.kind?(n.inclusive?e.data>n.value:e.data>=n.value)&&(ew(t=this._getOrReturnCtx(e,t),{code:em.too_big,maximum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),r.dirty()):"multipleOf"===n.kind?0!==function(e,t){let r=(e.toString().split(".")[1]||"").length,n=(t.toString().split(".")[1]||"").length,i=r>n?r:n;return Number.parseInt(e.toFixed(i).replace(".",""))%Number.parseInt(t.toFixed(i).replace(".",""))/10**i}(e.data,n.value)&&(ew(t=this._getOrReturnCtx(e,t),{code:em.not_multiple_of,multipleOf:n.value,message:n.message}),r.dirty()):"finite"===n.kind?Number.isFinite(e.data)||(ew(t=this._getOrReturnCtx(e,t),{code:em.not_finite,message:n.message}),r.dirty()):oa.assertNever(n);return{status:r.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,oo.toString(t))}gt(e,t){return this.setLimit("min",e,!1,oo.toString(t))}lte(e,t){return this.setLimit("max",e,!0,oo.toString(t))}lt(e,t){return this.setLimit("max",e,!1,oo.toString(t))}setLimit(e,t,r,n){return new e1({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:oo.toString(n)}]})}_addCheck(e){return new e1({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:oo.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:oo.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:oo.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:oo.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:oo.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:oo.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:oo.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:oo.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:oo.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>"int"===e.kind||"multipleOf"===e.kind&&oa.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let r of this._def.checks)if("finite"===r.kind||"int"===r.kind||"multipleOf"===r.kind)return!0;else"min"===r.kind?(null===t||r.value>t)&&(t=r.value):"max"===r.kind&&(null===e||r.value<e)&&(e=r.value);return Number.isFinite(t)&&Number.isFinite(e)}}e1.create=e=>new e1({checks:[],typeName:ol.ZodNumber,coerce:e?.coerce||!1,...eN(e)});class e2 extends eU{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){let t;if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==ep.bigint)return this._getInvalidInput(e);let r=new eI;for(let n of this._def.checks)"min"===n.kind?(n.inclusive?e.data<n.value:e.data<=n.value)&&(ew(t=this._getOrReturnCtx(e,t),{code:em.too_small,type:"bigint",minimum:n.value,inclusive:n.inclusive,message:n.message}),r.dirty()):"max"===n.kind?(n.inclusive?e.data>n.value:e.data>=n.value)&&(ew(t=this._getOrReturnCtx(e,t),{code:em.too_big,type:"bigint",maximum:n.value,inclusive:n.inclusive,message:n.message}),r.dirty()):"multipleOf"===n.kind?e.data%n.value!==BigInt(0)&&(ew(t=this._getOrReturnCtx(e,t),{code:em.not_multiple_of,multipleOf:n.value,message:n.message}),r.dirty()):oa.assertNever(n);return{status:r.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);
2return ew(t,{code:em.invalid_type,expected:ep.bigint,received:t.parsedType}),eS}gte(e,t){return this.setLimit("min",e,!0,oo.toString(t))}gt(e,t){return this.setLimit("min",e,!1,oo.toString(t))}lte(e,t){return this.setLimit("max",e,!0,oo.toString(t))}lt(e,t){return this.setLimit("max",e,!1,oo.toString(t))}setLimit(e,t,r,n){return new e2({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:oo.toString(n)}]})}_addCheck(e){return new e2({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:oo.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:oo.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:oo.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:oo.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:oo.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}e2.create=e=>new e2({checks:[],typeName:ol.ZodBigInt,coerce:e?.coerce??!1,...eN(e)});class e4 extends eU{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==ep.boolean){let t=this._getOrReturnCtx(e);return ew(t,{code:em.invalid_type,expected:ep.boolean,received:t.parsedType}),eS}return eR(e.data)}}e4.create=e=>new e4({typeName:ol.ZodBoolean,coerce:e?.coerce||!1,...eN(e)});class e9 extends eU{_parse(e){let t;if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==ep.date){let t=this._getOrReturnCtx(e);return ew(t,{code:em.invalid_type,expected:ep.date,received:t.parsedType}),eS}if(Number.isNaN(e.data.getTime()))return ew(this._getOrReturnCtx(e),{code:em.invalid_date}),eS;let r=new eI;for(let n of this._def.checks)"min"===n.kind?e.data.getTime()<n.value&&(ew(t=this._getOrReturnCtx(e,t),{code:em.too_small,message:n.message,inclusive:!0,exact:!1,minimum:n.value,type:"date"}),r.dirty()):"max"===n.kind?e.data.getTime()>n.value&&(ew(t=this._getOrReturnCtx(e,t),{code:em.too_big,message:n.message,inclusive:!0,exact:!1,maximum:n.value,type:"date"}),r.dirty()):oa.assertNever(n);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new e9({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:oo.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:oo.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return null!=e?new Date(e):null}get maxDate(){let e=null;for(let t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return null!=e?new Date(e):null}}e9.create=e=>new e9({checks:[],coerce:e?.coerce||!1,typeName:ol.ZodDate,...eN(e)});class e5 extends eU{_parse(e){if(this._getType(e)!==ep.symbol){let t=this._getOrReturnCtx(e);return ew(t,{code:em.invalid_type,expected:ep.symbol,received:t.parsedType}),eS}return eR(e.data)}}e5.create=e=>new e5({typeName:ol.ZodSymbol,...eN(e)});class e3 extends eU{_parse(e){if(this._getType(e)!==ep.undefined){let t=this._getOrReturnCtx(e);return ew(t,{code:em.invalid_type,expected:ep.undefined,received:t.parsedType}),eS}return eR(e.data)}}e3.create=e=>new e3({typeName:ol.ZodUndefined,...eN(e)});class e6 extends eU{_parse(e){if(this._getType(e)!==ep.null){let t=this._getOrReturnCtx(e);return ew(t,{code:em.invalid_type,expected:ep.null,received:t.parsedType}),eS}return eR(e.data)}}e6.create=e=>new e6({typeName:ol.ZodNull,...eN(e)});class e8 extends eU{constructor(){super(...arguments),this._any=!0}_parse(e){return eR(e.data)}}e8.create=e=>new e8({typeName:ol.ZodAny,...eN(e)});class e7 extends eU{constructor(){super(...arguments),this._unknown=!0}_parse(e){return eR(e.data)}}e7.create=e=>new e7({typeName:ol.ZodUnknown,...eN(e)});class te extends eU{_parse(e){let t=this._getOrReturnCtx(e);
2return ew(t,{code:em.invalid_type,expected:ep.never,received:t.parsedType}),eS}}te.create=e=>new te({typeName:ol.ZodNever,...eN(e)});class tt extends eU{_parse(e){if(this._getType(e)!==ep.undefined){let t=this._getOrReturnCtx(e);return ew(t,{code:em.invalid_type,expected:ep.void,received:t.parsedType}),eS}return eR(e.data)}}tt.create=e=>new tt({typeName:ol.ZodVoid,...eN(e)});class tr extends eU{_parse(e){let{ctx:t,status:r}=this._processInputParams(e),n=this._def;if(t.parsedType!==ep.array)return ew(t,{code:em.invalid_type,expected:ep.array,received:t.parsedType}),eS;if(null!==n.exactLength){let e=t.data.length>n.exactLength.value,i=t.data.length<n.exactLength.value;(e||i)&&(ew(t,{code:e?em.too_big:em.too_small,minimum:i?n.exactLength.value:void 0,maximum:e?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),r.dirty())}if(null!==n.minLength&&t.data.length<n.minLength.value&&(ew(t,{code:em.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),r.dirty()),null!==n.maxLength&&t.data.length>n.maxLength.value&&(ew(t,{code:em.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),r.dirty()),t.common.async)return Promise.all([...t.data].map((e,r)=>n.type._parseAsync(new ej(t,e,t.path,r)))).then(e=>eI.mergeArray(r,e));let i=[...t.data].map((e,r)=>n.type._parseSync(new ej(t,e,t.path,r)));return eI.mergeArray(r,i)}get element(){return this._def.type}min(e,t){return new tr({...this._def,minLength:{value:e,message:oo.toString(t)}})}max(e,t){return new tr({...this._def,maxLength:{value:e,message:oo.toString(t)}})}length(e,t){return new tr({...this._def,exactLength:{value:e,message:oo.toString(t)}})}nonempty(e){return this.min(1,e)}}tr.create=(e,t)=>new tr({type:e,minLength:null,maxLength:null,exactLength:null,typeName:ol.ZodArray,...eN(t)});class tn extends eU{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(null!==this._cached)return this._cached;let e=this._def.shape(),t=oa.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==ep.object){let t=this._getOrReturnCtx(e);return ew(t,{code:em.invalid_type,expected:ep.object,received:t.parsedType}),eS}let{status:t,ctx:r}=this._processInputParams(e),{shape:n,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof te&&"strip"===this._def.unknownKeys))for(let e in r.data)i.includes(e)||a.push(e);let s=[];for(let e of i){let t=n[e],i=r.data[e];s.push({key:{status:"valid",value:e},value:t._parse(new ej(r,i,r.path,e)),alwaysSet:e in r.data})}if(this._def.catchall instanceof te){let e=this._def.unknownKeys;if("passthrough"===e)for(let e of a)s.push({key:{status:"valid",value:e},value:{status:"valid",value:r.data[e]}});else if("strict"===e)a.length>0&&(ew(r,{code:em.unrecognized_keys,keys:a}),t.dirty());else if("strip"===e);else throw Error("Internal ZodObject error: invalid unknownKeys value.")}else{let e=this._def.catchall;for(let t of a){let n=r.data[t];s.push({key:{status:"valid",value:t},value:e._parse(new ej(r,n,r.path,t)),alwaysSet:t in r.data})}}return r.common.async?Promise.resolve().then(async()=>{let e=[];for(let t of s){let r=await t.key,n=await t.value;e.push({key:r,value:n,alwaysSet:t.alwaysSet})}return e}).then(e=>eI.mergeObjectSync(t,e)):eI.mergeObjectSync(t,s)}get shape(){return this._def.shape()}strict(e){return oo.errToObj,new tn({...this._def,unknownKeys:"strict",...void 0!==e?{errorMap:(t,r)=>{let n=this._def.errorMap?.(t,r).message??r.defaultError;return"unrecognized_keys"===t.code?{message:oo.errToObj(e).message??n}:{message:n}}}:{}})}strip(){return new tn({...this._def,unknownKeys:"strip"})}passthrough(){return new tn({...this._def,unknownKeys:"passthrough"})}extend(e){return new tn({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new tn({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:ol.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new tn({...this._def,catchall:e})}pick(e){let t={};for(let r of oa.objectKeys(e))e[r]&&this.shape[r]&&(t[r]=this.shape[r]);return new tn({...this._def,shape:()=>t})}omit(e){let t={};for(let r of oa.objectKeys(this.shape))e[r]||(t[r]=this.shape[r]);return new tn({...this._def,shape:()=>t})}deepPartial(){return function e(t){if(t instanceof tn){let r={};for(let n in t.shape){let i=t.shape[n];r[n]=t_.create(e(i))}return new tn({...t._def,shape:()=>r})}if(t instanceof tr)return new tr({...t._def,type:e(t.element)});if(t instanceof t_)return t_.create(e(t.unwrap()));if(t instanceof tE)return tE.create(e(t.unwrap()));if(t instanceof tl)return tl.create(t.items.map(t=>e(t)));else return t}(this)}partial(e){let t={};for(let r of oa.objectKeys(this.shape)){let n=this.shape[r];e&&!e[r]?t[r]=n:t[r]=n.optional()}return new tn({...this._def,shape:()=>t})}required(e){let t={};for(let r of oa.objectKeys(this.shape))if(e&&!e[r])t[r]=this.shape[r];else{let e=this.shape[r];for(;e instanceof t_;)e=e._def.innerType;t[r]=e}return new tn({...this._def,shape:()=>t})}keyof(){return tg(oa.objectKeys(this.shape))}}tn.create=(e,t)=>
2new tn({shape:()=>e,unknownKeys:"strip",catchall:te.create(),typeName:ol.ZodObject,...eN(t)}),tn.strictCreate=(e,t)=>new tn({shape:()=>e,unknownKeys:"strict",catchall:te.create(),typeName:ol.ZodObject,...eN(t)}),tn.lazycreate=(e,t)=>new tn({shape:e,unknownKeys:"strip",catchall:te.create(),typeName:ol.ZodObject,...eN(t)});class ti extends eU{_parse(e){let{ctx:t}=this._processInputParams(e),r=this._def.options;if(t.common.async)return Promise.all(r.map(async e=>{let r={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:r}),ctx:r}})).then(function(e){for(let t of e)if("valid"===t.result.status)return t.result;for(let r of e)if("dirty"===r.result.status)return t.common.issues.push(...r.ctx.common.issues),r.result;let r=e.map(e=>new ef(e.ctx.common.issues));return ew(t,{code:em.invalid_union,unionErrors:r}),eS});{let e,n=[];for(let i of r){let r={...t,common:{...t.common,issues:[]},parent:null},a=i._parseSync({data:t.data,path:t.path,parent:r});if("valid"===a.status)return a;"dirty"!==a.status||e||(e={result:a,ctx:r}),r.common.issues.length&&n.push(r.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;let i=n.map(e=>new ef(e));return ew(t,{code:em.invalid_union,unionErrors:i}),eS}}get options(){return this._def.options}}ti.create=(e,t)=>new ti({options:e,typeName:ol.ZodUnion,...eN(t)});let ta=e=>{if(e instanceof th)return ta(e.schema);if(e instanceof tv)return ta(e.innerType());if(e instanceof tm)return[e.value];if(e instanceof tf)return e.options;if(e instanceof ty)return oa.objectValues(e.enum);else if(e instanceof tT)return ta(e._def.innerType);else if(e instanceof e3)return[void 0];else if(e instanceof e6)return[null];else if(e instanceof t_)return[void 0,...ta(e.unwrap())];else if(e instanceof tE)return[null,...ta(e.unwrap())];else if(e instanceof tk)return ta(e.unwrap());else if(e instanceof tA)return ta(e.unwrap());else if(e instanceof tw)return ta(e._def.innerType);else return[]};class ts extends eU{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==ep.object)return ew(t,{code:em.invalid_type,expected:ep.object,received:t.parsedType}),eS;let r=this.discriminator,n=t.data[r],i=this.optionsMap.get(n);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):(ew(t,{code:em.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),eS)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,r){let n=new Map;for(let r of t){let t=ta(r.shape[e]);if(!t.length)throw Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let i of t){if(n.has(i))throw Error(`Discriminator property ${String(e)} has duplicate value ${String(i)}`);n.set(i,r)}}return new ts({typeName:ol.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:n,...eN(r)})}}class to extends eU{_parse(e){let{status:t,ctx:r}=this._processInputParams(e),n=(e,n)=>{if(eA(e)||eA(n))return eS;let i=function e(t,r){let n=eh(t),i=eh(r);if(t===r)return{valid:!0,data:t};if(n===ep.object&&i===ep.object){let n=oa.objectKeys(r),i=oa.objectKeys(t).filter(e=>-1!==n.indexOf(e)),a={...t,...r};for(let n of i){let i=e(t[n],r[n]);if(!i.valid)return{valid:!1};a[n]=i.data}return{valid:!0,data:a}}if(n===ep.array&&i===ep.array){if(t.length!==r.length)return{valid:!1};let n=[];for(let i=0;i<t.length;i++){let a=e(t[i],r[i]);if(!a.valid)return{valid:!1};n.push(a.data)}return{valid:!0,data:n}}if(n===ep.date&&i===ep.date&&+t==+r)return{valid:!0,data:t};return{valid:!1}}(e.value,n.value);return i.valid?((ex(e)||ex(n))&&t.dirty(),{status:t.value,value:i.data}):(ew(r,{code:em.invalid_intersection_types}),eS)};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(([e,t])=>n(e,t)):n(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}to.create=(e,t,r)=>new to({left:e,right:t,typeName:ol.ZodIntersection,...eN(r)});class tl extends eU{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);
2if(r.parsedType!==ep.array)return ew(r,{code:em.invalid_type,expected:ep.array,received:r.parsedType}),eS;if(r.data.length<this._def.items.length)return ew(r,{code:em.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),eS;!this._def.rest&&r.data.length>this._def.items.length&&(ew(r,{code:em.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());let n=[...r.data].map((e,t)=>{let n=this._def.items[t]||this._def.rest;return n?n._parse(new ej(r,e,r.path,t)):null}).filter(e=>!!e);return r.common.async?Promise.all(n).then(e=>eI.mergeArray(t,e)):eI.mergeArray(t,n)}get items(){return this._def.items}rest(e){return new tl({...this._def,rest:e})}}tl.create=(e,t)=>{if(!Array.isArray(e))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new tl({items:e,typeName:ol.ZodTuple,rest:null,...eN(t)})};class tu extends eU{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==ep.object)return ew(r,{code:em.invalid_type,expected:ep.object,received:r.parsedType}),eS;let n=[],i=this._def.keyType,a=this._def.valueType;for(let e in r.data)n.push({key:i._parse(new ej(r,e,r.path,e)),value:a._parse(new ej(r,r.data[e],r.path,e)),alwaysSet:e in r.data});return r.common.async?eI.mergeObjectAsync(t,n):eI.mergeObjectSync(t,n)}get element(){return this._def.valueType}static create(e,t,r){return new tu(t instanceof eU?{keyType:e,valueType:t,typeName:ol.ZodRecord,...eN(r)}:{keyType:e0.create(),valueType:e,typeName:ol.ZodRecord,...eN(t)})}}class td extends eU{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==ep.map)return ew(r,{code:em.invalid_type,expected:ep.map,received:r.parsedType}),eS;let n=this._def.keyType,i=this._def.valueType,a=[...r.data.entries()].map(([e,t],a)=>({key:n._parse(new ej(r,e,r.path,[a,"key"])),value:i._parse(new ej(r,t,r.path,[a,"value"]))}));if(r.common.async){let e=new Map;return Promise.resolve().then(async()=>{for(let r of a){let n=await r.key,i=await r.value;if("aborted"===n.status||"aborted"===i.status)return eS;("dirty"===n.status||"dirty"===i.status)&&t.dirty(),e.set(n.value,i.value)}return{status:t.value,value:e}})}{let e=new Map;for(let r of a){let n=r.key,i=r.value;if("aborted"===n.status||"aborted"===i.status)return eS;("dirty"===n.status||"dirty"===i.status)&&t.dirty(),e.set(n.value,i.value)}return{status:t.value,value:e}}}}td.create=(e,t,r)=>new td({valueType:t,keyType:e,typeName:ol.ZodMap,...eN(r)});class tc extends eU{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==ep.set)return ew(r,{code:em.invalid_type,expected:ep.set,received:r.parsedType}),eS;let n=this._def;null!==n.minSize&&r.data.size<n.minSize.value&&(ew(r,{code:em.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),t.dirty()),null!==n.maxSize&&r.data.size>n.maxSize.value&&(ew(r,{code:em.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),t.dirty());let i=this._def.valueType;function a(e){let r=new Set;for(let n of e){if("aborted"===n.status)return eS;"dirty"===n.status&&t.dirty(),r.add(n.value)}return{status:t.value,value:r}}let s=[...r.data.values()].map((e,t)=>i._parse(new ej(r,e,r.path,t)));return r.common.async?Promise.all(s).then(e=>a(e)):a(s)}min(e,t){return new tc({...this._def,minSize:{value:e,message:oo.toString(t)}})}max(e,t){return new tc({...this._def,maxSize:{value:e,message:oo.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}tc.create=(e,t)=>new tc({valueType:e,minSize:null,maxSize:null,typeName:ol.ZodSet,...eN(t)});class tp extends eU{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==ep.function)return ew(t,{code:em.invalid_type,expected:ep.function,received:t.parsedType}),eS;function r(e,r){return eE({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,e_(),ey].filter(e=>
2!!e),issueData:{code:em.invalid_arguments,argumentsError:r}})}function n(e,r){return eE({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,e_(),ey].filter(e=>!!e),issueData:{code:em.invalid_return_type,returnTypeError:r}})}let i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof tb){let e=this;return eR(async function(...t){let s=new ef([]),o=await e._def.args.parseAsync(t,i).catch(e=>{throw s.addIssue(r(t,e)),s}),l=await Reflect.apply(a,this,o);return await e._def.returns._def.type.parseAsync(l,i).catch(e=>{throw s.addIssue(n(l,e)),s})})}{let e=this;return eR(function(...t){let s=e._def.args.safeParse(t,i);if(!s.success)throw new ef([r(t,s.error)]);let o=Reflect.apply(a,this,s.data),l=e._def.returns.safeParse(o,i);if(!l.success)throw new ef([n(o,l.error)]);return l.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new tp({...this._def,args:tl.create(e).rest(e7.create())})}returns(e){return new tp({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,r){return new tp({args:e||tl.create([]).rest(e7.create()),returns:t||e7.create(),typeName:ol.ZodFunction,...eN(r)})}}class th extends eU{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}th.create=(e,t)=>new th({getter:e,typeName:ol.ZodLazy,...eN(t)});class tm extends eU{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return ew(t,{received:t.data,code:em.invalid_literal,expected:this._def.value}),eS}return{status:"valid",value:e.data}}get value(){return this._def.value}}function tg(e,t){return new tf({values:e,typeName:ol.ZodEnum,...eN(t)})}tm.create=(e,t)=>new tm({value:e,typeName:ol.ZodLiteral,...eN(t)});class tf extends eU{_parse(e){if("string"!=typeof e.data){let t=this._getOrReturnCtx(e),r=this._def.values;return ew(t,{expected:oa.joinValues(r),received:t.parsedType,code:em.invalid_type}),eS}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),r=this._def.values;return ew(t,{received:t.data,code:em.invalid_enum_value,options:r}),eS}return eR(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return tf.create(e,{...this._def,...t})}exclude(e,t=this._def){return tf.create(this.options.filter(t=>!e.includes(t)),{...this._def,...t})}}tf.create=tg;class ty extends eU{_parse(e){let t=oa.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==ep.string&&r.parsedType!==ep.number){let e=oa.objectValues(t);return ew(r,{expected:oa.joinValues(e),received:r.parsedType,code:em.invalid_type}),eS}if(this._cache||(this._cache=new Set(oa.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let e=oa.objectValues(t);return ew(r,{received:r.data,code:em.invalid_enum_value,options:e}),eS}return eR(e.data)}get enum(){return this._def.values}}ty.create=(e,t)=>new ty({values:e,typeName:ol.ZodNativeEnum,...eN(t)});class tb extends eU{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);return t.parsedType!==ep.promise&&!1===t.common.async?(ew(t,{code:em.invalid_type,expected:ep.promise,received:t.parsedType}),eS):eR((t.parsedType===ep.promise?t.data:Promise.resolve(t.data)).then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}}tb.create=(e,t)=>new tb({type:e,typeName:ol.ZodPromise,...eN(t)});class tv extends eU{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===ol.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:r}=this._processInputParams(e),n=this._def.effect||null,i={addIssue:e=>{ew(r,e),e.fatal?t.abort():t.dirty()},get path(){return r.path}};if(i.addIssue=i.addIssue.bind(i),"preprocess"===n.type){let e=n.transform(r.data,i);if(r.common.async)return Promise.resolve(e).then(async e=>{if("aborted"===t.value)return eS;let n=await this._def.schema._parseAsync({data:e,path:r.path,parent:r});return"aborted"===n.status?eS:"dirty"===n.status||"dirty"===t.value?ek(n.value):n});{if("aborted"===t.value)return eS;let n=this._def.schema._parseSync({data:e,path:r.path,parent:r});return"aborted"===n.status?eS:"dirty"===n.status||"dirty"===t.value?ek(n.value):n}}if("refinement"===n.type){let e=e=>{let t=n.refinement(e,i);if(r.common.async)return Promise.resolve(t);if(t instanceof Promise)throw Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return e};if(!1!==r.common.async)return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(r=>"aborted"===r.status?eS:("dirty"===r.status&&t.dirty(),e(r.value).then(()=>({status:t.value,value:r.value}))));{let n=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return"aborted"===n.status?eS:("dirty"===n.status&&t.dirty(),e(n.value),{status:t.value,value:n.value})}}if("transform"===n.type)if(!1!==r.common.async)return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(e=>eC(e)?Promise.resolve(n.transform(e.value,i)).then(e=>({status:t.value,value:e})):eS);else{let e=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!eC(e))return eS;let a=n.transform(e.value,i);if(a instanceof Promise)throw Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:a}}oa.assertNever(n)}}tv.create=(e,t,r)=>new tv({schema:e,typeName:ol.ZodEffects,effect:t,...eN(r)}),tv.createWithPreprocess=(e,t,r)=>new tv({schema:t,effect:{type:"preprocess",transform:e},typeName:ol.ZodEffects,...eN(r)});class t_ extends eU{_parse(e){return this._getType(e)===ep.undefined?eR(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}t_.create=(e,t)=>
2new t_({innerType:e,typeName:ol.ZodOptional,...eN(t)});class tE extends eU{_parse(e){return this._getType(e)===ep.null?eR(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}tE.create=(e,t)=>new tE({innerType:e,typeName:ol.ZodNullable,...eN(t)});class tT extends eU{_parse(e){let{ctx:t}=this._processInputParams(e),r=t.data;return t.parsedType===ep.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}tT.create=(e,t)=>new tT({innerType:e,typeName:ol.ZodDefault,defaultValue:"function"==typeof t.default?t.default:()=>t.default,...eN(t)});class tw extends eU{_parse(e){let{ctx:t}=this._processInputParams(e),r={...t,common:{...t.common,issues:[]}},n=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return eO(n)?n.then(e=>({status:"valid",value:"valid"===e.status?e.value:this._def.catchValue({get error(){return new ef(r.common.issues)},input:r.data})})):{status:"valid",value:"valid"===n.status?n.value:this._def.catchValue({get error(){return new ef(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}tw.create=(e,t)=>new tw({innerType:e,typeName:ol.ZodCatch,catchValue:"function"==typeof t.catch?t.catch:()=>t.catch,...eN(t)});class tI extends eU{_parse(e){if(this._getType(e)!==ep.nan){let t=this._getOrReturnCtx(e);return ew(t,{code:em.invalid_type,expected:ep.nan,received:t.parsedType}),eS}return{status:"valid",value:e.data}}}tI.create=e=>new tI({typeName:ol.ZodNaN,...eN(e)});let tS=Symbol("zod_brand");class tk extends eU{_parse(e){let{ctx:t}=this._processInputParams(e),r=t.data;return this._def.type._parse({data:r,path:t.path,parent:t})}unwrap(){return this._def.type}}class tR extends eU{_parse(e){let{status:t,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{let e=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return"aborted"===e.status?eS:"dirty"===e.status?(t.dirty(),ek(e.value)):this._def.out._parseAsync({data:e.value,path:r.path,parent:r})})();{let e=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return"aborted"===e.status?eS:"dirty"===e.status?(t.dirty(),{status:"dirty",value:e.value}):this._def.out._parseSync({data:e.value,path:r.path,parent:r})}}static create(e,t){return new tR({in:e,out:t,typeName:ol.ZodPipeline})}}class tA extends eU{_parse(e){let t=this._def.innerType._parse(e),r=e=>(eC(e)&&(e.value=Object.freeze(e.value)),e);return eO(t)?t.then(e=>r(e)):r(t)}unwrap(){return this._def.innerType}}function tx(e,t){let r="function"==typeof e?e(t):"string"==typeof e?{message:e}:e;return"string"==typeof r?{message:r}:r}function tC(e,t={},r){return e?e8.create().superRefine((n,i)=>{let a=e(n);if(a instanceof Promise)return a.then(e=>{if(!e){let e=tx(t,n),a=e.fatal??r??!0;i.addIssue({code:"custom",...e,fatal:a})}});if(!a){let e=tx(t,n),a=e.fatal??r??!0;i.addIssue({code:"custom",...e,fatal:a})}}):e8.create()}tA.create=(e,t)=>new tA({innerType:e,typeName:ol.ZodReadonly,...eN(t)});let tO={object:tn.lazycreate};(oi=ol||(ol={})).ZodString="ZodString",oi.ZodNumber="ZodNumber",oi.ZodNaN="ZodNaN",oi.ZodBigInt="ZodBigInt",oi.ZodBoolean="ZodBoolean",oi.ZodDate="ZodDate",oi.ZodSymbol="ZodSymbol",oi.ZodUndefined="ZodUndefined",oi.ZodNull="ZodNull",oi.ZodAny="ZodAny",oi.ZodUnknown="ZodUnknown",oi.ZodNever="ZodNever",oi.ZodVoid="ZodVoid",oi.ZodArray="ZodArray",oi.ZodObject="ZodObject",oi.ZodUnion="ZodUnion",oi.ZodDiscriminatedUnion="ZodDiscriminatedUnion",oi.ZodIntersection="ZodIntersection",oi.ZodTuple="ZodTuple",oi.ZodRecord="ZodRecord",oi.ZodMap="ZodMap",oi.ZodSet="ZodSet",oi.ZodFunction="ZodFunction",oi.ZodLazy="ZodLazy",oi.ZodLiteral="ZodLiteral",oi.ZodEnum="ZodEnum",oi.ZodEffects="ZodEffects",oi.ZodNativeEnum="ZodNativeEnum",oi.ZodOptional="ZodOptional",oi.ZodNullable="ZodNullable",oi.ZodDefault="ZodDefault",oi.ZodCatch="ZodCatch",oi.ZodPromise="ZodPromise",oi.ZodBranded="ZodBranded",oi.ZodPipeline="ZodPipeline",oi.ZodReadonly="ZodReadonly";let tj=(e,t={message:`Input not instance of ${e.name}`})=>tC(t=>t instanceof e,t),tP=e0.create,tN=e1.create,tU=tI.create,tD=e2.create,t$=e4.create,tL=e9.create,tM=e5.create,tZ=e3.create,tG=e6.create,tq=e8.create,tH=e7.create,tK=te.create,tB=tt.create,tW=tr.create,tF=tn.create,tV=tn.strictCreate,tz=ti.create,tY=ts.create,tJ=to.create,tX=tl.create,tQ=tu.create,t0=td.create,t1=tc.create,t2=tp.create,t4=th.create,t9=tm.create,t5=tf.create,t3=ty.create,t6=tb.create,t8=tv.create,t7=t_.create,re=tE.create,rt=tv.createWithPreprocess,rr=tR.create,rn=()=>tP().optional(),ri=()=>tN().optional(),ra=()=>t$().optional(),rs={string:e=>e0.create({...e,coerce:!0}),number:e=>e1.create({...e,coerce:!0}),boolean:e=>e4.create({...e,coerce:!0}),bigint:e=>e2.create({...e,coerce:!0}),date:e=>e9.create({...e,coerce:!0})};e.s(["BRAND",0,tS,"NEVER",0,eS,"Schema",0,eU,"ZodAny",0,e8,"ZodArray",0,tr,"ZodBigInt",0,e2,"ZodBoolean",0,e4,"ZodBranded",0,tk,"ZodCatch",0,tw,"ZodD
2ate",0,e9,"ZodDefault",0,tT,"ZodDiscriminatedUnion",0,ts,"ZodEffects",0,tv,"ZodEnum",0,tf,"ZodFirstPartyTypeKind",0,ol,"ZodFunction",0,tp,"ZodIntersection",0,to,"ZodLazy",0,th,"ZodLiteral",0,tm,"ZodMap",0,td,"ZodNaN",0,tI,"ZodNativeEnum",0,ty,"ZodNever",0,te,"ZodNull",0,e6,"ZodNullable",0,tE,"ZodNumber",0,e1,"ZodObject",0,tn,"ZodOptional",0,t_,"ZodPipeline",0,tR,"ZodPromise",0,tb,"ZodReadonly",0,tA,"ZodRecord",0,tu,"ZodSchema",0,eU,"ZodSet",0,tc,"ZodString",0,e0,"ZodSymbol",0,e5,"ZodTransformer",0,tv,"ZodTuple",0,tl,"ZodType",0,eU,"ZodUndefined",0,e3,"ZodUnion",0,ti,"ZodUnknown",0,e7,"ZodVoid",0,tt,"any",0,tq,"array",0,tW,"bigint",0,tD,"boolean",0,t$,"coerce",0,rs,"custom",0,tC,"date",0,tL,"datetimeRegex",0,eQ,"discriminatedUnion",0,tY,"effect",0,t8,"enum",0,t5,"function",0,t2,"instanceof",0,tj,"intersection",0,tJ,"late",0,tO,"lazy",0,t4,"literal",0,t9,"map",0,t0,"nan",0,tU,"nativeEnum",0,t3,"never",0,tK,"null",0,tG,"nullable",0,re,"number",0,tN,"object",0,tF,"oboolean",0,ra,"onumber",0,ri,"optional",0,t7,"ostring",0,rn,"pipeline",0,rr,"preprocess",0,rt,"promise",0,t6,"record",0,tQ,"set",0,t1,"strictObject",0,tV,"string",0,tP,"symbol",0,tM,"transformer",0,t8,"tuple",0,tX,"undefined",0,tZ,"union",0,tz,"unknown",0,tH,"void",0,tB],703016),e.i(703016),e.i(559413),e.s(["BRAND",0,tS,"DIRTY",0,ek,"EMPTY_PATH",0,eT,"INVALID",0,eS,"NEVER",0,eS,"OK",0,eR,"ParseStatus",0,eI,"Schema",0,eU,"ZodAny",0,e8,"ZodArray",0,tr,"ZodBigInt",0,e2,"ZodBoolean",0,e4,"ZodBranded",0,tk,"ZodCatch",0,tw,"ZodDate",0,e9,"ZodDefault",0,tT,"ZodDiscriminatedUnion",0,ts,"ZodEffects",0,tv,"ZodEnum",0,tf,"ZodError",0,ef,"ZodFirstPartyTypeKind",0,ol,"ZodFunction",0,tp,"ZodIntersection",0,to,"ZodIssueCode",0,em,"ZodLazy",0,th,"ZodLiteral",0,tm,"ZodMap",0,td,"ZodNaN",0,tI,"ZodNativeEnum",0,ty,"ZodNever",0,te,"ZodNull",0,e6,"ZodNullable",0,tE,"ZodNumber",0,e1,"ZodObject",0,tn,"ZodOptional",0,t_,"ZodParsedType",0,ep,"ZodPipeline",0,tR,"ZodPromise",0,tb,"ZodReadonly",0,tA,"ZodRecord",0,tu,"ZodSchema",0,eU,"ZodSet",0,tc,"ZodString",0,e0,"ZodSymbol",0,e5,"ZodTransformer",0,tv,"ZodTuple",0,tl,"ZodType",0,eU,"ZodUndefined",0,e3,"ZodUnion",0,ti,"ZodUnknown",0,e7,"ZodVoid",0,tt,"addIssueToContext",0,ew,"any",0,tq,"array",0,tW,"bigint",0,tD,"boolean",0,t$,"coerce",0,rs,"custom",0,tC,"date",0,tL,"datetimeRegex",0,eQ,"defaultErrorMap",0,ey,"discriminatedUnion",0,tY,"effect",0,t8,"enum",0,t5,"function",0,t2,"getErrorMap",0,e_,"getParsedType",0,eh,"instanceof",0,tj,"intersection",0,tJ,"isAborted",0,eA,"isAsync",0,eO,"isDirty",0,ex,"isValid",0,eC,"late",0,tO,"lazy",0,t4,"literal",0,t9,"makeIssue",0,eE,"map",0,t0,"nan",0,tU,"nativeEnum",0,t3,"never",0,tK,"null",0,tG,"nullable",0,re,"number",0,tN,"object",0,tF,"objectUtil",0,os,"oboolean",0,ra,"onumber",0,ri,"optional",0,t7,"ostring",0,rn,"pipeline",0,rr,"preprocess",0,rt,"promise",0,t6,"quotelessJson",0,eg,"record",0,tQ,"set",0,t1,"setErrorMap",0,ev,"strictObject",0,tV,"string",0,tP,"symbol",0,tM,"transformer",0,t8,"tuple",0,tX,"undefined",0,tZ,"union",0,tz,"unknown",0,tH,"util",0,oa,"void",0,tB],966951);var ro=e.i(966951),ro=ro;let rl="4.5.15",ru=/^tr_(dev|stg|prod|preview)_sk_[0-9a-zA-Z]{24}$/;async function rd(t){let{SignJWT:r}=await e.A(80826),n=new TextEncoder().encode(t.secretKey),i=new r(t.payload).setIssuer("https://id.trigger.dev").setAudience("https://api.trigger.dev").setProtectedHeader({alg:"HS256"}).setExpirationTime(t.expirationTime??"15m");return t.omitIssuedAt||i.setIssuedAt(),i.sign(n)}var ro=ro,ro=ro;let rc=ro.union([ro.string(),ro.number(),ro.boolean(),ro.null()]),rp=ro.lazy(()=>ro.union([rc,ro.array(rp),ro.record(rp)])),rh=ro.union([ro.string(),ro.number(),ro.boolean(),ro.null(),ro.date(),ro.undefined(),ro.symbol()]),rm=ro.lazy(()=>ro.union([rh,ro.array(rm),ro.record(rm)]));var ro=ro;let rg=new Set(["__proto__","constructor","prototype"]),rf=ro.string().refine(function(e){return e.startsWith("$.")?!e.split(/[.[\]'"]+/).some(e=>rg.has(e)):"__proto__"!==e},{message:"Metadata key may not reference __proto__, constructor, or prototype"}),ry=ro.object({type:ro.literal("update"),value:ro.record(ro.unknown())}),rb=ro.object({type:ro.literal("set"),key:rf,value:rp}),rv=ro.object({type:ro.literal("delete"),key:rf}),r_=ro.object({type:ro.literal("append"),key:rf,value:rp}),rE=ro.object({type:ro.literal("remove"),key:rf,value:rp}),rT=ro.object({type:ro.literal("increment"),key:rf,value:ro.number()}),rw=ro.discriminatedUnion("type",[ry,rb,rv,r_,rE,rT]),rI=ro.object({metadata:ro.record(rp).optional(),operations:ro.array(rw).optional(),parentOperations:ro.array(rw).optional(),rootOperations:ro.array(rw).optional()}),rS=ro.union([ro.literal(.25),ro.literal(.5),ro.literal(1),ro.literal(2),ro.literal(4)]),rk=ro.union([ro.literal(.25),ro.literal(.5),ro.literal(1),ro.literal(2),ro.literal(4),ro.literal(8)]),rR=ro.enum(["micro","small-1x","small-2x","medium-1x","medium-2x","large-1x","large-2x"]),rA=ro.object({cpu:rS.optional(),memory:rk.optional(),preset:rR.optional()}),rx=ro.object({name:rR,cpu:ro.number(),memory:ro.number(),centsPerMs:ro.number()}),rC=ro.object({type:ro.literal("BUILT_IN_ERROR"),name:ro.string(),message:ro.string(),stackTrace:ro.string()}),rO=ro.object({type:ro.literal("CUSTOM_ERROR"),raw:ro.string()}),rj=ro.object({type:ro.literal("STRING_ERROR"),raw:ro.string()}),rP=ro.object({type:ro.literal("INTERNAL_ERROR"),code:ro.enum(["COULD_NOT_FIND_EXECUTOR","COULD_NOT_FIND_TASK","COULD_NOT_IMPORT_TASK","CONFIGURED_INCORRECTLY","TASK_ALREADY_RUNNING","TASK_EXECUTION_FAILED","TASK_
2EXECUTION_ABORTED","TASK_PROCESS_EXITED_WITH_NON_ZERO_CODE","TASK_PROCESS_SIGKILL_TIMEOUT","TASK_PROCESS_SIGSEGV","TASK_PROCESS_SIGTERM","TASK_PROCESS_OOM_KILLED","TASK_PROCESS_MAYBE_OOM_KILLED","TASK_RUN_CANCELLED","TASK_INPUT_ERROR","TASK_OUTPUT_ERROR","TASK_MIDDLEWARE_ERROR","HANDLE_ERROR_ERROR","GRACEFUL_EXIT_TIMEOUT","TASK_RUN_HEARTBEAT_TIMEOUT","TASK_RUN_CRASHED","TASK_RUN_UNCAUGHT_EXCEPTION","MAX_DURATION_EXCEEDED","DISK_SPACE_EXCEEDED","POD_EVICTED","POD_UNKNOWN_ERROR","TASK_HAS_N0_EXECUTION_SNAPSHOT","TASK_DEQUEUED_INVALID_STATE","TASK_DEQUEUED_QUEUE_NOT_FOUND","TASK_RUN_DEQUEUED_MAX_RETRIES","TASK_RUN_STALLED_EXECUTING","TASK_RUN_STALLED_EXECUTING_WITH_WAITPOINTS","OUTDATED_SDK_VERSION","TASK_DID_CONCURRENT_WAIT","RECURSIVE_WAIT_DEADLOCK","BATCH_ITEM_COULD_NOT_TRIGGER","PAYLOAD_TOO_LARGE","UNSPECIFIED_ERROR"]),message:ro.string().optional(),stackTrace:ro.string().optional()}),rN=rP.shape.code.enum,rU=ro.discriminatedUnion("type",[rC,rO,rj,rP]),rD=ro.object({id:ro.string(),payload:ro.string(),payloadType:ro.string(),tags:ro.array(ro.string()),isTest:ro.boolean().default(!1),isReplay:ro.boolean().default(!1),createdAt:ro.coerce.date(),startedAt:ro.coerce.date().default(()=>new Date),idempotencyKey:ro.string().optional(),idempotencyKeyScope:ro.enum(["run","attempt","global"]).optional(),maxAttempts:ro.number().optional(),version:ro.string().optional(),metadata:ro.record(rp).optional(),maxDuration:ro.number().optional(),priority:ro.number().optional(),baseCostInCents:ro.number().optional(),parentTaskRunId:ro.string().optional(),rootTaskRunId:ro.string().optional(),durationMs:ro.number().optional(),costInCents:ro.number().optional(),region:ro.string().optional()}),r$=ro.object({provider:ro.string().optional(),source:ro.enum(["trigger_github_app","github_actions","local"]).optional(),ghUsername:ro.string().optional(),ghUserAvatarUrl:ro.string().optional(),commitAuthorName:ro.string().optional(),commitMessage:ro.string().optional(),commitRef:ro.string().optional(),commitSha:ro.string().optional(),dirty:ro.boolean().optional(),remoteUrl:ro.string().optional(),pullRequestNumber:ro.number().optional(),pullRequestTitle:ro.string().optional(),pullRequestState:ro.enum(["open","closed","merged"]).optional()}),rL=ro.object({id:ro.string(),filePath:ro.string()}),rM=ro.object({number:ro.number(),startedAt:ro.coerce.date()}),rZ=ro.object({id:ro.string(),slug:ro.string(),type:ro.enum(["PRODUCTION","STAGING","DEVELOPMENT","PREVIEW"]),branchName:ro.string().optional(),git:r$.optional()}),rG=ro.object({id:ro.string(),slug:ro.string(),name:ro.string()}),rq=ro.object({id:ro.string(),ref:ro.string(),slug:ro.string(),name:ro.string()}),rH=ro.object({id:ro.string(),name:ro.string()}),rK=ro.object({id:ro.string()}),rB=ro.object({id:ro.string(),shortCode:ro.string(),version:ro.string(),runtime:ro.string(),runtimeVersion:ro.string(),git:r$.optional()}),rW={task:rL.passthrough(),queue:rH,environment:rZ,organization:rG,project:rq,machine:rx,batch:rK.optional(),deployment:rB.optional()};ro.object(rW);let rF=ro.object({attempt:rM.passthrough(),run:rD.and(ro.object({traceContext:ro.record(ro.unknown()).optional(),realtimeStreamsVersion:ro.string().optional()})),...rW}),rV=ro.object({id:ro.string(),filePath:ro.string(),exportName:ro.string().optional()}),rz=ro.object({number:ro.number(),startedAt:ro.coerce.date(),id:ro.string(),backgroundWorkerId:ro.string(),backgroundWorkerTaskId:ro.string(),status:ro.string()}),rY=ro.object({id:ro.string(),payload:ro.string(),payloadType:ro.string(),tags:ro.array(ro.string()),isTest:ro.boolean().default(!1),isReplay:ro.boolean().default(!1),createdAt:ro.coerce.date(),startedAt:ro.coerce.date().default(()=>new Date),idempotencyKey:ro.string().optional(),idempotencyKeyScope:ro.enum(["run","attempt","global"]).optional(),maxAttempts:ro.number().optional(),version:ro.string().optional(),metadata:ro.record(rp).optional(),maxDuration:ro.number().optional(),context:ro.unknown(),durationMs:ro.number(),costInCents:ro.number(),baseCostInCents:ro.number()}),rJ=ro.object({task:rV,attempt:rz,run:rY.and(ro.object({traceContext:ro.record(ro.unknown()).optional()})),queue:rH,environment:rZ,organization:rG,project:rq,machine:rx,batch:rK.optional()});ro.object({attempt:rM,run:rD.omit({payload:!0,payloadType:!0,metadata:!0,durationMs:!0,costInCents:!0}),...rW});let rX=ro.object({id:ro.string(),slug:ro.string(),type:ro.enum(["PRODUCTION","STAGING","DEVELOPMENT","PREVIEW"])});ro.object({attempt:rz.omit({backgroundWorkerId:!0,backgroundWorkerTaskId:!0}),run:rY.omit({payload:!0,payloadType:!0,metadata:!0}),task:rV,queue:rH,environment:rX,organization:rG,project:rq,batch:rK.optional(),machine:rx.optional()});let rQ=ro.object({timestamp:ro.number(),delay:ro.number(),error:ro.unknown().optional()}),r0=ro.object({durationMs:ro.number()}),r1=ro.object({ok:ro.literal(!1),id:ro.string(),error:rU,retry:rQ.optional(),skippedRetrying:ro.boolean().optional(),usage:r0.optional(),taskIdentifier:ro.string().optional(),metadata:rI.optional(),flushedMetadata:ro.object({data:ro.string().optional(),dataType:ro.string()}).optional()}),r2=ro.object({ok:ro.literal(!0),id:ro.string(),output:ro.string().optional(),outputType:ro.string(),usage:r0.optional(),taskIdentifier:ro.string().optional(),metadata:rI.optional(),flushedMetadata:ro.object({data:ro.string().optional(),dataType:ro.string()}).optional()}),r4=ro.discriminatedUnion("ok",[r2,r1]),r9=ro.object({id:ro.string(),items:r4.array()});ro.object({ok:ro.boolean(),output:ro.string().optional(),outputType:ro.string().optional()});let r5=ro.object({message:ro.string(),name:ro.string().optional(),stackTrace:ro.string().optional()});ro.enum(Object.values({PRODUCTION:"PRODUCTION",STAGING:"STAGING",DEVELOPMENT:"DEVELOPMENT",PREVIEW:"PREVIEW"}));var ro=ro,ro=ro,ro=ro;let r3=ro.enum(["provider","integrator","either"]),r6=ro.object({from:ro.enum(["header","body"]),name:ro.string()}),r8=ro.discriminatedUnion("from",[ro.object({from:ro.literal("header"),name:ro.string()}),ro.object({from:ro.literal("signatureField"),field:ro.string()}),ro.object({from:ro.literal("body"),path:ro.string()}),ro.object({from:ro.literal("url")}),ro.object({from:ro.literal("constant"),value:ro.string()})]),r7=ro.object({itemSeparator:ro.string().optional(),fieldSeparator:ro.string().optional(),field:ro.string().optional(),trim:ro.boolean().optional()}),ne=ro.object({source:r8,unit:ro.enum(["seconds","milliseconds"]).optional(),toleranceSeconds:ro.number().optional()}),nt=ro.object({encoding:ro.enum(["utf8","base64"]).optional(),stripPrefix:ro.string().optional()}),nr=ro.union([ro.literal("raw"),ro.object({template:ro.string(),vars:ro.record(r8).optional()})]),nn=ro.object({field:ro.string()}),ni=ro.object({scheme:ro.literal("hmac"),algorithm:ro.enum(["sha256","sha1"]),encoding:ro.enum(["hex","base64"]),signatureHeader:ro.string(),signature:r7.optional(),timestamp:ne.optional(),signingString:nr,secret:nt.optional(),idempotencyField:r6.optional(),formPayload:nn.optional()}),na=ro.object({scheme:ro.literal("asymmetric"),algorithm:ro.enum(["ed25519","ec
2dsa-p256","rsa-sha256"]),encoding:ro.enum(["hex","base64"]),signatureHeader:ro.string(),signature:r7.optional(),timestamp:ne.optional(),signingString:nr,publicKeyEncoding:ro.enum(["pem","spki-der-base64","raw-hex","raw-base64"]).optional(),idempotencyField:r6.optional()}),ns=ro.object({scheme:ro.literal("shared-secret"),placement:ro.enum(["header","bearer","basic","body"]),fieldName:ro.string().optional(),idempotencyField:r6.optional()}),no=ro.object({scheme:ro.literal("url-secret"),placement:ro.enum(["query","path"]),paramName:ro.string(),idempotencyField:r6.optional()}),nl=ro.discriminatedUnion("scheme",[ni,ns,no,na]),nu=ro.object({matchPath:ro.string(),matchValue:ro.string(),respondPath:ro.string()}),nd=ro.discriminatedUnion("kind",[ro.object({kind:ro.literal("config"),config:nl,handshake:nu.optional()}),ro.object({kind:ro.literal("preset"),preset:ro.string(),config:nl,handshake:nu.optional()}),ro.object({kind:ro.literal("bundle"),bundleUrl:ro.string(),hash:ro.string()})]),nc=ro.discriminatedUnion("type",[ro.object({type:ro.literal("task"),taskId:ro.string()}),ro.object({type:ro.literal("session"),taskIdentifier:ro.string(),keyTemplate:ro.string(),deliverAs:ro.enum(["action","message"]),actionType:ro.string().optional(),connectorId:ro.string().optional(),triggerConfigTemplate:ro.record(ro.unknown()).optional(),startOn:ro.string().optional()})]);ro.object({ok:ro.boolean(),idempotencyKey:ro.string(),parsedEvent:ro.unknown().optional(),error:ro.string().optional()});var ro=ro;let np=ro.string().superRefine((e,t)=>{try{!function(e){let t=/^(0|[1-9]\d*)([mh])$/.exec(e);if(t){let e=Number(t[1])*("m"===t[2]?60:3600);if(!Number.isSafeInteger(e)||e>86400)throw RangeError("Schedule window duration cannot exceed 24 hours");return}let r=/^(0|[1-9]\d*)%$/.exec(e);if(r){let e=Number(r[1]);if(!Number.isSafeInteger(e)||e>100)throw RangeError("Schedule window percentage cannot exceed 100%");return}throw TypeError('Schedule window must be a whole duration such as "30m" or "2h", or a percentage such as "30%"')}(e)}catch(e){t.addIssue({code:ro.ZodIssueCode.custom,message:e instanceof Error?e.message:String(e)})}}),nh=ro.enum(["PRODUCTION","STAGING","DEVELOPMENT","PREVIEW"]),nm=ro.enum(["V1","V2"]),ng=ro.object({name:ro.string(),event:ro.string(),timestamp:ro.number(),duration:ro.number()}),nf=ro.array(ng);ro.object({execution:rF,traceContext:ro.record(ro.unknown()),environment:ro.record(ro.string()).optional(),metrics:nf.optional()});let ny=rJ.extend({worker:ro.object({id:ro.string(),contentHash:ro.string(),version:ro.string(),type:nm.optional()}),machine:rx.default({name:"small-1x",cpu:1,memory:1,centsPerMs:0})});ro.object({execution:ny,traceContext:ro.record(ro.unknown()),environment:ro.record(ro.string()).optional(),metrics:nf.optional()});let nb=ro.object({type:ro.literal("fixed-window"),limit:ro.number(),window:ro.union([ro.object({seconds:ro.number()}),ro.object({minutes:ro.number()}),ro.object({hours:ro.number()})])}),nv=ro.object({type:ro.literal("sliding-window"),limit:ro.number(),window:ro.union([ro.object({seconds:ro.number()}),ro.object({minutes:ro.number()}),ro.object({hours:ro.number()})])});ro.discriminatedUnion("type",[nb,nv]);let n_=ro.object({maxAttempts:ro.number().int().optional(),factor:ro.number().optional(),minTimeoutInMs:ro.number().int().optional(),maxTimeoutInMs:ro.number().int().optional(),randomize:ro.boolean().optional(),outOfMemory:ro.object({machine:rR.optional()}).optional()}),nE=ro.object({name:ro.string(),concurrencyLimit:ro.number().int().min(0).max(1e5).optional().nullable()}),nT=ro.object({cron:ro.string(),timezone:ro.string(),environments:ro.array(nh).optional(),window:np.optional()}),nw=ro.object({type:ro.string()}),nI={id:ro.string(),description:ro.string().optional(),queue:nE.extend({name:ro.string().optional()}).optional(),retry:n_.optional(),machine:rA.optional(),triggerSource:ro.string().optional(),agentConfig:nw.optional(),schedule:nT.optional(),maxDuration:ro.number().optional(),ttl:ro.string().or(ro.number().nonnegative().int()).optional(),payloadSchema:ro.unknown().optional()};ro.object(nI);let nS=ro.object({entry:ro.string(),out:ro.string()}),nk={filePath:ro.string(),exportName:ro.string().optional(),entryPoint:ro.string()};ro.object(nk);let nR=ro.object({...nI,...nk}),nA={id:ro.string(),description:ro.string().optional(),content:ro.string().optional(),model:ro.string().optional(),config:ro.record(ro.unknown()).optional(),variableSchema:ro.unknown().optional()};ro.object(nA);let nx=ro.object({...nA,...nk}),nC={id:ro.string(),sourcePath:ro.string()};ro.object(nC);let nO=ro.object({...nC,...nk}),nj={id:ro.string(),description:ro.string().optional(),source:ro.string(),verifierArtifact:nd,routingTarget:nc,secretProvisioning:r3.optional(),filter:ro.string().optional(),metadata:ro.record(ro.unknown()).optional()};ro.object(nj);let nP=ro.object({...nj,...nk});ro.enum(["index","create","restore"]),ro.enum(["terminate"]);let nN=ro.custom(e=>{try{return"function"==typeof e.test}catch{return!1}});ro.object({project:ro.string(),triggerDirectories:ro.string().array().optional(),triggerUrl:ro.string().optional(),projectDir:ro.string().optional(),tsconfigPath:ro.string().optional(),retries:ro.object({enabledInDev:ro.boolean().default(!0),default:n_.optional()}).optional(),additionalPackages:ro.string().array().optional(),additionalFiles:ro.string().array().optional(),dependenciesToBundle:ro.array(ro.union([ro.string(),nN])).optional(),logLevel:ro.string().optional(),enableConsoleLogging:ro.boolean().optional(),postInstall:ro.string().optional(),extraCACerts:ro.string().optional()}),ro.enum(["WAIT_FOR_DURATION","WAIT_FOR_TASK","WAIT_FOR_BATCH"]),ro.object({runId:ro.string(),attemptCount:ro.number().optional(),messageId:ro.string(),isTest:ro.boolean(),isReplay:ro.boolean().default(!1),traceContext:ro.record(ro.unknown()),environment:ro.record(ro.string()).optional(),metrics:nf.optional()}),ro.object({attemptId:ro.string(),previousRunStatus:ro.string(),previousAttemptStatus:ro.string()}),ro.object({concurrency:ro.object({queues:ro.array(ro.object({id:ro.string(),name:ro.string(),holding:ro.number()})),environment:ro.number().optional()}).optional()}),ro.object({traceparent:ro.string().optional(),tracestate:ro.string().optional(),external:ro.object({traceparent:ro.string().optional(),tracestate:ro.string().optional()}).optional()});let nU=ro.object({type:ro.string()}),nD=ro.object({id:ro.string(),description:ro.string().optional(),filePath:ro.string(),exportName:ro.string().optional(),queue:nE.extend({name:ro.string().optional()}).optional(),retry:n_.optional(),machine:rA.optional(),triggerSource:ro.string().optional(),agentConfig:nU.optional(),schedule:nT.optional(),maxDuration:ro.number().optional(),ttl:ro.string().or(ro.number().nonnegative().int()).optional(),payloadSchema:ro.unknown().optional()}),n$=ro.object({filePath:ro.string(),contents:ro.string(),contentHash:ro.string(),taskIds:ro.array(ro.string())}),nL=ro.object({id:ro.string(),description:ro.string().optional(),filePath:ro.string(),exportName:ro.string().optional(),content:ro.string().optional(),model:ro.string().optional(),config:ro.record(ro.unknown()).optional(),variableSchema:ro.unknown().optional()}
2),nM=ro.object({id:ro.string(),description:ro.string().optional(),filePath:ro.string(),exportName:ro.string().optional(),source:ro.string(),verifierArtifact:nd,routingTarget:nc,secretProvisioning:r3.optional(),filter:ro.string().optional(),metadata:ro.record(ro.unknown()).optional()}),nZ=ro.object({packageVersion:ro.string(),contentHash:ro.string(),cliPackageVersion:ro.string().optional(),tasks:ro.array(nD),prompts:ro.array(nL).optional(),webhooks:ro.array(nM).optional(),queues:ro.array(nE).optional(),sourceFiles:ro.array(n$).optional(),runtime:ro.string().optional(),runtimeVersion:ro.string().optional()});ro.object({contentHash:ro.string(),imageTag:ro.string()});var ro=ro;let nG=ro.custom(e=>"string"==typeof e),nq=ro.enum(["sdk","api","dashboard","cli","mcp","schedule"]).or(nG),nH=ro.enum(["trigger","replay","test"]).or(nG),nK=ro.enum(["STANDARD","SCHEDULED","AGENT"]).or(nG),nB=ro.object({triggerSource:nq,triggerAction:nH,rootTriggerSource:nq,rootScheduleId:ro.string().optional(),taskKind:nK.optional(),externalDeploymentId:ro.string().optional()});ro.enum(Object.values({PENDING:"PENDING",COMPLETED:"COMPLETED"}));let nW=ro.object({id:ro.string(),index:ro.number().optional(),friendlyId:ro.string(),type:ro.enum(Object.values({RUN:"RUN",DATETIME:"DATETIME",MANUAL:"MANUAL",BATCH:"BATCH"})),completedAt:ro.coerce.date(),idempotencyKey:ro.string().optional(),completedByTaskRun:ro.object({id:ro.string(),friendlyId:ro.string(),batch:ro.object({id:ro.string(),friendlyId:ro.string()}).optional()}).optional(),completedAfter:ro.coerce.date().optional(),completedByBatch:ro.object({id:ro.string(),friendlyId:ro.string()}).optional(),output:ro.string().optional(),outputType:ro.string().optional(),outputIsError:ro.boolean()}),nF=ro.object({id:ro.string(),friendlyId:ro.string(),executionStatus:ro.enum(Object.values({RUN_CREATED:"RUN_CREATED",QUEUED:"QUEUED",QUEUED_EXECUTING:"QUEUED_EXECUTING",PENDING_EXECUTING:"PENDING_EXECUTING",EXECUTING:"EXECUTING",EXECUTING_WITH_WAITPOINTS:"EXECUTING_WITH_WAITPOINTS",SUSPENDED:"SUSPENDED",PENDING_CANCEL:"PENDING_CANCEL",FINISHED:"FINISHED",DELAYED:"DELAYED"})),description:ro.string(),createdAt:ro.coerce.date()}),nV=ro.object({id:ro.string(),friendlyId:ro.string(),status:ro.enum(Object.values({DELAYED:"DELAYED",PENDING:"PENDING",PENDING_VERSION:"PENDING_VERSION",WAITING_FOR_DEPLOY:"WAITING_FOR_DEPLOY",DEQUEUED:"DEQUEUED",EXECUTING:"EXECUTING",WAITING_TO_RESUME:"WAITING_TO_RESUME",RETRYING_AFTER_FAILURE:"RETRYING_AFTER_FAILURE",PAUSED:"PAUSED",CANCELED:"CANCELED",INTERRUPTED:"INTERRUPTED",COMPLETED_SUCCESSFULLY:"COMPLETED_SUCCESSFULLY",COMPLETED_WITH_ERRORS:"COMPLETED_WITH_ERRORS",SYSTEM_FAILURE:"SYSTEM_FAILURE",CRASHED:"CRASHED",EXPIRED:"EXPIRED",TIMED_OUT:"TIMED_OUT"})),attemptNumber:ro.number().nullish(),taskEventStore:ro.string().optional()}),nz=ro.object({snapshot:nF,run:nV});nz.and(ro.object({execution:rF}));let nY=ro.enum(["RUN_FINISHED","RUN_PENDING_CANCEL","RETRY_QUEUED","RETRY_IMMEDIATELY"]);ro.object({attemptStatus:nY}).and(nz);let nJ=ro.enum(Object.values({DOCKER:"DOCKER",KUBERNETES:"KUBERNETES",COMPUTE:"COMPUTE"})),nX=ro.object({type:nJ,location:ro.string(),imageRef:ro.string().nullish(),reason:ro.string().nullish()}).merge(ro.object({id:ro.string(),friendlyId:ro.string()}));ro.object({version:ro.literal("1"),snapshot:nF,run:nV,batch:ro.object({id:ro.string(),friendlyId:ro.string()}).optional(),checkpoint:nX.optional(),completedWaitpoints:ro.array(nW)}),ro.discriminatedUnion("ok",[ro.object({ok:ro.literal(!0),checkpoint:nX}).merge(nz),ro.object({ok:ro.literal(!1),error:ro.string()})]);let nQ=ro.object({cpu:ro.number(),memory:ro.number()}),n0=ro.object({id:ro.string(),type:nJ,location:ro.string(),imageRef:ro.string().nullish(),reason:ro.string().nullish()}),n1=ro.object({key:ro.string(),values:ro.array(ro.string()).optional()}),n2=ro.object({version:ro.literal("1"),snapshot:nF,dequeuedAt:ro.coerce.date(),workerQueueLength:ro.number().optional(),image:ro.string().optional(),checkpoint:n0.optional(),completedWaitpoints:ro.array(nW),backgroundWorker:ro.object({id:ro.string(),friendlyId:ro.string(),version:ro.string(),runtime:ro.string().optional()}),deployment:ro.object({id:ro.string().optional(),friendlyId:ro.string().optional(),imagePlatform:ro.string().optional()}),run:ro.object({id:ro.string(),friendlyId:ro.string(),isTest:ro.boolean(),isReplay:ro.boolean().default(!1),machine:rx,attemptNumber:ro.number(),masterQueue:ro.string(),traceContext:ro.record(ro.unknown()),annotations:nB.optional()}),environment:ro.object({id:ro.string(),type:nh}),organization:ro.object({id:ro.string(),hasPrivateLink:ro.boolean().optional()}),project:ro.object({id:ro.string()}),placementTags:ro.array(n1).optional()});var ro=ro;let n4=["task","custom"],n9=ro.enum(n4);ro.enum([...n4,"id"]);let n5=ro.object({id:ro.string(),name:ro.string(),type:n9,running:ro.number(),queued:ro.number(),paused:ro.boolean(),concurrencyLimit:ro.number().nullable(),concurrency:ro.object({current:ro.number().nullable(),base:ro.number().nullable(),override:ro.number().nullable(),overriddenAt:ro.coerce.date().nullable(),overriddenBy:ro.string().nullable()}).optional()});ro.object({page:ro.number().optional(),perPage:ro.number().optional()});let n3=ro.object({type:n9,name:ro.string()});ro.union([ro.string(),n3]);var ro=ro,ro=ro;let n6=ro.object({project:ro.string(),dirs:ro.string().array()}),n8=ro.object({name:ro.string(),version:ro.string()}),n7=ro.enum(["dev","deploy","unmanaged"]);ro.enum(["node","node-22","node-24","node-26","experimental-node-24","experimental-node-26","bun"]);let ie=ro.enum(["node","node-22","node-24","node-26","bun"]),it=ro.object({target:n7,packageVersion:ro.string(),cliPackageVersion:ro.string(),contentHash:ro.string(),runtime:ie,environment:ro.string(),branch:ro.string().optional(),config:n6,files:ro.array(nS),sources:ro.record(ro.object({contents:ro.string(),contentHash:ro.string()})),outputPath:ro.string(),runWorkerEntryPoint:ro.string(),runControllerEntryPoint:ro.string().optional(),indexWorkerEntryPoint:ro.string(),indexControllerEntryPoint:ro.string().optional(),loaderEntryPoint:ro.string().optional(),initEntryPoint:ro.string().optional(),configPath:ro.string(),externals:n8.array().optional(),build:ro.object({env:ro.record(ro.string()).optional(),commands:ro.array(ro.string()).optional()}),customConditions:ro.array(ro.string()).optional(),deploy:ro.object({env:ro.record(ro.string()).optional(),sync:ro.object({env:ro.record(ro.string()).optional(),parentEnv:ro.record(ro.string()).optional(),secretEnv:ro.record(ro.string()).optional(),secretParentEnv:ro.record(ro.string()).optional()}).optional()}),image:ro.object({pkgs:ro.array(ro.string()).optional(),instructions:ro.array(ro.string()).optional()}).optional(),otelImportHook:ro.object({include:ro.array(ro.string()).optional(),exclude:ro.array(ro.string()).optional()}).optional(),outputHashes:ro.record(ro.string()).optional(),skills:nO.array().optional()});ro.object({type:ro.literal("index"),data:ro.object({build:it})});let ir=ro.object({configPath:ro.string(),tasks:nR.array(),prompts:nx.array().optional(),skills:nO.array().optional(),webhooks:nP.array().optional(),unclaimedSessionWebhooks:ro.array(ro.string()).optional(),queues:nE.array().optional(),workerEntryPoint:ro.string(),controllerEntryPoint:ro.string().optional(),loaderEntryPoint:ro.string().optional(),initEntryPoint:ro.string().optional(),runtime:ie,runtimeVersion:ro.string().optional(),customConditions:ro.array(ro.string()).optional(),timings:ro.record(ro.number()).optional(),processKeepAlive:ro.object({enabled:ro.boolean(),maxExecutionsPerProcess:ro.number().int().positive().optional()}).optional(),otelImportHook:ro.object({include:ro.array(ro.string()).optional(),exclude:ro.array(ro.string()).optional()}).optional()});ro.object({type:ro.literal("worker-manifest"),data:ro.object({manifest:ir})});let ii=ro.object({message:ro.string(),file:ro.string(),stack:ro.string().optional(),name:ro.string().optional()});ro.array(ii);let ia=ro.union([ro.literal("V1"),ro.literal("V2")]);ro.object({userId:ro.string(),email:ro.string().email(),dashboardUrl:ro.string(),project:ro.object({name:ro.string(),url:ro.string(),orgTitle:ro.string()}).optional()});let is=ro.object({id:ro.string(),externalRef:ro.string().describe("The external reference for the project, also known as the project ref, a unique identifier starting with proj_"),name:ro.string(),slug:ro.string(),createdAt:ro.coerce.date(),defaultRegion:ro.string().nullable().optional(),defaultRuntime:ie.nullable().optional(),organization:ro.object({id:ro.string(),title:ro.string(),slug:ro.string(),createdAt:ro.coerce.date()})});ro.array(is),ro.array(ro.object({organization:ro.object({title:ro.string(),slug:ro.string()}),project:ro.object({name:ro.string(),slug:ro.string(),externalRef:ro.string()}),environment:ro.object({slug:ro.string()}),deployment:ro.object({runtime:ro.string().nullable(),runtimeVersion:ro.string().nullable(),nodeMajor:ro.number().int().positive().nullable(),deployedAt:ro.coerce.date().nullable(),shortCode:ro.string()}).nullable()})),ro.array(ro.object({id:ro.string(),title:ro.string(),slug:ro.string(),createdAt:ro.coerce.date()})),ro.object({title:ro.string().trim().min(3).max(50),companySize:ro.string().optional(),companyUrl:ro.string().optional()}),ro.object({id:ro.string(),title:ro.string(),slug:ro.string(),createdAt:ro.coerce.date()}),ro.object({name:ro.string().trim().min(1,"Name is required").max(255,"Name must be less than 255 characters")}),ro.object({apiKey:ro.string(),name:ro.string(),apiUrl:ro.string(),projectId:ro.string(),defaultRuntime:ie.nullable().optional()});let io=ro.object({id:ro.string(),slug:ro.string(),type:ro.enum(["DEVELOPMENT","STAGING","PREVIEW","PRODUCTION"]),isBranchableEnvironment:ro.boolean(),branchName:ro.string().nullable(),paused:ro.boolean()});ro.array(io);let il=ro.object({id:ro.string(),slug:ro.string(),filePath:ro.string(),triggerSource:ro.string(),createdAt:ro.coerce.date(),payloadSchema:ro.any().nullish(),queueConfig:ro.any().nullish()});ro.object({worker:ro.object({id:ro.string(),version:ro.string(),engine:ro.string().nullish(),sdkVersion:ro.string().nullish(),cliVersion:ro.string().nullish(),tasks:ro.array(il)}),urls:ro.object({runs:ro.string()})}),ro.object({claims:ro.object({scopes:ro.array(ro.string()).default([])}).optional(),expirationTime:ro.union([ro.number(),ro.string()]).optional()}),ro.object({token:ro.string()}),ro.object({localOnly:ro.boolean(),metadata:nZ,engine:ia.optional(),supportsLazyAttempts:ro.boolean().optional(),buildPlatform:ro.string().optional(),targetPlatform:ro.string().optional()}),ro.object({id:ro.string(),version:ro.string(),contentHash:ro.string()});let iu=ro.string().max(128,"Tags must be less than 128 characters"),id=ro.union([iu,iu.array()]),ic=ro.object({key:ro.string(),scope:ro.enum(["run","attempt","global"])}),ip=ro.union([ro.string(),ro.number()]).transform(e=>String(e)),ih=ro.preprocess(e=>{if("string"!=typeof e)return e;let t=e.trim();return""===t?void 0:t},ro.string().max(128,"externalId must be at most 128 characters").optional()),im=ro.object({payload:ro.any(),context:ro.any(),options:ro.object({dependentAttempt:ro.string().optional(),parentAttempt:ro.string().optional(),dependentBatch:ro.string().optional(),parentBatch:ro.string().optional(),parentRunId:ro.string().optional(),resumeParentOnCompletion:ro.boolean().optional(),lockToVersion:ro.string().optional(),externalDeploymentId:ih,queue:ro.object({name:ro.string(),concurrencyLimit:ro.number().int().optional()}).optional(),concurrencyKey:ip.optional(),delay:ro.string().or(ro.coerce.date()).optional(),idempotencyKey:ro.string().max(2048,"idempotencyKey must be 2048 characters or less").optional(),idempotencyKeyTTL:ro.string().optional(),idempotencyKeyOptions:ic.optional(),machine:rR.optional(),maxAttempts:ro.number().int().optional(),maxDuration:ro.number().optional(),metadata:ro.any(),metadataType:ro.string().optional(),payloadType:ro.string().optional(),payloadSize:ro.number().int().nonnegative().optional(),tags:id.optional(),test:ro.boolean().optional(),ttl:ro.string().or(ro.number().nonnegative().int()).optional(),priority:ro.number().optional(),bulkActionId:ro.string().optional(),region:ro.string().optional(),debounce:ro.object({key:ro.string().max(512),delay:ro.string(),mode:ro.enum(["leading","trailing"]).optional(),maxDelay:ro.string().optional()}).optional()}).optional()}).superRefine((e,t)=>
2{e.options?.payloadType==="application/store"&&("string"!=typeof e.payload||0===e.payload.length)&&t.addIssue({code:ro.ZodIssueCode.custom,message:"payload must be a non-empty string when options.payloadType is application/store",path:["payload"]})}),ig=ro.object({id:ro.string(),isCached:ro.boolean().optional()});ro.object({items:im.array(),dependentAttempt:ro.string().optional()});let iy=ro.object({task:ro.string(),payload:ro.any(),context:ro.any(),options:ro.object({concurrencyKey:ip.optional(),delay:ro.string().or(ro.coerce.date()).optional(),idempotencyKey:ro.string().max(2048,"idempotencyKey must be 2048 characters or less").optional(),idempotencyKeyTTL:ro.string().optional(),idempotencyKeyOptions:ic.optional(),lockToVersion:ro.string().optional(),externalDeploymentId:ih,machine:rR.optional(),maxAttempts:ro.number().int().optional(),maxDuration:ro.number().optional(),metadata:ro.any(),metadataType:ro.string().optional(),parentAttempt:ro.string().optional(),payloadType:ro.string().optional(),payloadSize:ro.number().int().nonnegative().optional(),queue:ro.object({name:ro.string()}).optional(),tags:id.optional(),test:ro.boolean().optional(),ttl:ro.string().or(ro.number().nonnegative().int()).optional(),priority:ro.number().optional(),region:ro.string().optional(),debounce:ro.object({key:ro.string().max(512),delay:ro.string(),mode:ro.enum(["leading","trailing"]).optional(),maxDelay:ro.string().optional()}).optional()}).optional()});ro.object({items:iy.array(),dependentAttempt:ro.string().optional(),parentRunId:ro.string().optional(),resumeParentOnCompletion:ro.boolean().optional()}),ro.object({id:ro.string(),isCached:ro.boolean(),idempotencyKey:ro.string().optional(),runs:ro.array(ro.object({id:ro.string(),taskIdentifier:ro.string(),isCached:ro.boolean(),idempotencyKey:ro.string().optional()}))}),ro.object({items:iy.array(),parentRunId:ro.string().optional(),resumeParentOnCompletion:ro.boolean().optional()});let ib=ro.object({id:ro.string(),runCount:ro.number()});ro.object({runCount:ro.number().int().positive(),taskIdentifiers:ro.array(ro.string().min(1)).min(1).optional(),parentRunId:ro.string().optional(),resumeParentOnCompletion:ro.boolean().optional(),idempotencyKey:ro.string().max(2048,"idempotencyKey must be 2048 characters or less").optional(),idempotencyKeyOptions:ic.optional()});let iv=ro.object({id:ro.string(),runCount:ro.number(),isCached:ro.boolean(),idempotencyKey:ro.string().optional()});ro.object({index:ro.number().int().nonnegative(),task:ro.string(),payload:ro.unknown().optional(),options:iy.shape.options});let i_=ro.object({id:ro.string(),itemsAccepted:ro.number(),itemsDeduplicated:ro.number(),sealed:ro.boolean(),enqueuedCount:ro.number().optional(),expectedCount:ro.number().optional()});ro.object({batchId:ro.string(),runs:ro.string().array()}),ro.object({id:ro.string(),items:ro.array(ro.object({id:ro.string(),taskRunId:ro.string(),status:ro.enum(["PENDING","CANCELED","COMPLETED","FAILED"])}))}),ro.object({tags:id}),ro.object({delay:ro.string().or(ro.coerce.date())}),ro.object({variables:ro.record(ro.string())}),ro.object({imageReference:ro.string(),selfHosted:ro.boolean().optional()}),ro.object({id:ro.string(),contentHash:ro.string()}),ro.object({skipPromotion:ro.boolean().optional(),imageDigest:ro.string().optional(),skipPushToRegistry:ro.boolean().optional()});let iE=ro.object({buildId:ro.string().optional(),isNativeBuild:ro.boolean().optional(),artifactKey:ro.string().optional(),skipPromotion:ro.boolean().optional(),configFilePath:ro.string().optional(),skipEnqueue:ro.boolean().optional(),fromBundle:ro.boolean().optional()});ro.object({contentHash:ro.string().optional(),gitMeta:r$.optional(),runtime:ro.string().optional(),buildServerMetadata:iE.optional()}),ro.object({reason:ro.string().max(200,"Reason must be less than 200 characters").optional()});let iT=ro.object({buildId:ro.string(),buildToken:ro.string(),projectId:ro.string()}),iw=ro.custom(e=>"string"==typeof e),iI=ro.enum(["cli:manual","cli:ci_other","cli:github_actions","cli:gitlab_ci","cli:circleci","cli:jenkins","cli:azure_pipelines","cli:bitbucket_pipelines","cli:travis_ci","cli:buildkite","git_integration:github","dashboard"]).or(iw);ro.object({git:r$.optional(),env:ro.enum(["preview","development"]),branch:ro.string()}),ro.object({id:ro.string()}),ro.object({type:ro.enum(["deployment_context","deployment_bundle"]).default("deployment_context"),contentType:ro.string().default("application/gzip"),contentLength:ro.number().optional()}),ro.object({artifactKey:ro.string(),uploadUrl:ro.string(),uploadFields:ro.record(ro.string()),expiresAt:ro.string().datetime()}),ro.object({id:ro.string(),contentHash:ro.string(),shortCode:ro.string(),version:ro.string(),imageTag:ro.string(),imagePlatform:ro.string(),externalId:ro.string().optional(),outcome:ro.enum(["created","existing"]).optional(),isPromoted:ro.boolean().optional(),externalBuildData:iT.optional().nullable(),canceledDeployments:ro.array(ro.object({version:ro.string(),shortCode:ro.string()})).optional(),eventStream:ro.object({s2:ro.object({basin:ro.string(),stream:ro.string(),accessToken:ro.string()})}).optional()}),ro.object({contentHash:ro.string(),userId:ro.string().optional(),selfHosted:ro.boolean().optional(),gitMeta:r$.optional(),type:ro.enum(["MANAGED","UNMANAGED","V1"]).optional(),runtime:ro.string().optional(),initialStatus:ro.enum(["PENDING","BUILDING"]).optional(),isLocalBuild:ro.boolean().optional(),triggeredVia:iI.optional(),buildId:ro.string().optional(),externalId:ih,force:ro.boolean().optional()}).extend({isNativeBuild:ro.boolean().default(!1),skipPromotion:ro.boolean().optional(),artifactKey:ro.string().optional(),configFilePath:ro.string().optional(),skipEnqueue:ro.boolean().optional().default(!1),fromBundle:ro.boolean().optional(),buildEnvVars:ro.record(ro.string()).optional()}).superRefine((e,t)=>
2{e.force&&!e.externalId&&t.addIssue({code:ro.ZodIssueCode.custom,path:["force"],message:"force requires externalId"})}).transform(e=>{if(e.isNativeBuild)return{...e,isNativeBuild:!0};let{skipPromotion:t,artifactKey:r,configFilePath:n,skipEnqueue:i,fromBundle:a,buildEnvVars:s,...o}=e;return{...o,isNativeBuild:!1}});let iS=ro.enum(["depot","native","native_local_bundle"]);ro.object({build_path:iS}),ro.object({status:ro.enum(["operational","degraded","unknown"]),message:ro.string()}),ro.object({username:ro.string(),password:ro.string(),expiresAt:ro.string(),repositoryUri:ro.string()});let ik=ro.object({name:ro.string(),message:ro.string(),stack:ro.string().optional(),stderr:ro.string().optional()});ro.object({error:ik}),ro.object({id:ro.string()}),ro.object({id:ro.string(),version:ro.string(),shortCode:ro.string()});let iR=ro.object({id:ro.string(),status:ro.enum(["PENDING","INSTALLING","BUILDING","DEPLOYING","DEPLOYED","FAILED","CANCELED","TIMED_OUT"]),contentHash:ro.string(),shortCode:ro.string(),version:ro.string(),imageReference:ro.string().nullish(),imagePlatform:ro.string(),commitSHA:ro.string().nullish(),externalBuildData:iT.optional().nullable(),errorData:ik.nullish(),canceledReason:ro.string().nullish(),worker:ro.object({id:ro.string(),version:ro.string(),tasks:ro.array(ro.object({id:ro.string(),slug:ro.string(),filePath:ro.string(),exportName:ro.string().optional()}))}).optional(),integrationDeployments:ro.array(ro.object({id:ro.string(),integrationName:ro.string(),integrationDeploymentId:ro.string(),commitSHA:ro.string(),createdAt:ro.coerce.date()})).nullish()});ro.object({variables:ro.record(ro.string())}),iR.omit({worker:!0});let iA=ro.object({type:ro.literal("log"),data:ro.object({level:ro.enum(["debug","info","warn","error"]).optional().default("info"),message:ro.string()})}),ix=ro.object({type:ro.literal("finalized"),data:ro.object({result:ro.enum(["succeeded","failed","timed_out","canceled"]).or(iw),message:ro.string().optional()})}),iC=ro.discriminatedUnion("type",[iA,ix]);ro.string().transform((e,t)=>{try{return JSON.parse(e)}catch{return t.addIssue({code:ro.ZodIssueCode.custom,message:"Invalid JSON"}),ro.NEVER}}).pipe(iC);let iO=ro.object({presignedUrl:ro.string(),storagePath:ro.string().optional()});ro.object({type:ro.string(),name:ro.string(),description:ro.string().nullish(),latestVersion:ro.string().nullish(),lastHeartbeatAt:ro.string().nullish(),isDefault:ro.boolean(),updatedAt:ro.coerce.date()}).array(),ro.object({name:ro.string().optional(),description:ro.string().optional()}),ro.object({workerGroup:ro.object({name:ro.string(),description:ro.string().nullish()}),token:ro.object({plaintext:ro.string()})}),ro.object({environmentId:ro.string(),dequeueIntervalWithRun:ro.number(),dequeueIntervalWithoutRun:ro.number(),maxConcurrentRuns:ro.number(),engineUrl:ro.string()}),ro.object({currentWorker:ro.string(),oldWorkers:ro.string().array(),maxResources:nQ.optional()}),ro.object({dequeuedMessages:n2.array()}),ro.object({runFriendlyIds:ro.string().array()}),ro.object({cancelled:ro.number(),bulkActionId:ro.string().optional()});let ij=ro.object({id:ro.string()}),iP=ro.object({id:ro.string()}),iN=ro.object({id:ro.string()}),iU=ro.union([ro.literal("DECLARATIVE"),ro.literal("IMPERATIVE")]);ro.object({scheduleId:ro.string(),type:iU,timestamp:ro.date(),lastTimestamp:ro.date().optional(),externalId:ro.string().optional(),timezone:ro.string(),upcoming:ro.array(ro.date())}),ro.object({task:ro.string(),cron:ro.string(),deduplicationKey:ro.string(),externalId:ro.string().optional(),timezone:ro.string().optional(),window:np.optional()}).omit({deduplicationKey:!0});let iD=ro.object({type:ro.literal("CRON"),expression:ro.string(),description:ro.string()}),i$=ro.object({id:ro.string(),type:iU,task:ro.string(),active:ro.boolean(),deduplicationKey:ro.string().nullish(),externalId:ro.string().nullish(),generator:iD,timezone:ro.string(),window:np.optional(),nextRun:ro.coerce.date().nullish(),nextRunEffectiveAt:ro.coerce.date().nullish(),environments:ro.array(ro.object({id:ro.string(),type:ro.string(),userName:ro.string().nullish()}))}),iL=ro.object({id:ro.string()});ro.object({data:ro.array(i$),pagination:ro.object({currentPage:ro.number(),totalPages:ro.number(),count:ro.number()})}),ro.object({page:ro.number().optional(),perPage:ro.number().optional()}),ro.object({timezones:ro.array(ro.string())});let iM=ro.enum(["PENDING_VERSION","QUEUED","DEQUEUED","EXECUTING","WAITING","COMPLETED","CANCELED","FAILED","CRASHED","SYSTEM_FAILURE","DELAYED","EXPIRED","TIMED_OUT"]);ro.enum(["PENDING","EXECUTING","PAUSED","COMPLETED","FAILED","CANCELED"]);let iZ=ro.object({id:ro.string(),name:ro.string(),user:ro.string().optional()}),iG=ro.object({id:ro.string(),externalId:ro.string().optional(),deduplicationKey:ro.string().optional(),generator:iD});ro.enum(["triggerAndWait","trigger","batchTriggerAndWait","batchTrigger"]);let iq={id:ro.string(),status:iM,taskIdentifier:ro.string(),idempotencyKey:ro.string().optional(),version:ro.string().optional(),isQueued:ro.boolean(),isExecuting:ro.boolean(),isWaiting:ro.boolean(),isCompleted:ro.boolean(),isSuccess:ro.boolean(),isFailed:ro.boolean(),isCancelled:ro.boolean(),isTest:ro.boolean(),createdAt:ro.coerce.date(),updatedAt:ro.coerce.date(),startedAt:ro.coerce.date().optional(),finishedAt:ro.coerce.date().optional(),delayedUntil:ro.coerce.date().optional(),ttl:ro.string().optional(),expiredAt:ro.coerce.date().optional(),tags:ro.string().array(),costInCents:ro.number(),baseCostInCents:ro.number(),durationMs:ro.number(),metadata:ro.record(ro.any()).optional(),taskKind:ro.string().optional(),region:ro.string().optional()},iH={...iq,depth:ro.number(),triggerFunction:ro.enum(["triggerAndWait","trigger","batchTriggerAndWait","batchTrigger"]),batchId:ro.string().optional()},iK=ro.object(iH),iB=ro.object({...iH,payload:ro.any().optional(),payloadPresignedUrl:ro.string().optional(),output:ro.any().optional(),outputPresignedUrl:ro.string().optional(),error:r5.optional(),schedule:iG.optional(),relatedRuns:ro.object({root:iK.optional(),parent:iK.optional(),children:ro.array(iK).optional()}),attemptCount:ro.number().default(0)}),iW=ro.object({...iq,env:iZ});ro.object({data:ro.array(iW),pagination:ro.object({next:ro.string().optional(),previous:ro.string().optional()})});let iF=ro.union([ro.string(),ro.array(ro.string())]),iV=ro.union([rR,ro.array(rR)]),iz=ro.union([n3,ro.array(n3)]),iY=ro.union([ro.coerce.date(),ro.number()]);function iJ(e){return void 0!==e&&(Array.isArray(e)?e.some(iJ):"string"!=typeof e||e.trim().length>0)}let iX={filter:ro.object({status:ro.union([iM,ro.array(iM)]).optional(),taskIdentifier:iF.optional(),version:iF.optional(),from:iY.optional(),to:iY.optional(),period:ro.string().optional(),bulkAction:ro.string().optional(),tag:iF.optional(),schedule:ro.string().optional(),isTest:ro.boolean().optional(),batch:ro.string().optional(),queue:iz.optional(),machine:iV.optional(),region:iF.optional()}).refine(e=>Object.values(e).some(iJ),{message:"At least one filter must be provided"}).optional(),runIds:ro.array(ro.string()).min(1).optional(),name:ro.string().max(255,"Name must be less than 255 characters").optional()};ro.discriminatedUnion("action",[ro.object({action:ro.literal("cancel"),targetRegion:ro.never().optional(),...iX}),ro.object({action:ro.literal("replay"),targetRegion:ro.string().optional(),...iX})]).refine(e=>
2+!!e.filter+ +!!e.runIds==1,{message:"Exactly one of filter or runIds must be provided"});let iQ=ro.enum(["PENDING","COMPLETED","ABORTED"]),i0=ro.enum(["CANCEL","REPLAY"]),i1=ro.object({id:ro.string(),name:ro.string().optional(),type:i0,status:iQ,counts:ro.object({total:ro.number(),success:ro.number(),failure:ro.number()}),createdAt:ro.coerce.date(),completedAt:ro.coerce.date().optional()}),i2=ro.object({id:ro.string()}),i4=ro.object({id:ro.string()});ro.object({data:ro.array(i1),pagination:ro.object({next:ro.string().optional(),previous:ro.string().optional()})}),ro.object({name:ro.string(),value:ro.string(),isSecret:ro.boolean().optional()}),ro.object({value:ro.string()}),ro.object({variables:ro.record(ro.string()),parentVariables:ro.record(ro.string()).optional(),override:ro.boolean().optional(),isSecret:ro.boolean().optional(),source:ro.discriminatedUnion("type",[ro.object({type:ro.literal("user"),userId:ro.string()}),ro.object({type:ro.literal("integration"),integration:ro.string()})]).optional()});let i9=ro.object({success:ro.boolean()});ro.object({value:ro.string()});let i5=ro.object({name:ro.string(),value:ro.string()});ro.array(i5);let i3=ro.object({name:ro.string(),value:ro.string(),isSecret:ro.boolean()}),i6=ro.object({metadata:ro.record(rp)}),i8=ro.string().transform(e=>`${e}Z`).pipe(ro.coerce.date()),i7=ro.string().nullish().transform(e=>e?new Date(`${e}Z`):e),ae=ro.object({id:ro.string(),taskIdentifier:ro.string(),friendlyId:ro.string(),status:ro.string(),createdAt:i8,updatedAt:i8,startedAt:i7,delayUntil:i7,queuedAt:i7,expiredAt:i7,completedAt:i7,idempotencyKey:ro.string().nullish(),number:ro.number().default(0),isTest:ro.boolean().default(!1),usageDurationMs:ro.number().default(0),costInCents:ro.number().default(0),baseCostInCents:ro.number().default(0),ttl:ro.string().nullish(),payload:ro.string().nullish(),payloadType:ro.string().nullish(),metadata:ro.string().nullish(),metadataType:ro.string().nullish(),output:ro.string().nullish(),outputType:ro.string().nullish(),runTags:ro.array(ro.string()).nullish().default([]),error:rU.nullish(),realtimeStreams:ro.array(ro.string()).nullish().default([])}),at=ro.enum(["PENDING","PROCESSING","COMPLETED","PARTIAL_FAILED","ABORTED"]);ro.object({id:ro.string(),status:at,idempotencyKey:ro.string().optional(),createdAt:ro.coerce.date(),updatedAt:ro.coerce.date(),runCount:ro.number(),runs:ro.array(ro.string())});let ar=ro.object({id:ro.string(),status:at,idempotencyKey:ro.string().optional(),createdAt:ro.coerce.date(),updatedAt:ro.coerce.date(),runCount:ro.number(),runs:ro.array(ro.string()),processing:ro.object({completedAt:ro.coerce.date().optional(),errors:ro.array(ro.object({index:ro.number(),taskIdentifier:ro.string(),error:ro.string(),errorCode:ro.string().optional()}))})});ro.object({id:ro.string(),runId:ro.string(),sequence:ro.number(),key:ro.string(),value:ro.string(),createdAt:ro.coerce.date()});let an=ro.string().or(ro.coerce.date());ro.object({idempotencyKey:ro.string().max(2048,"idempotencyKey must be 2048 characters or less").optional(),idempotencyKeyTTL:ro.string().optional(),timeout:an.optional(),tags:id.optional()});let ai=ro.object({id:ro.string(),isCached:ro.boolean(),url:ro.string()});ro.object({streamId:ro.string(),timeout:ro.string().optional(),idempotencyKey:ro.string().max(2048,"idempotencyKey must be 2048 characters or less").optional(),idempotencyKeyTTL:ro.string().optional(),tags:ro.union([ro.string(),ro.array(ro.string())]).optional(),lastSeqNum:ro.number().optional()});let aa=ro.object({waitpointId:ro.string(),isCached:ro.boolean()});ro.object({session:ro.string(),io:ro.enum(["out","in"]),timeout:ro.string().optional(),idempotencyKey:ro.string().max(2048,"idempotencyKey must be 2048 characters or less").optional(),idempotencyKeyTTL:ro.string().optional(),tags:ro.union([ro.string(),ro.array(ro.string())]).optional(),lastSeqNum:ro.number().optional()});let as=ro.object({waitpointId:ro.string(),isCached:ro.boolean()}),ao=ro.enum(["WAITING","COMPLETED","TIMED_OUT"]),al=ro.object({id:ro.string(),url:ro.string(),status:ao,completedAt:ro.coerce.date().optional(),completedAfter:ro.coerce.date().optional(),timeoutAt:ro.coerce.date().optional(),idempotencyKey:ro.string().optional(),idempotencyKeyExpiresAt:ro.coerce.date().optional(),tags:ro.array(ro.string()),createdAt:ro.coerce.date()}),au=al.omit({completedAfter:!0}).and(ro.object({output:ro.string().optional(),outputType:ro.string().optional(),outputIsError:ro.boolean().optional()}));ro.object({data:ro.any().nullish()});let ad=ro.object({basePayload:ro.record(ro.unknown()),machine:rR.optional(),queue:ro.string().max(128).optional(),tags:ro.array(ro.string().max(128)).max(10).optional(),maxAttempts:ro.number().int().positive().max(10).optional(),maxDuration:ro.number().int().positive().optional(),lockToVersion:ro.string().optional(),region:ro.string().optional(),idleTimeoutInSeconds:ro.number().int().positive().max(3600).optional()});ro.object({type:ro.string().min(1).max(64),externalId:ro.string().trim().min(1).max(256).refine(e=>!e.startsWith("session_"),{message:"externalId cannot start with 'session_' (reserved prefix for internal friendlyIds)"}).optional(),taskIdentifier:ro.string().min(1).max(128),triggerConfig:ad,tags:ro.array(ro.string().max(128)).max(10).optional(),metadata:ro.record(ro.unknown()).optional(),expiresAt:ro.coerce.date().optional()});let ac=ro.object({id:ro.string(),externalId:ro.string().nullable(),type:ro.string(),taskIdentifier:ro.string(),triggerConfig:ad.optional(),currentRunId:ro.string().nullable().optional(),tags:ro.array(ro.string()),metadata:ro.record(ro.unknown()).nullable(),closedAt:ro.coerce.date().nullable(),closedReason:ro.string().nullable(),expiresAt:ro.coerce.date().nullable(),createdAt:ro.coerce.date(),updatedAt:ro.coerce.date()}),ap=ac.extend({runId:ro.string(),publicAccessToken:ro.string(),isCached:ro.boolean()});ro.object({callingRunId:ro.string(),reason:ro.string().max(64)});let ah=ro.object({runId:ro.string(),swapped:ro.boolean()});ro.object({tags:ro.array(ro.string().max(128)).max(10).optional(),metadata:ro.record(ro.unknown()).nullable().optional(),externalId:ro.union([ro.literal(null),ro.string().trim().min(1).max(256).refine(e=>!e.startsWith("session_"),{message:"externalId cannot start with 'session_' (reserved prefix for internal friendlyIds)"})]).optional()}),ro.object({reason:ro.string().max(256).optional()});let am=ro.enum(["ACTIVE","CLOSED","EXPIRED"]);ro.object({"page[size]":ro.coerce.number().int().min(1).max(100).default(20),"page[after]":ro.string().optional(),"page[before]":ro.string().optional(),"filter[type]":ro.union([ro.string(),ro.array(ro.string())]).optional(),"filter[tags]":ro.union([ro.string(),ro.array(ro.string())]).optional(),"filter[taskIdentifier]":ro.union([ro.string(),ro.array(ro.string())]).optional(),"filter[externalId]":ro.string().optional(),"filter[status]":ro.union([am,ro.array(am)]).optional(),"filter[createdAt][period]":ro.string().optional(),"filter[createdAt][from]":ro.coerce.number().int().optional(),"filter[createdAt][to]":ro.coerce.number().int().optional()}).refine(e=>!(e["page[after]"]&&e["page[before]"]),{message:"Cannot pass both page[after] and page[before] on the same request",path:["page[before]"]}),ro.object({limit:ro.number().int().min(1).max(100).optional(),after:ro.string().optional(),before:ro.string().optional(),type:ro.union([ro.string(),ro.array(ro.string())]).optional(),tag:ro.union([ro.string(),ro.array(ro.string())]).optional(),taskIdentifier:ro.union([ro.string(),ro.array(ro.string())]).optional(),externalId:ro.string().optional(),status:ro.union([am,ro.array(am)]).optional(),period:ro.string().optional(),from:ro.union([ro.number(),ro.date()]).optional(),to:ro.union([ro.number(),ro.date()]).optional()}),ro.object({data:ro.array(ac),pagination:ro.object({next:ro.string().optional(),previous:ro.string().optional()})});let ag=ro.object({success:ro.literal(!0)}),af=ro.object({success:ro.boolean()});ro.object({idempotencyKey:ro.string().max(2048,"idempotencyKey must be 2048 characters or less").optional(),idempotencyKeyTTL:ro.string().optional(),date:ro.coerce.date()});let ay=ro.object({waitUntil:ro.coerce.date(),waitpoint:ro.object({id:ro.string()})}),ab={from:ro.string().describe("The date to start the search from, in ISO 8601 format").optional(),to:ro.string().describe("The date to end the search, in ISO 8601 format").optional(),period:ro.string().describe("The period to search within (e.g. 1d, 7d, 3h, etc.)").optional(),status:ro.enum(["PENDING","BUILDING","DEPLOYING","DEPLOYE
2D","FAILED","CANCELED","TIMED_OUT"]).describe("Filter deployments that are in this status").optional()},av=ro.string().describe("The deployment ID to start the search from, to get the next page").optional(),a_=ro.coerce.number().describe("The number of deployments to return, defaults to 20 (max 100)").min(1,"Limit must be at least 1").max(100,"Limit must be less than 100").optional(),aE={...ab,cursor:av,limit:a_};ro.object(aE),ro.object({...ab,"page[after]":av,"page[size]":a_});let aT=ro.object({id:ro.string(),createdAt:ro.coerce.date(),shortCode:ro.string(),version:ro.string(),runtime:ro.string().nullable(),runtimeVersion:ro.string().nullable(),status:ro.enum(["PENDING","BUILDING","DEPLOYING","DEPLOYED","FAILED","CANCELED","TIMED_OUT"]),deployedAt:ro.coerce.date().optional(),git:ro.record(ro.any()).optional(),error:ik.optional()});ro.object({branches:ro.array(ro.object({id:ro.string(),name:ro.string(),createdAt:ro.coerce.date(),updatedAt:ro.coerce.date(),git:ro.record(ro.any()).optional(),isPaused:ro.boolean()}))});let aw=ro.object({id:ro.string(),parentId:ro.string().optional(),runId:ro.string(),data:ro.object({message:ro.string(),taskSlug:ro.string().optional(),taskPath:ro.string().optional(),events:ro.array(ro.any()).optional(),startTime:ro.coerce.date(),duration:ro.number(),isError:ro.boolean(),isPartial:ro.boolean(),isCancelled:ro.boolean(),level:ro.string(),workerVersion:ro.string().optional(),queueName:ro.string().optional(),machinePreset:ro.string().optional(),properties:ro.record(ro.any()).optional(),output:ro.unknown().optional()})}).extend({children:ro.lazy(()=>aw.array())}),aI=ro.object({trace:ro.object({traceId:ro.string(),rootSpan:aw})}),aS=ro.object({spanId:ro.string(),parentId:ro.string().nullable(),runId:ro.string(),message:ro.string(),isError:ro.boolean(),isPartial:ro.boolean(),isCancelled:ro.boolean(),level:ro.string(),startTime:ro.coerce.date(),durationMs:ro.number(),properties:ro.record(ro.any()).optional(),events:ro.array(ro.any()).optional(),entityType:ro.string().optional(),ai:ro.object({model:ro.string(),provider:ro.string(),operationName:ro.string(),inputTokens:ro.number(),outputTokens:ro.number(),totalTokens:ro.number(),cachedTokens:ro.number().optional(),reasoningTokens:ro.number().optional(),inputCost:ro.number().optional(),outputCost:ro.number().optional(),totalCost:ro.number().optional(),cachedCost:ro.number().optional(),cacheCreationCost:ro.number().optional(),tokensPerSecond:ro.number().optional(),msToFirstChunk:ro.number().optional(),durationMs:ro.number(),finishReason:ro.string().optional(),responseText:ro.string().optional()}).optional(),triggeredRuns:ro.array(ro.object({runId:ro.string(),taskIdentifier:ro.string(),status:ro.string(),createdAt:ro.coerce.date()})).optional()}),ak=ro.object({version:ro.string()}),aR=ro.object({ok:ro.boolean(),message:ro.string().optional()}),aA=ro.object({ok:ro.boolean()}),ax=ro.object({records:ro.array(ro.object({data:ro.unknown(),id:ro.string(),seqNum:ro.number(),headers:ro.array(ro.tuple([ro.string(),ro.string()])).optional()}))});ro.object({variables:ro.record(ro.unknown()).default({}),label:ro.string().optional(),version:ro.number().optional()});let aC=ro.object({data:ro.object({promptId:ro.string(),slug:ro.string(),version:ro.number(),labels:ro.array(ro.string()),template:ro.string().optional(),text:ro.string().optional(),model:ro.string().optional().nullable(),config:ro.record(ro.unknown()).optional().nullable()})}),aO=ro.object({data:ro.array(ro.object({slug:ro.string(),friendlyId:ro.string(),description:ro.string().nullable(),tags:ro.array(ro.string()),defaultModel:ro.string().nullable(),currentVersion:ro.number().nullable(),hasOverride:ro.boolean(),updatedAt:ro.string()}))}),aj=ro.object({data:ro.array(ro.object({id:ro.string(),version:ro.number(),labels:ro.array(ro.string()),source:ro.string(),model:ro.string().nullable(),textContent:ro.string().nullable(),commitMessage:ro.string().nullable(),contentHash:ro.string(),createdAt:ro.string()}))});ro.object({version:ro.number().int().positive()}),ro.object({textContent:ro.string(),model:ro.string().optional(),commitMessage:ro.string().optional(),source:ro.string().optional()}),ro.object({textContent:ro.string().optional(),model:ro.string().optional(),commitMessage:ro.string().optional()}),ro.object({version:ro.number().int().positive()});let aP=ro.object({ok:ro.boolean()}),aN=ro.object({ok:ro.boolean(),version:ro.number()});var ro=ro;ro.object({query:ro.string(),scope:ro.enum(["organization","project","environment"]).default("environment"),period:ro.string().nullish(),from:ro.string().nullish(),to:ro.string().nullish(),format:ro.enum(["json","csv"]).default("json")});let aU=ro.object({format:ro.literal("json"),results:ro.array(ro.record(ro.any()))}),aD=ro.object({format:ro.literal("csv"),results:ro.string()}),a$=ro.discriminatedUnion("format",[aU,aD]),aL=ro.object({name:ro.string(),type:ro.string(),description:ro.string().optional(),example:ro.string().optional(),allowedValues:ro.array(ro.string()).optional(),coreColumn:ro.boolean().optional()}),aM=ro.object({name:ro.string(),description:ro.string().optional(),timeColumn:ro.string().optional(),columns:ro.array(aL)}),aZ=ro.object({tables:ro.array(aM)}),aG=ro.object({id:ro.string(),title:ro.string(),query:ro.string(),type:ro.enum(["bignumber","chart","table","t
2itle"])}),aq=ro.object({key:ro.string(),title:ro.string(),widgets:ro.array(aG)}),aH=ro.object({dashboards:ro.array(aq)});var ro=ro;let aK={m:6e4,h:36e5,d:864e5,w:6048e5},aB=90*864e5;ro.string().regex(/^[1-9]\d*[mhdw]$/,"period must be a shorthand like '30m', '1h' or '7d' â minutes (m), hours (h), days (d) or weeks (w); seconds are not supported").refine(e=>Number(e.slice(0,-1))*(aK[e.slice(-1)]??0)<=aB,"period is too large (max 90d)"),ro.enum(["markdown","json","ansi"]);let aW=ro.enum(["ok","warn","crit"]),aF=ro.enum(["ms","count","ratio","perMin"]),aV=ro.string(),az=ro.string(),aY=ro.object({dir:ro.enum(["up","down","flat"]),mult:ro.number().optional()}),aJ=ro.object({points:ro.array(ro.number()),kind:ro.enum(["measured","estimated"])}),aX=ro.object({id:ro.string(),value:ro.number(),unit:aF,aggregation:ro.enum(["p95","rate","ratio","count"]).optional(),normal:ro.number().optional(),delta:aY.optional(),series:aJ.optional(),breakdown:ro.record(ro.number()).optional(),annotation:ro.object({code:aV,value:ro.number().optional()}).optional(),availability:ro.enum(["measured","unknown"]).optional(),severity:aW}),aQ=ro.object({code:aV,link:az.optional()}),a0=ro.object({code:aV,link:az.optional(),value:ro.number().optional()}),a1=ro.object({code:aV,evidence:ro.record(ro.number()).optional()}),a2=ro.object({code:aV,evidence:ro.record(ro.number()).optional()}),a4=ro.object({type:ro.string(),severity:aW,reason:aV,read:aV.optional(),metricIds:ro.array(ro.string()),recommendation:aQ.optional(),hedge:aQ.optional(),anomalyWindow:ro.object({minutes:ro.number(),touchesEnd:ro.boolean()}).optional(),attribution:ro.object({dim:ro.string(),key:ro.string(),share:ro.number(),of:ro.string()}).optional(),exclusions:ro.array(a1).optional(),observations:ro.array(a2).optional()}),a9=ro.object({findingType:ro.string(),severity:aW,reason:aV.optional()}),a5=ro.object({key:az,label:ro.string(),url:ro.string()}),a3=ro.object({title:ro.string(),scope:ro.string(),period:ro.string(),baselineLabel:ro.string().optional(),generatedAt:ro.string(),windowMinutes:ro.number(),summary:ro.object({severity:aW,statements:ro.array(a9)}),findings:ro.array(a4),metrics:ro.array(aX),facts:ro.record(ro.unknown()),links:ro.array(a5),footer:ro.array(a0)}),a6="$style.icon",a8=()=>r?.getStore(),a7="object"==typeof globalThis?globalThis:e.g,se=Symbol.for("dev.trigger.ts.api");function st(e,t,r=!1){let n=a7[se];return(n||(n={},a7[se]=n),!r&&n[e])?(Error(`trigger.dev: Attempted duplicate registration of API: ${e}`),!1):(n[e]=t,!0)}let sr="task-context";class sn{static _instance;_runDisabled=!1;_conversationId;static getInstance(){return this._instance||(this._instance=new sn),this._instance}get isInsideTask(){return!this.#e()&&void 0!==this.#t()}get isRunDisabled(){return this._runDisabled}get ctx(){if(!this.#e())return this.#t()?.ctx}get worker(){if(!this.#e())return this.#t()?.worker}
2get isWarmStart(){if(!this.#e())return this.#t()?.isWarmStart}#e(){let e=a8();return!!e&&!e.inheritContext}get attributes(){return this.ctx?{...this.contextAttributes,...this.workerAttributes,...this.conversationAttributes,warm_start:!!this.isWarmStart}:{}}get conversationAttributes(){return this._conversationId?{"gen_ai.conversation.id":this._conversationId}:{}}get conversationId(){return this._conversationId}setConversationId(e){this._conversationId=e||void 0}get resourceAttributes(){return this.ctx?{"ctx.environment.id":this.ctx.environment.id,"ctx.environment.type":this.ctx.environment.type,"ctx.organization.id":this.ctx.organization.id,"ctx.project.id":this.ctx.project.id,"ctx.project.ref":this.ctx.project.ref,"ctx.project.title":this.ctx.project.name,"ctx.organization.slug":this.ctx.organization.slug,"ctx.organization.name":this.ctx.organization.name,"ctx.machine.name":this.ctx.machine?.name,"ctx.machine.cpu":this.ctx.machine?.cpu,"ctx.machine.memory":this.ctx.machine?.memory,"ctx.machine.centsPerMs":this.ctx.machine?.centsPerMs}:{}}get workerAttributes(){return this.worker?{"worker.id":this.worker.id,"worker.version":this.worker.version}:{}}get contextAttributes(){return this.ctx?{"ctx.attempt.number":this.ctx.attempt.number,"ctx.task.id":this.ctx.task.id,"ctx.task.filePath":this.ctx.task.filePath,"ctx.queue.name":this.ctx.queue.name,"ctx.queue.id":this.ctx.queue.id,"ctx.run.id":this.ctx.run.id,"ctx.run.isTest":this.ctx.run.isTest,"ctx.run.isReplay":this.ctx.run.isReplay,"ctx.batch.id":this.ctx.batch?.id,"ctx.run.idempotencyKey":this.ctx.run.idempotencyKey}:{}}disable(){this._runDisabled=!0}setGlobalTaskContext(e){return this._runDisabled=!1,this._conversationId=void 0,st(sr,e,!0)}#t(){return a7[se]?.[sr]}}let si=sn.getInstance();var sa=e.i(668390);let ss={get url(){return`file://${e.P("node_modules/.pnpm/[email protected]/node_modules/std-env/dist/index.mjs")}`}},so=Object.create(null),sl=e=>globalThis.process?.env||ss.env||globalThis.Deno?.env.toObject()||globalThis.__env__||(e?so:globalThis),su=new Proxy(so,{get:(e,t)=>sl()[t]??so[t],has:(e,t)=>t in sl()||t in so,set:(e,t,r)=>(sl(!0)[t]=r,!0),deleteProperty(e,t){if(!t)return!1;let r=sl(!0);return delete r[t],!0},ownKeys:()=>Object.keys(sl(!0))}),sd="u">typeof sa.default&&sa.default.env&&"production"||"",sc=[["APPVEYOR"],["AWS_AMPLIFY","AWS_APP_ID",{ci:!0}],["AZURE_PIPELINES","SYSTEM_TEAMFOUNDATIONCOLLECTIONURI"],["AZURE_STATIC","INPUT_AZURE_STATIC_WEB_APPS_API_TOKEN"],["APPCIRCLE","AC_APPCIRCLE"],["BAMBOO","bamboo_planKey"],["BITBUCKET","BITBUCKET_COMMIT"],["BITRISE","BITRISE_IO"],["BUDDY","BUDDY_WORKSPACE_ID"],["BUILDKITE"],["CIRCLE","CIRCLECI"],["CIRRUS","CIRRUS_CI"],["CLOUDFLARE_PAGES","CF_PAGES",{ci:!0}],["CLOUDFLARE_WORKERS","WORKERS_CI",{ci:!0}],["CODEBUILD","CODEBUILD_BUILD_ARN"],["CODEFRESH","CF_BUILD_ID"],["DRONE"],["DRONE","DRONE_BUILD_EVENT"],["DSARI"],["GITHUB_ACTIONS"],["GITLAB","GITLAB_CI"],["GITLAB","CI_MERGE_REQUEST_ID"],["GOCD","GO_PIPELINE_LABEL"],["LAYERCI"],["HUDSON","HUDSON_URL"],["JENKINS","JENKINS_URL"],["MAGNUM"],["NETLIFY"],["NETLIFY","NETLIFY_LOCAL",{ci:!1}],["NEVERCODE"],["RENDER"],["SAIL","SAILCI"],["SEMAPHORE"],["SCREWDRIVER"],["SHIPPABLE"],["SOLANO","TDDIUM"],["STRIDER"],["TEAMCITY","TEAMCITY_VERSION"],["TRAVIS"],["VERCEL","NOW_BUILDER"],["VERCEL","VERCEL",{ci:!1}],["VERCEL","VERCEL_ENV",{ci:!1}],["APPCENTER","APPCENTER_BUILD_ID"],["CODESANDBOX","CODESANDBOX_SSE",{ci:!1}],["CODESANDBOX","CODESANDBOX_HOST",{ci:!1}],["STACKBLITZ"],["STORMKIT"],["CLEAVR"],["ZEABUR"],["CODESPHERE","CODESPHERE_APP_ID",{ci:!0}],["RAILWAY","RAILWAY_PROJECT_ID"],["RAILWAY","RAILWAY_SERVICE_ID"],["DENO-DEPLOY","DENO_DEPLOYMENT_ID"],["FIREBASE_APP_HOSTING","FIREBASE_APP_HOSTING",{ci:!0}]],sp=function(){if(globalThis.process?.env)for(let e of sc){let t=e[1]||e[0];if(globalThis.process?.env[t])return{name:e[0].toLowerCase(),...e[2]}}return globalThis.process?.env?.SHELL==="/bin/jsh"&&globalThis.process?.versions?.webcontainer?{name:"stackblitz",ci:!1}:{name:"",ci:!1}}();function sh(e){return!!e&&"false"!==e}sp.name;let sm=globalThis.process?.platform||"",sg=(sh(su.CI)||sp.ci,sh(globalThis.process?.stdout&&globalThis.process?.stdout.isTTY)),sf=(sh(su.DEBUG),"test"===sd||sh(su.TEST),sh(su.MINIMAL),/^win/i.test(sm)),sy=(/^linux/i.test(sm),/^darwin/i.test(sm),
2!sh(su.NO_COLOR)&&(sh(su.FORCE_COLOR)||(sg||sf)&&su.TERM),(globalThis.process?.versions?.node||"").replace(/^v/,"")||null),sb=(sy?.split(".")[0],globalThis.process||Object.create(null)),sv={versions:{}},s_=(new Proxy(sb,{get:(e,t)=>"env"===t?su:t in e?e[t]:t in sv?sv[t]:void 0}),globalThis.process?.release?.name==="node"),sE=!!globalThis.Bun||!!globalThis.process?.versions?.bun,sT=!!globalThis.Deno,sw=!!globalThis.fastly,sI=[[!!globalThis.Netlify,"netlify"],[!!globalThis.EdgeRuntime,"edge-light"],[globalThis.navigator?.userAgent==="Cloudflare-Workers","workerd"],[sw,"fastly"],[sT,"deno"],[sE,"bun"],[s_,"node"]],sS=function(){let e=sI.find(e=>e[0]);if(e)return{name:e[1]}}();function sk(e,t){return su[e]??t}sS?.name;let sR={maxAttempts:3,factor:2,minTimeoutInMs:1e3,maxTimeoutInMs:6e4,randomize:!0};function sA(e,t){let r={...sR,...e};if(t>=r.maxAttempts)return;let{factor:n,minTimeoutInMs:i,maxTimeoutInMs:a,randomize:s}=r;return Math.round(Math.min(a,(s?Math.random()+1:1)*i*Math.pow(n,t-1)))}({...sR});var ro=ro;let sx=/[$_\p{ID_Start}][$\u200c\u200d\p{ID_Continue}]*/u,sC="Validation error";class sO extends Error{details;name;constructor(e,t=[]){super(e),this.details=t,this.name="ZodValidationError"}toString(){return this.message}}
2class sj extends Error{status;headers;error;code;param;type;constructor(e,t,r,n){super(`${sj.makeMessage(e,t,r)}`),this.name="TriggerApiError",this.status=e,this.headers=n,this.error=t,this.code=t?.code,this.param=t?.param,this.type=t?.type}static makeMessage(e,t,r){let n=t?.message?"string"==typeof t.message?t.message:JSON.stringify(t.message):"string"==typeof t?t:t?JSON.stringify(t):void 0;return n||(e&&r?`${e} ${r}`:e?`${e} status code (no body)`:r||"(no status code or body)")}static generate(e,t,r,n){if(!e){var i;return new sP({cause:(i=t)instanceof Error?i:Error(i)})}let a=t?.error;return 400===e?new sN(e,a,r,n):401===e?new sU(e,a,r,n):403===e?new sD(e,a,r,n):404===e?new s$(e,a,r,n):409===e?new sL(e,a,r,n):422===e?new sM(e,a,r,n):429===e?new sZ(e,a,r,n):e>=500?new sG(e,a,r,n):new sj(e,a,r,n)}}class sP extends sj{status=void 0;constructor({message:e,cause:t}){super(void 0,void 0,e||"Connection error.",void 0),t&&(this.cause=t)}}class sN extends sj{status=400}class sU extends sj{status=401}class sD extends sj{status=403}class s$ extends sj{status=404}class sL extends sj{status=409}class sM extends sj{status=422}class sZ extends sj{status=429;get millisecondsUntilReset(){let e=(this.headers??{})["x-ratelimit-reset"];if("string"==typeof e){let t=parseInt(e,10);if(isNaN(t))return;return Math.max(t-Date.now()+Math.floor(2e3*Math.random()),0)}}}class sG extends sj{}class sq extends sj{status=200;rawBody;constructor({message:e,cause:t,status:r,rawBody:n,headers:i}){super(r,void 0,e||"Validation error.",i),t&&(this.cause=t),this.rawBody=n}}class sH extends Error{name="BatchNotSealedError";batchId;enqueuedCount;expectedCount;itemsAccepted;itemsDeduplicated;constructor(e){super(`Batch ${e.batchId} was not sealed: received ${e.enqueuedCount} of ${e.expectedCount} expected items (accepted: ${e.itemsAccepted}, deduplicated: ${e.itemsDeduplicated})`),this.batchId=e.batchId,this.enqueuedCount=e.enqueuedCount,this.expectedCount=e.expectedCount,this.itemsAccepted=e.itemsAccepted,this.itemsDeduplicated=e.itemsDeduplicated}}var sK=e.i(926070),sB=e.i(336092);let sW={get(e,t){if(null!=e)return e[t]},keys:e=>null==e?[]:Object.keys(e)},sF={set(e,t,r){null!=e&&(e[t]=r)}};var sV=e.i(843152),sz=e.i(57271);let sY=(0,sz.createContextKey)("OpenTelemetry Baggage Key");function sJ(e){return e.getValue(sY)||void 0}function sX(){return sJ(sV.ContextAPI.getInstance().active())}function sQ(e,t){return e.setValue(sY,t)}function s0(e){return e.deleteValue(sY)}var s1=e.i(130252);class s2{constructor(e){this._entries=e?new Map(e):new Map}getEntry(e){let t=this._entries.get(e);if(t)return Object.assign({},t)}getAllEntries(){return Array.from(this._entries.entries())}setEntry(e,t){let r=new s2(this._entries);return r._entries.set(e,t),r}removeEntry(e){let t=new s2(this._entries);return t._entries.delete(e),t}removeEntries(...e){let t=new s2(this._entries);for(let r of e)t._entries.delete(r);return t}clear(){return new s2}}function s4(e={}){return new s2(new Map(Object.entries(e)))}s1.DiagAPI.instance();let s9="propagation",s5=new class{inject(e,t){}extract(e,t){return e}fields(){return[]}};class s3{constructor(){this.createBaggage=s4,this.getBaggage=sJ,this.getActiveBaggage=sX,this.setBaggage=sQ,this.deleteBaggage=s0}static getInstance(){return this._instance||(this._instance=new s3),this._instance}setGlobalPropagator(e){return(0,sB.registerGlobal)(s9,e,s1.DiagAPI.instance())}inject(e,t,r=sF){return this._getGlobalPropagator().inject(e,t,r)}extract(e,t,r=sW){return this._getGlobalPropagator().extract(e,t,r)}fields(){return this._getGlobalPropagator().fields()}disable(){(0,sB.unregisterGlobal)(s9,s1.DiagAPI.instance())}_getGlobalPropagator(){return(0,sB.getGlobal)(s9)||s5}}let s6=s3.getInstance(),s8=(0,sz.createContextKey)("OpenTelemetry SDK Context Key SUPPRESS_TRACING");var s7=e.i(794663);class oe extends Event{constructor(e,t){var r,n;super(e),this.code=null!=(r=null==t?void 0:t.code)?r:void 0,this.message=null!=(n=null==t?void 0:t.message)?n:void 0}[Symbol.for("nodejs.util.inspect.custom")](e,t,r){return r(ot(this),t)}[Symbol.for("Deno.customInspect")](e,t){return e(ot(this),t)}}function ot(e){return{type:e.type,message:e.message,code:e.code,defaultPrevented:e.defaultPrevented,cancelable:e.cancelable,timeStamp:e.timeStamp}}var or,on,oi,oa,os,oo,ol,ou,od,oc,op,oh,om,og,of,oy,ob,ov,o_,oE,oT,ow,oI,oS,ok,oR,oA,ox,oC,oO,oj=e=>{throw TypeError(e)},oP=(e,t,r)=>t.has(e)||oj("Cannot "+r),oN=(e,t,r)=>(oP(e,t,"read from private field"),r?r.call(e):t.get(e)),oU=(e,t,r)=>t.has(e)?oj("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),oD=(e,t,r,n)=>(oP(e,t,"write to private field"),t.set(e,r),r),o$=(e,t,r)=>(oP(e,t,"access private method"),r);
2class oL extends EventTarget{constructor(e,t){var r,n;super(),oU(this,oT),this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,oU(this,ou),oU(this,od),oU(this,oc),oU(this,op),oU(this,oh),oU(this,om),oU(this,og),oU(this,of,null),oU(this,oy),oU(this,ob),oU(this,ov,null),oU(this,o_,null),oU(this,oE,null),oU(this,oI,async e=>{var t;oN(this,ob).reset();let{body:r,redirected:n,status:i,headers:a}=e;if(204===i){o$(this,oT,ox).call(this,"Server sent HTTP 204, not reconnecting",204),this.close();return}if(n?oD(this,oc,new URL(e.url)):oD(this,oc,void 0),200!==i)return void o$(this,oT,ox).call(this,`Non-200 status code (${i})`,i);if(!(a.get("content-type")||"").startsWith("text/event-stream"))return void o$(this,oT,ox).call(this,'Invalid content type, expected "text/event-stream"',i);if(oN(this,ou)===this.CLOSED)return;oD(this,ou,this.OPEN);let s=new Event("open");if(null==(t=oN(this,oE))||t.call(this,s),this.dispatchEvent(s),"object"!=typeof r||!r||!("getReader"in r)){o$(this,oT,ox).call(this,"Invalid response body, expected a web ReadableStream",i),this.close();return}let o=new TextDecoder,l=r.getReader(),u=!0;do{let{done:e,value:t}=await l.read();t&&oN(this,ob).feed(o.decode(t,{stream:!e})),e&&(u=!1,oN(this,ob).reset(),o$(this,oT,oC).call(this))}while(u)}),oU(this,oS,e=>{oD(this,oy,void 0),"AbortError"!==e.name&&"aborted"!==e.type&&o$(this,oT,oC).call(this,function e(t){return t instanceof Error?"errors"in t&&Array.isArray(t.errors)?t.errors.map(e).join(", "):"cause"in t&&t.cause instanceof Error?`${t}: ${e(t.cause)}`:t.message:`${t}`}(e))}),oU(this,oR,e=>{"string"==typeof e.id&&oD(this,of,e.id);let t=new MessageEvent(e.event||"message",{data:e.data,origin:oN(this,oc)?oN(this,oc).origin:oN(this,od).origin,lastEventId:e.id||""});oN(this,o_)&&(!e.event||"message"===e.event)&&oN(this,o_).call(this,t),this.dispatchEvent(t)}),oU(this,oA,e=>{oD(this,om,e)}),oU(this,oO,()=>{oD(this,og,void 0),oN(this,ou)===this.CONNECTING&&o$(this,oT,ow).call(this)});try{if(e instanceof URL)oD(this,od,e);else if("string"==typeof e)oD(this,od,new URL(e,function(){let e="document"in globalThis?globalThis.document:void 0;return e&&"object"==typeof e&&"baseURI"in e&&"string"==typeof e.baseURI?e.baseURI:void 0}()));else throw Error("Invalid URL")}catch{throw function(e){let t=globalThis.DOMException;return"function"==typeof t?new t(e,"SyntaxError"):SyntaxError(e)}("An invalid or illegal string was specified")}oD(this,ob,(0,s7.createParser)({onEvent:oN(this,oR),onRetry:oN(this,oA)})),oD(this,ou,this.CONNECTING),oD(this,om,3e3),oD(this,oh,null!=(r=null==t?void 0:t.fetch)?r:globalThis.fetch),oD(this,op,null!=(n=null==t?void 0:t.withCredentials)&&n),o$(this,oT,ow).call(this)}get readyState(){return oN(this,ou)}get url(){return oN(this,od).href}get withCredentials(){return oN(this,op)}get onerror(){return oN(this,ov)}set onerror(e){oD(this,ov,e)}get onmessage(){return oN(this,o_)}set onmessage(e){oD(this,o_,e)}get onopen(){return oN(this,oE)}set onopen(e){oD(this,oE,e)}addEventListener(e,t,r){super.addEventListener(e,t,r)}removeEventListener(e,t,r){super.removeEventListener(e,t,r)}close(){oN(this,og)&&clearTimeout(oN(this,og)),oN(this,ou)!==this.CLOSED&&(oN(this,oy)&&oN(this,oy).abort(),oD(this,ou,this.CLOSED),oD(this,oy,void 0))}}async function oM(){let{randomUUID:t}=await e.A(161673);return t()}ou=new WeakMap,od=new WeakMap,oc=new WeakMap,op=new WeakMap,oh=new WeakMap,om=new WeakMap,og=new WeakMap,of=new WeakMap,oy=new WeakMap,ob=new WeakMap,ov=new WeakMap,o_=new WeakMap,oE=new WeakMap,oT=new WeakSet,ow=function(){oD(this,ou,this.CONNECTING),oD(this,oy,new AbortController),oN(this,oh)(oN(this,od),o$(this,oT,ok).call(this)).then(oN(this,oI)).catch(oN(this,oS))},oI=new WeakMap,oS=new WeakMap,ok=function(){var e;let t={mode:"cors",redirect:"follow",headers:{Accept:"text/event-stream",...oN(this,of)?{"Last-Event-ID":oN(this,of)}:void 0},cache:"no-store",signal:null==(e=oN(this,oy))?void 0:e.signal};return"window"in globalThis&&(t.credentials=this.withCredentials?"include":"same-origin"),t},oR=new WeakMap,oA=new WeakMap,ox=function(e,t){var r;oN(this,ou)!==this.CLOSED&&oD(this,ou,this.CLOSED);let n=new oe("error",{code:t,message:e});null==(r=oN(this,ov))||r.call(this,n),this.dispatchEvent(n)},oC=function(e,t){var r;if(oN(this,ou)===this.CLOSED)return;oD(this,ou,this.CONNECTING);let n=new oe("error",{code:t,message:e});null==(r=oN(this,ov))||r.call(this,n),this.dispatchEvent(n),oD(this,og,setTimeout(oN(this,oO),oN(this,om)))},oO=new WeakMap,oL.CONNECTING=0,oL.OPEN=1,oL.CLOSED=2;let oZ="$@null((";class oG{maxAttributeCount;maxDepth;seen=new WeakSet;attributeCounter=0;result={};constructor(e,t=128){this.maxAttributeCount=e,this.maxDepth=t}get attributes(){return this.result}canAddMoreAttributes(){return void 0===this.maxAttributeCount||this.attributeCounter<this.maxAttributeCount}addAttribute(e,t){return!!this.canAddMoreAttributes()&&(this.result[e]=t,this.attributeCounter++,!0)}doFlatten(e,t,r=0){if(this.canAddMoreAttributes()&&!(r>this.maxDepth)&&void 0!==e){if(null===e)return void this.addAttribute(t||"",oZ);if("string"==typeof e||"number"==typeof e||"boolean"==typeof e)return void this.addAttribute(t||"",e);if(e instanceof Date)return void this.addAttribute(t||"",e.toISOString());if(e instanceof Error){this.addAttribute(`${t||"error"}.name`,e.name),this.addAttribute(`${t||"error"}.message`,e.message),e.stack&&this.addAttribute(`${t||"error"}.stack`,e.stack);return}if("function"==typeof e){let r=e.name||"anonymous";this.addAttribute(t||"",`[Function: ${r}]`);return}if(e instanceof Set){let n=0;for(let i of e){if(!this.canAddMoreAttributes())break;this.#r(i,`${t||"set"}.[${n}]`,r),n++}return}if(e instanceof Map){for(let[n,i]of e){if(!this.canAddMoreAttributes())break;let e="string"==typeof n?n:String(n);this.#r(i,`${t||"map"}.${e}`,r)}return}if("u">typeof File&&e instanceof File){this.addAttribute(`${t||"file"}.name`,e.name),this.addAttribute(`${t||"file"}.size`,e.size),this.addAttribute(`${t||"file"}.type`,e.type),this.addAttribute(`${t||"file"}.lastModified`,e.lastModified);return}if("u">typeof ReadableStream&&e instanceof ReadableStream){this.addAttribute(`${t||"stream"}.type`,"ReadableStream"),this.addAttribute(`${t||"stream"}.locked`,e.locked);return}if("u">typeof WritableStream&&e instanceof WritableStream){this.addAttribute(`${t||"stream"}.type`,"WritableStream"),this.addAttribute(`${t||"stream"}.locked`,e.locked);return}if(e instanceof Promise)return void this.addAttribute(t||"promise","[Promise object]");if(e instanceof RegExp){this.addAttribute(`${t||"regexp"}.source`,e.source),this.addAttribute(`${t||"regexp"}.flags`,e.flags);return}if("u">typeof URL&&e instanceof URL){this.addAttribute(`${t||"url"}.href`,e.href),this.addAttribute(`${t||"url"}.protocol`,e.protocol),this.addAttribute(`${t||"url"}.host`,e.host),this.addAttribute(`${t||"url"}.pathname`,e.pathname);return}if(e instanceof ArrayBuffer)return void this.addAttribute(`${t||"arraybuffer"}.byteLength`,e.byteLength);if(ArrayBuffer.isView(e)){this.addAttribute(`${t||"typedarray"}.constructor`,e.constructor.name),this.addAttribute(`${t||"typedarray"}.length`,e.length),this.addAttribute(`${t||"typedarray"}.byteLength`,e.byteLength),this.addAttribute(`${t||"typedarray"}.byteOffset`,e.byteOffset);return}if(null!==e&&"object"==typeof e&&this.seen.has(e))return void this.addAttribute(t||"","$@circular((");for(let[n,i]of(null!==e&&"object"==typeof e&&this.seen.add(e),Object.entries(e))){if(!this.canAddMoreAttributes())break;let a=`${t?`${t}.`:""}${Array.isArray(e)?`[${n}]`:n}`;if(Array.isArray(i))for(let e=0;e<i.length&&this.canAddMoreAttributes();e++)this.#r(i[e],`${a}.[${e}
2]`,r);else this.#r(i,a,r)}}}#r(e,t,r){if(this.canAddMoreAttributes()&&void 0!==e){if(null===e)return void this.addAttribute(t,oZ);if("string"==typeof e||"number"==typeof e||"boolean"==typeof e)return void this.addAttribute(t,e);"object"==typeof e||"function"==typeof e?this.doFlatten(e,t,r+1):this.addAttribute(t,String(e))}}}class oq{pageFetcher;data;pagination;constructor(e,t,r){this.pageFetcher=r,this.data=e,this.pagination=t}getPaginatedItems(){return this.data??[]}hasNextPage(){return!!this.pagination.next}hasPreviousPage(){return!!this.pagination.previous}getNextPage(){if(!this.pagination.next)throw Error("No next page available");return this.pageFetcher({after:this.pagination.next})}getPreviousPage(){if(!this.pagination.previous)throw Error("No previous page available");return this.pageFetcher({before:this.pagination.previous})}async *iterPages(){let e=this;for(yield e;e.hasNextPage();)e=await e.getNextPage(),yield e}async *[Symbol.asyncIterator](){for await(let e of this.iterPages())for(let t of e.getPaginatedItems())yield t}}class oH{pageFetcher;data;pagination;constructor(e,t,r){this.pageFetcher=r,this.data=e,this.pagination=t}getPaginatedItems(){return this.data??[]}hasNextPage(){return this.pagination.currentPage<this.pagination.totalPages}hasPreviousPage(){return this.pagination.currentPage>1}getNextPage(){if(!this.hasNextPage())throw Error("No next page available");return this.pageFetcher({page:this.pagination.currentPage+1})}getPreviousPage(){if(!this.hasPreviousPage())throw Error("No previous page available");return this.pageFetcher({page:this.pagination.currentPage-1})}async *iterPages(){let e=this;for(yield e;e.hasNextPage();)e=await e.getNextPage(),yield e}async *[Symbol.asyncIterator](){for await(let e of this.iterPages())for(let t of e.getPaginatedItems())yield t}}let oK={maxAttempts:3,factor:2,minTimeoutInMs:1e3,maxTimeoutInMs:6e4,randomize:!1};function oB(e,t,r,n){return new oQ(oz(e,t,r,n))}function oW(e,t,r,n,i){let a=new URLSearchParams(r.query);r.limit&&a.set("page[size]",String(r.limit)),r.after&&a.set("page[after]",r.after),r.before&&a.set("page[before]",r.before);let s=ro.object({data:ro.array(e),pagination:ro.object({next:ro.string().optional(),previous:ro.string().optional()})}),o=new URL(t);return o.search=a.toString(),new o0(oz(s,o.href,n,i),e,t,r,n,i)}function oF(e,t,r,n,i){let a=new URLSearchParams(r.query);r.limit&&a.set("perPage",String(r.limit)),r.page&&a.set("page",String(r.page));let s=ro.object({data:ro.array(e),pagination:ro.object({currentPage:ro.coerce.number(),totalPages:ro.coerce.number(),count:ro.coerce.number()})}),o=new URL(t);return o.search=a.toString(),new o1(oz(s,o.href,n,i),e,t,r,n,i)}async function oV(e,t){if(!e.options?.tracer)return t();let r=new URL(e.url),n=e.requestInit?.method??"GET",i=e.options.name??`${n} ${r.pathname}`;return await e.options.tracer.startActiveSpan(i,async e=>await t(e),{attributes:{[a6]:e.options?.icon??"api",...e.options.attributes}})}async function oz(e,t,r,n){let i=await r;return oV({url:t,requestInit:i,options:n},async r=>{var a,s,o;let l,u;s=await oM(),o=(a=i,l=Object.fromEntries(new Headers(a?.headers).entries()),s6.inject(sK.context.active(),l),i={...a,headers:new Headers(l)}),(u=new Headers(o?.headers)).set("x-trigger-request-idempotency-key",s),i={...o,headers:u};let d=await oY(e,t,i,n);return n?.onResponseBody&&r&&n.onResponseBody(d.data,r),n?.prepareData&&(d.data=await n.prepareData(d.data,d.response)),d})}async function oY(e,t,r,n,i=1){try{var a;let s=await sK.context.with(sK.context.active().setValue(s8,!0),()=>fetch(t,function(e){try{let t={...e,cache:"no-cache"};return new Request("http://localhost",t),t}catch(t){return e??{}}}(r))),o=(a=s.headers,new Proxy(Object.fromEntries(a.entries()),{get(e,t){let r=t.toString();return e[r.toLowerCase()]||e[r]}}));if(!s.ok){let a=function(e,t,r){function n(){let e=sA({...oK,...r},t);return e?{retry:!0,delay:e}:{retry:!1}}let i=e.headers.get("x-should-retry");if("true"===i)return n();if("false"===i)return{retry:!1};if(408===e.status||409===e.status)return n();if(429===e.status){if(t>=("number"==typeof r?.maxAttempts?r?.maxAttempts:3))return{retry:!1};let i=e.headers.get("x-ratelimit-reset");if(i){let e=parseInt(i,10)-Date.now()+Math.floor(1e3*Math.random());if(e>0)return{retry:!0,delay:e}}return n()}return e.status>=500?n():{retry:!1}}(s,i,n?.retry);if(a.retry)return await o2(t,i+1,a.delay,n,r,s),await oY(e,t,r,n,i+1);{let e=await s.text().catch(e=>oX(e).message),t=function(e){try{return JSON.parse(e)}catch(e){return}}(e),r=t?void 0:e;throw sj.generate(s.status,t,r,o)}}let l=await oJ(s),u=e.safeParse(l);if(u.success)return{data:u.data,response:s};let d=function(e,t={}){var r,n,i;let{maxIssuesInMessage:a=99,issueSeparator:s="; ",unionSeparator:o=", or ",prefixSeparator:l=": ",prefix:u=sC}=t;return new sO((r=e.errors.slice(0,a).map(e=>(function e(t,r,n){if("invalid_union"===t.code)return t.unionErrors.reduce((t,i)=>{let a=i.issues.map(t=>e(t,r,n)).join(r);
2return t.includes(a)||t.push(a),t},[]).join(n);if(0!==t.path.length){var i;if(1===t.path.length){let e=t.path[0];if("number"==typeof e)return`${t.message} at index ${e}`}return`${t.message} at "${1===(i=t.path).length?i[0].toString():i.reduce((e,t)=>{if("number"==typeof t)return e+"["+t.toString()+"]";if(t.includes('"'))return e+'["'+t.replace(/"/g,'\\"')+'"]';if(!sx.test(t))return e+'["'+t+'"]';let r=0===e.length?"":".";return e+r+t},"")}"`}return t.message})(e,s,o)).join(s),n=u,i=l,null!==n?r.length>0?[n,r].join(i):n:r.length>0?r:sC),e.errors)}(u.error);throw new sq({status:s.status,cause:d,message:d.message,rawBody:l,headers:o})}catch(a){if(a instanceof sj)throw a;if(n?.retry){let a=sA({...oK,...n.retry},i);if(a)return await o2(t,i+1,a,n,r),await oY(e,t,r,n,i+1)}throw new sP({cause:oX(a)})}}async function oJ(e){try{return await e.clone().json()}catch(e){return}}function oX(e){return e instanceof Error?e:Error(e)}class oQ extends Promise{responsePromise;constructor(e){super(e=>{e(null)}),this.responsePromise=e}asResponse(){return this.responsePromise.then(e=>e.response)}async withResponse(){let[e,t]=await Promise.all([this.parse(),this.asResponse()]);return{data:e,response:t}}parse(){return this.responsePromise.then(e=>e.data)}then(e,t){return this.parse().then(e,t)}catch(e){return this.parse().catch(e)}finally(e){return this.parse().finally(e)}}class o0 extends oQ{schema;url;params;requestInit;options;constructor(e,t,r,n,i,a){super(e.then(e=>({data:new oq(e.data.data,e.data.pagination,this.#n.bind(this)),response:e.response}))),this.schema=t,this.url=r,this.params=n,this.requestInit=i,this.options=a}#n(e){return oW(this.schema,this.url,{...this.params,...e},this.requestInit,this.options)}async *[Symbol.asyncIterator](){for await(let e of(await this))yield e}}class o1 extends oQ{schema;url;params;requestInit;options;constructor(e,t,r,n,i,a){super(e.then(e=>({data:new oH(e.data.data,e.data.pagination,this.#n.bind(this)),response:e.response}))),this.schema=t,this.url=r,this.params=n,this.requestInit=i,this.options=a}#n(e){return oF(this.schema,this.url,{...this.params,...e},this.requestInit,this.options)}async *[Symbol.asyncIterator](){for await(let e of(await this))yield e}}async function o2(e,t,r,n,i,a){if(n?.tracer){let e=i?.method??"GET";return n.tracer.startActiveSpan(a?`wait after ${a.status}`:"wait after error",async e=>{await new Promise(e=>setTimeout(e,r))},{attributes:{[a6]:"wait",...function(e,t,r=128){let n=new oG(void 0,r);return n.doFlatten(e,t,0),n.attributes}({items:[{text:`retrying ${n?.name??e.toUpperCase()} in ${r}ms`,variant:"normal"}],style:"codepath"},"$style.accessory")}})}await new Promise(e=>setTimeout(e,r))}let o4=new WeakMap;function o9(e){let t=o4.get(e);if(t)return t;let r=e().finally(()=>{o4.delete(e)});return o4.set(e,r),r}var o5=e.i(543966);let o3={home:"https://trigger.dev/docs/v3/machines"},o6={beta:"https://trigger.dev/docs/upgrading-beta"},o8={concurrentWaits:"https://trigger.dev/docs/troubleshooting#parallel-waits-are-not-supported",stalledExecution:"https://trigger.dev/docs/troubleshooting#task-run-stalled-executing",uncaughtException:"https://trigger.dev/docs/troubleshooting#uncaught-exceptions"},o7={recursiveDeadlock:"https://trigger.dev/docs/queue-concurrency#waiting-for-a-subtask-on-the-same-queue",deadlock:"https://trigger.dev/docs/queue-concurrency#deadlock"},le="https://trigger.dev/contact",lt={TASK_PROCESS_OOM_KILLED:{message:"Your run was terminated due to exceeding the machine's memory limit. Try increasing the machine preset in your task options or replay using a larger machine.",link:{name:"Machines",href:o3.home}},TASK_PROCESS_MAYBE_OOM_KILLED:{message:"Your run was terminated due to exceeding the machine's memory limit. Try increasing the machine preset in your task options or replay using a larger machine.",link:{name:"Machines",href:o3.home}},TASK_PROCESS_SIGSEGV:{message:"Your task crashed with a segmentation fault (SIGSEGV). Most likely there's a bug in a package or binary you're using. If this keeps happening and you're unsure why, please get in touch.",link:{name:"Contact us",href:le,magic:"CONTACT_FORM"}},TASK_PROCESS_SIGTERM:{message:"Your task exited after receiving SIGTERM but we don't know
2why. If this keeps happening, please get in touch so we can investigate.",link:{name:"Contact us",href:le,magic:"CONTACT_FORM"}},OUTDATED_SDK_VERSION:{message:"Your task is using an outdated version of the SDK. Please upgrade to the latest version.",link:{name:"Beta upgrade guide",href:o6.beta}},TASK_DID_CONCURRENT_WAIT:{message:"Parallel waits are not supported, e.g. using Promise.all() around our wait functions.",link:{name:"Read the docs for solutions",href:o8.concurrentWaits}},RECURSIVE_WAIT_DEADLOCK:{message:"This run will never execute because it was triggered recursively and the task has no remaining concurrency available.",link:{name:"See docs for help",href:o7.recursiveDeadlock}},TASK_RUN_STALLED_EXECUTING:{link:{name:"Read our troubleshooting guide",href:o8.stalledExecution}},TASK_RUN_UNCAUGHT_EXCEPTION:{link:{name:"Read our troubleshooting guide",href:o8.uncaughtException}}},lr=e=>({type:"INTERNAL_ERROR",code:e,...lt[e]}),ln=(e,t=100)=>{if(!e)return;let r=t?e.slice(0,t):e;return r.includes("SIGTERM")?"SIGTERM":r.includes("SIGSEGV")?"SIGSEGV":r.includes("SIGKILL")?"SIGKILL":r.includes("SIGABRT")?"SIGABRT":void 0};function li(e,t,r){return new ReadableStream({async start(n){let i=e.pipeThrough(new TransformStream(t)).getReader();for(r.addEventListener("abort",()=>{queueMicrotask(()=>{i.cancel(),n.close()})});;){let{done:e,value:t}=await i.read();if(e){n.close();break}n.enqueue(t)}}})}var la=e.i(431326);e.i(721092);var ro=ro;let ls="api-client";function lo(){let e=sk("TRIGGER_DEV_BRANCH");return e&&"default"!==e?e:void 0}class ll extends Error{constructor(e){super(e),this.name="ApiClientMissingError"}}class lu{static _instance;static getInstance(){return this._instance||(this._instance=new lu),this._instance}disable(){let e;(e=a7[se])&&delete e[ls]}get baseURL(){let e=a8();if(e)return e.apiClientConfig.baseURL??"https://api.trigger.dev";let t=this.#i();return t?.baseURL??sk("TRIGGER_API_URL")??"https://api.trigger.dev"}get accessToken(){let e=a8();if(e)return e.apiClientConfig.accessToken??e.apiClientConfig.secretKey;let t=this.#i();return t?.secretKey??t?.accessToken??sk("TRIGGER_SECRET_KEY")??sk("TRIGGER_ACCESS_TOKEN")}get branchName(){let e=a8();if(e)return e.apiClientConfig.previewBranch||void 0;let t=this.#i();return(t?.previewBranch??sk("TRIGGER_PREVIEW_BRANCH")??sk("VERCEL_GIT_COMMIT_REF")??lo()??void 0)||void 0}get externalDeploymentId(){let e=a8();return e?e.apiClientConfig.externalDeploymentId:this.#i()?.externalDeploymentId}resolveApiClientConfig(e={}){return{baseURL:e.baseURL??sk("TRIGGER_API_URL"),accessToken:e.accessToken??e.secretKey??sk("TRIGGER_SECRET_KEY")??sk("TRIGGER_ACCESS_TOKEN"),secretKey:e.secretKey,refreshAccessToken:e.refreshAccessToken,previewBranch:e.previewBranch??sk("TRIGGER_PREVIEW_BRANCH")??sk("VERCEL_GIT_COMMIT_REF")??lo(),externalDeploymentId:e.externalDeploymentId,requestOptions:e.requestOptions,future:e.future}}get client(){if(!this.baseURL||!this.accessToken)return;let e=a8(),t=e?.apiClientConfig??this.#i(),r=t?.requestOptions,n=t?.future;return new dp(this.baseURL,this.accessToken,this.branchName,r,n,t?.refreshAccessToken)}clientOrThrow(e){let t=e?.baseURL??this.baseURL,r=e?.accessToken??e?.secretKey??this.accessToken;if(!t||!r)throw new ll(this.apiClientMissingError());let n=e?.previewBranch??this.branchName,i=a8(),a=i?.apiClientConfig??this.#i();return new dp(t,r,n,e?.requestOptions??a?.requestOptions,e?.future??a?.future,e?.refreshAccessToken??a?.refreshAccessToken)}runWithConfig(e,t){let n=a8()?.apiClientConfig??this.#i(),i=this.resolveApiClientConfig({...n,...e});if(void 0!==r){let e,n;return e={apiClientConfig:i,inheritContext:!0},n=t,r?r.run(e,n):n()}let a=this.#i();return st(ls,i,!0),t().finally(()=>{st(ls,a,!0)})}setGlobalAPIClientConfiguration(e){return st(ls,e,!0)}#i(){return a7[se]?.[ls]}apiClientMissingError(){let e=!!this.baseURL,t=!!this.accessToken;return e||t?e?t?"Unknown error":"You need to set the TRIGGER_SECRET_KEY environment variable. See https://trigger.dev/docs/management/overview#authentication":"You need to set the TRIGGER_API_URL environment variable. See https://trigger.dev/docs/management/overview#authentication":"You need to set the TRIGGER_API_URL and TRIGGER_SECRET_KEY environment variables. See https://trigger.dev/docs/management/overview#authentication"}}let ld=lu.getInstance();var lc=class{constructor(){this.keyToValue=new Map,this.valueToKey=new Map}set(e,t){this.keyToValue.set(e,t),this.valueToKey.set(t,e)}getByKey(e){return this.keyToValue.get(e)}getByValue(e){return this.valueToKey.get(e)}clear(){this.keyToValue.clear(),this.valueToKey.clear()}},lp=class{constructor(e){this.generateIdentifier=e,this.kv=new lc}register(e,t){this.kv.getByValue(e)||(t||(t=this.generateIdentifier(e)),this.kv.set(t,e))}clear(){this.kv.clear()}getIdentifier(e){return this.kv.getByValue(e)}getValue(e){return this.kv.getByKey(e)}},lh=class extends lp{constructor(){super(e=>e.name),this.classToAllowedProps=new Map}register(e,t){"object"==typeof t?(t.allowProps&&this.classToAllowedProps.set(e,t.allowProps),super.register(e,t.identifier)):super.register(e,t)}getAllowedProps(e){return this.classToAllowedProps.get(e)}};function lm(e,t){Object.entries(e).forEach(([e,r])=>t(r,e))}function lg(e,t){return -1!==e.indexOf(t)}function lf(e,t){for(let r=0;r<e.length;r++){let n=e[r];if(t(n))return n}}var ly=class{constructor(){this.transfomers={}}register(e){this.transfomers[e.name]=e}findApplicable(e){return function(e,t){let r=function(e){if("values"in Object)return Object.values(e);let t=[];for(let r in e)e.hasOwnProperty(r)&&t.push(e[r]);return t}(e);if("find"in r)return r.find(t);for(let e=0;e<r.length;e++){let n=r[e];if(t(n))return n}}(this.transfomers,t=>t.isApplicable(e))}findByName(e){return this.transfomers[e]}},lb=e=>void 0===e,lv=e=>"object"==typeof e&&null!==e&&e!==Object.prototype&&(null===Object.getPrototypeOf(e)||Object.getPrototypeOf(e)===Object.prototype),l_=e=>lv(e)&&0===Object.keys(e).length,lE=e=>Array.isArray(e),lT=e=>e instanceof Map,lw=e=>e instanceof Set,lI=e=>"Symbol"===Object.prototype.toString.call(e).slice(8,-1),lS=e=>"number"==typeof e&&isNaN(e),lk=e=>e.replace(/\./g,"\\."),lR=e=>e.map(String).map(lk).join("."),lA=e=>{let t=[],r="";for(let n=0;n<e.length;n++){let i=e.charAt(n);if("\\"===i&&"."===e.charAt(n+1)){r+=".",n++;continue}
2if("."===i){t.push(r),r="";continue}r+=i}let n=r;return t.push(n),t};function lx(e,t,r,n){return{isApplicable:e,annotation:t,transform:r,untransform:n}}var lC=[lx(lb,"undefined",()=>null,()=>void 0),lx(e=>"bigint"==typeof e,"bigint",e=>e.toString(),e=>"u">typeof BigInt?BigInt(e):(console.error("Please add a BigInt polyfill."),e)),lx(e=>e instanceof Date&&!isNaN(e.valueOf()),"Date",e=>e.toISOString(),e=>new Date(e)),lx(e=>e instanceof Error,"Error",(e,t)=>{let r={name:e.name,message:e.message};return t.allowedErrorProps.forEach(t=>{r[t]=e[t]}),r},(e,t)=>{let r=Error(e.message);return r.name=e.name,r.stack=e.stack,t.allowedErrorProps.forEach(t=>{r[t]=e[t]}),r}),lx(e=>e instanceof RegExp,"regexp",e=>""+e,e=>new RegExp(e.slice(1,e.lastIndexOf("/")),e.slice(e.lastIndexOf("/")+1))),lx(lw,"set",e=>[...e.values()],e=>new Set(e)),lx(lT,"map",e=>[...e.entries()],e=>new Map(e)),lx(e=>lS(e)||e===1/0||e===-1/0,"number",e=>lS(e)?"NaN":e>0?"Infinity":"-Infinity",Number),lx(e=>0===e&&1/e==-1/0,"number",()=>"-0",Number),lx(e=>e instanceof URL,"URL",e=>e.toString(),e=>new URL(e))];function lO(e,t,r,n){return{isApplicable:e,annotation:t,transform:r,untransform:n}}var lj=lO((e,t)=>!!lI(e)&&!!t.symbolRegistry.getIdentifier(e),(e,t)=>["symbol",t.symbolRegistry.getIdentifier(e)],e=>e.description,(e,t,r)=>{let n=r.symbolRegistry.getValue(t[1]);if(!n)throw Error("Trying to deserialize unknown symbol");return n}),lP=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,Uint8ClampedArray].reduce((e,t)=>(e[t.name]=t,e),{}),lN=lO(e=>ArrayBuffer.isView(e)&&!(e instanceof DataView),e=>["typed-array",e.constructor.name],e=>[...e],(e,t)=>{let r=lP[t[1]];if(!r)throw Error("Trying to deserialize unknown typed array");return new r(e)});function lU(e,t){return!!e?.constructor&&!!t.classRegistry.getIdentifier(e.constructor)}var lD=lO(lU,(e,t)=>["class",t.classRegistry.getIdentifier(e.constructor)],(e,t)=>{let r=t.classRegistry.getAllowedProps(e.constructor);if(!r)return{...e};let n={};return r.forEach(t=>{n[t]=e[t]}),n},(e,t,r)=>{let n=r.classRegistry.getValue(t[1]);if(!n)throw Error("Trying to deserialize unknown class - check https://github.com/blitz-js/superjson/issues/116#issuecomment-773996564");return Object.assign(Object.create(n.prototype),e)}),l$=lO((e,t)=>!!t.customTransformerRegistry.findApplicable(e),(e,t)=>["custom",t.customTransformerRegistry.findApplicable(e).name],(e,t)=>t.customTransformerRegistry.findApplicable(e).serialize(e),(e,t,r)=>{let n=r.customTransformerRegistry.findByName(t[1]);if(!n)throw Error("Trying to deserialize unknown custom value");return n.deserialize(e)}),lL=[lD,lj,l$,lN],lM=(e,t)=>{let r=lf(lL,r=>r.isApplicable(e,t));if(r)return{value:r.transform(e,t),type:r.annotation(e,t)};let n=lf(lC,r=>r.isApplicable(e,t));if(n)return{value:n.transform(e,t),type:n.annotation}},lZ={};lC.forEach(e=>{lZ[e.annotation]=e});var lG=(e,t)=>{let r=e.keys();for(;t>0;)r.next(),t--;return r.next().value};function lq(e){if(lg(e,"__proto__"))throw Error("__proto__ is not allowed as a property");if(lg(e,"prototype"))throw Error("prototype is not allowed as a property");if(lg(e,"constructor"))throw Error("constructor is not allowed as a property")}var lH=(e,t,r)=>{if(lq(t),0===t.length)return r(e);let n=e;for(let e=0;e<t.length-1;e++){let r=t[e];if(lE(n))n=n[+r];else if(lv(n))n=n[r];else if(lw(n))n=lG(n,+r);else if(lT(n)){if(e===t.length-2)break;let i=+r,a=0==+t[++e]?"key":"value",s=lG(n,i);switch(a){case"key":n=s;break;case"value":n=n.get(s)}}}let i=t[t.length-1];if(lE(n)?n[+i]=r(n[+i]):lv(n)&&(n[i]=r(n[i])),lw(n)){let e=lG(n,+i),t=r(e);e!==t&&(n.delete(e),n.add(t))}if(lT(n)){let e=lG(n,+t[t.length-2]);switch(0==+i?"key":"value"){case"key":{let t=r(e);n.set(t,n.get(e)),t!==e&&n.delete(e);break}case"value":n.set(e,r(n.get(e)))}}return e},lK=(e,t,r,n,i=[],a=[],s=new Map)=>{let o=(e=>"boolean"==typeof e||null===e||lb(e)||"number"==typeof e&&!isNaN(e)||"string"==typeof e||lI(e))(e);if(!o){let r;(r=t.get(e))?r.push(i):t.set(e,[i]);let a=s.get(e);if(a)return n?{transformedValue:null}:a}if(!(lv(e)||lE(e)||lT(e)||lw(e)||lU(e,r))){let t=lM(e,r),n=t?{transformedValue:t.value,annotations:[t.type]}:{transformedValue:e};return o||s.set(e,n),n}if(lg(a,e))return{transformedValue:null};let l=lM(e,r),u=l?.value??e,d=lE(u)?[]:{},c={};lm(u,(o,l)=>{if("__proto__"===l||"constructor"===l||"prototype"===l)throw Error(`Detected property ${l}. This is a prototype pollution risk, please remove it from your object.`);let u=lK(o,t,r,n,[...i,l],[...a,e],s);d[l]=u.transformedValue,lE(u.annotations)?c[l]=u.annotations:lv(u.annotations)&&lm(u.annotations,(e,t)=>{c[lk(l)+"."+t]=e})});let p=l_(c)?{transformedValue:d,annotations:l?[l.type]:void 0}:{transformedValue:d,annotations:l?[l.type,c]:c};return o||s.set(e,p),p};function lB(e){return Object.prototype.toString.call(e).slice(8,-1)}function lW(e){return"Array"===lB(e)}var lF=class{constructor({dedupe:e=!1}={}){this.classRegistry=new lh,this.symbolRegistry=new lp(e=>e.description??""),this.customTransformerRegistry=new ly,this.allowedErrorProps=[],this.dedupe=e}serialize(e){var t;let r,n,i=new Map,a=lK(e,i,this,this.dedupe),s={json:a.transformedValue};a.annotations&&(s.meta={...s.meta,values:a.annotations});let o=(t=this.dedupe,r={}
2,(i.forEach(e=>{if(e.length<=1)return;t||(e=e.map(e=>e.map(String)).sort((e,t)=>e.length-t.length));let[i,...a]=e;0===i.length?n=a.map(lR):r[lR(i)]=a.map(lR)}),n)?l_(r)?[n]:[n,r]:l_(r)?void 0:r);return o&&(s.meta={...s.meta,referentialEqualities:o}),s}deserialize(e){var t,r,n;let{json:i,meta:a}=e,s=function e(t,r={}){return lW(t)?t.map(t=>e(t,r)):!function(e){if("Object"!==lB(e))return!1;let t=Object.getPrototypeOf(e);return!!t&&t.constructor===Object&&t===Object.prototype}(t)?t:[...Object.getOwnPropertyNames(t),...Object.getOwnPropertySymbols(t)].reduce((n,i)=>{var a;let s;if(lW(r.props)&&!r.props.includes(i))return n;let o=e(t[i],r);return a=r.nonenumerable,"enumerable"==(s=({}).propertyIsEnumerable.call(t,i)?"enumerable":"nonenumerable")&&(n[i]=o),a&&"nonenumerable"===s&&Object.defineProperty(n,i,{value:o,enumerable:!1,writable:!0,configurable:!0}),n},{})}(i);return a?.values&&(t=s,r=a.values,n=this,function e(t,r,n=[]){if(!t)return;if(!lE(t))return void lm(t,(t,i)=>e(t,r,[...n,...lA(i)]));let[i,a]=t;a&&lm(a,(t,i)=>{e(t,r,[...n,...lA(i)])}),r(i,n)}(r,(e,r)=>{t=lH(t,r,t=>((e,t,r)=>{if(lE(t))switch(t[0]){case"symbol":return lj.untransform(e,t,r);case"class":return lD.untransform(e,t,r);case"custom":return l$.untransform(e,t,r);case"typed-array":return lN.untransform(e,t,r);default:throw Error("Unknown transformation: "+t)}{let n=lZ[t];if(!n)throw Error("Unknown transformation: "+t);return n.untransform(e,r)}})(t,e,n))}),s=t),a?.referentialEqualities&&(s=function(e,t){function r(t,r){let n=((e,t)=>{lq(t);for(let r=0;r<t.length;r++){let n=t[r];if(lw(e))e=lG(e,+n);else if(lT(e)){let i=+n,a=0==+t[++r]?"key":"value",s=lG(e,i);switch(a){case"key":e=s;break;case"value":e=e.get(s)}}else e=e[n]}return e})(e,lA(r));t.map(lA).forEach(t=>{e=lH(e,t,()=>n)})}if(lE(t)){let[n,i]=t;n.forEach(t=>{e=lH(e,lA(t),()=>e)}),i&&lm(i,r)}else lm(t,r);return e}(s,a.referentialEqualities)),s}stringify(e){return JSON.stringify(this.serialize(e))}parse(e){return this.deserialize(JSON.parse(e))}registerClass(e,t){this.classRegistry.register(e,t)}registerSymbol(e,t){this.symbolRegistry.register(e,t)}registerCustom(e,t){this.customTransformerRegistry.register({name:t,...e})}allowErrorProps(...e){this.allowedErrorProps.push(...e)}};async function lV(e,t){if(e.data)switch(e.dataType){case"application/json":return JSON.parse(e.data,function(e){if(e)return function(t,r){if(!e?.filteredKeys?.includes(t))return r}}(t));case"application/super+json":return lF.parse(e.data);case"text/plain":default:return e.data;case"application/store":throw Error(`Cannot parse an application/store packet (${e.data}). Needs to be imported first.`)}}async function lz(e,t){let r=await lJ(e,void 0,t);return await lV(r)}lF.defaultInstance=new lF,lF.serialize=lF.defaultInstance.serialize.bind(lF.defaultInstance),lF.deserialize=lF.defaultInstance.deserialize.bind(lF.defaultInstance),lF.stringify=lF.defaultInstance.stringify.bind(lF.defaultInstance),lF.parse=lF.defaultInstance.parse.bind(lF.defaultInstance),lF.registerClass=lF.defaultInstance.registerClass.bind(lF.defaultInstance),lF.registerSymbol=lF.defaultInstance.registerSymbol.bind(lF.defaultInstance),lF.registerCustom=lF.defaultInstance.registerCustom.bind(lF.defaultInstance),lF.allowErrorProps=lF.defaultInstance.allowErrorProps.bind(lF.defaultInstance),lF.serialize,lF.deserialize,lF.stringify,lF.parse,lF.registerClass,lF.registerCustom,lF.registerSymbol,lF.allowErrorProps,lF.registerCustom({isApplicable:e=>"function"==typeof la.Buffer&&la.Buffer.isBuffer(e),serialize:e=>[...e],deserialize:e=>la.Buffer.from(e)},"buffer");let lY={minTimeoutInMs:500,maxTimeoutInMs:5e3,maxAttempts:5,factor:2,randomize:!0};async function lJ(e,t,r){return"application/store"!==e.dataType?e:t?await t.startActiveSpan("store.downloadPayload",async t=>await lX(e,t,r),{attributes:{[a6]:"cloud-download"}})??e:await lX(e,void 0,r)}async function lX(e,t,r){if(!e.data)return e;let n=r??ld.client;if(!n)return e;let i=await n.getPayloadUrl(e.data),a=await oB(ro.any(),i.presignedUrl,void 0,{retry:lY}).asResponse();if(!a.ok)throw Error(`Failed to import packet ${i.presignedUrl}: ${a.statusText}`);let s=await a.text();return t?.setAttribute("size",la.Buffer.byteLength(s,"utf8")),{data:s,dataType:a.headers.get("content-type")??"application/json"}}async function lQ(e,t){let r,n=e.getReader();for(;!(r=await n.read()).done;)t(r.value)}function l0(){return{data:"",event:"",id:"",retry:void 0}}var l1=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&0>t.indexOf(n)&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var i=0,n=Object.getOwnPropertySymbols(e);i<n.length;i++)0>t.indexOf(n[i])&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]]);return r};let l2="text/event-stream",l4="last-event-id";function l9(e){let t=e.headers.get("content-type");if(!(null==t?void 0:t.startsWith(l2)))throw Error(`Expected content-type to be ${l2}, Actual: ${t}`)}var l5=Object.defineProperty,l3=Object.defineProperties,l6=Object.getOwnPropertyDescriptors,l8=Object.getOwnPropertySymbols,l7=Object.prototype.hasOwnProperty,ue=Object.prototype.propertyIsEnumerable,ut=e=>{throw TypeError(e)},ur=(e,t,r)=>t in e?l5(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,un=(e,t)=>{for(var r in t||(t={}))l7.call(t,r)&&ur(e,r,t[r]);if(l8)for(var r of l8(t))ue.call(t,r)&&ur(e,r,t[r]);return e},ui=(e,t,r)=>t.has(e)||ut("Cannot "+r),ua=(e,t,r)=>(ui(e,t,"read from private field"),r?r.call(e):t.get(e)),us=(e,t,r)=>t.has(e)?ut("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),uo=(e,t,r,n)=>(ui(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r),ul=(e,t,r)=>(ui(e,t,"access private method"),r),uu=(e,t,r,n)=>({set _(value){uo(e,t,value,r)},get _(){return ua(e,t,n)}}),ud=(e,t,r)=>new Promise((n,i)=>{var a=e=>{try{o(r.next(e))}catch(e){i(e)}},s=e=>{try{o(r.throw(e))}catch(e){i(e)}},o=e=>e.done?n(e.value):Promise.resolve(e.value).then(a,s);o((r=r.apply(e,t)).next())}
2),uc=class e extends Error{constructor(e,t,r,n,i,a){super(a||`HTTP Error ${e} at ${i}: ${null!=t?t:JSON.stringify(r)}`),this.url=i,this.name="FetchError",this.status=e,this.text=t,this.json=r,this.headers=n}static fromResponse(t,r){return ud(this,null,function*(){let n,i,a=t.status,s=Object.fromEntries([...t.headers.entries()]),o=t.headers.get("content-type");return t.bodyUsed||(o&&o.includes("application/json")?i=yield t.json():n=yield t.text()),new e(a,n,i,s,r)})}},up=class extends Error{constructor(){super("Fetch with backoff aborted"),this.name="FetchBackoffAbortError"}},uh=class extends Error{constructor(){super("Invalid shape options: missing required url parameter"),this.name="MissingShapeUrlError"}},um=class extends Error{constructor(){super("Invalid signal option. It must be an instance of AbortSignal."),this.name="InvalidSignalError"}},ug=class extends Error{constructor(){super("shapeHandle is required if this isn't an initial fetch (i.e. offset > -1)"),this.name="MissingShapeHandleError"}},uf=class extends Error{constructor(e){super(`Cannot use reserved Electric parameter names in custom params: ${e.join(", ")}`),this.name="ReservedParamError"}},uy=class extends Error{constructor(e){super(`Column "${null!=e?e:"unknown"}" does not allow NULL values`),this.name="ParserNullValueError"}},ub=class extends Error{constructor(e,t){let r=`The response for the shape request to ${e} didn't include the following required headers: 3`;t.forEach(e=>{r+=`- ${e} 4`}),super(r+=` 5This is often due to a proxy not setting CORS correctly so that all Electric headers can be read by the client. 6For more information visit the troubleshooting guide: /docs/guides/troubleshooting/missing-headers`)}},uv=e=>Number(e),u_=e=>JSON.parse(e),uE=e=>e,uT={int2:uv,int4:uv,int8:e=>BigInt(e),bool:e=>"true"===e||"t"===e,float4:uv,float8:uv,json:u_,jsonb:u_},uw=class{constructor(e,t){this.parser=un(un({},uT),e),this.transformer=t}parse(e,t){return JSON.parse(e,(e,r)=>{if(("value"===e||"old_value"===e)&&"object"==typeof r&&null!==r){let e=r;Object.keys(e).forEach(r=>{e[r]=this.parseRow(r,e[r],t)}),this.transformer&&(r=this.transformer(r))}return r})}parseRow(e,t,r){var n;let i=r[e];if(!i)return t;let{type:a,dims:s}=i,o=((e,t)=>{var r={};for(var n in e)l7.call(e,n)&&0>t.indexOf(n)&&(r[n]=e[n]);if(null!=e&&l8)for(var n of l8(e))0>t.indexOf(n)&&ue.call(e,n)&&(r[n]=e[n]);return r})(i,["type","dims"]),l=uI(null!=(n=this.parser[a])?n:uE,i,e);return s&&s>0?uI((e,t)=>(function(e,t){let r,n=0,i=null,a="",s=!1,o=0;function l(e,r,n){let i=e.slice(r,n);return i="NULL"===i?null:i,t?t(i):i}return function e(u){let d=[];for(;n<u.length;n++){if(i=u[n],s)"\\"===i?a+=u[++n]:'"'===i?(d.push(t?t(a):a),a="",s='"'===u[n+1],o=n+2):a+=i;else if('"'===i)s=!0;else if("{"===i)o=++n,d.push(e(u));else if("}"===i){s=!1,o<n&&d.push(l(u,o,n)),o=n+1;break}else","===i&&"}"!==r&&'"'!==r&&(d.push(l(u,o,n)),o=n+1);r=i}return o<n&&d.push(d.push(l(u,o,n+1))),d}(e)[0]})(e,l),i,e)(t):l(t,o)}};function uI(e,t,r){var n;let i=!(null!=(n=t.not_null)&&n);return n=>{if(null===n){if(!i)throw new uy(null!=r?r:"unknown");return null}return e(n,t)}}function uS(e){return"key"in e}function uk(e){return!uS(e)&&"up-to-date"===e.headers.control}var uR="electric-handle",uA="electric-offset",ux="cursor",uC="expired_handle",uO="handle",uj="live",uP="offset",uN="force-disconnect-and-refresh",uU="pause-stream",uD="subset__where",u$="subset__limit",uL="subset__offset",uM="subset__order_by",uZ="subset__params",uG=[uj,uO,uP,ux,uC,"log",uD,u$,uL,uM,uZ],uq=[429],uH={initialDelay:100,maxDelay:1e4,multiplier:1.3},uK=[201,204,205],uB={maxChunksToPrefetch:2},uW=["electric-offset","electric-handle"],uF=["electric-cursor"],uV=["electric-schema"],uz=class{constructor(e){var t;us(this,l),us(this,n),us(this,i),us(this,a,new Map),us(this,s),us(this,o),uo(this,n,null!=(t=e.fetchClient)?t:(...e)=>fetch(...e)),uo(this,i,e.maxPrefetchedRequests),uo(this,s,e.url.toString()),uo(this,o,ua(this,s)),ul(this,l,u).call(this,e.url,e.requestInit)}abort(){ua(this,a).forEach(([e,t])=>t.abort())}consume(...e){var t;let r=e[0].toString(),n=null==(t=ua(this,a).get(r))?void 0:t[0];if(n&&r===ua(this,s))return ua(this,a).delete(r),n.then(t=>{let n=uY(r,t);uo(this,s,n),ua(this,o)&&!ua(this,a).has(ua(this,o))&&ul(this,l,u).call(this,ua(this,o),e[1])}).catch(()=>{}),n}};function uY(e,t){let r=t.headers.get(uR),n=t.headers.get(uA),i=t.headers.has("electric-up-to-date");if(!r||!n||i)return;let a=new URL(e);if(!a.searchParams.has(uj))return a.searchParams.set(uO,r),a.searchParams.set(uP,n),a.searchParams.sort(),a.toString()}function uJ(){}n=new WeakMap,i=new WeakMap,a=new WeakMap,s=new WeakMap,o=new WeakMap,l=new WeakSet,u=function(...e){var t,r;let s=e[0].toString();if(ua(this,a).size>=ua(this,i))return;let d=new AbortController;try{let i,c,{signal:p,cleanup:h}=function(e,t){let r=uJ;if(t)if(t.aborted)e.abort();else{let n=()=>e.abort();t.addEventListener("abort",n,{once:!0,signal:e.signal}),r=()=>t.removeEventListener("abort",n)}return{signal:e.signal,cleanup:r}}(d,null==(t=e[1])?void 0:t.signal),m=ua(this,n).call(this,s,(i=un({},null!=(r=e[1])?r:{}),c={signal:p},l3(i,l6(c))));ua(this,a).set(s,[m,d]),m.then(t=>{if(!t.ok||d.signal.aborted)return;let r=uY(s,t);return r&&r!==s?(uo(this,o,r),ul(this,l,u).call(this,r,e[1])):void uo(this,o,void 0)}).catch(()=>{}).finally(h)}catch(e){}};var uX=new class{constructor(){this.data={},this.max=250,this.storageKey="electric_expired_shapes",this.load()}getExpiredHandle(e){let t=this.data[e];return t?(t.lastUsed=Date.now(),this.save(),t.expiredHandle):null}markExpired(e,t){this.data[e]={expiredHandle:t,lastUsed:Date.now()};let r=Object.keys(this.data);if(r.length>this.max){let e=r.reduce((e,t)=>
6this.data[t].lastUsed<this.data[e].lastUsed?t:e);delete this.data[e]}this.save()}save(){if("u">typeof localStorage)try{localStorage.setItem(this.storageKey,JSON.stringify(this.data))}catch(e){}}load(){if("u">typeof localStorage)try{let e=localStorage.getItem(this.storageKey);e&&(this.data=JSON.parse(e))}catch(e){this.data={}}}clear(){this.data={},this.save()}},uQ=class{constructor(){this.activeSnapshots=new Map,this.xmaxSnapshots=new Map,this.snapshotsByDatabaseLsn=new Map}addSnapshot(e,t){var r,n,i,a;this.activeSnapshots.set(e.snapshot_mark,{xmin:BigInt(e.xmin),xmax:BigInt(e.xmax),xip_list:e.xip_list.map(BigInt),keys:t});let s=null!=(n=null==(r=this.xmaxSnapshots.get(BigInt(e.xmax)))?void 0:r.add(e.snapshot_mark))?n:new Set([e.snapshot_mark]);this.xmaxSnapshots.set(BigInt(e.xmax),s);let o=null!=(a=null==(i=this.snapshotsByDatabaseLsn.get(BigInt(e.database_lsn)))?void 0:i.add(e.snapshot_mark))?a:new Set([e.snapshot_mark]);this.snapshotsByDatabaseLsn.set(BigInt(e.database_lsn),o)}removeSnapshot(e){this.activeSnapshots.delete(e)}shouldRejectMessage(e){let t=e.headers.txids||[];if(0===t.length)return!1;let r=Math.max(...t);for(let[e,t]of this.xmaxSnapshots.entries())if(r>=e)for(let e of t)this.removeSnapshot(e);return[...this.activeSnapshots.values()].some(t=>{let n,i,a,s;return t.keys.has(e.key)&&(n=BigInt(r),i=BigInt(t.xmin),a=BigInt(t.xmax),s=t.xip_list.map(BigInt),n<i||n<a&&!s.includes(n))})}lastSeenUpdate(e){for(let[t,r]of this.snapshotsByDatabaseLsn.entries())if(t<=e)for(let e of r)this.removeSnapshot(e)}},u0=new Set([ux,uO,uj,uP]);function u1(e){return ud(this,null,function*(){return"function"==typeof e?e():e})}function u2(e){let t=new URL(e.origin+e.pathname);for(let[r,n]of e.searchParams)uG.includes(r)||t.searchParams.set(r,n);return t.searchParams.sort(),t.toString()}var u4=class{constructor(e){var t,r,n,i;us(this,$),us(this,d,null),us(this,c),us(this,p),us(this,h),us(this,m,new Map),us(this,g,!1),us(this,f,"active"),us(this,y),us(this,b),us(this,v),us(this,_,!1),us(this,E,!0),us(this,T,!1),us(this,w),us(this,I),us(this,S),us(this,k),us(this,R),us(this,A,!1),us(this,x),us(this,C),us(this,O),us(this,j,Promise.resolve([])),us(this,P,new uQ),us(this,N,0),us(this,U),us(this,D),this.options=un({subscribe:!0},e),function(e){if(!e.url)throw new uh;if(e.signal&&!(e.signal instanceof AbortSignal))throw new um;if(void 0!==e.offset&&"-1"!==e.offset&&"now"!==e.offset&&!e.handle)throw new ug;u9(e.params)}(this.options),uo(this,y,null!=(t=this.options.offset)?t:"-1"),uo(this,b,""),uo(this,w,this.options.handle),uo(this,h,new uw(e.parser,e.transformer)),uo(this,k,this.options.onError),uo(this,I,null!=(r=this.options.log)?r:"full");const a=function(e,t=uH){let{initialDelay:r,maxDelay:n,multiplier:i,debug:a=!1,onFailedAttempt:s}=t;return(...t)=>ud(this,null,function*(){var o;let l=t[0],u=t[1],d=r,c=0;for(;;)try{let r=yield e(...t);if(r.ok)return r;throw yield uc.fromResponse(r,l.toString())}catch(e){if(null==s||s(),null==(o=null==u?void 0:u.signal)?void 0:o.aborted)throw new up;if(e instanceof uc&&!uq.includes(e.status)&&e.status>=400&&e.status<500)throw e;yield new Promise(e=>setTimeout(e,d)),d=Math.min(d*i,n),a&&(c++,console.log(`Retry attempt #${c} after ${d}ms`))}})}(null!=(n=e.fetchClient)?n:(...e)=>fetch(...e),((e,t)=>l3(e,l6(t)))(un({},null!=(i=e.backoffOptions)?i:uH),{onFailedAttempt:()=>{var t,r;uo(this,T,!1),null==(r=null==(t=e.backoffOptions)?void 0:t.onFailedAttempt)||r.call(t)}}));uo(this,p,function(e){return(...t)=>ud(this,null,function*(){let r=yield e(...t);if(r.ok){let e=r.headers,n=[],i=t=>n.push(...t.filter(t=>!e.has(t))),a=t[0].toString(),s=new URL(a);if([uD,uZ,u$,uL,uM].some(e=>s.searchParams.has(e)))return r;if(i(uW),"true"===s.searchParams.get(uj)&&i(uF),s.searchParams.has(uj)&&"false"!==s.searchParams.get(uj)||i(uV),n.length>0)throw new ub(a,n)}return r})}(function(e,t=uB){let r,{maxChunksToPrefetch:n}=t;return(...t)=>ud(this,null,function*(){let i=t[0].toString(),a=null==r?void 0:r.consume(...t);if(a)return a;null==r||r.abort();let s=yield e(...t),o=uY(i,s);return o&&(r=new uz({fetchClient:e,maxPrefetchedRequests:n,url:o,requestInit:t[1]})),s})}(a))),uo(this,c,function(e){return(...t)=>ud(this,null,function*(){let r=t[0],n=yield e(...t);try{if(n.status<200||uK.includes(n.status))return n;let e=yield n.text();return new Response(e,n)}catch(e){throw new uc(n.status,void 0,void 0,Object.fromEntries([...n.headers.entries()]),r.toString(),e instanceof Error?e.message:"string"==typeof e?e:"failed to read body")}})}(ua(this,p))),ul(this,$,Q).call(this)}get shapeHandle(){return ua(this,w)}get error(){return ua(this,d)}get isUpToDate(){return ua(this,_)}get lastOffset(){return ua(this,y)}get mode(){return ua(this,I)}subscribe(e,t=()=>{}){let r=Math.random();return ua(this,m).set(r,[e,t]),ua(this,g)||ul(this,$,L).call(this),()=>{ua(this,m).delete(r)}}unsubscribeAll(){ua(this,m).clear()}lastSyncedAt(){return ua(this,v)}lastSynced(){return void 0===ua(this,v)?1/0:Date.now()-ua(this,v)}isConnected(){return ua(this,T)}isLoading(){return!ua(this,_)}hasStarted(){return ua(this,g)}isPaused(){return"paused"===ua(this,f)}forceDisconnectAndRefresh(){return ud(this,null,function*(){var e,t;uo(this,A,!0),!ua(this,_)||(null==(e=ua(this,R))?void 0:e.signal.aborted)||null==(t=ua(this,R))||t.abort(uN),yield ul(this,$,z).call(this),uo(this,A,!1)})}requestSnapshot(e){return ud(this,null,function*(){if("full"===ua(this,I))throw Error(`Snapshot requests are not supported in ${ua(this,I)} mode, as the consumer is guaranteed to observe all data`);ua(this,g)||(yield ul(this,$,L).call(this)),yield ul(this,$,Y).call(this),uu(this,N)._++;try{1===ua(this,N)&&ul(this,$,F).call(this);let{fetchUrl:t,requestHeaders:r}=yield ul(this,$,Z).call(this,this.options.url,!0,e),{metadata:n,data:i}=yield ul(this,$,et).call(this,t,r),a=i.concat([{headers:un({control:"snapshot-end"},n)}]);
6return ua(this,P).addSnapshot(n,new Set(i.map(e=>e.key))),ul(this,$,H).call(this,a,!1),{metadata:n,data:i}}finally{uu(this,N)._--,0===ua(this,N)&&ul(this,$,V).call(this)}})}};function u9(e){if(!e)return;let t=Object.keys(e).filter(e=>u0.has(e));if(t.length>0)throw new uf(t)}function u5(e,t,r){if(void 0!==r&&null!=r)if("string"==typeof r)e.searchParams.set(t,r);else if("object"==typeof r)for(let[n,i]of Object.entries(r))e.searchParams.set(`${t}[${n}]`,i);else e.searchParams.set(t,r.toString())}d=new WeakMap,c=new WeakMap,p=new WeakMap,h=new WeakMap,m=new WeakMap,g=new WeakMap,f=new WeakMap,y=new WeakMap,b=new WeakMap,v=new WeakMap,_=new WeakMap,E=new WeakMap,T=new WeakMap,w=new WeakMap,I=new WeakMap,S=new WeakMap,k=new WeakMap,R=new WeakMap,A=new WeakMap,x=new WeakMap,C=new WeakMap,O=new WeakMap,j=new WeakMap,P=new WeakMap,N=new WeakMap,U=new WeakMap,D=new WeakMap,$=new WeakSet,L=function(){return ud(this,null,function*(){var e;uo(this,g,!0);try{yield ul(this,$,M).call(this)}catch(e){if(uo(this,d,e),ua(this,k)){let t=yield ua(this,k).call(this,e);"object"==typeof t&&(ul(this,$,ee).call(this),"params"in t&&(this.options.params=t.params),"headers"in t&&(this.options.headers=t.headers),uo(this,g,!1),ul(this,$,L).call(this));return}throw e}finally{uo(this,T,!1),null==(e=ua(this,O))||e.call(this)}})},M=function(){return ud(this,null,function*(){var e,t;if("pause-requested"===ua(this,f))return void uo(this,f,"paused");if(!this.options.subscribe&&((null==(e=this.options.signal)?void 0:e.aborted)||ua(this,_)))return;let r="paused"===ua(this,f);uo(this,f,"active");let{url:n,signal:i}=this.options,{fetchUrl:a,requestHeaders:s}=yield ul(this,$,Z).call(this,n,r),o=yield ul(this,$,G).call(this,i),l=ua(this,R);try{yield ul(this,$,K).call(this,{fetchUrl:a,requestAbortController:l,headers:s,resumingFromPause:r})}catch(e){if((e instanceof uc||e instanceof up)&&l.signal.aborted&&l.signal.reason===uN)return ul(this,$,M).call(this);if(e instanceof up){l.signal.aborted&&l.signal.reason===uU&&uo(this,f,"paused");return}if(!(e instanceof uc))throw e;if(409==e.status){if(ua(this,w)){let e=u2(a);uX.markExpired(e,ua(this,w))}let t=e.headers[uR]||`${ua(this,w)}-next`;return ul(this,$,ee).call(this,t),yield ul(this,$,J).call(this,e.json),ul(this,$,M).call(this)}throw ul(this,$,X).call(this,e),e}finally{o&&i&&i.removeEventListener("abort",o),uo(this,R,void 0)}return null==(t=ua(this,C))||t.call(this),ul(this,$,M).call(this)})},Z=function(e,t,r){return ud(this,null,function*(){let[n,i]=yield Promise.all([function(e){return ud(this,null,function*(){if(!e)return{};let t=Object.entries(e);return Object.fromEntries((yield Promise.all(t.map(e=>ud(this,[e],function*([e,t]){return[e,(yield u1(t))]})))))})}(this.options.headers),this.options.params?function(e){return ud(this,null,function*(){let t=Object.entries(e);return Object.fromEntries((yield Promise.all(t.map(e=>ud(this,[e],function*([e,t]){if(void 0===t)return[e,void 0];let r=yield u1(t);return[e,Array.isArray(r)?r.join(","):r]})))).filter(([e,t])=>void 0!==t))})}(function(e){if(Array.isArray(e.params))return l3(un({},e),l6({params:Object.fromEntries(e.params.map((e,t)=>[t+1,e]))}));return e}(this.options.params)):void 0]);i&&u9(i);let a=new URL(e);if(i){i.table&&u5(a,"table",i.table),i.where&&u5(a,"where",i.where),i.columns&&u5(a,"columns",i.columns),i.replica&&u5(a,"replica",i.replica),i.params&&u5(a,"params",i.params);let e=un({},i);for(let[t,r]of(delete e.table,delete e.where,delete e.columns,delete e.replica,delete e.params,Object.entries(e)))u5(a,t,r)}r&&(r.where&&u5(a,uD,r.where),r.params&&u5(a,uZ,r.params),r.limit&&u5(a,u$,r.limit),r.offset&&u5(a,uL,r.offset),r.orderBy&&u5(a,uM,r.orderBy)),a.searchParams.set(uP,ua(this,y)),a.searchParams.set("log",ua(this,I)),ua(this,_)&&(ua(this,A)||t||a.searchParams.set(uj,"true"),a.searchParams.set(ux,ua(this,b))),ua(this,w)&&a.searchParams.set(uO,ua(this,w));let s=u2(a),o=uX.getExpiredHandle(s);return o&&a.searchParams.set(uC,o),a.searchParams.sort(),{fetchUrl:a,requestHeaders:n}})},G=function(e){return ud(this,null,function*(){var t;if(uo(this,R,new AbortController),e){let r=()=>{var t;null==(t=ua(this,R))||t.abort(e.reason)};return e.addEventListener("abort",r,{once:!0}),e.aborted&&(null==(t=ua(this,R))||t.abort(e.reason)),r}})},q=function(e){return ud(this,null,function*(){var t;let r,{headers:n,status:i}=e,a=n.get(uR);a&&uo(this,w,a);let s=n.get(uA);s&&uo(this,y,s);let o=n.get("electric-cursor");o&&uo(this,b,o),uo(this,S,null!=(t=ua(this,S))?t:(r=n.get("electric-schema"))?JSON.parse(r):{}),204===i&&uo(this,v,Date.now())})},H=function(e,t=!1){return ud(this,null,function*(){var r;if(e.length>0){uo(this,E,!0);let n=e[e.length-1];if(uk(n)){if(t){let e=function(e){let t=e.headers.global_last_seen_lsn;if(t)return`${t}_0`}(n);e&&uo(this,y,e)}uo(this,v,Date.now()),uo(this,_,!0),uo(this,E,!1),null==(r=ua(this,D))||r.call(this)}let i=e.filter(e=>!uS(e)||!ua(this,P).shouldRejectMessage(e));yield ul(this,$,J).call(this,i)}})},K=function(e){return ud(this,null,function*(){return ua(this,_)&&this.options.experimentalLiveSse&&!ua(this,A)&&!e.resumingFromPause?(e.fetchUrl.searchParams.set("experimental_live_sse","true"),ul(this,$,W).call(this,e)):ul(this,$,B).call(this,e)})},B=function(e){return ud(this,null,function*(){let{fetchUrl:t,requestAbortController:r,headers:n}=e,i=yield ua(this,c).call(this,t.toString(),{signal:r.signal,headers:n});uo(this,T,!0),yield ul(this,$,q).call(this,i);let a=ua(this,S),s=yield i.text(),o=ua(this,h).parse(s||"[]",a);
6yield ul(this,$,H).call(this,o)})},W=function(e){return ud(this,null,function*(){let{fetchUrl:t,requestAbortController:r,headers:n}=e,i=ua(this,p);try{let e=[];yield function(e,t){var{signal:r,headers:n,onopen:i,onmessage:a,onclose:s,onerror:o,openWhenHidden:l,fetch:u}=t,d=l1(t,["signal","headers","onopen","onmessage","onclose","onerror","openWhenHidden","fetch"]);return new Promise((t,c)=>{let p,h=Object.assign({},n);function m(){p.abort(),document.hidden||_()}h.accept||(h.accept=l2),l||document.addEventListener("visibilitychange",m);let g=1e3,f=0;function y(){document.removeEventListener("visibilitychange",m),window.clearTimeout(f),p.abort()}null==r||r.addEventListener("abort",()=>{y(),t()});let b=null!=u?u:window.fetch,v=null!=i?i:l9;async function _(){var r,n,i,l;p=new AbortController;try{let r,o,u,c,m,f,_=await b(e,Object.assign(Object.assign({},d),{headers:h,signal:p.signal}));await v(_),await lQ(_.body,(n=e=>{e?h[l4]=e:delete h[l4]},i=e=>{g=e},r=l0(),o=new TextDecoder,l=function(e,t){if(0===e.length)null==a||a(r),r=l0();else if(t>0){let a=o.decode(e.subarray(0,t)),s=t+(32===e[t+1]?2:1),l=o.decode(e.subarray(s));switch(a){case"data":r.data=r.data?r.data+"\n"+l:l;break;case"event":r.event=l;break;case"id":n(r.id=l);break;case"retry":let u=parseInt(l,10);isNaN(u)||i(r.retry=u)}}},f=!1,function(e){var t,r;let n;void 0===u?(u=e,c=0,m=-1):(t=u,r=e,(n=new Uint8Array(t.length+r.length)).set(t),n.set(r,t.length),u=n);let i=u.length,a=0;for(;c<i;){f&&(10===u[c]&&(a=++c),f=!1);let e=-1;for(;c<i&&-1===e;++c)switch(u[c]){case 58:-1===m&&(m=c-a);break;case 13:f=!0;case 10:e=c}if(-1===e)break;l(u.subarray(a,e),m),a=c,m=-1}a===i?u=void 0:0!==a&&(u=u.subarray(a),c-=a)})),null==s||s(),y(),t()}catch(e){if(!p.signal.aborted)try{let t=null!=(r=null==o?void 0:o(e))?r:g;window.clearTimeout(f),f=window.setTimeout(_,t)}catch(e){y(),c(e)}}}_()})}(t.toString(),{headers:n,fetch:i,onopen:e=>ud(this,null,function*(){uo(this,T,!0),yield ul(this,$,q).call(this,e)}),onmessage:t=>{if(t.data){let r=ua(this,S),n=ua(this,h).parse(t.data,r);e.push(n),uk(n)&&(ul(this,$,H).call(this,e,!0),e=[])}},onerror:e=>{throw e},signal:r.signal})}catch(e){if(r.signal.aborted)throw new up;throw e}})},F=function(){var e;ua(this,g)&&"active"===ua(this,f)&&(uo(this,f,"pause-requested"),null==(e=ua(this,R))||e.abort(uU))},V=function(){ua(this,g)&&"paused"===ua(this,f)&&ul(this,$,L).call(this)},z=function(){return ud(this,null,function*(){return ua(this,x)||(uo(this,x,new Promise((e,t)=>{uo(this,C,e),uo(this,O,t)})),ua(this,x).finally(()=>{uo(this,x,void 0),uo(this,C,void 0),uo(this,O,void 0)})),ua(this,x)})},Y=function(){return ud(this,null,function*(){if(ua(this,E))return ua(this,U)||(uo(this,U,new Promise(e=>{uo(this,D,e)})),ua(this,U).finally(()=>{uo(this,U,void 0),uo(this,D,void 0)})),ua(this,U)})},J=function(e){return ud(this,null,function*(){return uo(this,j,ua(this,j).then(()=>Promise.all(Array.from(ua(this,m).values()).map(t=>ud(this,[t],function*([t,r]){try{yield t(e)}catch(e){queueMicrotask(()=>{throw e})}}))))),ua(this,j)})},X=function(e){ua(this,m).forEach(([t,r])=>{null==r||r(e)})},Q=function(){if("object"==typeof document&&"boolean"==typeof document.hidden&&"function"==typeof document.addEventListener){let e=()=>{document.hidden?ul(this,$,F).call(this):ul(this,$,V).call(this)};document.addEventListener("visibilitychange",e)}},ee=function(e){uo(this,y,"-1"),uo(this,b,""),uo(this,w,e),uo(this,_,!1),uo(this,E,!0),uo(this,T,!1),uo(this,S,void 0),uo(this,N,0)},et=function(e,t){return ud(this,null,function*(){let r=yield ua(this,c).call(this,e.toString(),{headers:t});if(!r.ok)throw new uc(r.status,void 0,void 0,Object.fromEntries([...r.headers.entries()]),e.toString());let{metadata:n,data:i}=yield r.json();return{metadata:n,data:ua(this,h).parse(JSON.stringify(i),ua(this,S))}})},u4.Replica={FULL:"full",DEFAULT:"default"},new WeakMap,er=new WeakMap,new WeakMap,en=new WeakMap,new WeakMap,ei=new WeakMap,new WeakMap,ea=new WeakSet,es=function(){return ud(this,null,function*(){this.stream.isUpToDate||(yield new Promise(e=>{let t=()=>{this.stream.isUpToDate&&(clearInterval(r),n(),e())},r=setInterval(t,10),n=this.stream.subscribe(()=>t(),()=>t());t()}))})};let u3="2025-07-16",u6="x-trigger-api-version";class u8{#a;#s=new Map;#o;#l=!1;#u;#d=!1;stop(){this.#d=!0,this.#u?.()}constructor(e){this.#a=e;const t=new ReadableStream({start:e=>{this.#u=this.#a.subscribe(t=>{this.#d||e.enqueue(t)},this.#c.bind(this))},cancel:()=>{this.#d=!0,this.#u?.()}});let r=new Set;this.#o=function(e,t){let r=e.pipeThrough(new TransformStream(t));return r[Symbol.asyncIterator]=()=>{let e=r.getReader();return{async next(){let{done:t,value:r}=await e.read();return t?{done:!0,value:void 0}:{done:!1,value:r}}}},r}(t,{transform:(e,t)=>
6{if(!this.#d)try{let n=!1;for(let t of e)if(uS(t)){let e=t.key;switch(t.headers.operation){case"insert":this.#s.set(e,t.value),r.add(e);break;case"update":{let n=this.#s.get(e),i=n?{...n,...t.value}:t.value;this.#s.set(e,i),r.add(e)}}}else uS(t)||("must-refetch"===t.headers.control?(this.#s.clear(),this.#l=!1):"up-to-date"===t.headers.control&&(n=!0));if(!this.#d&&n){for(let e of r){let r=this.#s.get(e);r&&t.enqueue(r)}r.clear()}}catch(e){console.error("Error processing stream messages:",e),this.#c(e)}}})}get stream(){return this.#o}get isUpToDate(){return this.#a.isUpToDate}get lastOffset(){return this.#a.lastOffset}get handle(){return this.#a.shapeHandle}get error(){return this.#l}lastSyncedAt(){return this.#a.lastSyncedAt()}lastSynced(){return this.#a.lastSynced()}isLoading(){return this.#a.isLoading()}isConnected(){return this.#a.isConnected()}#c(e){e instanceof uc&&(this.#l=e),this.#d=!0,this.#u?.()}}function u7(e,t){var r;let n,i=new AbortController,a=new dt(sk("TRIGGER_STREAM_URL",sk("TRIGGER_API_URL"))??"https://api.trigger.dev",{headers:t?.headers,resolveHeaders:t?.resolveHeaders,signal:i.signal});t?.signal?.addEventListener("abort",()=>{i.signal.aborted||i.abort()},{once:!0});let s=(r={...t,signal:i.signal,onError:e=>{t?.onFetchError?.(e)}},n=new AbortController,r?.signal?.addEventListener("abort",()=>{n.abort()},{once:!0}),{stream:new u8(new u4({url:e,headers:{...r?.headers,"x-trigger-electric-version":"1.0.0-beta.1",[u6]:u3},fetchClient:r?.fetchClient,signal:n.signal,onError:e=>{r?.onError?.(e)}})).stream.pipeThrough(new TransformStream({async transform(e,t){let r=ae.safeParse(e);r.success?t.enqueue(r.data):t.error(Error(`Unable to parse shape: ${r.error.message}`))}})),stop:e=>{e?setTimeout(()=>{n.signal.aborted||n.abort()},e):n.abort()}});return new dr({runShapeStream:s.stream,stopRunShapeStream:()=>s.stop(3e4),streamFactory:a,abortController:i,...t})}class de{url;options;lastEventId;from;retryCount=0;maxRetries;retryDelayMs;maxRetryDelayMs;retryJitter;fetchTimeoutMs;stallTimeoutMs;nonRetryableStatuses;retryNowController=null;internalAbort=null;cancelledByConsumer=!1;completeNotified=!1;currentHeaders;authRefreshed=!1;retryAfterAuthRefresh=!1;sessionSettled=!1;constructor(e,t){this.url=e,this.options=t,this.currentHeaders=t.headers,this.lastEventId=t.lastEventId,this.from=t.from??"beginning",this.maxRetries=t.maxRetries??1/0,this.retryDelayMs=t.retryDelayMs??100,this.maxRetryDelayMs=t.maxRetryDelayMs??5e3,this.retryJitter=t.retryJitter??.5,this.fetchTimeoutMs=t.fetchTimeoutMs??3e4,this.stallTimeoutMs=t.stallTimeoutMs??0,this.nonRetryableStatuses=new Set(t.nonRetryableStatuses??[400,404,409,410,422])}retryNow(){this.retryNowController?.abort()}forceReconnect(){this.internalAbort?.abort(),this.retryNowController?.abort()}notifyComplete(){this.completeNotified||(this.completeNotified=!0,this.options.onComplete?.())}async subscribe(){let e=this,t=new ReadableStream({async start(t){await e.connectStream(t)},cancel(){e.cancelledByConsumer=!0,e.internalAbort?.abort(),e.retryNowController?.abort()}}).getReader();return new ReadableStream({async pull(r){let n;try{n=await t.read()}catch(e){r.error(e);return}if(n.done){e.notifyComplete();try{r.close()}catch{}return}r.enqueue(n.value.part)},cancel(r){e.cancelledByConsumer=!0,e.notifyComplete(),t.cancel(r).catch(()=>{})}},{highWaterMark:0})}async connectStream(e){let t;this.internalAbort=new AbortController;let r=function(e,t){if(!e)return()=>{};if(e.aborted)return t.abort(),()=>{};let r=()=>t.abort();return e.addEventListener("abort",r,{once:!0}),()=>e.removeEventListener("abort",r)}(this.options.signal,this.internalAbort),n=setTimeout(()=>this.internalAbort?.abort(),this.fetchTimeoutMs),i=()=>{this.stallTimeoutMs<=0||(clearTimeout(t),t=setTimeout(()=>this.internalAbort?.abort(),this.stallTimeoutMs))},a=()=>{clearTimeout(n),clearTimeout(t),r(),this.internalAbort=null};try{let t={Accept:"text/event-stream",...this.currentHeaders};this.lastEventId?t["Last-Event-ID"]=this.lastEventId:"latest"===this.from&&(t["X-Trigger-Stream-Start"]="latest"),this.options.timeoutInSeconds&&(t["Timeout-Seconds"]=this.options.timeoutInSeconds.toString());let r=this.options.fetchClient??fetch,a=await r(this.url,{headers:t,signal:this.internalAbort.signal});if(clearTimeout(n),!a.ok){let t=sj.generate(a.status,{},"Could not subscribe to stream",Object.fromEntries(a.headers));if(this.nonRetryableStatuses.has(a.status)){this.options.onError?.(t),e.error(t);return}throw await this.refreshHeadersForAuthError(a.status)||this.options.onError?.(t),t}if(!a.body){let e=Error("No response body");throw this.options.onError?.(e),e}let s=a.headers.get("X-Stream-Version")??"v1";this.sessionSettled="true"===a.headers.get("X-Session-Settled"),this.retryCount=0,i();let o=new Set,l=e=>{if(o.add(e),o.size>5e3){let e=o.values().next().value;void 0!==e&&o.delete(e)}},u=a.body.pipeThrough(new TextDecoderStream).pipeThrough(new o5.EventSourceParserStream).pipeThrough(new TransformStream({transform:(e,t)=>
6{if("v1"===s){e.id&&(this.lastEventId=e.id);let r=function(e){if(!e)return Date.now();let t=parseInt(e.split("-")[0],10);return isNaN(t)?Date.now():t}(e.id);t.enqueue({type:"part",part:{id:e.id??"unknown",chunk:du(e.data),timestamp:r}})}else if("batch"===e.event){let r=du(e.data);if(!r||!Array.isArray(r.records))return;for(let e of r.records){if(this.lastEventId=e.seq_num.toString(),e.headers?.[0]?.[0]==="")continue;let r=du(e.body);if(r?.id){if(o.has(r.id))continue;l(r.id)}t.enqueue({type:"part",part:{recordId:r?.id,id:e.seq_num.toString(),chunk:r?.data,timestamp:e.timestamp,headers:e.headers??[]}})}}}})).getReader();try{for(;;){let{done:t,value:r}=await u.read();if(t){u.releaseLock(),this.notifyComplete(),e.close();return}if(this.options.signal?.aborted){u.cancel(),u.releaseLock(),this.notifyComplete(),e.close();return}i(),this.authRefreshed=!1,e.enqueue(r)}}catch(e){throw u.releaseLock(),e}}catch(t){if(this.options.signal?.aborted||this.cancelledByConsumer){this.notifyComplete(),e.close();return}if(null!==t&&"object"==typeof t&&"TriggerApiError"===t.name&&(401===t.status||403===t.status))if(!this.retryAfterAuthRefresh)return void e.error(t);else this.retryAfterAuthRefresh=!1;a(),await this.retryConnection(e,t)}finally{a()}}async refreshHeadersForAuthError(e){if(401!==e&&403!==e||!this.options.resolveHeaders||this.authRefreshed)return!1;this.authRefreshed=!0;try{this.currentHeaders=await this.options.resolveHeaders()}catch{return!1}return this.retryAfterAuthRefresh=!0,!0}async retryConnection(e,t){if(this.options.signal?.aborted||this.cancelledByConsumer){this.notifyComplete(),e.close();return}if(this.retryCount>=this.maxRetries){let r=t||Error("Max retries reached");e.error(r),this.options.onError?.(r);return}this.retryCount++;let r=Math.min(this.retryDelayMs*Math.pow(2,this.retryCount-1),this.maxRetryDelayMs)*(1-this.retryJitter*Math.random());(this.retryNowController=new AbortController,await new Promise(e=>{let t=setTimeout(()=>{this.retryNowController?.signal.removeEventListener("abort",n),e()},r),n=()=>{clearTimeout(t),e()};this.retryNowController.signal.addEventListener("abort",n,{once:!0})}),this.retryNowController=null,this.options.signal?.aborted||this.cancelledByConsumer)?e.close():await this.connectStream(e)}}class dt{baseUrl;options;constructor(e,t){this.baseUrl=e,this.options=t}createSubscription(e,t,r){if(!e||!t)throw Error("runId and streamKey are required");return new de(`${r?.baseUrl??this.baseUrl}/realtime/v1/streams/${e}/${t}`,{...this.options,...r})}}class dr{options;stream;packetCache=new Map;_closeOnComplete;_isRunComplete=!1;constructor(e){this.options=e,this._closeOnComplete=void 0===e.closeOnComplete||e.closeOnComplete,this.stream=li(this.options.runShapeStream,{transform:async(e,t)=>{let r=await this.transformRunShape(e);t.enqueue(r),this._isRunComplete=!!r.finishedAt,this._closeOnComplete&&this._isRunComplete&&!this.options.abortController.signal.aborted&&this.options.stopRunShapeStream()}},this.options.abortController.signal)}unsubscribe(){this.options.abortController.signal.aborted||this.options.abortController.abort(),this.options.stopRunShapeStream()}[Symbol.asyncIterator](){return this.stream[Symbol.asyncIterator]()}getReader(){return this.stream.getReader()}withStreams(){let e=new Set;return li(this.stream,{transform:async(t,r)=>{var n;let i;r.enqueue({type:"run",run:t});let a=(i=(n=t).metadata&&"$$streams"in n.metadata&&Array.isArray(n.metadata.$$streams)&&n.metadata.$$streams.length>0&&n.metadata.$$streams.every(e=>"string"==typeof e)?n.metadata.$$streams:void 0)||n.realtimeStreams;if(a.length>0)for(let n of a)"string"==typeof n&&(e.has(n)||(e.add(n),this.options.streamFactory.createSubscription(t.id,n,{baseUrl:this.options.client?.baseUrl}).subscribe().then(e=>{e.pipeThrough(new TransformStream({transform(e,r){r.enqueue({type:n,chunk:e.chunk,run:t})}})).pipeTo(new WritableStream({write(e){r.enqueue(e)}}))})))}},this.options.abortController.signal)}async transformRunShape(e){var t;let r=e.payloadType?{data:e.payload??void 0,dataType:e.payloadType}:void 0,n=e.outputType?{data:e.output??void 0,dataType:e.outputType}:void 0,[i,a]=await Promise.all([{packet:r,key:"payload"},{packet:n,key:"output"}].map(async({packet:t,key:r})=>{if(!t)return;let n=this.packetCache.get(`${e.friendlyId}/${r}`);if(void 0!==n)return n;let i=await lz(t,this.options.client);return this.packetCache.set(`${e.friendlyId}/${r}`,i),i})),s=e.metadata&&e.metadataType?await lV({data:e.metadata,dataType:e.metadataType}):void 0,o=function(e){switch(e){case"DELAYED":return"DELAYED";case"WAITING_FOR_DEPLOY":case"PENDING_VERSION":return"PENDING_VERSION";case"PENDING":default:return"QUEUED";case"PAUSED":case"WAITING_TO_RESUME":return"WAITING";case"DEQUEUED":return"DEQUEUED";case"RETRYING_AFTER_FAILURE":case"EXECUTING":return"EXECUTING";case"CANCELED":return"CANCELED";case"COMPLETED_SUCCESSFULLY":return"COMPLETED";case"SYSTEM_FAILURE":return"SYSTEM_FAILURE";case"CRASHED":return"CRASHED";case"INTERRUPTED":case"COMPLETED_WITH_ERRORS":return"FAILED";case"EXPIRED":return"EXPIRED";case"TIMED_OUT":return"TIMED_OUT"}}(e.status);return{id:e.friendlyId,createdAt:e.createdAt,updatedAt:e.updatedAt,taskIdentifier:e.taskIdentifier,status:o,payload:i,output:a,durationMs:e.usageDurationMs??0,costInCents:e.costInCents??0,baseCostInCents:e.baseCostInCents??0,tags:e.runTags??[],idempotencyKey:e.idempotencyKey??void 0,expiredAt:e.expiredAt??void 0,finishedAt:e.completedAt??void 0,startedAt:e.startedAt??void 0,delayedUntil:e.delayUntil??void 0,queuedAt:e.queuedAt??void 0,error:e.error?function(e){let t=function(e){switch(e.type){case"BUILT_IN_ERROR":if("UnexpectedExitError"===e.name&&e.message.startsWith("Unexpected exit with code -1"))switch(ln(e.stackTrace)){case"SIGTERM":return{...lr("TASK_PROCESS_SIGTERM")};case"SIGSEGV":return{...lr("TASK_PROCESS_SIGSEGV")};case"SIGKILL":case"SIGABRT":return{...lr("TASK_PROCESS_MAYBE_OOM_KILLED")};default:return{...lr("TASK_PROCESS_EXITED_WITH_NON_ZERO_CODE"),message:e.message,stackTrace:e.stackTrace}}if("Error"===e.name&&"ffmpeg was killed with signal SIGKILL"===e.message||"BUILT_IN_ERROR"===e.type&&e.message&&"MANUAL_OOM_KILL_E
6RROR"===e.message)return{...lr("TASK_PROCESS_OOM_KILLED")};if("TriggerApiError"===e.name&&e.message.startsWith("Deadlock detected:"))return{type:"BUILT_IN_ERROR",name:"Concurrency Deadlock Error",message:e.message,stackTrace:"",link:{name:"Read the docs",href:o7.deadlock}};break;case"STRING_ERROR":case"CUSTOM_ERROR":break;case"INTERNAL_ERROR":if(e.code===rN.TASK_PROCESS_EXITED_WITH_NON_ZERO_CODE)switch(ln(e.message)){case"SIGTERM":return{...lr("TASK_PROCESS_SIGTERM")};case"SIGSEGV":return{...lr("TASK_PROCESS_SIGSEGV")};case"SIGKILL":case"SIGABRT":return{...lr("TASK_PROCESS_MAYBE_OOM_KILLED")};default:return{...lr("TASK_PROCESS_EXITED_WITH_NON_ZERO_CODE"),message:e.message,stackTrace:e.stackTrace}}return{...e,...lr(e.code)}}return e}(e);switch(t.type){case"BUILT_IN_ERROR":return{name:t.name,message:t.message,stackTrace:t.stackTrace};case"STRING_ERROR":case"CUSTOM_ERROR":return{message:t.raw};case"INTERNAL_ERROR":return{message:`trigger.dev internal error (${t.code})`}}}(e.error):void 0,isTest:e.isTest??!1,metadata:s,realtimeStreams:e.realtimeStreams??[],...{isQueued:dn.includes(t=o),isWaiting:di.includes(t),isExecuting:da.includes(t),isCompleted:dl.includes(t)||ds.includes(t),isFailed:ds.includes(t),isSuccess:dl.includes(t),isCancelled:"CANCELED"===t}}}}let dn=["PENDING_VERSION","QUEUED","PENDING","DELAYED"],di=["WAITING"],da=["DEQUEUED","EXECUTING"],ds=["FAILED","CRASHED","SYSTEM_FAILURE","EXPIRED","TIMED_OUT"],dl=["COMPLETED"];function du(e){try{return JSON.parse(e)}catch(t){return e}}"u">typeof window&&"u">typeof navigator&&"string"==typeof navigator.userAgent&&(/^((?!chrome|android).)*safari/i.test(navigator.userAgent)||/iPad|iPhone|iPod/.test(navigator.userAgent))&&(ReadableStream.prototype.values??=function({preventCancel:e=!1}={}){let t=this.getReader();return{async next(){try{let e=await t.read();return e.done&&t.releaseLock(),{done:e.done,value:e.value}}catch(e){throw t.releaseLock(),e}},async return(r){if(e)t.releaseLock();else{let e=t.cancel(r);t.releaseLock(),await e}return{done:!0,value:r}},[Symbol.asyncIterator](){return this}}},ReadableStream.prototype[Symbol.asyncIterator]??=ReadableStream.prototype.values);let dd={retry:{maxAttempts:5,minTimeoutInMs:1e3,maxTimeoutInMs:3e4,factor:1.6,randomize:!1}},dc=ro.object({token:ro.string()});class dp{baseUrl;accessToken;previewBranch;futureFlags;additionalHeaders;defaultRequestOptions;refreshAccessToken;constructor(e,t,r,n={},i={},a){this.accessToken=t,this.refreshAccessToken=a,this.baseUrl=e.replace(/\/$/,""),this.previewBranch=r;const{additionalHeaders:s,...o}=n;this.additionalHeaders=s,this.defaultRequestOptions=dv(dd,o),this.futureFlags=i}get #p(){var e;if(e=this.accessToken,ru.test(e))throw Error("This additional API key cannot self-sign public tokens, and the server did not return one. Upgrade the server or use the root API key.");return this.accessToken}get fetchClient(){let e=this.#h(!1);return(t,r)=>fetch(t,{...r,headers:{...r?.headers,...e}})}getHeaders(){return this.#h(!1)}#m(){let e=this.refreshAccessToken;if(e)return async()=>{let t=await o9(e);return this.#h(!1,{Authorization:`Bearer ${t}`})}}#g(){let e=this.refreshAccessToken;if(e)return async()=>{let t=await o9(e);return{...this.#f(),Authorization:`Bearer ${t}`}}}async getRunResult(e,t){try{return await oB(r4,`${this.baseUrl}/api/v1/runs/${e}/result`,{method:"GET",headers:this.#h(!1)},dv(this.defaultRequestOptions,t))}catch(e){if(e instanceof sj&&404===e.status)return;throw e}}async getBatchResults(e,t){return await oB(r9,`${this.baseUrl}/api/v1/batches/${e}/results`,{method:"GET",headers:this.#h(!1)},dv(this.defaultRequestOptions,t))}triggerTask(e,t,r,n){let i=encodeURIComponent(e);return oB(ig,`${this.baseUrl}/api/v1/tasks/${i}/trigger`,{method:"POST",headers:this.#h(r?.spanParentAsLink??!1),body:JSON.stringify(t)},dv(this.defaultRequestOptions,n)).withResponse().then(async({data:e,response:t})=>{let r=t.headers.get("x-trigger-jwt");if("string"==typeof r)return{...e,publicAccessToken:r};let i=t.headers.get("x-trigger-jwt-claims"),a=i?JSON.parse(i):void 0,s=await rd({secretKey:this.#p,payload:{...a,scopes:[`read:runs:${e.id}`]},expirationTime:n?.publicAccessToken?.expirationTime??"1h"});return{...e,publicAccessToken:s}})}batchTriggerV3(e,t,r){return oB(ib,`${this.baseUrl}/api/v2/tasks/batch`,{method:"POST",headers:this.#h(t?.spanParentAsLink??!1,{"batch-processing-strategy":t?.processingStrategy}),body:JSON.stringify(e)},dv(this.defaultRequestOptions,r)).withResponse().then(async({data:e,response:t})=>{let n=t.headers.get("x-trigger-jwt");if("string"==typeof n)return{...e,publicAccessToken:n};let i=t.headers.get("x-trigger-jwt-claims"),a=i?JSON.parse(i):void 0,s=await rd({secretKey:this.#p,payload:{...a,scopes:[`read:batch:${e.id}`]},expirationTime:r?.publicAccessToken?.expirationTime??"1h"});return{...e,publicAccessToken:s}})}createBatch(e,t,r){return oB(iv,`${this.baseUrl}/api/v3/batches`,{method:"POST",headers:this.#h(t?.spanParentAsLink??!1),body:JSON.stringify(e)},dv(this.defaultRequestOptions,r)).withResponse().then(async({data:e,response:t})=>{let n=t.headers.get("x-trigger-jwt");if("string"==typeof n)return{...e,publicAccessToken:n};let i=t.headers.get("x-trigger-jwt-claims"),a=i?JSON.parse(i):void 0,s=await rd({secretKey:this.#p,payload:{...a,scopes:[`read:batch:${e.id}`]},expirationTime:r?.publicAccessToken?.expirationTime??"1h"});return{...e,publicAccessToken:s}})}async streamBatchItems(e,t,r){let n=function(e){let t=new TextEncoder;if(Array.isArray(e)){let r=0;return new ReadableStream({pull(n){if(r>=e.length)return void n.close();let i=JSON.stringify(e[r++])+"\n";n.enqueue(t.encode(i))}})}let r=e[Symbol.asyncIterator]();return new ReadableStream({async pull(e){let{value:n,done:i}=await r.next();if(i)return void e.close();let a=JSON.stringify(n)+"\n";e.enqueue(t.encode(a))}})}(t),i={...dg,...r?.retry};return this.#y(e,n,i)}async #y(e,t,r,n=1){let i=this.#h(!1);i["Content-Type"]="application/x-ndjson";let[a,s]=t.tee();try{let t=await fetch(`${this.baseUrl}/api/v3/batches/${e}/items`,{method:"POST",headers:i,body:a,duplex:"half"});if(!t.ok){let i,o=function(e,t,r){function n(){let e=sA(r,t);return e?{retry:!0,delay:e}:{retry:!1}}let i=e.headers.get("x-should-retry");if("true"===i)return n();if("false"===i)return{retry:!1};if(408===e.status||409===e.status)return n();if(429===e.status){if(t>=r.maxAttempts)return{retry:!1};let i=e.headers.get("x-ratelimit-reset");if(i){let e=parseInt(i,10)-Date.now()+Math.floor(1e3*Math.random());if(e>0)return{retry:!0,delay:e}}let a=e.headers.get("retry-after");if(a){let e=parseInt(a,10);if(!isNaN(e))return{retry:!0,delay:1e3*e}}return n()}return e.status>=500?n():{retry:!1}}(t,n,r);
6if(o.retry)return await db(a),await df(o.delay),this.#y(e,s,r,n+1);await db(s);let l=await t.text().catch(e=>e.message);try{i=JSON.parse(l)}catch{}let u=i?void 0:l,d=Object.fromEntries(t.headers.entries());throw sj.generate(t.status,i,u,d)}let o=await t.json(),l=i_.safeParse(o);if(!l.success)throw await db(s),Error(`Invalid response from server for batch ${e}: ${l.error.message}`);if(!l.data.sealed){let t=sA(r,n);if(t)return await db(a),await df(t),this.#y(e,s,r,n+1);throw await db(s),new sH({batchId:e,enqueuedCount:l.data.enqueuedCount??0,expectedCount:l.data.expectedCount??0,itemsAccepted:l.data.itemsAccepted,itemsDeduplicated:l.data.itemsDeduplicated})}return await db(s),l.data}catch(o){if(o instanceof sH||o instanceof sj)throw o;let t=sA(r,n);if(t)return await db(a),await df(t),this.#y(e,s,r,n+1);await db(s);let i=o instanceof Error?o:Error(String(o));throw new sP({cause:i,message:`Failed to stream batch items for batch ${e}: ${i.message}`})}}createUploadPayloadUrl(e,t){let r=encodeURIComponent(e);return oB(iO,`${this.baseUrl}/api/v2/packets/${r}`,{method:"PUT",headers:this.#h(!1)},dv(this.defaultRequestOptions,t))}getPayloadUrl(e,t){let r=encodeURIComponent(e);return oB(iO,`${this.baseUrl}/api/v1/packets/${r}`,{method:"GET",headers:this.#h(!1)},dv(this.defaultRequestOptions,t))}createChatSnapshotUploadUrl(e,t){return oB(iO,`${this.baseUrl}/api/v1/sessions/${encodeURIComponent(e)}/snapshot-url`,{method:"PUT",headers:this.#h(!1)},dv(this.defaultRequestOptions,t))}getChatSnapshotUrl(e,t){return oB(iO,`${this.baseUrl}/api/v1/sessions/${encodeURIComponent(e)}/snapshot-url`,{method:"GET",headers:this.#h(!1)},dv(this.defaultRequestOptions,t))}retrieveRun(e,t){return oB(iB,`${this.baseUrl}/api/v3/runs/${e}`,{method:"GET",headers:this.#h(!1)},dv(this.defaultRequestOptions,t))}retrieveRunTrace(e,t){return oB(aI,`${this.baseUrl}/api/v1/runs/${e}/trace`,{method:"GET",headers:this.#h(!1)},dv(this.defaultRequestOptions,t))}retrieveSpan(e,t,r){return oB(aS,`${this.baseUrl}/api/v1/runs/${e}/spans/${t}`,{method:"GET",headers:this.#h(!1)},dv(this.defaultRequestOptions,r))}listRuns(e,t){let r=dh(e);return oW(iW,`${this.baseUrl}/api/v1/runs`,{query:r,limit:e?.limit,after:e?.after,before:e?.before},{method:"GET",headers:this.#h(!1)},dv(this.defaultRequestOptions,t))}listProjectRuns(e,t,r){let n=dh(t);return t?.env&&n.append("filter[env]",Array.isArray(t.env)?t.env.join(","):t.env),oW(iW,`${this.baseUrl}/api/v1/projects/${e}/runs`,{query:n,limit:t?.limit,after:t?.after,before:t?.before},{method:"GET",headers:this.#h(!1)},dv(this.defaultRequestOptions,r))}replayRun(e,t){return oB(ij,`${this.baseUrl}/api/v1/runs/${e}/replay`,{method:"POST",headers:this.#h(!1)},dv(this.defaultRequestOptions,t))}cancelRun(e,t){return oB(iP,`${this.baseUrl}/api/v2/runs/${e}/cancel`,{method:"POST",headers:this.#h(!1)},dv(this.defaultRequestOptions,t))}createBulkAction(e,t){return oB(i2,`${this.baseUrl}/api/v1/bulk-actions`,{method:"POST",headers:this.#h(!1),body:JSON.stringify(e)},dv(this.defaultRequestOptions,t))}listBulkActions(e,t){return oW(i1,`${this.baseUrl}/api/v1/bulk-actions`,{query:new URLSearchParams,limit:e?.limit,after:e?.after,before:e?.before},{method:"GET",headers:this.#h(!1)},dv(this.defaultRequestOptions,t))}retrieveBulkAction(e,t){return oB(i1,`${this.baseUrl}/api/v1/bulk-actions/${e}`,{method:"GET",headers:this.#h(!1)},dv(this.defaultRequestOptions,t))}abortBulkAction(e,t){return oB(i4,`${this.baseUrl}/api/v1/bulk-actions/${e}/abort`,{method:"POST",headers:this.#h(!1)},dv(this.defaultRequestOptions,t))}resetIdempotencyKey(e,t,r){return oB(iN,`${this.baseUrl}/api/v1/idempotencyKeys/${encodeURIComponent(t)}/reset`,{method:"POST",headers:this.#h(!1),body:JSON.stringify({taskIdentifier:e})},dv(this.defaultRequestOptions,r))}rescheduleRun(e,t,r){return oB(iB,`${this.baseUrl}/api/v1/runs/${e}/reschedule`,{method:"POST",headers:this.#h(!1),body:JSON.stringify(t)},dv(this.defaultRequestOptions,r))}listRunEvents(e,t){return oB(ro.any(),`${this.baseUrl}/api/v1/runs/${e}/events`,{method:"GET",headers:this.#h(!1)},dv(this.defaultRequestOptions,t))}addTags(e,t,r){return oB(ro.object({message:ro.string()}),`${this.baseUrl}/api/v1/runs/${e}/tags`,{method:"POST",headers:this.#h(!1),body:JSON.stringify(t)},dv(this.defaultRequestOptions,r))}createSchedule(e,t){return oB(i$,`${this.baseUrl}/api/v1/schedules`,{method:"POST",headers:this.#h(!1),body:JSON.stringify(e)},dv(this.defaultRequestOptions,t))}listSchedules(e,t){let r=new URLSearchParams;return e?.page&&r.append("page",e.page.toString()),e?.perPage&&r.append("perPage",e.perPage.toString()),oF(i$,`${this.baseUrl}/api/v1/schedules`,{page:e?.page,limit:e?.perPage},{method:"GET",headers:this.#h(!1)},dv(this.defaultRequestOptions,t))}retrieveSchedule(e,t){return oB(i$,`${this.baseUrl}/api/v1/schedules/${e}`,{method:"GET",headers:this.#h(!1)},dv(this.defaultRequestOptions,t))}updateSchedule(e,t,r){return oB(i$,`${this.baseUrl}/api/v1/schedules/${e}`,{method:"PUT",headers:this.#h(!1),body:JSON.stringify(t)},dv(this.defaultRequestOptions,r))}deactivateSchedule(e,t){return oB(i$,`${this.baseUrl}/api/v1/schedules/${e}/deactivate`,{method:"POST",headers:this.#h(!1)},dv(this.defaultRequestOptions,t))}activateSchedule(e,t){return oB(i$,`${this.baseUrl}/api/v1/schedules/${e}/activate`,{method:"POST",headers:this.#h(!1)},dv(this.defaultRequestOptions,t))}deleteSchedule(e,t){return oB(iL,`${this.baseUrl}/api/v1/schedules/${e}`,{method:"DELETE",headers:this.#h(!1)},dv(this.defaultRequestOptions,t))}listEnvVars(e,t,r){return oB(ro.array(i3),`${this.baseUrl}/api/v1/projects/${e}/envvars/${t}`,{method:"GET",headers:this.#h(!1)},dv(this.defaultRequestOptions,r))}importEnvVars(e,t,r,n){return oB(i9,`${this.baseUrl}/api/v1/projects/${e}/envvars/${t}/import`,{method:"POST",headers:this.#h(!1),body:JSON.stringify(r)},dv(this.defaultRequestOptions,n))}retrieveEnvVar(e,t,r,n){return oB(i3,`${this.baseUrl}/api/v1/projects/${e}/envvars/${t}/${r}`,{method:"GET",headers:this.#h(!1)},dv(this.defaultRequestOptions,n))}createEnvVar(e,t,r,n){return oB(i9,`${this.baseUrl}/api/v1/projects/${e}/envvars/${t}`,{method:"POST",headers:this.#h(!1),body:JSON.stringify(r)},dv(this.defaultRequestOptions,n))}updateEnvVar(e,t,r,n,i){return oB(i9,`${this.baseUrl}/api/v1/projects/${e}/envvars/${t}/${r}`,{method:"PUT",headers:this.#h(!1),body:JSON.stringify(n)},dv(this.defaultRequestOptions,i))}deleteEnvVar(e,t,r,n){return oB(i9,`${this.baseUrl}/api/v1/projects/${e}/envvars/${t}/${r}`,{method:"DELETE",headers:this.#h(!1)},dv(this.defaultRequestOptions,n))}updateRunMetadata(e,t,r){return oB(i6,`${this.baseUrl}/api/v1/runs/${e}/metadata`,{method:"PUT",headers:this.#h(!1),body:JSON.stringify(t)},dv(this.defaultRequestOptions,r))}getRunMetadata(e,t){return oB(i6,`${this.baseUrl}/api/v1/runs/${e}/metadata`,{method:"GET",headers:this.#h(!1)},dv(this.defaultRequestOptions,t))}createWaitpointToken(e,t){return oB(ai,`${this.baseUrl}/api/v1/waitpoints/tokens`,{method:"POST",headers:this.#h(!1),body:JSON.stringify(e)},{...dv(this.defaultRequestOptions,t),prepareData:async(e,t)=>{let r=t.headers.get("x-trigger-jwt");if("string"==typeof r)return{...e,publicAccessToken:r};let n=t.headers.get("x-trigger-jwt-claims"),i=n?JSON.parse(n):void 0,a=await rd({secretKey:this.#p,payload:{...i,scopes:[`write:waitpoints:${e.id}`]},expirationTime:"24h"});return{...e,publicAccessToken:a}}})}listWaitpointTokens(e,t){var r;let n,i=(r=e,n=new URLSearchParams,r&&(r.status&&n.append("filter[status]",Array.isArray(r.status)?r.status.join(","):r.status),r.idempotencyKey&&n.append("filter[idempotencyKey]",r.idempotencyKey),r.tags&&n.append("filter[tags]",Array.isArray(r.tags)?r.tags.join(","):r.tags),r.period&&n.append("filter[createdAt][period]",r.period),r.from&&n.append("filter[createdAt][from]",r.from instanceof Date?r.from.getTime().toString():r.from.toString()),r.to&&n.append("filter[createdAt][to]",r.to instanceof Date?r.to.getTime().toString():r.to.toString())),n);return oW(al,`${this.baseUrl}/api/v1/waitpoints/tokens`,{query:i,limit:e?.limit,after:e?.after,before:e?.before},{method:"GET",headers:this.#h(!1)},dv(this.defaultRequestOptions,t))}retrieveWaitpointToken(e,t){return oB(au,`${this.baseUrl}/api/v1/waitpoints/tokens/${e}`,{method:"GET",headers:this.#h(!1)},dv(this.defaultRequestOptions,t))}completeWaitpointToken(e,t,r){return oB(ag,`${this.baseUrl}/api/v1/waitpoints/tokens/${e}/complete`,{method:"POST",headers:this.#h(!1),body:JSON.stringify(t)},{...dv(this.defaultRequestOptions,r)})}waitForWaitpointToken({runFriendlyId:e,waitpointFriendlyId:t},r){return oB(af,`${this.baseUrl}/engine/v1/runs/${e}/waitpoints/tokens/${t}/wait`,{method:"POST",headers:this.#h(!1)},dv(this.defaultRequestOptions,r))}createSession(e,t){return oB(ap,`${this.baseUrl}/api/v1/sessions`,{method:"POST",headers:this.#h(!1),body:JSON.stringify(e)},dv(this.defaultRequestOptions,t))}retrieveSession(e,t){return oB(ac,`${this.baseUrl}/api/v1/sessions/${encodeURIComponent(e)}`,{method:"GET",headers:this.#h(!1)},dv(this.defaultRequestOptions,t))}updateSession(e,t,r){return oB(ac,`${this.baseUrl}/api/v1/sessions/${encodeURIComponent(e)}`,{method:"PATCH",headers:this.#h(!1),body:JSON.stringify(t)},dv(this.defaultRequestOptions,r))}closeSession(e,t,r){return oB(ac,`${this.baseUrl}/api/v1/sessions/${encodeURIComponent(e)}/close`,{method:"POST",headers:this.#h(!1),body:JSON.stringify(t??{})},dv(this.defaultRequestOptions,r))}endAndContinueSession(e,t,r){return oB(ah,`${this.baseUrl}/api/v1/sessions/${encodeURIComponent(e)}/end-and-continue`,{method:"POST",headers:this.#h(!1),body:JSON.stringify(t)},dv(this.defaultRequestOptions,r))}listSessions(e,t){let r=function(e){let t=new URLSearchParams;if(!e)return t;let r=(e,r)=>{void 0!==r&&t.append(e,Array.isArray(r)?r.join(","):r)};return r("filter[type]",e.type),r("filter[tags]",e.tag),r("filter[taskIdentifier]",e.taskIdentifier),e.externalId&&t.append("filter[externalId]",e.externalId),r("filter[status]",e.status),e.period&&t.append("filter[createdAt][period]",e.period),void 0!==e.from&&t.append("filter[createdAt][from]",e.from instanceof Date?e.from.getTime().toString():e.from.toString()),void 0!==e.to&&t.append("filter[createdAt][to]",e.to instanceof Date?e.to.getTime().toString():e.to.toString()),t}(e);return oW(ac,`${this.baseUrl}/api/v1/sessions`,{query:r,limit:e?.limit,after:e?.after,before:e?.before},{method:"GET",headers:this.#h(!1)},dv(this.defaultRequestOptions,t))}async initializeSessionStream(e,t,r,n){let i=`${this.baseUrl}/realtime/v1/sessions/${encodeURIComponent(e)}`;return oB(ak,n?`${i}/channels/${encodeURIComponent(n)}/${t}`:`${i}/${t}`,{method:"PUT",headers:this.#h(!1)},dv(this.defaultRequestOptions,r)).withResponse().then(({data:e,response:t})=>({...e,headers:Object.fromEntries(t.headers.entries())}))}async appendToSessionStream(e,t,r,n,i){let a=((e=21)=>crypto.getRandomValues(new Uint8Array(e)).reduce((e,t)=>
6((t&=63)<36?e+=t.toString(36):t<62?e+=(t-26).toString(36).toUpperCase():t>62?e+="-":e+="_",e),""))(),s=`${this.baseUrl}/realtime/v1/sessions/${encodeURIComponent(e)}`;return oB(aR,i?`${s}/channels/${encodeURIComponent(i)}/${t}/append`:`${s}/${t}/append`,{method:"POST",headers:{...this.#h(!1),"X-Part-Id":a},body:r},dv(this.defaultRequestOptions,n))}async readSessionStreamRecords(e,t,r){let n=new URLSearchParams;r?.afterEventId!==void 0&&n.set("afterEventId",r.afterEventId);let i=`${r?.baseUrl??this.baseUrl}/realtime/v1/sessions/${encodeURIComponent(e)}`,a=r?.channel?`${i}/channels/${encodeURIComponent(r.channel)}/${t}/records`:`${i}/${t}/records`;return oB(ax,`${a}${n.toString()?`?${n.toString()}`:""}`,{method:"GET",headers:this.#h(!1)},dv(this.defaultRequestOptions,void 0))}async subscribeToSessionStream(e,t,r){let n=`${r?.baseUrl??this.baseUrl}/realtime/v1/sessions/${encodeURIComponent(e)}`,i=new de(r?.channel?`${n}/channels/${encodeURIComponent(r.channel)}/${t}`:`${n}/${t}`,{headers:this.getHeaders(),resolveHeaders:this.#m(),signal:r?.signal,onComplete:r?.onComplete,onError:r?.onError,timeoutInSeconds:r?.timeoutInSeconds,lastEventId:r?.lastEventId,from:r?.from}),a=await i.subscribe(),s=r?.onPart,o=r?.onControl;return a.pipeThrough(new TransformStream({transform(e,t){s?.(e);let r=function(e){if(e){for(let t of e)if(t?.[0]==="trigger-control")return t[1]}}(e.headers);if(r){let t=Number.parseInt(e.id,10);if(!Number.isFinite(t))return;o?.({subtype:r,headers:e.headers??[],seqNum:t,timestamp:e.timestamp});return}t.enqueue(e.chunk)}}))}async waitForDuration(e,t,r){return oB(ay,`${this.baseUrl}/engine/v1/runs/${e}/wait/duration`,{method:"POST",headers:this.#h(!1),body:JSON.stringify(t)},dv(this.defaultRequestOptions,r))}listQueues(e,t){let r=new URLSearchParams;return e?.page&&r.append("page",e.page.toString()),e?.perPage&&r.append("perPage",e.perPage.toString()),oF(n5,`${this.baseUrl}/api/v1/queues`,{page:e?.page,limit:e?.perPage},{method:"GET",headers:this.#h(!1)},dv(this.defaultRequestOptions,t))}retrieveQueue(e,t){let r="string"==typeof e?"id":e.type,n=encodeURIComponent(("string"==typeof e?e:e.name).replace(/\//g,"%2F"));return oB(n5,`${this.baseUrl}/api/v1/queues/${n}?type=${r}`,{method:"GET",headers:this.#h(!1)},dv(this.defaultRequestOptions,t))}pauseQueue(e,t,r){let n="string"==typeof e?"id":e.type,i=encodeURIComponent(("string"==typeof e?e:e.name).replace(/\//g,"%2F"));return oB(n5,`${this.baseUrl}/api/v1/queues/${i}/pause`,{method:"POST",headers:this.#h(!1),body:JSON.stringify({type:n,action:t})},dv(this.defaultRequestOptions,r))}overrideQueueConcurrencyLimit(e,t,r){let n="string"==typeof e?"id":e.type,i=encodeURIComponent(("string"==typeof e?e:e.name).replace(/\//g,"%2F"));return oB(n5,`${this.baseUrl}/api/v1/queues/${i}/concurrency/override`,{method:"POST",headers:this.#h(!1),body:JSON.stringify({type:n,concurrencyLimit:t})},dv(this.defaultRequestOptions,r))}resetQueueConcurrencyLimit(e,t){let r="string"==typeof e?"id":e.type,n=encodeURIComponent(("string"==typeof e?e:e.name).replace(/\//g,"%2F"));return oB(n5,`${this.baseUrl}/api/v1/queues/${n}/concurrency/reset`,{method:"POST",headers:this.#h(!1),body:JSON.stringify({type:r})},dv(this.defaultRequestOptions,t))}subscribeToRun(e,t){let r=new URLSearchParams;return t?.skipColumns&&r.append("skipColumns",t.skipColumns.join(",")),u7(`${this.baseUrl}/realtime/v1/runs/${e}${r?`?${r}`:""}`,{closeOnComplete:"boolean"!=typeof t?.closeOnComplete||t.closeOnComplete,headers:this.#f(),resolveHeaders:this.#g(),client:this,signal:t?.signal,onFetchError:t?.onFetchError})}subscribeToRunsWithTag(e,t,r){var n;let i,a=(n={tags:e,...t?{createdAt:t.createdAt}:{},...t?.skipColumns?{skipColumns:t.skipColumns}:{}},i=new URLSearchParams,n&&(n.tasks&&i.append("tasks",Array.isArray(n.tasks)?n.tasks.join(","):n.tasks),n.tags&&i.append("tags",Array.isArray(n.tags)?n.tags.join(","):n.tags),n.createdAt&&i.append("createdAt",n.createdAt),n.skipColumns&&i.append("skipColumns",n.skipColumns.join(","))),i);return u7(`${this.baseUrl}/realtime/v1/runs${a?`?${a}`:""}`,{closeOnComplete:!1,headers:this.#f(),resolveHeaders:this.#g(),client:this,signal:r?.signal,onFetchError:r?.onFetchError})}subscribeToBatch(e,t){let r=new URLSearchParams;
6return t?.skipColumns&&r.append("skipColumns",t.skipColumns.join(",")),u7(`${this.baseUrl}/realtime/v1/batches/${e}${r?`?${r}`:""}`,{closeOnComplete:!1,headers:this.#f(),resolveHeaders:this.#g(),client:this,signal:t?.signal,onFetchError:t?.onFetchError})}listDeployments(e,t){let r=new URLSearchParams;return e?.status&&r.append("status",e.status),e?.period&&r.append("period",e.period),e?.from&&r.append("from",e.from),e?.to&&r.append("to",e.to),oW(aT,`${this.baseUrl}/api/v1/deployments`,{query:r,after:e?.cursor,limit:e?.limit},{method:"GET",headers:this.#h(!1)},dv(this.defaultRequestOptions,t))}retrieveCurrentDeployment(e){return oB(aT,`${this.baseUrl}/api/v1/deployments/current`,{method:"GET",headers:this.#h(!1)},dv(this.defaultRequestOptions,e))}async fetchStream(e,t,r){let n=new dt(r?.baseUrl??this.baseUrl,{headers:this.getHeaders(),signal:r?.signal,resolveHeaders:this.#m()}).createSubscription(e,t,{onComplete:r?.onComplete,onError:r?.onError,timeoutInSeconds:r?.timeoutInSeconds,lastEventId:r?.lastEventId,from:r?.from}),i=await n.subscribe(),a=r?.onPart;return i.pipeThrough(new TransformStream({transform(e,t){let r=e.chunk;a?.(e),t.enqueue(r)}}))}async createStream(e,t,r,n){return oB(ak,`${this.baseUrl}/realtime/v1/streams/${e}/${t}/${r}`,{method:"PUT",headers:this.#h(!1)},dv(this.defaultRequestOptions,n)).withResponse().then(async({data:e,response:t})=>({...e,headers:Object.fromEntries(t.headers.entries())}))}async appendToStream(e,t,r,n,i){return oB(aR,`${this.baseUrl}/realtime/v1/streams/${e}/${t}/${r}/append`,{method:"POST",headers:this.#h(!1),body:n},dv(this.defaultRequestOptions,i))}async sendInputStream(e,t,r,n){return oB(aA,`${this.baseUrl}/realtime/v1/streams/${e}/input/${t}`,{method:"POST",headers:this.#h(!1),body:JSON.stringify({data:r})},dv(this.defaultRequestOptions,n))}async createInputStreamWaitpoint(e,t,r){return oB(aa,`${this.baseUrl}/api/v1/runs/${e}/input-streams/wait`,{method:"POST",headers:this.#h(!1),body:JSON.stringify(t)},dv(this.defaultRequestOptions,r))}async createSessionStreamWaitpoint(e,t,r){return oB(as,`${this.baseUrl}/api/v1/runs/${e}
6/session-streams/wait`,{method:"POST",headers:this.#h(!1),body:JSON.stringify(t)},dv(this.defaultRequestOptions,r))}async generateJWTClaims(e){return oB(ro.record(ro.any()),`${this.baseUrl}/api/v1/auth/jwt/claims`,{method:"POST",headers:this.#h(!1)},dv(this.defaultRequestOptions,e))}async createPublicToken(e,t){return oB(dc,`${this.baseUrl}/api/v1/auth/public-tokens`,{method:"POST",headers:this.#h(!1),body:JSON.stringify(e)},dv(this.defaultRequestOptions,t))}retrieveBatch(e,t){return oB(ar,`${this.baseUrl}/api/v2/batches/${e}`,{method:"GET",headers:this.#h(!1)},dv(this.defaultRequestOptions,t))}async executeQuery(e,t,r){let n={query:e,scope:t?.scope??"environment",period:t?.period,from:t?.from,to:t?.to,format:t?.format??"json"};return oB(a$,`${this.baseUrl}/api/v1/query`,{method:"POST",headers:this.#h(!1),body:JSON.stringify(n)},dv(this.defaultRequestOptions,r))}async getQuerySchema(e){return oB(aZ,`${this.baseUrl}/api/v1/query/schema`,{method:"GET",headers:this.#h(!1)},dv(this.defaultRequestOptions,e))}async listDashboards(e){return oB(aH,`${this.baseUrl}/api/v1/query/dashboards`,{method:"GET",headers:this.#h(!1)},dv(this.defaultRequestOptions,e))}async getReport(e,t){let r=new URLSearchParams({format:t?.format??"markdown"});t?.period&&r.set("period",t.period);let n=await fetch(`${this.baseUrl}/api/v1/reports/${encodeURIComponent(e)}?${r.toString()}`,{method:"GET",headers:this.#h(!1)});if(!n.ok){let t=await dy(n);throw Error(`Failed to fetch report "${e}": ${n.status} ${n.statusText}${t?` â ${t}`:""}`)}return t?.format==="json"?a3.parse(await n.json()):n.text()}#h(e,t){let r={"Content-Type":"application/json",Authorization:`Bearer ${this.accessToken}`,"trigger-version":rl,...Object.entries(t??{}).reduce((e,[t,r])=>(void 0!==r&&(e[t]=r),e),{})};if(this.additionalHeaders)for(let[e,t]of Object.entries(this.additionalHeaders))e in r||(r[e]=t);return r["x-trigger-source"]||(r["x-trigger-source"]="sdk"),this.previewBranch&&(r["x-trigger-branch"]=this.previewBranch),si.isInsideTask&&(r["x-trigger-worker"]="true",r["x-trigger-engine-version"]="V2",e&&(r["x-trigger-span-parent-as-link"]="1")),"u">typeof window&&void 0!==window.document&&(r["x-trigger-client"]="browser"),r[u6]=u3,!1===(this.futureFlags.v2RealtimeStreams??!0)||"0"===sk("TRIGGER_V2_REALTIME_STREAMS")||"false"===sk("TRIGGER_V2_REALTIME_STREAMS")||"0"===sk("TRIGGER_REALTIME_STREAMS_V2")||"false"===sk("TRIGGER_REALTIME_STREAMS_V2")?r["x-trigger-realtime-streams-version"]="v1":r["x-trigger-realtime-streams-version"]="v2",r}resolvePrompt(e,t,r){return oB(aC,`${this.baseUrl}/api/v1/prompts/${e}`,{method:"POST",headers:this.#h(!1),body:JSON.stringify(t)},dv(this.defaultRequestOptions,r))}listPrompts(e){return oB(aO,`${this.baseUrl}/api/v1/prompts`,{method:"GET",headers:this.#h(!1)},dv(this.defaultRequestOptions,e))}listPromptVersions(e,t){return oB(aj,`${this.baseUrl}/api/v1/prompts/${e}/versions`,{method:"GET",headers:this.#h(!1)},dv(this.defaultRequestOptions,t))}promotePromptVersion(e,t,r){return oB(aP,`${this.baseUrl}/api/v1/prompts/${e}/promote`,{method:"POST",headers:this.#h(!1),body:JSON.stringify(t)},dv(this.defaultRequestOptions,r))}createPromptOverride(e,t,r){return oB(aN,`${this.baseUrl}/api/v1/prompts/${e}/override`,{method:"POST",headers:this.#h(!1),body:JSON.stringify(t)},dv(this.defaultRequestOptions,r))}updatePromptOverride(e,t,r){return oB(aP,`${this.baseUrl}/api/v1/prompts/${e}/override`,{method:"PUT",headers:this.#h(!1),body:JSON.stringify(t)},dv(this.defaultRequestOptions,r))}removePromptOverride(e,t){return oB(aP,`${this.baseUrl}/api/v1/prompts/${e}/override`,{method:"DELETE",headers:this.#h(!1)},dv(this.defaultRequestOptions,t))}reactivatePromptOverride(e,t,r){return oB(aP,`${this.baseUrl}/api/v1/prompts/${e}/override/reactivate`,{method:"POST",headers:this.#h(!1),body:JSON.stringify(t)},dv(this.defaultRequestOptions,r))}#f(){let e={Authorization:`Bearer ${this.accessToken}`,"trigger-version":rl};return this.previewBranch&&(e["x-trigger-branch"]=this.previewBranch),e}}function dh(e){let t=new URLSearchParams;return e&&(e.status&&t.append("filter[status]",Array.isArray(e.status)?e.status.join(","):e.status),e.taskIdentifier&&t.append("filter[taskIdentifier]",Array.isArray(e.taskIdentifier)?e.taskIdentifier.join(","):e.taskIdentifier),e.version&&t.append("filter[version]",Array.isArray(e.version)?e.version.join(","):e.version),e.bulkAction&&t.append("filter[bulkAction]",e.bulkAction),e.tag&&t.append("filter[tag]",Array.isArray(e.tag)?e.tag.join(","):e.tag),e.schedule&&t.append("filter[schedule]",e.schedule),"boolean"==typeof e.isTest&&t.append("filter[isTest]",String(e.isTest)),e.from&&t.append("filter[createdAt][from]",e.from instanceof Date?e.from.getTime().toString():e.from.toString()),e.to&&t.append("filter[createdAt][to]",e.to instanceof Date?e.to.getTime().toString():e.to.toString()),e.period&&t.append("filter[createdAt][period]",e.period),e.batch&&t.append("filter[batch]",e.batch),e.queue&&t.append("filter[queue]",Array.isArray(e.queue)?e.queue.map(e=>dm(e)).join(","):dm(e.queue)),e.machine&&t.append("filter[machine]",Array.isArray(e.machine)?e.machine.join(","):e.machine),e.region&&t.append("filter[region]",Array.isArray(e.region)?e.region.join(","):e.region)),t}function dm(e){return"task"===e.type?`task/${e.name}`:e.name}let dg={maxAttempts:5,factor:2,minTimeoutInMs:1e3,maxTimeoutInMs:3e4,randomize:!0};function df(e){return new Promise(t=>setTimeout(t,e))}async function dy(e,t=500){try{let r=(await e.text()).trim();if(!r)return"";return r.length>t?`${r.slice(0,t)}â¦`:r}catch{return""}}async function db(e){try{await e.cancel()}catch(e){if(e instanceof TypeError&&String(e).includes("locked"))return;throw e}}function dv(e,t){return t?{...e,...t,retry:{...e.retry,...t.retry}}:e}var d_=e.i(423484),d_=d_;async function dE(e,t,r,n,i,a,s=!0){for await(let o of r.subscribeToRun(e,{signal:a.current?.signal,closeOnComplete:s,onFetchError:i,skipColumns:t.skipColumns}))n(o)}e.s(["useRealtimeRun",0,function(e,t){var r;let n,i=(0,eo.useId)(),a=t?.id??i,{data:s,mutate:o}=(0,d_.default)([a,"run"],null),{data:l,mutate:u}=(0,d_.default)([a,"error"],null),{data:d=!1,mutate:c}=(0,d_.default)([a,"complete"],null),p=(0,eo.useRef)(null),h=(0,eo.useCallback)(()=>{p.current&&(p.current.abort(),p.current=null)},[]),m=function(e){let t=ec(),r=e?.baseURL??t?.baseURL??"https://api.trigger.dev",n=e?.accessToken??t?.accessToken,i=e?.previewBranch??t?.previewBranch,a=e?.refreshAccessToken??t?.refreshAccessToken,s=(0,eo.useRef)(a);(0,eo.useEffect)(()=>{s.current=a},[a]);let o=(0,eo.useCallback)(async()=>{let e=s.current;if(!e)throw Error("Missing refreshAccessToken in TriggerAuthContext or useApiClient options");return o9(e)},[]);
6if(!n){if(e?.enabled===!1)return;throw Error("Missing accessToken in TriggerAuthContext or useApiClient options")}return new dp(r,n,i,{...t?.requestOptions,...e?.requestOptions},void 0,a?o:void 0)}(t),g=t?.onComplete,f=t?.skipColumns,y=t?.stopOnCompletion,b=(r=(0,eo.useCallback)(async()=>{try{if(!e||!m)return;p.current=new AbortController,await dE(e,{skipColumns:f},m,o,u,p,"boolean"!=typeof y||y)}catch(e){if("AbortError"===e.name){p.current=null;return}u(e)}finally{p.current&&(p.current=null),c(!0)}},[e,m,o,u,c,f,y]),n=(0,eo.useRef)(r),(0,eo.useEffect)(()=>{n.current=r},[r]),(0,eo.useCallback)(()=>n.current(),[])),v=(0,eo.useRef)(!1);return(0,eo.useEffect)(()=>{d&&s?.finishedAt&&g&&!v.current&&(g(s,l),v.current=!0)},[d,s,l,g]),(0,eo.useEffect)(()=>{if(("boolean"!=typeof t?.enabled||t.enabled)&&e)return b().finally(()=>{}),()=>{h()}},[e,h,t?.enabled,b]),(0,eo.useEffect)(()=>{s?.finishedAt&&c(!0)},[s,c]),{run:s,error:l,stop:h}}],895397),e.s([],911)}]); 7 8//# debugId=128bda12-bcc6-d6ef-2c33-af66f45d8140 9//# sourceMappingURL=3boo94nxxnuvm.js.map
10//# chunkId=01a0d0df-a62f-7371-9d48-5a5eac5e21c0
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.