@oomol-lab/open-flow 0.1.0-beta.66 → 0.1.0-beta.68
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/ContentIcon-Sx9bywU-.js +11861 -0
- package/dist/browser/FlowCanvas-CXpaeurx.js +22721 -0
- package/dist/browser/{createResourceDialog-C-Si_cYs.js → createResourceDialog-BKmimKA_.js} +3 -2
- package/dist/browser/dialog-ZmfcwuMS.js +8785 -0
- package/dist/browser/event-sources.d.ts +4 -1
- package/dist/browser/exportSvg-D4CqCcx2.js +659 -0
- package/dist/browser/flow-authoring-node.d.ts +2 -0
- package/dist/browser/flow-authoring.js +6 -5
- package/dist/browser/flow-change.js +6 -5
- package/dist/browser/{flowChanges-T4_R5p1f.js → flowChanges-B5tZMcGr.js} +3440 -15004
- package/dist/browser/{flowRunInputEditorStore-DJqmR6Qh.js → flowRunInputEditorStore-ys1-w9GW.js} +2 -1
- package/dist/browser/{flowWorkspace-C0J5C0oM.js → flowWorkspace-zFBFtZPo.js} +1232 -23701
- package/dist/browser/languages-gYzoQqCi.js +68 -0
- package/dist/browser/licenses.md +24 -0
- package/dist/browser/preview.css +125 -55
- package/dist/browser/preview.js +16256 -15986
- package/dist/browser/theme.css +1 -0
- package/dist/browser/{icons-BD3m0RQq.js → tooltip-CJjYs_2I.js} +280 -9041
- package/dist/browser/ui.css +38 -4
- package/dist/browser/{value-BADHeZ9I.js → value-BbFQZZ_V.js} +1 -68
- package/dist/browser/workbench-contract.d.ts +1 -1
- package/dist/browser/workbench.css +2907 -2871
- package/dist/browser/workbench.d.ts +0 -1
- package/dist/browser/workbench.js +760 -461
- package/dist/browser/{workbenchSelect-B-PFpF_Q.js → workbenchSelect-CChdgugI.js} +2 -1
- package/dist/command/index.js +25 -25
- package/dist/common/authoringExamples.d.ts +2 -2
- package/dist/common/control-api-conformance.js +57 -12
- package/dist/common/control-api.d.ts +12 -2
- package/dist/common/control-api.js +41 -8
- package/dist/common/control-requests.js +7 -6
- package/dist/common/decision.js +5 -4
- package/dist/common/flow-encoding.js +7 -4
- package/dist/common/flow-semantics.js +11 -8
- package/dist/common/integration-trigger.js +5 -4
- package/dist/common/mcp.js +42 -9
- package/dist/common/openapi.js +5 -4
- package/dist/common/poll-trigger.js +5 -4
- package/dist/common/scheduler.js +5 -4
- package/dist/common/webhook-trigger.js +5 -4
- package/dist/common/workflow.js +5 -4
- package/package.json +1 -1
- package/skills/open-flow/SKILL.md +9 -0
- package/skills/open-flow/references/flow-authoring.md +2 -0
package/dist/command/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var ka="0.1.0-beta.66";var Fo=["en","zh-CN","zh-TW","ja","ko","ru","fr"],Sa="en";var Zo=new Map(Fo.map((e)=>[e.toLowerCase(),e])),wg=new Set(["hk","mo","tw"]);function Ia(e){return typeof e=="string"&&Zo.get(e.toLowerCase())==e}function br(e,n="en"){for(let t of e){let r=t==null?void 0:xg(t);if(r!=null)return r}return n}function xg(e){let n=e.trim().toLowerCase();if(n.length==0)return;let t=Zo.get(n);if(t!=null)return t;let r=n.split("-");if(r[0]=="zh"){if(r.includes("hant"))return"zh-TW";if(r.includes("hans"))return"zh-CN";return r.some((o)=>wg.has(o))?"zh-TW":"zh-CN"}return Zo.get(r[0])}function Ca(e){return{en:"Imported workflow","zh-CN":"\u5BFC\u5165\u7684\u5DE5\u4F5C\u6D41","zh-TW":"\u532F\u5165\u7684\u5DE5\u4F5C\u6D41",ja:"\u30A4\u30F3\u30DD\u30FC\u30C8\u3057\u305F\u30EF\u30FC\u30AF\u30D5\u30ED\u30FC",ko:"\uAC00\uC838\uC628 \uC6CC\uD06C\uD50C\uB85C",fr:"Workflow import\xE9",ru:"\u0418\u043C\u043F\u043E\u0440\u0442\u0438\u0440\u043E\u0432\u0430\u043D\u043D\u044B\u0439 \u043F\u0440\u043E\u0446\u0435\u0441\u0441"}[e]}import{spawn as Fx}from"child_process";import{readFile as Jx}from"fs/promises";import{setTimeout as Lx}from"timers/promises";var Ea=Object.prototype.hasOwnProperty;function ve(e,n){var t,r;if(e===n)return!0;if(e&&n&&(t=e.constructor)===n.constructor){if(t===Date)return e.getTime()===n.getTime();if(t===RegExp)return e.toString()===n.toString();if(t===Array){if((r=e.length)===n.length)while(r--&&ve(e[r],n[r]));return r===-1}if(!t||typeof e==="object"){r=0;for(t in e){if(Ea.call(e,t)&&++r&&!Ea.call(n,t))return!1;if(!(t in n)||!ve(e[t],n[t]))return!1}return Object.keys(n).length===r}}return e!==e&&n!==n}function ht(e){let n=Object.values(e).filter((r)=>typeof r==="number");return Object.entries(e).filter(([r,o])=>n.indexOf(+r)===-1).map(([r,o])=>o)}function Lo(e,n="|"){return e.map((t)=>Bo(t)).join(n)}function yt(e,n){if(typeof n==="bigint")return n.toString();return n}class Ra{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;if(e!==void 0)this._value=e(),this._getter=void 0;return this._value}}function bt(e){return new Ra(e)}function Aa(e){return e===null||e===void 0}function wr(e){let n=e.startsWith("^")?1:0,t=e.endsWith("$")?e.length-1:e.length;return e.slice(n,t)}function ja(e,n){let t=e/n,r=Math.round(t),o=4*Number.EPSILON*Math.max(Math.abs(t),1);if(Math.abs(t-r)<o)return 0;return t-r}var Oa=Symbol("evaluating");function Pa(e,n,t){let r=void 0;Object.defineProperty(e,n,{get(){if(r===Oa)return;if(r===void 0)r=Oa,r=t();return r},set(o){Object.defineProperty(e,n,{value:o})},configurable:!0})}function Ve(e,n,t){Object.defineProperty(e,n,{value:t,writable:!0,enumerable:!0,configurable:!0})}function wt(e){let n=Object.getOwnPropertyDescriptor(e,"shape");return n?.get?n.get.raw:n?.value}function rn(e){return wt(e._zod.def)??e._zod.def.shape}function $a(e,n,t){Object.defineProperty(e,n,{get(){let r=t();return Ve(this,n,r),r},enumerable:!0,configurable:!0})}function _a(e,n,t){if(n in e)Ve(e,n,t);else e[n]=t}function En(e,n,t,r){let o=rn(n);for(let i of t){let s=Object.getOwnPropertyDescriptor(o,i);if(!s.enumerable)continue;if(s.get)$a(e,i,()=>{let a=n._zod.def.shape[i];return r?r(a,i):a});else _a(e,i,r?r(s.value,i):s.value)}}function vg(e,n){for(let t of Reflect.ownKeys(n)){let r=Object.getOwnPropertyDescriptor(n,t);if(!r.enumerable)continue;if(r.get)$a(e,t,()=>n[t]);else _a(e,t,r.value)}}function Me(...e){let n={};for(let t of e){let r=Object.getOwnPropertyDescriptors(t);Object.assign(n,r)}return Object.defineProperties({},n)}function Na(e){return JSON.stringify(e)}function Ta(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var qo="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function qn(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var za=bt(()=>{if(Pe.jitless)return!1;if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function On(e){if(qn(e)===!1)return!1;let n=e.constructor;if(n===void 0)return!0;if(typeof n!=="function")return!0;let t=n.prototype;if(qn(t)===!1)return!1;if(Object.prototype.hasOwnProperty.call(t,"isPrototypeOf")===!1)return!1;return!0}function Uo(e){if(On(e))return{...e};if(Array.isArray(e))return[...e];if(e instanceof Map)return new Map(e);if(e instanceof Set)return new Set(e);return e}var Da=new Set(["string","number","symbol"]);function fn(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Qe(e,n,t){let r=new e._zod.constr(n??e._zod.def);if(!n||t?.parent)r._zod.parent=e;return r}function _(e){let n=e;if(!n)return{};if(typeof n==="string")return{error:()=>n};if(n?.message!==void 0){if(n?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");n.error=n.message}if(delete n.message,typeof n.error==="string")return{...n,error:()=>n.error};return n}function Bo(e){if(typeof e==="bigint")return e.toString()+"n";if(typeof e==="string")return`"${e}"`;return`${e}`}function Va(e){return Object.keys(e).filter((n)=>e[n]._zod.optin!==void 0&&e[n]._zod.optout==="optional")}var xr=(()=>({safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-340282346638528860000000000000000000000,340282346638528860000000000000000000000],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]}))(),Ko={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function kg(e,n){let t=e._zod.def,r=t.checks;if(r&&r.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let i={};return En(i,e,vr(e,n)),Qe(e,Me(t,{shape:i,checks:[]}))}function vr(e,n){let t=rn(e),r=[];for(let o of Reflect.ownKeys(n)){if(!Object.getOwnPropertyDescriptor(t,o)?.enumerable)throw Error(`Unrecognized key: "${String(o)}"`);if(n[o])r.push(o)}return r}function Sg(e,n){let t=e._zod.def,r=t.checks;if(r&&r.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let i=new Set(vr(e,n)),s={};return En(s,e,Reflect.ownKeys(rn(e)).filter((a)=>!i.has(a))),Qe(e,Me(t,{shape:s,checks:[]}))}function Ig(e,n){if(!On(n))throw Error("Invalid input to extend: expected a plain object");let t=e._zod.def.checks;if(t&&t.length>0){let o=rn(e);for(let i of Reflect.ownKeys(n))if(Object.getOwnPropertyDescriptor(o,i)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return Qe(e,Me(e._zod.def,{shape:Ma(e,n)}))}function Ma(e,n){let t={};return En(t,e,Reflect.ownKeys(rn(e))),vg(t,n),t}function Cg(e,n){if(!On(n))throw Error("Invalid input to safeExtend: expected a plain object");return Qe(e,Me(e._zod.def,{shape:Ma(e,n)}))}function Eg(e,n){if(!n?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let t={};En(t,e,Reflect.ownKeys(rn(e))),En(t,n,Reflect.ownKeys(rn(n)));let r=Me(e._zod.def,{shape:t,get catchall(){return n._zod.def.catchall},checks:n._zod.def.checks??[]});return Qe(e,r)}function Za(e,n,t,r="partial"){let i=n._zod.def.checks;if(i&&i.length>0)throw Error(`.${r}() cannot be used on object schemas containing refinements`);let a=t?new Set(vr(n,t)):void 0,c={};return En(c,n,Reflect.ownKeys(rn(n)),e&&((u,l)=>a&&!a.has(l)?u:new e({type:"optional",innerType:u}))),Qe(n,Me(n._zod.def,{shape:c,checks:[]}))}function Og(e,n,t){let r=t?new Set(vr(n,t)):void 0,o={};return En(o,n,Reflect.ownKeys(rn(n)),(i,s)=>r&&!r.has(s)?i:new e({type:"nonoptional",innerType:i})),Qe(n,Me(n._zod.def,{shape:o}))}function Ye(e,n=0){if(e.aborted===!0)return!0;for(let t=n;t<e.issues.length;t++)if(e.issues[t]?.continue!==!0)return!0;return!1}function Fa(e,n=0){if(e.aborted===!0)return!0;for(let t=n;t<e.issues.length;t++)if(e.issues[t]?.continue===!1)return!0;return!1}function mn(e,n){return n.map((t)=>{var r;return(r=t).path??(r.path=[]),t.path.unshift(e),t})}function gt(e){return typeof e==="string"?e:e?.message}function Wo(e,n,t){var r;for(let o=n;o<e.length;o++)(r=e[o]).schema??(r.schema=t)}function Xe(e,n,t){var r;let o=e.inst?._zod?.traits;if(o?.has("$ZodType"))if(o.has("$ZodCheck"))(r=e).schema??(r.schema=e.inst);else e.schema=e.inst;let i=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,s=e.message?e.message:gt(e.inst?._zod.def?.error?.(e))??gt(i?.(e))??gt(n?.error?.(e))??gt(t.customError?.(e))??gt(t.localeError?.(e))??"Invalid input",a={};for(let c of Object.keys(e)){if(c==="inst"||c==="schema"||c==="continue"||c==="input"||c==="__proto__")continue;a[c]=e[c]}if(a.path??(a.path=[]),a.message=s,n?.reportInput)a.input=e.input;return a}var Rg=/[\uD800-\uDBFF]/;function kr(e){let n=e.length;if(!Rg.test(e))return n;let t=n;for(let r=0;r<n-1;r++)if((e.charCodeAt(r)&64512)===55296&&(e.charCodeAt(r+1)&64512)===56320)t--,r++;return t}function Sr(e){if(Array.isArray(e))return"array";if(typeof e==="string")return"string";return"unknown"}function Ja(e){let n=typeof e;switch(n){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let t=e;if(t&&Object.getPrototypeOf(t)!==Object.prototype&&"constructor"in t&&t.constructor)return t.constructor.name}}return n}function Rn(...e){let[n,t,r]=e;if(typeof n==="string")return{message:n,code:"custom",input:t,inst:r};return{...n}}function La(e,n){for(let t in n){let r=Object.getOwnPropertyDescriptor(n,t);if(r.get)Object.defineProperty(e,t,{...r,enumerable:!1});else Ag(e,t,r.value)}}function on(e,n,t,r=!0){return Object.defineProperty(e,n,{configurable:!0,writable:!0,enumerable:r,value:t}),t}function Ir(e,n,t){return on(e,n,t,!1)}function qa(e,n){for(let t in e){let r=e[t];Object.defineProperty(n,t,{configurable:!0,enumerable:!0,get(){return on(this,t,r(this))},set(o){on(this,t,o)}})}return n}function Ag(e,n,t){Object.defineProperty(e,n,{configurable:!0,get(){return this==null?t:on(this,n,t.bind(this))},set(r){on(this,n,r)}})}function jg(e,n){let t=Object.getPrototypeOf(e);return n in t?void 0:t}var Jo,pn=!1,Pg={configurable:!0,get(){pn=!0;return}};function B(e,n,t){let r=Object.getPrototypeOf(e._zod);if(n in r&&Jo!==e._zod){Jo=void 0;return}Jo=e._zod,Object.defineProperty(r,n,{configurable:!0,get(){Object.defineProperty(this,n,Pg);let o=pn;pn=!1;try{let i=t(this);if(pn)delete this[n];else Object.defineProperty(this,n,{configurable:!0,writable:!0,value:i});return pn=pn||o,i}catch(i){throw delete this[n],pn=pn||o,i}},set(o){Object.defineProperty(this,n,{configurable:!0,writable:!0,value:o})}})}function $g(e,n,t,r){let o=jg(e,n);if(!o)return;Object.defineProperty(o,n,{configurable:!0,get(){let i={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,n,i),i.value=t(this),Object.defineProperty(this,n,i),i.value},set(i){Object.defineProperty(this,n,{configurable:!0,writable:!0,enumerable:r,value:i})}})}var _g="~constantCatch";function Ua(e){let n=()=>e;return n[_g]=!0,n}var Ba;var Go={value:void 0,enumerable:!1},Ka="captureStackTrace"in Error?Error:null;function Ng(e){let n=Ka;if(n){let t=n.stackTraceLimit;if(typeof t==="number"){try{n.stackTraceLimit=0}catch{return Ka=null,new e}try{return new e}finally{n.stackTraceLimit=t}}}return new e}function b(e,n,t,r){let o={};function i(m){this.def=m,this.constr=p,this.traits=new Set}i.prototype=o;let s=t,a=s&&new WeakSet;function c(m,h){if(!m._zod){Go.value=new i(h);try{Object.defineProperty(m,"_zod",Go)}finally{Go.value=void 0}}else if(m._zod.traits.has(e))return;if(m._zod.traits.add(e),n(m,h),a){let E=Object.getPrototypeOf(m),P=m._zod.constr.prototype,N=E;while(N&&N!==P)N=Object.getPrototypeOf(N);let L=N??E;if(!a.has(L))a.add(L),La(L,s)}let g=p.prototype;for(let E in g){if(!Object.prototype.hasOwnProperty.call(g,E))continue;if(!(E in m))m[E]=g[E].bind(m)}}let u=r?.Parent??Object;class l extends u{}Object.defineProperty(l,"name",{value:e});function p(m){let h=r?.Parent?Ng(l):this;c(h,m);let g=h._zod.deferred;if(g){for(let P of g)P();h._zod.deferred=void 0}let E=globalThis.__zod_globalConfig?.postProcessor;if(E)E(h);return h}return Object.defineProperty(p,"init",{value:c}),Object.defineProperty(p,Symbol.hasInstance,{value:(m)=>{if(r?.Parent&&m instanceof r.Parent)return!0;return m?._zod?.traits?.has(e)}}),Object.defineProperty(p,"name",{value:e}),p}class en extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class xt extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`);this.name="ZodEncodeError"}}(Ba=globalThis).__zod_globalConfig??(Ba.__zod_globalConfig={});var Pe=globalThis.__zod_globalConfig;function Ze(e){if(e)Object.assign(Pe,e);return Pe}function Tg(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,yt,2)),e.message}function zg(e){this._zod.message=e}var Dg={get:Tg,set:zg,enumerable:!0,configurable:!0},Qo={value:void 0,enumerable:!1},Wa=new WeakSet([Object.prototype,Error.prototype]),Ga=(e,n)=>{e.name="$ZodError",Qo.value=n,Object.defineProperty(e,"issues",Qo),Qo.value=void 0,Object.defineProperty(e,"message",Dg);let t=Object.getPrototypeOf(e);if(!Wa.has(t))Wa.add(t),Object.defineProperty(t,"toString",{configurable:!0,enumerable:!1,get(){let r=()=>this.message;return Object.defineProperty(this,"toString",{value:r,configurable:!0,writable:!0}),r},set(r){Object.defineProperty(this,"toString",{value:r,configurable:!0,writable:!0})}})},Ha=b("$ZodError",Ga),Qx=b("$ZodError",Ga,void 0,{Parent:Error});function Vg(e,n,t){if(!Object.prototype.hasOwnProperty.call(e,n))if(n==="__proto__")Object.defineProperty(e,n,{value:t(),writable:!0,enumerable:!0,configurable:!0});else e[n]=t();return e[n]}function Qa(e,n=(t)=>t.message){let t={},r=[];for(let o of e.issues)if(o.path.length>0)Vg(t,o.path[0],()=>[]).push(n(o));else r.push(n(o));return{formErrors:r,fieldErrors:t}}function Ya(e,n=(t)=>t.message){let t={_errors:[]},r=(o,i=[])=>{for(let s of o.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map((a)=>r({issues:a},[...i,...s.path]));else if(s.code==="invalid_key")r({issues:s.issues},[...i,...s.path]);else if(s.code==="invalid_element")r({issues:s.issues},[...i,...s.path]);else{let a=[...i,...s.path];if(a.length===0)t._errors.push(n(s));else{let c=t,u=0;while(u<a.length){let l=a[u],p=u===a.length-1;if(l==="_errors"){if(p)c._errors.push(n(s));u++;continue}if(!Object.prototype.hasOwnProperty.call(c,l))Object.defineProperty(c,l,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let m=c[l];if(p)m._errors.push(n(s));c=m,u++}}}};return r(e),t}function Cr(e,n){return{callee:n?.callee??e,Err:n?.Err}}var Er=(e)=>{let n=(t,r,o,i)=>{let s=o?{...o,async:!1}:{async:!1},a=t._zod.run({value:r,issues:[]},s);if(a instanceof Promise)throw new en;if(a.issues.length){let c=new(i?.Err??e)(a.issues.map((u)=>Xe(u,s,Ze())));throw qo(c,i?.callee??n),c}return a.value};return n};var Or=(e)=>{let n=async(t,r,o,i)=>{let s=o?{...o,async:!0}:{async:!0},a=t._zod.run({value:r,issues:[]},s);if(a instanceof Promise)a=await a;if(a.issues.length){let c=new(i?.Err??e)(a.issues.map((u)=>Xe(u,s,Ze())));throw qo(c,i?.callee??n),c}return a.value};return n};var Rr=(e)=>(n,t,r)=>{let o=r?{...r,async:!1}:{async:!1},i=n._zod.run({value:t,issues:[]},o);if(i instanceof Promise)throw new en;return i.issues.length?Xa(e,i.issues,o):{success:!0,data:i.value}};function Xa(e,n,t){let r;return{success:!1,get error(){if(!r)r=new e(n.map((o)=>Xe(o,t,Ze()))),n=void 0,t=void 0;return r},set error(o){r=o,n=void 0,t=void 0}}}var Ar=(e)=>async(n,t,r)=>{let o=r?{...r,async:!0}:{async:!0},i=n._zod.run({value:t,issues:[]},o);if(i instanceof Promise)i=await i;return i.issues.length?Xa(e,i.issues,o):{success:!0,data:i.value}};var Mg=Symbol.for("zod.compile.invalid"),Zg=Symbol.for("zod.compile.fallback"),Yo=(e,n,t)=>{let r=e._zod.bag.validator;if(r!==void 0){if(r(n)!==Mg)return!0;if(r.definite===!0&&t===void 0)return!1}return Fg(e,n,t)};function Fg(e,n,t){let r=t?{...t,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},o=e._zod.bag.fallbackRun,i;if(o)r[Zg]=!0,i=o({value:n,issues:[]},r);else i=e._zod.run({value:n,issues:[]},r);if(i instanceof Promise)throw new en;return i.issues.length===0}var Xo=async(e,n,t)=>{let r=t?{...t,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},o=e._zod.run({value:n,issues:[]},r);if(o instanceof Promise)o=await o;return o.issues.length===0},ec=(e)=>{let n=Er(e),t=(r,o,i,s)=>{let a=i?{...i,direction:"backward"}:{direction:"backward"};return n(r,o,a,Cr(t,s))};return t};var nc=(e)=>{let n=Er(e),t=(r,o,i,s)=>n(r,o,i,Cr(t,s));return t};var tc=(e)=>{let n=Or(e),t=async(r,o,i,s)=>{let a=i?{...i,direction:"backward"}:{direction:"backward"};return await n(r,o,a,Cr(t,s))};return t};var rc=(e)=>{let n=Or(e),t=async(r,o,i,s)=>await n(r,o,i,Cr(t,s));return t};var oc=(e)=>(n,t,r)=>{let o=r?{...r,direction:"backward"}:{direction:"backward"};return Rr(e)(n,t,o)};var ic=(e)=>(n,t,r)=>Rr(e)(n,t,r);var sc=(e)=>async(n,t,r)=>{let o=r?{...r,direction:"backward"}:{direction:"backward"};return Ar(e)(n,t,o)};var ac=(e)=>async(n,t,r)=>Ar(e)(n,t,r);var cc=/^[cC][0-9a-z]{6,}$/,uc=/^[0-9a-z]+$/,lc=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,dc=/^[0-9a-vA-V]{20}$/,pc=/^[A-Za-z0-9]{27}$/,fc=/^[a-zA-Z0-9_-]{21}$/;function mc(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var gc=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var hc=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,ni=(e)=>{if(!e)return/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)};var yc=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var Jg="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function bc(){return new RegExp(Jg,"u")}var wc=/^(?:(?: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])$/,xc=/^(([0-9a-fA-F]{1,4}:){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}|:))$/;var vc=/^((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])\/([0-9]|[1-2][0-9]|3[0-2])$/,kc=/^(([0-9a-fA-F]{1,4}:){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}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Sc=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Ic=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;var Cc=/^https?$/,Ec=/^\+[1-9]\d{6,14}$/;var Oc="(?:(?:\\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])))";function Lg(e){return new RegExp(`^${e}$`)}var Rc=Lg(Oc);function ei(e){return typeof e.precision==="number"?e.precision===-1?"(?:[01]\\d|2[0-3]):[0-5]\\d":e.precision===0?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d":`(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?":"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}function Ac(e){return new RegExp(`^${ei(e)}$`)}function jc(e){let n=["Z"];if(e.offset)n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let t=`${ei({precision:e.precision,seconds:!0})}(?:${n.join("|")})`,r=e.local?`${t}|${ei({precision:e.precision})}`:t;return new RegExp(`^${Oc}T(?:${r})$`)}var Pc=/^[\s\S]{0,}$/;var ti=/^-?\d+$/,vt=/^-?\d+(?:\.\d+)?$/,$c=/^(?:true|false)$/i,_c=/^null$/i;var Nc=/^[^A-Z]*$/,Tc=/^[^a-z]*$/;var Se=b("$ZodCheck",(e,n)=>{var t;e._zod??(e._zod={}),e._zod.def=n,(t=e._zod).onattach??(t.onattach=[])});var ri=(e)=>{let n=e.value;return!Aa(n)&&n.length!==void 0},jr={number:"number",bigint:"bigint",object:"date"},oi=b("$ZodCheckLessThan",(e,n)=>{Se.init(e,n);let t=jr[typeof n.value];e._zod.check=(r)=>{if(n.inclusive?r.value<=n.value:r.value<n.value)return;r.issues.push({origin:jr[typeof r.value]??t,code:"too_big",maximum:typeof n.value==="object"?n.value.getTime():n.value,input:r.value,inclusive:n.inclusive,inst:e,continue:!n.abort})}}),ii=b("$ZodCheckGreaterThan",(e,n)=>{Se.init(e,n);let t=jr[typeof n.value];e._zod.check=(r)=>{if(n.inclusive?r.value>=n.value:r.value>n.value)return;r.issues.push({origin:jr[typeof r.value]??t,code:"too_small",minimum:typeof n.value==="object"?n.value.getTime():n.value,input:r.value,inclusive:n.inclusive,inst:e,continue:!n.abort})}}),zc=b("$ZodCheckMultipleOf",(e,n)=>{Se.init(e,n),e._zod.check=(t)=>{if(typeof t.value!==typeof n.value)throw Error("Cannot mix number and bigint in multiple_of check.");if(typeof t.value==="bigint"?n.value!==BigInt(0)&&t.value%n.value===BigInt(0):ja(t.value,n.value)===0)return;t.issues.push({origin:typeof t.value,code:"not_multiple_of",divisor:n.value,input:t.value,inst:e,continue:!n.abort})}}),Dc=b("$ZodCheckNumberFormat",(e,n)=>{Se.init(e,n),n.format=n.format||"float64";let t=n.format?.includes("int"),r=t?"int":"number",[o,i]=xr[n.format];e._zod.check=(s)=>{let a=s.value;if(t){if(!Number.isInteger(a)){s.issues.push({expected:r,format:n.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){if(a>0)s.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!n.abort});else s.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!n.abort});return}}if(a<o)s.issues.push({origin:"number",input:a,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!n.abort});if(a>i)s.issues.push({origin:"number",input:a,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!n.abort})}});var Vc=b("$ZodCheckMaxLength",(e,n)=>{var t;Se.init(e,n),(t=e._zod.def).when??(t.when=ri),e._zod.check=(r)=>{let o=r.value,i=o.length;if((typeof o==="string"&&i>n.maximum?kr(o):i)<=n.maximum)return;let a=Sr(o);r.issues.push({origin:a,code:"too_big",maximum:n.maximum,inclusive:!0,input:o,inst:e,continue:!n.abort})}}),Mc=b("$ZodCheckMinLength",(e,n)=>{var t;Se.init(e,n),(t=e._zod.def).when??(t.when=ri),e._zod.check=(r)=>{let o=r.value,i=o.length;if((typeof o==="string"&&i>=n.minimum&&i<n.minimum*2?kr(o):i)>=n.minimum)return;let a=Sr(o);r.issues.push({origin:a,code:"too_small",minimum:n.minimum,inclusive:!0,input:o,inst:e,continue:!n.abort})}}),Zc=b("$ZodCheckLengthEquals",(e,n)=>{var t;Se.init(e,n),(t=e._zod.def).when??(t.when=ri),e._zod.check=(r)=>{let o=r.value,i=o.length,s=typeof o==="string"&&i>=n.length&&i<=n.length*2?kr(o):i;if(s===n.length)return;let a=Sr(o),c=s>n.length;r.issues.push({origin:a,...c?{code:"too_big",maximum:n.length}:{code:"too_small",minimum:n.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!n.abort})}}),St=b("$ZodCheckStringFormat",(e,n)=>{var t,r;if(Se.init(e,n),n.pattern)(t=e._zod).check??(t.check=(o)=>{if(n.pattern.lastIndex=0,n.pattern.test(o.value))return;o.issues.push({origin:"string",code:"invalid_format",format:n.format,input:o.value,...n.pattern?{pattern:n.pattern.toString()}:{},inst:e,continue:!n.abort})});else(r=e._zod).check??(r.check=()=>{})}),Fc=b("$ZodCheckRegex",(e,n)=>{St.init(e,n),e._zod.check=(t)=>{if(n.pattern.lastIndex=0,n.pattern.test(t.value))return;t.issues.push({origin:"string",code:"invalid_format",format:"regex",input:t.value,pattern:n.pattern.toString(),inst:e,continue:!n.abort})}}),Jc=b("$ZodCheckLowerCase",(e,n)=>{n.pattern??(n.pattern=Nc),St.init(e,n)}),Lc=b("$ZodCheckUpperCase",(e,n)=>{n.pattern??(n.pattern=Tc),St.init(e,n)}),qc=b("$ZodCheckIncludes",(e,n)=>{Se.init(e,n);let t=fn(n.includes),r=new RegExp(typeof n.position==="number"?`^.{${n.position},}${t}`:t);n.pattern=r,e._zod.check=(o)=>{if(o.value.includes(n.includes,n.position))return;o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:n.includes,input:o.value,inst:e,continue:!n.abort})}}),Uc=b("$ZodCheckStartsWith",(e,n)=>{Se.init(e,n);let t=new RegExp(`^${fn(n.prefix)}.*`);n.pattern??(n.pattern=t),e._zod.check=(r)=>{if(r.value.startsWith(n.prefix))return;r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:n.prefix,input:r.value,inst:e,continue:!n.abort})}}),Bc=b("$ZodCheckEndsWith",(e,n)=>{Se.init(e,n);let t=new RegExp(`.*${fn(n.suffix)}$`);n.pattern??(n.pattern=t),e._zod.check=(r)=>{if(r.value.endsWith(n.suffix))return;r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:n.suffix,input:r.value,inst:e,continue:!n.abort})}});var Kc=b("$ZodCheckOverwrite",(e,n)=>{Se.init(e,n),e._zod.check=(t)=>{t.value=n.tx(t.value)}});class si{constructor(e=[],n={}){this.content=[],this.indent=0,this.args=e,this.closed=n}indented(e){this.indent+=1;try{e(this)}finally{this.indent-=1}}write(e){if(typeof e==="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let t=e.split(`
|
|
2
|
+
var Sa="0.1.0-beta.68";var Jo=["en","zh-CN","zh-TW","ja","ko","ru","fr"],Ia="en";var Fo=new Map(Jo.map((e)=>[e.toLowerCase(),e])),xg=new Set(["hk","mo","tw"]);function Ca(e){return typeof e=="string"&&Fo.get(e.toLowerCase())==e}function br(e,n="en"){for(let t of e){let r=t==null?void 0:vg(t);if(r!=null)return r}return n}function vg(e){let n=e.trim().toLowerCase();if(n.length==0)return;let t=Fo.get(n);if(t!=null)return t;let r=n.split("-");if(r[0]=="zh"){if(r.includes("hant"))return"zh-TW";if(r.includes("hans"))return"zh-CN";return r.some((o)=>xg.has(o))?"zh-TW":"zh-CN"}return Fo.get(r[0])}function Ea(e){return{en:"Imported workflow","zh-CN":"\u5BFC\u5165\u7684\u5DE5\u4F5C\u6D41","zh-TW":"\u532F\u5165\u7684\u5DE5\u4F5C\u6D41",ja:"\u30A4\u30F3\u30DD\u30FC\u30C8\u3057\u305F\u30EF\u30FC\u30AF\u30D5\u30ED\u30FC",ko:"\uAC00\uC838\uC628 \uC6CC\uD06C\uD50C\uB85C",fr:"Workflow import\xE9",ru:"\u0418\u043C\u043F\u043E\u0440\u0442\u0438\u0440\u043E\u0432\u0430\u043D\u043D\u044B\u0439 \u043F\u0440\u043E\u0446\u0435\u0441\u0441"}[e]}import{spawn as qx}from"child_process";import{readFile as Ux}from"fs/promises";import{setTimeout as Bx}from"timers/promises";var Oa=Object.prototype.hasOwnProperty;function ve(e,n){var t,r;if(e===n)return!0;if(e&&n&&(t=e.constructor)===n.constructor){if(t===Date)return e.getTime()===n.getTime();if(t===RegExp)return e.toString()===n.toString();if(t===Array){if((r=e.length)===n.length)while(r--&&ve(e[r],n[r]));return r===-1}if(!t||typeof e==="object"){r=0;for(t in e){if(Oa.call(e,t)&&++r&&!Oa.call(n,t))return!1;if(!(t in n)||!ve(e[t],n[t]))return!1}return Object.keys(n).length===r}}return e!==e&&n!==n}function ht(e){let n=Object.values(e).filter((r)=>typeof r==="number");return Object.entries(e).filter(([r,o])=>n.indexOf(+r)===-1).map(([r,o])=>o)}function qo(e,n="|"){return e.map((t)=>Ko(t)).join(n)}function yt(e,n){if(typeof n==="bigint")return n.toString();return n}class Aa{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;if(e!==void 0)this._value=e(),this._getter=void 0;return this._value}}function bt(e){return new Aa(e)}function ja(e){return e===null||e===void 0}function wr(e){let n=e.startsWith("^")?1:0,t=e.endsWith("$")?e.length-1:e.length;return e.slice(n,t)}function Pa(e,n){let t=e/n,r=Math.round(t),o=4*Number.EPSILON*Math.max(Math.abs(t),1);if(Math.abs(t-r)<o)return 0;return t-r}var Ra=Symbol("evaluating");function $a(e,n,t){let r=void 0;Object.defineProperty(e,n,{get(){if(r===Ra)return;if(r===void 0)r=Ra,r=t();return r},set(o){Object.defineProperty(e,n,{value:o})},configurable:!0})}function Ve(e,n,t){Object.defineProperty(e,n,{value:t,writable:!0,enumerable:!0,configurable:!0})}function wt(e){let n=Object.getOwnPropertyDescriptor(e,"shape");return n?.get?n.get.raw:n?.value}function rn(e){return wt(e._zod.def)??e._zod.def.shape}function _a(e,n,t){Object.defineProperty(e,n,{get(){let r=t();return Ve(this,n,r),r},enumerable:!0,configurable:!0})}function Ta(e,n,t){if(n in e)Ve(e,n,t);else e[n]=t}function En(e,n,t,r){let o=rn(n);for(let i of t){let s=Object.getOwnPropertyDescriptor(o,i);if(!s.enumerable)continue;if(s.get)_a(e,i,()=>{let a=n._zod.def.shape[i];return r?r(a,i):a});else Ta(e,i,r?r(s.value,i):s.value)}}function kg(e,n){for(let t of Reflect.ownKeys(n)){let r=Object.getOwnPropertyDescriptor(n,t);if(!r.enumerable)continue;if(r.get)_a(e,t,()=>n[t]);else Ta(e,t,r.value)}}function Me(...e){let n={};for(let t of e){let r=Object.getOwnPropertyDescriptors(t);Object.assign(n,r)}return Object.defineProperties({},n)}function Na(e){return JSON.stringify(e)}function za(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var Uo="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function qn(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var Da=bt(()=>{if(Pe.jitless)return!1;if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function On(e){if(qn(e)===!1)return!1;let n=e.constructor;if(n===void 0)return!0;if(typeof n!=="function")return!0;let t=n.prototype;if(qn(t)===!1)return!1;if(Object.prototype.hasOwnProperty.call(t,"isPrototypeOf")===!1)return!1;return!0}function Bo(e){if(On(e))return{...e};if(Array.isArray(e))return[...e];if(e instanceof Map)return new Map(e);if(e instanceof Set)return new Set(e);return e}var Va=new Set(["string","number","symbol"]);function fn(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Qe(e,n,t){let r=new e._zod.constr(n??e._zod.def);if(!n||t?.parent)r._zod.parent=e;return r}function _(e){let n=e;if(!n)return{};if(typeof n==="string")return{error:()=>n};if(n?.message!==void 0){if(n?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");n.error=n.message}if(delete n.message,typeof n.error==="string")return{...n,error:()=>n.error};return n}function Ko(e){if(typeof e==="bigint")return e.toString()+"n";if(typeof e==="string")return`"${e}"`;return`${e}`}function Ma(e){return Object.keys(e).filter((n)=>e[n]._zod.optin!==void 0&&e[n]._zod.optout==="optional")}var xr=(()=>({safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-340282346638528860000000000000000000000,340282346638528860000000000000000000000],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]}))(),Wo={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function Sg(e,n){let t=e._zod.def,r=t.checks;if(r&&r.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let i={};return En(i,e,vr(e,n)),Qe(e,Me(t,{shape:i,checks:[]}))}function vr(e,n){let t=rn(e),r=[];for(let o of Reflect.ownKeys(n)){if(!Object.getOwnPropertyDescriptor(t,o)?.enumerable)throw Error(`Unrecognized key: "${String(o)}"`);if(n[o])r.push(o)}return r}function Ig(e,n){let t=e._zod.def,r=t.checks;if(r&&r.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let i=new Set(vr(e,n)),s={};return En(s,e,Reflect.ownKeys(rn(e)).filter((a)=>!i.has(a))),Qe(e,Me(t,{shape:s,checks:[]}))}function Cg(e,n){if(!On(n))throw Error("Invalid input to extend: expected a plain object");let t=e._zod.def.checks;if(t&&t.length>0){let o=rn(e);for(let i of Reflect.ownKeys(n))if(Object.getOwnPropertyDescriptor(o,i)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return Qe(e,Me(e._zod.def,{shape:Za(e,n)}))}function Za(e,n){let t={};return En(t,e,Reflect.ownKeys(rn(e))),kg(t,n),t}function Eg(e,n){if(!On(n))throw Error("Invalid input to safeExtend: expected a plain object");return Qe(e,Me(e._zod.def,{shape:Za(e,n)}))}function Og(e,n){if(!n?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let t={};En(t,e,Reflect.ownKeys(rn(e))),En(t,n,Reflect.ownKeys(rn(n)));let r=Me(e._zod.def,{shape:t,get catchall(){return n._zod.def.catchall},checks:n._zod.def.checks??[]});return Qe(e,r)}function Fa(e,n,t,r="partial"){let i=n._zod.def.checks;if(i&&i.length>0)throw Error(`.${r}() cannot be used on object schemas containing refinements`);let a=t?new Set(vr(n,t)):void 0,c={};return En(c,n,Reflect.ownKeys(rn(n)),e&&((u,l)=>a&&!a.has(l)?u:new e({type:"optional",innerType:u}))),Qe(n,Me(n._zod.def,{shape:c,checks:[]}))}function Rg(e,n,t){let r=t?new Set(vr(n,t)):void 0,o={};return En(o,n,Reflect.ownKeys(rn(n)),(i,s)=>r&&!r.has(s)?i:new e({type:"nonoptional",innerType:i})),Qe(n,Me(n._zod.def,{shape:o}))}function Ye(e,n=0){if(e.aborted===!0)return!0;for(let t=n;t<e.issues.length;t++)if(e.issues[t]?.continue!==!0)return!0;return!1}function Ja(e,n=0){if(e.aborted===!0)return!0;for(let t=n;t<e.issues.length;t++)if(e.issues[t]?.continue===!1)return!0;return!1}function mn(e,n){return n.map((t)=>{var r;return(r=t).path??(r.path=[]),t.path.unshift(e),t})}function gt(e){return typeof e==="string"?e:e?.message}function Go(e,n,t){var r;for(let o=n;o<e.length;o++)(r=e[o]).schema??(r.schema=t)}function Xe(e,n,t){var r;let o=e.inst?._zod?.traits;if(o?.has("$ZodType"))if(o.has("$ZodCheck"))(r=e).schema??(r.schema=e.inst);else e.schema=e.inst;let i=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,s=e.message?e.message:gt(e.inst?._zod.def?.error?.(e))??gt(i?.(e))??gt(n?.error?.(e))??gt(t.customError?.(e))??gt(t.localeError?.(e))??"Invalid input",a={};for(let c of Object.keys(e)){if(c==="inst"||c==="schema"||c==="continue"||c==="input"||c==="__proto__")continue;a[c]=e[c]}if(a.path??(a.path=[]),a.message=s,n?.reportInput)a.input=e.input;return a}var Ag=/[\uD800-\uDBFF]/;function kr(e){let n=e.length;if(!Ag.test(e))return n;let t=n;for(let r=0;r<n-1;r++)if((e.charCodeAt(r)&64512)===55296&&(e.charCodeAt(r+1)&64512)===56320)t--,r++;return t}function Sr(e){if(Array.isArray(e))return"array";if(typeof e==="string")return"string";return"unknown"}function La(e){let n=typeof e;switch(n){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let t=e;if(t&&Object.getPrototypeOf(t)!==Object.prototype&&"constructor"in t&&t.constructor)return t.constructor.name}}return n}function Rn(...e){let[n,t,r]=e;if(typeof n==="string")return{message:n,code:"custom",input:t,inst:r};return{...n}}function qa(e,n){for(let t in n){let r=Object.getOwnPropertyDescriptor(n,t);if(r.get)Object.defineProperty(e,t,{...r,enumerable:!1});else jg(e,t,r.value)}}function on(e,n,t,r=!0){return Object.defineProperty(e,n,{configurable:!0,writable:!0,enumerable:r,value:t}),t}function Ir(e,n,t){return on(e,n,t,!1)}function Ua(e,n){for(let t in e){let r=e[t];Object.defineProperty(n,t,{configurable:!0,enumerable:!0,get(){return on(this,t,r(this))},set(o){on(this,t,o)}})}return n}function jg(e,n,t){Object.defineProperty(e,n,{configurable:!0,get(){return this==null?t:on(this,n,t.bind(this))},set(r){on(this,n,r)}})}function Pg(e,n){let t=Object.getPrototypeOf(e);return n in t?void 0:t}var Lo,pn=!1,$g={configurable:!0,get(){pn=!0;return}};function B(e,n,t){let r=Object.getPrototypeOf(e._zod);if(n in r&&Lo!==e._zod){Lo=void 0;return}Lo=e._zod,Object.defineProperty(r,n,{configurable:!0,get(){Object.defineProperty(this,n,$g);let o=pn;pn=!1;try{let i=t(this);if(pn)delete this[n];else Object.defineProperty(this,n,{configurable:!0,writable:!0,value:i});return pn=pn||o,i}catch(i){throw delete this[n],pn=pn||o,i}},set(o){Object.defineProperty(this,n,{configurable:!0,writable:!0,value:o})}})}function _g(e,n,t,r){let o=Pg(e,n);if(!o)return;Object.defineProperty(o,n,{configurable:!0,get(){let i={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,n,i),i.value=t(this),Object.defineProperty(this,n,i),i.value},set(i){Object.defineProperty(this,n,{configurable:!0,writable:!0,enumerable:r,value:i})}})}var Tg="~constantCatch";function Ba(e){let n=()=>e;return n[Tg]=!0,n}var Ka;var Ho={value:void 0,enumerable:!1},Wa="captureStackTrace"in Error?Error:null;function Ng(e){let n=Wa;if(n){let t=n.stackTraceLimit;if(typeof t==="number"){try{n.stackTraceLimit=0}catch{return Wa=null,new e}try{return new e}finally{n.stackTraceLimit=t}}}return new e}function b(e,n,t,r){let o={};function i(m){this.def=m,this.constr=f,this.traits=new Set}i.prototype=o;let s=t,a=s&&new WeakSet;function c(m,h){if(!m._zod){Ho.value=new i(h);try{Object.defineProperty(m,"_zod",Ho)}finally{Ho.value=void 0}}else if(m._zod.traits.has(e))return;if(m._zod.traits.add(e),n(m,h),a){let E=Object.getPrototypeOf(m),P=m._zod.constr.prototype,T=E;while(T&&T!==P)T=Object.getPrototypeOf(T);let L=T??E;if(!a.has(L))a.add(L),qa(L,s)}let g=f.prototype;for(let E in g){if(!Object.prototype.hasOwnProperty.call(g,E))continue;if(!(E in m))m[E]=g[E].bind(m)}}let u=r?.Parent??Object;class l extends u{}Object.defineProperty(l,"name",{value:e});function f(m){let h=r?.Parent?Ng(l):this;c(h,m);let g=h._zod.deferred;if(g){for(let P of g)P();h._zod.deferred=void 0}let E=globalThis.__zod_globalConfig?.postProcessor;if(E)E(h);return h}return Object.defineProperty(f,"init",{value:c}),Object.defineProperty(f,Symbol.hasInstance,{value:(m)=>{if(r?.Parent&&m instanceof r.Parent)return!0;return m?._zod?.traits?.has(e)}}),Object.defineProperty(f,"name",{value:e}),f}class en extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class xt extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`);this.name="ZodEncodeError"}}(Ka=globalThis).__zod_globalConfig??(Ka.__zod_globalConfig={});var Pe=globalThis.__zod_globalConfig;function Ze(e){if(e)Object.assign(Pe,e);return Pe}function zg(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,yt,2)),e.message}function Dg(e){this._zod.message=e}var Vg={get:zg,set:Dg,enumerable:!0,configurable:!0},Yo={value:void 0,enumerable:!1},Ga=new WeakSet([Object.prototype,Error.prototype]),Ha=(e,n)=>{e.name="$ZodError",Yo.value=n,Object.defineProperty(e,"issues",Yo),Yo.value=void 0,Object.defineProperty(e,"message",Vg);let t=Object.getPrototypeOf(e);if(!Ga.has(t))Ga.add(t),Object.defineProperty(t,"toString",{configurable:!0,enumerable:!1,get(){let r=()=>this.message;return Object.defineProperty(this,"toString",{value:r,configurable:!0,writable:!0}),r},set(r){Object.defineProperty(this,"toString",{value:r,configurable:!0,writable:!0})}})},Qa=b("$ZodError",Ha),ev=b("$ZodError",Ha,void 0,{Parent:Error});function Mg(e,n,t){if(!Object.prototype.hasOwnProperty.call(e,n))if(n==="__proto__")Object.defineProperty(e,n,{value:t(),writable:!0,enumerable:!0,configurable:!0});else e[n]=t();return e[n]}function Ya(e,n=(t)=>t.message){let t={},r=[];for(let o of e.issues)if(o.path.length>0)Mg(t,o.path[0],()=>[]).push(n(o));else r.push(n(o));return{formErrors:r,fieldErrors:t}}function Xa(e,n=(t)=>t.message){let t={_errors:[]},r=(o,i=[])=>{for(let s of o.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map((a)=>r({issues:a},[...i,...s.path]));else if(s.code==="invalid_key")r({issues:s.issues},[...i,...s.path]);else if(s.code==="invalid_element")r({issues:s.issues},[...i,...s.path]);else{let a=[...i,...s.path];if(a.length===0)t._errors.push(n(s));else{let c=t,u=0;while(u<a.length){let l=a[u],f=u===a.length-1;if(l==="_errors"){if(f)c._errors.push(n(s));u++;continue}if(!Object.prototype.hasOwnProperty.call(c,l))Object.defineProperty(c,l,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let m=c[l];if(f)m._errors.push(n(s));c=m,u++}}}};return r(e),t}function Cr(e,n){return{callee:n?.callee??e,Err:n?.Err}}var Er=(e)=>{let n=(t,r,o,i)=>{let s=o?{...o,async:!1}:{async:!1},a=t._zod.run({value:r,issues:[]},s);if(a instanceof Promise)throw new en;if(a.issues.length){let c=new(i?.Err??e)(a.issues.map((u)=>Xe(u,s,Ze())));throw Uo(c,i?.callee??n),c}return a.value};return n};var Or=(e)=>{let n=async(t,r,o,i)=>{let s=o?{...o,async:!0}:{async:!0},a=t._zod.run({value:r,issues:[]},s);if(a instanceof Promise)a=await a;if(a.issues.length){let c=new(i?.Err??e)(a.issues.map((u)=>Xe(u,s,Ze())));throw Uo(c,i?.callee??n),c}return a.value};return n};var Rr=(e)=>(n,t,r)=>{let o=r?{...r,async:!1}:{async:!1},i=n._zod.run({value:t,issues:[]},o);if(i instanceof Promise)throw new en;return i.issues.length?ec(e,i.issues,o):{success:!0,data:i.value}};function ec(e,n,t){let r;return{success:!1,get error(){if(!r)r=new e(n.map((o)=>Xe(o,t,Ze()))),n=void 0,t=void 0;return r},set error(o){r=o,n=void 0,t=void 0}}}var Ar=(e)=>async(n,t,r)=>{let o=r?{...r,async:!0}:{async:!0},i=n._zod.run({value:t,issues:[]},o);if(i instanceof Promise)i=await i;return i.issues.length?ec(e,i.issues,o):{success:!0,data:i.value}};var Zg=Symbol.for("zod.compile.invalid"),Fg=Symbol.for("zod.compile.fallback"),Xo=(e,n,t)=>{let r=e._zod.bag.validator;if(r!==void 0){if(r(n)!==Zg)return!0;if(r.definite===!0&&t===void 0)return!1}return Jg(e,n,t)};function Jg(e,n,t){let r=t?{...t,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},o=e._zod.bag.fallbackRun,i;if(o)r[Fg]=!0,i=o({value:n,issues:[]},r);else i=e._zod.run({value:n,issues:[]},r);if(i instanceof Promise)throw new en;return i.issues.length===0}var ei=async(e,n,t)=>{let r=t?{...t,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},o=e._zod.run({value:n,issues:[]},r);if(o instanceof Promise)o=await o;return o.issues.length===0},nc=(e)=>{let n=Er(e),t=(r,o,i,s)=>{let a=i?{...i,direction:"backward"}:{direction:"backward"};return n(r,o,a,Cr(t,s))};return t};var tc=(e)=>{let n=Er(e),t=(r,o,i,s)=>n(r,o,i,Cr(t,s));return t};var rc=(e)=>{let n=Or(e),t=async(r,o,i,s)=>{let a=i?{...i,direction:"backward"}:{direction:"backward"};return await n(r,o,a,Cr(t,s))};return t};var oc=(e)=>{let n=Or(e),t=async(r,o,i,s)=>await n(r,o,i,Cr(t,s));return t};var ic=(e)=>(n,t,r)=>{let o=r?{...r,direction:"backward"}:{direction:"backward"};return Rr(e)(n,t,o)};var sc=(e)=>(n,t,r)=>Rr(e)(n,t,r);var ac=(e)=>async(n,t,r)=>{let o=r?{...r,direction:"backward"}:{direction:"backward"};return Ar(e)(n,t,o)};var cc=(e)=>async(n,t,r)=>Ar(e)(n,t,r);var uc=/^[cC][0-9a-z]{6,}$/,lc=/^[0-9a-z]+$/,dc=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,pc=/^[0-9a-vA-V]{20}$/,fc=/^[A-Za-z0-9]{27}$/,mc=/^[a-zA-Z0-9_-]{21}$/;function gc(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var hc=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var yc=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,ti=(e)=>{if(!e)return/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)};var bc=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var Lg="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function wc(){return new RegExp(Lg,"u")}var xc=/^(?:(?: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])$/,vc=/^(([0-9a-fA-F]{1,4}:){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}|:))$/;var kc=/^((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])\/([0-9]|[1-2][0-9]|3[0-2])$/,Sc=/^(([0-9a-fA-F]{1,4}:){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}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Ic=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Cc=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;var Ec=/^https?$/,Oc=/^\+[1-9]\d{6,14}$/;var Rc="(?:(?:\\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])))";function qg(e){return new RegExp(`^${e}$`)}var Ac=qg(Rc);function ni(e){return typeof e.precision==="number"?e.precision===-1?"(?:[01]\\d|2[0-3]):[0-5]\\d":e.precision===0?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d":`(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?":"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}function jc(e){return new RegExp(`^${ni(e)}$`)}function Pc(e){let n=["Z"];if(e.offset)n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let t=`${ni({precision:e.precision,seconds:!0})}(?:${n.join("|")})`,r=e.local?`${t}|${ni({precision:e.precision})}`:t;return new RegExp(`^${Rc}T(?:${r})$`)}var $c=/^[\s\S]{0,}$/;var ri=/^-?\d+$/,vt=/^-?\d+(?:\.\d+)?$/,_c=/^(?:true|false)$/i,Tc=/^null$/i;var Nc=/^[^A-Z]*$/,zc=/^[^a-z]*$/;var Se=b("$ZodCheck",(e,n)=>{var t;e._zod??(e._zod={}),e._zod.def=n,(t=e._zod).onattach??(t.onattach=[])});var oi=(e)=>{let n=e.value;return!ja(n)&&n.length!==void 0},jr={number:"number",bigint:"bigint",object:"date"},ii=b("$ZodCheckLessThan",(e,n)=>{Se.init(e,n);let t=jr[typeof n.value];e._zod.check=(r)=>{if(n.inclusive?r.value<=n.value:r.value<n.value)return;r.issues.push({origin:jr[typeof r.value]??t,code:"too_big",maximum:typeof n.value==="object"?n.value.getTime():n.value,input:r.value,inclusive:n.inclusive,inst:e,continue:!n.abort})}}),si=b("$ZodCheckGreaterThan",(e,n)=>{Se.init(e,n);let t=jr[typeof n.value];e._zod.check=(r)=>{if(n.inclusive?r.value>=n.value:r.value>n.value)return;r.issues.push({origin:jr[typeof r.value]??t,code:"too_small",minimum:typeof n.value==="object"?n.value.getTime():n.value,input:r.value,inclusive:n.inclusive,inst:e,continue:!n.abort})}}),Dc=b("$ZodCheckMultipleOf",(e,n)=>{Se.init(e,n),e._zod.check=(t)=>{if(typeof t.value!==typeof n.value)throw Error("Cannot mix number and bigint in multiple_of check.");if(typeof t.value==="bigint"?n.value!==BigInt(0)&&t.value%n.value===BigInt(0):Pa(t.value,n.value)===0)return;t.issues.push({origin:typeof t.value,code:"not_multiple_of",divisor:n.value,input:t.value,inst:e,continue:!n.abort})}}),Vc=b("$ZodCheckNumberFormat",(e,n)=>{Se.init(e,n),n.format=n.format||"float64";let t=n.format?.includes("int"),r=t?"int":"number",[o,i]=xr[n.format];e._zod.check=(s)=>{let a=s.value;if(t){if(!Number.isInteger(a)){s.issues.push({expected:r,format:n.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){if(a>0)s.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!n.abort});else s.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!n.abort});return}}if(a<o)s.issues.push({origin:"number",input:a,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!n.abort});if(a>i)s.issues.push({origin:"number",input:a,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!n.abort})}});var Mc=b("$ZodCheckMaxLength",(e,n)=>{var t;Se.init(e,n),(t=e._zod.def).when??(t.when=oi),e._zod.check=(r)=>{let o=r.value,i=o.length;if((typeof o==="string"&&i>n.maximum?kr(o):i)<=n.maximum)return;let a=Sr(o);r.issues.push({origin:a,code:"too_big",maximum:n.maximum,inclusive:!0,input:o,inst:e,continue:!n.abort})}}),Zc=b("$ZodCheckMinLength",(e,n)=>{var t;Se.init(e,n),(t=e._zod.def).when??(t.when=oi),e._zod.check=(r)=>{let o=r.value,i=o.length;if((typeof o==="string"&&i>=n.minimum&&i<n.minimum*2?kr(o):i)>=n.minimum)return;let a=Sr(o);r.issues.push({origin:a,code:"too_small",minimum:n.minimum,inclusive:!0,input:o,inst:e,continue:!n.abort})}}),Fc=b("$ZodCheckLengthEquals",(e,n)=>{var t;Se.init(e,n),(t=e._zod.def).when??(t.when=oi),e._zod.check=(r)=>{let o=r.value,i=o.length,s=typeof o==="string"&&i>=n.length&&i<=n.length*2?kr(o):i;if(s===n.length)return;let a=Sr(o),c=s>n.length;r.issues.push({origin:a,...c?{code:"too_big",maximum:n.length}:{code:"too_small",minimum:n.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!n.abort})}}),St=b("$ZodCheckStringFormat",(e,n)=>{var t,r;if(Se.init(e,n),n.pattern)(t=e._zod).check??(t.check=(o)=>{if(n.pattern.lastIndex=0,n.pattern.test(o.value))return;o.issues.push({origin:"string",code:"invalid_format",format:n.format,input:o.value,...n.pattern?{pattern:n.pattern.toString()}:{},inst:e,continue:!n.abort})});else(r=e._zod).check??(r.check=()=>{})}),Jc=b("$ZodCheckRegex",(e,n)=>{St.init(e,n),e._zod.check=(t)=>{if(n.pattern.lastIndex=0,n.pattern.test(t.value))return;t.issues.push({origin:"string",code:"invalid_format",format:"regex",input:t.value,pattern:n.pattern.toString(),inst:e,continue:!n.abort})}}),Lc=b("$ZodCheckLowerCase",(e,n)=>{n.pattern??(n.pattern=Nc),St.init(e,n)}),qc=b("$ZodCheckUpperCase",(e,n)=>{n.pattern??(n.pattern=zc),St.init(e,n)}),Uc=b("$ZodCheckIncludes",(e,n)=>{Se.init(e,n);let t=fn(n.includes),r=new RegExp(typeof n.position==="number"?`^.{${n.position},}${t}`:t);n.pattern=r,e._zod.check=(o)=>{if(o.value.includes(n.includes,n.position))return;o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:n.includes,input:o.value,inst:e,continue:!n.abort})}}),Bc=b("$ZodCheckStartsWith",(e,n)=>{Se.init(e,n);let t=new RegExp(`^${fn(n.prefix)}.*`);n.pattern??(n.pattern=t),e._zod.check=(r)=>{if(r.value.startsWith(n.prefix))return;r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:n.prefix,input:r.value,inst:e,continue:!n.abort})}}),Kc=b("$ZodCheckEndsWith",(e,n)=>{Se.init(e,n);let t=new RegExp(`.*${fn(n.suffix)}$`);n.pattern??(n.pattern=t),e._zod.check=(r)=>{if(r.value.endsWith(n.suffix))return;r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:n.suffix,input:r.value,inst:e,continue:!n.abort})}});var Wc=b("$ZodCheckOverwrite",(e,n)=>{Se.init(e,n),e._zod.check=(t)=>{t.value=n.tx(t.value)}});class ai{constructor(e=[],n={}){this.content=[],this.indent=0,this.args=e,this.closed=n}indented(e){this.indent+=1;try{e(this)}finally{this.indent-=1}}write(e){if(typeof e==="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let t=e.split(`
|
|
3
3
|
`).filter((i)=>i),r=Math.min(...t.map((i)=>i.length-i.trimStart().length)),o=t.map((i)=>i.slice(r)).map((i)=>" ".repeat(this.indent*2)+i);for(let i of o)this.content.push(i)}compile(){let e=Function,n=this?.content??[""];return new e(...Object.keys(this.closed),`return function (${this.args.join(", ")}) {
|
|
4
4
|
${n.join(`
|
|
5
5
|
`)}
|
|
6
|
-
};`)(...Object.values(this.closed))}}var Gc={major:4,minor:6,patch:5};var ie=b("$ZodType",(e,n)=>{var t;e??(e={}),e._zod.def=n,e._zod.bag=e._zod.bag||{},e._zod.version=Gc;let r=e._zod.def.checks,o=e._zod.traits.has("$ZodCheck")?[e,...r??[]]:r?.length?[...r]:[];for(let i of o)for(let s of i._zod.onattach)s(e);if(o.length===0)(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let i=(a,c,u)=>{if(a.memo)return a;let l=Ye(a),p;for(let m of c){if(m._zod.def.when){if(Fa(a))continue;if(!m._zod.def.when(a))continue}else if(l)continue;let h=a.issues.length,g=m._zod.check(a);if(g instanceof Promise&&u?.async===!1)throw new en;if(p||g instanceof Promise)p=(p??Promise.resolve()).then(async()=>{if(await g,a.issues.length===h)return;if(Wo(a.issues,h,e),!l)l=Ye(a,h)});else{if(a.issues.length===h)continue;if(Wo(a.issues,h,e),!l)l=Ye(a,h)}}if(p)return p.then(()=>a);return a},s=(a,c,u)=>{if(Ye(a))return a.aborted=!0,a;let l=i(c,o,u);if(l instanceof Promise){if(u.async===!1)throw new en;return l.then((p)=>e._zod.parse(p,u))}return e._zod.parse(l,u)};e._zod.run=(a,c)=>{if(c.skipChecks)return e._zod.parse(a,c);if(c.direction==="backward"){let l=e._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});if(l instanceof Promise)return l.then((p)=>s(p,a,c));return s(l,a,c)}let u=e._zod.parse(a,c);if(u instanceof Promise){if(c.async===!1)throw new en;return u.then((l)=>i(l,o,c))}return i(u,o,c)}}},{get "~standard"(){return Ir(this,"~standard",ci(this))},set "~standard"(e){on(this,"~standard",e)}}),su=(e,n)=>e.issues.length?{issues:e.issues.map((t)=>Xe(t,n,Ze()))}:{value:e.value};async function qg(e,n){let t={async:!0};return su(await e._zod.run({value:n,issues:[]},t),t)}function ci(e){return{validate:(n)=>{let t={async:!1};try{let r=e._zod.run({value:n,issues:[]},t);if(!(r instanceof Promise))return su(r,t)}catch(r){}return qg(e,n)},vendor:"zod",version:1}}var Nr=b("$ZodString",(e,n)=>{ie.init(e,n),e._zod.pattern=n.pattern??Pc,e._zod.parse=(t,r)=>{if(n.coerce)try{t.value=String(t.value)}catch(o){}if(typeof t.value==="string")return t;return t.issues.push({expected:"string",code:"invalid_type",input:t.value,inst:e}),t}}),ae=b("$ZodStringFormat",(e,n)=>{St.init(e,n),Nr.init(e,n)}),au=b("$ZodGUID",(e,n)=>{n.pattern??(n.pattern=hc),ae.init(e,n)}),cu=b("$ZodUUID",(e,n)=>{if(n.version){let r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[n.version];if(r===void 0)throw Error(`Invalid UUID version: "${n.version}"`);n.pattern??(n.pattern=ni(r))}else n.pattern??(n.pattern=ni());ae.init(e,n)}),uu=b("$ZodEmail",(e,n)=>{n.pattern??(n.pattern=yc),ae.init(e,n)}),lu=1,$r=2;function du(e){try{if(typeof URL<"u"&&typeof URL.canParse==="function")return URL.canParse(e);return new URL(e),!0}catch{return!1}}function Ug(e,n){if(!("normalize"in n)&&!("hostname"in n)&&!("protocol"in n))return du(e)||$r;return Bg(e,n)}function Bg(e,n){if(!n.normalize&&n.protocol?.source===Cc.source&&!/^https?:\/\//i.test(e))return lu;try{if(typeof URL<"u"){let t=URL;if(typeof t.parse==="function")return t.parse(e)??$r}return new URL(e)}catch{return $r}}var Kg=/[\t\n\r]/g;function Hc(e){return e.replace(Kg,"")}function Wg(e,n){return n.lastIndex=0,n.test(e.hostname)}function Gg(e,n){return n.lastIndex=0,n.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var pu=b("$ZodURL",(e,n)=>{ae.init(e,n),e._zod.check=(t)=>{try{let r=t.value.trim(),o=Ug(r,n);if(o===lu){t.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:t.value,inst:e,continue:!n.abort});return}if(o===$r){t.issues.push({code:"invalid_format",format:"url",input:t.value,inst:e,continue:!n.abort});return}if(o===!0){t.value=Hc(r);return}if(n.hostname&&!Wg(o,n.hostname))t.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:n.hostname.source,input:t.value,inst:e,continue:!n.abort});if(n.protocol&&!Gg(o,n.protocol))t.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:n.protocol.source,input:t.value,inst:e,continue:!n.abort});t.value=n.normalize?o.href:Hc(r);return}catch(r){t.issues.push({code:"invalid_format",format:"url",input:t.value,inst:e,continue:!n.abort})}}}),fu=b("$ZodEmoji",(e,n)=>{n.pattern??(n.pattern=bc()),ae.init(e,n)}),mu=b("$ZodNanoID",(e,n)=>{if(n.length!==void 0&&(!Number.isInteger(n.length)||n.length<1))throw Error(`Invalid nanoid length: ${n.length}`);n.pattern??(n.pattern=n.length===void 0?fc:mc(n.length)),ae.init(e,n)}),gu=b("$ZodCUID",(e,n)=>{n.pattern??(n.pattern=cc),ae.init(e,n)}),hu=b("$ZodCUID2",(e,n)=>{n.pattern??(n.pattern=uc),ae.init(e,n)}),yu=b("$ZodULID",(e,n)=>{n.pattern??(n.pattern=lc),ae.init(e,n)}),bu=b("$ZodXID",(e,n)=>{n.pattern??(n.pattern=dc),ae.init(e,n)}),wu=b("$ZodKSUID",(e,n)=>{n.pattern??(n.pattern=pc),ae.init(e,n)}),xu=b("$ZodISODateTime",(e,n)=>{n.pattern??(n.pattern=jc(n)),ae.init(e,n)}),vu=b("$ZodISODate",(e,n)=>{n.pattern??(n.pattern=Rc),ae.init(e,n)}),ku=b("$ZodISOTime",(e,n)=>{n.pattern??(n.pattern=Ac(n)),ae.init(e,n)}),Su=b("$ZodISODuration",(e,n)=>{n.pattern??(n.pattern=gc),ae.init(e,n)}),Iu=b("$ZodIPv4",(e,n)=>{n.pattern??(n.pattern=wc),ae.init(e,n)}),Hg=/^[0-9a-fA-F:.]+$/;function Cu(e){if(!Hg.test(e))return!1;return du(`http://[${e}]`)}var Eu=b("$ZodIPv6",(e,n)=>{n.pattern??(n.pattern=xc),ae.init(e,n),e._zod.check=(t)=>{if(!Cu(t.value))t.issues.push({code:"invalid_format",format:"ipv6",input:t.value,inst:e,continue:!n.abort})}});var Ou=b("$ZodCIDRv4",(e,n)=>{n.pattern??(n.pattern=vc),ae.init(e,n)});function Qg(e){let n=e.split("/");if(n.length!==2)return!1;let[t,r]=n;if(!r)return!1;let o=Number(r);if(`${o}`!==r)return!1;if(o<0||o>128)return!1;return Cu(t)}var Ru=b("$ZodCIDRv6",(e,n)=>{n.pattern??(n.pattern=kc),ae.init(e,n),e._zod.check=(t)=>{if(!Qg(t.value))t.issues.push({code:"invalid_format",format:"cidrv6",input:t.value,inst:e,continue:!n.abort})}});function Au(e){if(e==="")return!0;if(/\s/.test(e))return!1;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var ui=/^[0-9a-zA-Z+/]*={0,2}$/,ju=b("$ZodBase64",(e,n)=>{n.pattern??(n.pattern=ui),ae.init(e,n),e._zod.check=(t)=>{if(Au(t.value))return;t.issues.push({code:"invalid_format",format:"base64",input:t.value,inst:e,continue:!n.abort})}}),Tr=/^[A-Za-z0-9_-]*$/;function Yg(e){if(!Tr.test(e))return!1;let n=e.replace(/[-_]/g,(r)=>r==="-"?"+":"/"),t=n.padEnd(Math.ceil(n.length/4)*4,"=");return Au(t)}var Pu=b("$ZodBase64URL",(e,n)=>{n.pattern??(n.pattern=Tr),ae.init(e,n),e._zod.check=(t)=>{if(Yg(t.value))return;t.issues.push({code:"invalid_format",format:"base64url",input:t.value,inst:e,continue:!n.abort})}}),$u=b("$ZodE164",(e,n)=>{n.pattern??(n.pattern=Ec),ae.init(e,n)});function Xg(e,n=null){try{let t=e.split(".");if(t.length!==3)return!1;let[r]=t;if(!r)return!1;let o=JSON.parse(atob(r));if("typ"in o&&o?.typ!=="JWT")return!1;if(!o.alg)return!1;if(n&&(!("alg"in o)||o.alg!==n))return!1;return!0}catch{return!1}}var _u=b("$ZodJWT",(e,n)=>{ae.init(e,n),e._zod.check=(t)=>{if(Xg(t.value,n.alg))return;t.issues.push({code:"invalid_format",format:"jwt",input:t.value,inst:e,continue:!n.abort})}});var li=b("$ZodNumber",(e,n)=>{ie.init(e,n),e._zod.pattern=vt,e._zod.parse=(t,r)=>{if(n.coerce)try{t.value=Number(t.value)}catch(s){}let o=t.value;if(typeof o==="number"&&!Number.isNaN(o)&&Number.isFinite(o))return t;let i=typeof o==="number"?Number.isNaN(o)?"NaN":!Number.isFinite(o)?String(o):void 0:void 0;return t.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...i?{received:i}:{}}),t}}),Nu=b("$ZodNumberFormat",(e,n)=>{Dc.init(e,n),li.init(e,n)}),Tu=b("$ZodBoolean",(e,n)=>{ie.init(e,n),e._zod.pattern=$c,e._zod.parse=(t,r)=>{if(n.coerce)try{t.value=Boolean(t.value)}catch(i){}let o=t.value;if(typeof o==="boolean")return t;return t.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),t}});var zu=b("$ZodNull",(e,n)=>{ie.init(e,n),e._zod.pattern=_c,e._zod.values=new Set([null]),e._zod.parse=(t,r)=>{let o=t.value;if(o===null)return t;return t.issues.push({expected:"null",code:"invalid_type",input:o,inst:e}),t}});var Du=b("$ZodUnknown",(e,n)=>{ie.init(e,n),e._zod.parse=(t)=>t}),Vu=b("$ZodNever",(e,n)=>{ie.init(e,n),e._zod.parse=(t,r)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:e}),t)});function Qc(e,n,t){if(e.issues.length)n.issues.push(...mn(t,e.issues));n.value[t]=e.value}var Mu=b("$ZodArray",(e,n)=>{ie.init(e,n);let t=Pe.memoizer;t?.attach(e),e._zod.parse=(r,o)=>{let i=r.value;if(!Array.isArray(i))return r.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),r;r.value=t?t.alloc(e,r,Array(i.length),o):Array(i.length);let s=[],a=o?.abortEarly;for(let c=0;c<i.length;c++){let u=i[c],l=n.element._zod.run({value:u,issues:[]},o);if(l instanceof Promise)s.push(l.then((p)=>Qc(p,r,c)));else if(Qc(l,r,c),a&&l.issues.length!==0&&Ye(l))break}if(s.length)return Promise.all(s).then(()=>r);return r}});function _r(e,n,t,r,o,i){let s=t in r,a=i==="optional";if(!s&&a&&o==="optional")return;if(e.issues.length){if(o!==void 0&&a&&!s)return;n.issues.push(...mn(t,e.issues))}if(!s&&o===void 0){if(!e.issues.length)n.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[t]});return}if(e.value===void 0){if(s||o==="defaulted"&&!a)n.value[t]=void 0}else n.value[t]=e.value}var eh=[];function Zu(e){let n=Object.keys(e.shape),t=Object.getOwnPropertySymbols(e.shape),r=t.length?t:eh,o=r.length?[...n,...r]:n;for(let s of o)if(!e.shape?.[s]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${String(s)}": expected a Zod schema`);let i=Va(e.shape);return{...e,allKeys:o,symbolKeys:r,keySet:new Set(n),numKeys:n.length,optionalKeys:new Set(i)}}function Fu(e,n,t,r,o,i,s){let a=[],c=o.keySet,u=o.catchall._zod,l=u.def.type,{optin:p,optout:m}=u,h=0;for(let g in n){if(s&&t.issues.length!==h){if(Ye(t,h))break;h=t.issues.length}if(c.has(g))continue;if(g==="__proto__"){if(l==="never")a.push(g);continue}if(l==="never"){a.push(g);continue}let E=u.run({value:n[g],issues:[]},r);if(E instanceof Promise)e.push(E.then((P)=>_r(P,t,g,n,p,m)));else _r(E,t,g,n,p,m)}if(a.length)t.issues.push({code:"unrecognized_keys",keys:a,input:n,inst:i,continue:!0});if(!e.length)return t;return Promise.all(e).then(()=>t)}var nh=b("$ZodObject",(e,n)=>{ie.init(e,n);let t=Object.getOwnPropertyDescriptor(n,"shape"),r=t?.get?t.get.raw:n.shape??{};if(r){let u=()=>{let l={...r};return Object.defineProperty(n,"shape",{value:l}),u.raw=l,l};u.raw=r,Object.defineProperty(n,"shape",{get:u})}let o=bt(()=>Zu(n));B(e,"propValues",(u)=>{let l=u.def.shape,p={};for(let m in l){let h=l[m]._zod;if(h.values){if(!Object.prototype.hasOwnProperty.call(p,m))Ve(p,m,new Set);for(let g of h.values)p[m].add(g);if(h.optin!==void 0)p[m].add(void 0)}}return p});let i=qn,s=n.catchall,a,c=Pe.memoizer;c?.attach(e),e._zod.parse=(u,l)=>{a??(a=o.value);let p=u.value;if(!i(p))return u.issues.push({expected:"object",code:"invalid_type",input:p,inst:e}),u;u.value=c?c.alloc(e,u,{},l):{};let m=[],h=a.shape,g=l?.abortEarly,E=u.issues.length;for(let P of a.allKeys){if(g&&u.issues.length!==E){if(Ye(u,E))break;E=u.issues.length}if(P==="__proto__")continue;let N=h[P],L=N._zod.optin,M=N._zod.optout,De=N._zod.run({value:p[P],issues:[]},l);if(De instanceof Promise)m.push(De.then((pe)=>_r(pe,u,P,p,L,M)));else _r(De,u,P,p,L,M)}if(!s)return m.length?Promise.all(m).then(()=>u):u;return Fu(m,p,u,l,o.value,e,g===!0)}}),Ju=b("$ZodObjectJIT",(e,n)=>{nh.init(e,n);let t=e._zod.parse,r=bt(()=>Zu(n)),o=Pe.memoizer,i=(h)=>{let g=r.value,E=g.symbolKeys,P=new si(["payload","ctx"],{shape:h,inst:e,memo:o,syms:E}),N=(pe)=>`shape[${pe}]._zod.run({ value: input[${pe}], issues: [] }, ctx)`,L=(pe,Y)=>`
|
|
6
|
+
};`)(...Object.values(this.closed))}}var Hc={major:4,minor:6,patch:5};var ie=b("$ZodType",(e,n)=>{var t;e??(e={}),e._zod.def=n,e._zod.bag=e._zod.bag||{},e._zod.version=Hc;let r=e._zod.def.checks,o=e._zod.traits.has("$ZodCheck")?[e,...r??[]]:r?.length?[...r]:[];for(let i of o)for(let s of i._zod.onattach)s(e);if(o.length===0)(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let i=(a,c,u)=>{if(a.memo)return a;let l=Ye(a),f;for(let m of c){if(m._zod.def.when){if(Ja(a))continue;if(!m._zod.def.when(a))continue}else if(l)continue;let h=a.issues.length,g=m._zod.check(a);if(g instanceof Promise&&u?.async===!1)throw new en;if(f||g instanceof Promise)f=(f??Promise.resolve()).then(async()=>{if(await g,a.issues.length===h)return;if(Go(a.issues,h,e),!l)l=Ye(a,h)});else{if(a.issues.length===h)continue;if(Go(a.issues,h,e),!l)l=Ye(a,h)}}if(f)return f.then(()=>a);return a},s=(a,c,u)=>{if(Ye(a))return a.aborted=!0,a;let l=i(c,o,u);if(l instanceof Promise){if(u.async===!1)throw new en;return l.then((f)=>e._zod.parse(f,u))}return e._zod.parse(l,u)};e._zod.run=(a,c)=>{if(c.skipChecks)return e._zod.parse(a,c);if(c.direction==="backward"){let l=e._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});if(l instanceof Promise)return l.then((f)=>s(f,a,c));return s(l,a,c)}let u=e._zod.parse(a,c);if(u instanceof Promise){if(c.async===!1)throw new en;return u.then((l)=>i(l,o,c))}return i(u,o,c)}}},{get "~standard"(){return Ir(this,"~standard",ui(this))},set "~standard"(e){on(this,"~standard",e)}}),au=(e,n)=>e.issues.length?{issues:e.issues.map((t)=>Xe(t,n,Ze()))}:{value:e.value};async function Ug(e,n){let t={async:!0};return au(await e._zod.run({value:n,issues:[]},t),t)}function ui(e){return{validate:(n)=>{let t={async:!1};try{let r=e._zod.run({value:n,issues:[]},t);if(!(r instanceof Promise))return au(r,t)}catch(r){}return Ug(e,n)},vendor:"zod",version:1}}var Tr=b("$ZodString",(e,n)=>{ie.init(e,n),e._zod.pattern=n.pattern??$c,e._zod.parse=(t,r)=>{if(n.coerce)try{t.value=String(t.value)}catch(o){}if(typeof t.value==="string")return t;return t.issues.push({expected:"string",code:"invalid_type",input:t.value,inst:e}),t}}),ae=b("$ZodStringFormat",(e,n)=>{St.init(e,n),Tr.init(e,n)}),cu=b("$ZodGUID",(e,n)=>{n.pattern??(n.pattern=yc),ae.init(e,n)}),uu=b("$ZodUUID",(e,n)=>{if(n.version){let r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[n.version];if(r===void 0)throw Error(`Invalid UUID version: "${n.version}"`);n.pattern??(n.pattern=ti(r))}else n.pattern??(n.pattern=ti());ae.init(e,n)}),lu=b("$ZodEmail",(e,n)=>{n.pattern??(n.pattern=bc),ae.init(e,n)}),du=1,$r=2;function pu(e){try{if(typeof URL<"u"&&typeof URL.canParse==="function")return URL.canParse(e);return new URL(e),!0}catch{return!1}}function Bg(e,n){if(!("normalize"in n)&&!("hostname"in n)&&!("protocol"in n))return pu(e)||$r;return Kg(e,n)}function Kg(e,n){if(!n.normalize&&n.protocol?.source===Ec.source&&!/^https?:\/\//i.test(e))return du;try{if(typeof URL<"u"){let t=URL;if(typeof t.parse==="function")return t.parse(e)??$r}return new URL(e)}catch{return $r}}var Wg=/[\t\n\r]/g;function Qc(e){return e.replace(Wg,"")}function Gg(e,n){return n.lastIndex=0,n.test(e.hostname)}function Hg(e,n){return n.lastIndex=0,n.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var fu=b("$ZodURL",(e,n)=>{ae.init(e,n),e._zod.check=(t)=>{try{let r=t.value.trim(),o=Bg(r,n);if(o===du){t.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:t.value,inst:e,continue:!n.abort});return}if(o===$r){t.issues.push({code:"invalid_format",format:"url",input:t.value,inst:e,continue:!n.abort});return}if(o===!0){t.value=Qc(r);return}if(n.hostname&&!Gg(o,n.hostname))t.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:n.hostname.source,input:t.value,inst:e,continue:!n.abort});if(n.protocol&&!Hg(o,n.protocol))t.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:n.protocol.source,input:t.value,inst:e,continue:!n.abort});t.value=n.normalize?o.href:Qc(r);return}catch(r){t.issues.push({code:"invalid_format",format:"url",input:t.value,inst:e,continue:!n.abort})}}}),mu=b("$ZodEmoji",(e,n)=>{n.pattern??(n.pattern=wc()),ae.init(e,n)}),gu=b("$ZodNanoID",(e,n)=>{if(n.length!==void 0&&(!Number.isInteger(n.length)||n.length<1))throw Error(`Invalid nanoid length: ${n.length}`);n.pattern??(n.pattern=n.length===void 0?mc:gc(n.length)),ae.init(e,n)}),hu=b("$ZodCUID",(e,n)=>{n.pattern??(n.pattern=uc),ae.init(e,n)}),yu=b("$ZodCUID2",(e,n)=>{n.pattern??(n.pattern=lc),ae.init(e,n)}),bu=b("$ZodULID",(e,n)=>{n.pattern??(n.pattern=dc),ae.init(e,n)}),wu=b("$ZodXID",(e,n)=>{n.pattern??(n.pattern=pc),ae.init(e,n)}),xu=b("$ZodKSUID",(e,n)=>{n.pattern??(n.pattern=fc),ae.init(e,n)}),vu=b("$ZodISODateTime",(e,n)=>{n.pattern??(n.pattern=Pc(n)),ae.init(e,n)}),ku=b("$ZodISODate",(e,n)=>{n.pattern??(n.pattern=Ac),ae.init(e,n)}),Su=b("$ZodISOTime",(e,n)=>{n.pattern??(n.pattern=jc(n)),ae.init(e,n)}),Iu=b("$ZodISODuration",(e,n)=>{n.pattern??(n.pattern=hc),ae.init(e,n)}),Cu=b("$ZodIPv4",(e,n)=>{n.pattern??(n.pattern=xc),ae.init(e,n)}),Qg=/^[0-9a-fA-F:.]+$/;function Eu(e){if(!Qg.test(e))return!1;return pu(`http://[${e}]`)}var Ou=b("$ZodIPv6",(e,n)=>{n.pattern??(n.pattern=vc),ae.init(e,n),e._zod.check=(t)=>{if(!Eu(t.value))t.issues.push({code:"invalid_format",format:"ipv6",input:t.value,inst:e,continue:!n.abort})}});var Ru=b("$ZodCIDRv4",(e,n)=>{n.pattern??(n.pattern=kc),ae.init(e,n)});function Yg(e){let n=e.split("/");if(n.length!==2)return!1;let[t,r]=n;if(!r)return!1;let o=Number(r);if(`${o}`!==r)return!1;if(o<0||o>128)return!1;return Eu(t)}var Au=b("$ZodCIDRv6",(e,n)=>{n.pattern??(n.pattern=Sc),ae.init(e,n),e._zod.check=(t)=>{if(!Yg(t.value))t.issues.push({code:"invalid_format",format:"cidrv6",input:t.value,inst:e,continue:!n.abort})}});function ju(e){if(e==="")return!0;if(/\s/.test(e))return!1;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var li=/^[0-9a-zA-Z+/]*={0,2}$/,Pu=b("$ZodBase64",(e,n)=>{n.pattern??(n.pattern=li),ae.init(e,n),e._zod.check=(t)=>{if(ju(t.value))return;t.issues.push({code:"invalid_format",format:"base64",input:t.value,inst:e,continue:!n.abort})}}),Nr=/^[A-Za-z0-9_-]*$/;function Xg(e){if(!Nr.test(e))return!1;let n=e.replace(/[-_]/g,(r)=>r==="-"?"+":"/"),t=n.padEnd(Math.ceil(n.length/4)*4,"=");return ju(t)}var $u=b("$ZodBase64URL",(e,n)=>{n.pattern??(n.pattern=Nr),ae.init(e,n),e._zod.check=(t)=>{if(Xg(t.value))return;t.issues.push({code:"invalid_format",format:"base64url",input:t.value,inst:e,continue:!n.abort})}}),_u=b("$ZodE164",(e,n)=>{n.pattern??(n.pattern=Oc),ae.init(e,n)});function eh(e,n=null){try{let t=e.split(".");if(t.length!==3)return!1;let[r]=t;if(!r)return!1;let o=JSON.parse(atob(r));if("typ"in o&&o?.typ!=="JWT")return!1;if(!o.alg)return!1;if(n&&(!("alg"in o)||o.alg!==n))return!1;return!0}catch{return!1}}var Tu=b("$ZodJWT",(e,n)=>{ae.init(e,n),e._zod.check=(t)=>{if(eh(t.value,n.alg))return;t.issues.push({code:"invalid_format",format:"jwt",input:t.value,inst:e,continue:!n.abort})}});var di=b("$ZodNumber",(e,n)=>{ie.init(e,n),e._zod.pattern=vt,e._zod.parse=(t,r)=>{if(n.coerce)try{t.value=Number(t.value)}catch(s){}let o=t.value;if(typeof o==="number"&&!Number.isNaN(o)&&Number.isFinite(o))return t;let i=typeof o==="number"?Number.isNaN(o)?"NaN":!Number.isFinite(o)?String(o):void 0:void 0;return t.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...i?{received:i}:{}}),t}}),Nu=b("$ZodNumberFormat",(e,n)=>{Vc.init(e,n),di.init(e,n)}),zu=b("$ZodBoolean",(e,n)=>{ie.init(e,n),e._zod.pattern=_c,e._zod.parse=(t,r)=>{if(n.coerce)try{t.value=Boolean(t.value)}catch(i){}let o=t.value;if(typeof o==="boolean")return t;return t.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),t}});var Du=b("$ZodNull",(e,n)=>{ie.init(e,n),e._zod.pattern=Tc,e._zod.values=new Set([null]),e._zod.parse=(t,r)=>{let o=t.value;if(o===null)return t;return t.issues.push({expected:"null",code:"invalid_type",input:o,inst:e}),t}});var Vu=b("$ZodUnknown",(e,n)=>{ie.init(e,n),e._zod.parse=(t)=>t}),Mu=b("$ZodNever",(e,n)=>{ie.init(e,n),e._zod.parse=(t,r)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:e}),t)});function Yc(e,n,t){if(e.issues.length)n.issues.push(...mn(t,e.issues));n.value[t]=e.value}var Zu=b("$ZodArray",(e,n)=>{ie.init(e,n);let t=Pe.memoizer;t?.attach(e),e._zod.parse=(r,o)=>{let i=r.value;if(!Array.isArray(i))return r.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),r;r.value=t?t.alloc(e,r,Array(i.length),o):Array(i.length);let s=[],a=o?.abortEarly;for(let c=0;c<i.length;c++){let u=i[c],l=n.element._zod.run({value:u,issues:[]},o);if(l instanceof Promise)s.push(l.then((f)=>Yc(f,r,c)));else if(Yc(l,r,c),a&&l.issues.length!==0&&Ye(l))break}if(s.length)return Promise.all(s).then(()=>r);return r}});function _r(e,n,t,r,o,i){let s=t in r,a=i==="optional";if(!s&&a&&o==="optional")return;if(e.issues.length){if(o!==void 0&&a&&!s)return;n.issues.push(...mn(t,e.issues))}if(!s&&o===void 0){if(!e.issues.length)n.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[t]});return}if(e.value===void 0){if(s||o==="defaulted"&&!a)n.value[t]=void 0}else n.value[t]=e.value}var nh=[];function Fu(e){let n=Object.keys(e.shape),t=Object.getOwnPropertySymbols(e.shape),r=t.length?t:nh,o=r.length?[...n,...r]:n;for(let s of o)if(!e.shape?.[s]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${String(s)}": expected a Zod schema`);let i=Ma(e.shape);return{...e,allKeys:o,symbolKeys:r,keySet:new Set(n),numKeys:n.length,optionalKeys:new Set(i)}}function Ju(e,n,t,r,o,i,s){let a=[],c=o.keySet,u=o.catchall._zod,l=u.def.type,{optin:f,optout:m}=u,h=0;for(let g in n){if(s&&t.issues.length!==h){if(Ye(t,h))break;h=t.issues.length}if(c.has(g))continue;if(g==="__proto__"){if(l==="never")a.push(g);continue}if(l==="never"){a.push(g);continue}let E=u.run({value:n[g],issues:[]},r);if(E instanceof Promise)e.push(E.then((P)=>_r(P,t,g,n,f,m)));else _r(E,t,g,n,f,m)}if(a.length)t.issues.push({code:"unrecognized_keys",keys:a,input:n,inst:i,continue:!0});if(!e.length)return t;return Promise.all(e).then(()=>t)}var th=b("$ZodObject",(e,n)=>{ie.init(e,n);let t=Object.getOwnPropertyDescriptor(n,"shape"),r=t?.get?t.get.raw:n.shape??{};if(r){let u=()=>{let l={...r};return Object.defineProperty(n,"shape",{value:l}),u.raw=l,l};u.raw=r,Object.defineProperty(n,"shape",{get:u})}let o=bt(()=>Fu(n));B(e,"propValues",(u)=>{let l=u.def.shape,f={};for(let m in l){let h=l[m]._zod;if(h.values){if(!Object.prototype.hasOwnProperty.call(f,m))Ve(f,m,new Set);for(let g of h.values)f[m].add(g);if(h.optin!==void 0)f[m].add(void 0)}}return f});let i=qn,s=n.catchall,a,c=Pe.memoizer;c?.attach(e),e._zod.parse=(u,l)=>{a??(a=o.value);let f=u.value;if(!i(f))return u.issues.push({expected:"object",code:"invalid_type",input:f,inst:e}),u;u.value=c?c.alloc(e,u,{},l):{};let m=[],h=a.shape,g=l?.abortEarly,E=u.issues.length;for(let P of a.allKeys){if(g&&u.issues.length!==E){if(Ye(u,E))break;E=u.issues.length}if(P==="__proto__")continue;let T=h[P],L=T._zod.optin,M=T._zod.optout,De=T._zod.run({value:f[P],issues:[]},l);if(De instanceof Promise)m.push(De.then((pe)=>_r(pe,u,P,f,L,M)));else _r(De,u,P,f,L,M)}if(!s)return m.length?Promise.all(m).then(()=>u):u;return Ju(m,f,u,l,o.value,e,g===!0)}}),Lu=b("$ZodObjectJIT",(e,n)=>{th.init(e,n);let t=e._zod.parse,r=bt(()=>Fu(n)),o=Pe.memoizer,i=(h)=>{let g=r.value,E=g.symbolKeys,P=new ai(["payload","ctx"],{shape:h,inst:e,memo:o,syms:E}),T=(pe)=>`shape[${pe}]._zod.run({ value: input[${pe}], issues: [] }, ctx)`,L=(pe,Y)=>`
|
|
7
7
|
let ${pe}_ab = false;
|
|
8
8
|
for (let i = 0; i < ${pe}.issues.length; i++) {
|
|
9
9
|
const iss = ${pe}.issues[i];
|
|
@@ -14,7 +14,7 @@ ${n.join(`
|
|
|
14
14
|
if (${pe}_ab && ctx && ctx.abortEarly) {
|
|
15
15
|
payload.value = newResult;
|
|
16
16
|
return payload;
|
|
17
|
-
}`;P.write("const input = payload.value;");let M=Object.create(null),De=0;for(let pe of g.allKeys)M[pe]=`key_${De++}`;P.write(o?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(let pe of g.allKeys){if(pe==="__proto__")continue;let Y=M[pe],je=typeof pe==="symbol"?`syms[${E.indexOf(pe)}]`:Na(pe),Zn=`${je} in input`,Fn=h[pe],Jn=Fn?._zod?.optin,Ln=Jn!==void 0,pt=Fn?._zod?.optout==="optional";if(P.write(`const ${Y} = ${
|
|
17
|
+
}`;P.write("const input = payload.value;");let M=Object.create(null),De=0;for(let pe of g.allKeys)M[pe]=`key_${De++}`;P.write(o?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(let pe of g.allKeys){if(pe==="__proto__")continue;let Y=M[pe],je=typeof pe==="symbol"?`syms[${E.indexOf(pe)}]`:Na(pe),Zn=`${je} in input`,Fn=h[pe],Jn=Fn?._zod?.optin,Ln=Jn!==void 0,pt=Fn?._zod?.optout==="optional";if(P.write(`const ${Y} = ${T(je)};`),Ln&&pt){let gr=Jn==="optional"?`${Y}_present`:`${Y}.value !== undefined || ${Y}_present`;P.write(`
|
|
18
18
|
const ${Y}_present = ${Zn};
|
|
19
19
|
if (!${Y}.issues.length || ${Y}_present) {
|
|
20
20
|
if (${Y}.issues.length) {${L(Y,je)}
|
|
@@ -53,33 +53,33 @@ ${n.join(`
|
|
|
53
53
|
if (${Y}.value !== undefined || ${Zn}) {
|
|
54
54
|
newResult[${je}] = ${Y}.value;
|
|
55
55
|
}
|
|
56
|
-
`)}return P.write("payload.value = newResult;"),P.write("return payload;"),P.compile()},s,a=qn,c=!Pe.jitless,l=c&&za.value,p=n.catchall,m;e._zod.parse=(h,g)=>{m??(m=r.value);let E=h.value;if(!a(E))return h.issues.push({expected:"object",code:"invalid_type",input:E,inst:e}),h;if(c&&l&&g?.async===!1&&g.jitless!==!0){if(!s)s=i(n.shape);if(h=s(h,g),!p)return h;return Fu([],E,h,g,m,e,g?.abortEarly===!0)}return t(h,g)}});function Yc(e,n,t,r){for(let i of e)if(i.issues.length===0)return n.value=i.value,n;let o=e.filter((i)=>!Ye(i));if(o.length===1)return n.value=o[0].value,o[0];return n.issues.push({code:"invalid_union",input:n.value,inst:t,errors:e.map((i)=>i.issues.map((s)=>Xe(s,r,Ze())))}),n}var di=b("$ZodUnion",(e,n)=>{ie.init(e,n),B(e,"optin",(r)=>r.def.options.some((o)=>o._zod.optin==="defaulted")?"defaulted":r.def.options.some((o)=>o._zod.optin!==void 0)?"optional":void 0),B(e,"optout",(r)=>r.def.options.some((o)=>o._zod.optout==="optional")?"optional":void 0),B(e,"values",(r)=>{if(r.def.options.every((o)=>o._zod.values))return new Set(r.def.options.flatMap((o)=>Array.from(o._zod.values)));return}),B(e,"pattern",(r)=>{if(r.def.options.every((o)=>o._zod.pattern)){let o=r.def.options.map((i)=>i._zod.pattern);return new RegExp(`^(${o.map((i)=>wr(i.source)).join("|")})$`)}return});let t=n.options.length===1?n.options[0]._zod.run:null;e._zod.parse=(r,o)=>{if(t)return t(r,o);let i=!1,s=[];for(let a of n.options){let c=a._zod.run({value:r.value,issues:[]},o);if(c instanceof Promise)s.push(c),i=!0;else{if(c.issues.length===0)return c;s.push(c)}}if(!i)return Yc(s,r,e,o);return Promise.all(s).then((a)=>Yc(a,r,e,o))}});function th(e){let n=new Map;for(let t of e.options){let r=t._zod.propValues?.[e.discriminator];if(!r||r.size===0)throw Error(`Invalid discriminated union option at index "${e.options.indexOf(t)}"`);for(let o of r)if(n.has(o)){if(o!==void 0)throw Error(`Duplicate discriminator value "${String(o)}"`);n.set(o,null)}else n.set(o,t)}return n}var Lu=b("$ZodDiscriminatedUnion",(e,n)=>{n.inclusive=!1,di.init(e,n);let t=e._zod.parse;B(e,"propValues",(o)=>{let i={},s=0;for(let a of o.def.options){let c=a._zod.propValues;if(!c||Object.keys(c).length===0)throw Error(`Invalid discriminated union option at index "${o.def.options.indexOf(a)}"`);if(c[o.def.discriminator]?.has(void 0))s++;for(let[u,l]of Object.entries(c)){if(!Object.prototype.hasOwnProperty.call(i,u))Ve(i,u,new Set);for(let p of l)i[u].add(p)}}if(!o.def.unionFallback&&s>1)i[o.def.discriminator]?.delete(void 0);return i}),n.options.forEach((o,i)=>{let s=wt(o._zod.def);if(s&&!Object.prototype.hasOwnProperty.call(s,n.discriminator))throw Error(`Invalid discriminated union option at index "${i}"`)});let r=bt(()=>th(n));e._zod.parse=(o,i)=>{let s=o.value;if(!qn(s))return o.issues.push({code:"invalid_type",expected:"object",input:s,inst:e}),o;let a=s?.[n.discriminator],c=r.value.get(a);if(c&&(a!==void 0||i.direction!=="backward"))return c._zod.run(o,i);if(n.unionFallback||i.direction==="backward")return t(o,i);return o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:n.discriminator,options:Array.from(r.value.keys()).filter((u)=>r.value.get(u)!==null),input:s,path:[n.discriminator],inst:e}),o}}),qu=b("$ZodIntersection",(e,n)=>{ie.init(e,n),e._zod.parse=(t,r)=>{let o=t.value,i=n.left._zod.run({value:o,issues:[]},r),s=n.right._zod.run({value:o,issues:[]},r);if(i instanceof Promise||s instanceof Promise)return Promise.all([i,s]).then(([c,u])=>Xc(t,c,u));return Xc(t,i,s)}});function ai(e,n){if(e===n)return{valid:!0,data:e};if(e instanceof Date&&n instanceof Date&&+e===+n)return{valid:!0,data:e};if(On(e)&&On(n)){let t=Object.keys(n),r=Object.keys(e).filter((i)=>t.indexOf(i)!==-1),o={...e,...n};if(Object.prototype.hasOwnProperty.call(o,"__proto__"))delete o.__proto__;for(let i of r){if(i==="__proto__")continue;let s=ai(e[i],n[i]);if(!s.valid)return{valid:!1,mergeErrorPath:[i,...s.mergeErrorPath]};o[i]=s.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(n)){if(e.length!==n.length)return{valid:!1,mergeErrorPath:[]};let t=[];for(let r=0;r<e.length;r++){let o=e[r],i=n[r],s=ai(o,i);if(!s.valid)return{valid:!1,mergeErrorPath:[r,...s.mergeErrorPath]};t.push(s.data)}return{valid:!0,data:t}}return{valid:!1,mergeErrorPath:[]}}function Xc(e,n,t){let r=new Map,o,i=new Map,s=(u,l)=>{let p;if(u.code==="unrecognized_keys"&&!u.path?.length)o??(o=u),p=u.keys;else if(u.code==="invalid_key"&&u.origin==="record"&&u.path?.length===1){let m=String(u.path[0]);if(!i.has(m))i.set(m,u);p=[m]}else return!1;for(let m of p){if(!r.has(m))r.set(m,{});r.get(m)[l]=!0}return!0};for(let u of n.issues)if(!s(u,"l"))e.issues.push(u);for(let u of t.issues)if(!s(u,"r"))e.issues.push(u);let a=[...r].filter(([,u])=>u.l&&u.r).map(([u])=>u);if(a.length){let u=o?a.filter((l)=>o.keys.includes(l)):[];if(u.length)e.issues.push({...o,keys:u});for(let l of a)if(!u.includes(l)&&i.has(l))e.issues.push(i.get(l))}let c=ai(n.value,t.value);if(!c.valid){if(Ye(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var Uu=b("$ZodRecord",(e,n)=>{ie.init(e,n);let t=Pe.memoizer;t?.attach(e),e._zod.parse=(r,o)=>{let i=r.value;if(!On(i))return r.issues.push({expected:"record",code:"invalid_type",input:i,inst:e}),r;let s=[],a=n.keyType._zod.values;if(a&&!n.partial){r.value=t?t.alloc(e,r,{},o):{};let c=new Set;for(let l of a)if(typeof l==="string"||typeof l==="number"||typeof l==="symbol"){if(c.add(typeof l==="number"?l.toString():l),l==="__proto__")continue;let p=n.keyType._zod.run({value:l,issues:[]},o);if(p instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(p.issues.length){r.issues.push({code:"invalid_key",origin:"record",issues:p.issues.map((g)=>Xe(g,o,Ze())),input:l,path:[l],inst:e});continue}let m=p.value;if(m==="__proto__")continue;let h=n.valueType._zod.run({value:i[l],issues:[]},o);if(h instanceof Promise)s.push(h.then((g)=>{if(g.issues.length)r.issues.push(...mn(l,g.issues));r.value[m]=g.value}));else{if(h.issues.length)r.issues.push(...mn(l,h.issues));r.value[m]=h.value}}let u;for(let l in i)if(!c.has(l))if(n.mode==="loose"){if(l==="__proto__")continue;r.value[l]=i[l]}else u=u??[],u.push(l);if(u&&u.length>0)r.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:u,continue:!0})}else{r.value=t?t.alloc(e,r,{},o):{};let c;for(let u of Reflect.ownKeys(i)){if(u==="__proto__")continue;if(!Object.prototype.propertyIsEnumerable.call(i,u))continue;let l=n.keyType._zod.run({value:u,issues:[]},o);if(l instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(typeof u==="string"&&vt.test(u)&&l.issues.length){let g=n.keyType._zod.run({value:Number(u),issues:[]},o);if(g instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(g.issues.length===0)l=g}if(l.issues.length){if(n.mode==="loose")r.value[u]=i[u];else if(a)c=c??[],c.push(u);else r.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map((g)=>Xe(g,o,Ze())),input:u,path:[u],inst:e});continue}let m=l.value;if(m==="__proto__")continue;let h=n.valueType._zod.run({value:i[u],issues:[]},o);if(h instanceof Promise)s.push(h.then((g)=>{if(g.issues.length)r.issues.push(...mn(u,g.issues));r.value[m]=g.value}));else{if(h.issues.length)r.issues.push(...mn(u,h.issues));r.value[m]=h.value}}if(c&&c.length>0)r.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:c,continue:!0})}if(s.length)return Promise.all(s).then(()=>r);return r}});var Bu=b("$ZodEnum",(e,n)=>{ie.init(e,n);let t=ht(n.entries),r=new Set(t);e._zod.values=r,B(e,"pattern",(o)=>{let i=ht(o.def.entries).filter((s)=>Da.has(typeof s));return new RegExp(i.length?`^(${i.map((s)=>fn(s.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(o,i)=>{let s=o.value;if(r.has(s))return o;return o.issues.push({code:"invalid_value",values:t,input:s,inst:e}),o}}),Ku=b("$ZodLiteral",(e,n)=>{ie.init(e,n);let t=new Set(n.values);e._zod.values=t,B(e,"pattern",(r)=>{let o=r.def.values;return new RegExp(o.length?`^(${o.map((i)=>typeof i==="string"?fn(i):i?fn(i.toString()):String(i)).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(r,o)=>{let i=r.value;if(t.has(i))return r;return r.issues.push({code:"invalid_value",values:n.values,input:i,inst:e}),r}});var Wu=b("$ZodTransform",(e,n)=>{ie.init(e,n),e._zod.optin="optional",Pe.memoizer?.guard(e),e._zod.parse=(t,r)=>{if(r.direction==="backward")throw new xt(e.constructor.name);let o=n.transform(t.value,t);if(r.async)return(o instanceof Promise?o:Promise.resolve(o)).then((s)=>(t.value=s,t));if(o instanceof Promise)throw new en;return t.value=o,t}});function eu(e,n){return e.value=n.issues.length?void 0:n.value,e}var pi=b("$ZodOptional",(e,n)=>{ie.init(e,n),B(e,"optin",(t)=>t.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",B(e,"values",(t)=>{let r=t.def.innerType._zod.values;return r?new Set([...r,void 0]):void 0}),B(e,"pattern",(t)=>{let r=t.def.innerType._zod.pattern;return r?new RegExp(`^(${wr(r.source)})?$`):void 0}),e._zod.parse=(t,r)=>{if(t.value===void 0){if(n.innerType._zod.optin!=="defaulted")return t;let o=n.innerType._zod.run({value:t.value,issues:[]},r);if(o instanceof Promise)return o.then((i)=>eu(t,i));return eu(t,o)}return n.innerType._zod.run(t,r)}}),Gu=b("$ZodExactOptional",(e,n)=>{pi.init(e,n),B(e,"values",(t)=>t.def.innerType._zod.values),B(e,"pattern",(t)=>t.def.innerType._zod.pattern),e._zod.parse=(t,r)=>n.innerType._zod.run(t,r)}),Hu=b("$ZodNullable",(e,n)=>{ie.init(e,n),B(e,"optin",(t)=>t.def.innerType._zod.optin),B(e,"optout",(t)=>t.def.innerType._zod.optout),B(e,"pattern",(t)=>{let r=t.def.innerType._zod.pattern;return r?new RegExp(`^(${wr(r.source)}|null)$`):void 0}),B(e,"values",(t)=>t.def.innerType._zod.values?new Set([...t.def.innerType._zod.values,null]):void 0),e._zod.parse=(t,r)=>{if(t.value===null)return t;return n.innerType._zod.run(t,r)}}),Qu=b("$ZodDefault",(e,n)=>{ie.init(e,n),e._zod.optin="defaulted",B(e,"values",(t)=>t.def.innerType._zod.values),e._zod.parse=(t,r)=>{if(r.direction==="backward")return n.innerType._zod.run(t,r);if(t.value===void 0)return t.value=n.defaultValue,t;let o=n.innerType._zod.run(t,r);if(o instanceof Promise)return o.then((i)=>nu(i,n));return nu(o,n)}});function nu(e,n){if(e.value===void 0)e.value=n.defaultValue;return e}var Yu=b("$ZodPrefault",(e,n)=>{ie.init(e,n),e._zod.optin="defaulted",B(e,"values",(t)=>t.def.innerType._zod.values),e._zod.parse=(t,r)=>{if(r.direction==="backward")return n.innerType._zod.run(t,r);if(t.value===void 0)t.value=n.defaultValue;return n.innerType._zod.run(t,r)}}),Xu=b("$ZodNonOptional",(e,n)=>{ie.init(e,n),B(e,"values",(t)=>{let r=t.def.innerType._zod.values;return r?new Set([...r].filter((o)=>o!==void 0)):void 0}),e._zod.parse=(t,r)=>{let o=n.innerType._zod.run(t,r);if(o instanceof Promise)return o.then((i)=>tu(i,e));return tu(o,e)}});function tu(e,n){if(!e.issues.length&&e.value===void 0)e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:n});return e}function ru(e,n,t,r){if(!n.issues.length){if(e.value=n.value,n.memo)e.memo=!0;return e}return e.value=t.catchValue({...n,value:e.value,error:{issues:n.issues.map((o)=>Xe(o,r,Ze()))},input:e.value}),e}var el=b("$ZodCatch",(e,n)=>{ie.init(e,n),B(e,"optin",(t)=>t.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),B(e,"optout",(t)=>t.def.innerType._zod.optout),B(e,"values",(t)=>t.def.innerType._zod.values),e._zod.parse=(t,r)=>{if(r.direction==="backward")return n.innerType._zod.run(t,r);let o=n.innerType._zod.run({value:t.value,issues:[]},r);if(o instanceof Promise)return o.then((i)=>ru(t,i,n,r));return ru(t,o,n,r)}});var fi=b("$ZodPipe",(e,n)=>{ie.init(e,n),B(e,"values",(t)=>t.def.in._zod.values),B(e,"optin",(t)=>t.def.in._zod.optin),B(e,"optout",(t)=>t.def.out._zod.optout),B(e,"propValues",(t)=>t.def.in._zod.propValues),e._zod.parse=(t,r)=>{if(r.direction==="backward"){let i=n.out._zod.run(t,r);if(i instanceof Promise)return i.then((s)=>Pr(s,n.in,r));return Pr(i,n.in,r)}let o=n.in._zod.run(t,r);if(o instanceof Promise)return o.then((i)=>Pr(i,n.out,r));return Pr(o,n.out,r)}});function Pr(e,n,t){if(e.issues.some((r)=>r.code!=="unrecognized_keys"))return e.aborted=!0,e;return n._zod.run({value:e.value,issues:e.issues},t)}var nl=b("$ZodPreprocess",(e,n)=>{fi.init(e,n)}),tl=b("$ZodReadonly",(e,n)=>{ie.init(e,n),B(e,"propValues",(t)=>t.def.innerType._zod.propValues),B(e,"values",(t)=>t.def.innerType._zod.values),B(e,"optin",(t)=>t.def.innerType?._zod?.optin),B(e,"optout",(t)=>t.def.innerType?._zod?.optout),e._zod.parse=(t,r)=>{if(r.direction==="backward")return n.innerType._zod.run(t,r);let o=n.innerType._zod.run(t,r);if(o instanceof Promise)return o.then(ou);return ou(o)}});function ou(e){if(!e.memo)e.value=Object.freeze(e.value);return e}var rl=b("$ZodLazy",(e,n)=>{ie.init(e,n),Pa(e._zod,"innerType",()=>{let t=n;if(!t._cachedInner)t._cachedInner=n.getter();return t._cachedInner}),B(e,"pattern",(t)=>t.innerType?._zod?.pattern),B(e,"propValues",(t)=>t.innerType?._zod?.propValues),B(e,"optin",(t)=>t.innerType?._zod?.optin??void 0),B(e,"optout",(t)=>t.innerType?._zod?.optout??void 0),e._zod.parse=(t,r)=>e._zod.innerType._zod.run(t,r)}),ol=b("$ZodCustom",(e,n)=>{Se.init(e,n),ie.init(e,n),e._zod.parse=(t,r)=>t,e._zod.check=(t)=>{let r=t.value,o=n.fn(r);if(o instanceof Promise)return o.then((i)=>iu(i,t,r,e));iu(o,t,r,e);return}});function iu(e,n,t,r){if(!e){let o={code:"custom",input:t,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};if(r._zod.def.params)o.params=r._zod.def.params;n.issues.push(Rn(o))}}class sl extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform");this.name="ZodCyclicError"}}var gi="~memo",il=[];function al(e){return e!==null&&typeof e==="object"}function mi(e){return e.map((n)=>n.path?{...n,path:n.path.slice()}:{...n})}var cl=new WeakMap,It=0,Vr=1,Ct=2;function Mr(e,n,t){let r=cl.get(e);if(r!==void 0)return r?Ct:It;if(n.has(e))return Ct;n.add(e);let o=It,i=(l)=>{if(o!==Ct&&l?._zod){let p=Mr(l,n,t);if(p>o)o=p}},s=(l,p)=>{let m=It;for(let h of Reflect.ownKeys(l)){let g=Object.getOwnPropertyDescriptor(l,h);if(p&&!g.enumerable)continue;let E=g.get?Vr:g.value?._zod?Mr(g.value,n,t):It;if(E>m)m=E}return m},a=(l)=>{if(l>o)o=l},c=e._zod.def,u=c.type;switch(u){case"object":{let l=wt(c);a(l?s(l,!0):Vr),i(c.catchall);break}case"array":i(c.element);break;case"tuple":for(let l of c.items)i(l);i(c.rest);break;case"record":case"map":i(c.keyType),i(c.valueType);break;case"set":i(c.valueType);break;case"union":for(let l of c.options)i(l);break;case"intersection":i(c.left),i(c.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":i(c.innerType);break;case"pipe":i(c.in),i(c.out);break;case"function":i(c.input),i(c.output);break;case"lazy":{let l=c._cachedInner??(t?e._zod.innerType:void 0);a(l?Mr(l,n,!1):Vr);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(let l in c){let p=Object.getOwnPropertyDescriptor(c,l);if(!p||p.get)continue;let m=p.value;if(!m||typeof m!=="object")continue;if(m._zod)i(m);else if(Array.isArray(m))for(let h of m)i(h)}}return n.delete(e),rh(e,o)}function rh(e,n){if(n!==Vr)cl.set(e,n===Ct);return n}function oh(e,n){let t=e.buckets.get(n);if(!t)t=new WeakMap,e.buckets.set(n,t);return t}var zr,Dr=[],ih={alloc(e,n,t){let r=zr;if(!r)return t;zr=void 0;let o={value:t,issues:null};return r.set(n.value,o),Dr.push(o),t},guard(e){var n;(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,r=(o,i)=>{if(i.direction!=="backward"&&sh(i,o.value))throw new sl;return t(o,i)};if(e._zod.parse=r,e._zod.run===t)e._zod.run=r})},attach(e){var n;let t,r=!1,o,i;(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred.push(()=>{let s=e._zod.parse,a=(c,u)=>{if(t===void 0){let N=Mr(e,new Set,!1);if(N===It){if(e._zod.parse=s,e._zod.run===a)e._zod.run=s;return s(c,u)}if(N===Ct||r)t=!0;else r=!0}let l=c.value;if(!al(l))return s(c,u);let p=u[gi];if(!p)p={buckets:new WeakMap,backEdges:void 0},u[gi]=p;let m;if(o===u)m=i;else m=oh(p,e),o=u,i=m;let h=m.get(l);if(h){if(c.value=h.value,h.issues){if(h.issues.length)c.issues.push(...mi(h.issues))}else c.memo=!0,p.backEdges??(p.backEdges=new WeakSet),p.backEdges.add(h.value);return c}zr=m;let g=Dr.length,E=s(c,u);zr=void 0;let P=Dr.length>g?Dr.pop():void 0;if(E instanceof Promise)return E.then((N)=>{if(P)P.issues=N.issues.length?mi(N.issues):il;return N});if(P)P.issues=E.issues.length?mi(E.issues):il;return E};if(e._zod.parse=a,e._zod.run===s)e._zod.run=a})}};function ul(){return ih}function sh(e,n){let t=e[gi]?.backEdges;return t!==void 0&&al(n)&&t.has(n)}var ah=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function n(i){return e[i]??null}let t={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},r={nan:"NaN"};function o(i,s){if(i==="number"&&typeof s==="number"&&!Number.isFinite(s))return String(s);return r[i]??i}return(i)=>{switch(i.code){case"invalid_type":{let s=o(i.expected),a=Ja(i.input),c=o(a,i.input);return`Invalid input: expected ${s}, received ${c}`}case"invalid_value":if(i.values.length===1)return`Invalid input: expected ${Bo(i.values[0])}`;return`Invalid option: expected one of ${Lo(i.values,"|")}`;case"too_big":{let s=i.exact?"exactly ":i.inclusive?"<=":"<",a=n(i.origin);if(a)return`Too big: expected ${i.origin??"value"} to have ${s}${i.maximum.toString()} ${a.unit??"elements"}`;return`Too big: expected ${i.origin??"value"} to be ${s}${i.maximum.toString()}`}case"too_small":{let s=i.exact?"exactly ":i.inclusive?">=":">",a=n(i.origin);if(a)return`Too small: expected ${i.origin} to have ${s}${i.minimum.toString()} ${a.unit}`;return`Too small: expected ${i.origin} to be ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;if(s.format==="starts_with")return`Invalid string: must start with "${s.prefix}"`;if(s.format==="ends_with")return`Invalid string: must end with "${s.suffix}"`;if(s.format==="includes")return`Invalid string: must include "${s.includes}"`;if(s.format==="regex")return`Invalid string: must match pattern ${s.pattern}`;return`Invalid ${t[s.format]??i.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${i.divisor}`;case"unrecognized_keys":return`Unrecognized key${i.keys.length>1?"s":""}: ${Lo(i.keys,", ")}`;case"invalid_key":return`Invalid key in ${i.origin}`;case"invalid_union":if(i.options&&Array.isArray(i.options)&&i.options.length>0)return`Invalid discriminator value. Expected ${i.options.map((a)=>`'${a}'`).join(" | ")}`;if(i.inclusive===!1)return"Invalid input: more than one option matched";return"Invalid input";case"invalid_element":return`Invalid value in ${i.origin}`;default:return"Invalid input"}}};function hi(){return{localeError:ah()}}var ll;class dl{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...n){let t=n[0];if(this._map.set(e,t),t&&typeof t==="object"&&"id"in t)this._idmap.set(t.id,e);return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let n=this._map.get(e);if(n&&typeof n==="object"&&"id"in n)this._idmap.delete(n.id);return this._map.delete(e),this}get(e){let n=e._zod.parent;if(n){let t={...this.get(n)??{}};delete t.id;let r={...t,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function ch(){return new dl}(ll=globalThis).__zod_globalRegistry??(ll.__zod_globalRegistry=ch());var An=globalThis.__zod_globalRegistry;function pl(e){if(e.checks)e.checks=[...e.checks];return e}function fl(e,n){return new e(pl({type:"string",..._(n)}))}function ml(e,n){return new e({type:"string",format:"email",check:"string_format",abort:!1,..._(n)})}function gl(e,n){return new e({type:"string",format:"guid",check:"string_format",abort:!1,..._(n)})}function hl(e,n){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,..._(n)})}function yl(e,n){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",..._(n)})}function bl(e,n){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",..._(n)})}function wl(e,n){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",..._(n)})}function xl(e,n){return new e({type:"string",format:"url",check:"string_format",abort:!1,..._(n)})}function vl(e,n){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,..._(n)})}function kl(e,n){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,..._(n)})}function Sl(e,n){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,..._(n)})}function Il(e,n){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,..._(n)})}function Cl(e,n){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,..._(n)})}function El(e,n){return new e({type:"string",format:"xid",check:"string_format",abort:!1,..._(n)})}function Ol(e,n){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,..._(n)})}function Rl(e,n){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,..._(n)})}function Al(e,n){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,..._(n)})}function jl(e,n){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,..._(n)})}function Pl(e,n){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,..._(n)})}function $l(e,n){return new e({type:"string",format:"base64",check:"string_format",abort:!1,..._(n)})}function _l(e,n){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,..._(n)})}function Nl(e,n){return new e({type:"string",format:"e164",check:"string_format",abort:!1,..._(n)})}function Tl(e,n){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,..._(n)})}function zl(e,n){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,..._(n)})}function Dl(e,n){return new e({type:"string",format:"date",check:"string_format",..._(n)})}function Vl(e,n){return new e({type:"string",format:"time",check:"string_format",precision:null,..._(n)})}function Ml(e,n){return new e({type:"string",format:"duration",check:"string_format",..._(n)})}function Zl(e,n){return new e(pl({type:"number",checks:[],..._(n)}))}function Fl(e,n){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",..._(n)})}function Jl(e,n){return new e({type:"boolean",..._(n)})}function Ll(e,n){return new e({type:"null",..._(n)})}function ql(e){return new e({type:"unknown"})}function Ul(e,n){return new e({type:"never",..._(n)})}function Zr(e,n){return new oi({check:"less_than",..._(n),value:e,inclusive:!1})}function Et(e,n){return new oi({check:"less_than",..._(n),value:e,inclusive:!0})}function Fr(e,n){return new ii({check:"greater_than",..._(n),value:e,inclusive:!1})}function Ot(e,n){return new ii({check:"greater_than",..._(n),value:e,inclusive:!0})}function Jr(e,n){return new zc({check:"multiple_of",..._(n),value:e})}function Lr(e,n){return new Vc({check:"max_length",..._(n),maximum:e})}function Un(e,n){return new Mc({check:"min_length",..._(n),minimum:e})}function qr(e,n){return new Zc({check:"length_equals",..._(n),length:e})}function yi(e,n){return new Fc({check:"string_format",format:"regex",..._(n),pattern:e})}function bi(e){return new Jc({check:"string_format",format:"lowercase",..._(e)})}function wi(e){return new Lc({check:"string_format",format:"uppercase",..._(e)})}function xi(e,n){return new qc({check:"string_format",format:"includes",..._(n),includes:e})}function vi(e,n){return new Uc({check:"string_format",format:"starts_with",..._(n),prefix:e})}function ki(e,n){return new Bc({check:"string_format",format:"ends_with",..._(n),suffix:e})}function gn(e){return new Kc({check:"overwrite",tx:e})}function Si(e){return gn((n)=>n.normalize(e))}function Ii(){return gn((e)=>e.trim())}function Ci(){return gn((e)=>e.toLowerCase())}function Ei(){return gn((e)=>e.toUpperCase())}function Oi(){return gn((e)=>Ta(e))}function Bl(e,n,t){return new e({type:"array",element:n,..._(t)})}function Kl(e,n,t){return new e({type:"custom",check:"custom",fn:n,..._(t)})}function Wl(e,n){let t=uh((r)=>(r.addIssue=(o)=>{if(typeof o==="string")r.issues.push(Rn(o,r.value,t._zod.def));else{let i=o;if(i.fatal)i.continue=!1;if(i.code??(i.code="custom"),!("input"in i))i.input=r.value;i.inst??(i.inst=t),i.continue??(i.continue=!t._zod.def.abort),r.issues.push(Rn(i))}},e(r.value,r)),n);return t}function uh(e,n){let t=new Se({check:"custom",..._(n)});return t._zod.check=e,t}function Rt(e,...n){for(let t of n)for(let r of Reflect.ownKeys(t))if(Object.prototype.propertyIsEnumerable.call(t,r))Ve(e,r,t[r]);return e}function jt(e){let n=e?.target??"draft-2020-12";if(n==="draft-4")n="draft-04";if(n==="draft-7")n="draft-07";return{processors:e.processors??{},metadataRegistry:e?.metadata??An,target:n,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??"ref",reused:e?.reused??"inline",intersections:[],deferred:[],external:e?.external??void 0}}function ke(e,n,t,r,o){let i=typeof n.unrepresentable==="function"?n.unrepresentable({zodSchema:e,path:r.path,message:o}):n.unrepresentable;if(i==="any")return!1;if(i===void 0||i==="throw")throw Error(o);return Object.assign(t,i),!0}function ne(e,n,t={path:[],schemaPath:[]}){var r;let o=e._zod.def,i=n.seen.get(e);if(i){if(i.count++,t.schemaPath.includes(e))i.cycle=t.path;return i.schema}let s={schema:{},count:1,cycle:void 0,path:t.path};n.seen.set(e,s),n.sharedDefsExtractedFor=void 0,n.sharedEmitDoneFor=void 0;let a=e._zod.toJSONSchema?.();if(a)s.schema=a;else{let l={...t,schemaPath:[...t.schemaPath,e],path:t.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(n,s.schema,l);else{let m=s.schema,h=n.processors[o.type];if(!h)throw Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);h(e,n,m,l)}let p=e._zod.parent;if(p){if(!s.ref)s.ref=p;ne(p,n,l),n.seen.get(p).isParent=!0}}let c=n.metadataRegistry.get(e);if(c)Rt(s.schema,c);if(n.io==="input"&&Oe(e))delete s.schema.examples,delete s.schema.default;if(n.io==="input"&&"_prefault"in s.schema)(r=s.schema).default??(r.default=s.schema._prefault);return delete s.schema._prefault,n.seen.get(e).schema}function Gl(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function Pt(e,n){let t=e.seen.get(n);if(!t)throw Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;let r=new Map;for(let s of e.seen.entries()){let a=e.metadataRegistry.get(s[0])?.id;if(a){let c=r.get(a);if(c&&c!==s[0])throw Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(a,s[0])}}let o=(s)=>{let a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let p=e.external.registry.get(s[0])?.id,m=e.external.uri??((g)=>g);if(p)return{ref:m(p)};let h=s[1].defId??s[1].schema.id??`schema${e.counter++}`;return s[1].defId=h,{defId:h,ref:`${m("__shared")}#/${a}/${Gl(h)}`}}let c="#",u=`${c}/${a}/`;if(s[1]===t&&!s[1].schema.id)return{ref:c};let l=s[1].schema.id??`__schema${e.counter++}`;return{defId:l,ref:u+Gl(l)}},i=(s)=>{if(s[1].schema.$ref)return;let a=s[1],{ref:c,defId:u}=o(s);if(a.def={...a.schema},u)a.defId=u;let l=a.schema;for(let p in l)delete l[p];l.$ref=c};if(e.cycles==="throw")for(let s of e.seen.entries()){let a=s[1];if(a.cycle)throw Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
|
|
56
|
+
`)}return P.write("payload.value = newResult;"),P.write("return payload;"),P.compile()},s,a=qn,c=!Pe.jitless,l=c&&Da.value,f=n.catchall,m;e._zod.parse=(h,g)=>{m??(m=r.value);let E=h.value;if(!a(E))return h.issues.push({expected:"object",code:"invalid_type",input:E,inst:e}),h;if(c&&l&&g?.async===!1&&g.jitless!==!0){if(!s)s=i(n.shape);if(h=s(h,g),!f)return h;return Ju([],E,h,g,m,e,g?.abortEarly===!0)}return t(h,g)}});function Xc(e,n,t,r){for(let i of e)if(i.issues.length===0)return n.value=i.value,n;let o=e.filter((i)=>!Ye(i));if(o.length===1)return n.value=o[0].value,o[0];return n.issues.push({code:"invalid_union",input:n.value,inst:t,errors:e.map((i)=>i.issues.map((s)=>Xe(s,r,Ze())))}),n}var pi=b("$ZodUnion",(e,n)=>{ie.init(e,n),B(e,"optin",(r)=>r.def.options.some((o)=>o._zod.optin==="defaulted")?"defaulted":r.def.options.some((o)=>o._zod.optin!==void 0)?"optional":void 0),B(e,"optout",(r)=>r.def.options.some((o)=>o._zod.optout==="optional")?"optional":void 0),B(e,"values",(r)=>{if(r.def.options.every((o)=>o._zod.values))return new Set(r.def.options.flatMap((o)=>Array.from(o._zod.values)));return}),B(e,"pattern",(r)=>{if(r.def.options.every((o)=>o._zod.pattern)){let o=r.def.options.map((i)=>i._zod.pattern);return new RegExp(`^(${o.map((i)=>wr(i.source)).join("|")})$`)}return});let t=n.options.length===1?n.options[0]._zod.run:null;e._zod.parse=(r,o)=>{if(t)return t(r,o);let i=!1,s=[];for(let a of n.options){let c=a._zod.run({value:r.value,issues:[]},o);if(c instanceof Promise)s.push(c),i=!0;else{if(c.issues.length===0)return c;s.push(c)}}if(!i)return Xc(s,r,e,o);return Promise.all(s).then((a)=>Xc(a,r,e,o))}});function rh(e){let n=new Map;for(let t of e.options){let r=t._zod.propValues?.[e.discriminator];if(!r||r.size===0)throw Error(`Invalid discriminated union option at index "${e.options.indexOf(t)}"`);for(let o of r)if(n.has(o)){if(o!==void 0)throw Error(`Duplicate discriminator value "${String(o)}"`);n.set(o,null)}else n.set(o,t)}return n}var qu=b("$ZodDiscriminatedUnion",(e,n)=>{n.inclusive=!1,pi.init(e,n);let t=e._zod.parse;B(e,"propValues",(o)=>{let i={},s=0;for(let a of o.def.options){let c=a._zod.propValues;if(!c||Object.keys(c).length===0)throw Error(`Invalid discriminated union option at index "${o.def.options.indexOf(a)}"`);if(c[o.def.discriminator]?.has(void 0))s++;for(let[u,l]of Object.entries(c)){if(!Object.prototype.hasOwnProperty.call(i,u))Ve(i,u,new Set);for(let f of l)i[u].add(f)}}if(!o.def.unionFallback&&s>1)i[o.def.discriminator]?.delete(void 0);return i}),n.options.forEach((o,i)=>{let s=wt(o._zod.def);if(s&&!Object.prototype.hasOwnProperty.call(s,n.discriminator))throw Error(`Invalid discriminated union option at index "${i}"`)});let r=bt(()=>rh(n));e._zod.parse=(o,i)=>{let s=o.value;if(!qn(s))return o.issues.push({code:"invalid_type",expected:"object",input:s,inst:e}),o;let a=s?.[n.discriminator],c=r.value.get(a);if(c&&(a!==void 0||i.direction!=="backward"))return c._zod.run(o,i);if(n.unionFallback||i.direction==="backward")return t(o,i);return o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:n.discriminator,options:Array.from(r.value.keys()).filter((u)=>r.value.get(u)!==null),input:s,path:[n.discriminator],inst:e}),o}}),Uu=b("$ZodIntersection",(e,n)=>{ie.init(e,n),e._zod.parse=(t,r)=>{let o=t.value,i=n.left._zod.run({value:o,issues:[]},r),s=n.right._zod.run({value:o,issues:[]},r);if(i instanceof Promise||s instanceof Promise)return Promise.all([i,s]).then(([c,u])=>eu(t,c,u));return eu(t,i,s)}});function ci(e,n){if(e===n)return{valid:!0,data:e};if(e instanceof Date&&n instanceof Date&&+e===+n)return{valid:!0,data:e};if(On(e)&&On(n)){let t=Object.keys(n),r=Object.keys(e).filter((i)=>t.indexOf(i)!==-1),o={...e,...n};if(Object.prototype.hasOwnProperty.call(o,"__proto__"))delete o.__proto__;for(let i of r){if(i==="__proto__")continue;let s=ci(e[i],n[i]);if(!s.valid)return{valid:!1,mergeErrorPath:[i,...s.mergeErrorPath]};o[i]=s.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(n)){if(e.length!==n.length)return{valid:!1,mergeErrorPath:[]};let t=[];for(let r=0;r<e.length;r++){let o=e[r],i=n[r],s=ci(o,i);if(!s.valid)return{valid:!1,mergeErrorPath:[r,...s.mergeErrorPath]};t.push(s.data)}return{valid:!0,data:t}}return{valid:!1,mergeErrorPath:[]}}function eu(e,n,t){let r=new Map,o,i=new Map,s=(u,l)=>{let f;if(u.code==="unrecognized_keys"&&!u.path?.length)o??(o=u),f=u.keys;else if(u.code==="invalid_key"&&u.origin==="record"&&u.path?.length===1){let m=String(u.path[0]);if(!i.has(m))i.set(m,u);f=[m]}else return!1;for(let m of f){if(!r.has(m))r.set(m,{});r.get(m)[l]=!0}return!0};for(let u of n.issues)if(!s(u,"l"))e.issues.push(u);for(let u of t.issues)if(!s(u,"r"))e.issues.push(u);let a=[...r].filter(([,u])=>u.l&&u.r).map(([u])=>u);if(a.length){let u=o?a.filter((l)=>o.keys.includes(l)):[];if(u.length)e.issues.push({...o,keys:u});for(let l of a)if(!u.includes(l)&&i.has(l))e.issues.push(i.get(l))}let c=ci(n.value,t.value);if(!c.valid){if(Ye(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var Bu=b("$ZodRecord",(e,n)=>{ie.init(e,n);let t=Pe.memoizer;t?.attach(e),e._zod.parse=(r,o)=>{let i=r.value;if(!On(i))return r.issues.push({expected:"record",code:"invalid_type",input:i,inst:e}),r;let s=[],a=n.keyType._zod.values;if(a&&!n.partial){r.value=t?t.alloc(e,r,{},o):{};let c=new Set;for(let l of a)if(typeof l==="string"||typeof l==="number"||typeof l==="symbol"){if(c.add(typeof l==="number"?l.toString():l),l==="__proto__")continue;let f=n.keyType._zod.run({value:l,issues:[]},o);if(f instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(f.issues.length){r.issues.push({code:"invalid_key",origin:"record",issues:f.issues.map((g)=>Xe(g,o,Ze())),input:l,path:[l],inst:e});continue}let m=f.value;if(m==="__proto__")continue;let h=n.valueType._zod.run({value:i[l],issues:[]},o);if(h instanceof Promise)s.push(h.then((g)=>{if(g.issues.length)r.issues.push(...mn(l,g.issues));r.value[m]=g.value}));else{if(h.issues.length)r.issues.push(...mn(l,h.issues));r.value[m]=h.value}}let u;for(let l in i)if(!c.has(l))if(n.mode==="loose"){if(l==="__proto__")continue;r.value[l]=i[l]}else u=u??[],u.push(l);if(u&&u.length>0)r.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:u,continue:!0})}else{r.value=t?t.alloc(e,r,{},o):{};let c;for(let u of Reflect.ownKeys(i)){if(u==="__proto__")continue;if(!Object.prototype.propertyIsEnumerable.call(i,u))continue;let l=n.keyType._zod.run({value:u,issues:[]},o);if(l instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(typeof u==="string"&&vt.test(u)&&l.issues.length){let g=n.keyType._zod.run({value:Number(u),issues:[]},o);if(g instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(g.issues.length===0)l=g}if(l.issues.length){if(n.mode==="loose")r.value[u]=i[u];else if(a)c=c??[],c.push(u);else r.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map((g)=>Xe(g,o,Ze())),input:u,path:[u],inst:e});continue}let m=l.value;if(m==="__proto__")continue;let h=n.valueType._zod.run({value:i[u],issues:[]},o);if(h instanceof Promise)s.push(h.then((g)=>{if(g.issues.length)r.issues.push(...mn(u,g.issues));r.value[m]=g.value}));else{if(h.issues.length)r.issues.push(...mn(u,h.issues));r.value[m]=h.value}}if(c&&c.length>0)r.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:c,continue:!0})}if(s.length)return Promise.all(s).then(()=>r);return r}});var Ku=b("$ZodEnum",(e,n)=>{ie.init(e,n);let t=ht(n.entries),r=new Set(t);e._zod.values=r,B(e,"pattern",(o)=>{let i=ht(o.def.entries).filter((s)=>Va.has(typeof s));return new RegExp(i.length?`^(${i.map((s)=>fn(s.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(o,i)=>{let s=o.value;if(r.has(s))return o;return o.issues.push({code:"invalid_value",values:t,input:s,inst:e}),o}}),Wu=b("$ZodLiteral",(e,n)=>{ie.init(e,n);let t=new Set(n.values);e._zod.values=t,B(e,"pattern",(r)=>{let o=r.def.values;return new RegExp(o.length?`^(${o.map((i)=>typeof i==="string"?fn(i):i?fn(i.toString()):String(i)).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(r,o)=>{let i=r.value;if(t.has(i))return r;return r.issues.push({code:"invalid_value",values:n.values,input:i,inst:e}),r}});var Gu=b("$ZodTransform",(e,n)=>{ie.init(e,n),e._zod.optin="optional",Pe.memoizer?.guard(e),e._zod.parse=(t,r)=>{if(r.direction==="backward")throw new xt(e.constructor.name);let o=n.transform(t.value,t);if(r.async)return(o instanceof Promise?o:Promise.resolve(o)).then((s)=>(t.value=s,t));if(o instanceof Promise)throw new en;return t.value=o,t}});function nu(e,n){return e.value=n.issues.length?void 0:n.value,e}var fi=b("$ZodOptional",(e,n)=>{ie.init(e,n),B(e,"optin",(t)=>t.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",B(e,"values",(t)=>{let r=t.def.innerType._zod.values;return r?new Set([...r,void 0]):void 0}),B(e,"pattern",(t)=>{let r=t.def.innerType._zod.pattern;return r?new RegExp(`^(${wr(r.source)})?$`):void 0}),e._zod.parse=(t,r)=>{if(t.value===void 0){if(n.innerType._zod.optin!=="defaulted")return t;let o=n.innerType._zod.run({value:t.value,issues:[]},r);if(o instanceof Promise)return o.then((i)=>nu(t,i));return nu(t,o)}return n.innerType._zod.run(t,r)}}),Hu=b("$ZodExactOptional",(e,n)=>{fi.init(e,n),B(e,"values",(t)=>t.def.innerType._zod.values),B(e,"pattern",(t)=>t.def.innerType._zod.pattern),e._zod.parse=(t,r)=>n.innerType._zod.run(t,r)}),Qu=b("$ZodNullable",(e,n)=>{ie.init(e,n),B(e,"optin",(t)=>t.def.innerType._zod.optin),B(e,"optout",(t)=>t.def.innerType._zod.optout),B(e,"pattern",(t)=>{let r=t.def.innerType._zod.pattern;return r?new RegExp(`^(${wr(r.source)}|null)$`):void 0}),B(e,"values",(t)=>t.def.innerType._zod.values?new Set([...t.def.innerType._zod.values,null]):void 0),e._zod.parse=(t,r)=>{if(t.value===null)return t;return n.innerType._zod.run(t,r)}}),Yu=b("$ZodDefault",(e,n)=>{ie.init(e,n),e._zod.optin="defaulted",B(e,"values",(t)=>t.def.innerType._zod.values),e._zod.parse=(t,r)=>{if(r.direction==="backward")return n.innerType._zod.run(t,r);if(t.value===void 0)return t.value=n.defaultValue,t;let o=n.innerType._zod.run(t,r);if(o instanceof Promise)return o.then((i)=>tu(i,n));return tu(o,n)}});function tu(e,n){if(e.value===void 0)e.value=n.defaultValue;return e}var Xu=b("$ZodPrefault",(e,n)=>{ie.init(e,n),e._zod.optin="defaulted",B(e,"values",(t)=>t.def.innerType._zod.values),e._zod.parse=(t,r)=>{if(r.direction==="backward")return n.innerType._zod.run(t,r);if(t.value===void 0)t.value=n.defaultValue;return n.innerType._zod.run(t,r)}}),el=b("$ZodNonOptional",(e,n)=>{ie.init(e,n),B(e,"values",(t)=>{let r=t.def.innerType._zod.values;return r?new Set([...r].filter((o)=>o!==void 0)):void 0}),e._zod.parse=(t,r)=>{let o=n.innerType._zod.run(t,r);if(o instanceof Promise)return o.then((i)=>ru(i,e));return ru(o,e)}});function ru(e,n){if(!e.issues.length&&e.value===void 0)e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:n});return e}function ou(e,n,t,r){if(!n.issues.length){if(e.value=n.value,n.memo)e.memo=!0;return e}return e.value=t.catchValue({...n,value:e.value,error:{issues:n.issues.map((o)=>Xe(o,r,Ze()))},input:e.value}),e}var nl=b("$ZodCatch",(e,n)=>{ie.init(e,n),B(e,"optin",(t)=>t.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),B(e,"optout",(t)=>t.def.innerType._zod.optout),B(e,"values",(t)=>t.def.innerType._zod.values),e._zod.parse=(t,r)=>{if(r.direction==="backward")return n.innerType._zod.run(t,r);let o=n.innerType._zod.run({value:t.value,issues:[]},r);if(o instanceof Promise)return o.then((i)=>ou(t,i,n,r));return ou(t,o,n,r)}});var mi=b("$ZodPipe",(e,n)=>{ie.init(e,n),B(e,"values",(t)=>t.def.in._zod.values),B(e,"optin",(t)=>t.def.in._zod.optin),B(e,"optout",(t)=>t.def.out._zod.optout),B(e,"propValues",(t)=>t.def.in._zod.propValues),e._zod.parse=(t,r)=>{if(r.direction==="backward"){let i=n.out._zod.run(t,r);if(i instanceof Promise)return i.then((s)=>Pr(s,n.in,r));return Pr(i,n.in,r)}let o=n.in._zod.run(t,r);if(o instanceof Promise)return o.then((i)=>Pr(i,n.out,r));return Pr(o,n.out,r)}});function Pr(e,n,t){if(e.issues.some((r)=>r.code!=="unrecognized_keys"))return e.aborted=!0,e;return n._zod.run({value:e.value,issues:e.issues},t)}var tl=b("$ZodPreprocess",(e,n)=>{mi.init(e,n)}),rl=b("$ZodReadonly",(e,n)=>{ie.init(e,n),B(e,"propValues",(t)=>t.def.innerType._zod.propValues),B(e,"values",(t)=>t.def.innerType._zod.values),B(e,"optin",(t)=>t.def.innerType?._zod?.optin),B(e,"optout",(t)=>t.def.innerType?._zod?.optout),e._zod.parse=(t,r)=>{if(r.direction==="backward")return n.innerType._zod.run(t,r);let o=n.innerType._zod.run(t,r);if(o instanceof Promise)return o.then(iu);return iu(o)}});function iu(e){if(!e.memo)e.value=Object.freeze(e.value);return e}var ol=b("$ZodLazy",(e,n)=>{ie.init(e,n),$a(e._zod,"innerType",()=>{let t=n;if(!t._cachedInner)t._cachedInner=n.getter();return t._cachedInner}),B(e,"pattern",(t)=>t.innerType?._zod?.pattern),B(e,"propValues",(t)=>t.innerType?._zod?.propValues),B(e,"optin",(t)=>t.innerType?._zod?.optin??void 0),B(e,"optout",(t)=>t.innerType?._zod?.optout??void 0),e._zod.parse=(t,r)=>e._zod.innerType._zod.run(t,r)}),il=b("$ZodCustom",(e,n)=>{Se.init(e,n),ie.init(e,n),e._zod.parse=(t,r)=>t,e._zod.check=(t)=>{let r=t.value,o=n.fn(r);if(o instanceof Promise)return o.then((i)=>su(i,t,r,e));su(o,t,r,e);return}});function su(e,n,t,r){if(!e){let o={code:"custom",input:t,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};if(r._zod.def.params)o.params=r._zod.def.params;n.issues.push(Rn(o))}}class al extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform");this.name="ZodCyclicError"}}var hi="~memo",sl=[];function cl(e){return e!==null&&typeof e==="object"}function gi(e){return e.map((n)=>n.path?{...n,path:n.path.slice()}:{...n})}var ul=new WeakMap,It=0,Vr=1,Ct=2;function Mr(e,n,t){let r=ul.get(e);if(r!==void 0)return r?Ct:It;if(n.has(e))return Ct;n.add(e);let o=It,i=(l)=>{if(o!==Ct&&l?._zod){let f=Mr(l,n,t);if(f>o)o=f}},s=(l,f)=>{let m=It;for(let h of Reflect.ownKeys(l)){let g=Object.getOwnPropertyDescriptor(l,h);if(f&&!g.enumerable)continue;let E=g.get?Vr:g.value?._zod?Mr(g.value,n,t):It;if(E>m)m=E}return m},a=(l)=>{if(l>o)o=l},c=e._zod.def,u=c.type;switch(u){case"object":{let l=wt(c);a(l?s(l,!0):Vr),i(c.catchall);break}case"array":i(c.element);break;case"tuple":for(let l of c.items)i(l);i(c.rest);break;case"record":case"map":i(c.keyType),i(c.valueType);break;case"set":i(c.valueType);break;case"union":for(let l of c.options)i(l);break;case"intersection":i(c.left),i(c.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":i(c.innerType);break;case"pipe":i(c.in),i(c.out);break;case"function":i(c.input),i(c.output);break;case"lazy":{let l=c._cachedInner??(t?e._zod.innerType:void 0);a(l?Mr(l,n,!1):Vr);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(let l in c){let f=Object.getOwnPropertyDescriptor(c,l);if(!f||f.get)continue;let m=f.value;if(!m||typeof m!=="object")continue;if(m._zod)i(m);else if(Array.isArray(m))for(let h of m)i(h)}}return n.delete(e),oh(e,o)}function oh(e,n){if(n!==Vr)ul.set(e,n===Ct);return n}function ih(e,n){let t=e.buckets.get(n);if(!t)t=new WeakMap,e.buckets.set(n,t);return t}var zr,Dr=[],sh={alloc(e,n,t){let r=zr;if(!r)return t;zr=void 0;let o={value:t,issues:null};return r.set(n.value,o),Dr.push(o),t},guard(e){var n;(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,r=(o,i)=>{if(i.direction!=="backward"&&ah(i,o.value))throw new al;return t(o,i)};if(e._zod.parse=r,e._zod.run===t)e._zod.run=r})},attach(e){var n;let t,r=!1,o,i;(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred.push(()=>{let s=e._zod.parse,a=(c,u)=>{if(t===void 0){let T=Mr(e,new Set,!1);if(T===It){if(e._zod.parse=s,e._zod.run===a)e._zod.run=s;return s(c,u)}if(T===Ct||r)t=!0;else r=!0}let l=c.value;if(!cl(l))return s(c,u);let f=u[hi];if(!f)f={buckets:new WeakMap,backEdges:void 0},u[hi]=f;let m;if(o===u)m=i;else m=ih(f,e),o=u,i=m;let h=m.get(l);if(h){if(c.value=h.value,h.issues){if(h.issues.length)c.issues.push(...gi(h.issues))}else c.memo=!0,f.backEdges??(f.backEdges=new WeakSet),f.backEdges.add(h.value);return c}zr=m;let g=Dr.length,E=s(c,u);zr=void 0;let P=Dr.length>g?Dr.pop():void 0;if(E instanceof Promise)return E.then((T)=>{if(P)P.issues=T.issues.length?gi(T.issues):sl;return T});if(P)P.issues=E.issues.length?gi(E.issues):sl;return E};if(e._zod.parse=a,e._zod.run===s)e._zod.run=a})}};function ll(){return sh}function ah(e,n){let t=e[hi]?.backEdges;return t!==void 0&&cl(n)&&t.has(n)}var ch=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function n(i){return e[i]??null}let t={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},r={nan:"NaN"};function o(i,s){if(i==="number"&&typeof s==="number"&&!Number.isFinite(s))return String(s);return r[i]??i}return(i)=>{switch(i.code){case"invalid_type":{let s=o(i.expected),a=La(i.input),c=o(a,i.input);return`Invalid input: expected ${s}, received ${c}`}case"invalid_value":if(i.values.length===1)return`Invalid input: expected ${Ko(i.values[0])}`;return`Invalid option: expected one of ${qo(i.values,"|")}`;case"too_big":{let s=i.exact?"exactly ":i.inclusive?"<=":"<",a=n(i.origin);if(a)return`Too big: expected ${i.origin??"value"} to have ${s}${i.maximum.toString()} ${a.unit??"elements"}`;return`Too big: expected ${i.origin??"value"} to be ${s}${i.maximum.toString()}`}case"too_small":{let s=i.exact?"exactly ":i.inclusive?">=":">",a=n(i.origin);if(a)return`Too small: expected ${i.origin} to have ${s}${i.minimum.toString()} ${a.unit}`;return`Too small: expected ${i.origin} to be ${s}${i.minimum.toString()}`}case"invalid_format":{let s=i;if(s.format==="starts_with")return`Invalid string: must start with "${s.prefix}"`;if(s.format==="ends_with")return`Invalid string: must end with "${s.suffix}"`;if(s.format==="includes")return`Invalid string: must include "${s.includes}"`;if(s.format==="regex")return`Invalid string: must match pattern ${s.pattern}`;return`Invalid ${t[s.format]??i.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${i.divisor}`;case"unrecognized_keys":return`Unrecognized key${i.keys.length>1?"s":""}: ${qo(i.keys,", ")}`;case"invalid_key":return`Invalid key in ${i.origin}`;case"invalid_union":if(i.options&&Array.isArray(i.options)&&i.options.length>0)return`Invalid discriminator value. Expected ${i.options.map((a)=>`'${a}'`).join(" | ")}`;if(i.inclusive===!1)return"Invalid input: more than one option matched";return"Invalid input";case"invalid_element":return`Invalid value in ${i.origin}`;default:return"Invalid input"}}};function yi(){return{localeError:ch()}}var dl;class pl{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...n){let t=n[0];if(this._map.set(e,t),t&&typeof t==="object"&&"id"in t)this._idmap.set(t.id,e);return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let n=this._map.get(e);if(n&&typeof n==="object"&&"id"in n)this._idmap.delete(n.id);return this._map.delete(e),this}get(e){let n=e._zod.parent;if(n){let t={...this.get(n)??{}};delete t.id;let r={...t,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function uh(){return new pl}(dl=globalThis).__zod_globalRegistry??(dl.__zod_globalRegistry=uh());var An=globalThis.__zod_globalRegistry;function fl(e){if(e.checks)e.checks=[...e.checks];return e}function ml(e,n){return new e(fl({type:"string",..._(n)}))}function gl(e,n){return new e({type:"string",format:"email",check:"string_format",abort:!1,..._(n)})}function hl(e,n){return new e({type:"string",format:"guid",check:"string_format",abort:!1,..._(n)})}function yl(e,n){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,..._(n)})}function bl(e,n){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",..._(n)})}function wl(e,n){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",..._(n)})}function xl(e,n){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",..._(n)})}function vl(e,n){return new e({type:"string",format:"url",check:"string_format",abort:!1,..._(n)})}function kl(e,n){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,..._(n)})}function Sl(e,n){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,..._(n)})}function Il(e,n){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,..._(n)})}function Cl(e,n){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,..._(n)})}function El(e,n){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,..._(n)})}function Ol(e,n){return new e({type:"string",format:"xid",check:"string_format",abort:!1,..._(n)})}function Rl(e,n){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,..._(n)})}function Al(e,n){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,..._(n)})}function jl(e,n){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,..._(n)})}function Pl(e,n){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,..._(n)})}function $l(e,n){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,..._(n)})}function _l(e,n){return new e({type:"string",format:"base64",check:"string_format",abort:!1,..._(n)})}function Tl(e,n){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,..._(n)})}function Nl(e,n){return new e({type:"string",format:"e164",check:"string_format",abort:!1,..._(n)})}function zl(e,n){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,..._(n)})}function Dl(e,n){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,..._(n)})}function Vl(e,n){return new e({type:"string",format:"date",check:"string_format",..._(n)})}function Ml(e,n){return new e({type:"string",format:"time",check:"string_format",precision:null,..._(n)})}function Zl(e,n){return new e({type:"string",format:"duration",check:"string_format",..._(n)})}function Fl(e,n){return new e(fl({type:"number",checks:[],..._(n)}))}function Jl(e,n){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",..._(n)})}function Ll(e,n){return new e({type:"boolean",..._(n)})}function ql(e,n){return new e({type:"null",..._(n)})}function Ul(e){return new e({type:"unknown"})}function Bl(e,n){return new e({type:"never",..._(n)})}function Zr(e,n){return new ii({check:"less_than",..._(n),value:e,inclusive:!1})}function Et(e,n){return new ii({check:"less_than",..._(n),value:e,inclusive:!0})}function Fr(e,n){return new si({check:"greater_than",..._(n),value:e,inclusive:!1})}function Ot(e,n){return new si({check:"greater_than",..._(n),value:e,inclusive:!0})}function Jr(e,n){return new Dc({check:"multiple_of",..._(n),value:e})}function Lr(e,n){return new Mc({check:"max_length",..._(n),maximum:e})}function Un(e,n){return new Zc({check:"min_length",..._(n),minimum:e})}function qr(e,n){return new Fc({check:"length_equals",..._(n),length:e})}function bi(e,n){return new Jc({check:"string_format",format:"regex",..._(n),pattern:e})}function wi(e){return new Lc({check:"string_format",format:"lowercase",..._(e)})}function xi(e){return new qc({check:"string_format",format:"uppercase",..._(e)})}function vi(e,n){return new Uc({check:"string_format",format:"includes",..._(n),includes:e})}function ki(e,n){return new Bc({check:"string_format",format:"starts_with",..._(n),prefix:e})}function Si(e,n){return new Kc({check:"string_format",format:"ends_with",..._(n),suffix:e})}function gn(e){return new Wc({check:"overwrite",tx:e})}function Ii(e){return gn((n)=>n.normalize(e))}function Ci(){return gn((e)=>e.trim())}function Ei(){return gn((e)=>e.toLowerCase())}function Oi(){return gn((e)=>e.toUpperCase())}function Ri(){return gn((e)=>za(e))}function Kl(e,n,t){return new e({type:"array",element:n,..._(t)})}function Wl(e,n,t){return new e({type:"custom",check:"custom",fn:n,..._(t)})}function Gl(e,n){let t=lh((r)=>(r.addIssue=(o)=>{if(typeof o==="string")r.issues.push(Rn(o,r.value,t._zod.def));else{let i=o;if(i.fatal)i.continue=!1;if(i.code??(i.code="custom"),!("input"in i))i.input=r.value;i.inst??(i.inst=t),i.continue??(i.continue=!t._zod.def.abort),r.issues.push(Rn(i))}},e(r.value,r)),n);return t}function lh(e,n){let t=new Se({check:"custom",..._(n)});return t._zod.check=e,t}function Rt(e,...n){for(let t of n)for(let r of Reflect.ownKeys(t))if(Object.prototype.propertyIsEnumerable.call(t,r))Ve(e,r,t[r]);return e}function jt(e){let n=e?.target??"draft-2020-12";if(n==="draft-4")n="draft-04";if(n==="draft-7")n="draft-07";return{processors:e.processors??{},metadataRegistry:e?.metadata??An,target:n,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??"ref",reused:e?.reused??"inline",intersections:[],deferred:[],external:e?.external??void 0}}function ke(e,n,t,r,o){let i=typeof n.unrepresentable==="function"?n.unrepresentable({zodSchema:e,path:r.path,message:o}):n.unrepresentable;if(i==="any")return!1;if(i===void 0||i==="throw")throw Error(o);return Object.assign(t,i),!0}function te(e,n,t={path:[],schemaPath:[]}){var r;let o=e._zod.def,i=n.seen.get(e);if(i){if(i.count++,t.schemaPath.includes(e))i.cycle=t.path;return i.schema}let s={schema:{},count:1,cycle:void 0,path:t.path};n.seen.set(e,s),n.sharedDefsExtractedFor=void 0,n.sharedEmitDoneFor=void 0;let a=e._zod.toJSONSchema?.();if(a)s.schema=a;else{let l={...t,schemaPath:[...t.schemaPath,e],path:t.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(n,s.schema,l);else{let m=s.schema,h=n.processors[o.type];if(!h)throw Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);h(e,n,m,l)}let f=e._zod.parent;if(f){if(!s.ref)s.ref=f;te(f,n,l),n.seen.get(f).isParent=!0}}let c=n.metadataRegistry.get(e);if(c)Rt(s.schema,c);if(n.io==="input"&&Oe(e))delete s.schema.examples,delete s.schema.default;if(n.io==="input"&&"_prefault"in s.schema)(r=s.schema).default??(r.default=s.schema._prefault);return delete s.schema._prefault,n.seen.get(e).schema}function Hl(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function Pt(e,n){let t=e.seen.get(n);if(!t)throw Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;let r=new Map;for(let s of e.seen.entries()){let a=e.metadataRegistry.get(s[0])?.id;if(a){let c=r.get(a);if(c&&c!==s[0])throw Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(a,s[0])}}let o=(s)=>{let a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let f=e.external.registry.get(s[0])?.id,m=e.external.uri??((g)=>g);if(f)return{ref:m(f)};let h=s[1].defId??s[1].schema.id??`schema${e.counter++}`;return s[1].defId=h,{defId:h,ref:`${m("__shared")}#/${a}/${Hl(h)}`}}let c="#",u=`${c}/${a}/`;if(s[1]===t&&!s[1].schema.id)return{ref:c};let l=s[1].schema.id??`__schema${e.counter++}`;return{defId:l,ref:u+Hl(l)}},i=(s)=>{if(s[1].schema.$ref)return;let a=s[1],{ref:c,defId:u}=o(s);if(a.def={...a.schema},u)a.defId=u;let l=a.schema;for(let f in l)delete l[f];l.$ref=c};if(e.cycles==="throw")for(let s of e.seen.entries()){let a=s[1];if(a.cycle)throw Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
|
|
57
57
|
|
|
58
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let s of e.seen.entries()){let a=s[1];if(n===s[0]){i(s);continue}if(e.external){let u=e.external.registry.get(s[0])?.id;if(n!==s[0]&&u){i(s);continue}}if(e.metadataRegistry.get(s[0])?.id){i(s);continue}if(a.cycle){i(s);continue}if(a.count>1){if(e.reused==="ref")i(s)}}if(e.external)e.sharedDefsExtractedFor=e.external}function Yl(e){let n=e.anyOf;if(!Array.isArray(n)||n.length===0||e.type!==void 0)return;let t=[];for(let r of n){if(!r||typeof r!=="object")return;Yl(r);let o=Object.keys(r);if(o.length!==1||o[0]!=="type")return;let i=r.type;for(let s of Array.isArray(i)?i:[i]){if(typeof s!=="string")return;if(!t.includes(s))t.push(s)}}delete e.anyOf,e.type=t.length===1?t[0]:t}var Xl=new Set(["type","properties","required","additionalProperties"]),Hl=["oneOf","anyOf"];function Ql(e){let n=e.additionalProperties;if(n===void 0||n===!1||typeof n!=="object"||n===null)return null;return Object.keys(n).length?n:null}function Ri(e){let n=[];for(let i of e){if(typeof i!=="object"||i.type!=="object")return null;for(let s in i)if(!Xl.has(s))return null;n.push(i)}let t={},r=new Set;for(let i of n){for(let s in i.properties){if(Object.prototype.hasOwnProperty.call(t,s))continue;let a=[];for(let u of n){let l=u.properties?.[s]??Ql(u);if(l===null||l===void 0)continue;if(!a.some((p)=>JSON.stringify(p)===JSON.stringify(l)))a.push(l)}let c=a.length===1?a[0]:Ri(a)??{allOf:a};Ve(t,s,c)}for(let s of i.required??[])r.add(s)}let o={type:"object",properties:t};if(r.size)o.required=[...r];if(n.every((i)=>i.additionalProperties===!1))o.additionalProperties=!1;else{let i=[];for(let s of n){let a=Ql(s);if(a&&!i.some((c)=>JSON.stringify(c)===JSON.stringify(a)))i.push(a)}if(i.length===1)o.additionalProperties=i[0];else if(i.length>1)o.additionalProperties={allOf:i}}return o}function lh(e){let n=e.allOf;if(!Array.isArray(n)||n.length<2)return;for(let o of Xl)if(o in e)return;let t=n.filter((o)=>Hl.some((i)=>Array.isArray(o[i]))),r=null;if(!t.length)r=Ri(n);else{let o=t[0],i=Hl.find((c)=>Array.isArray(o[c]));if(Object.keys(o).length!==1)return;let s=n.filter((c)=>c!==o),a=o[i].map((c)=>Ri([...s,c]));if(a.some((c)=>!c))return;r={[i]:a}}if(!r)return;delete e.allOf,Rt(e,r)}function $t(e,n){let t=e.seen.get(n);if(!t)throw Error("Unprocessed schema. This is a bug in Zod.");let r=(a)=>{let c=e.seen.get(a);if(c.ref===null)return;let u=c.def??c.schema,l={...u},p=c.ref;if(c.ref=null,p){r(p);let h=e.seen.get(p),g=h.schema;if(g.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"))u.allOf=u.allOf??[],u.allOf.push(g);else Rt(u,g);if(Rt(u,l),a._zod.parent===p)for(let P in u){if(P==="$ref"||P==="allOf")continue;if(!(P in l))delete u[P]}if(g.$ref&&h.def)for(let P in u){if(P==="$ref"||P==="allOf")continue;if(P in h.def&&JSON.stringify(u[P])===JSON.stringify(h.def[P]))delete u[P]}}let m=a._zod.parent;if(m&&m!==p){r(m);let h=e.seen.get(m);if(h?.schema.$ref){if(u.$ref=h.schema.$ref,h.def)for(let g in u){if(g==="$ref"||g==="allOf")continue;if(g in h.def&&JSON.stringify(u[g])===JSON.stringify(h.def[g]))delete u[g]}}}e.override({zodSchema:a,jsonSchema:u,path:c.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let a of[...e.seen.entries()].reverse())r(a[0]);if(e.target!=="openapi-3.0")for(let a of e.seen.entries())Yl(a[1].def??a[1].schema);for(let a of e.deferred)a();if(e.intersections.length){let a=new Map;for(let c of e.seen.values())for(let u of[c.schema,c.def]){let l=u?.allOf;if(!Array.isArray(l))continue;let p=a.get(l);if(p)p.push(u);else a.set(l,[u])}for(let c of e.intersections)for(let u of a.get(c)??[])lh(u)}}let o={};if(e.target==="draft-2020-12")o.$schema="https://json-schema.org/draft/2020-12/schema";else if(e.target==="draft-07")o.$schema="http://json-schema.org/draft-07/schema#";else if(e.target==="draft-04")o.$schema="http://json-schema.org/draft-04/schema#";else if(e.target==="openapi-3.0");if(e.external?.uri){let a=e.external.registry.get(n)?.id;if(!a)throw Error("Schema is missing an `id` property");o.$id=e.external.uri(a)}Rt(o,t.defId?t.schema:t.def??t.schema);let i=e.metadataRegistry.get(n)?.id;if(i!==void 0&&o.id===i)delete o.id;let s=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let a of e.seen.entries()){let c=a[1];if(c.def&&c.defId){if(c.def.id===c.defId)delete c.def.id;Ve(s,c.defId,c.def)}}if(e.external)e.sharedEmitDoneFor=e.external;if(e.external);else if(Object.keys(s).length>0)if(e.target==="draft-2020-12")o.$defs=s;else o.definitions=s;try{let a=JSON.parse(JSON.stringify(o));return Object.defineProperty(a,"~standard",{value:{...n["~standard"],jsonSchema:{input:At(n,"input",e.processors),output:At(n,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch(a){throw Error("Error converting schema to JSON.")}}function Oe(e,n){let t=n??{seen:new Set};if(t.seen.has(e))return!1;t.seen.add(e);let r=e._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return Oe(r.element,t);if(r.type==="set")return Oe(r.valueType,t);if(r.type==="lazy")return Oe(r.getter(),t);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault"||r.type==="catch")return Oe(r.innerType,t);if(r.type==="intersection")return Oe(r.left,t)||Oe(r.right,t);if(r.type==="record"||r.type==="map")return Oe(r.keyType,t)||Oe(r.valueType,t);if(r.type==="pipe"){if(e._zod.traits.has("$ZodCodec"))return!0;return Oe(r.in,t)||Oe(r.out,t)}if(r.type==="object"){for(let o in r.shape)if(Oe(r.shape[o],t))return!0;return!1}if(r.type==="union"){for(let o of r.options)if(Oe(o,t))return!0;return!1}if(r.type==="tuple"){for(let o of r.items)if(Oe(o,t))return!0;if(r.rest&&Oe(r.rest,t))return!0;return!1}return!1}var ed=(e,n={})=>(t)=>{let r=jt({...t,processors:n});return ne(e,r),Pt(r,e),$t(r,e)},At=(e,n,t={})=>(r)=>{let{libraryOptions:o,target:i}=r??{},s=jt({...o??{},target:i,io:n,processors:t});return ne(e,s),Pt(s,e),$t(s,e)};var Bn=(e,n,t)=>{if(e[n]===void 0||t>e[n])e[n]=t},Kn=(e,n,t)=>{if(e[n]===void 0||t<e[n])e[n]=t},nd=(e,n)=>{Bn(e,"minimum",n),Kn(e,"maximum",n)},sd=(e,n)=>{if(e.multipleOf??(e.multipleOf=[]),!e.multipleOf.includes(n))e.multipleOf.push(n)},ad=(e,n)=>{e.patterns??(e.patterns=new Set),e.patterns.add(n)},cd=(e,n)=>{e.mime=e.mime?e.mime.filter((t)=>n.includes(t)):[...n]},ud=(e,n)=>{if(e.format=n,n.includes("int"))e.isInt=!0},td=(e,n)=>Bn(e,"minimum",n.minimum),rd=(e,n)=>Kn(e,"maximum",n.maximum),od=(e)=>(n,t)=>{ud(n,t.format);let[r,o]=e[t.format];Bn(n,"minimum",r),Kn(n,"maximum",o)},dh={greater_than:(e,n)=>Bn(e,n.inclusive?"minimum":"exclusiveMinimum",n.value),less_than:(e,n)=>Kn(e,n.inclusive?"maximum":"exclusiveMaximum",n.value),multiple_of:(e,n)=>sd(e,n.value),number_format:od(xr),bigint_format:od(Ko),min_length:td,max_length:rd,length_equals:(e,n)=>nd(e,n.length),min_size:td,max_size:rd,size_equals:(e,n)=>nd(e,n.size),string_format:(e,n)=>{if(ud(e,n.format),n.pattern)ad(e,n.pattern);if(n.format==="base64"||n.format==="base64url")e.contentEncoding=n.format;if(n.local||n.precision===-1)e.laxFormat=!0},mime_type:(e,n)=>cd(e,n.mime)};function $e(e){let n={},t=e._zod.def,r=e._zod.traits.has("$ZodCheck")?[e,...t.checks??[]]:t.checks??[];for(let i of r)dh[i._zod.def.check]?.(n,i._zod.def);let o=e._zod.bag;if(o.minimum!==void 0)Bn(n,"minimum",o.minimum);if(o.exclusiveMinimum!==void 0)Bn(n,"exclusiveMinimum",o.exclusiveMinimum);if(o.maximum!==void 0)Kn(n,"maximum",o.maximum);if(o.exclusiveMaximum!==void 0)Kn(n,"exclusiveMaximum",o.exclusiveMaximum);if(o.multipleOf!==void 0)sd(n,o.multipleOf);if(o.format!==void 0){if(n.format??(n.format=o.format),o.format.includes("int"))n.isInt=!0}if(o.mime)cd(n,o.mime);for(let i of o.patterns??[])ad(n,i);return n}var ph={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},fh=new Map([[ui,Sc],[Tr,Ic]]),ld=(e)=>fh.get(e)??e,Pi=(e,n,t,r)=>{let o=t;o.type="string";let{minimum:i,maximum:s,format:a,patterns:c,contentEncoding:u,laxFormat:l}=$e(e);if(typeof i==="number")o.minLength=i;if(typeof s==="number")o.maxLength=s;if(a){if(o.format=ph[a]??a,o.format==="")delete o.format;if(a==="time"||l)delete o.format}if(u)o.contentEncoding=u;if(c&&c.size>0){let p=[...c].map(ld);if(p.length===1)o.pattern=p[0].source;else if(p.length>1)o.allOf=[...p.map((m)=>({...n.target==="draft-07"||n.target==="draft-04"||n.target==="openapi-3.0"?{type:"string"}:{},pattern:m.source}))]}},$i=(e,n,t,r)=>{let o=t,{minimum:i,maximum:s,multipleOf:a,exclusiveMaximum:c,exclusiveMinimum:u,isInt:l}=$e(e);o.type=l?"integer":"number";let p=typeof u==="number"&&u>=(i??Number.NEGATIVE_INFINITY),m=typeof c==="number"&&c<=(s??Number.POSITIVE_INFINITY),h=n.target==="draft-04"||n.target==="openapi-3.0";if(p)if(h)o.minimum=u,o.exclusiveMinimum=!0;else o.exclusiveMinimum=u;else if(typeof i==="number")o.minimum=i;if(m)if(h)o.maximum=c,o.exclusiveMaximum=!0;else o.exclusiveMaximum=c;else if(typeof s==="number")o.maximum=s;if(a){let g=new Set;for(let N of a)if(Number.isFinite(N)&&N!==0)g.add(Math.abs(N));else ke(e,n,o,r,`A multipleOf divisor of ${N} cannot be represented in JSON Schema`);let[E,...P]=g;if(E!==void 0)o.multipleOf=E;if(P.length)o.allOf=[...o.allOf??[],...P.map((N)=>({multipleOf:N}))]}},_i=(e,n,t,r)=>{t.type="boolean"},dd=(e,n,t,r)=>{ke(e,n,t,r,"BigInt cannot be represented in JSON Schema")},pd=(e,n,t,r)=>{ke(e,n,t,r,"Symbols cannot be represented in JSON Schema")},Ni=(e,n,t,r)=>{if(n.target==="openapi-3.0")t.type="string",t.nullable=!0,t.enum=[null];else t.type="null"},fd=(e,n,t,r)=>{ke(e,n,t,r,"Undefined cannot be represented in JSON Schema")},md=(e,n,t,r)=>{ke(e,n,t,r,"Void cannot be represented in JSON Schema")},Ti=(e,n,t,r)=>{t.not={}},gd=(e,n,t,r)=>{},zi=(e,n,t,r)=>{},hd=(e,n,t,r)=>{ke(e,n,t,r,"Date cannot be represented in JSON Schema")},Di=(e,n,t,r)=>{let o=e._zod.def,i=ht(o.entries);if(i.length===0){t.not={};return}if(i.every((s)=>typeof s==="number"))t.type="number";if(i.every((s)=>typeof s==="string"))t.type="string";t.enum=i},Vi=(e,n,t,r)=>{let o=e._zod.def;if(o.values.length===0){t.not={};return}let i=[];for(let s of o.values)if(s===void 0){if(ke(e,n,t,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof s==="bigint"){if(ke(e,n,t,r,"BigInt literals cannot be represented in JSON Schema"))return;i.push(Number(s))}else i.push(s);if(i.length===0);else if(i.length===1){let s=i[0];if(t.type=s===null?"null":typeof s,n.target==="draft-04"||n.target==="openapi-3.0")t.enum=[s];else t.const=s}else{if(i.every((s)=>typeof s==="number"))t.type="number";if(i.every((s)=>typeof s==="string"))t.type="string";if(i.every((s)=>typeof s==="boolean"))t.type="boolean";if(i.every((s)=>s===null))t.type="null";t.enum=i}},yd=(e,n,t,r)=>{ke(e,n,t,r,"NaN cannot be represented in JSON Schema")},bd=(e,n,t,r)=>{let o=t,i=e._zod.pattern;if(!i)throw Error("Pattern not found in template literal");o.type="string",o.pattern=i.source},wd=(e,n,t,r)=>{let o=t;o.type="string",o.format="binary",o.contentEncoding="binary";let{minimum:i,maximum:s,mime:a}=$e(e);if(i!==void 0)o.minLength=i;if(s!==void 0)o.maxLength=s;if(!a)return;if(a.length===0)o.not={};else if(a.length===1)o.contentMediaType=a[0];else o.anyOf=a.map((c)=>({contentMediaType:c}))},xd=(e,n,t,r)=>{t.type="boolean"},Mi=(e,n,t,r)=>{ke(e,n,t,r,"Custom types cannot be represented in JSON Schema")},vd=(e,n,t,r)=>{ke(e,n,t,r,"Function types cannot be represented in JSON Schema")},Zi=(e,n,t,r)=>{ke(e,n,t,r,"Transforms cannot be represented in JSON Schema")},kd=(e,n,t,r)=>{ke(e,n,t,r,"Map cannot be represented in JSON Schema")},Sd=(e,n,t,r)=>{ke(e,n,t,r,"Set cannot be represented in JSON Schema")},Fi=(e,n,t,r)=>{let o=t,i=e._zod.def,{minimum:s,maximum:a}=$e(e);if(typeof s==="number")o.minItems=s;if(typeof a==="number")o.maxItems=a;o.type="array",o.items=ne(i.element,n,{...r,path:[...r.path,"items"]})};function _t(e){let n=e._zod.def;if(n.type==="pipe"&&n.in._zod.traits.has("$ZodTransform"))return _t(n.out);if(n.type==="catch")return _t(n.innerType);return e._zod.optin}var Ji=(e,n,t,r)=>{let o=t,i=e._zod.def,s=i.shape;if(Object.getOwnPropertySymbols(s).length&&ke(e,n,o,r,"Symbol keys cannot be represented in JSON Schema"))return;o.type="object",o.properties={};for(let u in s)Ve(o.properties,u,ne(s[u],n,{...r,path:[...r.path,"properties",u]}));let c=[];for(let u of Object.keys(s)){let l=i.shape[u];if(n.io==="input"?_t(l)===void 0:l._zod.optout===void 0)c.push(u)}if(c.length>0)o.required=c;if(i.catchall?._zod.def.type==="never")o.additionalProperties=!1;else if(!i.catchall){if(n.io==="output")o.additionalProperties=!1}else if(i.catchall)o.additionalProperties=ne(i.catchall,n,{...r,path:[...r.path,"additionalProperties"]})},Li=(e,n,t,r)=>{let o=e._zod.def,i=o.inclusive===!1,s=o.options.map((a,c)=>ne(a,n,{...r,path:[...r.path,i?"oneOf":"anyOf",c]}));if(i)t.oneOf=s;else t.anyOf=s},qi=(e,n,t,r)=>{let o=e._zod.def,i=ne(o.left,n,{...r,path:[...r.path,"allOf",0]}),s=ne(o.right,n,{...r,path:[...r.path,"allOf",1]}),a=(u)=>("allOf"in u)&&Object.keys(u).length===1,c=[...a(i)?i.allOf:[i],...a(s)?s.allOf:[s]];t.allOf=c,n.intersections.push(c)},Id=(e,n,t,r)=>{let o=t,i=e._zod.def;o.type="array";let s=n.target==="draft-2020-12"?"prefixItems":"items",a=n.target==="draft-2020-12"?"items":n.target==="openapi-3.0"?"items":"additionalItems",c=i.items.map((E,P)=>ne(E,n,{...r,path:[...r.path,s,P]})),u=i.rest?ne(i.rest,n,{...r,path:[...r.path,a,...n.target==="openapi-3.0"?[i.items.length]:[]]}):null,l=i.items.length;while(l>0){let E=i.items[l-1];if(!(n.io==="input"?_t(E)!==void 0:E._zod.optout==="optional"))break;l--}let p=i.items.length,m=!i.rest;if(n.target==="draft-2020-12"){if(o.prefixItems=c,m)o.items=!1;else if(u)o.items=u;if(l>0)o.minItems=l;if(m)o.maxItems=p}else if(n.target==="openapi-3.0"){if(o.items={anyOf:c},u)o.items.anyOf.push(u);if(l>0)o.minItems=l;if(m)o.maxItems=p}else{if(o.items=c,m)o.additionalItems=!1;else if(u)o.additionalItems=u;if(l>0)o.minItems=l;if(m)o.maxItems=p}let{minimum:h,maximum:g}=$e(e);if(typeof h==="number")o.minItems=h;if(typeof g==="number")o.maxItems=g};function Ai(e,n,t){if(n.$ref){if(t.has(n))return n;t.add(n);let g=e.get(n)?.def;if(!g)return n;let E=Ai(e,g,t);return E===g?n:E}for(let g of["anyOf","oneOf"]){let E=n[g];if(!Array.isArray(E))continue;let P=E.map((N)=>Ai(e,N,t));if(P.some((N,L)=>N!==E[L]))n={...n,[g]:P}}let r=Array.isArray(n.type)?n.type:[n.type],o=!r.includes("string")&&r.some((g)=>g==="number"||g==="integer"),i=n.enum??(n.const!==void 0?[n.const]:void 0);if(!o&&!i?.some((g)=>typeof g==="number"))return n;let{minimum:s,maximum:a,exclusiveMinimum:c,exclusiveMaximum:u,multipleOf:l,format:p,id:m,...h}=n;if(h.enum)h.enum=h.enum.map((g)=>typeof g==="number"?String(g):g);else if(typeof h.const==="number")h.const=String(h.const);if(!o)return h;if(h.type="string",!i)h.pattern=(r.includes("number")?vt:ti).source;return h}var ji=new WeakMap;function mh(e){let n=new Map;for(let r of e.seen.values())if(r.def&&!n.has(r.schema))n.set(r.schema,r);let t=new Map;for(let r of ji.get(e)??[]){let o=e.seen.get(r),i=(o?.def??o?.schema)?.propertyNames;if(!i||i===!0||t.has(i))continue;let s=Ai(n,i,new Set);if(s!==i)t.set(i,s)}if(!t.size)return;for(let r of e.seen.values())for(let o of[r.schema,r.def]){let i=o&&t.get(o.propertyNames);if(i)o.propertyNames=i}}var Ui=(e,n,t,r)=>{let o=t,i=e._zod.def;o.type="object";let s=i.keyType,a=$e(s).patterns;if(i.mode==="loose"&&a&&a.size>0){let l=ne(i.valueType,n,{...r,path:[...r.path,"patternProperties","*"]});o.patternProperties={};for(let p of a)Ve(o.patternProperties,ld(p).source,l)}else{if(n.target==="draft-07"||n.target==="draft-2020-12"){o.propertyNames=ne(i.keyType,n,{...r,path:[...r.path,"propertyNames"]});let l=ji.get(n);if(!l)l=[],ji.set(n,l),n.deferred.push(()=>mh(n));l.push(e)}o.additionalProperties=ne(i.valueType,n,{...r,path:[...r.path,"additionalProperties"]})}let c=s._zod.values,u=n.io==="input"&&_t(i.valueType)!==void 0;if(c&&!i.partial&&!u){let l=[...c].filter((p)=>typeof p==="string"||typeof p==="number");if(l.length>0)o.required=l.map(String)}},Bi=(e,n,t,r)=>{let o=e._zod.def,i=ne(o.innerType,n,r),s=n.seen.get(e);if(n.target==="openapi-3.0")s.ref=o.innerType,t.nullable=!0;else t.anyOf=[i,{type:"null"}]},Ki=(e,n,t,r)=>{let o=e._zod.def;ne(o.innerType,n,r);let i=n.seen.get(e);i.ref=o.innerType},Wi=Symbol();function Cd(e,n,t,r,o){let i=!1,s=JSON.stringify(e,(a,c)=>{if(typeof c!=="bigint")return c;return i=!0,null});if(!i)return JSON.parse(s);return ke(n,t,r,o,"BigInt defaults cannot be represented in JSON Schema"),Wi}var Gi=(e,n,t,r)=>{let o=e._zod.def;ne(o.innerType,n,r);let i=n.seen.get(e);i.ref=o.innerType;let s=Cd(o.defaultValue,e,n,t,r);if(s!==Wi)t.default=s},Hi=(e,n,t,r)=>{let o=e._zod.def;ne(o.innerType,n,r);let i=n.seen.get(e);if(i.ref=o.innerType,n.io!=="input")return;let s=Cd(o.defaultValue,e,n,t,r);if(s!==Wi)t._prefault=s},Qi=(e,n,t,r)=>{let o=e._zod.def;ne(o.innerType,n,r);let i=n.seen.get(e);i.ref=o.innerType;let s;try{s=o.catchValue(void 0)}catch{ke(e,n,t,r,"Dynamic catch values are not supported in JSON Schema");return}t.default=s},Yi=(e,n,t,r)=>{let o=e._zod.def,i=o.in._zod.traits.has("$ZodTransform"),s=n.io==="input"?i?o.out:o.in:o.out;ne(s,n,r);let a=n.seen.get(e);a.ref=s},Xi=(e,n,t,r)=>{let o=e._zod.def;ne(o.innerType,n,r);let i=n.seen.get(e);i.ref=o.innerType,t.readOnly=!0},Ed=(e,n,t,r)=>{let o=e._zod.def;ne(o.innerType,n,r);let i=n.seen.get(e);i.ref=o.innerType},Ur=(e,n,t,r)=>{let o=e._zod.def;ne(o.innerType,n,r);let i=n.seen.get(e);i.ref=o.innerType},es=(e,n,t,r)=>{let o=e._zod.innerType;ne(o,n,r);let i=n.seen.get(e);i.ref=o},id={string:Pi,number:$i,boolean:_i,bigint:dd,symbol:pd,null:Ni,undefined:fd,void:md,never:Ti,any:gd,unknown:zi,date:hd,enum:Di,literal:Vi,nan:yd,template_literal:bd,file:wd,success:xd,custom:Mi,function:vd,transform:Zi,map:kd,set:Sd,array:Fi,object:Ji,union:Li,intersection:qi,tuple:Id,record:Ui,nullable:Bi,nonoptional:Ki,default:Gi,prefault:Hi,catch:Qi,pipe:Yi,readonly:Xi,promise:Ed,optional:Ur,lazy:es};function Nt(e,n){if("_idmap"in e){let r=e,o=jt({...n,processors:id}),i={};for(let c of r._idmap.entries()){let[u,l]=c;ne(l,o)}let s={},a={registry:r,uri:n?.uri,defs:i};o.external=a;for(let c of r._idmap.entries()){let[u,l]=c;Pt(o,l),Ve(s,u,$t(o,l))}if(Object.keys(i).length>0){let c=o.target==="draft-2020-12"?"$defs":"definitions";s.__shared={[c]:i}}return{schemas:s}}let t=jt({...n,processors:id});return ne(e,t),Pt(t,e),$t(t,e)}var Od=new WeakSet([Object.prototype,Error.prototype]);function Kr(e,n,t){Object.defineProperty(e,n,{configurable:!0,enumerable:!1,get(){let r=t(this);return Object.defineProperty(this,n,{value:r,configurable:!0,writable:!0}),r},set(r){Object.defineProperty(this,n,{value:r,configurable:!0,writable:!0})}})}var Rd=(e,n)=>{Ha.init(e,n),e.name="ZodError";let t=Object.getPrototypeOf(e);if(Od.has(t))return;Od.add(t),Kr(t,"format",(r)=>(o)=>Ya(r,o)),Kr(t,"flatten",(r)=>(o)=>Qa(r,o)),Kr(t,"addIssue",(r)=>(o)=>{r.issues.push(o),r.message=JSON.stringify(r.issues,yt,2)}),Kr(t,"addIssues",(r)=>(o)=>{r.issues.push(...o),r.message=JSON.stringify(r.issues,yt,2)}),Object.defineProperty(t,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}})},Sh=b("ZodError",Rd),Fe=b("ZodError",Rd,void 0,{Parent:Error});var Ad=Er(Fe),jd=Or(Fe),Pd=Rr(Fe),$d=Ar(Fe),_d=ec(Fe),Nd=nc(Fe),Td=tc(Fe),zd=rc(Fe),Dd=oc(Fe),Vd=ic(Fe),Md=sc(Fe),Zd=ac(Fe);function Ch(){if(!Pe.localeError)Ze(hi())}function Gr(){if(!Pe.memoizer)Ze({memoizer:ul()})}var se=b("ZodType",(e,n)=>(Ch(),ie.init(e,n),e.def=n,e.type=n.type,e),{check(...e){let n=this.def;return this.clone(Me(n,{checks:[...n.checks??[],...e.map((t)=>typeof t==="function"?{_zod:{check:t,def:{check:"custom"},onattach:[]}}:t)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,n){return Qe(this,e,n)},brand(){return this},register(e,n){return e.add(this,n),this},refine(e,n){return this.check(ky(e,n))},superRefine(e,n){return this.check(Sy(e,n))},overwrite(e){return this.check(gn(e))},optional(){return Jd(this)},exactOptional(){return ay(this)},nullable(){return Ld(this)},nullish(){return Jd(Ld(this))},nonoptional(e){return fy(this,e)},array(){return j(this)},or(e){return X([this,e])},and(e){return oy(this,e)},transform(e){return qd(this,Gd(e))},default(e){return ly(this,e)},prefault(e){return py(this,e)},catch(e){return gy(this,e)},pipe(e){return qd(this,e)},readonly(){return by(this)},describe(e){let n=this.clone();return An.add(n,{description:e}),n},meta(...e){if(e.length===0)return An.get(this);let n=this.clone();return An.add(n,e[0]),n},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...n){return n.length===0?e(this):e(this,...n)},get "~standard"(){return Ir(this,"~standard",{...ci(this),jsonSchema:{input:At(this,"input"),output:At(this,"output")}})},set "~standard"(e){on(this,"~standard",e)},parse:function e(n,t){return Ad(this,n,t,{callee:e})},parseAsync:async function e(n,t){return await jd(this,n,t,{callee:e})},safeParse(e,n){return Pd(this,e,n)},async safeParseAsync(e,n){return $d(this,e,n)},get spa(){return this?.safeParseAsync},set spa(e){on(this,"spa",e)},validate(e,n){return Yo(this,e,n)},validateAsync(e,n){return Xo(this,e,n)},encode:function e(n,t){return _d(this,n,t,{callee:e})},decode:function e(n,t){return Nd(this,n,t,{callee:e})},encodeAsync:async function e(n,t){return await Td(this,n,t,{callee:e})},decodeAsync:async function e(n,t){return await zd(this,n,t,{callee:e})},safeEncode(e,n){return Dd(this,e,n)},safeDecode(e,n){return Vd(this,e,n)},async safeEncodeAsync(e,n){return Md(this,e,n)},async safeDecodeAsync(e,n){return Zd(this,e,n)},toJSONSchema(e){return ed(this,{})(e)},get description(){return An.get(this)?.description},get _def(){return this._zod.def}}),Ud=b("_ZodString",(e,n)=>{Nr.init(e,n),se.init(e,n),e._zod.processJSONSchema=(t,r,o)=>Pi(e,t,r,o)},qa({format:(e)=>$e(e).format??null,minLength:(e)=>$e(e).minimum??null,maxLength:(e)=>$e(e).maximum??null},{regex(...e){return this.check(yi(...e))},includes(...e){return this.check(xi(...e))},startsWith(...e){return this.check(vi(...e))},endsWith(...e){return this.check(ki(...e))},min(...e){return this.check(Un(...e))},max(...e){return this.check(Lr(...e))},length(...e){return this.check(qr(...e))},nonempty(...e){return this.check(Un(1,...e))},lowercase(e){return this.check(bi(e))},uppercase(e){return this.check(wi(e))},trim(){return this.check(Ii())},normalize(...e){return this.check(Si(...e))},toLowerCase(){return this.check(Ci())},toUpperCase(){return this.check(Ei())},slugify(){return this.check(Oi())}})),Eh=b("ZodString",(e,n)=>{Nr.init(e,n),Ud.init(e,n)},{email(e){return this.check(ml(Ph,e))},url(e){return this.check(xl(_h,e))},jwt(e){return this.check(Tl(Wh,e))},emoji(e){return this.check(vl(Nh,e))},guid(e){return this.check(gl($h,e))},uuid(e){return this.check(hl(Wr,e))},uuidv4(e){return this.check(yl(Wr,e))},uuidv6(e){return this.check(bl(Wr,e))},uuidv7(e){return this.check(wl(Wr,e))},nanoid(e){return this.check(kl(Th,e))},cuid(e){return this.check(Sl(zh,e))},cuid2(e){return this.check(Il(Dh,e))},ulid(e){return this.check(Cl(Vh,e))},base64(e){return this.check($l(Uh,e))},base64url(e){return this.check(_l(Bh,e))},xid(e){return this.check(El(Mh,e))},ksuid(e){return this.check(Ol(Zh,e))},ipv4(e){return this.check(Rl(Fh,e))},ipv6(e){return this.check(Al(Jh,e))},cidrv4(e){return this.check(jl(Lh,e))},cidrv6(e){return this.check(Pl(qh,e))},e164(e){return this.check(Nl(Kh,e))},datetime(e){return this.check(zl(Oh,e))},date(e){return this.check(Dl(Rh,e))},time(e){return this.check(Vl(Ah,e))},duration(e){return this.check(Ml(jh,e))}});function R(e){return fl(Eh,e)}var fe=b("ZodStringFormat",(e,n)=>{ae.init(e,n),Ud.init(e,n)}),Oh=b("ZodISODateTime",(e,n)=>{xu.init(e,n),fe.init(e,n)}),Rh=b("ZodISODate",(e,n)=>{vu.init(e,n),fe.init(e,n)}),Ah=b("ZodISOTime",(e,n)=>{ku.init(e,n),fe.init(e,n)}),jh=b("ZodISODuration",(e,n)=>{Su.init(e,n),fe.init(e,n)}),Ph=b("ZodEmail",(e,n)=>{uu.init(e,n),fe.init(e,n)});var $h=b("ZodGUID",(e,n)=>{au.init(e,n),fe.init(e,n)});var Wr=b("ZodUUID",(e,n)=>{cu.init(e,n),fe.init(e,n)});var _h=b("ZodURL",(e,n)=>{pu.init(e,n),fe.init(e,n)});var Nh=b("ZodEmoji",(e,n)=>{fu.init(e,n),fe.init(e,n)});var Th=b("ZodNanoID",(e,n)=>{mu.init(e,n),fe.init(e,n)});var zh=b("ZodCUID",(e,n)=>{gu.init(e,n),fe.init(e,n)});var Dh=b("ZodCUID2",(e,n)=>{hu.init(e,n),fe.init(e,n)});var Vh=b("ZodULID",(e,n)=>{yu.init(e,n),fe.init(e,n)});var Mh=b("ZodXID",(e,n)=>{bu.init(e,n),fe.init(e,n)});var Zh=b("ZodKSUID",(e,n)=>{wu.init(e,n),fe.init(e,n)});var Fh=b("ZodIPv4",(e,n)=>{Iu.init(e,n),fe.init(e,n)});var Jh=b("ZodIPv6",(e,n)=>{Eu.init(e,n),fe.init(e,n)});var Lh=b("ZodCIDRv4",(e,n)=>{Ou.init(e,n),fe.init(e,n)});var qh=b("ZodCIDRv6",(e,n)=>{Ru.init(e,n),fe.init(e,n)});var Uh=b("ZodBase64",(e,n)=>{ju.init(e,n),fe.init(e,n)});var Bh=b("ZodBase64URL",(e,n)=>{Pu.init(e,n),fe.init(e,n)});var Kh=b("ZodE164",(e,n)=>{$u.init(e,n),fe.init(e,n)});var Wh=b("ZodJWT",(e,n)=>{_u.init(e,n),fe.init(e,n)});var Bd=b("ZodNumber",(e,n)=>{li.init(e,n),se.init(e,n),e._zod.processJSONSchema=(t,r,o)=>$i(e,t,r,o),e.isFinite=!0},qa({minValue:(e)=>{let{minimum:n,exclusiveMinimum:t}=$e(e);return Math.max(n??Number.NEGATIVE_INFINITY,t??Number.NEGATIVE_INFINITY)},maxValue:(e)=>{let{maximum:n,exclusiveMaximum:t}=$e(e);return Math.min(n??Number.POSITIVE_INFINITY,t??Number.POSITIVE_INFINITY)},isInt:(e)=>{let{isInt:n,multipleOf:t}=$e(e);return!!n||!!t?.some(Number.isSafeInteger)},format:(e)=>$e(e).format??null},{gt(e,n){return this.check(Fr(e,n))},gte(e,n){return this.check(Ot(e,n))},min(e,n){return this.check(Ot(e,n))},lt(e,n){return this.check(Zr(e,n))},lte(e,n){return this.check(Et(e,n))},max(e,n){return this.check(Et(e,n))},int(e){return this.check(ge(e))},safe(e){return this.check(ge(e))},positive(e){return this.check(Fr(0,e))},nonnegative(e){return this.check(Ot(0,e))},negative(e){return this.check(Zr(0,e))},nonpositive(e){return this.check(Et(0,e))},multipleOf(e,n){return this.check(Jr(e,n))},step(e,n){return this.check(Jr(e,n))},finite(){return this}}));function ue(e){return Zl(Bd,e)}var Gh=b("ZodNumberFormat",(e,n)=>{Nu.init(e,n),Bd.init(e,n)});function ge(e){return Fl(Gh,e)}var Hh=b("ZodBoolean",(e,n)=>{Tu.init(e,n),se.init(e,n),e._zod.processJSONSchema=(t,r,o)=>_i(e,t,r,o)});function le(e){return Jl(Hh,e)}var Qh=b("ZodNull",(e,n)=>{zu.init(e,n),se.init(e,n),e._zod.processJSONSchema=(t,r,o)=>Ni(e,t,r,o)});function Yh(e){return Ll(Qh,e)}var Xh=b("ZodUnknown",(e,n)=>{Du.init(e,n),se.init(e,n),e._zod.processJSONSchema=(t,r,o)=>zi(e,t,r,o)});function Wn(){return ql(Xh)}var ey=b("ZodNever",(e,n)=>{Vu.init(e,n),se.init(e,n),e._zod.processJSONSchema=(t,r,o)=>Ti(e,t,r,o)});function hn(e){return Ul(ey,e)}var ny=b("ZodArray",(e,n)=>{Gr(),Mu.init(e,n),se.init(e,n),e._zod.processJSONSchema=(t,r,o)=>Fi(e,t,r,o),e.element=n.element},{min(e,n){return this.check(Un(e,n))},nonempty(e){return this.check(Un(1,e))},max(e,n){return this.check(Lr(e,n))},length(e,n){return this.check(qr(e,n))},unwrap(){return this.element}});function j(e,n){return Bl(ny,e,n)}var Kd=b("ZodObject",(e,n)=>{Gr(),Ju.init(e,n),se.init(e,n),e._zod.processJSONSchema=(t,r,o)=>Ji(e,t,r,o),$g(e,"shape",(t)=>t._zod.def.shape,!1)},{keyof(){return ce(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(Me(this._zod.def,{catchall:e}))},passthrough(){return this.clone(Me(this._zod.def,{catchall:Wn()}))},loose(){return this.clone(Me(this._zod.def,{catchall:Wn()}))},strict(){return this.clone(Me(this._zod.def,{catchall:hn()}))},strip(){return this.clone(Me(this._zod.def,{catchall:void 0}))},extend(e){return Ig(this,e)},safeExtend(e){return Cg(this,e)},merge(e){return Eg(this,e)},pick(e){return kg(this,e)},omit(e){return Sg(this,e)},partial(...e){return Za(Hd,this,e[0])},exactPartial(...e){return Za(Qd,this,e[0],"exactPartial")},required(...e){return Og(Yd,this,e[0])}});function I(e,n){let t={type:"object",shape:e??{},..._(n)};return new Kd(t)}function k(e,n){return new Kd({type:"object",shape:e,catchall:hn(),..._(n)})}var Wd=b("ZodUnion",(e,n)=>{di.init(e,n),se.init(e,n),e._zod.processJSONSchema=(t,r,o)=>Li(e,t,r,o),e.options=n.options});function X(e,n){return new Wd({type:"union",options:e,..._(n)})}var ty=b("ZodDiscriminatedUnion",(e,n)=>{Wd.init(e,n),Lu.init(e,n)});function jn(e,n,t){return new ty({type:"union",options:n,discriminator:e,..._(t)})}var ry=b("ZodIntersection",(e,n)=>{qu.init(e,n),se.init(e,n),e._zod.processJSONSchema=(t,r,o)=>qi(e,t,r,o)});function oy(e,n){return new ry({type:"intersection",left:e,right:n})}var Fd=b("ZodRecord",(e,n)=>{Gr(),Uu.init(e,n),se.init(e,n),e._zod.processJSONSchema=(t,r,o)=>Ui(e,t,r,o),e.keyType=n.keyType,e.valueType=n.valueType});function ee(e,n,t){if(!n||!n._zod)return new Fd({type:"record",keyType:R(),valueType:e,..._(n)});return new Fd({type:"record",keyType:e,valueType:n,..._(t)})}var ns=b("ZodEnum",(e,n)=>{Bu.init(e,n),se.init(e,n),e._zod.processJSONSchema=(r,o,i)=>Di(e,r,o,i),e.enum=n.entries,e.options=[...e._zod.values];let t=new Set(Object.keys(n.entries));e.extract=(r,o)=>{let i={};for(let s of r)if(t.has(s))i[s]=n.entries[s];else throw Error(`Key ${s} not found in enum`);return new ns({...n,checks:[],..._(o),entries:i})},e.exclude=(r,o)=>{let i={...n.entries};for(let s of r)if(t.has(s))delete i[s];else throw Error(`Key ${s} not found in enum`);return new ns({...n,checks:[],..._(o),entries:i})}});function ce(e,n){let t=Array.isArray(e)?Object.fromEntries(e.map((r)=>[r,r])):e;return new ns({type:"enum",entries:t,..._(n)})}var iy=b("ZodLiteral",(e,n)=>{Ku.init(e,n),se.init(e,n),e._zod.processJSONSchema=(t,r,o)=>Vi(e,t,r,o),e.values=new Set(n.values),Object.defineProperty(e,"value",{get(){if(n.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return n.values[0]}})});function x(e,n){return new iy({type:"literal",values:Array.isArray(e)?e:[e],..._(n)})}var sy=b("ZodTransform",(e,n)=>{Gr(),Wu.init(e,n),se.init(e,n),e._zod.processJSONSchema=(t,r,o)=>Zi(e,t,r,o),e._zod.parse=(t,r)=>{if(r.direction==="backward")throw new xt(e.constructor.name);t.addIssue=(i)=>{if(typeof i==="string")t.issues.push(Rn(i,t.value,n));else{let s=i;if(s.fatal)s.continue=!1;if(s.code??(s.code="custom"),!("input"in s))s.input=t.value;s.inst??(s.inst=e),t.issues.push(Rn(s))}};let o=n.transform(t.value,t);if(o instanceof Promise)return o.then((i)=>(t.value=i,t));return t.value=o,t}});function Gd(e){return new sy({type:"transform",transform:e})}var Hd=b("ZodOptional",(e,n)=>{pi.init(e,n),se.init(e,n),e._zod.processJSONSchema=(t,r,o)=>Ur(e,t,r,o),e.unwrap=()=>e._zod.def.innerType});function Jd(e){return new Hd({type:"optional",innerType:e})}var Qd=b("ZodExactOptional",(e,n)=>{Gu.init(e,n),se.init(e,n),e._zod.processJSONSchema=(t,r,o)=>Ur(e,t,r,o),e.unwrap=()=>e._zod.def.innerType});function ay(e){return new Qd({type:"optional",innerType:e})}var cy=b("ZodNullable",(e,n)=>{Hu.init(e,n),se.init(e,n),e._zod.processJSONSchema=(t,r,o)=>Bi(e,t,r,o),e.unwrap=()=>e._zod.def.innerType});function Ld(e){return new cy({type:"nullable",innerType:e})}var uy=b("ZodDefault",(e,n)=>{Qu.init(e,n),se.init(e,n),e._zod.processJSONSchema=(t,r,o)=>Gi(e,t,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function ly(e,n){return new uy({type:"default",innerType:e,get defaultValue(){return typeof n==="function"?n():Uo(n)}})}var dy=b("ZodPrefault",(e,n)=>{Yu.init(e,n),se.init(e,n),e._zod.processJSONSchema=(t,r,o)=>Hi(e,t,r,o),e.unwrap=()=>e._zod.def.innerType});function py(e,n){return new dy({type:"prefault",innerType:e,get defaultValue(){return typeof n==="function"?n():Uo(n)}})}var Yd=b("ZodNonOptional",(e,n)=>{Xu.init(e,n),se.init(e,n),e._zod.processJSONSchema=(t,r,o)=>Ki(e,t,r,o),e.unwrap=()=>e._zod.def.innerType});function fy(e,n){return new Yd({type:"nonoptional",innerType:e,..._(n)})}var my=b("ZodCatch",(e,n)=>{el.init(e,n),se.init(e,n),e._zod.processJSONSchema=(t,r,o)=>Qi(e,t,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function gy(e,n){return new my({type:"catch",innerType:e,catchValue:typeof n==="function"?n:Ua(n)})}var Xd=b("ZodPipe",(e,n)=>{fi.init(e,n),se.init(e,n),e._zod.processJSONSchema=(t,r,o)=>Yi(e,t,r,o),e.in=n.in,e.out=n.out});function qd(e,n){return new Xd({type:"pipe",in:e,out:n})}var hy=b("ZodPreprocess",(e,n)=>{Xd.init(e,n),nl.init(e,n)}),yy=b("ZodReadonly",(e,n)=>{tl.init(e,n),se.init(e,n),e._zod.processJSONSchema=(t,r,o)=>Xi(e,t,r,o),e.unwrap=()=>e._zod.def.innerType});function by(e){return new yy({type:"readonly",innerType:e})}var wy=b("ZodLazy",(e,n)=>{rl.init(e,n),se.init(e,n),e._zod.processJSONSchema=(t,r,o)=>es(e,t,r,o),e.unwrap=()=>e._zod.def.getter()});function xy(e){return new wy({type:"lazy",getter:e})}var vy=b("ZodCustom",(e,n)=>{ol.init(e,n),se.init(e,n),e._zod.processJSONSchema=(t,r,o)=>Mi(e,t,r,o)});function ky(e,n={}){return Kl(vy,e,n)}function Sy(e,n){return Wl(e,n)}function _e(e){let n=xy(()=>X([R(e),ue(),le(),Yh(),j(n),ee(R(),n)]));return n}function Iy(e,n){return new hy({type:"pipe",in:Gd(e),out:n})}function ts(e){for(let n of Object.values(e.graph.nodes)){if(n.kind!="task"||!("executor"in n.task)||n.task.executor.kind!="openapi")continue;for(let[t,r]of Object.entries(n.inputs))if(t.startsWith("auth.")&&r.kind=="value")throw TypeError("OpenAPI authentication accepts deployment variables and upstream outputs only.")}}var rs={choice:255,score:10};function ep(e){if(e.type==="noul"||e.criteria.length<=rs[e.type])return e;if(e.type==="choice")return{...e,criteria:e.criteria.slice(0,rs.choice)};return{...e,criteria:e.criteria.slice(0,rs.score)}}function Cy(e){let n=e.map(ep);return n.every((t,r)=>t===e[r])?e:n}function np(e){if(e.executor.kind!=="decision")return e;let n=e.executor.questions,t=Cy(n);if(t===n)return e;let r=e.outputs.map((o)=>{if(!("handle"in o))return o;let i=n.findIndex((s)=>s.name===o.handle);if(i<0||n[i]===t[i]||!ve(o.jsonSchema,tp(n[i])))return o;return{...o,jsonSchema:Ey(t[i])}});return{...e,executor:{...e.executor,questions:t},outputs:r}}var os={type:"number",minimum:0,maximum:1};function Ey(e){return tp(ep(e))}function tp(e){let n={type:{const:e.type}};if(e.type==="noul")n.noul=os;else{let t=e.type==="choice"?e.criteria.map((r)=>r.name):e.criteria.map((r,o)=>String(o));if(n.confidence=os,n.probabilities={type:"object",properties:Object.fromEntries(t.map((r)=>[r,os])),required:t,additionalProperties:!1},e.type==="choice")n.choice={type:"string",...t.length?{enum:t}:{}};else n.score={type:"number",minimum:0,maximum:Math.max(0,t.length-1)},n.legend={type:"object",properties:Object.fromEntries(t.map((r)=>[r,{type:"string"}])),required:t,additionalProperties:!1}}return{type:"object",properties:n,required:Object.keys(n)}}function Pn(e,n=0){if(n>64)throw TypeError("Value exceeds the maximum JSON depth.");if(e!=null&&typeof e=="object")for(let t of Object.values(e))Pn(t,n+1)}var yn=j(X([I({type:x("cron"),expression:R(),timezone:R()}),I({type:x("every"),unit:ce(["day","hour","minute","month","week"]),value:ue()})]));var is=["GET","POST","PUT","PATCH","DELETE"];function Hr(e){return e!=="GET"}var no=8,v=R(),_n=_e(),zt=j(v),Yn=I({description:v.optional(),jsonSchema:_n,nullable:le(),handle:v}),Oy=j(Yn.strict()),Le=Yn.extend({value:_n.optional()}),rp=I({collapsed:le().optional(),group:v}),Ry=I({kind:x("node"),nodeId:v,output:v,field:v.optional()}),sp=X([Ry,I({kind:x("binding"),bindingId:v})]),Dt=X([I({kind:x("unset")}),I({kind:x("value"),value:_n})]),ss=X([Dt,I({kind:x("sources"),sources:j(sp)})]),ap=ee(v,ss),Qn={inputs:j(X([Le,rp])),outputs:j(X([Yn,rp]))},Ay=k({kind:x("connector"),action:v,connectionId:v.optional(),connections:j(k({connectionId:v,alias:v.optional()}))}),Yr=X([Ay,k({kind:x("connector"),mode:x("shared")}),k({kind:x("connector"),mode:x("independent"),actions:j(k({action:v,connectionId:v.optional()}))}),k({kind:x("connector"),actionHints:j(v).optional(),connectionHints:j(k({action:v,connectionId:v,alias:v.optional()})).optional()})]),as=I({...Qn,name:v,moduleId:v,capabilities:j(Yr).optional()}),cp=X([I({kind:x("value"),value:_n}),I({kind:x("input"),input:v})]),jy=X([cp,I({kind:x("model")})]),Py=jn("type",[k({name:v,instructions:v,type:x("noul"),criteria:k({true:v.optional(),false:v.optional()}).optional()}),k({name:v,instructions:v,type:x("choice"),criteria:j(k({name:v,description:v}))}),k({name:v,instructions:v,type:x("score"),criteria:zt})]),Hn=I({...Qn,name:v,executor:X([I({kind:x("connector"),action:v,connectionId:v.optional(),outputMode:x("value").optional()}),I({kind:x("openapi"),sourceUrl:v,method:v,path:v,serverUrl:v,document:_n,auth:j(I({id:v,type:ce(["bearer","basic","apiKey"]),name:v.optional(),in:ce(["header","query"]).optional()}))}),k({kind:x("decision"),questions:j(Py)}),I({kind:x("llm"),mode:ce(["chat","json"])}),I({kind:x("agent"),code:le().optional(),model:v,prompt:v,maxRounds:ue(),tools:j(I({id:v,name:v,description:v,action:v,connectionId:v.optional(),approval:le(),inputs:j(Le.extend({source:jy}))})),notification:I({action:v,connectionId:v.optional(),inputDefinitions:j(Le),messageHandle:v,inputs:ee(v,cp)}).optional()}),k({kind:x("workflow"),flowId:v,revisionId:v})])}),cs=Hn.transform(np),op=X([I({kind:x("value"),value:_n.optional(),jsonSchema:_n.optional()}),I({kind:x("source"),source:sp})]),Xr={matchMode:ce(["first","all"]),cases:j(I({description:v.optional(),output:v,groups:j(I({expressions:j(I({left:op,operator:ce(["!=","<","<=","==",">",">=","contains","endsWith","hasKey","hasValue","isEmpty","isFalse","isNotEmpty","isNotNull","isNull","isTrue","notContains","notHasKey","notHasValue","startsWith"]),right:op.optional()}))}))}))},Vt={inputDefinitions:j(Le),prompt:v},$y=I({allowedMethods:hn().optional(),allowedOrigins:zt.optional(),noResponseBody:hn().optional(),responseData:v.optional(),responseHeaders:ee(v,v).optional(),responseStatusCode:ue().int().min(200).max(599).optional()}),eo={bodyFields:j(Le),method:ce(is),options:$y.optional()},ip={configInputs:Qn.inputs,definitionVersion:x(2),description:v,displayName:v,key:v,name:v,outputs:j(Yn).refine((e)=>new Set(e.map((n)=>n.handle)).size===e.length,"Duplicate Trigger output handle."),provider:v},_y=I({body:I({allowArray:le(),allowEmpty:le(),formats:j(ce(["form","json","multipart","text"]))}),methods:j(ce(["DELETE","GET","HEAD","PATCH","POST","PUT"])),successStatus:ue()}),us=j(v.min(1)).refine((e)=>new Set(e).size===e.length,"Duplicate source Flow ID."),$n={name:v,description:v.optional(),icon:v.optional()},Gn={maxExecutions:ue().int().positive().max(Number.MAX_SAFE_INTEGER).optional(),inputs:ap,name:v.optional(),description:v.optional(),icon:v.optional(),timeoutMs:ue().optional()},Qr=X([k({...Gn,kind:x("outputs"),outputDefs:j(Yn.strict()),outputMappings:ap}).omit({inputs:!0}),I({...Gn,inputs:ee(v,hn()),kind:x("condition"),...Xr}),I({...Gn,inputs:Wn().transform(()=>({})).default({}),kind:x("value"),values:j(Le)}),I({...Gn,kind:x("task"),task:X([as,cs]),additionalInputs:j(Le).optional()}),k({...Gn,kind:x("approval"),...Vt}).omit({timeoutMs:!0}),k({...Gn,kind:x("wait"),...Vt}).omit({timeoutMs:!0}),I({...$n,kind:x("manual")}),k({...$n,kind:x("start"),inputDefs:Oy}),k({...$n,kind:x("error"),sourceFlowIds:us.optional()}),I({...$n,kind:x("webhook"),...eo}),I({...$n,kind:x("cron"),cronTimes:yn}),I({...$n,kind:x("poll"),connectionId:v.min(1).optional(),config:ee(v,Dt),definition:I({...ip,type:x("poll")}),pollTimes:yn}),I({...$n,kind:x("integration"),connectionId:v.min(1).optional(),config:ee(v,Dt),definition:I({...ip,type:x("integration"),endpoint:_y})})]),qe={input:Le,port:Yn,ports:Qn,condition:k(Xr),wait:k(Vt),webhook:k(eo),schedule:yn,capabilities:j(Yr),connector:Hn.shape.executor.options[0].omit({kind:!0}).strict(),openapi:Hn.shape.executor.options[1].omit({kind:!0}).strict(),decision:Hn.shape.executor.options[2].omit({kind:!0}).strict(),llm:Hn.shape.executor.options[3].omit({kind:!0}).strict(),agent:Hn.shape.executor.options[4].omit({kind:!0,notification:!0}).strict()},ls=I({source:v,target:v,sourceHandle:v.optional()}),Ie={nodeId:v,target:hn().optional()},Ny=I({nodes:ee(v,Qr),edges:j(ls).default([])}),up=I({kind:x("variable"),target:v}),lp=I({name:v,imports:zt,source:v}),Ty=Iy(zy,I({bindings:ee(v,up),graph:Ny})),dp=I({modelVersion:X([x(2),x(4),x(5),x(6),x(7),x(no)]),document:Ty,modules:ee(v,lp)}),xS=dp.extend({kind:x("open-flow-flow-revision"),version:x(1)});function zy(e){let n=Ge(e);if(n.tasks!==void 0&&(n.tasks===null||typeof n.tasks!=="object"||Array.isArray(n.tasks)||Object.keys(n.tasks).length>0))throw TypeError("Independent Task definitions are no longer supported.");if(Object.values(Ge(Ge(n.graph).nodes)).some((r)=>Object.hasOwn(Ge(r),"taskId")))throw TypeError("Task references are no longer supported.");let t=n.subflows;if(t!==void 0&&(t===null||typeof t!=="object"||Array.isArray(t)||Object.keys(t).length>0))throw TypeError("Subflows are no longer supported.");if(Object.values(Ge(Ge(n.graph).nodes)).some((r)=>Ge(r).kind==="subflow"))throw TypeError("Subflow nodes are no longer supported.");if(["inputDefs","outputDefs","outputMappings"].some((r)=>Object.hasOwn(n,r)))throw TypeError("Workflow interface configuration must belong to Start and Outputs nodes.");if(Object.values(Ge(Ge(n.graph).nodes)).some((r)=>Ge(r).kind=="start"&&Object.hasOwn(Ge(r),"parameters")))throw TypeError("Legacy Start.parameters is unsupported; configure node.inputDefs.");return e}function Ge(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)?e:{}}function Xn(e){Pn(e);let n=dp.parse(e);return Vy(n),ts(n.document),n}var Dy={"graph.trigger.sources.set":{nodeId:v,before:us.optional(),value:us.optional()},"binding.create":{bindingId:v,binding:up},"binding.delete":{bindingId:v},"binding.target.set":{bindingId:v,before:v,value:v},"graph.edge.connect":{edge:ls,target:hn().optional()},"graph.edge.disconnect":{edge:ls,target:hn().optional()},"graph.node.create":{...Ie,node:Qr},"graph.node.replace":{...Ie,before:Qr,node:Qr},"graph.node.delete":Ie,"graph.node.field.set":X([I({...Ie,kind:x("graph.node.field.set"),field:x("connectionId"),before:v.min(1).optional(),value:v.min(1).optional()}),I({...Ie,kind:x("graph.node.field.set"),field:ce(["description","icon","name"]),before:v.optional(),value:v.optional()}),I({...Ie,kind:x("graph.node.field.set"),field:x("maxExecutions"),before:ue().int().positive().max(Number.MAX_SAFE_INTEGER).optional(),value:ue().int().positive().max(Number.MAX_SAFE_INTEGER).optional()}),I({...Ie,kind:x("graph.node.field.set"),field:x("timeoutMs"),before:ue().optional(),value:ue().optional()})]),"graph.node.input.set":{...Ie,handle:v,before:ss.optional(),value:ss.optional()},"graph.node.additional-inputs.set":{...Ie,before:j(Le).optional(),value:j(Le).optional()},"graph.node.condition.set":{...Ie,before:I(Xr),value:I(Xr)},"graph.node.values.set":{...Ie,before:j(Le),value:j(Le)},"graph.node.resolution.set":{...Ie,before:I(Vt),value:I(Vt)},"graph.node.webhook.set":{...Ie,before:I(eo),value:I(eo)},"graph.node.task.ports.set":{...Ie,before:I(Qn),value:I(Qn)},"graph.node.task.name.set":{...Ie,before:v,value:v},"graph.node.task.capabilities.set":{...Ie,before:j(Yr).optional(),value:j(Yr).optional()},"graph.trigger.config.set":{nodeId:v,name:v,before:Dt.optional(),value:Dt.optional()},"graph.trigger.schedule.set":{nodeId:v,before:yn,value:yn},"module.create":{moduleId:v,module:lp},"module.delete":{moduleId:v},"module.rename":{moduleId:v,before:v,name:v},"module.source.replace":{moduleId:v,beforeImports:zt,beforeSource:v,imports:zt,source:v},"graph.node.task.set":{...Ie,before:X([as,cs]),value:X([as,cs])}},pp=new Map(Object.entries(Dy).map(([e,n])=>[e,n instanceof se?n:I({kind:x(e),...n})])),vS=j(X([...pp.values()])).min(1);function Mt(e,n,t){try{return t(e)}catch(r){if(!(r instanceof Sh))throw r;throw TypeError(`operations[${n}]: ${r.issues.map((o)=>`${o.path.join(".")}: ${o.message}`).join("; ")}`,{cause:r})}}function fp(e,n){let{kind:t}=Mt(e,n,I({kind:v}).parse),r=pp.get(t);if(r==null)throw TypeError(`operations[${n}]: Unknown operation ${JSON.stringify(t)}.`);return Mt(e,n,r.parse)}function Vy(e){if(e.modelVersion<8&&Object.values(e.document.graph.nodes).some((n)=>n.kind=="outputs"))throw TypeError("Workflow outputs require Flow model version 8.");if(e.modelVersion<7&&Object.values(e.document.graph.nodes).some((n)=>n.kind=="start"))throw TypeError("Start Triggers require Flow model version 7.");if(e.modelVersion<6&&Object.values(e.document.graph.nodes).some((n)=>n.kind=="task"&&("executor"in n.task)))throw TypeError("Node-owned managed Tasks require Flow model version 6.");if(e.modelVersion<5&&Object.values(e.document.graph.nodes).some((n)=>n.kind=="error"))throw TypeError("Error workflows require Flow model version 5.")}function mp(e){return e.kind=="source"&&e.source.kind=="binding"?{kind:"value"}:e}function gp(e){return{...e,cases:e.cases.map((n)=>({...n,groups:n.groups.map((t)=>({...t,expressions:t.expressions.map((r)=>({...r,left:mp(r.left),...r.right==null?{}:{right:mp(r.right)}}))}))}))}}var qy=new Set(["const","enum","exclusiveMaximum","exclusiveMinimum","maximum","maxItems","maxLength","maxProperties","minimum","minItems","minLength","minProperties","multipleOf","pattern","required","type"]);function ps(e){return qy.has(e)}var fs=80;function to(e){let n=e.trim();if(n.length==0)return"empty";if(n.length>fs)return"tooLong";for(let t of n){let r=t.charCodeAt(0);if(r<=31||r>=127&&r<=159)return"controlCharacter"}if(!/^[\p{L}\p{N}](?:[\p{L}\p{N} _-]*[\p{L}\p{N}])?$/u.test(n))return"specialCharacter"}var hp=0;function bn(){let e=hp;return hp+=1,e}function nt(e){if(typeof e==="object"&&e!==null&&!Object.isFrozen(e)){for(let n of Object.getOwnPropertyNames(e)){let t=Reflect.get(e,n);nt(t)}Object.freeze(e)}return e}function ms(e,n){let t={};for(let r of n)if(r in e)t[r]=e[r];return t}function ro(e){if(typeof e!=="object"||e===null)return e;else if(Array.isArray(e)){let n=[];for(let[t,r]of e.entries())n[t]=ro(r);return n}else{let n={};for(let t in e)n[t]=ro(e[t]);return n}}function et(e,n){if(e===n)return!0;if(e===null)return!1;if(typeof e!=="object")return!1;if(typeof e!==typeof n)return!1;if(Array.isArray(e)){if(!Array.isArray(n))return!1;if(e.length!==n.length)return!1;for(let[t,r]of e.entries())if(!et(r,n[t]))return!1}else{if(Array.isArray(n))return!1;for(let t in e){if(!(t in n))return!1;if(!et(e[t],n[t]))return!1}for(let t in n)if(!(t in e))return!1}return!0}var y=Object.freeze({Equals:0,Containing:1,ContainedBy:2,Rejection:3,Intersection:4}),J=wn(y.Equals),D=wn(y.Containing),Z=wn(y.ContainedBy),q=wn(y.Rejection),W=wn(y.Intersection),sn=nt([[y.Equals,J],[y.Containing,D],[y.ContainedBy,Z],[y.Rejection,q],[y.Intersection,W]]),te=0,Je=(()=>{let e=te;for(let[n,t]of sn)e|=t;return e})();function Zt(e){return!!(e&J)}function Ft(e){return!!(e&D)}function Jt(e){return!!(e&Z)}function Lt(e){return!!(e&q)}function qt(e){return!!(e&W)}function wn(e){return 1<<e}function gs(e){let n=te,t=0,r={push:(o)=>{if(t===0)n=o;else n=Uy(n,o,e);return t+=1,n}};return Object.defineProperties(r,{result:{get:()=>n},count:{get:()=>t}}),r}function Uy(e,n,t){let r=te;for(let[o,i]of sn)if(i&e){for(let[s,a]of sn)if(a&n){if(r|=t(o,s),r===Je)return r}}return r}var de=Object.freeze({Save:0,OneOf:1,AllOf:2,AnyOf:3,Not:4,Swap:5});function yp(e,n){switch(e){case de.Save:return n[0];case de.OneOf:return By(n);case de.AllOf:case de.AnyOf:return Ut(e,n);case de.Not:case de.Swap:return hs(e,n[0])}}function xn(e){return hs(de.Swap,e)}function By(e){if(e.length===1)return e[0];let n=Ut(de.AnyOf,e),t=[];for(let i=0;i<e.length;++i)for(let s=i+1;s<e.length;++s){let a=e[i],c=e[s],u=Ut(de.AllOf,[a,c]);t.push(u)}let r=Ut(de.AnyOf,t),o=hs(de.Not,r);return Ut(de.AllOf,[n,o])}function Ut(e,n){if(n.length<0)throw Error("invalid expressions: empty array");let t;switch(e){case de.AllOf:{t=gs(Ky);break}case de.AnyOf:{t=gs(Wy);break}default:throw Error(`invalid operator ${e}`)}for(let r of n)t.push(r);return t.result}function hs(e,n){let t,r=te;switch(e){case de.Not:{t=Gy;break}case de.Swap:{t=Hy;break}default:throw Error(`invalid operator ${e}`)}for(let[o,i]of sn)if(i&n)r|=t(o);return r}function Ky(e,n){let t=te;switch(e){case y.Equals:{switch(n){case y.Equals:{t=J;break}case y.Containing:{t=J;break}case y.ContainedBy:{t=Z;break}case y.Rejection:{t=te;break}case y.Intersection:{t=Z;break}}break}case y.Containing:{switch(n){case y.Equals:{t=J;break}case y.Containing:{t=J|D;break}case y.ContainedBy:{t=Z;break}case y.Rejection:{t=q;break}case y.Intersection:{t=W|Z;break}}break}case y.ContainedBy:{switch(n){case y.Equals:{t=Z;break}case y.Containing:{t=Z;break}case y.ContainedBy:{t=Z;break}case y.Rejection:{t=te;break}case y.Intersection:{t=Z;break}}break}case y.Rejection:{switch(n){case y.Equals:{t=te;break}case y.Containing:{t=q;break}case y.ContainedBy:{t=te;break}case y.Rejection:{t=q;break}case y.Intersection:{t=q;break}}break}case y.Intersection:{switch(n){case y.Equals:{t=Z;break}case y.Containing:{t=W|Z;break}case y.ContainedBy:{t=Z;break}case y.Rejection:{t=q;break}case y.Intersection:{t=Z|q|W;break}}break}}return t}function Wy(e,n){let t=te;switch(e){case y.Equals:{switch(n){case y.Equals:{t=J;break}case y.Containing:{t=D;break}case y.ContainedBy:{t=J;break}case y.Rejection:{t=D;break}case y.Intersection:{t=D;break}}break}case y.Containing:{switch(n){case y.Equals:{t=D;break}case y.Containing:{t=D;break}case y.ContainedBy:{t=D;break}case y.Rejection:{t=D;break}case y.Intersection:{t=D;break}}break}case y.ContainedBy:{switch(n){case y.Equals:{t=J;break}case y.Containing:{t=D;break}case y.ContainedBy:{t=J|Z;break}case y.Rejection:{t=W;break}case y.Intersection:{t=D|W;break}}break}case y.Rejection:{switch(n){case y.Equals:{t=D;break}case y.Containing:{t=D;break}case y.ContainedBy:{t=W;break}case y.Rejection:{t=q;break}case y.Intersection:{t=W;break}}break}case y.Intersection:{switch(n){case y.Equals:{t=D;break}case y.Containing:{t=D;break}case y.ContainedBy:{t=D|W;break}case y.Rejection:{t=W;break}case y.Intersection:{t=D|W;break}}break}}return t}function Gy(e){let n=te;switch(e){case y.Equals:{n=q;break}case y.Containing:{n=q;break}case y.ContainedBy:{n=W;break}case y.Rejection:{n=J|D;break}case y.Intersection:{n=Z|W;break}}return n}function Hy(e){let n=te;switch(e){case y.Equals:{n=J;break}case y.Containing:{n=Z;break}case y.ContainedBy:{n=D;break}case y.Rejection:{n=q;break}case y.Intersection:{n=W;break}}return n}var Ne=Object.freeze({Leaf:0,Not:1,AllOf:2,AnyOf:3,OneOf:4});var ys=(e)=>(n,t)=>{let r={parent:null,swapped:!1,expressions:null,calculation:{operator:de.Save,results:[te],willSwap:!1,count:0}},o=[{parent:{node:r,index:0},swapped:!1,expressions:[n,t],calculation:null}],i=[];while(o.length>0||i.length>0){while(o.length>0){let l=o.pop();s(l)}while(i.length>0){let l=i.pop();c(l)}}function s(l){let p=J,[m,h]=l.expressions;if(!e.equals(m,h)){let g=e.describe(m);if(g.kind!==Ne.Leaf){let[N,L]=a(g,!1);l.expressions=null,l.calculation=N;for(let[M,De]of L.entries())o.push({parent:{node:l,index:M},swapped:l.swapped,expressions:[De,h],calculation:null});return}let E=e.describe(h);if(E.kind!==Ne.Leaf){let[N,L]=a(E,!0);l.expressions=null,l.calculation=N;for(let[M,De]of L.entries())o.push({parent:{node:l,index:M},swapped:!l.swapped,expressions:[De,m],calculation:null});return}if(p=e.calculate(m,h),e.observeCalculation?.(m,h,p,l.swapped),p===te)throw Error("cannot response expression as none")}l.expressions=null,l.calculation={operator:de.Save,results:[p],willSwap:!1,count:0},i.push(l)}function a(l,p){let m=de.Save,h;switch(l.kind){case Ne.Not:{m=de.Not,h=[l.expression];break}case Ne.AllOf:{m=de.AllOf,h=[...l.expressions];break}case Ne.AnyOf:{m=de.AnyOf,h=[...l.expressions];break}case Ne.OneOf:{m=de.OneOf,h=[...l.expressions];break}default:throw Error(`invalid kind ${l.kind}`)}return[{operator:m,willSwap:p,count:0,results:Array(h.length).fill(-1)},h]}function c(l){let{calculation:p,parent:m}=l,h=yp(p.operator,p.results);if(h===te)h=Z;if(p.willSwap)h=xn(h);if(m){let g=m.node.calculation,E=g.results;if(E[m.index]=h,g.count+=1,g.count>=E.length)i.push(m.node)}}let u=r.calculation.results[0];if(u===0)throw Error("cannot find result of root");return u};class oo extends Error{constructor(e=[]){super(Qy(e));this.name="SchemaError",this.items=e}}var tt=Object.freeze({Compiled:0,External:1});function rt(e){switch(e.kind){case tt.Compiled:{let{message:n,path:t}=e;return`${n} (at ${t.length>0?t.join("."):"$root"})`}case tt.External:return String(e.error)}}function Qy(e){switch(e.length){case 0:return"without any items";case 1:return rt(e[0]);default:return`${rt(e[0])} ... omit the rest ${e.length-1} items`}}var Yy=new Set(["type","enum","const","multipleOf","maximum","exclusiveMaximum","minimum","exclusiveMinimum","maxLength","minLength","pattern","items","additionalItems","maxItems","minItems","uniqueItems","contains","maxProperties","minProperties","required","properties","patternProperties","additionalProperties","dependencies","propertyNames","if","then","else","allOf","anyOf","oneOf","not","format","contentMediaType","contentEncoding","definitions"]);function nn(e){return Yy.has(e)}function bp(e){for(let n in e)if(nn(n))return!1;return!0}function Re(e,...n){return{...e,path:[...e.path,...n]}}function Te(e){if(typeof e==="boolean")throw Error("JSONSchema7Definition cannot be boolean");return e}function vn({path:e,errors:n},t,...r){n.push(wp(e,r,t))}function G({path:e,warns:n},t,...r){n.push(wp(e,r,t))}function wp(e,n,t){return{kind:tt.Compiled,message:t,path:[...e,...n]}}function io(e){for(let n in e){let t=e[n];if(t===void 0)delete e[n];else if(t&&typeof t==="object"){if(Array.isArray(t)){if(t.length===0)delete e[n]}else if(Xy(t))delete e[n]}}return e}function Xy(e){for(let n in e)return!1;return!0}var Bt=Symbol("compiledId"),bs=Symbol("compiledKind"),ws=Symbol("compiledPath"),xp=Symbol("validatorLoader"),S=Object.freeze({Extends:0,Never:1,Any:2,Null:3,String:4,Numeric:5,Boolean:6,Object:7,Array:8,Not:9,Combination:10,EnumOrConst:11}),kn=nt(so(S.Any,bn(),{},()=>()=>!0)),Kt=nt(so(S.Never,bn(),{type:"string",maxLength:0,minLength:1},()=>()=>!1));function Wt(e){if(e===null||typeof e!=="object")return!1;return Bt in e}function ze(e){if(e===null||typeof e!=="object")return!1;return Bt in e&&bs in e}function K(e){if(ze(e))return e[bs];else return S.Extends}function Nn(e){if(ze(e)||Wt(e))return e[Bt];else return e.id}function xs(e){return ze(e)?e[ws]:void 0}function vs(e){if(e===null||typeof e!=="object")return e;return Object.defineProperty(e,Bt,{value:bn(),configurable:!1,writable:!1,enumerable:!1}),e}function me(e,n,t,r=[]){return so(e,bn(),n,t&&(()=>t.compile(n)),r)}function Gt(e){return so(S.Never,bn(),{...e},e[xp],e[ws])}function so(e,n,t,r,o=[]){let i=null;return Object.defineProperties(t,{[bs]:{value:e,configurable:!1,writable:!1,enumerable:!1},[Bt]:{value:n,configurable:!1,writable:!1,enumerable:!1},[ws]:{value:o,configurable:!1,writable:!1,enumerable:!1},[xp]:{value:r,configurable:!1,writable:!1,enumerable:!1},isValid:{configurable:!1,enumerable:!1,get:()=>{if(r){if(!i)i=r();return i}else return}}}),t}function Sp(e,n){let t=eb(e,n),r=vp(e,"maxItems",n),o=vp(e,"minItems",n),i=nb(e,n),s=n.uniqueItems,a;if(Array.isArray(t))a=tb(e,n);else if(n.additionalItems)G(e,"it is needless when items is not array","additionalItems");if(!t||!i||a===null)return null;let c=!1,u=!1;if(Array.isArray(t)){if(r!==void 0&&r<=t.length)t=t.splice(r),a=kp(a,e.delegate);let m=t.findIndex((h)=>K(h)===S.Never);if(m!==-1){if(t=t.splice(m),a=kp(a,e.delegate),r===void 0)r=t.length,u=!0}if(o!==void 0&&t.length<o)G(e,`length(${t.length}) of items if less than minItems(${o})`),c=!0;if(t.length===0&&a&&K(a)===S.Never)c=!0}else if(K(t)===S.Never)c=!0;if(r!==void 0&&o!==void 0&&r<o){if(!u)G(e,`maxItems(${r}) is less than minItems(${o})`);c=!0}let l=c?S.Never:S.Array,p=io({type:"array",items:t,contains:i,uniqueItems:s,maxItems:r,minItems:o,additionalItems:a});return me(l,p,e.delegate,e.path)}function eb(e,{items:n}){if(!n)return me(S.Any,{},e.delegate,e.path);if(Array.isArray(n)){let t=[],r=!1;for(let[o,i]of n.entries()){let s=Re(e,"items",o),a=Ae(s,Te(i));if(!a){r=!0;continue}t.push(a)}if(r)return null;return t}else{let t=Re(e,"items"),r=Te(n);return Ae(t,r)}}function vp(e,n,t){let r=t[n];if(r===void 0)return;if(Number.isNaN(r)){G(e,"find NaN",n);return}if(r<0){G(e,`find invalid number ${r}`,n);return}return r}function nb(e,{contains:n}){if(!n)return me(S.Any,{},e.delegate,e.path);let t=Re(e,"contains"),r=Te(n);return Ae(t,r)}function tb(e,{additionalItems:n}){switch(typeof n){case"boolean":if(n)return me(S.Any,{},e.delegate,e.path);else return!1;case"object":{let t=Re(e,"additionalItems");return Ae(t,n)}default:return me(S.Any,{},e.delegate,e.path)}}function kp(e,n){if(e===void 0)return me(S.Never,{type:"string",maxLength:0,minLength:1},n);else if(ze(e))return K(e)===S.Never?e:Gt(e);else return e}var Ip=Object.freeze(["allOf","anyOf","oneOf"]);function ks(e,n,t,r){if(t.length===0)return vn(e,"disable empty list",n),null;let o=[];for(let[c,u]of t.entries()){let l=Re(e,n,c),p=Te(u),m=Ae(l,p);if(m)o.push(m)}if(o.length<t.length)return null;let i=0,s=0;for(let c of o)switch(K(c)){case S.Any:{i+=1;break}case S.Never:{s+=1;break}}let a=S.Combination;switch(n){case"allOf":{if(s>0)a=S.Never;else if(i===o.length)a=S.Any;else if(!rb(o))a=S.Never;break}case"anyOf":{if(i>0)a=S.Any;else if(s===o.length)a=S.Never;break}case"oneOf":{if(i>1)a=S.Never;else if(s===o.length)a=S.Never;else if(i===1&&s===o.length-1)a=S.Any;break}}return me(a,{[n]:o},r,e.path)}function rb(e){let n=null;for(let t of e){let r=K(t);switch(r){case S.Any:case S.Never:break;default:{if(n===null)n=r;else if(n!==r)return!1;break}}}return!0}var Ce=Object.freeze({Valid:0,Invalid:1,Unknown:2});function tn(e,n){let t=e.isValid;if(t)if(t(n)===!0)return Ce.Valid;else return Ce.Invalid;else return Ce.Unknown}function Cp(e,n,t,r){let o,i=!1;if(n){if(n.length===0)return vn(e,"disable empty list","enum"),null;o=[];for(let[c,u]of n.entries())switch(tn(r,u)){case Ce.Valid:{o.push(vs(u));break}case Ce.Invalid:{G(e,"cannot pass JSON schema of currently schema object","enum",c);break}}if(o.length===0)G(e,"all of elements from list is rejected by currently schema object","enum")}if(t!==void 0&&tn(r,t)===Ce.Invalid)i=!0;if(o){if(o.length===0)i=!0;else if(t!==void 0){let c=!1;for(let u of o)if(et(u,t)){c=!0;break}if(!c)i=!0}}let s=i?S.Never:S.EnumOrConst,a={};if(r.type)a.type=r.type;if(o)a.enum=o;if(t!==void 0)a.const=vs(ro(t));return me(s,a,e.delegate,e.path)}var ob=new Set(["type","maxProperties","minProperties","required","properties","patternProperties","additionalProperties","dependencies","propertyNames"]);function Op(e,n){let t=Object.keys(n).filter((g)=>!ob.has(g)&&nn(g));if(t.length>0)G(e,`type="object" will exclude other keys: ${t.toSorted().join(", ")}`);let r=Ep(e,"maxProperties",n),o=Ep(e,"minProperties",n),i=ib(e,n),s=sb(e,n),a=ab(e,n),c=ub(e,n);if(!i||!s||!a||!c)return null;let u=cb(e,s,a,n);if(!u)return null;let l=lb(i,s,a,u),p=db(e,l,c,n),m=pb(e,i,u,p,r,o)?S.Never:S.Object,h=io({type:"object",required:p,properties:u,minProperties:o,maxProperties:r,additionalProperties:i,patternProperties:gb(s),dependencies:hb(c,n),propertyNames:a});return me(m,h,e.delegate,e.path)}function Ep(e,n,t){let r=t[n];if(r===void 0)return;if(Number.isNaN(r)){G(e,"find NaN",n);return}if(r<0){G(e,`find invalid number ${r}`,n);return}return r}function ib(e,{additionalProperties:n}){if(n===!1)return me(S.Never,{type:"string",maxLength:0,minLength:1},e.delegate,e.path);if(typeof n!=="object")return me(S.Any,{},e.delegate,e.path);let t=Re(e,"additionalProperties"),r=Te(n);return Ae(t,r)}function sb(e,{patternProperties:n}){let t=!1,r={};for(let o in n){let i=mb(o);if(i instanceof Error){G(e,`property name invalid. ${o}`,"patternProperties",o);continue}let s=Te(n[o]),a=Re(e,"patternProperties",o),c=Ae(a,s);if(!c){t=!0;continue}r[o]=[c,i]}if(t)return null;return r}function ab(e,{propertyNames:n}){if(!n)return me(S.Any,{},e.delegate,e.path);n=Te(n);let t=Re(e,"propertyNames"),r=Ae(t,n);if(!r)return null;let o=K(r);if(o!==S.String&&o!==S.Any)return Gt(r);return r}function cb(e,n,t,{properties:r}){let o=!1;if(!r)return{};let i={};for(let s in r){if(tn(t,s)===Ce.Invalid){G(e,`key ${JSON.stringify(s)} cannot pass JSON schema from propertyNames`,"properties");continue}let a=Ap(n,s);if(a&&K(a)===S.Never){G(e,`key ${JSON.stringify(s)} matches a pattern that has a impossible(never) schema`,"properties");continue}let c=Te(r[s]),u=Re(e,"properties",s),l=Ae(u,c);if(!l){o=!0;continue}i[s]=l}if(o)return null;return i}function ub(e,{dependencies:n}){if(!n)return[{},{}];let t={},r={};for(let o in n){let i=Te(n[o]);if(Array.isArray(i)){let{keys:s,duplicated:a}=Rp(i);if(a)G(e,`found duplicated property names: ${a.join(", ")}`,"dependencies",o);t[o]=s}else{let s=Re(e,"dependencies",o),a=Ae(s,i);if(a){let c=K(a);if(c===S.Object||c===S.Any)r[o]=a;else if(c===S.Extends)r[o]=Kt;else r[o]=Gt(a)}}}return[t,r]}function lb(e,n,t,r){return(o)=>{if(tn(t,o)===Ce.Invalid)return!0;let i=Ap(n,o);if(i&&K(i)===S.Never)return!0;let s=r[o]??e;if(K(s)===S.Never)return!0;return!1}}function db(e,n,t,{required:r}){if(!r)return[];let o=Rp(r);if(o.duplicated)G(e,`found duplicated required keys: ${o.duplicated.join(", ")}`,"required");let i=[],s=[];for(let a of o.keys)if(fb(t,a).some((u)=>n(u)))s.push(a);else i.push(a);if(s.length>0)G(e,`key ${s.map((a)=>JSON.stringify(a)).join(", ")} will ban by another condition`,"required");return i}function pb(e,n,t,r,o,i){if(o!==void 0&&i!==void 0&&o<i)return G(e,`maxProperties(${o}) is less than minProperties(${i})`),!0;if(o!==void 0&&r.length>o)return G(e,`length(${r.length}) of required is greater than maxProperties(${o})`),!0;if(i!==void 0&&r.length<i)return G(e,`length(${r.length}) of required is less than minProperties(${i})`),!0;if(K(n)!==S.Never)return!1;for(let s in t){let a=t[s];if(K(a)!==S.Never)return!1}return!0}function fb([e,n],t){let r=[t],o=new Set(r);while(r.length>0){let s=r.pop(),a=n[s],c=e[s];if(a){if(K(a)===S.Object)i(a.required)}if(c)i(c)}function i(s){if(s){for(let a of s)if(!o.has(a))o.add(a),r.push(a)}}return[...o]}function Rp(e){let n=new Set,t=new Set;for(let r of e)if(n.has(r))t.add(r);else n.add(r);if(t.size===0)return{keys:[...e],duplicated:null};else return{keys:[...n],duplicated:[...t]}}function Ap(e,n){for(let t in e){let[r,o]=e[t];if(o.test(n))return r}return null}function mb(e){try{return new RegExp(e,"i")}catch(n){if(n instanceof SyntaxError)return n;else throw n}}function gb(e){let n={};for(let t in e)n[t]=e[t][0];return n}function hb([e,n],{dependencies:t}){let r={};for(let o in t){let i=e[o],s=n[o];r[o]=i||s}return r}var Ss=new Set(["type","multipleOf","maximum","exclusiveMaximum","minimum","exclusiveMinimum"]),jp=new Set(["type","format","maxLength","minLength","pattern"]);function $p(e,n){let{type:t}=n;switch(t){case"number":case"integer":return yb(e,n);case"string":return wb(e,n);case"boolean":case"null":{let r=Object.keys(n).filter((s)=>nn(s)&&s!=="type");if(r.length>0)G(e,`key "type" will exclude other keys: ${r.toSorted().join(", ")}`);let o=t==="null"?S.Null:S.Boolean;return me(o,{type:t},e.delegate,e.path)}default:return vn(e,`invalid type ${JSON.stringify(t)}`),null}}function yb(e,n){let t=Object.keys(n).filter((l)=>!Ss.has(l)&&nn(l));if(t.length>0)G(e,`type=${JSON.stringify(n.type)} will exclude other keys: ${t.toSorted().join(", ")}`);let r=ms(n,Ss);for(let l of Ss){let p=r[l];if(l!=="type"&&p!==void 0&&Number.isNaN(p))G(e,"found NaN",l),delete r[l]}let{maximum:o,exclusiveMaximum:i,minimum:s,exclusiveMinimum:a}=r;if(o!==void 0&&i!==void 0){if(o===i)delete r.maximum;else if(o<i)delete r.exclusiveMaximum;else if(o>i)delete r.maximum}if(s!==void 0&&a!==void 0){if(s===a)delete r.minimum;else if(s<a)delete r.exclusiveMinimum;else if(s>a)delete r.minimum}let{multipleOf:c}=r;if(c===0)delete r.multipleOf,r.type="number",G(e,"cannot be 0","multipleOf");let u=S.Numeric;if(!bb(r))u=S.Never;return me(u,r,e.delegate,e.path)}function bb(e){let{maximum:n,exclusiveMaximum:t,minimum:r,exclusiveMinimum:o}=e;if(n!==void 0&&r!==void 0)return n>=r;else if(t!==void 0&&r!==void 0)return t>r;else if(n!==void 0&&o!==void 0)return n>o;else if(t!==void 0&&o!==void 0)return t>o;else return!0}function wb(e,n){let t=Object.keys(n).filter((a)=>!jp.has(a)&&nn(a));if(t.length>0)G(e,`type="string" will exclude other keys: ${t.toSorted().join(", ")}`);let r=ms(n,jp);Pp(e,r,"maxLength"),Pp(e,r,"minLength");let{maxLength:o,minLength:i}=r,s=S.String;if(o!==void 0){if(o<0)s=S.Never;else if(o!==void 0&&i!==void 0&&o<i)s=S.Never}return me(s,r,e.delegate,e.path)}function Pp(e,n,t){let r=n[t];if(r!==void 0){if(Number.isNaN(r))G(e,"found NaN",t),delete n[t]}}var _p=Object.freeze([]);function ao(e,n,t,r){if(ze(e))return{schema:e,warns:_p};if(n.isExtendsSchema(e))return{schema:e,warns:_p};if(r){let s=r.isSchema(e);if(typeof s==="object"){let a=[];for(let c of s)a.push({kind:tt.External,error:c});if(a.length>0)return a}else if(s===!1)throw Error("it is not a JSON Schema 7")}let o={delegate:r,payload:t,extends:n,path:[],errors:[],warns:[]},i=Ae(o,e);if(i)Np(o.errors.length===0,"found errors (it should be empty)");else return Np(o.errors.length>0,"cannot found any errors"),o.errors;return{schema:i,warns:o.warns}}function Np(e,n){if(!e)throw Error(n)}function Ae(e,n){if(e.extends.isExtendsSchema(n))return n;if(ze(n))return n;let t=e.extends.tryCompiledExtendsSchema(n,e.payload);if(t)return t;let r=n,o=!1,{enum:i,const:s}=n;if(i||s!==void 0){let{enum:c,const:u,...l}=n;r=l,o=!0}let a=xb(e,r);if(a&&o)a=Cp(e,i,s,a);if(!a)return null;return a}function xb(e,n){for(let t of Ip){let r=n[t];if(r){let o=Object.keys(n).filter((s)=>nn(s)&&s!==t);if(o.length>0)G(e,`composition key ${JSON.stringify(t)} will exclude other keys: ${o.toSorted().join(", ")}`);let i=ks(e,t,r);if(!i)return null;return i}}{let t=Te(n.not);if(t){let r=Object.keys(n).filter((a)=>nn(a)&&a!=="not");if(r.length>0)G(e,`key "not" will exclude other keys: ${r.toSorted().join(", ")}`);let o=Re(e,"not"),i=Ae(o,t);if(!i)return null;let s=S.Not;switch(K(i)){case S.Never:{s=S.Any;break}case S.Any:{s=S.Never;break}}return me(s,{not:i},e.delegate,e.path)}}if(n.type){let{type:t}=n;if(Array.isArray(t)){let{type:r,...o}=n;return ks(e,"anyOf",t.map((i)=>({...o,type:i})))}switch(t){case"object":return Op(e,n);case"array":return Sp(e,n);default:return $p(e,n)}}if(bp(n))return me(S.Any,{},e.delegate,e.path);return vn(e,"unrecognized"),null}class Is{constructor(e){let n=Object.freeze(e.toSorted());if(n.length>32)throw Error(`cannot define ${n.length} keys which is greater than 32`);this.keys=n,this.clazz=class extends Tp{constructor(t){super(n,t)}};for(let[t,r]of this.keys.entries()){let o=1<<t;Object.defineProperty(this.clazz.prototype,r,{enumerable:!0,get:function(){return!!(this.int32&o)},set:function(s){if(s)this.int32|=o;else this.int32&=~o}})}}toBundle(e){let n=0;if(typeof e==="number")n=e;else if(e){for(let[t,r]of this.keys.entries())if(e[r])n|=1<<t}return new this.clazz(n)}}class Tp{constructor(e,n){this.keys=e,this.int32=n}toInt32(){return this.int32}toString(){let e={};for(let n of this.keys)e[n]=this[n];return JSON.stringify(e)}}function co(e){return new zp(e)}class zp{constructor(e){this.description=new Is(e)}get keys(){return this.description.keys}variable(e){let n;if(e)n=this.description.toBundle(e).toInt32();return new Dp(this.description,n)}}class Dp{constructor(e,n){this.values=new Set;if(this.description=e,n!==void 0)this.values.add(n)}[Symbol.iterator](){let e=this.values[Symbol.iterator]();return{next:()=>{let n=e.next();if(n.done)return n;else return{done:!1,value:this.description.toBundle(n.value)}}}}assign(e){let{values:n}=e;for(let t of n)this.values.add(t);return this}push(e,n){let t=new Set;for(let r of this.values)for(let[o,i]of sn)if(e&i){let s=this.description.toBundle(r);n(o,s),t.add(s.toInt32())}this.values=t}update(e){let n=new Set;for(let t of this.values){let r=this.description.toBundle(t);e(r),n.add(r.toInt32())}this.values=n}}function Sn(e,n){let[t]=e,[r]=n;if(t.num<r.num)return vb(e,n);else if(t.num>r.num)return kb(e,n);else return Sb(e,n)}function vb(e,n){let[t,r]=e,[o,i]=n;if(r.num<=o.num){let s=r.exclusive,a=o.exclusive;if(r.num<o.num||s||a)return{left:{fromLeft:!0,range:e},right:{fromLeft:!1,range:n}}}if(r.num<=i.num){let s=!0,a=!1;if(r.num===i.num){let c=r.exclusive,u=i.exclusive;s=c!==u,a=!c&&u}if(!a){let c;if(s)c={fromLeft:!1,range:[Ue(r),i]};return{left:{fromLeft:!0,range:[t,Ue(o)]},center:[o,r],right:c}}}return{left:{fromLeft:!0,range:[t,Ue(o)]},center:[o,i],right:{fromLeft:!0,range:[Ue(i),r]}}}function kb(e,n){let[t,r]=e,[o,i]=n;if(t.num>=i.num){let s=i.exclusive,a=t.exclusive;if(t.num>i.num||s||a)return{left:{fromLeft:!1,range:n},right:{fromLeft:!0,range:e}}}if(i.num<=r.num){let s=!0,a=!1;if(r.num===i.num){let c=i.exclusive,u=r.exclusive;s=c!==u,a=!c&&u}if(!a){let c;if(s)c={fromLeft:!0,range:[Ue(i),r]};return{left:{fromLeft:!1,range:[o,Ue(t)]},center:[t,i],right:c}}}return{left:{fromLeft:!1,range:[o,Ue(t)]},center:[t,r],right:{fromLeft:!1,range:[Ue(r),i]}}}function Sb(e,n){let[t,r]=e,[o,i]=n,s=t.exclusive,a=o.exclusive,c,u=t;if(!s&&a)u=o,c={fromLeft:!0,range:[t,Ue(o)]};else if(s&&!a)c={fromLeft:!1,range:[o,Ue(t)]};if(r.num<=i.num){let l=!0,p=!1;if(r.num===i.num){let m=r.exclusive,h=i.exclusive;l=m!==h,p=!m&&h}if(!p){let m;if(l)m={fromLeft:!1,range:[Ue(r),i]};return{left:c,center:[u,r],right:m}}}return{left:c,center:[u,i],right:{fromLeft:!0,range:[Ue(i),r]}}}function Ue(e){return{num:e.num,exclusive:!e.exclusive}}var ot=(e)=>(n=e,t=Number.POSITIVE_INFINITY,r=e,o=Number.POSITIVE_INFINITY)=>{let{left:i,center:s,right:a}=Sn([{num:n,exclusive:!1},{num:t,exclusive:!1}],[{num:r,exclusive:!1},{num:o,exclusive:!1}]),c,u,l;if(i)c={min:i.range[0].num,max:i.range[1].num,isFrom1:i.fromLeft};if(a)u={min:a.range[0].num,max:a.range[1].num,isFrom1:a.fromLeft};if(s)l={min:s[0].num,max:s[1].num};return{left:c,right:u,intersection:l}};function it({left:e,right:n,intersection:t}){if(!t)return y.Rejection;let r=!1,o=!1;if(e)if(e.isFrom1)r=!0;else o=!0;if(n)if(n.isFrom1)r=!0;else o=!0;if(r&&o)return y.Intersection;if(r)return y.Containing;if(o)return y.ContainedBy;return y.Equals}var Ib=ot(0),Cb=co(["hasCommon","hasExtra1","hasExtra2","hasRejection","hasCommonBroken"]);function Mp({calculate:e},n,t){let r=Ib(n.minItems,n.maxItems,t.minItems,t.maxItems),o=it(r);if(o===y.Rejection)return q;let[i,s]=Vp(n),[a,c]=Vp(t),u=Math.max(i.length,a.length)+1,l=Math.min(u,r.intersection.max),p=Cb.variable({}),m=Math.min(n.minItems??0,t.minItems??0);for(let g=0;g<l;g++){let E=i[g]??s,P=a[g]??c,N=e(E,P);p.push(N,(L,M)=>{switch(L){case y.Equals:{if(!M.hasRejection)M.hasCommon=!0;break}case y.Containing:{if(!M.hasRejection)M.hasCommon=!0;M.hasExtra1=!0;break}case y.ContainedBy:{if(!M.hasRejection)M.hasCommon=!0;M.hasExtra2=!0;break}case y.Intersection:{if(!M.hasRejection)M.hasCommon=!0;M.hasExtra1=!0,M.hasExtra2=!0;break}case y.Rejection:{if(g<m)M.hasCommonBroken=!0;M.hasRejection=!0,M.hasExtra1=!0,M.hasExtra2=!0;break}}})}p.update((g)=>{switch(o){case y.Containing:{g.hasExtra1=!0;break}case y.ContainedBy:{g.hasExtra2=!0;break}case y.Intersection:{g.hasExtra1=!0,g.hasExtra2=!0;break}}if(n.uniqueItems&&!t.uniqueItems&&(t.maxItems??Number.POSITIVE_INFINITY)>1)g.hasExtra2=!0;else if(!n.uniqueItems&&t.uniqueItems&&(n.maxItems??Number.POSITIVE_INFINITY)>1)g.hasExtra1=!0;if(n.maxItems===0||t.maxItems===0){if(g.hasCommon=!0,n.maxItems!==0)g.hasExtra1=!0;if(t.maxItems!==0)g.hasExtra2=!0}});let h=te;for(let{hasExtra1:g,hasExtra2:E,hasCommon:P,hasCommonBroken:N}of p){let L=P;if(N)L=!1;if(!L)h|=q;else if(g&&E)h|=W;else if(g)h|=D;else if(E)h|=Z;else h|=J}return h}function Vp({items:e,additionalItems:n}){if(Array.isArray(e))return[e,n??kn];else return[[],e??kn]}function Zp(e){let n=new Map;return(t,r)=>{let o=Wt(t),i=Wt(r);if(o!==i)return!1;if(!o)return t===r;return Jp(n,t,r,e)}}function Fp(e){let n=new Map;return(t,r)=>Jp(n,t,r,e)}function Jp(e,n,t,r){let o=Nn(n),i=Nn(t),s=`${o}/${i}`,a=e.get(s);if(a===void 0)e.set(s,a=r(n,t));return a}function qp(e,n,t){let r=Cs(n),o=Cs(t),i=!1,s=!1,a=!1;for(let c of r){if(Lp(e,o,c))a=!0;else i=!0;if(i&&a)break}for(let c of o){if(Lp(e,r,c))a=!0;else s=!0;if(s&&a)break}if(!a)return q;if(i&&s)return W;if(i)return D;if(s)return Z;return J}function Es(e,n){let t=!1,r=!1;for(let o of Cs(e)){switch(tn(n,o)){case Ce.Valid:{t=!0;break}case Ce.Invalid:{r=!0;break}case Ce.Unknown:return Je}if(t&&r)break}if(t&&r)return W;if(t)return J|Z;if(r)return q;if(K(n)===S.Never)return J;return Z}function Cs({const:e,enum:n}){if(e!==void 0)return[e];if(n)return n;throw Error("invalid branch")}function Lp({isEquals:e},n,t){for(let r of n)if(e(r,t))return!0;return!1}function Up(e){function n(s,a){let c=e.isExtendsSchema(s),u=e.isExtendsSchema(a);if(c||u)return e.equals(s,a);else return r(s,a)}let t=new Map;function r(s,a){let c=Nn(s),u=Nn(a);if(c===u)return!0;let l=`${c}/${u}`,p=t.get(l);if(p===void 0)p=o(s,a),t.set(l,p);return p}function o(s,a){if(Array.isArray(s)){if(!Array.isArray(a))return!1;if(s.length!==a.length)return!1;for(let[c,u]of s.entries())if(!i(u,a[c]))return!1}else{if(Array.isArray(a))return!1;for(let c in s){if(!(c in a))return!1;let u=Reflect.get(s,c),l=Reflect.get(a,c);if(!i(u,l))return!1}for(let c in a)if(!(c in s))return!1}return!0}function i(s,a){if(s===a)return!0;if(s===null||a===null)return!1;if(typeof s!=="object")return!1;if(typeof s!==typeof a)return!1;if(ze(s)&&ze(a))return r(s,a);return o(s,a)}return n}function Ht(e){let n=Qt(e),t=e.multipleOf??1,r=He(n,t);if(!r)return null;return{multipleOf:t,range:r}}function Bp([e,n]){if(e.num!==n.num)return!1;if(e.exclusive)return!1;if(n.exclusive)return!1;return!0}function He(e,n){if(!e)return;let[t,r]=e,o=Eb(t.num,n),i=Ob(r.num,n);if(o===t.num&&t.exclusive)o+=n;if(i===r.num&&r.exclusive)i-=n;if(o>i)return;if(o===i){if(o===Number.POSITIVE_INFINITY)return;if(o===Number.NEGATIVE_INFINITY)return}return[{num:o,exclusive:!1},{num:i,exclusive:!1}]}function Eb(e,n){return Math.ceil(e/n)*n}function Ob(e,n){return Math.floor(e/n)*n}function Wp(e,n){let t=Qt(e),r=Qt(n),{left:o,right:i,center:s}=Sn(t,r);if(!s)return q;let a=!1,c=!1;if(o)if(o.fromLeft)a=!0;else c=!0;if(i)if(i.fromLeft)a=!0;else c=!0;if(a&&c)return W;if(a)return D;if(c)return Z;return J}function Os(e,n){let t=Qt(e),r=Ht(n);if(!r)return D;let o=Sn(t,r.range),i=He(o.center,r.multipleOf),s=Kp(o.left,r.multipleOf),a=Kp(o.right,r.multipleOf);if(!o.center)return q;let c=!1,u=!1;if(o.left?.fromLeft)c=!0;if(o.right?.fromLeft)c=!0;if(!i||!Bp(o.center))c=!0;if(s)u=!0;if(a)u=!0;if(c&&u)return W;if(c)return D;if(u)return Z;return J}function Qt(e){let n,t;if(e.exclusiveMinimum!==void 0)n={num:e.exclusiveMinimum,exclusive:!0};else if(e.minimum!==void 0)n={num:e.minimum,exclusive:!1};else n={num:Number.NEGATIVE_INFINITY,exclusive:!0};if(e.exclusiveMaximum!==void 0)t={num:e.exclusiveMaximum,exclusive:!0};else if(e.maximum!==void 0)t={num:e.maximum,exclusive:!1};else t={num:Number.POSITIVE_INFINITY,exclusive:!0};return[n,t]}function Kp(e,n){if(!e)return;if(e.fromLeft)return;return He(e.range,n)}function Qp(e,n){let t=Ht(e),r=Ht(n);if(!t&&!r)return J;if(!t)return Z;if(!r)return D;let{range:o,multipleOf:i}=t,{range:s,multipleOf:a}=r,c=Sn(o,s),u,l=0;if(c.center)l=Rb(i,a),u=He(c.center,l);if(!u)return q;let p=!1,m=!1,{left:h,right:g}=c;if(h&&He(h.range,h.fromLeft?i:a))if(h.fromLeft)p=!0;else m=!0;if(g&&He(g.range,g.fromLeft?i:a))if(g.fromLeft)p=!0;else m=!0;if(p=p||Gp(t,u,l),m=m||Gp(r,u,l),p&&m)return W;if(p)return D;if(m)return Z;return J}function Gp({range:e,multipleOf:n},t,r){let o=Sn(e,t);if(He(o.left?.range,n))return!0;if(He(o.right?.range,n))return!0;let i=He(o.center,n);if(!i)return!1;let s=Hp(t);if(Hp(i)>s)return!0;if(s===1)return!1;if(n<r)return!0;return!1}function Rb(e,n){return e*n/Yp(e,n)}function Yp(e,n){if(e===0)return n;return Yp(n%e,e)}function Hp(e){if(!e)return 0;let[n,t]=e;return t.num-n.num+1}function Rs(e,n){if(Xp(e)||Xp(n))return Je;let t=ef(e),r=ef(n);if(t&&r)return Wp(e,n);else if(t)return Os(e,n);else if(r)return xn(Os(n,e));else return Qp(e,n)}function Xp(e){let{multipleOf:n}=e;if(n===void 0)return!1;if(!Number.isInteger(n))return!0;if(n<0)return!0;return!1}function ef(e){let{multipleOf:n}=e;if(n!==void 0&&Number.isInteger(n))return!1;if(e.type==="integer")return!1;return!0}var Ab=ot(0),jb=co(["hasCommonInRequired","hasCommonOutRequired","hasExtra1","hasExtra2","hasRejection"]);function rf(e,n,t){if(Pb(n,t))return q;let r=$b(n,t);if(!r)return q;let o=nf(n),i=nf(t),s=(E)=>{let P=o(E),N=i(E);if(tf(P,N))return e.calculate(P,N);else return te},{commonRequired:a,extraRequired1:c,extraRequired2:u}=r,l=jb.variable({});for(let E of[...a].toSorted())l.push(s(E),Nb);for(let E of[...c].toSorted())l.push(s(E),Tb);for(let E of[...u].toSorted())l.push(s(E),zb);let{hasOptional1:p,hasOptional2:m}=r;if(p||m){let E=Db(p,m);for(let L of[..._b(n,t)].toSorted()){let M=s(L);if(M!==te)l.push(M,E)}let P=n.additionalProperties??kn,N=t.additionalProperties??kn;if(tf(P,N)){let L=e.calculate(P,N);l.push(L,E)}}l.update((E)=>{if(!E.hasRejection){if(c.size>0)E.hasExtra2=!0;if(u.size>0)E.hasExtra1=!0}});let{requiredKeysCount:h}=r,g=te;for(let{hasExtra1:E,hasExtra2:P,hasCommonInRequired:N,hasCommonOutRequired:L,hasRejection:M}of l)if(!N&&h>0)g|=q;else if(!L&&h===0)g|=q;else if(M)g|=q;else if(E&&P)g|=W;else if(E)g|=D;else if(P)g|=Z;else g|=J;return g}function Pb(e,n){let t=Ab(e.minProperties,e.maxProperties,n.minProperties,n.maxProperties);return it(t)===y.Rejection}function $b(e,n){let t=new Set(e.required),r=new Set(n.required),o=new Set,i=new Set,s=t.size,a=r.size;for(let p of t){if(r.has(p))o.add(p);i.add(p)}for(let p of r){if(t.has(p))o.add(p);i.add(p)}let c=i.size;for(let p of o)t.delete(p),r.delete(p);let u=e.maxProperties??Number.MAX_SAFE_INTEGER,l=n.maxProperties??Number.MAX_SAFE_INTEGER;if(c>u||c>l)return null;return{requiredKeysCount:c,extraRequired1:t,extraRequired2:r,commonRequired:o,hasOptional1:u>s,hasOptional2:l>a}}function _b(e,n){let t=new Set(e.required),r=e.properties,o=n.properties,i=e.required,s=n.required;if(r)for(let a in r)t.add(a);if(o)for(let a in o)t.add(a);if(i)for(let a of i)t.delete(a);if(s)for(let a of s)t.delete(a);return t}var Nb=(e,n)=>{switch(e){case y.Equals:{n.hasCommonInRequired=!0;break}case y.Containing:{n.hasExtra1=!0,n.hasCommonInRequired=!0;break}case y.ContainedBy:{n.hasExtra2=!0,n.hasCommonInRequired=!0;break}case y.Intersection:{n.hasExtra1=!0,n.hasExtra2=!0,n.hasCommonInRequired=!0;break}case y.Rejection:{n.hasRejection=!0;break}}},Tb=(e,n)=>{switch(e){case y.Equals:case y.ContainedBy:{n.hasCommonInRequired=!0;break}case y.Intersection:case y.Containing:{n.hasExtra1=!0,n.hasCommonInRequired=!0;break}case y.Rejection:{n.hasRejection=!0;break}}},zb=(e,n)=>{switch(e){case y.Equals:case y.Containing:{n.hasCommonInRequired=!0;break}case y.Intersection:case y.ContainedBy:{n.hasExtra2=!0,n.hasCommonInRequired=!0;break}case y.Rejection:{n.hasRejection=!0;break}}},Db=(e,n)=>(t,r)=>{if(r.hasRejection)return;let o=!1,i=!1,s=!1;switch(t){case y.Equals:{s=!0;break}case y.Containing:{o=!0,s=!0;break}case y.ContainedBy:{i=!0,s=!0;break}case y.Intersection:{o=!0,i=!0,s=!0;break}case y.Rejection:{o=!0,i=!0;break}}if(e&&o)r.hasExtra1=!0;if(n&&i)r.hasExtra2=!0;if(e&&n&&s)r.hasCommonOutRequired=!0};function nf(e){let{properties:n,propertyNames:t,additionalProperties:r}=e,o=[];if(e.patternProperties)for(let i in e.patternProperties){let s=e.patternProperties[i],a=new RegExp(i,"i");o.push({pattern:a,schema:s})}return(i)=>{if(t&&tn(t,i)===Ce.Invalid)return Kt;for(let{pattern:a,schema:c}of o)if(a.test(i))return c;let s=(n&&n[i])??r;if(!s)return kn;return s}}function tf(e,n){let t=K(e),r=K(n);return t!==S.Never||r!==S.Never}var Vb=ot(0);function of(e,n){if(n.format&&!e.format)return D;if(e.format&&n.format&&e.format!==n.format)return Je;let t=Vb(e.minLength,e.maxLength,n.minLength,n.maxLength),r=it(t),o=!!e.pattern,i=!!n.pattern;switch(r){case y.Rejection:return q;case y.Containing:return o?Je:D;case y.ContainedBy:return i?Je:Z;case y.Equals:{if(o&&i)return e.pattern===n.pattern?J:Je;if(o)return J|Z;if(i)return J|D;return J}case y.Intersection:{if(o&&i)return Je;if(o)return W|q|Z;if(i)return W|q|D;return W}}}function af(e,n,t){let r={},o=[],i=Fp(Zb(e,r)),s=Mb(),a=Up(e);r.isEquals=Zp(et),r.calculate=ys({describe:s,equals:a,calculate:i,observeCalculation:(u,l,p,m)=>{let h=m?xn(p):p;if(!Fb(h))return;let g=m?sf(l,u):sf(u,l);if(g)o.push(g)}}),Object.freeze(r);let c=r.calculate(n,t);return{errorPath:o[0],expression:c}}var Mb=()=>(e)=>{let n;switch(K(e)){case S.Not:{n={kind:Ne.Not,expression:e.not};break}case S.Combination:{if("allOf"in e)n={kind:Ne.AllOf,expressions:As(e.allOf,S.Any)};else if("anyOf"in e)n={kind:Ne.AnyOf,expressions:As(e.anyOf,S.Never)};else if("oneOf"in e)n={kind:Ne.OneOf,expressions:As(e.oneOf,S.Never)};else throw Error(`invalid combination JSON Schema: ${JSON.stringify(e)}`);break}default:{n={kind:Ne.Leaf};break}}return n},Zb=(e,n)=>(t,r)=>{let o=K(t),i=K(r);if(o===S.Extends||i===S.Extends)return e.calculate(t,r);switch(o){case S.Any:return i===S.Any?J:D;case S.Never:return i===S.Never?J:Z}switch(i){case S.Any:return Z;case S.Never:return D}if(o===S.EnumOrConst&&i===S.EnumOrConst)return qp(n,t,r);if(o===S.EnumOrConst)return Es(t,r);if(i===S.EnumOrConst)return xn(Es(r,t));if(o!==i)return q;switch(o){case S.Null:return J;case S.Numeric:return Rs(t,r);case S.String:return of(t,r);case S.Boolean:return J;case S.Object:return rf(n,t,r);case S.Array:return Mp(n,t,r);default:throw Error(`invalid kind ${o}`)}};function As(e,n){return e.filter((t)=>K(t)!==n)}function Fb(e){return!Zt(e)&&!Jt(e)&&(Ft(e)||qt(e)||Lt(e))}function sf(e,n){let t=xs(n);if(!t)return;let r=K(e),o=K(n);if(r!==o)return[...t,"type"];let i=e,s=n;switch(o){case S.String:{if((i.minLength??0)<(s.minLength??0))return[...t,"minLength"];if((i.maxLength??Number.POSITIVE_INFINITY)>(s.maxLength??Number.POSITIVE_INFINITY))return[...t,"maxLength"];if(i.pattern!==s.pattern&&s.pattern)return[...t,"pattern"];if(i.format!==s.format&&s.format)return[...t,"format"];break}case S.Numeric:{if((i.minimum??i.exclusiveMinimum??Number.NEGATIVE_INFINITY)<(s.minimum??s.exclusiveMinimum??Number.NEGATIVE_INFINITY))return[...t,s.exclusiveMinimum==null?"minimum":"exclusiveMinimum"];if((i.maximum??i.exclusiveMaximum??Number.POSITIVE_INFINITY)>(s.maximum??s.exclusiveMaximum??Number.POSITIVE_INFINITY))return[...t,s.exclusiveMaximum==null?"maximum":"exclusiveMaximum"];if(i.multipleOf!==s.multipleOf&&s.multipleOf!=null)return[...t,"multipleOf"];break}case S.Array:{if((i.minItems??0)<(s.minItems??0))return[...t,"minItems"];if((i.maxItems??Number.POSITIVE_INFINITY)>(s.maxItems??Number.POSITIVE_INFINITY))return[...t,"maxItems"];if(!i.uniqueItems&&s.uniqueItems)return[...t,"uniqueItems"];break}case S.Object:{let a=new Set(i.required??[]);if((s.required??[]).some((c)=>!a.has(c)))return[...t,"required"];if((i.minProperties??0)<(s.minProperties??0))return[...t,"minProperties"];if((i.maxProperties??Number.POSITIVE_INFINITY)>(s.maxProperties??Number.POSITIVE_INFINITY))return[...t,"maxProperties"];break}case S.EnumOrConst:return[...t,s.const===void 0?"enum":"const"]}return t}class Yt{constructor(e=[]){this.extendsSchemaClasses=Object.freeze([...e])}tryCompiledExtendsSchema(e,n){for(let t of this.extendsSchemaClasses)if(t.isMatch(e))return new t(bn(),e,n);return null}isExtendsSchema(e){for(let n of this.extendsSchemaClasses)if(e instanceof n)return!0;return!1}calculate(e,n){let t=this.findMatchedClass(e,n),r=!(e instanceof t),o=te,i;if(r)i=n.compare(e);else i=e.compare(n);for(let s of i){if(r)s=Yt.swap(s);o|=wn(s)}return o}equals(e,n){let t=this.findMatchedClass(e,n);if(!(e instanceof t))return n.equals(e);else return e.equals(n)}findMatchedClass(e,n){for(let t of this.extendsSchemaClasses){if(e instanceof t)return t;if(n instanceof t)return t}throw Error("Invalid schema")}static swap(e){switch(e){case y.Containing:return y.ContainedBy;case y.ContainedBy:return y.Containing;default:return e}}}function cf(e,n,t=!1){let r=n(e);if(Array.isArray(r)){let s=[];throw js(s,r,"$"),new oo(s)}let{schema:o,warns:i}=r;if(t&&i.length>0){console.warn(`found ${i.length} warns after compile schema`);for(let s of i)console.warn(rt(s))}return o}function uf(e,n,t,r=!1){let o=t(e),i=t(n);if(Array.isArray(o)||Array.isArray(i)){let l=[];if(Array.isArray(o))js(l,o,"$1");if(Array.isArray(i))js(l,i,"$2");throw new oo(l)}let{schema:s,warns:a}=o,{schema:c,warns:u}=i;if(r){if(a.length>0)console.warn(`found ${a.length} warns after compile superSchema`);for(let l of a)console.warn(rt(l));if(u.length>0)console.warn(`found ${u.length} warns after compile subSchema`);for(let l of u)console.warn(rt(l))}return[s,c]}function js(e,n,t){for(let r of n){let o={...r,path:[t,...r.path]};e.push(o)}}var Xt=Object.freeze({True:0,False:1,Unknown:2});function Ps({extendsSchemaClasses:e,delegate:n}={}){let t=new Yt(e);return Object.freeze({compile:(o,i,s)=>cf(o,(c)=>ao(c,t,i,n),s),isSubset:(o,i,s=!1)=>{let a=(g)=>ao(g,t,void 0,n),[c,u]=uf(o,i,a,s),{errorPath:l,expression:p}=af(t,c,u),m=Zt(p)||Jt(p),h=Ft(p)||qt(p)||Lt(p);if(m&&!h)return{result:Xt.True};if(!m&&h)return{errorPath:l,result:Xt.False};return{result:Xt.Unknown}}})}var uo=(e)=>typeof e==="string";var Jb=Array.isArray;var Lb=(e)=>e!==null&&typeof e==="object";var qb=(e)=>Lb(e)&&!Jb(e),Tn=(e)=>qb(e)?e:void 0;function Ub(e){return Tn(e)?.type==="string"}function Bb(e){let n=Tn(e),t=Tn(n?.error);if(n==null||t==null||n.packageId!=null&&!uo(n.packageId)||t.message!=null&&!uo(t.message))throw TypeError("Invalid schema comparison context.")}function Kb(e){if(e==null)return{error:{}};return Bb(e),e}class In{static setError(e,n,t){if(e instanceof In)e.context.error.message=t;else if(n instanceof In)n.context.error.message=t}constructor(e,n,t){this.id=e,this.value=n,this.context=Kb(t)}compare(e){if(ze(e)&&K(e)===S.Any)return[y.ContainedBy];return this.compareImpl(e)}}class er extends In{static isMatch(e){let n=Tn(e)?.enum;return Array.isArray(n)&&n.every((t)=>uo(t))}constructor(e,n,t){if(!er.isMatch(n))throw TypeError("Invalid single-select schema.");super(e,n,t)}compareImpl(e){if(Ub(e))return[y.ContainedBy];if(e instanceof er){let n=new Set(this.value.enum),t=y.Equals;for(let r of e.value.enum){if(!n.has(r))t=y.ContainedBy;n.delete(r)}if(n.size===0)return[t];if(n.size===this.value.enum.length)return[y.Rejection];return[y.Intersection]}return[y.Rejection]}equals(e){if(e instanceof er){let n=new Set(this.value.enum);for(let t of e.value.enum){if(!n.has(t))return!1;n.delete(t)}return n.size===0}return!1}}class nr extends In{static isMatch(e){return Tn(e)?.contentMediaType==="oomol/bin"}constructor(e,n,t){if(!nr.isMatch(n))throw TypeError("Invalid binary schema.");super(e,n,t)}compareImpl(e){if(e instanceof nr)return[y.Equals];else return In.setError(this,e,"edgeError.binDiffType"),[y.Rejection]}equals(e){return e instanceof nr}}class tr extends In{static isMatch(e){return Tn(e)?.contentMediaType==="oomol/artifact"}constructor(e,n,t){if(!tr.isMatch(n))throw TypeError("Invalid Artifact schema.");super(e,n,t)}compareImpl(e){if(e instanceof tr)return[y.Equals];return In.setError(this,e,"edgeError.artifactDiffType"),[y.Rejection]}equals(e){return e instanceof tr}}function lf(){return Ps({extendsSchemaClasses:[er,nr,tr]})}var vE=lf();var lo=I({handle:R().min(1),jsonSchema:_e(),nullable:le(),description:R().optional()}),PE=k({inputs:j(lo).nullable(),outputs:j(lo).nullable()});var df=I({version:x(1),flowId:R().min(1),name:R(),revisionId:R().min(1),publicationId:R().min(1),inputs:j(lo),outputs:j(lo).nullable()});var pf=I({version:x(1),direction:ce(["incoming","outgoing"]),total:ge().nonnegative(),nextOffset:ge().nonnegative().optional(),references:j(I({flowId:R(),name:R().nullable(),available:le(),draft:le(),live:I({publicationId:R(),enabled:le()}).nullable()}))});var ff=k({mode:ce(["chat","json"]),resultSchema:_e(),model:_e().optional().describe("Default model settings: {model, temperature?, top_p?, max_tokens?}. A bound model input takes precedence."),template:_e().optional().describe('Default message templates: [{role: "system" | "user" | "assistant", content: "Text with {{namedInput}}"}].'),messages:_e().optional().describe("Default conversation history, prepended without template interpolation; an array of {role, content} or null.")});var Qb=X([k({schemes:j(R().min(1)).describe("One complete security alternative advertised by this operation; [] selects no authentication.")}),k({type:ce(["bearer","basic"])}),k({type:x("apiKey"),name:R().min(1),in:ce(["header","query"])})]),mf=k({sourceUrl:R().min(1),path:R().min(1),method:R().min(1),serverUrl:R().optional(),authentication:Qb.optional().describe("Omit to use the operation default. Bind credentials through the advertised node inputs.")});var T=R().min(1),Be=_e(),Ts=ee(T,Be),po=["start","outputs","workflow","webhook","cron","error","poll","integration","code","connector","agent","llm","decision","openapi","condition","value","wait","approval"],zs=ce(po),an=T.describe('An existing node reference returned by read/search, or $alias for a preceding node.add in this edit batch. For node.add.as "step", reference "$step", never bare "step". Aliases are local to one batch.'),$s=k({kind:x("output"),node:an,port:T.optional().describe("Omit for a node with one output. For multiple outputs, choose a name from node details."),field:R().optional()}),_s=k({kind:x("variable"),name:T}),gf=X([$s,_s,k({kind:x("value"),value:Be}),k({kind:x("unset")}),k({kind:x("default")}),k({kind:x("sources"),sources:j(X([$s,_s])).min(1)})]),hf=X([k({kind:x("value"),value:Be.optional(),schema:Be.optional()}),$s,_s]),Yb=qe.agent.shape.tools.element.omit({id:!0,inputs:!0}).extend({inputs:ee(T,qe.agent.shape.tools.element.shape.inputs.element.shape.source).optional().describe("Action input sources by name. The tool resolves types from the Action. New inputs default to model-provided; existing sources are preserved when omitted.")}).strict(),Xb=k({...qe.connector.shape,messageHandle:T,inputs:ee(T,X([k({kind:x("value"),value:Be}),k({kind:x("input"),input:T})]))}),fo=k({schema:Be.optional(),nullable:le().optional(),description:R().optional()}),st=ee(T,fo.extend({default:Be.optional()})).describe("Optional business input constraints by name. A binding to a new Code, Agent, LLM, Wait or Approval input automatically declares an input accepting any JSON. Existing constraints are preserved. Omitted schema accepts any JSON; omitted nullable is true. Use default for inherited values; input.set supplies data."),xf=ee(T,fo).describe("Workflow input definitions by name. Omitted schema accepts any JSON; omitted nullable is true. No defaults. Supply call values as trigger.outputs."),ew=xf.describe("Workflow output definitions by name. Omitted schema accepts any JSON; omitted nullable is true. No defaults. Set values on the Outputs node with input.set or node.add.inputs."),vf=ee(T,fo.extend({schema:Be,nullable:le()})),yf=ee(T,fo).describe("Code return fields by name. Omitted schema accepts any JSON; omitted nullable is true."),Ns=k({left:hf,operator:qe.condition.shape.cases.element.shape.groups.element.shape.expressions.element.shape.operator,right:hf.optional()}),bf=k({all:j(Ns)}),nw=X([Ns,bf,k({any:j(X([Ns,bf]))})]),cn={workflow:k({flowId:T}),start:k({inputDefs:xf.default({})}),outputs:k({outputDefs:ew.default({})}),error:k({sourceFlowIds:j(T).optional()}),webhook:qe.webhook.omit({bodyFields:!0}).extend({body:st}).strict(),cron:k({schedule:qe.schedule}),poll:k({key:T,connectionId:T.optional(),schedule:qe.schedule}),integration:k({key:T,connectionId:T.optional()}),code:k({inputs:st,outputs:yf,capabilities:qe.capabilities.optional()}),connector:qe.connector.omit({outputMode:!0}).strict(),openapi:mf,agent:qe.agent.omit({prompt:!0,tools:!0}).extend({inputs:st,resultSchema:Be.describe("JSON schema of the final result. Defaults to text. The tool manages the output definition; references can omit port."),tools:j(Yb),notification:Xb.optional()}).strict(),llm:ff.extend({inputs:st}),decision:qe.decision,condition:k({match:ce(["first","all"]),branches:j(k({name:T,description:R().optional(),when:nw}))}),value:k({values:Ts,outputs:yf}),wait:k({inputs:st}),approval:k({inputs:st})},tw={name:T.optional(),description:R().optional(),icon:R().optional(),maxExecutions:ge().positive().optional(),timeoutMs:ue().nonnegative().optional()},rw=k({...tw,config:Ts.optional().describe('Recursively merge configuration; omitted fields remain unchanged and arrays replace as a whole. This includes schema objects: {} does not clear an existing schema. Use clear paths to remove fields, e.g. ["config","inputs","amount","schema","type"].')}),ow=jn("op",[k({op:x("node.add"),as:T.regex(/^[A-Za-z][\w-]*$/).describe("Unique batch-local alias without the $ prefix. Later edits must reference this new node as $alias; the bare alias is not its node ID."),type:zs,name:T,config:Ts.optional(),inputs:ee(T,gf).optional().describe("Input data sources, applied after creation, as input.set operations. Execution edges are separate."),code:R().optional(),prompt:R().optional()}),k({op:x("node.update"),node:an,set:rw.optional(),clear:j(j(T).min(1)).optional()}),k({op:x("node.refresh"),node:an}),k({op:x("node.remove"),node:an}),k({op:x("input.set"),node:an,input:T,source:gf}),k({op:ce(["edge.connect","edge.disconnect"]),source:an,target:an,branch:T.optional()}),k({op:x("text.edit"),node:an,field:ce(["code","prompt"]),oldText:T,newText:R()}),k({op:x("text.set"),node:an,field:ce(["code","prompt"]),text:R()})]),rr=k({baseRevision:T,requestId:T.max(256),edits:j(ow).min(1).max(1000)}),mo=k({revision:T.optional().describe("Fixed revision from a previous read; omit to read the current draft."),nodes:j(T).min(1).max(100).optional().describe("Node references to read in one batch. Mutually exclusive with text. Long texts return metadata."),text:k({node:T,field:ce(["code","prompt"]),start:ge().positive().default(1),lines:ge().min(1).max(200).default(80)}).optional().describe("Read code or prompt by line (1-based). Mutually exclusive with nodes. Follow nextStart at the same revision until truncated is false.")}).refine((e)=>e.nodes==null||e.text==null,"Choose nodes or text.").meta({not:{required:["nodes","text"]},description:"Omit nodes and text for an outline; provide nodes for details, or text for an excerpt."}),Ds=k({revisionId:T}),go=k({revision:T.optional(),query:T.max(1000),type:zs.optional(),offset:ge().nonnegative().default(0),limit:ge().min(1).max(100).default(20)}),kf=k({type:zs.optional(),action:T.optional()}).refine((e)=>e.type==null||e.action==null,"Choose type or action."),wf={read:{schema:mo,guidance:"Read Start and Outputs node details for their interface definitions and data sources. Choose one mode: outline (omit nodes and text), node details (nodes), or text excerpt (text). nodes and text are mutually exclusive. Text defaults to 80 lines, at most 200 lines and 24000 characters. For the complete text, repeat at nextStart with the same revision until truncated is false.",examples:[{},{revision:"REVISION",nodes:["NODE"]},{revision:"REVISION",text:{node:"NODE",field:"prompt",start:1,lines:80}}]},search:{schema:go,guidance:"Search names, configurations and text. Keep the returned revision when following nextOffset or reading a match.",examples:[{query:"Customer summary",type:"agent"}]},edit:{schema:rr,guidance:'Edit Start config.inputDefs and Outputs config.outputDefs through node.add or node.update; clear paths are relative to the node, e.g. ["config","inputDefs","amount"]. Set Outputs values with input.set. Use the observed revision as baseRevision and a stable requestId. Edits are ordered and atomic. node.add.as declares a batch-local alias without $. Every later reference to that new node must use $alias, including node, edge source/target and output source node fields; a bare alias is not the node ID. Use returned node references in later batches. Updates recursively merge objects (including schemas); {} preserves existing fields. Arrays replace as a whole. Remove fields with clear paths. Text replacement requires exactly one match. Read the target text first. A saved draft can have validation diagnostics.',examples:[{baseRevision:"REVISION",requestId:"CREATE_REQUEST",edits:[{op:"node.add",as:"start",type:"start",name:"Start"},{op:"node.add",as:"step",type:"code",name:"Process",code:"export default ({value}) => ({result:value})"},{op:"edge.connect",source:"$start",target:"$step"},{op:"node.update",node:"$step",set:{description:"Created and connected in one atomic edit."}}]},{baseRevision:"REVISION",requestId:"REQUEST",edits:[{op:"text.edit",node:"NODE",field:"prompt",oldText:"Original rule.",newText:"Updated rule."}]}]},check:{schema:Ds,guidance:"Check a fixed revision. In the CLI, pass this identity with --revision REVISION.",examples:[{revisionId:"REVISION"}]}};function Vs(e){if(!Object.hasOwn(wf,e))return;let n=wf[e];return{request:Nt(n.schema,{io:"input"}),guidance:n.guidance,examples:n.examples}}function Ms(e){return e==null?{types:po,request:Nt(rr),guidance:"Read a node type schema before creating or configuring it. Use $alias to reference a preceding node.add in the same batch. Read returns stable node references. Long code and prompt fields use text reads and edits. Changes use the observed baseRevision and a stable requestId."}:{type:e,inputSources:["poll","integration"].includes(e)?["value","unset","default"]:["start","outputs","error","cron","webhook","value","condition"].includes(e)?[]:["value","unset","default","output","variable","sources"],extensibleInputs:["code","agent","llm","wait","approval"].includes(e),guidance:e=="outputs"?"Declare output fields through config.outputDefs. Set their values through node.add.inputs or input.set. Outputs is a singleton execution sink; it waits for its predecessors and produces workflow business outputs independently of node logs. No downstream edges or data references to Outputs are allowed.":e=="start"?"Declare workflow inputs through config.inputDefs; read them in Start node details. REST calls and manual runs supply them as trigger.outputs. Downstream nodes bind these parameters as Start outputs. Start has no input sources or defaults; non-nullable parameters are required, and omitted nullable parameters become null.":e=="condition"?"Edit branch operands through config.branches. A branch can test one expression, all expressions, or any alternatives. Unmatched execution uses branch otherwise.":["poll","integration"].includes(e)?"Configure static parameters with node.add.inputs or input.set. Definitions come from the selected Trigger key; execution output and variable sources are unavailable.":e=="llm"?"Configure model settings, message templates and history as defaults. Input bindings with the same names override these defaults; named business inputs can be bound directly. Template strings interpolate {{name}}.":e=="openapi"?"Select an operation; the tool resolves its ports and authentication. Read authenticationChoices from node details. authentication is replaced as a complete choice. Bind advertised credentials through inputs.":e=="workflow"?"Select another workflow with config.flowId. A workflow cannot call itself, including in a disconnected node. Owned unpublished or unavailable targets may be saved as incomplete drafts. Use node.refresh to load the current published interface.":"Supply business configuration and input data. Fixed definitions are assembled by the tool. Existing constraints and defaults are preserved on partial updates.",example:{op:"node.add",as:"step",type:e,name:"Step",...{start:{config:{inputDefs:{}}},outputs:{config:{outputDefs:{}}},workflow:{config:{flowId:"<Flow ID>"}},connector:{config:{action:"<Action ID>",connectionId:"<Connection ID>"}},poll:{config:{key:"<Trigger key>",schedule:[{type:"every",unit:"minute",value:5}]}},integration:{config:{key:"<Trigger key>"}},openapi:{config:{sourceUrl:"https://example.com/openapi.json",path:"/items",method:"get"}},code:{code:"export default ({value}) => ({result:value})",inputs:{value:{kind:"value",value:"Hello"}}},condition:{config:{match:"first",branches:[{name:"yes",when:{left:{kind:"value",value:120},operator:">",right:{kind:"value",value:100}}}]}},value:{config:{values:{threshold:100,region:"EU"}}},webhook:{config:{method:"POST",body:{orderId:{schema:{type:"string"},nullable:!1}}}},wait:{prompt:"Continue processing this order?",inputs:{order:{kind:"value",value:{orderId:"A-1"}}}},approval:{prompt:"Approve this order?",inputs:{order:{kind:"value",value:{orderId:"A-1"}}}},llm:{config:{model:{model:"deepseek-v4-flash"},template:[{role:"user",content:"Summarize {{order}}."}]},inputs:{order:{kind:"value",value:{orderId:"A-1",total:42}}}},agent:{config:{model:"deepseek-v4-flash"},inputs:{orders:{kind:"value",value:[{orderId:"A-1",total:42}]}},prompt:"Summarize {{orders}}."}}[e]},configuration:Nt(cn[e].partial()),texts:e=="code"?["code"]:["agent","wait","approval"].includes(e)?["prompt"]:[]}}var Sf=I({code:T,message:R(),nodes:j(T),field:R().optional(),line:ue().optional(),column:ue().optional()}),If=I({flowId:T,revisionId:T,valid:le(),diagnostics:j(Sf),version:x(1)}),Cf=I({flowId:T,saved:x(!0),revision:T,nodes:ee(T,T),changes:j(I({index:ge(),op:T,node:T.optional()})),validation:I({status:ce(["valid","invalid","unavailable"]),diagnostics:j(Sf).optional()}),version:x(1)}),Ef=I({flowId:T,revision:T,data:I({nodes:j(ee(R(),Be)).optional(),edges:j(Be).optional(),text:ee(R(),Be).optional()}),version:x(1)}),Of=I({flowId:T,revision:T,data:I({matches:j(I({node:T.optional(),field:T,line:ge().optional(),excerpt:R()})),total:ge(),nextOffset:ge().optional()}),version:x(1)});var z={authenticationRequired:"authentication.required",authorizationDenied:"authorization.denied",bindingUnresolved:"binding.unresolved",connectorActionNotFound:"connector.action-not-found",connectorAccessConflict:"connector.access-conflict",connectorAccessInvalid:"connector.access-invalid",connectorAccessRequired:"connector.access-required",connectorAccessUnsupported:"connector.access-unsupported",connectorUnconfigured:"connector.unconfigured",connectorUnavailable:"connector.unavailable",connectorConsoleUnconfigured:"connector.console-unconfigured",engineUnavailable:"engine.unavailable",engineUnsupported:"engine.unsupported",eventSourceInvalid:"event-source.invalid",eventSourceIdentityUnavailable:"event-source.identity-unavailable",eventSourceNotFound:"event-source.not-found",eventSourceConflict:"event-source.conflict",flowInvalid:"flow.invalid",flowRepairRequired:"flow.repair-required",flowUpgradeRequired:"flow.upgrade-required",flowNotFound:"flow.not-found",flowBusy:"flow.busy",flowConflict:"flow.conflict",flowPresentationConflict:"flow.presentation-conflict",flowRevisionConflict:"flow.revision-conflict",liveConflict:"live.conflict",liveNotFound:"live.not-found",pageInvalidCursor:"page.invalid-cursor",publicationConflict:"publication.conflict",publicationNotFound:"publication.not-found",publicationUnsupported:"publication.unsupported",publishOperationNotFound:"publication.operation-not-found",routeNotFound:"route.not-found",runConflict:"run.conflict",runEventsExpired:"run.events-expired",runInvalid:"run.invalid",runNotFound:"run.not-found",runNotTerminal:"run.not-terminal",runOverloaded:"run.overloaded",runWaitNotFound:"run.wait-not-found",triggerKeyInvalid:"trigger-key.invalid",triggerKeyNotFound:"trigger-key.not-found",triggerNotFound:"trigger.not-found",variableInvalid:"variable.invalid",variableLimitReached:"variable.limit-reached",variableNotFound:"variable.not-found"},sw={[z.eventSourceInvalid]:{status:400},[z.eventSourceIdentityUnavailable]:{status:409},[z.eventSourceNotFound]:{status:404},[z.eventSourceConflict]:{status:409},[z.authenticationRequired]:{status:401},[z.authorizationDenied]:{status:403},[z.bindingUnresolved]:{status:409},[z.connectorActionNotFound]:{status:404},[z.connectorAccessConflict]:{status:412},[z.connectorAccessInvalid]:{status:409},[z.connectorAccessRequired]:{status:409},[z.connectorAccessUnsupported]:{status:409},[z.connectorUnconfigured]:{status:503},[z.connectorUnavailable]:{status:503},[z.connectorConsoleUnconfigured]:{status:503},[z.engineUnavailable]:{status:503},[z.engineUnsupported]:{status:409},[z.flowInvalid]:{status:400},[z.flowRepairRequired]:{status:409},[z.flowUpgradeRequired]:{status:409},[z.flowNotFound]:{status:404},[z.flowBusy]:{status:409},[z.flowConflict]:{status:409},[z.flowPresentationConflict]:{status:412},[z.flowRevisionConflict]:{status:412},[z.liveConflict]:{status:412},[z.liveNotFound]:{status:404},[z.pageInvalidCursor]:{status:400},[z.publicationConflict]:{status:409},[z.publicationNotFound]:{status:404},[z.publicationUnsupported]:{status:409},[z.publishOperationNotFound]:{status:404},[z.routeNotFound]:{status:404},[z.runConflict]:{status:409},[z.runEventsExpired]:{status:410},[z.runInvalid]:{status:400},[z.runNotFound]:{status:404},[z.runNotTerminal]:{status:409},[z.runOverloaded]:{status:429},[z.runWaitNotFound]:{status:404},[z.triggerKeyInvalid]:{status:409},[z.triggerKeyNotFound]:{status:404},[z.triggerNotFound]:{status:404},[z.variableInvalid]:{status:400},[z.variableLimitReached]:{status:409},[z.variableNotFound]:{status:404}};class Ee extends Error{constructor(e,n,t,r){super(t);this.code=n,this.details=r,this.name="ApiError",this.status=e}}class Rf extends Ee{constructor(e){super(502,"response.invalid",`The Control API returned an invalid response.${e==null?"":` ${e}`}`);this.detail=e}}function d(e){throw new Rf(e)}function w(e){if(e==null||typeof e!="object"||Array.isArray(e))return d("Expected an object.");return e}function f(e){return typeof e=="string"&&e.length>0?e:d("Expected a non-empty string.")}function U(e,n){let t=n.filter((r)=>!Object.hasOwn(e,r));if(t.length>0)d(`Missing fields: ${t.join(", ")}.`)}function Ke(e,n){let t=Object.keys(e);if(t.length!=n.length||t.some((r)=>!n.includes(r))){let r=n.filter((i)=>!Object.hasOwn(e,i)),o=t.filter((i)=>!n.includes(i));d([r.length>0?`Missing fields: ${r.join(", ")}.`:"",o.length>0?`Unexpected fields: ${o.join(", ")}.`:""].filter(Boolean).join(" "))}}function re(e){return Number.isSafeInteger(e)?e:d("Expected a safe integer.")}function be(e){if(e===null||typeof e=="boolean"||typeof e=="string")return e;if(typeof e=="number"&&Number.isFinite(e))return e;if(Array.isArray(e))return e.map(be);let n=w(e);return Object.fromEntries(Object.entries(n).map(([t,r])=>[t,be(r)]))}function ho(e){if(e==null)return;return f(e)}function at(e){let n=w(e),t=n.liveEnd==null?void 0:w(n.liveEnd);if(t!=null&&typeof t.enabled!="boolean")return d();let{operation:r,sourcePublicationId:o}=n;if(n.version!=1)return d();if(r!="publish"&&r!="rollback")return d();if(o!=null&&typeof o!="string")return d();return{...t==null?{}:{liveEnd:{enabled:t.enabled,endedAt:f(t.endedAt)}},actorId:f(n.actorId),closureDigest:f(n.closureDigest),createdAt:f(n.createdAt),engineContract:f(n.engineContract),flowId:f(n.flowId),modelVersion:re(n.modelVersion),operation:r,publicationId:f(n.publicationId),sharedAccessDigest:f(n.sharedAccessDigest),revisionDigest:f(n.revisionDigest),revisionId:f(n.revisionId),...o==null?{}:{sourcePublicationId:o},version:1}}function Zs(e){let n=w(e),t=n.status,r={createdAt:f(n.createdAt),flowId:f(n.flowId),operationId:f(n.operationId),revisionId:f(n.revisionId),updatedAt:f(n.updatedAt),version:1};if(n.version!=1)return d();switch(t){case"pending":return U(n,["createdAt","flowId","operationId","revisionId","status","updatedAt","version"]),{...r,status:t};case"succeeded":return U(n,["createdAt","flowId","operationId","publicationId","revisionId","status","updatedAt","version"]),{...r,publicationId:f(n.publicationId),status:t};case"failed":{U(n,["createdAt","flowId","issue","operationId","revisionId","status","updatedAt","version"]);let o=w(n.issue),i=o.nodeId;return U(o,["code","message",...i==null?[]:["nodeId"]]),{...r,issue:{code:f(o.code),message:f(o.message),...i==null?{}:{nodeId:f(i)}},status:t}}default:return d()}}function Fs(e){let n=w(e),{status:t,publication:r}=n;if(n.version!=1||typeof n.hasUnpublishedChanges!="boolean")return d();if(t!="not-published"&&t!="runnable"&&t!="suspended")return d();if(t=="not-published"&&r!==null)return d();if(t!="not-published"&&r===null)return d();return{flowId:f(n.flowId),hasUnpublishedChanges:n.hasUnpublishedChanges,publication:r===null?null:at(r),revision:re(n.revision),status:t,version:1}}function Af(e){let n=w(e),{nextCursor:t,total:r}=n;if(n.version!=1||!Array.isArray(n.publications))return d();if(t!=null&&typeof t!="string")return d();if(r!=null&&!Number.isSafeInteger(r))return d();return{...t==null?{}:{nextCursor:t},publications:n.publications.map(at),...r==null?{}:{total:r},version:1}}var jf=j(X([k({handle:R().min(1),description:R().optional(),jsonSchema:_e(),nullable:le(),value:_e().optional()}),k({group:R(),collapsed:le().optional()})]));function Js(e){let n=w(e),t=n.type;if(t!="integration"&&t!="poll")return d();return{description:typeof n.description=="string"?n.description:d(),displayName:f(n.displayName),key:f(n.key),name:f(n.name),provider:f(n.provider),type:t}}function or(e){let n=w(e),t=Js(n),r={configInputs:jf.parse(n.configInputs),definitionVersion:n.definitionVersion===2?2:d(),description:t.description,displayName:t.displayName,key:t.key,name:t.name,outputs:(Array.isArray(n.outputs)?n.outputs:d()).map((u)=>{let l=w(u);return Object.assign({handle:f(l.handle),jsonSchema:be(l.jsonSchema),nullable:typeof l.nullable==="boolean"?l.nullable:d()},l.description==null?{}:{description:f(l.description)})}),provider:t.provider};if(t.type=="poll")return{...r,type:"poll"};let o=w(n.endpoint),i=w(o.body);if(!Array.isArray(o.methods)||!Array.isArray(i.formats)||typeof i.allowArray!="boolean"||typeof i.allowEmpty!="boolean")return d();let s=o.methods.map(f),a=i.formats.map(f),c=re(o.successStatus);if(s.some((u)=>!["DELETE","GET","HEAD","PATCH","POST","PUT"].includes(u))||a.some((u)=>!["form","json","multipart","text"].includes(u))||c<200||c>299)return d();return{...r,endpoint:{body:{allowArray:i.allowArray,allowEmpty:i.allowEmpty,formats:a},methods:s,successStatus:c},type:"integration"}}var aw=new Set(["error","cron","integration","poll","webhook"]),cw=new Set(["failed","healthy","initializing","needs_reauth","suspended"]),uw=new Set(["delivery.failed","health.failed","health.needs_reauth","health.recovered","health.suspended","operator.paused","operator.resumed"]);function ir(e){let n=w(e),t=n.health,r=n.listener==null?void 0:w(n.listener);if(r!=null&&r.health!="healthy"&&r.health!="failed"&&r.health!="needs_reauth")return d();let o=n.kind,i=re(n.runtimeVersion);if(n.version!=1||typeof t!="string"||!cw.has(t))return d();if(typeof o!="string"||!aw.has(o))return d();if(i<=0)return d();return{...n.currentPublicationId==null?{}:{currentPublicationId:f(n.currentPublicationId)},...n.currentRevisionId==null?{}:{currentRevisionId:f(n.currentRevisionId)},...n.endpointUrl==null?{}:{endpointUrl:f(n.endpointUrl)},...r==null?{}:{listener:{health:r.health,...r.lastErrorCode==null?{}:{lastErrorCode:f(r.lastErrorCode)}}},flowId:f(n.flowId),health:t,kind:o,...n.lastErrorCode==null?{}:{lastErrorCode:f(n.lastErrorCode)},runtimeVersion:i,triggerNodeId:f(n.triggerNodeId),updatedAt:f(n.updatedAt),version:1}}function Pf(e){let n=w(e);if(n.version!=1)return d();return{binding:ir(n.binding),version:1}}function lw(e){let n=w(e),t=n.kind;if(typeof t!="string"||!uw.has(t))return d();let r=ho(n.errorCode),o=ho(n.errorMessage);if(o!=null&&o.length>512)return d();return{activityId:f(n.activityId),createdAt:f(n.createdAt),...r==null?{}:{errorCode:r},...o==null?{}:{errorMessage:o},kind:t}}function $f(e){let n=w(e),t=ho(n.nextCursor);if(n.version!=1||!Array.isArray(n.activities))return d();return{activities:n.activities.map(lw),...t==null?{}:{nextCursor:t},version:1}}function _f(e){let n=w(e),t=re(n.filtered);if(n.version!=1||!Array.isArray(n.events)||typeof n.hasMore!="boolean"||t<0)return d();return{events:n.events.map((r)=>{let o=w(r);return Object.fromEntries(Object.entries(o).map(([i,s])=>[i,be(s)]))}),filtered:t,hasMore:n.hasMore,version:1}}var zn={nodeId:R().min(1),name:R(),description:R().optional()},sr=Wn().transform(ir),Nf={provider:R().min(1),inputs:ee(R(),jn("kind",[I({kind:x("value"),value:_e()}),I({kind:x("unset")})]))},pw=jn("type",[I({...zn,type:x("start"),config:cn.start}),I({...zn,type:x("manual"),config:I({})}),I({...zn,type:x("webhook"),config:cn.webhook,binding:sr}),I({...zn,type:x("cron"),config:cn.cron,binding:sr}),I({...zn,type:x("error"),config:cn.error,binding:sr}),I({...zn,...Nf,type:x("poll"),config:cn.poll,binding:sr}),I({...zn,...Nf,type:x("integration"),config:cn.integration,binding:sr})]);function Tf(e){let n=w(e),t=f(n.flowId);if(n.version!=1||!Array.isArray(n.entries))return d();if(n.publication===null){if(n.inputDefs!==null||n.status!="not-published"||n.entries.length!=0||Object.hasOwn(n,"enabled"))return d();return{flowId:t,inputDefs:null,publication:null,status:"not-published",entries:[],version:1}}let r=at(n.publication),o=n.status;if(r.flowId!=t||typeof n.enabled!="boolean")return d();if(o!="runnable"&&o!="suspended")return d();if(!n.enabled&&n.status=="runnable")return d();let i=vf.safeParse(n.inputDefs);if(!i.success)return d();return{flowId:t,inputDefs:i.data,publication:r,status:o,enabled:n.enabled,entries:fw(n.entries,r),version:1}}function fw(e,n){let t=j(pw).safeParse(e);if(!t.success)return d();let r=new Set;for(let o of t.data){if(r.has(o.nodeId))return d();if(r.add(o.nodeId),o.type!="start"&&o.type!="manual"&&(o.binding.flowId!=n.flowId||o.binding.triggerNodeId!=o.nodeId||o.binding.kind!=o.type||o.binding.currentPublicationId!=n.publicationId||o.binding.currentRevisionId!=n.revisionId))return d();if(o.type=="webhook"&&(!o.binding.endpointUrl||!Hr(o.config.method)&&Object.keys(o.config.body).length>0))return d()}return t.data}function yo(e,n){if(!e||typeof e!="object"||!n||typeof n!="object")return{};let t=e,r=n;if(typeof t.version!="string"||![t.pixelRatio,t.iconSize,t.width,t.height].every((o)=>Number.isInteger(o)&&o>0)||![t.bleed,r.x,r.y].every((o)=>Number.isInteger(o)&&o>=0)||r.x+t.iconSize>t.width||r.y+t.iconSize>t.height)return{};try{for(let o of[t.lightUrl,t.darkUrl])if(typeof o!="string"||!["https:","http:","data:"].includes(new URL(o).protocol))return{}}catch{return{}}return{iconSprite:t,iconSpritePosition:{x:r.x,y:r.y}}}function zf(e,n){let t=e=="feishu_app_bot.on_event"?["sourceId","eventTypes","resource","chatIds"]:e=="linear.on_issue_changed"?["teamId","stateIds"]:[];return{...n,...Object.fromEntries(t.map((r)=>[r,{kind:"unset"}]))}}function Df(e,n){return{...e,nodes:Object.fromEntries(Object.entries(e.nodes).map(([t,r])=>{if((r.kind=="poll"||r.kind=="integration")&&(n==null||r.connectionId==n)){let{connectionId:i,...s}=r;return[t,s]}if(r.kind!="task")return[t,r];if("executor"in r.task){let i=r.task.executor,s=(a)=>{if(n!=null&&a.connectionId!=n)return a;let{connectionId:c,...u}=a;return u};if(i.kind=="connector")return[t,{...r,task:{...r.task,executor:s(i)}}];if(i.kind=="agent")return[t,{...r,task:{...r.task,executor:{...i,tools:i.tools.map(s),...i.notification==null?{}:{notification:s(i.notification)}}}}];return[t,r]}let o=r.task.capabilities?.map((i)=>{if(!("mode"in i)){if("action"in i){let{connectionId:s,...a}=i;return{...a,connections:i.connections.filter((c)=>n!=null&&c.connectionId!=n),...s!=null&&n!=null&&s!=n?{connectionId:s}:{}}}return{...i,...n==null&&(i.connectionHints?.length??0)>0?{actionHints:[...new Set([...i.actionHints??[],...i.connectionHints.map((s)=>s.action)])]}:{},...i.connectionHints==null?{}:{connectionHints:i.connectionHints.filter((s)=>n!=null&&s.connectionId!=n)}}}if(i.mode!="independent")return i;return{...i,actions:i.actions.map((s)=>{if(n!=null&&s.connectionId!=n)return s;let{connectionId:a,...c}=s;return c})}});return[t,o==null?r:{...r,task:{...r.task,capabilities:o}}]}))}}var mw=k({kind:x("open-flow-workflow"),version:x(1),name:R().optional(),content:Wn(),presentation:ee(R(),_e()).optional()});function bo(e){Pn(e,-1);let n=mw.parse(e);return{...n,content:Xn(n.content)}}function Mf(e){return bo(JSON.parse(e))}function Vf(e){if(e.kind!="sources"||!e.sources.some((t)=>t.kind=="binding"))return e;let n=e.sources.filter((t)=>t.kind!="binding");return n.length==0?{kind:"unset"}:{kind:"sources",sources:n}}function gw(e){let n=bo(e),t=n.content.document.graph,r=Df(t),o=Object.fromEntries(Object.entries(r.nodes).map(([i,s])=>{let a=s;if("inputs"in a)a={...a,inputs:Object.fromEntries(Object.entries(a.inputs).map(([c,u])=>[c,Vf(u)]))};if(a.kind=="outputs")a={...a,outputMappings:Object.fromEntries(Object.entries(a.outputMappings).map(([c,u])=>[c,Vf(u)]))};if(a.kind=="condition")a=gp(a);if(a.kind=="error"&&a.sourceFlowIds!=null)a={...a,sourceFlowIds:[]};if(a.kind=="poll"||a.kind=="integration")a={...a,config:zf(a.definition.key,a.config)};return[i,a]}));return{file:{...n,content:{...n.content,document:{...n.content.document,bindings:{},graph:{...r,nodes:o}}}},summary:{changedNodeIds:Object.keys(o).filter((i)=>!ve(o[i],t.nodes[i])),removedBindings:Object.keys(n.content.document.bindings).length}}}function Zf(e){return`${JSON.stringify(gw(e).file,null,2)}
|
|
59
|
-
`}function Ff(e){return e.replace(/(?:\.openflow)?\.json$/i,"")}var yw=jn("kind",[k({kind:x("admin-delegation")}),k({kind:x("policy"),ruleId:R().min(1).nullable()})]);function wo(e){return yw.parse(e)}function qf(e){let n=w(e);if(!Array.isArray(n.bots))return d("Leina bots: expected an array.");let t=n.bots.map((r)=>{let o=w(r);if(!Array.isArray(o.platforms))return d("Leina platforms: expected an array.");return{leinaId:f(o.leinaId),name:f(o.name),status:f(o.status),platforms:o.platforms.map(f)}});if(new Set(t.map((r)=>r.leinaId)).size!=t.length)return d("Leina bots: duplicate identifiers.");return t}function bw(e){let n=w(e);if(Ke(n,["actionIds","allActions","triggerIds","allTriggers","configured","proxy"]),!Array.isArray(n.actionIds))return d("permissions.actionIds: expected an array.");if(!Array.isArray(n.triggerIds))return d("permissions.triggerIds: expected an array.");if(typeof n.allActions!="boolean")return d("permissions.allActions: expected a boolean.");if(typeof n.allTriggers!="boolean")return d("permissions.allTriggers: expected a boolean.");if(typeof n.configured!="boolean")return d("permissions.configured: expected a boolean.");if(typeof n.proxy!="boolean")return d("permissions.proxy: expected a boolean.");let t=n.actionIds.map(f),r=n.triggerIds.map(f);if(new Set(t).size!=t.length)return d("permissions.actionIds: duplicate IDs.");if(n.allActions&&t.length!=0)return d("permissions.actionIds: must be empty when allActions is true.");if(new Set(r).size!=r.length)return d("permissions.triggerIds: duplicate IDs.");if(n.allTriggers&&r.length!=0)return d("permissions.triggerIds: must be empty when allTriggers is true.");if(n.proxy&&(!n.allActions||!n.allTriggers||n.configured))return d("permissions.proxy: requires allActions=true, allTriggers=true and configured=false.");return{actionIds:t,triggerIds:r,allTriggers:n.allTriggers,allActions:n.allActions,configured:n.configured,proxy:n.proxy}}function Uf(e,n){let t=w(e),{policyRevision:r,status:o,isDefault:i}=t,s=Object.hasOwn(t,"displayName")&&!Object.hasOwn(t,"connectionDisplayName"),a=n&&Object.hasOwn(t,"permissions")?bw(t.permissions):void 0,c=t.permissionGroupName;if(Ke(t,["accessBindingId","connectionId","source",s?"displayName":"connectionDisplayName",...n&&Object.hasOwn(t,"isDefault")?["isDefault"]:[],...n&&a!=null?["permissions"]:[],...Object.hasOwn(t,"permissionGroupName")?["permissionGroupName"]:[],...r==null?[]:["policyRevision"],"providerId",...n?[]:["status"]]),r!=null&&typeof r!="string")return d("policyRevision: expected a string.");if(n&&i!==void 0&&typeof i!="boolean")return d("isDefault: expected a boolean.");if(c!==void 0&&c!==null&&typeof c!="string")return d("permissionGroupName: expected a string or null.");if(!n&&o!="active"&&o!="forbidden"&&o!="invalid"&&o!="missing")return d();let u;try{u=wo(t.source)}catch{return d("source: expected { kind: 'admin-delegation' } or { kind: 'policy', ruleId: string | null }.")}return{accessBindingId:f(t.accessBindingId),connectionId:f(t.connectionId),source:u,connectionDisplayName:f(s?t.displayName:t.connectionDisplayName),...n&&typeof i=="boolean"?{isDefault:i}:{},...a==null?{}:{permissions:a},...c===void 0?{}:{permissionGroupName:c},...r==null?{}:{policyRevision:r},providerId:f(t.providerId),...n?{}:{status:o}}}function qs(e){if(e!="implicit"&&e!="selectable")return d("mode: expected implicit or selectable.");return e}function ct(e){let n=w(e);Ke(n,["accessRevision","bindings","mode","sharedAccessDigest",..."providerIds"in n?["providerIds"]:[],..."discardedBindingCount"in n?["discardedBindingCount"]:[],"version"]);let t=re(n.accessRevision);if(n.version!=1||t<0||!Array.isArray(n.bindings))return d();if("providerIds"in n&&!Array.isArray(n.providerIds))return d();let r=n.providerIds==null?void 0:n.providerIds.map((s)=>f(s));if(r!=null&&new Set(r).size!=r.length)return d();let o=n.discardedBindingCount==null?0:re(n.discardedBindingCount);if(o<0)return d();let i=[];for(let s of n.bindings)try{i.push(Uf(s,!1))}catch(a){if(!(a instanceof Ee)||a.code!="response.invalid")throw a;if(s!=null&&typeof s=="object"&&!Array.isArray(s)&&typeof s.accessBindingId=="string"&&s.accessBindingId.length>0&&typeof s.providerId=="string"&&s.providerId.length>0)i.push({accessBindingId:s.accessBindingId,providerId:s.providerId,connectionId:null,source:null,status:"invalid",connectionDisplayName:typeof s.connectionDisplayName=="string"&&s.connectionDisplayName.length>0?s.connectionDisplayName:typeof s.displayName=="string"&&s.displayName.length>0?s.displayName:s.providerId,permissionGroupName:typeof s.permissionGroupName=="string"?s.permissionGroupName:null});else o++}if(new Set(i.map((s)=>s.accessBindingId)).size!=i.length)return d();return{accessRevision:t,...o==0?{}:{discardedBindingCount:o},...r==null?{}:{providerIds:r},bindings:i,mode:qs(n.mode),sharedAccessDigest:f(n.sharedAccessDigest),version:1}}function Jf(e){if(!Array.isArray(e))return d();let n=e.map((t)=>{let r=w(t);Ke(r,["accessBindingId","connectionId","providerId","source","connectionDisplayName",..."permissionGroupName"in r?["permissionGroupName"]:[]]);let o;try{o=wo(r.source)}catch{return d()}if(r.permissionGroupName!=null&&typeof r.permissionGroupName!="string")return d();return{accessBindingId:f(r.accessBindingId),connectionId:f(r.connectionId),providerId:f(r.providerId),source:o,connectionDisplayName:f(r.connectionDisplayName),..."permissionGroupName"in r?{permissionGroupName:r.permissionGroupName}:{}}});if(new Set(n.map((t)=>t.accessBindingId)).size!=n.length)return d();return n}function Us(e){let n=w(e);if(Ke(n,["mode","sharedAccessDigest","sharedBindings","selectedBindings","version"]),n.version!=2)return d();let t=qs(n.mode),r=Jf(n.sharedBindings),o=Jf(n.selectedBindings);if(t=="implicit"&&(r.length>0||o.length>0))return d();return{mode:t,sharedAccessDigest:f(n.sharedAccessDigest),sharedBindings:r,selectedBindings:o,version:2}}function ww(e,n){let t=w(e);if(Ke(t,["candidates","mode","providerId","version"]),t.version!=1)return d("version: expected 1.");if(f(t.providerId)!=n)return d("providerId: does not match the requested provider.");if(!Array.isArray(t.candidates))return d("candidates: expected an array.");let r=t.candidates.map((o)=>Uf(o,!0));if(r.some((o)=>o.providerId!=n))return d("candidates[].providerId: does not match the requested provider.");if(new Set(r.map((o)=>o.accessBindingId)).size!=r.length)return d("candidates[].accessBindingId: duplicate IDs.");return{candidates:r,mode:qs(t.mode),providerId:n,version:1}}function Bf(e,n){let t=w(e);if(Ke(t,["results","version"]),t.version!=1)return d("version: expected 1.");if(!Array.isArray(t.results))return d("results: expected an array.");let r=new Set(n),o=t.results.map((i)=>{let s=w(i),a=f(s.providerId);if(!r.delete(a))return d("results[].providerId: duplicate or unrequested provider.");if(!Object.hasOwn(s,"error"))return ww(s,a);Ke(s,["providerId","error"]);let c=w(s.error);return Ke(c,["code","message"]),{providerId:a,error:{code:f(c.code),message:f(c.message)}}});if(r.size!=0)return d("results: missing requested providers.");return{results:o,version:1}}function ut(e){let n=w(e);if(U(n,[...Object.hasOwn(n,"providerAccountId")?["providerAccountId"]:[],...Object.hasOwn(n,"alias")?["alias"]:[],...Object.hasOwn(n,"builtInAccount")?["builtInAccount"]:[],"connectionId","displayName","isDefault","serviceId","status"]),n.builtInAccount!==void 0&&typeof n.builtInAccount!="boolean")return d();let t=n.status;if(t!="active"&&t!="disconnected"&&t!="error"&&t!="reauth_required")return d();if(typeof n.isDefault!="boolean")return d();return{...n.providerAccountId===void 0?{}:{providerAccountId:f(n.providerAccountId)},...n.alias===void 0?{}:{alias:f(n.alias)},...n.builtInAccount===void 0?{}:{builtInAccount:n.builtInAccount},connectionId:f(n.connectionId),displayName:f(n.displayName),isDefault:n.isDefault,serviceId:f(n.serviceId),status:t}}function Kf(e,n=!1){let t=w(e),r=t.description,o=n&&Object.hasOwn(t,"value");if(U(t,["jsonSchema","nullable",...r==null?[]:["description"],...o?["value"]:[]]),r!=null&&typeof r!="string")return d();if(typeof t.nullable!="boolean")return d();return{...r==null?{}:{description:r},jsonSchema:be(t.jsonSchema),nullable:t.nullable,...o?{value:be(t.value)}:{}}}function xw(e){return Kf(e,!0)}function Lf(e,n){return Object.fromEntries(Object.entries(w(e)).map(([t,r])=>[t,n(r)]))}function vw(e){let n=w(e),{homepageUrl:t,icon:r}=n;if(U(n,["actionId",...Object.hasOwn(n,"operationType")?["operationType"]:[],...Object.hasOwn(n,"inputSchema")?["inputSchema"]:[],...Object.hasOwn(n,"outputSchema")?["outputSchema"]:[],"authenticated","description",...t==null?[]:["homepageUrl"],...r==null?[]:["icon"],..."iconSprite"in n?["iconSprite"]:[],..."iconSpritePosition"in n?["iconSpritePosition"]:[],"inputs","name","outputs","serviceId","serviceName"]),t!=null&&typeof t!="string"||r!=null&&typeof r!="string")return d();return{...n.inputSchema===void 0?{}:{inputSchema:be(n.inputSchema)},...n.outputSchema===void 0?{}:{outputSchema:be(n.outputSchema)},actionId:f(n.actionId),...n.operationType==null?{}:{operationType:f(n.operationType)},authenticated:typeof n.authenticated=="boolean"?n.authenticated:d(),description:typeof n.description=="string"?n.description:d(),...t==null?{}:{homepageUrl:t},...r==null?{}:{icon:r},...yo(n.iconSprite,n.iconSpritePosition),inputs:Lf(n.inputs,xw),name:f(n.name),outputs:Lf(n.outputs,Kf),serviceId:f(n.serviceId),serviceName:f(n.serviceName)}}function xo(e){let{defaultConnection:n,...t}=w(e),r=vw(t);if(n==null)return r;let o=ut(n);if(o.serviceId!=r.serviceId||o.status!="active")return d();return{...r,defaultConnection:o}}function Wf(e){let n=w(e),{homepageUrl:t,icon:r}=n;if(n.noSetup!==void 0&&typeof n.noSetup!="boolean")return d();if(U(n,[...Object.hasOwn(n,"noSetup")?["noSetup"]:[],"serviceId","serviceName",...t==null?[]:["homepageUrl"],...r==null?[]:["icon"],..."iconSprite"in n?["iconSprite"]:[],..."iconSpritePosition"in n?["iconSpritePosition"]:[]]),t!=null&&typeof t!="string"||r!=null&&typeof r!="string")return d();return{...t==null?{}:{homepageUrl:t},...r==null?{}:{icon:r},...yo(n.iconSprite,n.iconSpritePosition),serviceId:f(n.serviceId),serviceName:f(n.serviceName),...n.noSetup===void 0?{}:{noSetup:n.noSetup}}}function Bs(e){return{actionId:e.actionId,authenticated:e.authenticated,...e.defaultConnection==null?{}:{defaultConnection:{connectionId:e.defaultConnection.connectionId,displayName:e.defaultConnection.displayName,status:e.defaultConnection.status}},description:e.description,name:e.name,serviceId:e.serviceId,serviceName:e.serviceName}}var Dn=R().min(1).max(256),Iw=R().regex(/^[a-z][a-z0-9_.]{0,127}$/),Cw=R().trim().min(1).max(128),Hf=I({version:x(1),sourceId:Dn,revision:ge().positive(),name:Cw,provider:ce(["feishu","feishu_app_bot"]),appId:Dn,connectionId:Dn,teamId:Dn.nullable(),enabled:le(),eventTypes:j(Iw),manageSubscriptions:le(),verificationTokenConfigured:le(),encryptKeyConfigured:le(),endpointUrl:R().nullable(),verifiedAt:R().nullable(),lastReceivedAt:R().nullable(),updatedAt:R(),consumers:j(I({flowId:Dn,flowName:R(),triggerNodeId:Dn}))});function vo(e){return Hf.parse(e)}function Ks(e){return I({version:x(1),sources:j(Hf),teamId:Dn.nullable().optional()}).parse(e)}function Ws(e){let n=w(e);if(U(n,["version","locale","definitions","display"]),n.version!=3||!Ia(n.locale)||!Array.isArray(n.definitions))return d();let t=n.definitions.map(or),r=w(n.display),o=new Set(t.map((s)=>s.key));if(o.size!=t.length||Object.keys(r).length!=o.size)return d();let i=Object.fromEntries(t.map((s)=>{let{key:a}=s,c=w(r[a]);return U(c,["configInputs","configInputLabels","displayName","description","outputs"]),[a,{configInputs:Qf(c.configInputs,s.configInputs.flatMap((u)=>("handle"in u)?[u.handle]:[])),configInputLabels:Ew(c.configInputLabels,s.configInputs.flatMap((u)=>("handle"in u)?[u.handle]:[])),displayName:f(c.displayName),description:f(c.description),outputs:Qf(c.outputs,s.outputs.map((u)=>u.handle))}]}));return{version:3,locale:n.locale,definitions:t,display:i}}function Qf(e,n){let t=w(e);return Ke(t,n),Object.fromEntries(Object.entries(t).map(([r,o])=>[r,f(o)]))}function Ew(e,n){let t=w(e);if(Object.keys(t).some((r)=>!n.includes(r)))return d();return Object.fromEntries(Object.entries(t).map(([r,o])=>{let i=f(o);return i.trim().length==0?d():[r,i]}))}function Gs(e,n){if(n==null)return e;let t=n.toLowerCase();return e.filter((r)=>[r.description,r.displayName,r.key,r.name,r.provider,r.type].some((o)=>o.toLowerCase().includes(t)))}var Ow=k({pointer:R().max(4096).default(""),offset:ue().int().nonnegative().default(0),limit:ue().int().min(1).max(100).default(20),maxBytes:ue().int().min(1).max(1048576).default(15000)});var Rw=_e(),Yf=I({pointer:R(),type:ce(["object","array","string","number","boolean","null"]),length:ue().int().nonnegative().optional(),complete:le(),value:Rw.optional()}),Aw=Yf.extend({offset:ue().int().nonnegative(),nextOffset:ue().int().positive().optional(),entries:j(Yf).optional()}),Xf=I({resultId:R().min(1),callId:R().min(1),toolId:R().min(1),source:jn("kind",[I({kind:x("connector"),action:R().min(1)}),I({kind:x("code")})]),bytes:ue().int().nonnegative(),digest:R().regex(/^[a-f0-9]{64}$/),createdAt:R().datetime()}),jw=I({version:x(1),runId:R(),results:j(Xf),nextAfter:R().optional()}),Pw=I({version:x(1),runId:R(),result:Xf,page:Aw});function Hs(e){return jw.parse(e)}function Qs(e){return Pw.parse(e)}function em(e){if(!Array.isArray(e))return d();return e.map((n)=>typeof n=="string"||Number.isSafeInteger(n)?n:d())}function $w(e){let n=w(e),t=f(n.kind);if(t=="artifact"||t=="binary"||t=="nullable")return{kind:t};if(t=="schema")return{kind:t,path:n.path==null?void 0:em(n.path)};if(t!="keyword"||typeof n.keyword!="string"||!ps(n.keyword))return d();return{kind:t,keyword:n.keyword,path:em(n.path),source:n.source===void 0?void 0:be(n.source),target:n.target===void 0?void 0:be(n.target)}}function _w(e){let n=w(e),t=n.values==null?void 0:w(n.values);return{code:f(n.code),column:re(n.column),...n.fields===void 0?{}:{fields:Array.isArray(n.fields)?n.fields.map(f):d()},line:re(n.line),message:f(n.message),mismatch:n.mismatch==null?void 0:$w(n.mismatch),path:typeof n.path=="string"?n.path:d(),...t==null?{}:{values:Object.fromEntries(Object.entries(t).map(([r,o])=>[r,typeof o=="string"||typeof o=="number"?o:d()]))}}}function nm(e){let n=w(e);if(n.version!=1||typeof n.valid!="boolean"||!Array.isArray(n.diagnostics))return d();return{closureDigest:f(n.closureDigest),diagnostics:n.diagnostics.map(_w),engineContract:f(n.engineContract),flowId:f(n.flowId),modelVersion:re(n.modelVersion),revisionDigest:f(n.revisionDigest),revisionId:f(n.revisionId),valid:n.valid,version:1}}var tm=(e)=>e==null?"":`?flowId=${encodeURIComponent(e)}`;function rm(e,n){let t=new URLSearchParams({...e==null?{}:{flowId:e},...n==null?{}:{locale:n}}).toString();return{path:`/v1/connector/providers${t?`?${t}`:""}`,decode:(r)=>{let o=w(r);if(U(o,["providers","version"]),o.version!=1||!Array.isArray(o.providers))return d();return o.providers.map(Wf)}}}function om(e,n,t){let r=new URLSearchParams({...n==null?{}:{flowId:n},...t==null?{}:{locale:t}}).toString();return{path:`/v1/connector/actions/${encodeURIComponent(e)}${r?`?${r}`:""}`,decode:(o)=>{let i=w(o);if(U(i,["action","version"]),i.version!=1)return d();return xo(i.action)}}}function im(e){return{path:`/v1/connector/connections${tm(e)}`,decode:(n)=>{let t=w(n);if(U(t,["connections","version"]),t.version!=1||!Array.isArray(t.connections))return d();return t.connections.map(ut)}}}function sm(e,n){return{path:`/v1/connector/connections/${encodeURIComponent(e)}${tm(n)}`,decode:(t)=>{let r=w(t);if(U(r,["connections","serviceId","version"]),r.version!=1||f(r.serviceId)!=e||!Array.isArray(r.connections))return d();return r.connections.map(ut)}}}function ko(e){return Array.isArray(e)?e.map(f):d()}function Nw(e){let n=w(e),t=n.draft===null?null:w(n.draft),r=w(n.sharedAccess);if(t!=null&&!Array.isArray(t.connections))return d();if(!Array.isArray(r.bindings))return d();let o=re(r.accessRevision);if(o<0)return d();return{draft:t==null?null:{...t.calledFlowIds===void 0?{}:{calledFlowIds:ko(t.calledFlowIds)},variableNames:ko(t.variableNames),errorSourceFlowIds:ko(t.errorSourceFlowIds),connections:t.connections.map((i)=>{let s=w(i);return{providerId:f(s.providerId),connectionId:f(s.connectionId)}})},sharedAccess:{accessRevision:o,providerIds:ko(r.providerIds),bindings:r.bindings.map((i)=>{let s=w(i);return{providerId:f(s.providerId),connectionId:s.connectionId===null?null:f(s.connectionId),accessBindingId:f(s.accessBindingId)}})}}}function un(e){let n=w(e),t=n.status;if(n.version!=1)return d();if(t!="active"&&t!="retiring")return d();let r=n.live==null?void 0:w(n.live);if(r!=null&&(typeof r.enabled!="boolean"||typeof r.hasStart!="boolean"))return d();return{...r==null?{}:{live:{enabled:r.enabled,hasStart:r.hasStart,publicationId:f(r.publicationId),revisionId:f(r.revisionId)}},createdAt:f(n.createdAt),...n.connectorTeamId==null?{}:{connectorTeamId:f(n.connectorTeamId)},draftRevisionId:f(n.draftRevisionId),resourceReferences:Nw(n.resourceReferences),flowId:f(n.flowId),name:f(n.name),status:t,updatedAt:f(n.updatedAt),version:1}}function am(e){let n=w(e);if(n.version!=1||!Array.isArray(n.flows))return d();let{nextCursor:t,total:r}=n;if(t!=null&&typeof t!="string")return d();if(r!=null&&!Number.isSafeInteger(r))return d();return{...t==null?{}:{nextCursor:t},flows:n.flows.map(un),...r==null?{}:{total:r},version:1}}function So(e){let n=w(e);if(U(n,["name","updatedAt","value","version"]),n.version!=1||typeof n.value!="string")return d();let t=f(n.updatedAt);try{if(new Date(t).toISOString()!=t)return d()}catch{return d()}return{name:f(n.name),updatedAt:t,value:n.value,version:1}}function cm(e){let n=w(e),{referenceCount:t,...r}=n,o=re(t);if(o<0)return d();return{...So(r),referenceCount:o}}function um(e){let n=w(e);if(typeof n.enabled!="boolean")return d();return{flowId:f(n.flowId),flowName:f(n.flowName),nodeId:f(n.nodeId),nodeName:f(n.nodeName),enabled:n.enabled}}function lm(e){let n=w(e);if(U(n,["version","references"]),n.version!=1||!Array.isArray(n.references))return d();return{version:1,references:n.references.map((t)=>{let r=w(t);if(U(r,["flowId","flowName","draft","live"]),typeof r.draft!="boolean")return d();let o=r.live===null?null:w(r.live);if(o!=null){if(U(o,["publicationId","enabled"]),typeof o.enabled!="boolean")return d()}return{flowId:f(r.flowId),flowName:f(r.flowName),draft:r.draft,live:o==null?null:{publicationId:f(o.publicationId),enabled:o.enabled}}})}}function dm(e){let n=w(e),t=n.parentRevisionId;if(n.version!=1||t!==null&&typeof t!="string")return d();return{actorId:f(n.actorId),createdAt:f(n.createdAt),digest:f(n.digest),flowId:f(n.flowId),modelVersion:re(n.modelVersion),parentRevisionId:t,revisionId:f(n.revisionId),version:1}}function ar(e){let n=w(e);try{return{...dm(n),content:Xn(n.content)}}catch{return d()}}function Io(e){let n=w(e);if(n.version!=1||re(n.revision)<1)return d();return{revision:re(n.revision),updatedAt:f(n.updatedAt),value:Object.fromEntries(Object.entries(w(n.value)).map(([t,r])=>[t,be(r)])),version:1}}function cr(e){let n=w(e);if(n.version!=1)return d();return{revision:dm(n.revision),version:1}}function pm(e){let n=w(e);if(n.version!=1||n.kind!="snapshot")return d();return{draft:ar(n.draft),kind:"snapshot",version:1}}var Tw=["canceled","completed","failed","indeterminate"],Co=[...Tw,"queued","running","starting","waiting"];var zw=new Set(Co);function Eo(e){return typeof e=="string"&&zw.has(e)?e:d()}function gm(e){let n=w(e),{source:t,startedAt:r,finishedAt:o}=n;if(n.version!=1||t!="draft"&&t!="live")return d();if(r!=null&&typeof r!="string")return d();if(o!=null&&typeof o!="string")return d();return{createdAt:f(n.createdAt),...o==null?{}:{finishedAt:o},flowId:f(n.flowId),revisionId:f(n.revisionId),runId:f(n.runId),source:t,...r==null?{}:{startedAt:r},status:Eo(n.status),version:1}}function Dw(e){let n=w(e);U(n,["actions","expiresAt","nodeId","prompt","waitId","waitingSince"]);let t=n.actions;if(!Array.isArray(t)||!(t.length==1&&t[0]=="continue"||t.length==2&&t[0]=="approve"&&t[1]=="reject"))return d();return{actions:t,expiresAt:f(n.expiresAt),nodeId:f(n.nodeId),prompt:f(n.prompt),waitId:f(n.waitId),waitingSince:f(n.waitingSince)}}function fm(e){let n=w(e);return{flowId:f(n.flowId),runId:f(n.runId),nodeId:f(n.nodeId),executionId:f(n.executionId)}}function Oo(e){let n=w(e),t=gm(n),r=n.eventsExpiresAt;if(r!=null&&typeof r!="string")return d();if(n.waiting!==void 0||!Array.isArray(n.waits))return d();let o=n.waits.map(Dw);if(new Set(o.map((a)=>a.waitId)).size!=o.length||t.status=="waiting"&&o.length==0&&(!Array.isArray(n.calls)||n.calls.length==0)||["completed","failed","canceled","indeterminate"].includes(t.status)&&o.length>0)return d();if(n.occurrenceId!==void 0&&n.triggerNodeId===void 0)return d();let i={status:t.status,waits:o};if(n.calls!==void 0&&!Array.isArray(n.calls))return d();let s={...t,...Vw(n),...n.triggerNodeId===void 0?{}:{triggerNodeId:f(n.triggerNodeId)},...n.caller===void 0?{}:{caller:fm(n.caller)},...n.calls===void 0?{}:{calls:n.calls.map((a)=>Object.assign(fm(a),{status:w(a).status===null?null:Eo(w(a).status)}))},closureDigest:f(n.closureDigest),engineContract:f(n.engineContract),engineDigest:f(n.engineDigest),...r==null?{}:{eventsExpiresAt:r},modelVersion:re(n.modelVersion),sharedAccessDigest:f(n.sharedAccessDigest),revisionDigest:f(n.revisionDigest),...i};switch(t.source){case"draft":return{...s,source:"draft"};case"live":return{...s,publicationId:f(n.publicationId),source:"live",...n.occurrenceId===void 0?{}:{occurrenceId:f(n.occurrenceId),triggerNodeId:f(n.triggerNodeId)}}}}function hm(e){let n=w(e),t=n.nextCursor;if(n.version!=1||!Array.isArray(n.runs))return d();if(t!=null&&typeof t!="string")return d();return{flowId:f(n.flowId),...t==null?{}:{nextCursor:t},runs:n.runs.map(gm),version:1}}function ym(e){let n=w(e),t=Eo(n.status);if(n.version!=1||typeof n.cancelAccepted!="boolean"||t=="queued"||t=="starting"||t=="running"||t=="waiting")return d();return{cancelAccepted:n.cancelAccepted,runId:f(n.runId),status:t,version:1}}function bm(e){let n=w(e);U(n,["action","comment","resolutionAccepted","resolvedAt","runId","status","version","waitId"]);let{action:t,resolvedAt:r}=n;if(n.version!=1||typeof n.resolutionAccepted!="boolean"||n.comment!==null&&typeof n.comment!="string"||t!==null&&t!="approve"&&t!="continue"&&t!="reject"||r!==null&&typeof r!="string"||t===null!=(r===null)||n.resolutionAccepted&&t===null)return d();return{action:t,comment:n.comment,resolutionAccepted:n.resolutionAccepted,resolvedAt:r,runId:f(n.runId),status:Eo(n.status),version:1,waitId:f(n.waitId)}}function wm(e){let n=w(e),t=n.status;if(n.version!=1)return d();let r={finishedAt:f(n.finishedAt),runId:f(n.runId),version:1};if(t=="completed"){if(!Object.hasOwn(n,"result"))return d();return{...r,result:n.result,status:"completed"}}if(t=="canceled")return{...r,status:"canceled"};if(t=="failed"){let o=w(n.error);return{...r,error:mm(o),status:"failed"}}if(t=="indeterminate"){let o=w(n.error);return{...r,error:mm(o),status:"indeterminate"}}return d()}function Vw(e){let n=e.errorSource==null?void 0:w(e.errorSource);if(e.errorDispatches!=null&&!Array.isArray(e.errorDispatches))return d();return{...n==null?{}:{errorSource:{flowId:f(n.flowId),runId:f(n.runId)}},...e.errorDispatches==null?{}:{errorDispatches:e.errorDispatches.map((t)=>{let r=w(t),o=f(r.flowId);switch(r.status){case"pending":return{status:"pending",flowId:o};case"dispatched":return{status:"dispatched",flowId:o,runId:f(r.runId)};case"failed":return{status:"failed",flowId:o,message:f(r.message)};default:return d()}})}}}function mm(e){return{code:f(e.code),message:f(e.message),...e.nodeId===void 0?{}:{nodeId:f(e.nodeId)},...e.jobId===void 0?{}:{jobId:f(e.jobId)},...e.path===void 0?{}:{path:(Array.isArray(e.path)?e.path:d()).map(f)}}}function Ro(){let e=globalThis.crypto;if(e!=null){try{if(typeof e.randomUUID=="function")return e.randomUUID()}catch{}if(typeof e.getRandomValues=="function"){let n=e.getRandomValues(new Uint8Array(16));n[6]=(n[6]??0)&15|64,n[8]=(n[8]??0)&63|128;let t=Array.from(n,(r)=>r.toString(16).padStart(2,"0")).join("");return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}}return`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}function vm(e){return e?.kind=="run.completed"||e?.kind=="run.failed"||e?.kind=="run.canceled"||e?.kind=="run.indeterminate"}function Mw(e){let n=w(e),t=re(n.sequence);if(t<0)return d();let r={createdAt:f(n.createdAt),sequence:t},o=w(n.payload),i=n.kind;switch(i){case"run.queued":return{...r,kind:i,payload:{}};case"run.started":return{...r,kind:i,payload:{flowId:f(o.flowId),scopeId:f(o.scopeId),...o.parentScopeId===void 0?{}:{parentScopeId:f(o.parentScopeId)}}};case"run.progress":return{...r,kind:i,payload:{flowId:f(o.flowId),scopeId:f(o.scopeId),progress:xm(o.progress)}};case"run.waiting":if(!Array.isArray(o.waitIds))return d();return{...r,kind:i,payload:{waitIds:o.waitIds.map((s)=>f(s))}};case"wait.created":return{...r,kind:i,payload:{expiresAt:f(o.expiresAt),nodeId:f(o.nodeId),waitId:f(o.waitId),waitingSince:f(o.waitingSince)}};case"run.resolved":{let s=o.action;if(s!=="approve"&&s!=="continue"&&s!=="reject")return d();if(o.comment!==null&&typeof o.comment!="string")return d();return{...r,kind:i,payload:{action:s,comment:o.comment,resolvedAt:f(o.resolvedAt),waitId:f(o.waitId)}}}case"run.completed":case"run.canceled":case"run.failed":case"run.indeterminate":return{...r,kind:i,payload:{result:be(o.result)}};case"run.events-truncated":return{...r,kind:i,payload:Object.fromEntries(Object.entries(o).map(([s,a])=>[s,be(a)]))};case"node.started":case"node.completed":case"node.failed":case"node.log":case"node.progress":case"node.artifact":{let s={flowId:f(o.flowId),scopeId:f(o.scopeId),nodeId:f(o.nodeId),executionId:f(o.executionId)};switch(i){case"node.started":{let a=o.nodeKind;if(a!==void 0&&a!=="approval"&&a!=="condition"&&a!=="connector"&&a!=="javascript"&&a!=="decision"&&a!=="openapi"&&a!=="llm"&&a!=="agent"&&a!=="value"&&a!=="outputs"&&a!=="workflow"&&a!=="wait")return d();return{...r,kind:i,payload:{...s,...a===void 0?{}:{nodeKind:a},...o.nodeTitle===void 0?{}:{nodeTitle:f(o.nodeTitle)},...o.operation===void 0?{}:{operation:f(o.operation)}}}}case"node.completed":return{...r,kind:i,payload:{...s,outputs:Object.fromEntries(Object.entries(w(o.outputs)).map(([a,c])=>[a,be(c)]))}};case"node.failed":{let a=w(o.error);return{...r,kind:i,payload:{...s,error:{code:f(a.code),message:f(a.message)}}}}case"node.log":{let a=o.level;if(a!=="debug"&&a!=="info"&&a!=="warn"&&a!=="error")return d();return{...r,kind:i,payload:{...s,level:a,message:f(o.message)}}}case"node.progress":return{...r,kind:i,payload:{...s,progress:xm(o.progress)}};case"node.artifact":{let a=w(o.artifact),c=re(a.size),u=f(a.digest);if(a.kind!="artifact"||c<0||!/^sha256:[0-9a-f]{64}$/.test(u))return d();return{...r,kind:i,payload:{...s,artifact:{kind:"artifact",id:f(a.id),name:f(a.name),size:c,digest:u,...a.mediaType===void 0?{}:{mediaType:f(a.mediaType)}}}}}}}default:return d()}}function xm(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0&&e<=100?e:d()}function Zw(e){let n=w(e),t=n.eventsExpiresAt,r=re(n.nextAfter);if(n.version!=1||!Array.isArray(n.events)||typeof n.done!="boolean"||typeof n.historyComplete!="boolean")return d();if(t!=null&&typeof t!="string")return d();if(r<0)return d();return{done:n.done,events:n.events.map(Mw),...t==null?{}:{eventsExpiresAt:t},historyComplete:n.historyComplete,nextAfter:r,runId:f(n.runId),version:1}}var O=encodeURIComponent;function Vn(e){return`${e}-${Ro()}`}class Ys{constructor(e){this.requestControl=e}async loadOpenApiDocument(e,n){let t=w(await this.request("/v1/openapi/document",{method:"POST",body:JSON.stringify({url:e,version:1}),signal:n}));if(t.version!=1)return d();return be(t.document)}async listFlows(e={}){let n=new URLSearchParams;if(e.cursor!=null)n.set("cursor",e.cursor);if(e.limit!=null)n.set("limit",String(e.limit));if(e.includeTotal!=null)n.set("includeTotal",String(e.includeTotal));let t=n.size==0?"":`?${n}`;return am(await this.request(`/v1/flows${t}`,e.signal==null?void 0:{signal:e.signal}))}async listEventSources(e,n){return Ks(await this.request("/v1/event-sources"+(e==null?"":`?flowId=${O(e)}`),{signal:n}))}async listEventSourceConnections(e,n){let t=w(await this.request(`/v1/event-sources/connections${e==null?"":`?teamId=${O(e)}`}`,{signal:n}));if(U(t,["version","connections"]),t.version!=1||!Array.isArray(t.connections))return d();return t.connections.map(ut)}async createEventSource(e){return vo(await this.request("/v1/event-sources",{method:"POST",body:JSON.stringify(e)}))}async updateEventSource(e,n){return vo(await this.request(`/v1/event-sources/${O(e)}`,{method:"PUT",body:JSON.stringify(n)}))}async deleteEventSource(e,n){await this.request(`/v1/event-sources/${O(e)}`,{method:"DELETE",body:JSON.stringify({version:1,expectedRevision:n})})}async listVariables(){let e=w(await this.request("/v1/variables"));if(U(e,["variables","version"]),e.version!=1||!Array.isArray(e.variables))return d();return{variables:e.variables.map(cm),version:1}}async getFlowReferences(e,n={}){let t=new URLSearchParams({direction:n.direction??"incoming",offset:String(n.offset??0),limit:String(n.limit??50)});return pf.parse(await this.request(`/v1/flows/${O(e)}/references?${t}`,{signal:n.signal}))}async getWorkflowContract(e,n){return df.parse(await this.request(`/v1/flows/${O(e)}/call-contract`,{signal:n}))}async getVariableReferences(e,n){return lm(await this.request(`/v1/variables/${O(e)}/references`,{signal:n}))}async getVariable(e){return So(await this.request(`/v1/variables/${O(e)}`))}async putVariable(e,n){return So(await this.request(`/v1/variables/${O(e)}`,{body:JSON.stringify({value:n}),method:"PUT"}))}async deleteVariable(e){let n=w(await this.request(`/v1/variables/${O(e)}`,{method:"DELETE"}));if(U(n,["version"]),n.version!=1)return d()}async exportFlow(e){let n=await this.request(`/v1/flows/${O(e)}/export`);try{return bo(n)}catch{return d()}}async importFlow(e,n={}){return un(await this.request("/v1/flows/import",{method:"POST",headers:{"Idempotency-Key":n.idempotencyKey??`flow-${Ro()}`},body:JSON.stringify({file:e,name:n.name,teamId:n.teamId,version:1})}))}async createFlow(e,n=`flow-${Ro()}`,t){return un(await this.request("/v1/flows",{body:JSON.stringify({name:e,...t==null?{}:{teamId:t},version:1}),headers:{"idempotency-key":n},method:"POST"}))}async broadcastCanvas(e,n){let t=w(await this.request(`/v1/flows/${O(e)}/canvas`,{method:"POST",body:JSON.stringify({version:1,command:n})}));if(U(t,["version","flowId","broadcast"]),t.version!=1||t.broadcast!==!0||t.flowId!==e)return d();return{version:1,flowId:f(t.flowId),broadcast:!0}}async getFlow(e){return un(await this.request(`/v1/flows/${O(e)}`))}async getErrorListeners(e,n){let t=w(await this.request(`/v1/flows/${O(e)}/error-listeners`,{signal:n}));if(t.version!=1||!Array.isArray(t.listeners))return d();return t.listeners.map(um)}async renameFlow(e,n){return un(await this.request(`/v1/flows/${O(e)}`,{body:JSON.stringify({name:n,version:1}),method:"PATCH"}))}async deleteFlow(e){return un(await this.request(`/v1/flows/${O(e)}`,{method:"DELETE"}))}async listTriggerKeys(e,n){let t=w(await this.request(`/v1/trigger-keys${n==null?"":`?locale=${encodeURIComponent(n)}`}`,{signal:e}));if(t.version!=1||!Array.isArray(t.keys))return d();return t.keys.map(Js)}async listTriggerDefinitions(e){let n=w(await this.request("/v1/trigger-keys/catalog",{signal:e}));if(n.version!=2||!Array.isArray(n.definitions))return d();return n.definitions.map(or)}async readCatalog(e,n,t){let r=new Headers;if(n)r.set("if-none-match",n);let o=await this.response(e.path,{headers:r,signal:t},!0),i=o.headers.get("etag")?.trim()||null;if(o.status==304)return{modified:!1,etag:i};return{modified:!0,data:e.decode(await o.json()),etag:i}}async getTriggerCatalog(e,n,t){let r=new Headers;if(n?.etag)r.set("if-none-match",n.etag);let o=await this.response(`/v1/trigger-keys/catalog?locale=${encodeURIComponent(e)}`,{headers:r,signal:t},!0);if(o.status==304){if(n==null)return d();return{...n,etag:o.headers.get("etag")?.trim()||n.etag}}return{data:Ws(await o.json()),etag:o.headers.get("etag")?.trim()||null}}async getTriggerKey(e,n){let t=w(await this.request(`/v1/trigger-keys/${O(e)}`,{signal:n}));if(t.version!=1)return d();return or(t.definition)}async listFlowTriggerBindings(e,n){let t=w(await this.request(`/v1/flows/${O(e)}/triggers`,{signal:n}));if(t.version!=1||f(t.flowId)!=e||!Array.isArray(t.bindings))return d();return t.bindings.map(ir)}async getFlowTriggerBinding(e,n){return Pf(await this.request(`/v1/flows/${O(e)}/triggers/${O(n)}`))}async listFlowTriggerActivities(e,n,t={}){let r=new URLSearchParams;if(t.cursor!=null)r.set("cursor",t.cursor);if(t.limit!=null)r.set("limit",String(t.limit));let o=r.size==0?"":`?${r}`;return $f(await this.request(`/v1/flows/${O(e)}/triggers/${O(n)}/activities${o}`))}async testFlowPollTrigger(e,n){return _f(await this.request(`/v1/flows/${O(e)}/triggers/${O(n)}/test`,{body:JSON.stringify({version:1}),method:"POST"}))}async getEditor(e){let n=w(await this.request(`/v1/flows/${O(e)}/editor`));if(n.version!=1)return d();let t={flow:un(n.flow),draft:ar(n.draft),live:Fs(n.live),presentation:Io(n.presentation),version:1};if(t.flow.flowId!=e||t.draft.flowId!=e||t.live.flowId!=e||t.flow.draftRevisionId!=t.draft.revisionId)return d();return t}async getPublicationPresentation(e,n,t){let r=w(await this.request(`/v1/flows/${O(e)}/publications/${O(n)}/presentation`,{signal:t}));if(r.version!=1)return d();return{version:1,presentation:r.presentation===null?null:Io(r.presentation)}}async getPresentation(e){return Io(await this.request(`/v1/flows/${O(e)}/presentation`))}async getDraft(e){return ar(await this.request(`/v1/flows/${O(e)}/draft`))}async syncDraft(e){return pm(await this.request(`/v1/flows/${O(e)}/draft/sync`))}async getRevision(e,n,t){return ar(await this.request(`/v1/flows/${O(e)}/revisions/${O(n)}`,{signal:t}))}async listTriggerConfigOptions(e,n,t,r){let o=w(await this.request(`/v1/flows/${O(e)}/triggers/${O(n)}/options/${O(t)}`,{signal:r}));if(U(o,["options","version"]),o.version!=1||!Array.isArray(o.options)||o.options.length>1000)return d();return o.options.map((i)=>{let s=w(i);U(s,["value","label",...s.color==null?[]:["color"]]);let a=s.color==null?void 0:f(s.color);if(a!=null&&!/^#[0-9a-fA-F]{6}$/.test(a))return d();return a==null?{value:f(s.value),label:f(s.label)}:{value:f(s.value),label:f(s.label),color:a}})}async listConnectorTeams(e){let n=w(await this.request("/v1/connector/teams",{signal:e}));if(U(n,["enabled","teams","version"]),n.version!=1||typeof n.enabled!="boolean"||!Array.isArray(n.teams))return d();return{enabled:n.enabled,teams:n.teams.map((t)=>{let r=w(t);if(U(r,["id","name","systemCreated"]),typeof r.systemCreated!="boolean")return d();return{id:f(r.id),name:f(r.name),systemCreated:r.systemCreated}}),version:1}}async listConnectorProviders(e,n,t){let r=rm(n,t);return this.connectorRequest(r.path,"providers",e,r.decode)}async listLeinaBots(e,n){return qf(await this.request(`/v1/connector/leina/bots?flowId=${O(e)}`,{signal:n}))}async removeConnectionUsage(e,n,t,r,o){return cr(await this.request(`/v1/flows/${O(e)}/connection-usage/remove`,{method:"POST",headers:{"idempotency-key":o},body:JSON.stringify({connectionId:n,expectedRevisionId:t,expectedAccessRevision:r,version:1})}))}async getConnectorAccess(e,n){return ct(await this.request(`/v1/flows/${O(e)}/connector-access`,{signal:n}))}async getPublishedConnectorAccess(e,n,t){return Us(await this.request(`/v1/flows/${O(e)}/connector-access?publicationId=${O(n)}`,{signal:t}))}async listProviderAccessBindingCandidates(e,n,t){return Bf(await this.request(`/v1/flows/${O(e)}/connector-access/candidates/query`,{method:"POST",body:JSON.stringify({providerIds:n,version:1}),signal:t}),n)}async setConnectorService(e,n,t,r){return ct(await this.request(`/v1/flows/${O(e)}/connector-access/${O(n)}/service`,{body:JSON.stringify({expectedAccessRevision:r,version:1}),method:t?"PUT":"DELETE"}))}async addProviderAccessBinding(e,n,t,r){return ct(await this.request(`/v1/flows/${O(e)}/connector-access/${O(n)}`,{body:JSON.stringify({accessBindingId:t,expectedAccessRevision:r,version:1}),method:"PUT"}))}async removeProviderAccessBinding(e,n,t,r){return ct(await this.request(`/v1/flows/${O(e)}/connector-access/${O(n)}`,{body:JSON.stringify({accessBindingId:t,expectedAccessRevision:r,version:1}),method:"DELETE"}))}async listConnectorActions(e,n,t,r){return await this.connectorActions({...r==null?{}:{locale:r},...t==null?{}:{flowId:t},...e==null?{}:{service:e}},n)}async searchConnectorActions(e,n,t,r){return await this.connectorActions({...r==null?{}:{locale:r},...t==null?{}:{flowId:t},q:e.trim()},n)}async getConnectorAction(e,n,t,r,o=!1){let i=om(e,t,r);return this.connectorRequest(i.path,"actions",n,i.decode,o)}async listAllConnectorConnections(e,n,t=!1){let r=im(n);return this.connectorRequest(r.path,"connections",e,r.decode,t)}async listConnectorConnections(e,n,t,r=!1){let o=sm(e,t);return this.connectorRequest(o.path,"connections",n,o.decode,r)}async createConnectorConnectionPage(e,n,t){let r=new URLSearchParams;if(n!=null)r.set("flowId",n);if(t!=null)r.set("teamId",t);let o=w(await this.request(`/v1/connector/connections/${O(e)}/page${r.size==0?"":`?${r}`}`,{body:JSON.stringify({version:1}),method:"POST"}));if(U(o,["url","version"]),o.version!=1)return d();try{let i=new URL(f(o.url));if(i.protocol!="http:"&&i.protocol!="https:")return d();return i.href}catch{return d()}}async readAuthoring(e,n={}){return Ef.parse(await this.request(`/v1/flows/${O(e)}/authoring/read`,{method:"POST",body:JSON.stringify(n)}))}async searchAuthoring(e,n){return Of.parse(await this.request(`/v1/flows/${O(e)}/authoring/search`,{method:"POST",body:JSON.stringify(n)}))}async authoringSchema(e,n){return w(await this.request(`/v1/flows/${O(e)}/authoring/schema`,{method:"POST",body:JSON.stringify(n)}))}async editAuthoring(e,n){return Cf.parse(await this.request(`/v1/flows/${O(e)}/authoring/edit`,{method:"POST",headers:{"idempotency-key":n.requestId},body:JSON.stringify(n)}))}async checkAuthoring(e,n){return If.parse(await this.request(`/v1/flows/${O(e)}/authoring/check`,{method:"POST",body:JSON.stringify({revisionId:n})}))}async changeDraft(e,n,t,r=Vn("change")){return cr(await this.request(`/v1/flows/${O(e)}/draft/changes`,{body:JSON.stringify({expectedRevisionId:n,operations:t,version:1}),headers:{"idempotency-key":r},method:"POST"}))}async repairDraft(e,n,t=Vn("repair")){return cr(await this.request(`/v1/flows/${O(e)}/draft/repair`,{body:JSON.stringify({expectedRevisionId:n,version:1}),headers:{"idempotency-key":t},method:"POST"}))}async upgradeDraft(e,n,t={}){return cr(await this.request(`/v1/flows/${O(e)}/draft/upgrade`,{body:JSON.stringify({expectedRevisionId:n,version:1}),headers:{"idempotency-key":t.idempotencyKey??Vn("upgrade")},method:"POST"}))}async checkFlow(e,n){return nm(await this.request(`/v1/flows/${O(e)}/revisions/${O(n)}/check`,{body:JSON.stringify({engineContract:"open-flow-engine/v5",version:1}),method:"POST"}))}async getLiveDetails(e,n){let t=Tf(await this.request(`/v1/flows/${O(e)}/live/details`,{signal:n}));if(t.flowId!=e)return d();return t}async getLive(e,n){return Fs(await this.request(`/v1/flows/${O(e)}/live`,{signal:n}))}async listPublications(e,n={},t){let r=new URLSearchParams;if(n.cursor!=null)r.set("cursor",n.cursor);if(n.limit!=null)r.set("limit",String(n.limit));if(n.includeTotal!=null)r.set("includeTotal",String(n.includeTotal));let o=r.size==0?"":`?${r}`;return Af(await this.request(`/v1/flows/${O(e)}/publications${o}`,{signal:t}))}async createDraftRun(e,n,t){let r=Oo(await this.request(`/v1/flows/${O(e)}/revisions/${O(n)}/runs`,{body:JSON.stringify({engineContract:"open-flow-engine/v5",inputs:t.inputs??{},trigger:t.trigger,version:2}),headers:{"idempotency-key":t.idempotencyKey??Vn("run")},method:"POST"}));return r.source=="draft"?r:d()}async createLiveRun(e,n){let t=Oo(await this.request("/v1/runs",{body:JSON.stringify({inputs:n.inputs??{},trigger:n.trigger,publicationId:e,version:2}),headers:{"idempotency-key":n.idempotencyKey??Vn("run")},method:"POST"}));return t.source=="live"?t:d()}async setFlowEnabled(e,n,t){return un(await this.request(`/v1/flows/${O(e)}/enabled`,{method:"PUT",body:JSON.stringify({enabled:t,expectedPublicationId:n,version:1})}))}async publishFlow(e,n,t,r={}){return Zs(await this.request(`/v1/flows/${O(e)}/revisions/${O(n)}/publications`,{body:JSON.stringify({engineContract:"open-flow-engine/v5",expectedLivePublicationId:t,version:1}),headers:{"idempotency-key":r.idempotencyKey??Vn("publication")},method:"POST"}))}async getPublishOperation(e,n,t){return Zs(await this.request(`/v1/flows/${O(e)}/publish-operations/${O(n)}`,{signal:t}))}async rollbackFlow(e,n,t,r={}){return at(await this.request(`/v1/flows/${O(e)}/publications/${O(n)}/rollback`,{body:JSON.stringify({expectedLivePublicationId:t,version:1}),headers:{"idempotency-key":r.idempotencyKey??Vn("publication")},method:"POST"}))}async getRun(e,n){return Oo(await this.request(`/v1/runs/${O(e)}`,{signal:n}))}async listRuns(e,n={}){let t=new URLSearchParams;if(n.cursor!=null)t.set("cursor",n.cursor);if(n.limit!=null)t.set("limit",String(n.limit));if(n.status!=null)t.set("status",n.status);if(n.pendingWait!=null)t.set("pendingWait",String(n.pendingWait));if(n.source!=null)t.set("source",n.source);if(n.createdFrom!=null)t.set("createdFrom",n.createdFrom);if(n.createdBefore!=null)t.set("createdBefore",n.createdBefore);if(n.runId!=null)t.set("runId",n.runId);let r=t.size==0?"":`?${t}`;return hm(await this.request(`/v1/flows/${O(e)}/runs${r}`))}async getRunEvents(e,n={},t){let r=new URLSearchParams;if(n.after!=null)r.set("after",String(n.after));if(n.limit!=null)r.set("limit",String(n.limit));let o=r.size==0?"":`?${r}`;return Zw(await this.request(`/v1/runs/${O(e)}/events${o}`,{signal:t}))}async listRunResults(e,n,t){return Hs(await this.request(`/v1/runs/${O(e)}/results${n==null?"":`?after=${encodeURIComponent(n)}`}`,{signal:t}))}async readRunResult(e,n,t={},r){let o=new URLSearchParams(Object.entries(t).map(([i,s])=>[i,String(s)]));return Qs(await this.request(`/v1/runs/${O(e)}/results/${O(n)}?${o}`,{signal:r}))}async downloadRunResult(e,n,t){return(await this.response(`/v1/runs/${O(e)}/results/${O(n)}/content`,{signal:t})).blob()}async getRunResult(e,n){return wm(await this.request(`/v1/runs/${O(e)}/result`,{signal:n}))}async cancelRun(e){return ym(await this.request(`/v1/runs/${O(e)}/cancel`,{body:JSON.stringify({version:1}),method:"POST"}))}async resolveRunWait(e,n,t,r){return bm(await this.request(`/v1/runs/${O(e)}/waits/${O(n)}/resolve`,{body:JSON.stringify({action:t,comment:r,version:1}),method:"POST"}))}async connectorActions(e,n){let t=Object.entries(e).map(([o,i])=>`${O(o)}=${O(i)}`).join("&"),r=t==""?"":`?${t}`;return this.connectorRequest(`/v1/connector/actions${r}`,"actions",n,(o)=>{let i=w(o);if(U(i,["actions","version"]),i.version!=1||!Array.isArray(i.actions))return d();return i.actions.map(xo)})}async connectorRequest(e,n,t,r,o=!1){return r(await this.request(e,{signal:t}))}async response(e,n,t=!1){let r=new Headers(n.headers);if(n.body!=null)r.set("content-type","application/json");let o=await this.requestControl(e,{...n,headers:r});if(!o.ok&&!(t&&o.status==304)){let i;try{i=await o.json()}catch{return d()}let s=w(i).error,a=s==null?void 0:w(s);throw new Ee(o.status,typeof a?.code=="string"?a.code:"request.failed",typeof a?.message=="string"?a.message:`Request failed with status ${o.status}.`,a?.details==null?void 0:w(a.details))}return o}async request(e,n={}){let t=await this.response(e,n);try{return await t.json()}catch{return d()}}}import{randomUUID as Bw}from"crypto";class C extends Error{constructor(e,n,t){super(n);this.code=e,this.details=t,this.name="CliError"}}function Ao(e,n){let t=e.trim();if(to(t)!=null)throw new C("cli.invalid-arguments",`${n} name must be between 1 and ${fs} characters and use only letters, numbers, spaces, hyphens, or underscores.`);return t}var Fw=100,Xs=100,ea=100,Jw=new Set(["canceled","completed","failed","indeterminate"]);async function Lw(e){let n=[],t=new Set,r;do{let o=await e.listFlows({cursor:r,limit:Fw});if(n.push(...o.flows),r=o.nextCursor,r!=null&&t.has(r))throw new C("page.invalid-cursor","The deployment returned a repeated Flow cursor.");if(r!=null)t.add(r)}while(r!=null);return n}function qw(e,n){let t=e.find((o)=>o.flowId==n);if(t!=null)return t;let r=e.filter((o)=>o.name==n);if(r.length==1)return r[0];if(r.length>1)throw new C("flow.ambiguous",`Flow name ${JSON.stringify(n)} is ambiguous.`,{candidates:r.map(({flowId:o,name:i})=>({flowId:o,name:i}))});throw new C("flow.not-found",`Flow ${JSON.stringify(n)} was not found.`)}async function he(e,n){try{return await e.getFlow(n)}catch(t){if(!(t instanceof Ee)||t.code!="flow.invalid"&&t.code!="flow.not-found")throw t}return qw(await Lw(e),n)}async function km(e,n,t){if(t.expectedRevision!=null&&t.expectedRevision!=n.draftRevisionId&&!t.options.includes("idempotency-key"))throw new C("flow.revision-conflict","The Flow Draft changed. Inspect it before submitting a new mutation.",{expectedRevisionId:t.expectedRevision,actualRevisionId:n.draftRevisionId,flowId:n.flowId});let r=await e.getRevision(n.flowId,t.expectedRevision??n.draftRevisionId);return{draft:r,flow:n,graph:r.content.document.graph}}function Uw(e,n){let t=e.find((o)=>o.actionId==n);if(t!=null)return t;let r=e.filter((o)=>o.name==n);if(r.length==1)return r[0];if(r.length>1)throw new C("connector.action-ambiguous",`Connector Action name ${JSON.stringify(n)} is ambiguous.`,{candidates:r.map(({actionId:o,name:i,serviceId:s})=>({actionId:o,name:i,serviceId:s}))});throw new C("connector.action-not-found",`Connector Action ${JSON.stringify(n)} was not found.`)}async function Sm(e,n,t){try{return await e.getConnectorAction(n,void 0,t)}catch(r){if(!(r instanceof Ee)||r.status!=404)throw r}return Uw(await e.searchConnectorActions(n,void 0,t),n)}function Im(e,n){let t=Object.entries(e.document.graph.nodes).filter((i)=>!("inputs"in i[1])),r=t?.find(([i])=>i==n);if(r!=null)return{trigger:r[1],triggerId:r[0]};let o=t?.filter(([,i])=>i.name==n)??[];if(o.length==1)return{trigger:o[0][1],triggerId:o[0][0]};if(o.length>1)throw new C("trigger.ambiguous",`Trigger name ${JSON.stringify(n)} is ambiguous.`,{candidates:o.map(([i,s])=>({name:s.name,triggerId:i}))});throw new C("trigger.not-found",`Trigger ${JSON.stringify(n)} was not found.`)}function na(e){return`${e.displayName} ${e.key} ${e.provider} ${e.type}`}async function Cm(e,n){try{return await e.getTriggerKey(n)}catch(o){if(!(o instanceof Ee)||o.status!=404)throw o}let r=(await e.listTriggerKeys()).filter((o)=>o.name==n||o.displayName==n);if(r.length==1)return await e.getTriggerKey(r[0].key);if(r.length>1)throw new C("trigger-key.ambiguous",`Trigger Key name ${JSON.stringify(n)} is ambiguous.`,{candidates:r.map(({displayName:o,key:i,provider:s})=>({displayName:o,key:i,provider:s}))});throw new C("trigger-key.not-found",`Trigger Key ${JSON.stringify(n)} was not found.`)}function Em(e){return`${e.displayName} ${e.connectionId} ${e.serviceId} ${e.status}${e.isDefault?"\tdefault":""}`}function ta(e){return`${e.name} ${e.actionId} ${e.serviceName} ${e.serviceId}`}function oe(e,n,t){if(e.length!=n)throw new C("cli.invalid-arguments",`Usage: ${t}`)}function V(e,n,t,r){e.stdout.write(n?`${JSON.stringify(t)}
|
|
58
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let s of e.seen.entries()){let a=s[1];if(n===s[0]){i(s);continue}if(e.external){let u=e.external.registry.get(s[0])?.id;if(n!==s[0]&&u){i(s);continue}}if(e.metadataRegistry.get(s[0])?.id){i(s);continue}if(a.cycle){i(s);continue}if(a.count>1){if(e.reused==="ref")i(s)}}if(e.external)e.sharedDefsExtractedFor=e.external}function Xl(e){let n=e.anyOf;if(!Array.isArray(n)||n.length===0||e.type!==void 0)return;let t=[];for(let r of n){if(!r||typeof r!=="object")return;Xl(r);let o=Object.keys(r);if(o.length!==1||o[0]!=="type")return;let i=r.type;for(let s of Array.isArray(i)?i:[i]){if(typeof s!=="string")return;if(!t.includes(s))t.push(s)}}delete e.anyOf,e.type=t.length===1?t[0]:t}var ed=new Set(["type","properties","required","additionalProperties"]),Ql=["oneOf","anyOf"];function Yl(e){let n=e.additionalProperties;if(n===void 0||n===!1||typeof n!=="object"||n===null)return null;return Object.keys(n).length?n:null}function Ai(e){let n=[];for(let i of e){if(typeof i!=="object"||i.type!=="object")return null;for(let s in i)if(!ed.has(s))return null;n.push(i)}let t={},r=new Set;for(let i of n){for(let s in i.properties){if(Object.prototype.hasOwnProperty.call(t,s))continue;let a=[];for(let u of n){let l=u.properties?.[s]??Yl(u);if(l===null||l===void 0)continue;if(!a.some((f)=>JSON.stringify(f)===JSON.stringify(l)))a.push(l)}let c=a.length===1?a[0]:Ai(a)??{allOf:a};Ve(t,s,c)}for(let s of i.required??[])r.add(s)}let o={type:"object",properties:t};if(r.size)o.required=[...r];if(n.every((i)=>i.additionalProperties===!1))o.additionalProperties=!1;else{let i=[];for(let s of n){let a=Yl(s);if(a&&!i.some((c)=>JSON.stringify(c)===JSON.stringify(a)))i.push(a)}if(i.length===1)o.additionalProperties=i[0];else if(i.length>1)o.additionalProperties={allOf:i}}return o}function dh(e){let n=e.allOf;if(!Array.isArray(n)||n.length<2)return;for(let o of ed)if(o in e)return;let t=n.filter((o)=>Ql.some((i)=>Array.isArray(o[i]))),r=null;if(!t.length)r=Ai(n);else{let o=t[0],i=Ql.find((c)=>Array.isArray(o[c]));if(Object.keys(o).length!==1)return;let s=n.filter((c)=>c!==o),a=o[i].map((c)=>Ai([...s,c]));if(a.some((c)=>!c))return;r={[i]:a}}if(!r)return;delete e.allOf,Rt(e,r)}function $t(e,n){let t=e.seen.get(n);if(!t)throw Error("Unprocessed schema. This is a bug in Zod.");let r=(a)=>{let c=e.seen.get(a);if(c.ref===null)return;let u=c.def??c.schema,l={...u},f=c.ref;if(c.ref=null,f){r(f);let h=e.seen.get(f),g=h.schema;if(g.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"))u.allOf=u.allOf??[],u.allOf.push(g);else Rt(u,g);if(Rt(u,l),a._zod.parent===f)for(let P in u){if(P==="$ref"||P==="allOf")continue;if(!(P in l))delete u[P]}if(g.$ref&&h.def)for(let P in u){if(P==="$ref"||P==="allOf")continue;if(P in h.def&&JSON.stringify(u[P])===JSON.stringify(h.def[P]))delete u[P]}}let m=a._zod.parent;if(m&&m!==f){r(m);let h=e.seen.get(m);if(h?.schema.$ref){if(u.$ref=h.schema.$ref,h.def)for(let g in u){if(g==="$ref"||g==="allOf")continue;if(g in h.def&&JSON.stringify(u[g])===JSON.stringify(h.def[g]))delete u[g]}}}e.override({zodSchema:a,jsonSchema:u,path:c.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let a of[...e.seen.entries()].reverse())r(a[0]);if(e.target!=="openapi-3.0")for(let a of e.seen.entries())Xl(a[1].def??a[1].schema);for(let a of e.deferred)a();if(e.intersections.length){let a=new Map;for(let c of e.seen.values())for(let u of[c.schema,c.def]){let l=u?.allOf;if(!Array.isArray(l))continue;let f=a.get(l);if(f)f.push(u);else a.set(l,[u])}for(let c of e.intersections)for(let u of a.get(c)??[])dh(u)}}let o={};if(e.target==="draft-2020-12")o.$schema="https://json-schema.org/draft/2020-12/schema";else if(e.target==="draft-07")o.$schema="http://json-schema.org/draft-07/schema#";else if(e.target==="draft-04")o.$schema="http://json-schema.org/draft-04/schema#";else if(e.target==="openapi-3.0");if(e.external?.uri){let a=e.external.registry.get(n)?.id;if(!a)throw Error("Schema is missing an `id` property");o.$id=e.external.uri(a)}Rt(o,t.defId?t.schema:t.def??t.schema);let i=e.metadataRegistry.get(n)?.id;if(i!==void 0&&o.id===i)delete o.id;let s=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let a of e.seen.entries()){let c=a[1];if(c.def&&c.defId){if(c.def.id===c.defId)delete c.def.id;Ve(s,c.defId,c.def)}}if(e.external)e.sharedEmitDoneFor=e.external;if(e.external);else if(Object.keys(s).length>0)if(e.target==="draft-2020-12")o.$defs=s;else o.definitions=s;try{let a=JSON.parse(JSON.stringify(o));return Object.defineProperty(a,"~standard",{value:{...n["~standard"],jsonSchema:{input:At(n,"input",e.processors),output:At(n,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch(a){throw Error("Error converting schema to JSON.")}}function Oe(e,n){let t=n??{seen:new Set};if(t.seen.has(e))return!1;t.seen.add(e);let r=e._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return Oe(r.element,t);if(r.type==="set")return Oe(r.valueType,t);if(r.type==="lazy")return Oe(r.getter(),t);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault"||r.type==="catch")return Oe(r.innerType,t);if(r.type==="intersection")return Oe(r.left,t)||Oe(r.right,t);if(r.type==="record"||r.type==="map")return Oe(r.keyType,t)||Oe(r.valueType,t);if(r.type==="pipe"){if(e._zod.traits.has("$ZodCodec"))return!0;return Oe(r.in,t)||Oe(r.out,t)}if(r.type==="object"){for(let o in r.shape)if(Oe(r.shape[o],t))return!0;return!1}if(r.type==="union"){for(let o of r.options)if(Oe(o,t))return!0;return!1}if(r.type==="tuple"){for(let o of r.items)if(Oe(o,t))return!0;if(r.rest&&Oe(r.rest,t))return!0;return!1}return!1}var nd=(e,n={})=>(t)=>{let r=jt({...t,processors:n});return te(e,r),Pt(r,e),$t(r,e)},At=(e,n,t={})=>(r)=>{let{libraryOptions:o,target:i}=r??{},s=jt({...o??{},target:i,io:n,processors:t});return te(e,s),Pt(s,e),$t(s,e)};var Bn=(e,n,t)=>{if(e[n]===void 0||t>e[n])e[n]=t},Kn=(e,n,t)=>{if(e[n]===void 0||t<e[n])e[n]=t},td=(e,n)=>{Bn(e,"minimum",n),Kn(e,"maximum",n)},ad=(e,n)=>{if(e.multipleOf??(e.multipleOf=[]),!e.multipleOf.includes(n))e.multipleOf.push(n)},cd=(e,n)=>{e.patterns??(e.patterns=new Set),e.patterns.add(n)},ud=(e,n)=>{e.mime=e.mime?e.mime.filter((t)=>n.includes(t)):[...n]},ld=(e,n)=>{if(e.format=n,n.includes("int"))e.isInt=!0},rd=(e,n)=>Bn(e,"minimum",n.minimum),od=(e,n)=>Kn(e,"maximum",n.maximum),id=(e)=>(n,t)=>{ld(n,t.format);let[r,o]=e[t.format];Bn(n,"minimum",r),Kn(n,"maximum",o)},ph={greater_than:(e,n)=>Bn(e,n.inclusive?"minimum":"exclusiveMinimum",n.value),less_than:(e,n)=>Kn(e,n.inclusive?"maximum":"exclusiveMaximum",n.value),multiple_of:(e,n)=>ad(e,n.value),number_format:id(xr),bigint_format:id(Wo),min_length:rd,max_length:od,length_equals:(e,n)=>td(e,n.length),min_size:rd,max_size:od,size_equals:(e,n)=>td(e,n.size),string_format:(e,n)=>{if(ld(e,n.format),n.pattern)cd(e,n.pattern);if(n.format==="base64"||n.format==="base64url")e.contentEncoding=n.format;if(n.local||n.precision===-1)e.laxFormat=!0},mime_type:(e,n)=>ud(e,n.mime)};function $e(e){let n={},t=e._zod.def,r=e._zod.traits.has("$ZodCheck")?[e,...t.checks??[]]:t.checks??[];for(let i of r)ph[i._zod.def.check]?.(n,i._zod.def);let o=e._zod.bag;if(o.minimum!==void 0)Bn(n,"minimum",o.minimum);if(o.exclusiveMinimum!==void 0)Bn(n,"exclusiveMinimum",o.exclusiveMinimum);if(o.maximum!==void 0)Kn(n,"maximum",o.maximum);if(o.exclusiveMaximum!==void 0)Kn(n,"exclusiveMaximum",o.exclusiveMaximum);if(o.multipleOf!==void 0)ad(n,o.multipleOf);if(o.format!==void 0){if(n.format??(n.format=o.format),o.format.includes("int"))n.isInt=!0}if(o.mime)ud(n,o.mime);for(let i of o.patterns??[])cd(n,i);return n}var fh={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},mh=new Map([[li,Ic],[Nr,Cc]]),dd=(e)=>mh.get(e)??e,$i=(e,n,t,r)=>{let o=t;o.type="string";let{minimum:i,maximum:s,format:a,patterns:c,contentEncoding:u,laxFormat:l}=$e(e);if(typeof i==="number")o.minLength=i;if(typeof s==="number")o.maxLength=s;if(a){if(o.format=fh[a]??a,o.format==="")delete o.format;if(a==="time"||l)delete o.format}if(u)o.contentEncoding=u;if(c&&c.size>0){let f=[...c].map(dd);if(f.length===1)o.pattern=f[0].source;else if(f.length>1)o.allOf=[...f.map((m)=>({...n.target==="draft-07"||n.target==="draft-04"||n.target==="openapi-3.0"?{type:"string"}:{},pattern:m.source}))]}},_i=(e,n,t,r)=>{let o=t,{minimum:i,maximum:s,multipleOf:a,exclusiveMaximum:c,exclusiveMinimum:u,isInt:l}=$e(e);o.type=l?"integer":"number";let f=typeof u==="number"&&u>=(i??Number.NEGATIVE_INFINITY),m=typeof c==="number"&&c<=(s??Number.POSITIVE_INFINITY),h=n.target==="draft-04"||n.target==="openapi-3.0";if(f)if(h)o.minimum=u,o.exclusiveMinimum=!0;else o.exclusiveMinimum=u;else if(typeof i==="number")o.minimum=i;if(m)if(h)o.maximum=c,o.exclusiveMaximum=!0;else o.exclusiveMaximum=c;else if(typeof s==="number")o.maximum=s;if(a){let g=new Set;for(let T of a)if(Number.isFinite(T)&&T!==0)g.add(Math.abs(T));else ke(e,n,o,r,`A multipleOf divisor of ${T} cannot be represented in JSON Schema`);let[E,...P]=g;if(E!==void 0)o.multipleOf=E;if(P.length)o.allOf=[...o.allOf??[],...P.map((T)=>({multipleOf:T}))]}},Ti=(e,n,t,r)=>{t.type="boolean"},pd=(e,n,t,r)=>{ke(e,n,t,r,"BigInt cannot be represented in JSON Schema")},fd=(e,n,t,r)=>{ke(e,n,t,r,"Symbols cannot be represented in JSON Schema")},Ni=(e,n,t,r)=>{if(n.target==="openapi-3.0")t.type="string",t.nullable=!0,t.enum=[null];else t.type="null"},md=(e,n,t,r)=>{ke(e,n,t,r,"Undefined cannot be represented in JSON Schema")},gd=(e,n,t,r)=>{ke(e,n,t,r,"Void cannot be represented in JSON Schema")},zi=(e,n,t,r)=>{t.not={}},hd=(e,n,t,r)=>{},Di=(e,n,t,r)=>{},yd=(e,n,t,r)=>{ke(e,n,t,r,"Date cannot be represented in JSON Schema")},Vi=(e,n,t,r)=>{let o=e._zod.def,i=ht(o.entries);if(i.length===0){t.not={};return}if(i.every((s)=>typeof s==="number"))t.type="number";if(i.every((s)=>typeof s==="string"))t.type="string";t.enum=i},Mi=(e,n,t,r)=>{let o=e._zod.def;if(o.values.length===0){t.not={};return}let i=[];for(let s of o.values)if(s===void 0){if(ke(e,n,t,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof s==="bigint"){if(ke(e,n,t,r,"BigInt literals cannot be represented in JSON Schema"))return;i.push(Number(s))}else i.push(s);if(i.length===0);else if(i.length===1){let s=i[0];if(t.type=s===null?"null":typeof s,n.target==="draft-04"||n.target==="openapi-3.0")t.enum=[s];else t.const=s}else{if(i.every((s)=>typeof s==="number"))t.type="number";if(i.every((s)=>typeof s==="string"))t.type="string";if(i.every((s)=>typeof s==="boolean"))t.type="boolean";if(i.every((s)=>s===null))t.type="null";t.enum=i}},bd=(e,n,t,r)=>{ke(e,n,t,r,"NaN cannot be represented in JSON Schema")},wd=(e,n,t,r)=>{let o=t,i=e._zod.pattern;if(!i)throw Error("Pattern not found in template literal");o.type="string",o.pattern=i.source},xd=(e,n,t,r)=>{let o=t;o.type="string",o.format="binary",o.contentEncoding="binary";let{minimum:i,maximum:s,mime:a}=$e(e);if(i!==void 0)o.minLength=i;if(s!==void 0)o.maxLength=s;if(!a)return;if(a.length===0)o.not={};else if(a.length===1)o.contentMediaType=a[0];else o.anyOf=a.map((c)=>({contentMediaType:c}))},vd=(e,n,t,r)=>{t.type="boolean"},Zi=(e,n,t,r)=>{ke(e,n,t,r,"Custom types cannot be represented in JSON Schema")},kd=(e,n,t,r)=>{ke(e,n,t,r,"Function types cannot be represented in JSON Schema")},Fi=(e,n,t,r)=>{ke(e,n,t,r,"Transforms cannot be represented in JSON Schema")},Sd=(e,n,t,r)=>{ke(e,n,t,r,"Map cannot be represented in JSON Schema")},Id=(e,n,t,r)=>{ke(e,n,t,r,"Set cannot be represented in JSON Schema")},Ji=(e,n,t,r)=>{let o=t,i=e._zod.def,{minimum:s,maximum:a}=$e(e);if(typeof s==="number")o.minItems=s;if(typeof a==="number")o.maxItems=a;o.type="array",o.items=te(i.element,n,{...r,path:[...r.path,"items"]})};function _t(e){let n=e._zod.def;if(n.type==="pipe"&&n.in._zod.traits.has("$ZodTransform"))return _t(n.out);if(n.type==="catch")return _t(n.innerType);return e._zod.optin}var Li=(e,n,t,r)=>{let o=t,i=e._zod.def,s=i.shape;if(Object.getOwnPropertySymbols(s).length&&ke(e,n,o,r,"Symbol keys cannot be represented in JSON Schema"))return;o.type="object",o.properties={};for(let u in s)Ve(o.properties,u,te(s[u],n,{...r,path:[...r.path,"properties",u]}));let c=[];for(let u of Object.keys(s)){let l=i.shape[u];if(n.io==="input"?_t(l)===void 0:l._zod.optout===void 0)c.push(u)}if(c.length>0)o.required=c;if(i.catchall?._zod.def.type==="never")o.additionalProperties=!1;else if(!i.catchall){if(n.io==="output")o.additionalProperties=!1}else if(i.catchall)o.additionalProperties=te(i.catchall,n,{...r,path:[...r.path,"additionalProperties"]})},qi=(e,n,t,r)=>{let o=e._zod.def,i=o.inclusive===!1,s=o.options.map((a,c)=>te(a,n,{...r,path:[...r.path,i?"oneOf":"anyOf",c]}));if(i)t.oneOf=s;else t.anyOf=s},Ui=(e,n,t,r)=>{let o=e._zod.def,i=te(o.left,n,{...r,path:[...r.path,"allOf",0]}),s=te(o.right,n,{...r,path:[...r.path,"allOf",1]}),a=(u)=>("allOf"in u)&&Object.keys(u).length===1,c=[...a(i)?i.allOf:[i],...a(s)?s.allOf:[s]];t.allOf=c,n.intersections.push(c)},Cd=(e,n,t,r)=>{let o=t,i=e._zod.def;o.type="array";let s=n.target==="draft-2020-12"?"prefixItems":"items",a=n.target==="draft-2020-12"?"items":n.target==="openapi-3.0"?"items":"additionalItems",c=i.items.map((E,P)=>te(E,n,{...r,path:[...r.path,s,P]})),u=i.rest?te(i.rest,n,{...r,path:[...r.path,a,...n.target==="openapi-3.0"?[i.items.length]:[]]}):null,l=i.items.length;while(l>0){let E=i.items[l-1];if(!(n.io==="input"?_t(E)!==void 0:E._zod.optout==="optional"))break;l--}let f=i.items.length,m=!i.rest;if(n.target==="draft-2020-12"){if(o.prefixItems=c,m)o.items=!1;else if(u)o.items=u;if(l>0)o.minItems=l;if(m)o.maxItems=f}else if(n.target==="openapi-3.0"){if(o.items={anyOf:c},u)o.items.anyOf.push(u);if(l>0)o.minItems=l;if(m)o.maxItems=f}else{if(o.items=c,m)o.additionalItems=!1;else if(u)o.additionalItems=u;if(l>0)o.minItems=l;if(m)o.maxItems=f}let{minimum:h,maximum:g}=$e(e);if(typeof h==="number")o.minItems=h;if(typeof g==="number")o.maxItems=g};function ji(e,n,t){if(n.$ref){if(t.has(n))return n;t.add(n);let g=e.get(n)?.def;if(!g)return n;let E=ji(e,g,t);return E===g?n:E}for(let g of["anyOf","oneOf"]){let E=n[g];if(!Array.isArray(E))continue;let P=E.map((T)=>ji(e,T,t));if(P.some((T,L)=>T!==E[L]))n={...n,[g]:P}}let r=Array.isArray(n.type)?n.type:[n.type],o=!r.includes("string")&&r.some((g)=>g==="number"||g==="integer"),i=n.enum??(n.const!==void 0?[n.const]:void 0);if(!o&&!i?.some((g)=>typeof g==="number"))return n;let{minimum:s,maximum:a,exclusiveMinimum:c,exclusiveMaximum:u,multipleOf:l,format:f,id:m,...h}=n;if(h.enum)h.enum=h.enum.map((g)=>typeof g==="number"?String(g):g);else if(typeof h.const==="number")h.const=String(h.const);if(!o)return h;if(h.type="string",!i)h.pattern=(r.includes("number")?vt:ri).source;return h}var Pi=new WeakMap;function gh(e){let n=new Map;for(let r of e.seen.values())if(r.def&&!n.has(r.schema))n.set(r.schema,r);let t=new Map;for(let r of Pi.get(e)??[]){let o=e.seen.get(r),i=(o?.def??o?.schema)?.propertyNames;if(!i||i===!0||t.has(i))continue;let s=ji(n,i,new Set);if(s!==i)t.set(i,s)}if(!t.size)return;for(let r of e.seen.values())for(let o of[r.schema,r.def]){let i=o&&t.get(o.propertyNames);if(i)o.propertyNames=i}}var Bi=(e,n,t,r)=>{let o=t,i=e._zod.def;o.type="object";let s=i.keyType,a=$e(s).patterns;if(i.mode==="loose"&&a&&a.size>0){let l=te(i.valueType,n,{...r,path:[...r.path,"patternProperties","*"]});o.patternProperties={};for(let f of a)Ve(o.patternProperties,dd(f).source,l)}else{if(n.target==="draft-07"||n.target==="draft-2020-12"){o.propertyNames=te(i.keyType,n,{...r,path:[...r.path,"propertyNames"]});let l=Pi.get(n);if(!l)l=[],Pi.set(n,l),n.deferred.push(()=>gh(n));l.push(e)}o.additionalProperties=te(i.valueType,n,{...r,path:[...r.path,"additionalProperties"]})}let c=s._zod.values,u=n.io==="input"&&_t(i.valueType)!==void 0;if(c&&!i.partial&&!u){let l=[...c].filter((f)=>typeof f==="string"||typeof f==="number");if(l.length>0)o.required=l.map(String)}},Ki=(e,n,t,r)=>{let o=e._zod.def,i=te(o.innerType,n,r),s=n.seen.get(e);if(n.target==="openapi-3.0")s.ref=o.innerType,t.nullable=!0;else t.anyOf=[i,{type:"null"}]},Wi=(e,n,t,r)=>{let o=e._zod.def;te(o.innerType,n,r);let i=n.seen.get(e);i.ref=o.innerType},Gi=Symbol();function Ed(e,n,t,r,o){let i=!1,s=JSON.stringify(e,(a,c)=>{if(typeof c!=="bigint")return c;return i=!0,null});if(!i)return JSON.parse(s);return ke(n,t,r,o,"BigInt defaults cannot be represented in JSON Schema"),Gi}var Hi=(e,n,t,r)=>{let o=e._zod.def;te(o.innerType,n,r);let i=n.seen.get(e);i.ref=o.innerType;let s=Ed(o.defaultValue,e,n,t,r);if(s!==Gi)t.default=s},Qi=(e,n,t,r)=>{let o=e._zod.def;te(o.innerType,n,r);let i=n.seen.get(e);if(i.ref=o.innerType,n.io!=="input")return;let s=Ed(o.defaultValue,e,n,t,r);if(s!==Gi)t._prefault=s},Yi=(e,n,t,r)=>{let o=e._zod.def;te(o.innerType,n,r);let i=n.seen.get(e);i.ref=o.innerType;let s;try{s=o.catchValue(void 0)}catch{ke(e,n,t,r,"Dynamic catch values are not supported in JSON Schema");return}t.default=s},Xi=(e,n,t,r)=>{let o=e._zod.def,i=o.in._zod.traits.has("$ZodTransform"),s=n.io==="input"?i?o.out:o.in:o.out;te(s,n,r);let a=n.seen.get(e);a.ref=s},es=(e,n,t,r)=>{let o=e._zod.def;te(o.innerType,n,r);let i=n.seen.get(e);i.ref=o.innerType,t.readOnly=!0},Od=(e,n,t,r)=>{let o=e._zod.def;te(o.innerType,n,r);let i=n.seen.get(e);i.ref=o.innerType},Ur=(e,n,t,r)=>{let o=e._zod.def;te(o.innerType,n,r);let i=n.seen.get(e);i.ref=o.innerType},ns=(e,n,t,r)=>{let o=e._zod.innerType;te(o,n,r);let i=n.seen.get(e);i.ref=o},sd={string:$i,number:_i,boolean:Ti,bigint:pd,symbol:fd,null:Ni,undefined:md,void:gd,never:zi,any:hd,unknown:Di,date:yd,enum:Vi,literal:Mi,nan:bd,template_literal:wd,file:xd,success:vd,custom:Zi,function:kd,transform:Fi,map:Sd,set:Id,array:Ji,object:Li,union:qi,intersection:Ui,tuple:Cd,record:Bi,nullable:Ki,nonoptional:Wi,default:Hi,prefault:Qi,catch:Yi,pipe:Xi,readonly:es,promise:Od,optional:Ur,lazy:ns};function Tt(e,n){if("_idmap"in e){let r=e,o=jt({...n,processors:sd}),i={};for(let c of r._idmap.entries()){let[u,l]=c;te(l,o)}let s={},a={registry:r,uri:n?.uri,defs:i};o.external=a;for(let c of r._idmap.entries()){let[u,l]=c;Pt(o,l),Ve(s,u,$t(o,l))}if(Object.keys(i).length>0){let c=o.target==="draft-2020-12"?"$defs":"definitions";s.__shared={[c]:i}}return{schemas:s}}let t=jt({...n,processors:sd});return te(e,t),Pt(t,e),$t(t,e)}var Rd=new WeakSet([Object.prototype,Error.prototype]);function Kr(e,n,t){Object.defineProperty(e,n,{configurable:!0,enumerable:!1,get(){let r=t(this);return Object.defineProperty(this,n,{value:r,configurable:!0,writable:!0}),r},set(r){Object.defineProperty(this,n,{value:r,configurable:!0,writable:!0})}})}var Ad=(e,n)=>{Qa.init(e,n),e.name="ZodError";let t=Object.getPrototypeOf(e);if(Rd.has(t))return;Rd.add(t),Kr(t,"format",(r)=>(o)=>Xa(r,o)),Kr(t,"flatten",(r)=>(o)=>Ya(r,o)),Kr(t,"addIssue",(r)=>(o)=>{r.issues.push(o),r.message=JSON.stringify(r.issues,yt,2)}),Kr(t,"addIssues",(r)=>(o)=>{r.issues.push(...o),r.message=JSON.stringify(r.issues,yt,2)}),Object.defineProperty(t,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}})},Ih=b("ZodError",Ad),Fe=b("ZodError",Ad,void 0,{Parent:Error});var jd=Er(Fe),Pd=Or(Fe),$d=Rr(Fe),_d=Ar(Fe),Td=nc(Fe),Nd=tc(Fe),zd=rc(Fe),Dd=oc(Fe),Vd=ic(Fe),Md=sc(Fe),Zd=ac(Fe),Fd=cc(Fe);function Eh(){if(!Pe.localeError)Ze(yi())}function Gr(){if(!Pe.memoizer)Ze({memoizer:ll()})}var se=b("ZodType",(e,n)=>(Eh(),ie.init(e,n),e.def=n,e.type=n.type,e),{check(...e){let n=this.def;return this.clone(Me(n,{checks:[...n.checks??[],...e.map((t)=>typeof t==="function"?{_zod:{check:t,def:{check:"custom"},onattach:[]}}:t)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,n){return Qe(this,e,n)},brand(){return this},register(e,n){return e.add(this,n),this},refine(e,n){return this.check(Sy(e,n))},superRefine(e,n){return this.check(Iy(e,n))},overwrite(e){return this.check(gn(e))},optional(){return Ld(this)},exactOptional(){return cy(this)},nullable(){return qd(this)},nullish(){return Ld(qd(this))},nonoptional(e){return my(this,e)},array(){return j(this)},or(e){return X([this,e])},and(e){return iy(this,e)},transform(e){return Ud(this,Hd(e))},default(e){return dy(this,e)},prefault(e){return fy(this,e)},catch(e){return hy(this,e)},pipe(e){return Ud(this,e)},readonly(){return wy(this)},describe(e){let n=this.clone();return An.add(n,{description:e}),n},meta(...e){if(e.length===0)return An.get(this);let n=this.clone();return An.add(n,e[0]),n},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...n){return n.length===0?e(this):e(this,...n)},get "~standard"(){return Ir(this,"~standard",{...ui(this),jsonSchema:{input:At(this,"input"),output:At(this,"output")}})},set "~standard"(e){on(this,"~standard",e)},parse:function e(n,t){return jd(this,n,t,{callee:e})},parseAsync:async function e(n,t){return await Pd(this,n,t,{callee:e})},safeParse(e,n){return $d(this,e,n)},async safeParseAsync(e,n){return _d(this,e,n)},get spa(){return this?.safeParseAsync},set spa(e){on(this,"spa",e)},validate(e,n){return Xo(this,e,n)},validateAsync(e,n){return ei(this,e,n)},encode:function e(n,t){return Td(this,n,t,{callee:e})},decode:function e(n,t){return Nd(this,n,t,{callee:e})},encodeAsync:async function e(n,t){return await zd(this,n,t,{callee:e})},decodeAsync:async function e(n,t){return await Dd(this,n,t,{callee:e})},safeEncode(e,n){return Vd(this,e,n)},safeDecode(e,n){return Md(this,e,n)},async safeEncodeAsync(e,n){return Zd(this,e,n)},async safeDecodeAsync(e,n){return Fd(this,e,n)},toJSONSchema(e){return nd(this,{})(e)},get description(){return An.get(this)?.description},get _def(){return this._zod.def}}),Bd=b("_ZodString",(e,n)=>{Tr.init(e,n),se.init(e,n),e._zod.processJSONSchema=(t,r,o)=>$i(e,t,r,o)},Ua({format:(e)=>$e(e).format??null,minLength:(e)=>$e(e).minimum??null,maxLength:(e)=>$e(e).maximum??null},{regex(...e){return this.check(bi(...e))},includes(...e){return this.check(vi(...e))},startsWith(...e){return this.check(ki(...e))},endsWith(...e){return this.check(Si(...e))},min(...e){return this.check(Un(...e))},max(...e){return this.check(Lr(...e))},length(...e){return this.check(qr(...e))},nonempty(...e){return this.check(Un(1,...e))},lowercase(e){return this.check(wi(e))},uppercase(e){return this.check(xi(e))},trim(){return this.check(Ci())},normalize(...e){return this.check(Ii(...e))},toLowerCase(){return this.check(Ei())},toUpperCase(){return this.check(Oi())},slugify(){return this.check(Ri())}})),Oh=b("ZodString",(e,n)=>{Tr.init(e,n),Bd.init(e,n)},{email(e){return this.check(gl($h,e))},url(e){return this.check(vl(Th,e))},jwt(e){return this.check(zl(Gh,e))},emoji(e){return this.check(kl(Nh,e))},guid(e){return this.check(hl(_h,e))},uuid(e){return this.check(yl(Wr,e))},uuidv4(e){return this.check(bl(Wr,e))},uuidv6(e){return this.check(wl(Wr,e))},uuidv7(e){return this.check(xl(Wr,e))},nanoid(e){return this.check(Sl(zh,e))},cuid(e){return this.check(Il(Dh,e))},cuid2(e){return this.check(Cl(Vh,e))},ulid(e){return this.check(El(Mh,e))},base64(e){return this.check(_l(Bh,e))},base64url(e){return this.check(Tl(Kh,e))},xid(e){return this.check(Ol(Zh,e))},ksuid(e){return this.check(Rl(Fh,e))},ipv4(e){return this.check(Al(Jh,e))},ipv6(e){return this.check(jl(Lh,e))},cidrv4(e){return this.check(Pl(qh,e))},cidrv6(e){return this.check($l(Uh,e))},e164(e){return this.check(Nl(Wh,e))},datetime(e){return this.check(Dl(Rh,e))},date(e){return this.check(Vl(Ah,e))},time(e){return this.check(Ml(jh,e))},duration(e){return this.check(Zl(Ph,e))}});function R(e){return ml(Oh,e)}var fe=b("ZodStringFormat",(e,n)=>{ae.init(e,n),Bd.init(e,n)}),Rh=b("ZodISODateTime",(e,n)=>{vu.init(e,n),fe.init(e,n)}),Ah=b("ZodISODate",(e,n)=>{ku.init(e,n),fe.init(e,n)}),jh=b("ZodISOTime",(e,n)=>{Su.init(e,n),fe.init(e,n)}),Ph=b("ZodISODuration",(e,n)=>{Iu.init(e,n),fe.init(e,n)}),$h=b("ZodEmail",(e,n)=>{lu.init(e,n),fe.init(e,n)});var _h=b("ZodGUID",(e,n)=>{cu.init(e,n),fe.init(e,n)});var Wr=b("ZodUUID",(e,n)=>{uu.init(e,n),fe.init(e,n)});var Th=b("ZodURL",(e,n)=>{fu.init(e,n),fe.init(e,n)});var Nh=b("ZodEmoji",(e,n)=>{mu.init(e,n),fe.init(e,n)});var zh=b("ZodNanoID",(e,n)=>{gu.init(e,n),fe.init(e,n)});var Dh=b("ZodCUID",(e,n)=>{hu.init(e,n),fe.init(e,n)});var Vh=b("ZodCUID2",(e,n)=>{yu.init(e,n),fe.init(e,n)});var Mh=b("ZodULID",(e,n)=>{bu.init(e,n),fe.init(e,n)});var Zh=b("ZodXID",(e,n)=>{wu.init(e,n),fe.init(e,n)});var Fh=b("ZodKSUID",(e,n)=>{xu.init(e,n),fe.init(e,n)});var Jh=b("ZodIPv4",(e,n)=>{Cu.init(e,n),fe.init(e,n)});var Lh=b("ZodIPv6",(e,n)=>{Ou.init(e,n),fe.init(e,n)});var qh=b("ZodCIDRv4",(e,n)=>{Ru.init(e,n),fe.init(e,n)});var Uh=b("ZodCIDRv6",(e,n)=>{Au.init(e,n),fe.init(e,n)});var Bh=b("ZodBase64",(e,n)=>{Pu.init(e,n),fe.init(e,n)});var Kh=b("ZodBase64URL",(e,n)=>{$u.init(e,n),fe.init(e,n)});var Wh=b("ZodE164",(e,n)=>{_u.init(e,n),fe.init(e,n)});var Gh=b("ZodJWT",(e,n)=>{Tu.init(e,n),fe.init(e,n)});var Kd=b("ZodNumber",(e,n)=>{di.init(e,n),se.init(e,n),e._zod.processJSONSchema=(t,r,o)=>_i(e,t,r,o),e.isFinite=!0},Ua({minValue:(e)=>{let{minimum:n,exclusiveMinimum:t}=$e(e);return Math.max(n??Number.NEGATIVE_INFINITY,t??Number.NEGATIVE_INFINITY)},maxValue:(e)=>{let{maximum:n,exclusiveMaximum:t}=$e(e);return Math.min(n??Number.POSITIVE_INFINITY,t??Number.POSITIVE_INFINITY)},isInt:(e)=>{let{isInt:n,multipleOf:t}=$e(e);return!!n||!!t?.some(Number.isSafeInteger)},format:(e)=>$e(e).format??null},{gt(e,n){return this.check(Fr(e,n))},gte(e,n){return this.check(Ot(e,n))},min(e,n){return this.check(Ot(e,n))},lt(e,n){return this.check(Zr(e,n))},lte(e,n){return this.check(Et(e,n))},max(e,n){return this.check(Et(e,n))},int(e){return this.check(ge(e))},safe(e){return this.check(ge(e))},positive(e){return this.check(Fr(0,e))},nonnegative(e){return this.check(Ot(0,e))},negative(e){return this.check(Zr(0,e))},nonpositive(e){return this.check(Et(0,e))},multipleOf(e,n){return this.check(Jr(e,n))},step(e,n){return this.check(Jr(e,n))},finite(){return this}}));function ue(e){return Fl(Kd,e)}var Hh=b("ZodNumberFormat",(e,n)=>{Nu.init(e,n),Kd.init(e,n)});function ge(e){return Jl(Hh,e)}var Qh=b("ZodBoolean",(e,n)=>{zu.init(e,n),se.init(e,n),e._zod.processJSONSchema=(t,r,o)=>Ti(e,t,r,o)});function le(e){return Ll(Qh,e)}var Yh=b("ZodNull",(e,n)=>{Du.init(e,n),se.init(e,n),e._zod.processJSONSchema=(t,r,o)=>Ni(e,t,r,o)});function Xh(e){return ql(Yh,e)}var ey=b("ZodUnknown",(e,n)=>{Vu.init(e,n),se.init(e,n),e._zod.processJSONSchema=(t,r,o)=>Di(e,t,r,o)});function Wn(){return Ul(ey)}var ny=b("ZodNever",(e,n)=>{Mu.init(e,n),se.init(e,n),e._zod.processJSONSchema=(t,r,o)=>zi(e,t,r,o)});function hn(e){return Bl(ny,e)}var ty=b("ZodArray",(e,n)=>{Gr(),Zu.init(e,n),se.init(e,n),e._zod.processJSONSchema=(t,r,o)=>Ji(e,t,r,o),e.element=n.element},{min(e,n){return this.check(Un(e,n))},nonempty(e){return this.check(Un(1,e))},max(e,n){return this.check(Lr(e,n))},length(e,n){return this.check(qr(e,n))},unwrap(){return this.element}});function j(e,n){return Kl(ty,e,n)}var Wd=b("ZodObject",(e,n)=>{Gr(),Lu.init(e,n),se.init(e,n),e._zod.processJSONSchema=(t,r,o)=>Li(e,t,r,o),_g(e,"shape",(t)=>t._zod.def.shape,!1)},{keyof(){return ce(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(Me(this._zod.def,{catchall:e}))},passthrough(){return this.clone(Me(this._zod.def,{catchall:Wn()}))},loose(){return this.clone(Me(this._zod.def,{catchall:Wn()}))},strict(){return this.clone(Me(this._zod.def,{catchall:hn()}))},strip(){return this.clone(Me(this._zod.def,{catchall:void 0}))},extend(e){return Cg(this,e)},safeExtend(e){return Eg(this,e)},merge(e){return Og(this,e)},pick(e){return Sg(this,e)},omit(e){return Ig(this,e)},partial(...e){return Fa(Qd,this,e[0])},exactPartial(...e){return Fa(Yd,this,e[0],"exactPartial")},required(...e){return Rg(Xd,this,e[0])}});function I(e,n){let t={type:"object",shape:e??{},..._(n)};return new Wd(t)}function v(e,n){return new Wd({type:"object",shape:e,catchall:hn(),..._(n)})}var Gd=b("ZodUnion",(e,n)=>{pi.init(e,n),se.init(e,n),e._zod.processJSONSchema=(t,r,o)=>qi(e,t,r,o),e.options=n.options});function X(e,n){return new Gd({type:"union",options:e,..._(n)})}var ry=b("ZodDiscriminatedUnion",(e,n)=>{Gd.init(e,n),qu.init(e,n)});function jn(e,n,t){return new ry({type:"union",options:n,discriminator:e,..._(t)})}var oy=b("ZodIntersection",(e,n)=>{Uu.init(e,n),se.init(e,n),e._zod.processJSONSchema=(t,r,o)=>Ui(e,t,r,o)});function iy(e,n){return new oy({type:"intersection",left:e,right:n})}var Jd=b("ZodRecord",(e,n)=>{Gr(),Bu.init(e,n),se.init(e,n),e._zod.processJSONSchema=(t,r,o)=>Bi(e,t,r,o),e.keyType=n.keyType,e.valueType=n.valueType});function ee(e,n,t){if(!n||!n._zod)return new Jd({type:"record",keyType:R(),valueType:e,..._(n)});return new Jd({type:"record",keyType:e,valueType:n,..._(t)})}var ts=b("ZodEnum",(e,n)=>{Ku.init(e,n),se.init(e,n),e._zod.processJSONSchema=(r,o,i)=>Vi(e,r,o,i),e.enum=n.entries,e.options=[...e._zod.values];let t=new Set(Object.keys(n.entries));e.extract=(r,o)=>{let i={};for(let s of r)if(t.has(s))i[s]=n.entries[s];else throw Error(`Key ${s} not found in enum`);return new ts({...n,checks:[],..._(o),entries:i})},e.exclude=(r,o)=>{let i={...n.entries};for(let s of r)if(t.has(s))delete i[s];else throw Error(`Key ${s} not found in enum`);return new ts({...n,checks:[],..._(o),entries:i})}});function ce(e,n){let t=Array.isArray(e)?Object.fromEntries(e.map((r)=>[r,r])):e;return new ts({type:"enum",entries:t,..._(n)})}var sy=b("ZodLiteral",(e,n)=>{Wu.init(e,n),se.init(e,n),e._zod.processJSONSchema=(t,r,o)=>Mi(e,t,r,o),e.values=new Set(n.values),Object.defineProperty(e,"value",{get(){if(n.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return n.values[0]}})});function x(e,n){return new sy({type:"literal",values:Array.isArray(e)?e:[e],..._(n)})}var ay=b("ZodTransform",(e,n)=>{Gr(),Gu.init(e,n),se.init(e,n),e._zod.processJSONSchema=(t,r,o)=>Fi(e,t,r,o),e._zod.parse=(t,r)=>{if(r.direction==="backward")throw new xt(e.constructor.name);t.addIssue=(i)=>{if(typeof i==="string")t.issues.push(Rn(i,t.value,n));else{let s=i;if(s.fatal)s.continue=!1;if(s.code??(s.code="custom"),!("input"in s))s.input=t.value;s.inst??(s.inst=e),t.issues.push(Rn(s))}};let o=n.transform(t.value,t);if(o instanceof Promise)return o.then((i)=>(t.value=i,t));return t.value=o,t}});function Hd(e){return new ay({type:"transform",transform:e})}var Qd=b("ZodOptional",(e,n)=>{fi.init(e,n),se.init(e,n),e._zod.processJSONSchema=(t,r,o)=>Ur(e,t,r,o),e.unwrap=()=>e._zod.def.innerType});function Ld(e){return new Qd({type:"optional",innerType:e})}var Yd=b("ZodExactOptional",(e,n)=>{Hu.init(e,n),se.init(e,n),e._zod.processJSONSchema=(t,r,o)=>Ur(e,t,r,o),e.unwrap=()=>e._zod.def.innerType});function cy(e){return new Yd({type:"optional",innerType:e})}var uy=b("ZodNullable",(e,n)=>{Qu.init(e,n),se.init(e,n),e._zod.processJSONSchema=(t,r,o)=>Ki(e,t,r,o),e.unwrap=()=>e._zod.def.innerType});function qd(e){return new uy({type:"nullable",innerType:e})}var ly=b("ZodDefault",(e,n)=>{Yu.init(e,n),se.init(e,n),e._zod.processJSONSchema=(t,r,o)=>Hi(e,t,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function dy(e,n){return new ly({type:"default",innerType:e,get defaultValue(){return typeof n==="function"?n():Bo(n)}})}var py=b("ZodPrefault",(e,n)=>{Xu.init(e,n),se.init(e,n),e._zod.processJSONSchema=(t,r,o)=>Qi(e,t,r,o),e.unwrap=()=>e._zod.def.innerType});function fy(e,n){return new py({type:"prefault",innerType:e,get defaultValue(){return typeof n==="function"?n():Bo(n)}})}var Xd=b("ZodNonOptional",(e,n)=>{el.init(e,n),se.init(e,n),e._zod.processJSONSchema=(t,r,o)=>Wi(e,t,r,o),e.unwrap=()=>e._zod.def.innerType});function my(e,n){return new Xd({type:"nonoptional",innerType:e,..._(n)})}var gy=b("ZodCatch",(e,n)=>{nl.init(e,n),se.init(e,n),e._zod.processJSONSchema=(t,r,o)=>Yi(e,t,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function hy(e,n){return new gy({type:"catch",innerType:e,catchValue:typeof n==="function"?n:Ba(n)})}var ep=b("ZodPipe",(e,n)=>{mi.init(e,n),se.init(e,n),e._zod.processJSONSchema=(t,r,o)=>Xi(e,t,r,o),e.in=n.in,e.out=n.out});function Ud(e,n){return new ep({type:"pipe",in:e,out:n})}var yy=b("ZodPreprocess",(e,n)=>{ep.init(e,n),tl.init(e,n)}),by=b("ZodReadonly",(e,n)=>{rl.init(e,n),se.init(e,n),e._zod.processJSONSchema=(t,r,o)=>es(e,t,r,o),e.unwrap=()=>e._zod.def.innerType});function wy(e){return new by({type:"readonly",innerType:e})}var xy=b("ZodLazy",(e,n)=>{ol.init(e,n),se.init(e,n),e._zod.processJSONSchema=(t,r,o)=>ns(e,t,r,o),e.unwrap=()=>e._zod.def.getter()});function vy(e){return new xy({type:"lazy",getter:e})}var ky=b("ZodCustom",(e,n)=>{il.init(e,n),se.init(e,n),e._zod.processJSONSchema=(t,r,o)=>Zi(e,t,r,o)});function Sy(e,n={}){return Wl(ky,e,n)}function Iy(e,n){return Gl(e,n)}function _e(e){let n=vy(()=>X([R(e),ue(),le(),Xh(),j(n),ee(R(),n)]));return n}function Cy(e,n){return new yy({type:"pipe",in:Hd(e),out:n})}function rs(e){for(let n of Object.values(e.graph.nodes)){if(n.kind!="task"||!("executor"in n.task)||n.task.executor.kind!="openapi")continue;for(let[t,r]of Object.entries(n.inputs))if(t.startsWith("auth.")&&r.kind=="value")throw TypeError("OpenAPI authentication accepts deployment variables and upstream outputs only.")}}var os={choice:255,score:10};function np(e){if(e.type==="noul"||e.criteria.length<=os[e.type])return e;if(e.type==="choice")return{...e,criteria:e.criteria.slice(0,os.choice)};return{...e,criteria:e.criteria.slice(0,os.score)}}function Ey(e){let n=e.map(np);return n.every((t,r)=>t===e[r])?e:n}function tp(e){if(e.executor.kind!=="decision")return e;let n=e.executor.questions,t=Ey(n);if(t===n)return e;let r=e.outputs.map((o)=>{if(!("handle"in o))return o;let i=n.findIndex((s)=>s.name===o.handle);if(i<0||n[i]===t[i]||!ve(o.jsonSchema,rp(n[i])))return o;return{...o,jsonSchema:Oy(t[i])}});return{...e,executor:{...e.executor,questions:t},outputs:r}}var is={type:"number",minimum:0,maximum:1};function Oy(e){return rp(np(e))}function rp(e){let n={type:{const:e.type}};if(e.type==="noul")n.noul=is;else{let t=e.type==="choice"?e.criteria.map((r)=>r.name):e.criteria.map((r,o)=>String(o));if(n.confidence=is,n.probabilities={type:"object",properties:Object.fromEntries(t.map((r)=>[r,is])),required:t,additionalProperties:!1},e.type==="choice")n.choice={type:"string",...t.length?{enum:t}:{}};else n.score={type:"number",minimum:0,maximum:Math.max(0,t.length-1)},n.legend={type:"object",properties:Object.fromEntries(t.map((r)=>[r,{type:"string"}])),required:t,additionalProperties:!1}}return{type:"object",properties:n,required:Object.keys(n)}}function Pn(e,n=0){if(n>64)throw TypeError("Value exceeds the maximum JSON depth.");if(e!=null&&typeof e=="object")for(let t of Object.values(e))Pn(t,n+1)}var yn=j(X([I({type:x("cron"),expression:R(),timezone:R()}),I({type:x("every"),unit:ce(["day","hour","minute","month","week"]),value:ue()})]));var ss=["GET","POST","PUT","PATCH","DELETE"];function Hr(e){return e!=="GET"}var to=8,k=R(),Qr=k.describe('Account selection: omit while unconfigured; use an account ID to select it; use "" to explicitly defer configuration. Deferred Actions fail if called; deferred Agent tools are excluded from the callable tool set. Not supported by Triggers.'),_n=_e(),zt=j(k),Yn=I({description:k.optional(),jsonSchema:_n,nullable:le(),handle:k}),Ry=j(Yn.strict()),Le=Yn.extend({value:_n.optional()}),op=I({collapsed:le().optional(),group:k}),Ay=I({kind:x("node"),nodeId:k,output:k,field:k.optional()}),ap=X([Ay,I({kind:x("binding"),bindingId:k})]),Dt=X([I({kind:x("unset")}),I({kind:x("value"),value:_n})]),as=X([Dt,I({kind:x("sources"),sources:j(ap)})]),cp=ee(k,as),Qn={inputs:j(X([Le,op])),outputs:j(X([Yn,op]))},jy=v({kind:x("connector"),action:k,connectionId:k.optional(),connections:j(v({connectionId:k,alias:k.optional()}))}),Xr=X([jy,v({kind:x("connector"),mode:x("shared")}),v({kind:x("connector"),mode:x("independent"),actions:j(v({action:k,connectionId:Qr.optional()}))}),v({kind:x("connector"),actionHints:j(k).optional(),connectionHints:j(v({action:k,connectionId:k,alias:k.optional()})).optional()})]),cs=I({...Qn,name:k,moduleId:k,capabilities:j(Xr).optional()}),up=X([I({kind:x("value"),value:_n}),I({kind:x("input"),input:k})]),Py=X([up,I({kind:x("model")})]),$y=jn("type",[v({name:k,instructions:k,type:x("noul"),criteria:v({true:k.optional(),false:k.optional()}).optional()}),v({name:k,instructions:k,type:x("choice"),criteria:j(v({name:k,description:k}))}),v({name:k,instructions:k,type:x("score"),criteria:zt})]),Hn=I({...Qn,name:k,executor:X([I({kind:x("connector"),action:k,connectionId:Qr.optional(),outputMode:x("value").optional()}),I({kind:x("openapi"),sourceUrl:k,method:k,path:k,serverUrl:k,document:_n,auth:j(I({id:k,type:ce(["bearer","basic","apiKey"]),name:k.optional(),in:ce(["header","query"]).optional()}))}),v({kind:x("decision"),questions:j($y)}),I({kind:x("llm"),mode:ce(["chat","json"])}),I({kind:x("agent"),code:le().optional(),model:k,prompt:k,maxRounds:ue(),tools:j(I({id:k,name:k,description:k,action:k,connectionId:Qr.optional(),approval:le(),inputs:j(Le.extend({source:Py}))})),notification:I({action:k,connectionId:Qr.optional(),inputDefinitions:j(Le),messageHandle:k,inputs:ee(k,up)}).optional()}),v({kind:x("workflow"),flowId:k,revisionId:k})])}),us=Hn.transform(tp),ip=X([I({kind:x("value"),value:_n.optional(),jsonSchema:_n.optional()}),I({kind:x("source"),source:ap})]),eo={matchMode:ce(["first","all"]),cases:j(I({description:k.optional(),output:k,groups:j(I({expressions:j(I({left:ip,operator:ce(["!=","<","<=","==",">",">=","contains","endsWith","hasKey","hasValue","isEmpty","isFalse","isNotEmpty","isNotNull","isNull","isTrue","notContains","notHasKey","notHasValue","startsWith"]),right:ip.optional()}))}))}))},Vt={inputDefinitions:j(Le),prompt:k},_y=I({allowedMethods:hn().optional(),allowedOrigins:zt.optional(),noResponseBody:hn().optional(),responseData:k.optional(),responseHeaders:ee(k,k).optional(),responseStatusCode:ue().int().min(200).max(599).optional()}),no={bodyFields:j(Le),method:ce(ss),options:_y.optional()},sp={configInputs:Qn.inputs,definitionVersion:x(2),description:k,displayName:k,key:k,name:k,outputs:j(Yn).refine((e)=>new Set(e.map((n)=>n.handle)).size===e.length,"Duplicate Trigger output handle."),provider:k},Ty=I({body:I({allowArray:le(),allowEmpty:le(),formats:j(ce(["form","json","multipart","text"]))}),methods:j(ce(["DELETE","GET","HEAD","PATCH","POST","PUT"])),successStatus:ue()}),ls=j(k.min(1)).refine((e)=>new Set(e).size===e.length,"Duplicate source Flow ID."),$n={name:k,description:k.optional(),icon:k.optional()},Gn={maxExecutions:ue().int().positive().max(Number.MAX_SAFE_INTEGER).optional(),inputs:cp,name:k.optional(),description:k.optional(),icon:k.optional(),timeoutMs:ue().optional()},Yr=X([v({...Gn,kind:x("outputs"),outputDefs:j(Yn.strict()),outputMappings:cp}).omit({inputs:!0}),I({...Gn,inputs:ee(k,hn()),kind:x("condition"),...eo}),I({...Gn,inputs:Wn().transform(()=>({})).default({}),kind:x("value"),values:j(Le)}),I({...Gn,kind:x("task"),task:X([cs,us]),additionalInputs:j(Le).optional()}),v({...Gn,kind:x("approval"),...Vt}).omit({timeoutMs:!0}),v({...Gn,kind:x("wait"),...Vt}).omit({timeoutMs:!0}),I({...$n,kind:x("manual")}),v({...$n,kind:x("start"),inputDefs:Ry}),v({...$n,kind:x("error"),sourceFlowIds:ls.optional()}),I({...$n,kind:x("webhook"),...no}),I({...$n,kind:x("cron"),cronTimes:yn}),I({...$n,kind:x("poll"),connectionId:k.min(1).optional(),config:ee(k,Dt),definition:I({...sp,type:x("poll")}),pollTimes:yn}),I({...$n,kind:x("integration"),connectionId:k.min(1).optional(),config:ee(k,Dt),definition:I({...sp,type:x("integration"),endpoint:Ty})})]),qe={input:Le,port:Yn,ports:Qn,condition:v(eo),wait:v(Vt),webhook:v(no),schedule:yn,capabilities:j(Xr),connector:Hn.shape.executor.options[0].omit({kind:!0}).strict(),openapi:Hn.shape.executor.options[1].omit({kind:!0}).strict(),decision:Hn.shape.executor.options[2].omit({kind:!0}).strict(),llm:Hn.shape.executor.options[3].omit({kind:!0}).strict(),agent:Hn.shape.executor.options[4].omit({kind:!0,notification:!0}).strict()},ds=I({source:k,target:k,sourceHandle:k.optional()}),Ie={nodeId:k,target:hn().optional()},Ny=I({nodes:ee(k,Yr),edges:j(ds).default([])}),lp=I({kind:x("variable"),target:k}),dp=I({name:k,imports:zt,source:k}),zy=Cy(Dy,I({bindings:ee(k,lp),graph:Ny})),pp=I({modelVersion:X([x(2),x(4),x(5),x(6),x(7),x(to)]),document:zy,modules:ee(k,dp)}),SS=pp.extend({kind:x("open-flow-flow-revision"),version:x(1)});function Dy(e){let n=Ge(e);if(n.tasks!==void 0&&(n.tasks===null||typeof n.tasks!=="object"||Array.isArray(n.tasks)||Object.keys(n.tasks).length>0))throw TypeError("Independent Task definitions are no longer supported.");if(Object.values(Ge(Ge(n.graph).nodes)).some((r)=>Object.hasOwn(Ge(r),"taskId")))throw TypeError("Task references are no longer supported.");let t=n.subflows;if(t!==void 0&&(t===null||typeof t!=="object"||Array.isArray(t)||Object.keys(t).length>0))throw TypeError("Subflows are no longer supported.");if(Object.values(Ge(Ge(n.graph).nodes)).some((r)=>Ge(r).kind==="subflow"))throw TypeError("Subflow nodes are no longer supported.");if(["inputDefs","outputDefs","outputMappings"].some((r)=>Object.hasOwn(n,r)))throw TypeError("Workflow interface configuration must belong to Start and Outputs nodes.");if(Object.values(Ge(Ge(n.graph).nodes)).some((r)=>Ge(r).kind=="start"&&Object.hasOwn(Ge(r),"parameters")))throw TypeError("Legacy Start.parameters is unsupported; configure node.inputDefs.");return e}function Ge(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)?e:{}}function Xn(e){Pn(e);let n=pp.parse(e);return My(n),rs(n.document),n}var Vy={"graph.trigger.sources.set":{nodeId:k,before:ls.optional(),value:ls.optional()},"binding.create":{bindingId:k,binding:lp},"binding.delete":{bindingId:k},"binding.target.set":{bindingId:k,before:k,value:k},"graph.edge.connect":{edge:ds,target:hn().optional()},"graph.edge.disconnect":{edge:ds,target:hn().optional()},"graph.node.create":{...Ie,node:Yr},"graph.node.replace":{...Ie,before:Yr,node:Yr},"graph.node.delete":Ie,"graph.node.field.set":X([I({...Ie,kind:x("graph.node.field.set"),field:x("connectionId"),before:k.min(1).optional(),value:k.min(1).optional()}),I({...Ie,kind:x("graph.node.field.set"),field:ce(["description","icon","name"]),before:k.optional(),value:k.optional()}),I({...Ie,kind:x("graph.node.field.set"),field:x("maxExecutions"),before:ue().int().positive().max(Number.MAX_SAFE_INTEGER).optional(),value:ue().int().positive().max(Number.MAX_SAFE_INTEGER).optional()}),I({...Ie,kind:x("graph.node.field.set"),field:x("timeoutMs"),before:ue().optional(),value:ue().optional()})]),"graph.node.input.set":{...Ie,handle:k,before:as.optional(),value:as.optional()},"graph.node.additional-inputs.set":{...Ie,before:j(Le).optional(),value:j(Le).optional()},"graph.node.condition.set":{...Ie,before:I(eo),value:I(eo)},"graph.node.values.set":{...Ie,before:j(Le),value:j(Le)},"graph.node.resolution.set":{...Ie,before:I(Vt),value:I(Vt)},"graph.node.webhook.set":{...Ie,before:I(no),value:I(no)},"graph.node.task.ports.set":{...Ie,before:I(Qn),value:I(Qn)},"graph.node.task.name.set":{...Ie,before:k,value:k},"graph.node.task.capabilities.set":{...Ie,before:j(Xr).optional(),value:j(Xr).optional()},"graph.trigger.config.set":{nodeId:k,name:k,before:Dt.optional(),value:Dt.optional()},"graph.trigger.schedule.set":{nodeId:k,before:yn,value:yn},"module.create":{moduleId:k,module:dp},"module.delete":{moduleId:k},"module.rename":{moduleId:k,before:k,name:k},"module.source.replace":{moduleId:k,beforeImports:zt,beforeSource:k,imports:zt,source:k},"graph.node.task.set":{...Ie,before:X([cs,us]),value:X([cs,us])}},fp=new Map(Object.entries(Vy).map(([e,n])=>[e,n instanceof se?n:I({kind:x(e),...n})])),IS=j(X([...fp.values()])).min(1);function Mt(e,n,t){try{return t(e)}catch(r){if(!(r instanceof Ih))throw r;throw TypeError(`operations[${n}]: ${r.issues.map((o)=>`${o.path.join(".")}: ${o.message}`).join("; ")}`,{cause:r})}}function mp(e,n){let{kind:t}=Mt(e,n,I({kind:k}).parse),r=fp.get(t);if(r==null)throw TypeError(`operations[${n}]: Unknown operation ${JSON.stringify(t)}.`);return Mt(e,n,r.parse)}function My(e){if(e.modelVersion<8&&Object.values(e.document.graph.nodes).some((n)=>n.kind=="outputs"))throw TypeError("Workflow outputs require Flow model version 8.");if(e.modelVersion<7&&Object.values(e.document.graph.nodes).some((n)=>n.kind=="start"))throw TypeError("Start Triggers require Flow model version 7.");if(e.modelVersion<6&&Object.values(e.document.graph.nodes).some((n)=>n.kind=="task"&&("executor"in n.task)))throw TypeError("Node-owned managed Tasks require Flow model version 6.");if(e.modelVersion<5&&Object.values(e.document.graph.nodes).some((n)=>n.kind=="error"))throw TypeError("Error workflows require Flow model version 5.")}function gp(e){return e.kind=="source"&&e.source.kind=="binding"?{kind:"value"}:e}function hp(e){return{...e,cases:e.cases.map((n)=>({...n,groups:n.groups.map((t)=>({...t,expressions:t.expressions.map((r)=>({...r,left:gp(r.left),...r.right==null?{}:{right:gp(r.right)}}))}))}))}}var Uy=new Set(["const","enum","exclusiveMaximum","exclusiveMinimum","maximum","maxItems","maxLength","maxProperties","minimum","minItems","minLength","minProperties","multipleOf","pattern","required","type"]);function fs(e){return Uy.has(e)}var ms=80;function ro(e){let n=e.trim();if(n.length==0)return"empty";if(n.length>ms)return"tooLong";for(let t of n){let r=t.charCodeAt(0);if(r<=31||r>=127&&r<=159)return"controlCharacter"}if(!/^[\p{L}\p{N}](?:[\p{L}\p{N} _-]*[\p{L}\p{N}])?$/u.test(n))return"specialCharacter"}var yp=0;function bn(){let e=yp;return yp+=1,e}function nt(e){if(typeof e==="object"&&e!==null&&!Object.isFrozen(e)){for(let n of Object.getOwnPropertyNames(e)){let t=Reflect.get(e,n);nt(t)}Object.freeze(e)}return e}function gs(e,n){let t={};for(let r of n)if(r in e)t[r]=e[r];return t}function oo(e){if(typeof e!=="object"||e===null)return e;else if(Array.isArray(e)){let n=[];for(let[t,r]of e.entries())n[t]=oo(r);return n}else{let n={};for(let t in e)n[t]=oo(e[t]);return n}}function et(e,n){if(e===n)return!0;if(e===null)return!1;if(typeof e!=="object")return!1;if(typeof e!==typeof n)return!1;if(Array.isArray(e)){if(!Array.isArray(n))return!1;if(e.length!==n.length)return!1;for(let[t,r]of e.entries())if(!et(r,n[t]))return!1}else{if(Array.isArray(n))return!1;for(let t in e){if(!(t in n))return!1;if(!et(e[t],n[t]))return!1}for(let t in n)if(!(t in e))return!1}return!0}var y=Object.freeze({Equals:0,Containing:1,ContainedBy:2,Rejection:3,Intersection:4}),J=wn(y.Equals),D=wn(y.Containing),Z=wn(y.ContainedBy),q=wn(y.Rejection),W=wn(y.Intersection),sn=nt([[y.Equals,J],[y.Containing,D],[y.ContainedBy,Z],[y.Rejection,q],[y.Intersection,W]]),re=0,Je=(()=>{let e=re;for(let[n,t]of sn)e|=t;return e})();function Zt(e){return!!(e&J)}function Ft(e){return!!(e&D)}function Jt(e){return!!(e&Z)}function Lt(e){return!!(e&q)}function qt(e){return!!(e&W)}function wn(e){return 1<<e}function hs(e){let n=re,t=0,r={push:(o)=>{if(t===0)n=o;else n=By(n,o,e);return t+=1,n}};return Object.defineProperties(r,{result:{get:()=>n},count:{get:()=>t}}),r}function By(e,n,t){let r=re;for(let[o,i]of sn)if(i&e){for(let[s,a]of sn)if(a&n){if(r|=t(o,s),r===Je)return r}}return r}var de=Object.freeze({Save:0,OneOf:1,AllOf:2,AnyOf:3,Not:4,Swap:5});function bp(e,n){switch(e){case de.Save:return n[0];case de.OneOf:return Ky(n);case de.AllOf:case de.AnyOf:return Ut(e,n);case de.Not:case de.Swap:return ys(e,n[0])}}function xn(e){return ys(de.Swap,e)}function Ky(e){if(e.length===1)return e[0];let n=Ut(de.AnyOf,e),t=[];for(let i=0;i<e.length;++i)for(let s=i+1;s<e.length;++s){let a=e[i],c=e[s],u=Ut(de.AllOf,[a,c]);t.push(u)}let r=Ut(de.AnyOf,t),o=ys(de.Not,r);return Ut(de.AllOf,[n,o])}function Ut(e,n){if(n.length<0)throw Error("invalid expressions: empty array");let t;switch(e){case de.AllOf:{t=hs(Wy);break}case de.AnyOf:{t=hs(Gy);break}default:throw Error(`invalid operator ${e}`)}for(let r of n)t.push(r);return t.result}function ys(e,n){let t,r=re;switch(e){case de.Not:{t=Hy;break}case de.Swap:{t=Qy;break}default:throw Error(`invalid operator ${e}`)}for(let[o,i]of sn)if(i&n)r|=t(o);return r}function Wy(e,n){let t=re;switch(e){case y.Equals:{switch(n){case y.Equals:{t=J;break}case y.Containing:{t=J;break}case y.ContainedBy:{t=Z;break}case y.Rejection:{t=re;break}case y.Intersection:{t=Z;break}}break}case y.Containing:{switch(n){case y.Equals:{t=J;break}case y.Containing:{t=J|D;break}case y.ContainedBy:{t=Z;break}case y.Rejection:{t=q;break}case y.Intersection:{t=W|Z;break}}break}case y.ContainedBy:{switch(n){case y.Equals:{t=Z;break}case y.Containing:{t=Z;break}case y.ContainedBy:{t=Z;break}case y.Rejection:{t=re;break}case y.Intersection:{t=Z;break}}break}case y.Rejection:{switch(n){case y.Equals:{t=re;break}case y.Containing:{t=q;break}case y.ContainedBy:{t=re;break}case y.Rejection:{t=q;break}case y.Intersection:{t=q;break}}break}case y.Intersection:{switch(n){case y.Equals:{t=Z;break}case y.Containing:{t=W|Z;break}case y.ContainedBy:{t=Z;break}case y.Rejection:{t=q;break}case y.Intersection:{t=Z|q|W;break}}break}}return t}function Gy(e,n){let t=re;switch(e){case y.Equals:{switch(n){case y.Equals:{t=J;break}case y.Containing:{t=D;break}case y.ContainedBy:{t=J;break}case y.Rejection:{t=D;break}case y.Intersection:{t=D;break}}break}case y.Containing:{switch(n){case y.Equals:{t=D;break}case y.Containing:{t=D;break}case y.ContainedBy:{t=D;break}case y.Rejection:{t=D;break}case y.Intersection:{t=D;break}}break}case y.ContainedBy:{switch(n){case y.Equals:{t=J;break}case y.Containing:{t=D;break}case y.ContainedBy:{t=J|Z;break}case y.Rejection:{t=W;break}case y.Intersection:{t=D|W;break}}break}case y.Rejection:{switch(n){case y.Equals:{t=D;break}case y.Containing:{t=D;break}case y.ContainedBy:{t=W;break}case y.Rejection:{t=q;break}case y.Intersection:{t=W;break}}break}case y.Intersection:{switch(n){case y.Equals:{t=D;break}case y.Containing:{t=D;break}case y.ContainedBy:{t=D|W;break}case y.Rejection:{t=W;break}case y.Intersection:{t=D|W;break}}break}}return t}function Hy(e){let n=re;switch(e){case y.Equals:{n=q;break}case y.Containing:{n=q;break}case y.ContainedBy:{n=W;break}case y.Rejection:{n=J|D;break}case y.Intersection:{n=Z|W;break}}return n}function Qy(e){let n=re;switch(e){case y.Equals:{n=J;break}case y.Containing:{n=Z;break}case y.ContainedBy:{n=D;break}case y.Rejection:{n=q;break}case y.Intersection:{n=W;break}}return n}var Te=Object.freeze({Leaf:0,Not:1,AllOf:2,AnyOf:3,OneOf:4});var bs=(e)=>(n,t)=>{let r={parent:null,swapped:!1,expressions:null,calculation:{operator:de.Save,results:[re],willSwap:!1,count:0}},o=[{parent:{node:r,index:0},swapped:!1,expressions:[n,t],calculation:null}],i=[];while(o.length>0||i.length>0){while(o.length>0){let l=o.pop();s(l)}while(i.length>0){let l=i.pop();c(l)}}function s(l){let f=J,[m,h]=l.expressions;if(!e.equals(m,h)){let g=e.describe(m);if(g.kind!==Te.Leaf){let[T,L]=a(g,!1);l.expressions=null,l.calculation=T;for(let[M,De]of L.entries())o.push({parent:{node:l,index:M},swapped:l.swapped,expressions:[De,h],calculation:null});return}let E=e.describe(h);if(E.kind!==Te.Leaf){let[T,L]=a(E,!0);l.expressions=null,l.calculation=T;for(let[M,De]of L.entries())o.push({parent:{node:l,index:M},swapped:!l.swapped,expressions:[De,m],calculation:null});return}if(f=e.calculate(m,h),e.observeCalculation?.(m,h,f,l.swapped),f===re)throw Error("cannot response expression as none")}l.expressions=null,l.calculation={operator:de.Save,results:[f],willSwap:!1,count:0},i.push(l)}function a(l,f){let m=de.Save,h;switch(l.kind){case Te.Not:{m=de.Not,h=[l.expression];break}case Te.AllOf:{m=de.AllOf,h=[...l.expressions];break}case Te.AnyOf:{m=de.AnyOf,h=[...l.expressions];break}case Te.OneOf:{m=de.OneOf,h=[...l.expressions];break}default:throw Error(`invalid kind ${l.kind}`)}return[{operator:m,willSwap:f,count:0,results:Array(h.length).fill(-1)},h]}function c(l){let{calculation:f,parent:m}=l,h=bp(f.operator,f.results);if(h===re)h=Z;if(f.willSwap)h=xn(h);if(m){let g=m.node.calculation,E=g.results;if(E[m.index]=h,g.count+=1,g.count>=E.length)i.push(m.node)}}let u=r.calculation.results[0];if(u===0)throw Error("cannot find result of root");return u};class io extends Error{constructor(e=[]){super(Yy(e));this.name="SchemaError",this.items=e}}var tt=Object.freeze({Compiled:0,External:1});function rt(e){switch(e.kind){case tt.Compiled:{let{message:n,path:t}=e;return`${n} (at ${t.length>0?t.join("."):"$root"})`}case tt.External:return String(e.error)}}function Yy(e){switch(e.length){case 0:return"without any items";case 1:return rt(e[0]);default:return`${rt(e[0])} ... omit the rest ${e.length-1} items`}}var Xy=new Set(["type","enum","const","multipleOf","maximum","exclusiveMaximum","minimum","exclusiveMinimum","maxLength","minLength","pattern","items","additionalItems","maxItems","minItems","uniqueItems","contains","maxProperties","minProperties","required","properties","patternProperties","additionalProperties","dependencies","propertyNames","if","then","else","allOf","anyOf","oneOf","not","format","contentMediaType","contentEncoding","definitions"]);function nn(e){return Xy.has(e)}function wp(e){for(let n in e)if(nn(n))return!1;return!0}function Re(e,...n){return{...e,path:[...e.path,...n]}}function Ne(e){if(typeof e==="boolean")throw Error("JSONSchema7Definition cannot be boolean");return e}function vn({path:e,errors:n},t,...r){n.push(xp(e,r,t))}function G({path:e,warns:n},t,...r){n.push(xp(e,r,t))}function xp(e,n,t){return{kind:tt.Compiled,message:t,path:[...e,...n]}}function so(e){for(let n in e){let t=e[n];if(t===void 0)delete e[n];else if(t&&typeof t==="object"){if(Array.isArray(t)){if(t.length===0)delete e[n]}else if(eb(t))delete e[n]}}return e}function eb(e){for(let n in e)return!1;return!0}var Bt=Symbol("compiledId"),ws=Symbol("compiledKind"),xs=Symbol("compiledPath"),vp=Symbol("validatorLoader"),S=Object.freeze({Extends:0,Never:1,Any:2,Null:3,String:4,Numeric:5,Boolean:6,Object:7,Array:8,Not:9,Combination:10,EnumOrConst:11}),kn=nt(ao(S.Any,bn(),{},()=>()=>!0)),Kt=nt(ao(S.Never,bn(),{type:"string",maxLength:0,minLength:1},()=>()=>!1));function Wt(e){if(e===null||typeof e!=="object")return!1;return Bt in e}function ze(e){if(e===null||typeof e!=="object")return!1;return Bt in e&&ws in e}function K(e){if(ze(e))return e[ws];else return S.Extends}function Tn(e){if(ze(e)||Wt(e))return e[Bt];else return e.id}function vs(e){return ze(e)?e[xs]:void 0}function ks(e){if(e===null||typeof e!=="object")return e;return Object.defineProperty(e,Bt,{value:bn(),configurable:!1,writable:!1,enumerable:!1}),e}function me(e,n,t,r=[]){return ao(e,bn(),n,t&&(()=>t.compile(n)),r)}function Gt(e){return ao(S.Never,bn(),{...e},e[vp],e[xs])}function ao(e,n,t,r,o=[]){let i=null;return Object.defineProperties(t,{[ws]:{value:e,configurable:!1,writable:!1,enumerable:!1},[Bt]:{value:n,configurable:!1,writable:!1,enumerable:!1},[xs]:{value:o,configurable:!1,writable:!1,enumerable:!1},[vp]:{value:r,configurable:!1,writable:!1,enumerable:!1},isValid:{configurable:!1,enumerable:!1,get:()=>{if(r){if(!i)i=r();return i}else return}}}),t}function Ip(e,n){let t=nb(e,n),r=kp(e,"maxItems",n),o=kp(e,"minItems",n),i=tb(e,n),s=n.uniqueItems,a;if(Array.isArray(t))a=rb(e,n);else if(n.additionalItems)G(e,"it is needless when items is not array","additionalItems");if(!t||!i||a===null)return null;let c=!1,u=!1;if(Array.isArray(t)){if(r!==void 0&&r<=t.length)t=t.splice(r),a=Sp(a,e.delegate);let m=t.findIndex((h)=>K(h)===S.Never);if(m!==-1){if(t=t.splice(m),a=Sp(a,e.delegate),r===void 0)r=t.length,u=!0}if(o!==void 0&&t.length<o)G(e,`length(${t.length}) of items if less than minItems(${o})`),c=!0;if(t.length===0&&a&&K(a)===S.Never)c=!0}else if(K(t)===S.Never)c=!0;if(r!==void 0&&o!==void 0&&r<o){if(!u)G(e,`maxItems(${r}) is less than minItems(${o})`);c=!0}let l=c?S.Never:S.Array,f=so({type:"array",items:t,contains:i,uniqueItems:s,maxItems:r,minItems:o,additionalItems:a});return me(l,f,e.delegate,e.path)}function nb(e,{items:n}){if(!n)return me(S.Any,{},e.delegate,e.path);if(Array.isArray(n)){let t=[],r=!1;for(let[o,i]of n.entries()){let s=Re(e,"items",o),a=Ae(s,Ne(i));if(!a){r=!0;continue}t.push(a)}if(r)return null;return t}else{let t=Re(e,"items"),r=Ne(n);return Ae(t,r)}}function kp(e,n,t){let r=t[n];if(r===void 0)return;if(Number.isNaN(r)){G(e,"find NaN",n);return}if(r<0){G(e,`find invalid number ${r}`,n);return}return r}function tb(e,{contains:n}){if(!n)return me(S.Any,{},e.delegate,e.path);let t=Re(e,"contains"),r=Ne(n);return Ae(t,r)}function rb(e,{additionalItems:n}){switch(typeof n){case"boolean":if(n)return me(S.Any,{},e.delegate,e.path);else return!1;case"object":{let t=Re(e,"additionalItems");return Ae(t,n)}default:return me(S.Any,{},e.delegate,e.path)}}function Sp(e,n){if(e===void 0)return me(S.Never,{type:"string",maxLength:0,minLength:1},n);else if(ze(e))return K(e)===S.Never?e:Gt(e);else return e}var Cp=Object.freeze(["allOf","anyOf","oneOf"]);function Ss(e,n,t,r){if(t.length===0)return vn(e,"disable empty list",n),null;let o=[];for(let[c,u]of t.entries()){let l=Re(e,n,c),f=Ne(u),m=Ae(l,f);if(m)o.push(m)}if(o.length<t.length)return null;let i=0,s=0;for(let c of o)switch(K(c)){case S.Any:{i+=1;break}case S.Never:{s+=1;break}}let a=S.Combination;switch(n){case"allOf":{if(s>0)a=S.Never;else if(i===o.length)a=S.Any;else if(!ob(o))a=S.Never;break}case"anyOf":{if(i>0)a=S.Any;else if(s===o.length)a=S.Never;break}case"oneOf":{if(i>1)a=S.Never;else if(s===o.length)a=S.Never;else if(i===1&&s===o.length-1)a=S.Any;break}}return me(a,{[n]:o},r,e.path)}function ob(e){let n=null;for(let t of e){let r=K(t);switch(r){case S.Any:case S.Never:break;default:{if(n===null)n=r;else if(n!==r)return!1;break}}}return!0}var Ce=Object.freeze({Valid:0,Invalid:1,Unknown:2});function tn(e,n){let t=e.isValid;if(t)if(t(n)===!0)return Ce.Valid;else return Ce.Invalid;else return Ce.Unknown}function Ep(e,n,t,r){let o,i=!1;if(n){if(n.length===0)return vn(e,"disable empty list","enum"),null;o=[];for(let[c,u]of n.entries())switch(tn(r,u)){case Ce.Valid:{o.push(ks(u));break}case Ce.Invalid:{G(e,"cannot pass JSON schema of currently schema object","enum",c);break}}if(o.length===0)G(e,"all of elements from list is rejected by currently schema object","enum")}if(t!==void 0&&tn(r,t)===Ce.Invalid)i=!0;if(o){if(o.length===0)i=!0;else if(t!==void 0){let c=!1;for(let u of o)if(et(u,t)){c=!0;break}if(!c)i=!0}}let s=i?S.Never:S.EnumOrConst,a={};if(r.type)a.type=r.type;if(o)a.enum=o;if(t!==void 0)a.const=ks(oo(t));return me(s,a,e.delegate,e.path)}var ib=new Set(["type","maxProperties","minProperties","required","properties","patternProperties","additionalProperties","dependencies","propertyNames"]);function Rp(e,n){let t=Object.keys(n).filter((g)=>!ib.has(g)&&nn(g));if(t.length>0)G(e,`type="object" will exclude other keys: ${t.toSorted().join(", ")}`);let r=Op(e,"maxProperties",n),o=Op(e,"minProperties",n),i=sb(e,n),s=ab(e,n),a=cb(e,n),c=lb(e,n);if(!i||!s||!a||!c)return null;let u=ub(e,s,a,n);if(!u)return null;let l=db(i,s,a,u),f=pb(e,l,c,n),m=fb(e,i,u,f,r,o)?S.Never:S.Object,h=so({type:"object",required:f,properties:u,minProperties:o,maxProperties:r,additionalProperties:i,patternProperties:hb(s),dependencies:yb(c,n),propertyNames:a});return me(m,h,e.delegate,e.path)}function Op(e,n,t){let r=t[n];if(r===void 0)return;if(Number.isNaN(r)){G(e,"find NaN",n);return}if(r<0){G(e,`find invalid number ${r}`,n);return}return r}function sb(e,{additionalProperties:n}){if(n===!1)return me(S.Never,{type:"string",maxLength:0,minLength:1},e.delegate,e.path);if(typeof n!=="object")return me(S.Any,{},e.delegate,e.path);let t=Re(e,"additionalProperties"),r=Ne(n);return Ae(t,r)}function ab(e,{patternProperties:n}){let t=!1,r={};for(let o in n){let i=gb(o);if(i instanceof Error){G(e,`property name invalid. ${o}`,"patternProperties",o);continue}let s=Ne(n[o]),a=Re(e,"patternProperties",o),c=Ae(a,s);if(!c){t=!0;continue}r[o]=[c,i]}if(t)return null;return r}function cb(e,{propertyNames:n}){if(!n)return me(S.Any,{},e.delegate,e.path);n=Ne(n);let t=Re(e,"propertyNames"),r=Ae(t,n);if(!r)return null;let o=K(r);if(o!==S.String&&o!==S.Any)return Gt(r);return r}function ub(e,n,t,{properties:r}){let o=!1;if(!r)return{};let i={};for(let s in r){if(tn(t,s)===Ce.Invalid){G(e,`key ${JSON.stringify(s)} cannot pass JSON schema from propertyNames`,"properties");continue}let a=jp(n,s);if(a&&K(a)===S.Never){G(e,`key ${JSON.stringify(s)} matches a pattern that has a impossible(never) schema`,"properties");continue}let c=Ne(r[s]),u=Re(e,"properties",s),l=Ae(u,c);if(!l){o=!0;continue}i[s]=l}if(o)return null;return i}function lb(e,{dependencies:n}){if(!n)return[{},{}];let t={},r={};for(let o in n){let i=Ne(n[o]);if(Array.isArray(i)){let{keys:s,duplicated:a}=Ap(i);if(a)G(e,`found duplicated property names: ${a.join(", ")}`,"dependencies",o);t[o]=s}else{let s=Re(e,"dependencies",o),a=Ae(s,i);if(a){let c=K(a);if(c===S.Object||c===S.Any)r[o]=a;else if(c===S.Extends)r[o]=Kt;else r[o]=Gt(a)}}}return[t,r]}function db(e,n,t,r){return(o)=>{if(tn(t,o)===Ce.Invalid)return!0;let i=jp(n,o);if(i&&K(i)===S.Never)return!0;let s=r[o]??e;if(K(s)===S.Never)return!0;return!1}}function pb(e,n,t,{required:r}){if(!r)return[];let o=Ap(r);if(o.duplicated)G(e,`found duplicated required keys: ${o.duplicated.join(", ")}`,"required");let i=[],s=[];for(let a of o.keys)if(mb(t,a).some((u)=>n(u)))s.push(a);else i.push(a);if(s.length>0)G(e,`key ${s.map((a)=>JSON.stringify(a)).join(", ")} will ban by another condition`,"required");return i}function fb(e,n,t,r,o,i){if(o!==void 0&&i!==void 0&&o<i)return G(e,`maxProperties(${o}) is less than minProperties(${i})`),!0;if(o!==void 0&&r.length>o)return G(e,`length(${r.length}) of required is greater than maxProperties(${o})`),!0;if(i!==void 0&&r.length<i)return G(e,`length(${r.length}) of required is less than minProperties(${i})`),!0;if(K(n)!==S.Never)return!1;for(let s in t){let a=t[s];if(K(a)!==S.Never)return!1}return!0}function mb([e,n],t){let r=[t],o=new Set(r);while(r.length>0){let s=r.pop(),a=n[s],c=e[s];if(a){if(K(a)===S.Object)i(a.required)}if(c)i(c)}function i(s){if(s){for(let a of s)if(!o.has(a))o.add(a),r.push(a)}}return[...o]}function Ap(e){let n=new Set,t=new Set;for(let r of e)if(n.has(r))t.add(r);else n.add(r);if(t.size===0)return{keys:[...e],duplicated:null};else return{keys:[...n],duplicated:[...t]}}function jp(e,n){for(let t in e){let[r,o]=e[t];if(o.test(n))return r}return null}function gb(e){try{return new RegExp(e,"i")}catch(n){if(n instanceof SyntaxError)return n;else throw n}}function hb(e){let n={};for(let t in e)n[t]=e[t][0];return n}function yb([e,n],{dependencies:t}){let r={};for(let o in t){let i=e[o],s=n[o];r[o]=i||s}return r}var Is=new Set(["type","multipleOf","maximum","exclusiveMaximum","minimum","exclusiveMinimum"]),Pp=new Set(["type","format","maxLength","minLength","pattern"]);function _p(e,n){let{type:t}=n;switch(t){case"number":case"integer":return bb(e,n);case"string":return xb(e,n);case"boolean":case"null":{let r=Object.keys(n).filter((s)=>nn(s)&&s!=="type");if(r.length>0)G(e,`key "type" will exclude other keys: ${r.toSorted().join(", ")}`);let o=t==="null"?S.Null:S.Boolean;return me(o,{type:t},e.delegate,e.path)}default:return vn(e,`invalid type ${JSON.stringify(t)}`),null}}function bb(e,n){let t=Object.keys(n).filter((l)=>!Is.has(l)&&nn(l));if(t.length>0)G(e,`type=${JSON.stringify(n.type)} will exclude other keys: ${t.toSorted().join(", ")}`);let r=gs(n,Is);for(let l of Is){let f=r[l];if(l!=="type"&&f!==void 0&&Number.isNaN(f))G(e,"found NaN",l),delete r[l]}let{maximum:o,exclusiveMaximum:i,minimum:s,exclusiveMinimum:a}=r;if(o!==void 0&&i!==void 0){if(o===i)delete r.maximum;else if(o<i)delete r.exclusiveMaximum;else if(o>i)delete r.maximum}if(s!==void 0&&a!==void 0){if(s===a)delete r.minimum;else if(s<a)delete r.exclusiveMinimum;else if(s>a)delete r.minimum}let{multipleOf:c}=r;if(c===0)delete r.multipleOf,r.type="number",G(e,"cannot be 0","multipleOf");let u=S.Numeric;if(!wb(r))u=S.Never;return me(u,r,e.delegate,e.path)}function wb(e){let{maximum:n,exclusiveMaximum:t,minimum:r,exclusiveMinimum:o}=e;if(n!==void 0&&r!==void 0)return n>=r;else if(t!==void 0&&r!==void 0)return t>r;else if(n!==void 0&&o!==void 0)return n>o;else if(t!==void 0&&o!==void 0)return t>o;else return!0}function xb(e,n){let t=Object.keys(n).filter((a)=>!Pp.has(a)&&nn(a));if(t.length>0)G(e,`type="string" will exclude other keys: ${t.toSorted().join(", ")}`);let r=gs(n,Pp);$p(e,r,"maxLength"),$p(e,r,"minLength");let{maxLength:o,minLength:i}=r,s=S.String;if(o!==void 0){if(o<0)s=S.Never;else if(o!==void 0&&i!==void 0&&o<i)s=S.Never}return me(s,r,e.delegate,e.path)}function $p(e,n,t){let r=n[t];if(r!==void 0){if(Number.isNaN(r))G(e,"found NaN",t),delete n[t]}}var Tp=Object.freeze([]);function co(e,n,t,r){if(ze(e))return{schema:e,warns:Tp};if(n.isExtendsSchema(e))return{schema:e,warns:Tp};if(r){let s=r.isSchema(e);if(typeof s==="object"){let a=[];for(let c of s)a.push({kind:tt.External,error:c});if(a.length>0)return a}else if(s===!1)throw Error("it is not a JSON Schema 7")}let o={delegate:r,payload:t,extends:n,path:[],errors:[],warns:[]},i=Ae(o,e);if(i)Np(o.errors.length===0,"found errors (it should be empty)");else return Np(o.errors.length>0,"cannot found any errors"),o.errors;return{schema:i,warns:o.warns}}function Np(e,n){if(!e)throw Error(n)}function Ae(e,n){if(e.extends.isExtendsSchema(n))return n;if(ze(n))return n;let t=e.extends.tryCompiledExtendsSchema(n,e.payload);if(t)return t;let r=n,o=!1,{enum:i,const:s}=n;if(i||s!==void 0){let{enum:c,const:u,...l}=n;r=l,o=!0}let a=vb(e,r);if(a&&o)a=Ep(e,i,s,a);if(!a)return null;return a}function vb(e,n){for(let t of Cp){let r=n[t];if(r){let o=Object.keys(n).filter((s)=>nn(s)&&s!==t);if(o.length>0)G(e,`composition key ${JSON.stringify(t)} will exclude other keys: ${o.toSorted().join(", ")}`);let i=Ss(e,t,r);if(!i)return null;return i}}{let t=Ne(n.not);if(t){let r=Object.keys(n).filter((a)=>nn(a)&&a!=="not");if(r.length>0)G(e,`key "not" will exclude other keys: ${r.toSorted().join(", ")}`);let o=Re(e,"not"),i=Ae(o,t);if(!i)return null;let s=S.Not;switch(K(i)){case S.Never:{s=S.Any;break}case S.Any:{s=S.Never;break}}return me(s,{not:i},e.delegate,e.path)}}if(n.type){let{type:t}=n;if(Array.isArray(t)){let{type:r,...o}=n;return Ss(e,"anyOf",t.map((i)=>({...o,type:i})))}switch(t){case"object":return Rp(e,n);case"array":return Ip(e,n);default:return _p(e,n)}}if(wp(n))return me(S.Any,{},e.delegate,e.path);return vn(e,"unrecognized"),null}class Cs{constructor(e){let n=Object.freeze(e.toSorted());if(n.length>32)throw Error(`cannot define ${n.length} keys which is greater than 32`);this.keys=n,this.clazz=class extends zp{constructor(t){super(n,t)}};for(let[t,r]of this.keys.entries()){let o=1<<t;Object.defineProperty(this.clazz.prototype,r,{enumerable:!0,get:function(){return!!(this.int32&o)},set:function(s){if(s)this.int32|=o;else this.int32&=~o}})}}toBundle(e){let n=0;if(typeof e==="number")n=e;else if(e){for(let[t,r]of this.keys.entries())if(e[r])n|=1<<t}return new this.clazz(n)}}class zp{constructor(e,n){this.keys=e,this.int32=n}toInt32(){return this.int32}toString(){let e={};for(let n of this.keys)e[n]=this[n];return JSON.stringify(e)}}function uo(e){return new Dp(e)}class Dp{constructor(e){this.description=new Cs(e)}get keys(){return this.description.keys}variable(e){let n;if(e)n=this.description.toBundle(e).toInt32();return new Vp(this.description,n)}}class Vp{constructor(e,n){this.values=new Set;if(this.description=e,n!==void 0)this.values.add(n)}[Symbol.iterator](){let e=this.values[Symbol.iterator]();return{next:()=>{let n=e.next();if(n.done)return n;else return{done:!1,value:this.description.toBundle(n.value)}}}}assign(e){let{values:n}=e;for(let t of n)this.values.add(t);return this}push(e,n){let t=new Set;for(let r of this.values)for(let[o,i]of sn)if(e&i){let s=this.description.toBundle(r);n(o,s),t.add(s.toInt32())}this.values=t}update(e){let n=new Set;for(let t of this.values){let r=this.description.toBundle(t);e(r),n.add(r.toInt32())}this.values=n}}function Sn(e,n){let[t]=e,[r]=n;if(t.num<r.num)return kb(e,n);else if(t.num>r.num)return Sb(e,n);else return Ib(e,n)}function kb(e,n){let[t,r]=e,[o,i]=n;if(r.num<=o.num){let s=r.exclusive,a=o.exclusive;if(r.num<o.num||s||a)return{left:{fromLeft:!0,range:e},right:{fromLeft:!1,range:n}}}if(r.num<=i.num){let s=!0,a=!1;if(r.num===i.num){let c=r.exclusive,u=i.exclusive;s=c!==u,a=!c&&u}if(!a){let c;if(s)c={fromLeft:!1,range:[Ue(r),i]};return{left:{fromLeft:!0,range:[t,Ue(o)]},center:[o,r],right:c}}}return{left:{fromLeft:!0,range:[t,Ue(o)]},center:[o,i],right:{fromLeft:!0,range:[Ue(i),r]}}}function Sb(e,n){let[t,r]=e,[o,i]=n;if(t.num>=i.num){let s=i.exclusive,a=t.exclusive;if(t.num>i.num||s||a)return{left:{fromLeft:!1,range:n},right:{fromLeft:!0,range:e}}}if(i.num<=r.num){let s=!0,a=!1;if(r.num===i.num){let c=i.exclusive,u=r.exclusive;s=c!==u,a=!c&&u}if(!a){let c;if(s)c={fromLeft:!0,range:[Ue(i),r]};return{left:{fromLeft:!1,range:[o,Ue(t)]},center:[t,i],right:c}}}return{left:{fromLeft:!1,range:[o,Ue(t)]},center:[t,r],right:{fromLeft:!1,range:[Ue(r),i]}}}function Ib(e,n){let[t,r]=e,[o,i]=n,s=t.exclusive,a=o.exclusive,c,u=t;if(!s&&a)u=o,c={fromLeft:!0,range:[t,Ue(o)]};else if(s&&!a)c={fromLeft:!1,range:[o,Ue(t)]};if(r.num<=i.num){let l=!0,f=!1;if(r.num===i.num){let m=r.exclusive,h=i.exclusive;l=m!==h,f=!m&&h}if(!f){let m;if(l)m={fromLeft:!1,range:[Ue(r),i]};return{left:c,center:[u,r],right:m}}}return{left:c,center:[u,i],right:{fromLeft:!0,range:[Ue(i),r]}}}function Ue(e){return{num:e.num,exclusive:!e.exclusive}}var ot=(e)=>(n=e,t=Number.POSITIVE_INFINITY,r=e,o=Number.POSITIVE_INFINITY)=>{let{left:i,center:s,right:a}=Sn([{num:n,exclusive:!1},{num:t,exclusive:!1}],[{num:r,exclusive:!1},{num:o,exclusive:!1}]),c,u,l;if(i)c={min:i.range[0].num,max:i.range[1].num,isFrom1:i.fromLeft};if(a)u={min:a.range[0].num,max:a.range[1].num,isFrom1:a.fromLeft};if(s)l={min:s[0].num,max:s[1].num};return{left:c,right:u,intersection:l}};function it({left:e,right:n,intersection:t}){if(!t)return y.Rejection;let r=!1,o=!1;if(e)if(e.isFrom1)r=!0;else o=!0;if(n)if(n.isFrom1)r=!0;else o=!0;if(r&&o)return y.Intersection;if(r)return y.Containing;if(o)return y.ContainedBy;return y.Equals}var Cb=ot(0),Eb=uo(["hasCommon","hasExtra1","hasExtra2","hasRejection","hasCommonBroken"]);function Zp({calculate:e},n,t){let r=Cb(n.minItems,n.maxItems,t.minItems,t.maxItems),o=it(r);if(o===y.Rejection)return q;let[i,s]=Mp(n),[a,c]=Mp(t),u=Math.max(i.length,a.length)+1,l=Math.min(u,r.intersection.max),f=Eb.variable({}),m=Math.min(n.minItems??0,t.minItems??0);for(let g=0;g<l;g++){let E=i[g]??s,P=a[g]??c,T=e(E,P);f.push(T,(L,M)=>{switch(L){case y.Equals:{if(!M.hasRejection)M.hasCommon=!0;break}case y.Containing:{if(!M.hasRejection)M.hasCommon=!0;M.hasExtra1=!0;break}case y.ContainedBy:{if(!M.hasRejection)M.hasCommon=!0;M.hasExtra2=!0;break}case y.Intersection:{if(!M.hasRejection)M.hasCommon=!0;M.hasExtra1=!0,M.hasExtra2=!0;break}case y.Rejection:{if(g<m)M.hasCommonBroken=!0;M.hasRejection=!0,M.hasExtra1=!0,M.hasExtra2=!0;break}}})}f.update((g)=>{switch(o){case y.Containing:{g.hasExtra1=!0;break}case y.ContainedBy:{g.hasExtra2=!0;break}case y.Intersection:{g.hasExtra1=!0,g.hasExtra2=!0;break}}if(n.uniqueItems&&!t.uniqueItems&&(t.maxItems??Number.POSITIVE_INFINITY)>1)g.hasExtra2=!0;else if(!n.uniqueItems&&t.uniqueItems&&(n.maxItems??Number.POSITIVE_INFINITY)>1)g.hasExtra1=!0;if(n.maxItems===0||t.maxItems===0){if(g.hasCommon=!0,n.maxItems!==0)g.hasExtra1=!0;if(t.maxItems!==0)g.hasExtra2=!0}});let h=re;for(let{hasExtra1:g,hasExtra2:E,hasCommon:P,hasCommonBroken:T}of f){let L=P;if(T)L=!1;if(!L)h|=q;else if(g&&E)h|=W;else if(g)h|=D;else if(E)h|=Z;else h|=J}return h}function Mp({items:e,additionalItems:n}){if(Array.isArray(e))return[e,n??kn];else return[[],e??kn]}function Fp(e){let n=new Map;return(t,r)=>{let o=Wt(t),i=Wt(r);if(o!==i)return!1;if(!o)return t===r;return Lp(n,t,r,e)}}function Jp(e){let n=new Map;return(t,r)=>Lp(n,t,r,e)}function Lp(e,n,t,r){let o=Tn(n),i=Tn(t),s=`${o}/${i}`,a=e.get(s);if(a===void 0)e.set(s,a=r(n,t));return a}function Up(e,n,t){let r=Es(n),o=Es(t),i=!1,s=!1,a=!1;for(let c of r){if(qp(e,o,c))a=!0;else i=!0;if(i&&a)break}for(let c of o){if(qp(e,r,c))a=!0;else s=!0;if(s&&a)break}if(!a)return q;if(i&&s)return W;if(i)return D;if(s)return Z;return J}function Os(e,n){let t=!1,r=!1;for(let o of Es(e)){switch(tn(n,o)){case Ce.Valid:{t=!0;break}case Ce.Invalid:{r=!0;break}case Ce.Unknown:return Je}if(t&&r)break}if(t&&r)return W;if(t)return J|Z;if(r)return q;if(K(n)===S.Never)return J;return Z}function Es({const:e,enum:n}){if(e!==void 0)return[e];if(n)return n;throw Error("invalid branch")}function qp({isEquals:e},n,t){for(let r of n)if(e(r,t))return!0;return!1}function Bp(e){function n(s,a){let c=e.isExtendsSchema(s),u=e.isExtendsSchema(a);if(c||u)return e.equals(s,a);else return r(s,a)}let t=new Map;function r(s,a){let c=Tn(s),u=Tn(a);if(c===u)return!0;let l=`${c}/${u}`,f=t.get(l);if(f===void 0)f=o(s,a),t.set(l,f);return f}function o(s,a){if(Array.isArray(s)){if(!Array.isArray(a))return!1;if(s.length!==a.length)return!1;for(let[c,u]of s.entries())if(!i(u,a[c]))return!1}else{if(Array.isArray(a))return!1;for(let c in s){if(!(c in a))return!1;let u=Reflect.get(s,c),l=Reflect.get(a,c);if(!i(u,l))return!1}for(let c in a)if(!(c in s))return!1}return!0}function i(s,a){if(s===a)return!0;if(s===null||a===null)return!1;if(typeof s!=="object")return!1;if(typeof s!==typeof a)return!1;if(ze(s)&&ze(a))return r(s,a);return o(s,a)}return n}function Ht(e){let n=Qt(e),t=e.multipleOf??1,r=He(n,t);if(!r)return null;return{multipleOf:t,range:r}}function Kp([e,n]){if(e.num!==n.num)return!1;if(e.exclusive)return!1;if(n.exclusive)return!1;return!0}function He(e,n){if(!e)return;let[t,r]=e,o=Ob(t.num,n),i=Rb(r.num,n);if(o===t.num&&t.exclusive)o+=n;if(i===r.num&&r.exclusive)i-=n;if(o>i)return;if(o===i){if(o===Number.POSITIVE_INFINITY)return;if(o===Number.NEGATIVE_INFINITY)return}return[{num:o,exclusive:!1},{num:i,exclusive:!1}]}function Ob(e,n){return Math.ceil(e/n)*n}function Rb(e,n){return Math.floor(e/n)*n}function Gp(e,n){let t=Qt(e),r=Qt(n),{left:o,right:i,center:s}=Sn(t,r);if(!s)return q;let a=!1,c=!1;if(o)if(o.fromLeft)a=!0;else c=!0;if(i)if(i.fromLeft)a=!0;else c=!0;if(a&&c)return W;if(a)return D;if(c)return Z;return J}function Rs(e,n){let t=Qt(e),r=Ht(n);if(!r)return D;let o=Sn(t,r.range),i=He(o.center,r.multipleOf),s=Wp(o.left,r.multipleOf),a=Wp(o.right,r.multipleOf);if(!o.center)return q;let c=!1,u=!1;if(o.left?.fromLeft)c=!0;if(o.right?.fromLeft)c=!0;if(!i||!Kp(o.center))c=!0;if(s)u=!0;if(a)u=!0;if(c&&u)return W;if(c)return D;if(u)return Z;return J}function Qt(e){let n,t;if(e.exclusiveMinimum!==void 0)n={num:e.exclusiveMinimum,exclusive:!0};else if(e.minimum!==void 0)n={num:e.minimum,exclusive:!1};else n={num:Number.NEGATIVE_INFINITY,exclusive:!0};if(e.exclusiveMaximum!==void 0)t={num:e.exclusiveMaximum,exclusive:!0};else if(e.maximum!==void 0)t={num:e.maximum,exclusive:!1};else t={num:Number.POSITIVE_INFINITY,exclusive:!0};return[n,t]}function Wp(e,n){if(!e)return;if(e.fromLeft)return;return He(e.range,n)}function Yp(e,n){let t=Ht(e),r=Ht(n);if(!t&&!r)return J;if(!t)return Z;if(!r)return D;let{range:o,multipleOf:i}=t,{range:s,multipleOf:a}=r,c=Sn(o,s),u,l=0;if(c.center)l=Ab(i,a),u=He(c.center,l);if(!u)return q;let f=!1,m=!1,{left:h,right:g}=c;if(h&&He(h.range,h.fromLeft?i:a))if(h.fromLeft)f=!0;else m=!0;if(g&&He(g.range,g.fromLeft?i:a))if(g.fromLeft)f=!0;else m=!0;if(f=f||Hp(t,u,l),m=m||Hp(r,u,l),f&&m)return W;if(f)return D;if(m)return Z;return J}function Hp({range:e,multipleOf:n},t,r){let o=Sn(e,t);if(He(o.left?.range,n))return!0;if(He(o.right?.range,n))return!0;let i=He(o.center,n);if(!i)return!1;let s=Qp(t);if(Qp(i)>s)return!0;if(s===1)return!1;if(n<r)return!0;return!1}function Ab(e,n){return e*n/Xp(e,n)}function Xp(e,n){if(e===0)return n;return Xp(n%e,e)}function Qp(e){if(!e)return 0;let[n,t]=e;return t.num-n.num+1}function As(e,n){if(ef(e)||ef(n))return Je;let t=nf(e),r=nf(n);if(t&&r)return Gp(e,n);else if(t)return Rs(e,n);else if(r)return xn(Rs(n,e));else return Yp(e,n)}function ef(e){let{multipleOf:n}=e;if(n===void 0)return!1;if(!Number.isInteger(n))return!0;if(n<0)return!0;return!1}function nf(e){let{multipleOf:n}=e;if(n!==void 0&&Number.isInteger(n))return!1;if(e.type==="integer")return!1;return!0}var jb=ot(0),Pb=uo(["hasCommonInRequired","hasCommonOutRequired","hasExtra1","hasExtra2","hasRejection"]);function of(e,n,t){if($b(n,t))return q;let r=_b(n,t);if(!r)return q;let o=tf(n),i=tf(t),s=(E)=>{let P=o(E),T=i(E);if(rf(P,T))return e.calculate(P,T);else return re},{commonRequired:a,extraRequired1:c,extraRequired2:u}=r,l=Pb.variable({});for(let E of[...a].toSorted())l.push(s(E),Nb);for(let E of[...c].toSorted())l.push(s(E),zb);for(let E of[...u].toSorted())l.push(s(E),Db);let{hasOptional1:f,hasOptional2:m}=r;if(f||m){let E=Vb(f,m);for(let L of[...Tb(n,t)].toSorted()){let M=s(L);if(M!==re)l.push(M,E)}let P=n.additionalProperties??kn,T=t.additionalProperties??kn;if(rf(P,T)){let L=e.calculate(P,T);l.push(L,E)}}l.update((E)=>{if(!E.hasRejection){if(c.size>0)E.hasExtra2=!0;if(u.size>0)E.hasExtra1=!0}});let{requiredKeysCount:h}=r,g=re;for(let{hasExtra1:E,hasExtra2:P,hasCommonInRequired:T,hasCommonOutRequired:L,hasRejection:M}of l)if(!T&&h>0)g|=q;else if(!L&&h===0)g|=q;else if(M)g|=q;else if(E&&P)g|=W;else if(E)g|=D;else if(P)g|=Z;else g|=J;return g}function $b(e,n){let t=jb(e.minProperties,e.maxProperties,n.minProperties,n.maxProperties);return it(t)===y.Rejection}function _b(e,n){let t=new Set(e.required),r=new Set(n.required),o=new Set,i=new Set,s=t.size,a=r.size;for(let f of t){if(r.has(f))o.add(f);i.add(f)}for(let f of r){if(t.has(f))o.add(f);i.add(f)}let c=i.size;for(let f of o)t.delete(f),r.delete(f);let u=e.maxProperties??Number.MAX_SAFE_INTEGER,l=n.maxProperties??Number.MAX_SAFE_INTEGER;if(c>u||c>l)return null;return{requiredKeysCount:c,extraRequired1:t,extraRequired2:r,commonRequired:o,hasOptional1:u>s,hasOptional2:l>a}}function Tb(e,n){let t=new Set(e.required),r=e.properties,o=n.properties,i=e.required,s=n.required;if(r)for(let a in r)t.add(a);if(o)for(let a in o)t.add(a);if(i)for(let a of i)t.delete(a);if(s)for(let a of s)t.delete(a);return t}var Nb=(e,n)=>{switch(e){case y.Equals:{n.hasCommonInRequired=!0;break}case y.Containing:{n.hasExtra1=!0,n.hasCommonInRequired=!0;break}case y.ContainedBy:{n.hasExtra2=!0,n.hasCommonInRequired=!0;break}case y.Intersection:{n.hasExtra1=!0,n.hasExtra2=!0,n.hasCommonInRequired=!0;break}case y.Rejection:{n.hasRejection=!0;break}}},zb=(e,n)=>{switch(e){case y.Equals:case y.ContainedBy:{n.hasCommonInRequired=!0;break}case y.Intersection:case y.Containing:{n.hasExtra1=!0,n.hasCommonInRequired=!0;break}case y.Rejection:{n.hasRejection=!0;break}}},Db=(e,n)=>{switch(e){case y.Equals:case y.Containing:{n.hasCommonInRequired=!0;break}case y.Intersection:case y.ContainedBy:{n.hasExtra2=!0,n.hasCommonInRequired=!0;break}case y.Rejection:{n.hasRejection=!0;break}}},Vb=(e,n)=>(t,r)=>{if(r.hasRejection)return;let o=!1,i=!1,s=!1;switch(t){case y.Equals:{s=!0;break}case y.Containing:{o=!0,s=!0;break}case y.ContainedBy:{i=!0,s=!0;break}case y.Intersection:{o=!0,i=!0,s=!0;break}case y.Rejection:{o=!0,i=!0;break}}if(e&&o)r.hasExtra1=!0;if(n&&i)r.hasExtra2=!0;if(e&&n&&s)r.hasCommonOutRequired=!0};function tf(e){let{properties:n,propertyNames:t,additionalProperties:r}=e,o=[];if(e.patternProperties)for(let i in e.patternProperties){let s=e.patternProperties[i],a=new RegExp(i,"i");o.push({pattern:a,schema:s})}return(i)=>{if(t&&tn(t,i)===Ce.Invalid)return Kt;for(let{pattern:a,schema:c}of o)if(a.test(i))return c;let s=(n&&n[i])??r;if(!s)return kn;return s}}function rf(e,n){let t=K(e),r=K(n);return t!==S.Never||r!==S.Never}var Mb=ot(0);function sf(e,n){if(n.format&&!e.format)return D;if(e.format&&n.format&&e.format!==n.format)return Je;let t=Mb(e.minLength,e.maxLength,n.minLength,n.maxLength),r=it(t),o=!!e.pattern,i=!!n.pattern;switch(r){case y.Rejection:return q;case y.Containing:return o?Je:D;case y.ContainedBy:return i?Je:Z;case y.Equals:{if(o&&i)return e.pattern===n.pattern?J:Je;if(o)return J|Z;if(i)return J|D;return J}case y.Intersection:{if(o&&i)return Je;if(o)return W|q|Z;if(i)return W|q|D;return W}}}function cf(e,n,t){let r={},o=[],i=Jp(Fb(e,r)),s=Zb(),a=Bp(e);r.isEquals=Fp(et),r.calculate=bs({describe:s,equals:a,calculate:i,observeCalculation:(u,l,f,m)=>{let h=m?xn(f):f;if(!Jb(h))return;let g=m?af(l,u):af(u,l);if(g)o.push(g)}}),Object.freeze(r);let c=r.calculate(n,t);return{errorPath:o[0],expression:c}}var Zb=()=>(e)=>{let n;switch(K(e)){case S.Not:{n={kind:Te.Not,expression:e.not};break}case S.Combination:{if("allOf"in e)n={kind:Te.AllOf,expressions:js(e.allOf,S.Any)};else if("anyOf"in e)n={kind:Te.AnyOf,expressions:js(e.anyOf,S.Never)};else if("oneOf"in e)n={kind:Te.OneOf,expressions:js(e.oneOf,S.Never)};else throw Error(`invalid combination JSON Schema: ${JSON.stringify(e)}`);break}default:{n={kind:Te.Leaf};break}}return n},Fb=(e,n)=>(t,r)=>{let o=K(t),i=K(r);if(o===S.Extends||i===S.Extends)return e.calculate(t,r);switch(o){case S.Any:return i===S.Any?J:D;case S.Never:return i===S.Never?J:Z}switch(i){case S.Any:return Z;case S.Never:return D}if(o===S.EnumOrConst&&i===S.EnumOrConst)return Up(n,t,r);if(o===S.EnumOrConst)return Os(t,r);if(i===S.EnumOrConst)return xn(Os(r,t));if(o!==i)return q;switch(o){case S.Null:return J;case S.Numeric:return As(t,r);case S.String:return sf(t,r);case S.Boolean:return J;case S.Object:return of(n,t,r);case S.Array:return Zp(n,t,r);default:throw Error(`invalid kind ${o}`)}};function js(e,n){return e.filter((t)=>K(t)!==n)}function Jb(e){return!Zt(e)&&!Jt(e)&&(Ft(e)||qt(e)||Lt(e))}function af(e,n){let t=vs(n);if(!t)return;let r=K(e),o=K(n);if(r!==o)return[...t,"type"];let i=e,s=n;switch(o){case S.String:{if((i.minLength??0)<(s.minLength??0))return[...t,"minLength"];if((i.maxLength??Number.POSITIVE_INFINITY)>(s.maxLength??Number.POSITIVE_INFINITY))return[...t,"maxLength"];if(i.pattern!==s.pattern&&s.pattern)return[...t,"pattern"];if(i.format!==s.format&&s.format)return[...t,"format"];break}case S.Numeric:{if((i.minimum??i.exclusiveMinimum??Number.NEGATIVE_INFINITY)<(s.minimum??s.exclusiveMinimum??Number.NEGATIVE_INFINITY))return[...t,s.exclusiveMinimum==null?"minimum":"exclusiveMinimum"];if((i.maximum??i.exclusiveMaximum??Number.POSITIVE_INFINITY)>(s.maximum??s.exclusiveMaximum??Number.POSITIVE_INFINITY))return[...t,s.exclusiveMaximum==null?"maximum":"exclusiveMaximum"];if(i.multipleOf!==s.multipleOf&&s.multipleOf!=null)return[...t,"multipleOf"];break}case S.Array:{if((i.minItems??0)<(s.minItems??0))return[...t,"minItems"];if((i.maxItems??Number.POSITIVE_INFINITY)>(s.maxItems??Number.POSITIVE_INFINITY))return[...t,"maxItems"];if(!i.uniqueItems&&s.uniqueItems)return[...t,"uniqueItems"];break}case S.Object:{let a=new Set(i.required??[]);if((s.required??[]).some((c)=>!a.has(c)))return[...t,"required"];if((i.minProperties??0)<(s.minProperties??0))return[...t,"minProperties"];if((i.maxProperties??Number.POSITIVE_INFINITY)>(s.maxProperties??Number.POSITIVE_INFINITY))return[...t,"maxProperties"];break}case S.EnumOrConst:return[...t,s.const===void 0?"enum":"const"]}return t}class Yt{constructor(e=[]){this.extendsSchemaClasses=Object.freeze([...e])}tryCompiledExtendsSchema(e,n){for(let t of this.extendsSchemaClasses)if(t.isMatch(e))return new t(bn(),e,n);return null}isExtendsSchema(e){for(let n of this.extendsSchemaClasses)if(e instanceof n)return!0;return!1}calculate(e,n){let t=this.findMatchedClass(e,n),r=!(e instanceof t),o=re,i;if(r)i=n.compare(e);else i=e.compare(n);for(let s of i){if(r)s=Yt.swap(s);o|=wn(s)}return o}equals(e,n){let t=this.findMatchedClass(e,n);if(!(e instanceof t))return n.equals(e);else return e.equals(n)}findMatchedClass(e,n){for(let t of this.extendsSchemaClasses){if(e instanceof t)return t;if(n instanceof t)return t}throw Error("Invalid schema")}static swap(e){switch(e){case y.Containing:return y.ContainedBy;case y.ContainedBy:return y.Containing;default:return e}}}function uf(e,n,t=!1){let r=n(e);if(Array.isArray(r)){let s=[];throw Ps(s,r,"$"),new io(s)}let{schema:o,warns:i}=r;if(t&&i.length>0){console.warn(`found ${i.length} warns after compile schema`);for(let s of i)console.warn(rt(s))}return o}function lf(e,n,t,r=!1){let o=t(e),i=t(n);if(Array.isArray(o)||Array.isArray(i)){let l=[];if(Array.isArray(o))Ps(l,o,"$1");if(Array.isArray(i))Ps(l,i,"$2");throw new io(l)}let{schema:s,warns:a}=o,{schema:c,warns:u}=i;if(r){if(a.length>0)console.warn(`found ${a.length} warns after compile superSchema`);for(let l of a)console.warn(rt(l));if(u.length>0)console.warn(`found ${u.length} warns after compile subSchema`);for(let l of u)console.warn(rt(l))}return[s,c]}function Ps(e,n,t){for(let r of n){let o={...r,path:[t,...r.path]};e.push(o)}}var Xt=Object.freeze({True:0,False:1,Unknown:2});function $s({extendsSchemaClasses:e,delegate:n}={}){let t=new Yt(e);return Object.freeze({compile:(o,i,s)=>uf(o,(c)=>co(c,t,i,n),s),isSubset:(o,i,s=!1)=>{let a=(g)=>co(g,t,void 0,n),[c,u]=lf(o,i,a,s),{errorPath:l,expression:f}=cf(t,c,u),m=Zt(f)||Jt(f),h=Ft(f)||qt(f)||Lt(f);if(m&&!h)return{result:Xt.True};if(!m&&h)return{errorPath:l,result:Xt.False};return{result:Xt.Unknown}}})}var lo=(e)=>typeof e==="string";var Lb=Array.isArray;var qb=(e)=>e!==null&&typeof e==="object";var Ub=(e)=>qb(e)&&!Lb(e),Nn=(e)=>Ub(e)?e:void 0;function Bb(e){return Nn(e)?.type==="string"}function Kb(e){let n=Nn(e),t=Nn(n?.error);if(n==null||t==null||n.packageId!=null&&!lo(n.packageId)||t.message!=null&&!lo(t.message))throw TypeError("Invalid schema comparison context.")}function Wb(e){if(e==null)return{error:{}};return Kb(e),e}class In{static setError(e,n,t){if(e instanceof In)e.context.error.message=t;else if(n instanceof In)n.context.error.message=t}constructor(e,n,t){this.id=e,this.value=n,this.context=Wb(t)}compare(e){if(ze(e)&&K(e)===S.Any)return[y.ContainedBy];return this.compareImpl(e)}}class er extends In{static isMatch(e){let n=Nn(e)?.enum;return Array.isArray(n)&&n.every((t)=>lo(t))}constructor(e,n,t){if(!er.isMatch(n))throw TypeError("Invalid single-select schema.");super(e,n,t)}compareImpl(e){if(Bb(e))return[y.ContainedBy];if(e instanceof er){let n=new Set(this.value.enum),t=y.Equals;for(let r of e.value.enum){if(!n.has(r))t=y.ContainedBy;n.delete(r)}if(n.size===0)return[t];if(n.size===this.value.enum.length)return[y.Rejection];return[y.Intersection]}return[y.Rejection]}equals(e){if(e instanceof er){let n=new Set(this.value.enum);for(let t of e.value.enum){if(!n.has(t))return!1;n.delete(t)}return n.size===0}return!1}}class nr extends In{static isMatch(e){return Nn(e)?.contentMediaType==="oomol/bin"}constructor(e,n,t){if(!nr.isMatch(n))throw TypeError("Invalid binary schema.");super(e,n,t)}compareImpl(e){if(e instanceof nr)return[y.Equals];else return In.setError(this,e,"edgeError.binDiffType"),[y.Rejection]}equals(e){return e instanceof nr}}class tr extends In{static isMatch(e){return Nn(e)?.contentMediaType==="oomol/artifact"}constructor(e,n,t){if(!tr.isMatch(n))throw TypeError("Invalid Artifact schema.");super(e,n,t)}compareImpl(e){if(e instanceof tr)return[y.Equals];return In.setError(this,e,"edgeError.artifactDiffType"),[y.Rejection]}equals(e){return e instanceof tr}}function df(){return $s({extendsSchemaClasses:[er,nr,tr]})}var IE=df();var po=I({handle:R().min(1),jsonSchema:_e(),nullable:le(),description:R().optional()}),TE=v({inputs:j(po).nullable(),outputs:j(po).nullable()});var pf=I({version:x(1),flowId:R().min(1),name:R(),revisionId:R().min(1),publicationId:R().min(1),inputs:j(po),outputs:j(po).nullable()});var ff=I({version:x(1),direction:ce(["incoming","outgoing"]),total:ge().nonnegative(),nextOffset:ge().nonnegative().optional(),references:j(I({flowId:R(),name:R().nullable(),available:le(),draft:le(),live:I({publicationId:R(),enabled:le()}).nullable()}))});var mf=v({mode:ce(["chat","json"]),resultSchema:_e(),model:_e().optional().describe("Default model settings: {model, temperature?, top_p?, max_tokens?}. A bound model input takes precedence."),template:_e().optional().describe('Default message templates: [{role: "system" | "user" | "assistant", content: "Text with {{namedInput}}"}].'),messages:_e().optional().describe("Default conversation history, prepended without template interpolation; an array of {role, content} or null.")});var Yb=X([v({schemes:j(R().min(1)).describe("One complete security alternative advertised by this operation; [] selects no authentication.")}),v({type:ce(["bearer","basic"])}),v({type:x("apiKey"),name:R().min(1),in:ce(["header","query"])})]),gf=v({sourceUrl:R().min(1),path:R().min(1),method:R().min(1),serverUrl:R().optional(),authentication:Yb.optional().describe("Omit to use the operation default. Bind credentials through the advertised node inputs.")});var N=R().min(1),Be=_e(),zs=ee(N,Be),fo=["start","outputs","workflow","webhook","cron","error","poll","integration","code","connector","agent","llm","decision","openapi","condition","value","wait","approval"],Ds=ce(fo),an=N.describe('An existing node reference returned by read/search, or $alias for a preceding node.add in this edit batch. For node.add.as "step", reference "$step", never bare "step". Aliases are local to one batch.'),_s=v({kind:x("output"),node:an,port:N.optional().describe("Omit for a node with one output. For multiple outputs, choose a name from node details."),field:R().optional()}),Ts=v({kind:x("variable"),name:N}),hf=X([_s,Ts,v({kind:x("value"),value:Be}),v({kind:x("unset")}),v({kind:x("default")}),v({kind:x("sources"),sources:j(X([_s,Ts])).min(1)})]),yf=X([v({kind:x("value"),value:Be.optional(),schema:Be.optional()}),_s,Ts]),Xb=qe.agent.shape.tools.element.omit({id:!0,inputs:!0}).extend({inputs:ee(N,qe.agent.shape.tools.element.shape.inputs.element.shape.source).optional().describe("Action input sources by name. The tool resolves types from the Action. New inputs default to model-provided; existing sources are preserved when omitted.")}).strict(),ew=v({...qe.connector.shape,messageHandle:N,inputs:ee(N,X([v({kind:x("value"),value:Be}),v({kind:x("input"),input:N})]))}),mo=v({schema:Be.optional(),nullable:le().optional(),description:R().optional()}),st=ee(N,mo.extend({default:Be.optional()})).describe("Optional business input constraints by name. A binding to a new Code, Agent, LLM, Wait or Approval input automatically declares an input accepting any JSON. Existing constraints are preserved. Omitted schema accepts any JSON; omitted nullable is true. Use default for inherited values; input.set supplies data."),vf=ee(N,mo).describe("Workflow input definitions by name. Omitted schema accepts any JSON; omitted nullable is true. No defaults. Supply call values as trigger.outputs."),nw=vf.describe("Workflow output definitions by name. Omitted schema accepts any JSON; omitted nullable is true. No defaults. Set values on the Outputs node with input.set or node.add.inputs."),kf=ee(N,mo.extend({schema:Be,nullable:le()})),bf=ee(N,mo).describe("Code return fields by name. Omitted schema accepts any JSON; omitted nullable is true."),Ns=v({left:yf,operator:qe.condition.shape.cases.element.shape.groups.element.shape.expressions.element.shape.operator,right:yf.optional()}),wf=v({all:j(Ns)}),tw=X([Ns,wf,v({any:j(X([Ns,wf]))})]),cn={workflow:v({flowId:N}),start:v({inputDefs:vf.default({})}),outputs:v({outputDefs:nw.default({})}),error:v({sourceFlowIds:j(N).optional()}),webhook:qe.webhook.omit({bodyFields:!0}).extend({body:st}).strict(),cron:v({schedule:qe.schedule}),poll:v({key:N,connectionId:N.optional(),schedule:qe.schedule}),integration:v({key:N,connectionId:N.optional()}),code:v({inputs:st,outputs:bf,capabilities:qe.capabilities.optional()}),connector:qe.connector.omit({outputMode:!0}).strict(),openapi:gf,agent:qe.agent.omit({prompt:!0,tools:!0}).extend({inputs:st,resultSchema:Be.describe("JSON schema of the final result. Defaults to text. The tool manages the output definition; references can omit port."),tools:j(Xb),notification:ew.optional()}).strict(),llm:mf.extend({inputs:st}),decision:qe.decision,condition:v({match:ce(["first","all"]),branches:j(v({name:N,description:R().optional(),when:tw}))}),value:v({values:zs,outputs:bf}),wait:v({inputs:st}),approval:v({inputs:st})},rw={name:N.optional(),description:R().optional(),icon:R().optional(),maxExecutions:ge().positive().optional(),timeoutMs:ue().nonnegative().optional()},ow=v({...rw,config:zs.optional().describe('Recursively merge configuration; omitted fields remain unchanged and arrays replace as a whole. This includes schema objects: {} does not clear an existing schema. Use clear paths to remove fields, e.g. ["config","inputs","amount","schema","type"].')}),iw=jn("op",[v({op:x("node.add"),as:N.regex(/^[A-Za-z][\w-]*$/).describe("Unique batch-local alias without the $ prefix. Later edits must reference this new node as $alias; the bare alias is not its node ID."),type:Ds,name:N,config:zs.optional(),inputs:ee(N,hf).optional().describe("Input data sources, applied after creation, as input.set operations. Execution edges are separate."),code:R().optional(),prompt:R().optional()}),v({op:x("node.update"),node:an,set:ow.optional(),clear:j(j(N).min(1)).optional()}),v({op:x("node.refresh"),node:an}),v({op:x("node.remove"),node:an}),v({op:x("input.set"),node:an,input:N,source:hf}),v({op:ce(["edge.connect","edge.disconnect"]),source:an,target:an,branch:N.optional()}),v({op:x("text.edit"),node:an,field:ce(["code","prompt"]),oldText:N,newText:R()}),v({op:x("text.set"),node:an,field:ce(["code","prompt"]),text:R()})]),rr=v({baseRevision:N,requestId:N.max(256),edits:j(iw).min(1).max(1000)}),go=v({revision:N.optional().describe("Fixed revision from a previous read; omit to read the current draft."),nodes:j(N).min(1).max(100).optional().describe("Node references to read in one batch. Mutually exclusive with text. Long texts return metadata."),text:v({node:N,field:ce(["code","prompt"]),start:ge().positive().default(1),lines:ge().min(1).max(200).default(80)}).optional().describe("Read code or prompt by line (1-based). Mutually exclusive with nodes. Follow nextStart at the same revision until truncated is false.")}).refine((e)=>e.nodes==null||e.text==null,"Choose nodes or text.").meta({not:{required:["nodes","text"]},description:"Omit nodes and text for an outline; provide nodes for details, or text for an excerpt."}),Vs=v({revisionId:N}),ho=v({revision:N.optional(),query:N.max(1000),type:Ds.optional(),offset:ge().nonnegative().default(0),limit:ge().min(1).max(100).default(20)}),Sf=v({type:Ds.optional(),action:N.optional()}).refine((e)=>e.type==null||e.action==null,"Choose type or action."),xf={read:{schema:go,guidance:"Read Start and Outputs node details for their interface definitions and data sources. Choose one mode: outline (omit nodes and text), node details (nodes), or text excerpt (text). nodes and text are mutually exclusive. Text defaults to 80 lines, at most 200 lines and 24000 characters. For the complete text, repeat at nextStart with the same revision until truncated is false.",examples:[{},{revision:"REVISION",nodes:["NODE"]},{revision:"REVISION",text:{node:"NODE",field:"prompt",start:1,lines:80}}]},search:{schema:ho,guidance:"Search names, configurations and text. Keep the returned revision when following nextOffset or reading a match.",examples:[{query:"Customer summary",type:"agent"}]},edit:{schema:rr,guidance:'Edit Start config.inputDefs and Outputs config.outputDefs through node.add or node.update; clear paths are relative to the node, e.g. ["config","inputDefs","amount"]. Set Outputs values with input.set. Use the observed revision as baseRevision and a stable requestId. Edits are ordered and atomic. node.add.as declares a batch-local alias without $. Every later reference to that new node must use $alias, including node, edge source/target and output source node fields; a bare alias is not the node ID. Use returned node references in later batches. Updates recursively merge objects (including schemas); {} preserves existing fields. Arrays replace as a whole. Remove fields with clear paths. Text replacement requires exactly one match. Read the target text first. A saved draft can have validation diagnostics.',examples:[{baseRevision:"REVISION",requestId:"CREATE_REQUEST",edits:[{op:"node.add",as:"start",type:"start",name:"Start"},{op:"node.add",as:"step",type:"code",name:"Process",code:"export default ({value}) => ({result:value})"},{op:"edge.connect",source:"$start",target:"$step"},{op:"node.update",node:"$step",set:{description:"Created and connected in one atomic edit."}}]},{baseRevision:"REVISION",requestId:"REQUEST",edits:[{op:"text.edit",node:"NODE",field:"prompt",oldText:"Original rule.",newText:"Updated rule."}]}]},check:{schema:Vs,guidance:"Check a fixed revision. In the CLI, pass this identity with --revision REVISION.",examples:[{revisionId:"REVISION"}]}};function Ms(e){if(!Object.hasOwn(xf,e))return;let n=xf[e];return{request:Tt(n.schema,{io:"input"}),guidance:n.guidance,examples:n.examples}}function Zs(e){return e==null?{types:fo,request:Tt(rr),guidance:"Read a node type schema before creating or configuring it. Use $alias to reference a preceding node.add in the same batch. Read returns stable node references. Long code and prompt fields use text reads and edits. Changes use the observed baseRevision and a stable requestId."}:{type:e,inputSources:["poll","integration"].includes(e)?["value","unset","default"]:["start","outputs","error","cron","webhook","value","condition"].includes(e)?[]:["value","unset","default","output","variable","sources"],extensibleInputs:["code","agent","llm","wait","approval"].includes(e),guidance:e=="outputs"?"Declare output fields through config.outputDefs. Set their values through node.add.inputs or input.set. Outputs is a singleton execution sink; it waits for its predecessors and produces workflow business outputs independently of node logs. No downstream edges or data references to Outputs are allowed.":e=="start"?"Declare workflow inputs through config.inputDefs; read them in Start node details. REST calls and manual runs supply them as trigger.outputs. Downstream nodes bind these parameters as Start outputs. Start has no input sources or defaults; non-nullable parameters are required, and omitted nullable parameters become null.":e=="condition"?"Edit branch operands through config.branches. A branch can test one expression, all expressions, or any alternatives. Unmatched execution uses branch otherwise.":["poll","integration"].includes(e)?"Configure static parameters with node.add.inputs or input.set. Definitions come from the selected Trigger key; execution output and variable sources are unavailable.":e=="llm"?"Configure model settings, message templates and history as defaults. Input bindings with the same names override these defaults; named business inputs can be bound directly. Template strings interpolate {{name}}.":e=="openapi"?"Select an operation; the tool resolves its ports and authentication. Read authenticationChoices from node details. authentication is replaced as a complete choice. Bind advertised credentials through inputs.":e=="workflow"?"Select another workflow with config.flowId. A workflow cannot call itself, including in a disconnected node. Owned unpublished or unavailable targets may be saved as incomplete drafts. Use node.refresh to load the current published interface.":"Supply business configuration and input data. Fixed definitions are assembled by the tool. Existing constraints and defaults are preserved on partial updates.",example:{op:"node.add",as:"step",type:e,name:"Step",...{start:{config:{inputDefs:{}}},outputs:{config:{outputDefs:{}}},workflow:{config:{flowId:"<Flow ID>"}},connector:{config:{action:"<Action ID>",connectionId:"<Connection ID>"}},poll:{config:{key:"<Trigger key>",schedule:[{type:"every",unit:"minute",value:5}]}},integration:{config:{key:"<Trigger key>"}},openapi:{config:{sourceUrl:"https://example.com/openapi.json",path:"/items",method:"get"}},code:{code:"export default ({value}) => ({result:value})",inputs:{value:{kind:"value",value:"Hello"}}},condition:{config:{match:"first",branches:[{name:"yes",when:{left:{kind:"value",value:120},operator:">",right:{kind:"value",value:100}}}]}},value:{config:{values:{threshold:100,region:"EU"}}},webhook:{config:{method:"POST",body:{orderId:{schema:{type:"string"},nullable:!1}}}},wait:{prompt:"Continue processing this order?",inputs:{order:{kind:"value",value:{orderId:"A-1"}}}},approval:{prompt:"Approve this order?",inputs:{order:{kind:"value",value:{orderId:"A-1"}}}},llm:{config:{model:{model:"deepseek-v4-flash"},template:[{role:"user",content:"Summarize {{order}}."}]},inputs:{order:{kind:"value",value:{orderId:"A-1",total:42}}}},agent:{config:{model:"deepseek-v4-flash"},inputs:{orders:{kind:"value",value:[{orderId:"A-1",total:42}]}},prompt:"Summarize {{orders}}."}}[e]},configuration:Tt(cn[e].partial()),texts:e=="code"?["code"]:["agent","wait","approval"].includes(e)?["prompt"]:[]}}var If=I({code:N,message:R(),nodes:j(N),field:R().optional(),line:ue().optional(),column:ue().optional()}),Cf=I({flowId:N,revisionId:N,valid:le(),diagnostics:j(If),version:x(1)}),Ef=I({flowId:N,saved:x(!0),revision:N,nodes:ee(N,N),changes:j(I({index:ge(),op:N,node:N.optional()})),validation:I({status:ce(["valid","invalid","unavailable"]),diagnostics:j(If).optional()}),version:x(1)}),Of=I({flowId:N,revision:N,data:I({nodes:j(ee(R(),Be)).optional(),edges:j(Be).optional(),text:ee(R(),Be).optional()}),version:x(1)}),Rf=I({flowId:N,revision:N,data:I({matches:j(I({node:N.optional(),field:N,line:ge().optional(),excerpt:R()})),total:ge(),nextOffset:ge().optional()}),version:x(1)});var z={authenticationRequired:"authentication.required",authorizationDenied:"authorization.denied",bindingUnresolved:"binding.unresolved",connectorActionNotFound:"connector.action-not-found",connectorAccessConflict:"connector.access-conflict",connectorAccessInvalid:"connector.access-invalid",connectorAccessRequired:"connector.access-required",connectorAccessUnsupported:"connector.access-unsupported",connectorUnconfigured:"connector.unconfigured",connectorUnavailable:"connector.unavailable",connectorConsoleUnconfigured:"connector.console-unconfigured",engineUnavailable:"engine.unavailable",engineUnsupported:"engine.unsupported",eventSourceInvalid:"event-source.invalid",eventSourceIdentityUnavailable:"event-source.identity-unavailable",eventSourceNotFound:"event-source.not-found",eventSourceConflict:"event-source.conflict",flowInvalid:"flow.invalid",flowRepairRequired:"flow.repair-required",flowUpgradeRequired:"flow.upgrade-required",flowNotFound:"flow.not-found",flowBusy:"flow.busy",flowConflict:"flow.conflict",flowPresentationConflict:"flow.presentation-conflict",flowRevisionConflict:"flow.revision-conflict",liveConflict:"live.conflict",liveNotFound:"live.not-found",pageInvalidCursor:"page.invalid-cursor",publicationConflict:"publication.conflict",publicationNotFound:"publication.not-found",publicationUnsupported:"publication.unsupported",publishOperationNotFound:"publication.operation-not-found",routeNotFound:"route.not-found",runConflict:"run.conflict",runEventsExpired:"run.events-expired",runInvalid:"run.invalid",runNotFound:"run.not-found",runNotTerminal:"run.not-terminal",runOverloaded:"run.overloaded",runWaitNotFound:"run.wait-not-found",triggerKeyInvalid:"trigger-key.invalid",triggerKeyNotFound:"trigger-key.not-found",triggerNotFound:"trigger.not-found",variableInvalid:"variable.invalid",variableLimitReached:"variable.limit-reached",variableNotFound:"variable.not-found"},aw={[z.eventSourceInvalid]:{status:400},[z.eventSourceIdentityUnavailable]:{status:409},[z.eventSourceNotFound]:{status:404},[z.eventSourceConflict]:{status:409},[z.authenticationRequired]:{status:401},[z.authorizationDenied]:{status:403},[z.bindingUnresolved]:{status:409},[z.connectorActionNotFound]:{status:404},[z.connectorAccessConflict]:{status:412},[z.connectorAccessInvalid]:{status:409},[z.connectorAccessRequired]:{status:409},[z.connectorAccessUnsupported]:{status:409},[z.connectorUnconfigured]:{status:503},[z.connectorUnavailable]:{status:503},[z.connectorConsoleUnconfigured]:{status:503},[z.engineUnavailable]:{status:503},[z.engineUnsupported]:{status:409},[z.flowInvalid]:{status:400},[z.flowRepairRequired]:{status:409},[z.flowUpgradeRequired]:{status:409},[z.flowNotFound]:{status:404},[z.flowBusy]:{status:409},[z.flowConflict]:{status:409},[z.flowPresentationConflict]:{status:412},[z.flowRevisionConflict]:{status:412},[z.liveConflict]:{status:412},[z.liveNotFound]:{status:404},[z.pageInvalidCursor]:{status:400},[z.publicationConflict]:{status:409},[z.publicationNotFound]:{status:404},[z.publicationUnsupported]:{status:409},[z.publishOperationNotFound]:{status:404},[z.routeNotFound]:{status:404},[z.runConflict]:{status:409},[z.runEventsExpired]:{status:410},[z.runInvalid]:{status:400},[z.runNotFound]:{status:404},[z.runNotTerminal]:{status:409},[z.runOverloaded]:{status:429},[z.runWaitNotFound]:{status:404},[z.triggerKeyInvalid]:{status:409},[z.triggerKeyNotFound]:{status:404},[z.triggerNotFound]:{status:404},[z.variableInvalid]:{status:400},[z.variableLimitReached]:{status:409},[z.variableNotFound]:{status:404}};class Ee extends Error{constructor(e,n,t,r){super(t);this.code=n,this.details=r,this.name="ApiError",this.status=e}}class Af extends Ee{constructor(e){super(502,"response.invalid",`The Control API returned an invalid response.${e==null?"":` ${e}`}`);this.detail=e}}function d(e){throw new Af(e)}function w(e){if(e==null||typeof e!="object"||Array.isArray(e))return d("Expected an object.");return e}function p(e){return typeof e=="string"&&e.length>0?e:d("Expected a non-empty string.")}function U(e,n){let t=n.filter((r)=>!Object.hasOwn(e,r));if(t.length>0)d(`Missing fields: ${t.join(", ")}.`)}function Ke(e,n){let t=Object.keys(e);if(t.length!=n.length||t.some((r)=>!n.includes(r))){let r=n.filter((i)=>!Object.hasOwn(e,i)),o=t.filter((i)=>!n.includes(i));d([r.length>0?`Missing fields: ${r.join(", ")}.`:"",o.length>0?`Unexpected fields: ${o.join(", ")}.`:""].filter(Boolean).join(" "))}}function ne(e){return Number.isSafeInteger(e)?e:d("Expected a safe integer.")}function be(e){if(e===null||typeof e=="boolean"||typeof e=="string")return e;if(typeof e=="number"&&Number.isFinite(e))return e;if(Array.isArray(e))return e.map(be);let n=w(e);return Object.fromEntries(Object.entries(n).map(([t,r])=>[t,be(r)]))}function yo(e){if(e==null)return;return p(e)}function at(e){let n=w(e),t=n.liveEnd==null?void 0:w(n.liveEnd);if(t!=null&&typeof t.enabled!="boolean")return d();let{operation:r,sourcePublicationId:o}=n;if(n.version!=1)return d();if(r!="publish"&&r!="rollback")return d();if(o!=null&&typeof o!="string")return d();return{...t==null?{}:{liveEnd:{enabled:t.enabled,endedAt:p(t.endedAt)}},actorId:p(n.actorId),closureDigest:p(n.closureDigest),createdAt:p(n.createdAt),engineContract:p(n.engineContract),flowId:p(n.flowId),modelVersion:ne(n.modelVersion),operation:r,publicationId:p(n.publicationId),sharedAccessDigest:p(n.sharedAccessDigest),revisionDigest:p(n.revisionDigest),revisionId:p(n.revisionId),...o==null?{}:{sourcePublicationId:o},version:1}}function Fs(e){let n=w(e),t=n.status,r={createdAt:p(n.createdAt),flowId:p(n.flowId),operationId:p(n.operationId),revisionId:p(n.revisionId),updatedAt:p(n.updatedAt),version:1};if(n.version!=1)return d();switch(t){case"pending":return U(n,["createdAt","flowId","operationId","revisionId","status","updatedAt","version"]),{...r,status:t};case"succeeded":return U(n,["createdAt","flowId","operationId","publicationId","revisionId","status","updatedAt","version"]),{...r,publicationId:p(n.publicationId),status:t};case"failed":{U(n,["createdAt","flowId","issue","operationId","revisionId","status","updatedAt","version"]);let o=w(n.issue),i=o.nodeId;return U(o,["code","message",...i==null?[]:["nodeId"]]),{...r,issue:{code:p(o.code),message:p(o.message),...i==null?{}:{nodeId:p(i)}},status:t}}default:return d()}}function Js(e){let n=w(e),{status:t,publication:r}=n;if(n.version!=1||typeof n.hasUnpublishedChanges!="boolean")return d();if(t!="not-published"&&t!="runnable"&&t!="suspended")return d();if(t=="not-published"&&r!==null)return d();if(t!="not-published"&&r===null)return d();return{flowId:p(n.flowId),hasUnpublishedChanges:n.hasUnpublishedChanges,publication:r===null?null:at(r),revision:ne(n.revision),status:t,version:1}}function jf(e){let n=w(e),{nextCursor:t,total:r}=n;if(n.version!=1||!Array.isArray(n.publications))return d();if(t!=null&&typeof t!="string")return d();if(r!=null&&!Number.isSafeInteger(r))return d();return{...t==null?{}:{nextCursor:t},publications:n.publications.map(at),...r==null?{}:{total:r},version:1}}var Pf=j(X([v({handle:R().min(1),description:R().optional(),jsonSchema:_e(),nullable:le(),value:_e().optional()}),v({group:R(),collapsed:le().optional()})]));function Ls(e){let n=w(e),t=n.type;if(t!="integration"&&t!="poll")return d();return{description:typeof n.description=="string"?n.description:d(),displayName:p(n.displayName),key:p(n.key),name:p(n.name),provider:p(n.provider),type:t}}function or(e){let n=w(e),t=Ls(n),r={configInputs:Pf.parse(n.configInputs),definitionVersion:n.definitionVersion===2?2:d(),description:t.description,displayName:t.displayName,key:t.key,name:t.name,outputs:(Array.isArray(n.outputs)?n.outputs:d()).map((u)=>{let l=w(u);return Object.assign({handle:p(l.handle),jsonSchema:be(l.jsonSchema),nullable:typeof l.nullable==="boolean"?l.nullable:d()},l.description==null?{}:{description:p(l.description)})}),provider:t.provider};if(t.type=="poll")return{...r,type:"poll"};let o=w(n.endpoint),i=w(o.body);if(!Array.isArray(o.methods)||!Array.isArray(i.formats)||typeof i.allowArray!="boolean"||typeof i.allowEmpty!="boolean")return d();let s=o.methods.map(p),a=i.formats.map(p),c=ne(o.successStatus);if(s.some((u)=>!["DELETE","GET","HEAD","PATCH","POST","PUT"].includes(u))||a.some((u)=>!["form","json","multipart","text"].includes(u))||c<200||c>299)return d();return{...r,endpoint:{body:{allowArray:i.allowArray,allowEmpty:i.allowEmpty,formats:a},methods:s,successStatus:c},type:"integration"}}var cw=new Set(["error","cron","integration","poll","webhook"]),uw=new Set(["failed","healthy","initializing","needs_reauth","suspended"]),lw=new Set(["delivery.failed","health.failed","health.needs_reauth","health.recovered","health.suspended","operator.paused","operator.resumed"]);function ir(e){let n=w(e),t=n.health,r=n.listener==null?void 0:w(n.listener);if(r!=null&&r.health!="healthy"&&r.health!="failed"&&r.health!="needs_reauth")return d();let o=n.kind,i=ne(n.runtimeVersion);if(n.version!=1||typeof t!="string"||!uw.has(t))return d();if(typeof o!="string"||!cw.has(o))return d();if(i<=0)return d();return{...n.currentPublicationId==null?{}:{currentPublicationId:p(n.currentPublicationId)},...n.currentRevisionId==null?{}:{currentRevisionId:p(n.currentRevisionId)},...n.endpointUrl==null?{}:{endpointUrl:p(n.endpointUrl)},...r==null?{}:{listener:{health:r.health,...r.lastErrorCode==null?{}:{lastErrorCode:p(r.lastErrorCode)}}},flowId:p(n.flowId),health:t,kind:o,...n.lastErrorCode==null?{}:{lastErrorCode:p(n.lastErrorCode)},runtimeVersion:i,triggerNodeId:p(n.triggerNodeId),updatedAt:p(n.updatedAt),version:1}}function $f(e){let n=w(e);if(n.version!=1)return d();return{binding:ir(n.binding),version:1}}function dw(e){let n=w(e),t=n.kind;if(typeof t!="string"||!lw.has(t))return d();let r=yo(n.errorCode),o=yo(n.errorMessage);if(o!=null&&o.length>512)return d();return{activityId:p(n.activityId),createdAt:p(n.createdAt),...r==null?{}:{errorCode:r},...o==null?{}:{errorMessage:o},kind:t}}function _f(e){let n=w(e),t=yo(n.nextCursor);if(n.version!=1||!Array.isArray(n.activities))return d();return{activities:n.activities.map(dw),...t==null?{}:{nextCursor:t},version:1}}function Tf(e){let n=w(e),t=ne(n.filtered);if(n.version!=1||!Array.isArray(n.events)||typeof n.hasMore!="boolean"||t<0)return d();return{events:n.events.map((r)=>{let o=w(r);return Object.fromEntries(Object.entries(o).map(([i,s])=>[i,be(s)]))}),filtered:t,hasMore:n.hasMore,version:1}}var zn={nodeId:R().min(1),name:R(),description:R().optional()},sr=Wn().transform(ir),Nf={provider:R().min(1),inputs:ee(R(),jn("kind",[I({kind:x("value"),value:_e()}),I({kind:x("unset")})]))},fw=jn("type",[I({...zn,type:x("start"),config:cn.start}),I({...zn,type:x("manual"),config:I({})}),I({...zn,type:x("webhook"),config:cn.webhook,binding:sr}),I({...zn,type:x("cron"),config:cn.cron,binding:sr}),I({...zn,type:x("error"),config:cn.error,binding:sr}),I({...zn,...Nf,type:x("poll"),config:cn.poll,binding:sr}),I({...zn,...Nf,type:x("integration"),config:cn.integration,binding:sr})]);function zf(e){let n=w(e),t=p(n.flowId);if(n.version!=1||!Array.isArray(n.entries))return d();if(n.publication===null){if(n.inputDefs!==null||n.status!="not-published"||n.entries.length!=0||Object.hasOwn(n,"enabled"))return d();return{flowId:t,inputDefs:null,publication:null,status:"not-published",entries:[],version:1}}let r=at(n.publication),o=n.status;if(r.flowId!=t||typeof n.enabled!="boolean")return d();if(o!="runnable"&&o!="suspended")return d();if(!n.enabled&&n.status=="runnable")return d();let i=kf.safeParse(n.inputDefs);if(!i.success)return d();return{flowId:t,inputDefs:i.data,publication:r,status:o,enabled:n.enabled,entries:mw(n.entries,r),version:1}}function mw(e,n){let t=j(fw).safeParse(e);if(!t.success)return d();let r=new Set;for(let o of t.data){if(r.has(o.nodeId))return d();if(r.add(o.nodeId),o.type!="start"&&o.type!="manual"&&(o.binding.flowId!=n.flowId||o.binding.triggerNodeId!=o.nodeId||o.binding.kind!=o.type||o.binding.currentPublicationId!=n.publicationId||o.binding.currentRevisionId!=n.revisionId))return d();if(o.type=="webhook"&&(!o.binding.endpointUrl||!Hr(o.config.method)&&Object.keys(o.config.body).length>0))return d()}return t.data}function bo(e,n){if(!e||typeof e!="object"||!n||typeof n!="object")return{};let t=e,r=n;if(typeof t.version!="string"||![t.pixelRatio,t.iconSize,t.width,t.height].every((o)=>Number.isInteger(o)&&o>0)||![t.bleed,r.x,r.y].every((o)=>Number.isInteger(o)&&o>=0)||r.x+t.iconSize>t.width||r.y+t.iconSize>t.height)return{};try{for(let o of[t.lightUrl,t.darkUrl])if(typeof o!="string"||!["https:","http:","data:"].includes(new URL(o).protocol))return{}}catch{return{}}return{iconSprite:t,iconSpritePosition:{x:r.x,y:r.y}}}function Df(e,n){let t=e=="feishu_app_bot.on_event"?["sourceId","eventTypes","resource","chatIds"]:e=="linear.on_issue_changed"?["teamId","stateIds"]:[];return{...n,...Object.fromEntries(t.map((r)=>[r,{kind:"unset"}]))}}function Vf(e,n){return{...e,nodes:Object.fromEntries(Object.entries(e.nodes).map(([t,r])=>{if((r.kind=="poll"||r.kind=="integration")&&(n==null||r.connectionId==n)){let{connectionId:i,...s}=r;return[t,s]}if(r.kind!="task")return[t,r];if("executor"in r.task){let i=r.task.executor,s=(a)=>{if(a.connectionId==="")return a;if(n!=null&&a.connectionId!=n)return a;let{connectionId:c,...u}=a;return u};if(i.kind=="connector")return[t,{...r,task:{...r.task,executor:s(i)}}];if(i.kind=="agent")return[t,{...r,task:{...r.task,executor:{...i,tools:i.tools.map(s),...i.notification==null?{}:{notification:s(i.notification)}}}}];return[t,r]}let o=r.task.capabilities?.map((i)=>{if(!("mode"in i)){if("action"in i){let{connectionId:s,...a}=i;return{...a,connections:i.connections.filter((c)=>n!=null&&c.connectionId!=n),...s!=null&&n!=null&&s!=n?{connectionId:s}:{}}}return{...i,...n==null&&(i.connectionHints?.length??0)>0?{actionHints:[...new Set([...i.actionHints??[],...i.connectionHints.map((s)=>s.action)])]}:{},...i.connectionHints==null?{}:{connectionHints:i.connectionHints.filter((s)=>n!=null&&s.connectionId!=n)}}}if(i.mode!="independent")return i;return{...i,actions:i.actions.map((s)=>{if(s.connectionId==="")return s;if(n!=null&&s.connectionId!=n)return s;let{connectionId:a,...c}=s;return c})}});return[t,o==null?r:{...r,task:{...r.task,capabilities:o}}]}))}}var gw=v({kind:x("open-flow-workflow"),version:x(1),name:R().optional(),content:Wn(),presentation:ee(R(),_e()).optional()});function wo(e){Pn(e,-1);let n=gw.parse(e);return{...n,content:Xn(n.content)}}function Zf(e){return wo(JSON.parse(e))}function Mf(e){if(e.kind!="sources"||!e.sources.some((t)=>t.kind=="binding"))return e;let n=e.sources.filter((t)=>t.kind!="binding");return n.length==0?{kind:"unset"}:{kind:"sources",sources:n}}function hw(e){let n=wo(e),t=n.content.document.graph,r=Vf(t),o=Object.fromEntries(Object.entries(r.nodes).map(([i,s])=>{let a=s;if("inputs"in a)a={...a,inputs:Object.fromEntries(Object.entries(a.inputs).map(([c,u])=>[c,Mf(u)]))};if(a.kind=="outputs")a={...a,outputMappings:Object.fromEntries(Object.entries(a.outputMappings).map(([c,u])=>[c,Mf(u)]))};if(a.kind=="condition")a=hp(a);if(a.kind=="error"&&a.sourceFlowIds!=null)a={...a,sourceFlowIds:[]};if(a.kind=="poll"||a.kind=="integration")a={...a,config:Df(a.definition.key,a.config)};return[i,a]}));return{file:{...n,content:{...n.content,document:{...n.content.document,bindings:{},graph:{...r,nodes:o}}}},summary:{changedNodeIds:Object.keys(o).filter((i)=>!ve(o[i],t.nodes[i])),removedBindings:Object.keys(n.content.document.bindings).length}}}function Ff(e){return`${JSON.stringify(hw(e).file,null,2)}
|
|
59
|
+
`}function Jf(e){return e.replace(/(?:\.openflow)?\.json$/i,"")}var bw=jn("kind",[v({kind:x("admin-delegation")}),v({kind:x("policy"),ruleId:R().min(1).nullable()})]);function xo(e){return bw.parse(e)}function Uf(e){let n=w(e);if(!Array.isArray(n.bots))return d("Leina bots: expected an array.");let t=n.bots.map((r)=>{let o=w(r);if(!Array.isArray(o.platforms))return d("Leina platforms: expected an array.");return{leinaId:p(o.leinaId),name:p(o.name),status:p(o.status),platforms:o.platforms.map(p)}});if(new Set(t.map((r)=>r.leinaId)).size!=t.length)return d("Leina bots: duplicate identifiers.");return t}function ww(e){let n=w(e);if(Ke(n,["actionIds","allActions","triggerIds","allTriggers","configured","proxy"]),!Array.isArray(n.actionIds))return d("permissions.actionIds: expected an array.");if(!Array.isArray(n.triggerIds))return d("permissions.triggerIds: expected an array.");if(typeof n.allActions!="boolean")return d("permissions.allActions: expected a boolean.");if(typeof n.allTriggers!="boolean")return d("permissions.allTriggers: expected a boolean.");if(typeof n.configured!="boolean")return d("permissions.configured: expected a boolean.");if(typeof n.proxy!="boolean")return d("permissions.proxy: expected a boolean.");let t=n.actionIds.map(p),r=n.triggerIds.map(p);if(new Set(t).size!=t.length)return d("permissions.actionIds: duplicate IDs.");if(n.allActions&&t.length!=0)return d("permissions.actionIds: must be empty when allActions is true.");if(new Set(r).size!=r.length)return d("permissions.triggerIds: duplicate IDs.");if(n.allTriggers&&r.length!=0)return d("permissions.triggerIds: must be empty when allTriggers is true.");if(n.proxy&&(!n.allActions||!n.allTriggers||n.configured))return d("permissions.proxy: requires allActions=true, allTriggers=true and configured=false.");return{actionIds:t,triggerIds:r,allTriggers:n.allTriggers,allActions:n.allActions,configured:n.configured,proxy:n.proxy}}function Bf(e,n){let t=w(e),{policyRevision:r,status:o,isDefault:i}=t,s=Object.hasOwn(t,"displayName")&&!Object.hasOwn(t,"connectionDisplayName"),a=n&&Object.hasOwn(t,"permissions")?ww(t.permissions):void 0,c=t.permissionGroupName;if(Ke(t,["accessBindingId","connectionId","source",s?"displayName":"connectionDisplayName",...n&&Object.hasOwn(t,"isDefault")?["isDefault"]:[],...n&&a!=null?["permissions"]:[],...Object.hasOwn(t,"permissionGroupName")?["permissionGroupName"]:[],...r==null?[]:["policyRevision"],"providerId",...n?[]:["status"]]),r!=null&&typeof r!="string")return d("policyRevision: expected a string.");if(n&&i!==void 0&&typeof i!="boolean")return d("isDefault: expected a boolean.");if(c!==void 0&&c!==null&&typeof c!="string")return d("permissionGroupName: expected a string or null.");if(!n&&o!="active"&&o!="forbidden"&&o!="invalid"&&o!="missing")return d();let u;try{u=xo(t.source)}catch{return d("source: expected { kind: 'admin-delegation' } or { kind: 'policy', ruleId: string | null }.")}return{accessBindingId:p(t.accessBindingId),connectionId:p(t.connectionId),source:u,connectionDisplayName:p(s?t.displayName:t.connectionDisplayName),...n&&typeof i=="boolean"?{isDefault:i}:{},...a==null?{}:{permissions:a},...c===void 0?{}:{permissionGroupName:c},...r==null?{}:{policyRevision:r},providerId:p(t.providerId),...n?{}:{status:o}}}function Us(e){if(e!="implicit"&&e!="selectable")return d("mode: expected implicit or selectable.");return e}function ct(e){let n=w(e);Ke(n,["accessRevision","bindings","mode","sharedAccessDigest",..."providerIds"in n?["providerIds"]:[],..."discardedBindingCount"in n?["discardedBindingCount"]:[],"version"]);let t=ne(n.accessRevision);if(n.version!=1||t<0||!Array.isArray(n.bindings))return d();if("providerIds"in n&&!Array.isArray(n.providerIds))return d();let r=n.providerIds==null?void 0:n.providerIds.map((s)=>p(s));if(r!=null&&new Set(r).size!=r.length)return d();let o=n.discardedBindingCount==null?0:ne(n.discardedBindingCount);if(o<0)return d();let i=[];for(let s of n.bindings)try{i.push(Bf(s,!1))}catch(a){if(!(a instanceof Ee)||a.code!="response.invalid")throw a;if(s!=null&&typeof s=="object"&&!Array.isArray(s)&&typeof s.accessBindingId=="string"&&s.accessBindingId.length>0&&typeof s.providerId=="string"&&s.providerId.length>0)i.push({accessBindingId:s.accessBindingId,providerId:s.providerId,connectionId:null,source:null,status:"invalid",connectionDisplayName:typeof s.connectionDisplayName=="string"&&s.connectionDisplayName.length>0?s.connectionDisplayName:typeof s.displayName=="string"&&s.displayName.length>0?s.displayName:s.providerId,permissionGroupName:typeof s.permissionGroupName=="string"?s.permissionGroupName:null});else o++}if(new Set(i.map((s)=>s.accessBindingId)).size!=i.length)return d();return{accessRevision:t,...o==0?{}:{discardedBindingCount:o},...r==null?{}:{providerIds:r},bindings:i,mode:Us(n.mode),sharedAccessDigest:p(n.sharedAccessDigest),version:1}}function Lf(e){if(!Array.isArray(e))return d();let n=e.map((t)=>{let r=w(t);Ke(r,["accessBindingId","connectionId","providerId","source","connectionDisplayName",..."permissionGroupName"in r?["permissionGroupName"]:[]]);let o;try{o=xo(r.source)}catch{return d()}if(r.permissionGroupName!=null&&typeof r.permissionGroupName!="string")return d();return{accessBindingId:p(r.accessBindingId),connectionId:p(r.connectionId),providerId:p(r.providerId),source:o,connectionDisplayName:p(r.connectionDisplayName),..."permissionGroupName"in r?{permissionGroupName:r.permissionGroupName}:{}}});if(new Set(n.map((t)=>t.accessBindingId)).size!=n.length)return d();return n}function Bs(e){let n=w(e);if(Ke(n,["mode","sharedAccessDigest","sharedBindings","selectedBindings","version"]),n.version!=2)return d();let t=Us(n.mode),r=Lf(n.sharedBindings),o=Lf(n.selectedBindings);if(t=="implicit"&&(r.length>0||o.length>0))return d();return{mode:t,sharedAccessDigest:p(n.sharedAccessDigest),sharedBindings:r,selectedBindings:o,version:2}}function xw(e,n){let t=w(e);if(Ke(t,["candidates","mode","providerId","version"]),t.version!=1)return d("version: expected 1.");if(p(t.providerId)!=n)return d("providerId: does not match the requested provider.");if(!Array.isArray(t.candidates))return d("candidates: expected an array.");let r=t.candidates.map((o)=>Bf(o,!0));if(r.some((o)=>o.providerId!=n))return d("candidates[].providerId: does not match the requested provider.");if(new Set(r.map((o)=>o.accessBindingId)).size!=r.length)return d("candidates[].accessBindingId: duplicate IDs.");return{candidates:r,mode:Us(t.mode),providerId:n,version:1}}function Kf(e,n){let t=w(e);if(Ke(t,["results","version"]),t.version!=1)return d("version: expected 1.");if(!Array.isArray(t.results))return d("results: expected an array.");let r=new Set(n),o=t.results.map((i)=>{let s=w(i),a=p(s.providerId);if(!r.delete(a))return d("results[].providerId: duplicate or unrequested provider.");if(!Object.hasOwn(s,"error"))return xw(s,a);Ke(s,["providerId","error"]);let c=w(s.error);return Ke(c,["code","message"]),{providerId:a,error:{code:p(c.code),message:p(c.message)}}});if(r.size!=0)return d("results: missing requested providers.");return{results:o,version:1}}function ut(e){let n=w(e);if(U(n,[...Object.hasOwn(n,"providerAccountId")?["providerAccountId"]:[],...Object.hasOwn(n,"alias")?["alias"]:[],...Object.hasOwn(n,"builtInAccount")?["builtInAccount"]:[],"connectionId","displayName","isDefault","serviceId","status"]),n.builtInAccount!==void 0&&typeof n.builtInAccount!="boolean")return d();let t=n.status;if(t!="active"&&t!="disconnected"&&t!="error"&&t!="reauth_required")return d();if(typeof n.isDefault!="boolean")return d();return{...n.providerAccountId===void 0?{}:{providerAccountId:p(n.providerAccountId)},...n.alias===void 0?{}:{alias:p(n.alias)},...n.builtInAccount===void 0?{}:{builtInAccount:n.builtInAccount},connectionId:p(n.connectionId),displayName:p(n.displayName),isDefault:n.isDefault,serviceId:p(n.serviceId),status:t}}function Wf(e,n=!1){let t=w(e),r=t.description,o=n&&Object.hasOwn(t,"value");if(U(t,["jsonSchema","nullable",...r==null?[]:["description"],...o?["value"]:[]]),r!=null&&typeof r!="string")return d();if(typeof t.nullable!="boolean")return d();return{...r==null?{}:{description:r},jsonSchema:be(t.jsonSchema),nullable:t.nullable,...o?{value:be(t.value)}:{}}}function vw(e){return Wf(e,!0)}function qf(e,n){return Object.fromEntries(Object.entries(w(e)).map(([t,r])=>[t,n(r)]))}function kw(e){let n=w(e),{homepageUrl:t,icon:r}=n;if(U(n,["actionId",...Object.hasOwn(n,"operationType")?["operationType"]:[],...Object.hasOwn(n,"inputSchema")?["inputSchema"]:[],...Object.hasOwn(n,"outputSchema")?["outputSchema"]:[],"authenticated","description",...t==null?[]:["homepageUrl"],...r==null?[]:["icon"],..."iconSprite"in n?["iconSprite"]:[],..."iconSpritePosition"in n?["iconSpritePosition"]:[],"inputs","name","outputs","serviceId","serviceName"]),t!=null&&typeof t!="string"||r!=null&&typeof r!="string")return d();return{...n.inputSchema===void 0?{}:{inputSchema:be(n.inputSchema)},...n.outputSchema===void 0?{}:{outputSchema:be(n.outputSchema)},actionId:p(n.actionId),...n.operationType==null?{}:{operationType:p(n.operationType)},authenticated:typeof n.authenticated=="boolean"?n.authenticated:d(),description:typeof n.description=="string"?n.description:d(),...t==null?{}:{homepageUrl:t},...r==null?{}:{icon:r},...bo(n.iconSprite,n.iconSpritePosition),inputs:qf(n.inputs,vw),name:p(n.name),outputs:qf(n.outputs,Wf),serviceId:p(n.serviceId),serviceName:p(n.serviceName)}}function vo(e){let{defaultConnection:n,...t}=w(e),r=kw(t);if(n==null)return r;let o=ut(n);if(o.serviceId!=r.serviceId||o.status!="active")return d();return{...r,defaultConnection:o}}function Gf(e){let n=w(e),{homepageUrl:t,icon:r}=n;if(n.noSetup!==void 0&&typeof n.noSetup!="boolean")return d();if(U(n,[...Object.hasOwn(n,"noSetup")?["noSetup"]:[],"serviceId","serviceName",...t==null?[]:["homepageUrl"],...r==null?[]:["icon"],..."iconSprite"in n?["iconSprite"]:[],..."iconSpritePosition"in n?["iconSpritePosition"]:[]]),t!=null&&typeof t!="string"||r!=null&&typeof r!="string")return d();return{...t==null?{}:{homepageUrl:t},...r==null?{}:{icon:r},...bo(n.iconSprite,n.iconSpritePosition),serviceId:p(n.serviceId),serviceName:p(n.serviceName),...n.noSetup===void 0?{}:{noSetup:n.noSetup}}}function Ks(e){return{actionId:e.actionId,authenticated:e.authenticated,...e.defaultConnection==null?{}:{defaultConnection:{connectionId:e.defaultConnection.connectionId,displayName:e.defaultConnection.displayName,status:e.defaultConnection.status}},description:e.description,name:e.name,serviceId:e.serviceId,serviceName:e.serviceName}}var Dn=R().min(1).max(256),Cw=R().regex(/^[a-z][a-z0-9_.]{0,127}$/),Ew=R().trim().min(1).max(128),Qf=I({version:x(1),sourceId:Dn,revision:ge().positive(),name:Ew,provider:ce(["feishu","feishu_app_bot"]),appId:Dn,connectionId:Dn,teamId:Dn.nullable(),enabled:le(),eventTypes:j(Cw),manageSubscriptions:le(),verificationTokenConfigured:le(),encryptKeyConfigured:le(),endpointUrl:R().nullable(),verifiedAt:R().nullable(),lastReceivedAt:R().nullable(),updatedAt:R(),consumers:j(I({flowId:Dn,flowName:R(),triggerNodeId:Dn}))});function ko(e){return Qf.parse(e)}function Ws(e){return I({version:x(1),sources:j(Qf),teamId:Dn.nullable().optional()}).parse(e)}function Gs(e){let n=w(e);if(U(n,["version","locale","definitions","display"]),n.version!=3||!Ca(n.locale)||!Array.isArray(n.definitions))return d();let t=n.definitions.map(or),r=w(n.display),o=new Set(t.map((s)=>s.key));if(o.size!=t.length||Object.keys(r).length!=o.size)return d();let i=Object.fromEntries(t.map((s)=>{let{key:a}=s,c=w(r[a]);return U(c,["configInputs","configInputLabels","displayName","description","outputs"]),[a,{configInputs:Yf(c.configInputs,s.configInputs.flatMap((u)=>("handle"in u)?[u.handle]:[])),configInputLabels:Ow(c.configInputLabels,s.configInputs.flatMap((u)=>("handle"in u)?[u.handle]:[])),displayName:p(c.displayName),description:p(c.description),outputs:Yf(c.outputs,s.outputs.map((u)=>u.handle))}]}));return{version:3,locale:n.locale,definitions:t,display:i}}function Yf(e,n){let t=w(e);return Ke(t,n),Object.fromEntries(Object.entries(t).map(([r,o])=>[r,p(o)]))}function Ow(e,n){let t=w(e);if(Object.keys(t).some((r)=>!n.includes(r)))return d();return Object.fromEntries(Object.entries(t).map(([r,o])=>{let i=p(o);return i.trim().length==0?d():[r,i]}))}function Hs(e,n){if(n==null)return e;let t=n.toLowerCase();return e.filter((r)=>[r.description,r.displayName,r.key,r.name,r.provider,r.type].some((o)=>o.toLowerCase().includes(t)))}var Rw=v({pointer:R().max(4096).default(""),offset:ue().int().nonnegative().default(0),limit:ue().int().min(1).max(100).default(20),maxBytes:ue().int().min(1).max(1048576).default(15000)});var Aw=_e(),Xf=I({pointer:R(),type:ce(["object","array","string","number","boolean","null"]),length:ue().int().nonnegative().optional(),complete:le(),value:Aw.optional()}),jw=Xf.extend({offset:ue().int().nonnegative(),nextOffset:ue().int().positive().optional(),entries:j(Xf).optional()}),em=I({resultId:R().min(1),callId:R().min(1),toolId:R().min(1),source:jn("kind",[I({kind:x("connector"),action:R().min(1)}),I({kind:x("code")})]),bytes:ue().int().nonnegative(),digest:R().regex(/^[a-f0-9]{64}$/),createdAt:R().datetime()}),Pw=I({version:x(1),runId:R(),results:j(em),nextAfter:R().optional()}),$w=I({version:x(1),runId:R(),result:em,page:jw});function Qs(e){return Pw.parse(e)}function Ys(e){return $w.parse(e)}function nm(e){if(!Array.isArray(e))return d();return e.map((n)=>typeof n=="string"||Number.isSafeInteger(n)?n:d())}function _w(e){let n=w(e),t=p(n.kind);if(t=="artifact"||t=="binary"||t=="nullable")return{kind:t};if(t=="schema")return{kind:t,path:n.path==null?void 0:nm(n.path)};if(t!="keyword"||typeof n.keyword!="string"||!fs(n.keyword))return d();return{kind:t,keyword:n.keyword,path:nm(n.path),source:n.source===void 0?void 0:be(n.source),target:n.target===void 0?void 0:be(n.target)}}function Tw(e){let n=w(e),t=n.values==null?void 0:w(n.values);return{code:p(n.code),column:ne(n.column),...n.fields===void 0?{}:{fields:Array.isArray(n.fields)?n.fields.map(p):d()},line:ne(n.line),message:p(n.message),mismatch:n.mismatch==null?void 0:_w(n.mismatch),path:typeof n.path=="string"?n.path:d(),...t==null?{}:{values:Object.fromEntries(Object.entries(t).map(([r,o])=>[r,typeof o=="string"||typeof o=="number"?o:d()]))}}}function tm(e){let n=w(e);if(n.version!=1||typeof n.valid!="boolean"||!Array.isArray(n.diagnostics))return d();return{closureDigest:p(n.closureDigest),diagnostics:n.diagnostics.map(Tw),engineContract:p(n.engineContract),flowId:p(n.flowId),modelVersion:ne(n.modelVersion),revisionDigest:p(n.revisionDigest),revisionId:p(n.revisionId),valid:n.valid,version:1}}var rm=(e)=>e==null?"":`?flowId=${encodeURIComponent(e)}`;function om(e,n){let t=new URLSearchParams({...e==null?{}:{flowId:e},...n==null?{}:{locale:n}}).toString();return{path:`/v1/connector/providers${t?`?${t}`:""}`,decode:(r)=>{let o=w(r);if(U(o,["providers","version"]),o.version!=1||!Array.isArray(o.providers))return d();return o.providers.map(Gf)}}}function im(e,n,t){let r=new URLSearchParams({...n==null?{}:{flowId:n},...t==null?{}:{locale:t}}).toString();return{path:`/v1/connector/actions/${encodeURIComponent(e)}${r?`?${r}`:""}`,decode:(o)=>{let i=w(o);if(U(i,["action","version"]),i.version!=1)return d();return vo(i.action)}}}function sm(e){return{path:`/v1/connector/connections${rm(e)}`,decode:(n)=>{let t=w(n);if(U(t,["connections","version"]),t.version!=1||!Array.isArray(t.connections))return d();return t.connections.map(ut)}}}function am(e,n){return{path:`/v1/connector/connections/${encodeURIComponent(e)}${rm(n)}`,decode:(t)=>{let r=w(t);if(U(r,["connections","serviceId","version"]),r.version!=1||p(r.serviceId)!=e||!Array.isArray(r.connections))return d();return r.connections.map(ut)}}}function So(e){return Array.isArray(e)?e.map(p):d()}function Nw(e){let n=w(e),t=n.draft===null?null:w(n.draft),r=w(n.sharedAccess);if(t!=null&&!Array.isArray(t.connections))return d();if(!Array.isArray(r.bindings))return d();let o=ne(r.accessRevision);if(o<0)return d();return{draft:t==null?null:{...t.calledFlowIds===void 0?{}:{calledFlowIds:So(t.calledFlowIds)},variableNames:So(t.variableNames),errorSourceFlowIds:So(t.errorSourceFlowIds),connections:t.connections.map((i)=>{let s=w(i);return{providerId:p(s.providerId),connectionId:p(s.connectionId)}})},sharedAccess:{accessRevision:o,providerIds:So(r.providerIds),bindings:r.bindings.map((i)=>{let s=w(i);return{providerId:p(s.providerId),connectionId:s.connectionId===null?null:p(s.connectionId),accessBindingId:p(s.accessBindingId)}})}}}function un(e){let n=w(e),t=n.status;if(n.version!=1)return d();if(t!="active"&&t!="retiring")return d();let r=n.live==null?void 0:w(n.live);if(r!=null&&(typeof r.enabled!="boolean"||typeof r.hasStart!="boolean"))return d();return{...r==null?{}:{live:{enabled:r.enabled,hasStart:r.hasStart,publicationId:p(r.publicationId),revisionId:p(r.revisionId)}},createdAt:p(n.createdAt),...n.connectorTeamId==null?{}:{connectorTeamId:p(n.connectorTeamId)},draftRevisionId:p(n.draftRevisionId),resourceReferences:Nw(n.resourceReferences),flowId:p(n.flowId),name:p(n.name),status:t,updatedAt:p(n.updatedAt),version:1}}function zw(e){let n=w(e),t=ne(n.referenceCount);if(t<0)return d();return{...un(n),referenceCount:t}}function cm(e){let n=w(e);if(n.version!=1||!Array.isArray(n.flows))return d();let{nextCursor:t,total:r}=n;if(t!=null&&typeof t!="string")return d();if(r!=null&&!Number.isSafeInteger(r))return d();return{...t==null?{}:{nextCursor:t},flows:n.flows.map(zw),...r==null?{}:{total:r},version:1}}function Io(e){let n=w(e);if(U(n,["name","updatedAt","value","version"]),n.version!=1||typeof n.value!="string")return d();let t=p(n.updatedAt);try{if(new Date(t).toISOString()!=t)return d()}catch{return d()}return{name:p(n.name),updatedAt:t,value:n.value,version:1}}function um(e){let n=w(e),{referenceCount:t,...r}=n,o=ne(t);if(o<0)return d();return{...Io(r),referenceCount:o}}function lm(e){let n=w(e);if(typeof n.enabled!="boolean")return d();return{flowId:p(n.flowId),flowName:p(n.flowName),nodeId:p(n.nodeId),nodeName:p(n.nodeName),enabled:n.enabled}}function dm(e){let n=w(e);if(U(n,["version","references"]),n.version!=1||!Array.isArray(n.references))return d();return{version:1,references:n.references.map((t)=>{let r=w(t);if(U(r,["flowId","flowName","draft","live"]),typeof r.draft!="boolean")return d();let o=r.live===null?null:w(r.live);if(o!=null){if(U(o,["publicationId","enabled"]),typeof o.enabled!="boolean")return d()}return{flowId:p(r.flowId),flowName:p(r.flowName),draft:r.draft,live:o==null?null:{publicationId:p(o.publicationId),enabled:o.enabled}}})}}function pm(e){let n=w(e),t=n.parentRevisionId;if(n.version!=1||t!==null&&typeof t!="string")return d();return{actorId:p(n.actorId),createdAt:p(n.createdAt),digest:p(n.digest),flowId:p(n.flowId),modelVersion:ne(n.modelVersion),parentRevisionId:t,revisionId:p(n.revisionId),version:1}}function ar(e){let n=w(e);try{return{...pm(n),content:Xn(n.content)}}catch{return d()}}function Co(e){let n=w(e);if(n.version!=1||ne(n.revision)<1)return d();return{revision:ne(n.revision),updatedAt:p(n.updatedAt),value:Object.fromEntries(Object.entries(w(n.value)).map(([t,r])=>[t,be(r)])),version:1}}function cr(e){let n=w(e);if(n.version!=1)return d();return{revision:pm(n.revision),version:1}}function fm(e){let n=w(e);if(n.version!=1||n.kind!="snapshot")return d();return{draft:ar(n.draft),kind:"snapshot",version:1}}var Dw=["canceled","completed","failed","indeterminate"],Eo=[...Dw,"queued","running","starting","waiting"];var Vw=new Set(Eo);function Oo(e){return typeof e=="string"&&Vw.has(e)?e:d()}function hm(e){let n=w(e),{source:t,startedAt:r,finishedAt:o}=n;if(n.version!=1||t!="draft"&&t!="live")return d();if(r!=null&&typeof r!="string")return d();if(o!=null&&typeof o!="string")return d();return{createdAt:p(n.createdAt),...o==null?{}:{finishedAt:o},flowId:p(n.flowId),revisionId:p(n.revisionId),runId:p(n.runId),source:t,...r==null?{}:{startedAt:r},status:Oo(n.status),version:1}}function Mw(e){let n=w(e);U(n,["actions","expiresAt","nodeId","prompt","waitId","waitingSince"]);let t=n.actions;if(!Array.isArray(t)||!(t.length==1&&t[0]=="continue"||t.length==2&&t[0]=="approve"&&t[1]=="reject"))return d();return{actions:t,expiresAt:p(n.expiresAt),nodeId:p(n.nodeId),prompt:p(n.prompt),waitId:p(n.waitId),waitingSince:p(n.waitingSince)}}function mm(e){let n=w(e);return{flowId:p(n.flowId),runId:p(n.runId),nodeId:p(n.nodeId),executionId:p(n.executionId)}}function Zw(e){let n=w(e);if(!["workbench","cli","mcp","api","trigger","workflow"].includes(n.channel))return d();return{channel:n.channel,...n.actorId===void 0?{}:{actorId:p(n.actorId)}}}function Ro(e){let n=w(e),t=hm(n),r=n.eventsExpiresAt;if(r!=null&&typeof r!="string")return d();if(n.waiting!==void 0||!Array.isArray(n.waits))return d();let o=n.waits.map(Mw);if(new Set(o.map((a)=>a.waitId)).size!=o.length||t.status=="waiting"&&o.length==0&&(!Array.isArray(n.calls)||n.calls.length==0)||["completed","failed","canceled","indeterminate"].includes(t.status)&&o.length>0)return d();if(n.occurrenceId!==void 0&&n.triggerNodeId===void 0)return d();let i={status:t.status,waits:o};if(n.calls!==void 0&&!Array.isArray(n.calls))return d();let s={...t,...n.initiator===void 0?{}:{initiator:Zw(n.initiator)},...Fw(n),...n.triggerNodeId===void 0?{}:{triggerNodeId:p(n.triggerNodeId)},...n.caller===void 0?{}:{caller:mm(n.caller)},...n.calls===void 0?{}:{calls:n.calls.map((a)=>Object.assign(mm(a),{status:w(a).status===null?null:Oo(w(a).status)}))},closureDigest:p(n.closureDigest),engineContract:p(n.engineContract),engineDigest:p(n.engineDigest),...r==null?{}:{eventsExpiresAt:r},modelVersion:ne(n.modelVersion),sharedAccessDigest:p(n.sharedAccessDigest),revisionDigest:p(n.revisionDigest),...i};switch(t.source){case"draft":return{...s,source:"draft"};case"live":return{...s,publicationId:p(n.publicationId),source:"live",...n.occurrenceId===void 0?{}:{occurrenceId:p(n.occurrenceId),triggerNodeId:p(n.triggerNodeId)}}}}function ym(e){let n=w(e),t=n.nextCursor;if(n.version!=1||!Array.isArray(n.runs))return d();if(t!=null&&typeof t!="string")return d();return{flowId:p(n.flowId),...t==null?{}:{nextCursor:t},runs:n.runs.map(hm),version:1}}function bm(e){let n=w(e),t=Oo(n.status);if(n.version!=1||typeof n.cancelAccepted!="boolean"||t=="queued"||t=="starting"||t=="running"||t=="waiting")return d();return{cancelAccepted:n.cancelAccepted,runId:p(n.runId),status:t,version:1}}function wm(e){let n=w(e);U(n,["action","comment","resolutionAccepted","resolvedAt","runId","status","version","waitId"]);let{action:t,resolvedAt:r}=n;if(n.version!=1||typeof n.resolutionAccepted!="boolean"||n.comment!==null&&typeof n.comment!="string"||t!==null&&t!="approve"&&t!="continue"&&t!="reject"||r!==null&&typeof r!="string"||t===null!=(r===null)||n.resolutionAccepted&&t===null)return d();return{action:t,comment:n.comment,resolutionAccepted:n.resolutionAccepted,resolvedAt:r,runId:p(n.runId),status:Oo(n.status),version:1,waitId:p(n.waitId)}}function xm(e){let n=w(e),t=n.status;if(n.version!=1)return d();let r={finishedAt:p(n.finishedAt),runId:p(n.runId),version:1};if(t=="completed"){if(!Object.hasOwn(n,"result"))return d();return{...r,result:n.result,status:"completed"}}if(t=="canceled")return{...r,status:"canceled"};if(t=="failed"){let o=w(n.error);return{...r,error:gm(o),status:"failed"}}if(t=="indeterminate"){let o=w(n.error);return{...r,error:gm(o),status:"indeterminate"}}return d()}function Fw(e){let n=e.errorSource==null?void 0:w(e.errorSource);if(e.errorDispatches!=null&&!Array.isArray(e.errorDispatches))return d();return{...n==null?{}:{errorSource:{flowId:p(n.flowId),runId:p(n.runId)}},...e.errorDispatches==null?{}:{errorDispatches:e.errorDispatches.map((t)=>{let r=w(t),o=p(r.flowId);switch(r.status){case"pending":return{status:"pending",flowId:o};case"dispatched":return{status:"dispatched",flowId:o,runId:p(r.runId)};case"failed":return{status:"failed",flowId:o,message:p(r.message)};default:return d()}})}}}function gm(e){return{code:p(e.code),message:p(e.message),...e.nodeId===void 0?{}:{nodeId:p(e.nodeId)},...e.jobId===void 0?{}:{jobId:p(e.jobId)},...e.path===void 0?{}:{path:(Array.isArray(e.path)?e.path:d()).map(p)}}}function Ao(){let e=globalThis.crypto;if(e!=null){try{if(typeof e.randomUUID=="function")return e.randomUUID()}catch{}if(typeof e.getRandomValues=="function"){let n=e.getRandomValues(new Uint8Array(16));n[6]=(n[6]??0)&15|64,n[8]=(n[8]??0)&63|128;let t=Array.from(n,(r)=>r.toString(16).padStart(2,"0")).join("");return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}}return`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}function km(e){return e?.kind=="run.completed"||e?.kind=="run.failed"||e?.kind=="run.canceled"||e?.kind=="run.indeterminate"}function Jw(e){let n=w(e),t=ne(n.sequence);if(t<0)return d();let r={createdAt:p(n.createdAt),sequence:t},o=w(n.payload),i=n.kind;switch(i){case"run.queued":return{...r,kind:i,payload:{}};case"run.started":return{...r,kind:i,payload:{flowId:p(o.flowId),scopeId:p(o.scopeId),...o.parentScopeId===void 0?{}:{parentScopeId:p(o.parentScopeId)}}};case"run.progress":return{...r,kind:i,payload:{flowId:p(o.flowId),scopeId:p(o.scopeId),progress:vm(o.progress)}};case"run.waiting":if(!Array.isArray(o.waitIds))return d();return{...r,kind:i,payload:{waitIds:o.waitIds.map((s)=>p(s))}};case"wait.created":return{...r,kind:i,payload:{expiresAt:p(o.expiresAt),nodeId:p(o.nodeId),waitId:p(o.waitId),waitingSince:p(o.waitingSince)}};case"run.resolved":{let s=o.action;if(s!=="approve"&&s!=="continue"&&s!=="reject")return d();if(o.comment!==null&&typeof o.comment!="string")return d();return{...r,kind:i,payload:{action:s,comment:o.comment,resolvedAt:p(o.resolvedAt),waitId:p(o.waitId)}}}case"run.completed":case"run.canceled":case"run.failed":case"run.indeterminate":return{...r,kind:i,payload:{result:be(o.result)}};case"run.events-truncated":return{...r,kind:i,payload:Object.fromEntries(Object.entries(o).map(([s,a])=>[s,be(a)]))};case"node.started":case"node.completed":case"node.failed":case"node.log":case"node.progress":case"node.artifact":{let s={flowId:p(o.flowId),scopeId:p(o.scopeId),nodeId:p(o.nodeId),executionId:p(o.executionId)};switch(i){case"node.started":{let a=o.nodeKind;if(a!==void 0&&a!=="approval"&&a!=="condition"&&a!=="connector"&&a!=="javascript"&&a!=="decision"&&a!=="openapi"&&a!=="llm"&&a!=="agent"&&a!=="value"&&a!=="outputs"&&a!=="workflow"&&a!=="wait")return d();return{...r,kind:i,payload:{...s,...a===void 0?{}:{nodeKind:a},...o.nodeTitle===void 0?{}:{nodeTitle:p(o.nodeTitle)},...o.operation===void 0?{}:{operation:p(o.operation)}}}}case"node.completed":return{...r,kind:i,payload:{...s,outputs:Object.fromEntries(Object.entries(w(o.outputs)).map(([a,c])=>[a,be(c)]))}};case"node.failed":{let a=w(o.error);return{...r,kind:i,payload:{...s,error:{code:p(a.code),message:p(a.message)}}}}case"node.log":{let a=o.level;if(a!=="debug"&&a!=="info"&&a!=="warn"&&a!=="error")return d();return{...r,kind:i,payload:{...s,level:a,message:p(o.message)}}}case"node.progress":return{...r,kind:i,payload:{...s,progress:vm(o.progress)}};case"node.artifact":{let a=w(o.artifact),c=ne(a.size),u=p(a.digest);if(a.kind!="artifact"||c<0||!/^sha256:[0-9a-f]{64}$/.test(u))return d();return{...r,kind:i,payload:{...s,artifact:{kind:"artifact",id:p(a.id),name:p(a.name),size:c,digest:u,...a.mediaType===void 0?{}:{mediaType:p(a.mediaType)}}}}}}}default:return d()}}function vm(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0&&e<=100?e:d()}function Lw(e){let n=w(e),t=n.eventsExpiresAt,r=ne(n.nextAfter);if(n.version!=1||!Array.isArray(n.events)||typeof n.done!="boolean"||typeof n.historyComplete!="boolean")return d();if(t!=null&&typeof t!="string")return d();if(r<0)return d();return{done:n.done,events:n.events.map(Jw),...t==null?{}:{eventsExpiresAt:t},historyComplete:n.historyComplete,nextAfter:r,runId:p(n.runId),version:1}}var O=encodeURIComponent;function Vn(e){return`${e}-${Ao()}`}class Xs{constructor(e,n="api"){this.channel=n,this.requestControl=e}async loadOpenApiDocument(e,n){let t=w(await this.request("/v1/openapi/document",{method:"POST",body:JSON.stringify({url:e,version:1}),signal:n}));if(t.version!=1)return d();return be(t.document)}async listFlows(e={}){let n=new URLSearchParams;if(e.cursor!=null)n.set("cursor",e.cursor);if(e.limit!=null)n.set("limit",String(e.limit));if(e.includeTotal!=null)n.set("includeTotal",String(e.includeTotal));let t=n.size==0?"":`?${n}`;return cm(await this.request(`/v1/flows${t}`,e.signal==null?void 0:{signal:e.signal}))}async listEventSources(e,n){return Ws(await this.request("/v1/event-sources"+(e==null?"":`?flowId=${O(e)}`),{signal:n}))}async listEventSourceConnections(e,n){let t=w(await this.request(`/v1/event-sources/connections${e==null?"":`?teamId=${O(e)}`}`,{signal:n}));if(U(t,["version","connections"]),t.version!=1||!Array.isArray(t.connections))return d();return t.connections.map(ut)}async createEventSource(e){return ko(await this.request("/v1/event-sources",{method:"POST",body:JSON.stringify(e)}))}async updateEventSource(e,n){return ko(await this.request(`/v1/event-sources/${O(e)}`,{method:"PUT",body:JSON.stringify(n)}))}async deleteEventSource(e,n){await this.request(`/v1/event-sources/${O(e)}`,{method:"DELETE",body:JSON.stringify({version:1,expectedRevision:n})})}async listVariables(){let e=w(await this.request("/v1/variables"));if(U(e,["variables","version"]),e.version!=1||!Array.isArray(e.variables))return d();return{variables:e.variables.map(um),version:1}}async getFlowReferences(e,n={}){let t=new URLSearchParams({direction:n.direction??"incoming",offset:String(n.offset??0),limit:String(n.limit??50)});return ff.parse(await this.request(`/v1/flows/${O(e)}/references?${t}`,{signal:n.signal}))}async getWorkflowContract(e,n){return pf.parse(await this.request(`/v1/flows/${O(e)}/call-contract`,{signal:n}))}async getVariableReferences(e,n){return dm(await this.request(`/v1/variables/${O(e)}/references`,{signal:n}))}async getVariable(e){return Io(await this.request(`/v1/variables/${O(e)}`))}async putVariable(e,n){return Io(await this.request(`/v1/variables/${O(e)}`,{body:JSON.stringify({value:n}),method:"PUT"}))}async deleteVariable(e){let n=w(await this.request(`/v1/variables/${O(e)}`,{method:"DELETE"}));if(U(n,["version"]),n.version!=1)return d()}async exportFlow(e){let n=await this.request(`/v1/flows/${O(e)}/export`);try{return wo(n)}catch{return d()}}async importFlow(e,n={}){return un(await this.request("/v1/flows/import",{method:"POST",headers:{"Idempotency-Key":n.idempotencyKey??`flow-${Ao()}`},body:JSON.stringify({file:e,name:n.name,teamId:n.teamId,version:1})}))}async createFlow(e,n=`flow-${Ao()}`,t){return un(await this.request("/v1/flows",{body:JSON.stringify({name:e,...t==null?{}:{teamId:t},version:1}),headers:{"idempotency-key":n},method:"POST"}))}async broadcastCanvas(e,n){let t=w(await this.request(`/v1/flows/${O(e)}/canvas`,{method:"POST",body:JSON.stringify({version:1,command:n})}));if(U(t,["version","flowId","broadcast"]),t.version!=1||t.broadcast!==!0||t.flowId!==e)return d();return{version:1,flowId:p(t.flowId),broadcast:!0}}async getFlow(e){return un(await this.request(`/v1/flows/${O(e)}`))}async getErrorListeners(e,n){let t=w(await this.request(`/v1/flows/${O(e)}/error-listeners`,{signal:n}));if(t.version!=1||!Array.isArray(t.listeners))return d();return t.listeners.map(lm)}async renameFlow(e,n){return un(await this.request(`/v1/flows/${O(e)}`,{body:JSON.stringify({name:n,version:1}),method:"PATCH"}))}async deleteFlow(e){return un(await this.request(`/v1/flows/${O(e)}`,{method:"DELETE"}))}async listTriggerKeys(e,n){let t=w(await this.request(`/v1/trigger-keys${n==null?"":`?locale=${encodeURIComponent(n)}`}`,{signal:e}));if(t.version!=1||!Array.isArray(t.keys))return d();return t.keys.map(Ls)}async listTriggerDefinitions(e){let n=w(await this.request("/v1/trigger-keys/catalog",{signal:e}));if(n.version!=2||!Array.isArray(n.definitions))return d();return n.definitions.map(or)}async readCatalog(e,n,t){let r=new Headers;if(n)r.set("if-none-match",n);let o=await this.response(e.path,{headers:r,signal:t},!0),i=o.headers.get("etag")?.trim()||null;if(o.status==304)return{modified:!1,etag:i};return{modified:!0,data:e.decode(await o.json()),etag:i}}async getTriggerCatalog(e,n,t){let r=new Headers;if(n?.etag)r.set("if-none-match",n.etag);let o=await this.response(`/v1/trigger-keys/catalog?locale=${encodeURIComponent(e)}`,{headers:r,signal:t},!0);if(o.status==304){if(n==null)return d();return{...n,etag:o.headers.get("etag")?.trim()||n.etag}}return{data:Gs(await o.json()),etag:o.headers.get("etag")?.trim()||null}}async getTriggerKey(e,n){let t=w(await this.request(`/v1/trigger-keys/${O(e)}`,{signal:n}));if(t.version!=1)return d();return or(t.definition)}async listFlowTriggerBindings(e,n){let t=w(await this.request(`/v1/flows/${O(e)}/triggers`,{signal:n}));if(t.version!=1||p(t.flowId)!=e||!Array.isArray(t.bindings))return d();return t.bindings.map(ir)}async getFlowTriggerBinding(e,n){return $f(await this.request(`/v1/flows/${O(e)}/triggers/${O(n)}`))}async listFlowTriggerActivities(e,n,t={}){let r=new URLSearchParams;if(t.cursor!=null)r.set("cursor",t.cursor);if(t.limit!=null)r.set("limit",String(t.limit));let o=r.size==0?"":`?${r}`;return _f(await this.request(`/v1/flows/${O(e)}/triggers/${O(n)}/activities${o}`))}async testFlowPollTrigger(e,n){return Tf(await this.request(`/v1/flows/${O(e)}/triggers/${O(n)}/test`,{body:JSON.stringify({version:1}),method:"POST"}))}async getEditor(e){let n=w(await this.request(`/v1/flows/${O(e)}/editor`));if(n.version!=1)return d();let t={flow:un(n.flow),draft:ar(n.draft),live:Js(n.live),presentation:Co(n.presentation),version:1};if(t.flow.flowId!=e||t.draft.flowId!=e||t.live.flowId!=e||t.flow.draftRevisionId!=t.draft.revisionId)return d();return t}async getPublicationPresentation(e,n,t){let r=w(await this.request(`/v1/flows/${O(e)}/publications/${O(n)}/presentation`,{signal:t}));if(r.version!=1)return d();return{version:1,presentation:r.presentation===null?null:Co(r.presentation)}}async getPresentation(e){return Co(await this.request(`/v1/flows/${O(e)}/presentation`))}async getDraft(e){return ar(await this.request(`/v1/flows/${O(e)}/draft`))}async syncDraft(e){return fm(await this.request(`/v1/flows/${O(e)}/draft/sync`))}async getRevision(e,n,t){return ar(await this.request(`/v1/flows/${O(e)}/revisions/${O(n)}`,{signal:t}))}async listTriggerConfigOptions(e,n,t,r){let o=w(await this.request(`/v1/flows/${O(e)}/triggers/${O(n)}/options/${O(t)}`,{signal:r}));if(U(o,["options","version"]),o.version!=1||!Array.isArray(o.options)||o.options.length>1000)return d();return o.options.map((i)=>{let s=w(i);U(s,["value","label",...s.color==null?[]:["color"]]);let a=s.color==null?void 0:p(s.color);if(a!=null&&!/^#[0-9a-fA-F]{6}$/.test(a))return d();return a==null?{value:p(s.value),label:p(s.label)}:{value:p(s.value),label:p(s.label),color:a}})}async listConnectorTeams(e){let n=w(await this.request("/v1/connector/teams",{signal:e}));if(U(n,["enabled","teams","version"]),n.version!=1||typeof n.enabled!="boolean"||!Array.isArray(n.teams))return d();return{enabled:n.enabled,teams:n.teams.map((t)=>{let r=w(t);if(U(r,["id","name","systemCreated"]),typeof r.systemCreated!="boolean")return d();return{id:p(r.id),name:p(r.name),systemCreated:r.systemCreated}}),version:1}}async listConnectorProviders(e,n,t){let r=om(n,t);return this.connectorRequest(r.path,"providers",e,r.decode)}async listLeinaBots(e,n){return Uf(await this.request(`/v1/connector/leina/bots?flowId=${O(e)}`,{signal:n}))}async removeConnectionUsage(e,n,t,r,o){return cr(await this.request(`/v1/flows/${O(e)}/connection-usage/remove`,{method:"POST",headers:{"idempotency-key":o},body:JSON.stringify({connectionId:n,expectedRevisionId:t,expectedAccessRevision:r,version:1})}))}async getConnectorAccess(e,n){return ct(await this.request(`/v1/flows/${O(e)}/connector-access`,{signal:n}))}async getPublishedConnectorAccess(e,n,t){return Bs(await this.request(`/v1/flows/${O(e)}/connector-access?publicationId=${O(n)}`,{signal:t}))}async listProviderAccessBindingCandidates(e,n,t){return Kf(await this.request(`/v1/flows/${O(e)}/connector-access/candidates/query`,{method:"POST",body:JSON.stringify({providerIds:n,version:1}),signal:t}),n)}async setConnectorService(e,n,t,r){return ct(await this.request(`/v1/flows/${O(e)}/connector-access/${O(n)}/service`,{body:JSON.stringify({expectedAccessRevision:r,version:1}),method:t?"PUT":"DELETE"}))}async addProviderAccessBinding(e,n,t,r){return ct(await this.request(`/v1/flows/${O(e)}/connector-access/${O(n)}`,{body:JSON.stringify({accessBindingId:t,expectedAccessRevision:r,version:1}),method:"PUT"}))}async removeProviderAccessBinding(e,n,t,r){return ct(await this.request(`/v1/flows/${O(e)}/connector-access/${O(n)}`,{body:JSON.stringify({accessBindingId:t,expectedAccessRevision:r,version:1}),method:"DELETE"}))}async listConnectorActions(e,n,t,r){return await this.connectorActions({...r==null?{}:{locale:r},...t==null?{}:{flowId:t},...e==null?{}:{service:e}},n)}async searchConnectorActions(e,n,t,r){return await this.connectorActions({...r==null?{}:{locale:r},...t==null?{}:{flowId:t},q:e.trim()},n)}async getConnectorAction(e,n,t,r,o=!1){let i=im(e,t,r);return this.connectorRequest(i.path,"actions",n,i.decode,o)}async listAllConnectorConnections(e,n,t=!1){let r=sm(n);return this.connectorRequest(r.path,"connections",e,r.decode,t)}async listConnectorConnections(e,n,t,r=!1){let o=am(e,t);return this.connectorRequest(o.path,"connections",n,o.decode,r)}async createConnectorConnectionPage(e,n,t){let r=new URLSearchParams;if(n!=null)r.set("flowId",n);if(t!=null)r.set("teamId",t);let o=w(await this.request(`/v1/connector/connections/${O(e)}/page${r.size==0?"":`?${r}`}`,{body:JSON.stringify({version:1}),method:"POST"}));if(U(o,["url","version"]),o.version!=1)return d();try{let i=new URL(p(o.url));if(i.protocol!="http:"&&i.protocol!="https:")return d();return i.href}catch{return d()}}async readAuthoring(e,n={}){return Of.parse(await this.request(`/v1/flows/${O(e)}/authoring/read`,{method:"POST",body:JSON.stringify(n)}))}async searchAuthoring(e,n){return Rf.parse(await this.request(`/v1/flows/${O(e)}/authoring/search`,{method:"POST",body:JSON.stringify(n)}))}async authoringSchema(e,n){return w(await this.request(`/v1/flows/${O(e)}/authoring/schema`,{method:"POST",body:JSON.stringify(n)}))}async editAuthoring(e,n){return Ef.parse(await this.request(`/v1/flows/${O(e)}/authoring/edit`,{method:"POST",headers:{"idempotency-key":n.requestId},body:JSON.stringify(n)}))}async checkAuthoring(e,n){return Cf.parse(await this.request(`/v1/flows/${O(e)}/authoring/check`,{method:"POST",body:JSON.stringify({revisionId:n})}))}async changeDraft(e,n,t,r=Vn("change")){return cr(await this.request(`/v1/flows/${O(e)}/draft/changes`,{body:JSON.stringify({expectedRevisionId:n,operations:t,version:1}),headers:{"idempotency-key":r},method:"POST"}))}async repairDraft(e,n,t=Vn("repair")){return cr(await this.request(`/v1/flows/${O(e)}/draft/repair`,{body:JSON.stringify({expectedRevisionId:n,version:1}),headers:{"idempotency-key":t},method:"POST"}))}async upgradeDraft(e,n,t={}){return cr(await this.request(`/v1/flows/${O(e)}/draft/upgrade`,{body:JSON.stringify({expectedRevisionId:n,version:1}),headers:{"idempotency-key":t.idempotencyKey??Vn("upgrade")},method:"POST"}))}async checkFlow(e,n){return tm(await this.request(`/v1/flows/${O(e)}/revisions/${O(n)}/check`,{body:JSON.stringify({engineContract:"open-flow-engine/v5",version:1}),method:"POST"}))}async getLiveDetails(e,n){let t=zf(await this.request(`/v1/flows/${O(e)}/live/details`,{signal:n}));if(t.flowId!=e)return d();return t}async getLive(e,n){return Js(await this.request(`/v1/flows/${O(e)}/live`,{signal:n}))}async listPublications(e,n={},t){let r=new URLSearchParams;if(n.cursor!=null)r.set("cursor",n.cursor);if(n.limit!=null)r.set("limit",String(n.limit));if(n.includeTotal!=null)r.set("includeTotal",String(n.includeTotal));let o=r.size==0?"":`?${r}`;return jf(await this.request(`/v1/flows/${O(e)}/publications${o}`,{signal:t}))}async createDraftRun(e,n,t){let r=Ro(await this.request(`/v1/flows/${O(e)}/revisions/${O(n)}/runs`,{body:JSON.stringify({engineContract:"open-flow-engine/v5",inputs:t.inputs??{},trigger:t.trigger,version:2}),headers:{"idempotency-key":t.idempotencyKey??Vn("run"),"x-open-flow-client":this.channel},method:"POST"}));return r.source=="draft"?r:d()}async createLiveRun(e,n){let t=Ro(await this.request("/v1/runs",{body:JSON.stringify({inputs:n.inputs??{},trigger:n.trigger,publicationId:e,version:2}),headers:{"idempotency-key":n.idempotencyKey??Vn("run"),"x-open-flow-client":this.channel},method:"POST"}));return t.source=="live"?t:d()}async setFlowEnabled(e,n,t){return un(await this.request(`/v1/flows/${O(e)}/enabled`,{method:"PUT",body:JSON.stringify({enabled:t,expectedPublicationId:n,version:1})}))}async publishFlow(e,n,t,r={}){return Fs(await this.request(`/v1/flows/${O(e)}/revisions/${O(n)}/publications`,{body:JSON.stringify({engineContract:"open-flow-engine/v5",expectedLivePublicationId:t,version:1}),headers:{"idempotency-key":r.idempotencyKey??Vn("publication")},method:"POST"}))}async getPublishOperation(e,n,t){return Fs(await this.request(`/v1/flows/${O(e)}/publish-operations/${O(n)}`,{signal:t}))}async rollbackFlow(e,n,t,r={}){return at(await this.request(`/v1/flows/${O(e)}/publications/${O(n)}/rollback`,{body:JSON.stringify({expectedLivePublicationId:t,version:1}),headers:{"idempotency-key":r.idempotencyKey??Vn("publication")},method:"POST"}))}async getRun(e,n){return Ro(await this.request(`/v1/runs/${O(e)}`,{signal:n}))}async listRuns(e,n={}){let t=new URLSearchParams;if(n.cursor!=null)t.set("cursor",n.cursor);if(n.limit!=null)t.set("limit",String(n.limit));if(n.status!=null)t.set("status",n.status);if(n.pendingWait!=null)t.set("pendingWait",String(n.pendingWait));if(n.source!=null)t.set("source",n.source);if(n.createdFrom!=null)t.set("createdFrom",n.createdFrom);if(n.createdBefore!=null)t.set("createdBefore",n.createdBefore);if(n.runId!=null)t.set("runId",n.runId);let r=t.size==0?"":`?${t}`;return ym(await this.request(`/v1/flows/${O(e)}/runs${r}`))}async getRunEvents(e,n={},t){let r=new URLSearchParams;if(n.after!=null)r.set("after",String(n.after));if(n.limit!=null)r.set("limit",String(n.limit));let o=r.size==0?"":`?${r}`;return Lw(await this.request(`/v1/runs/${O(e)}/events${o}`,{signal:t}))}async listRunResults(e,n,t){return Qs(await this.request(`/v1/runs/${O(e)}/results${n==null?"":`?after=${encodeURIComponent(n)}`}`,{signal:t}))}async readRunResult(e,n,t={},r){let o=new URLSearchParams(Object.entries(t).map(([i,s])=>[i,String(s)]));return Ys(await this.request(`/v1/runs/${O(e)}/results/${O(n)}?${o}`,{signal:r}))}async downloadRunResult(e,n,t){return(await this.response(`/v1/runs/${O(e)}/results/${O(n)}/content`,{signal:t})).blob()}async getRunResult(e,n){return xm(await this.request(`/v1/runs/${O(e)}/result`,{signal:n}))}async cancelRun(e){return bm(await this.request(`/v1/runs/${O(e)}/cancel`,{body:JSON.stringify({version:1}),method:"POST"}))}async resolveRunWait(e,n,t,r){return wm(await this.request(`/v1/runs/${O(e)}/waits/${O(n)}/resolve`,{body:JSON.stringify({action:t,comment:r,version:1}),method:"POST"}))}async connectorActions(e,n){let t=Object.entries(e).map(([o,i])=>`${O(o)}=${O(i)}`).join("&"),r=t==""?"":`?${t}`;return this.connectorRequest(`/v1/connector/actions${r}`,"actions",n,(o)=>{let i=w(o);if(U(i,["actions","version"]),i.version!=1||!Array.isArray(i.actions))return d();return i.actions.map(vo)})}async connectorRequest(e,n,t,r,o=!1){return r(await this.request(e,{signal:t}))}async response(e,n,t=!1){let r=new Headers(n.headers);if(n.body!=null)r.set("content-type","application/json");let o=await this.requestControl(e,{...n,headers:r});if(!o.ok&&!(t&&o.status==304)){let i;try{i=await o.json()}catch{return d()}let s=w(i).error,a=s==null?void 0:w(s);throw new Ee(o.status,typeof a?.code=="string"?a.code:"request.failed",typeof a?.message=="string"?a.message:`Request failed with status ${o.status}.`,a?.details==null?void 0:w(a.details))}return o}async request(e,n={}){let t=await this.response(e,n);try{return await t.json()}catch{return d()}}}import{randomUUID as Gw}from"crypto";class C extends Error{constructor(e,n,t){super(n);this.code=e,this.details=t,this.name="CliError"}}function jo(e,n){let t=e.trim();if(ro(t)!=null)throw new C("cli.invalid-arguments",`${n} name must be between 1 and ${ms} characters and use only letters, numbers, spaces, hyphens, or underscores.`);return t}var qw=100,ea=100,na=100,Uw=new Set(["canceled","completed","failed","indeterminate"]);async function Bw(e){let n=[],t=new Set,r;do{let o=await e.listFlows({cursor:r,limit:qw});if(n.push(...o.flows),r=o.nextCursor,r!=null&&t.has(r))throw new C("page.invalid-cursor","The deployment returned a repeated Flow cursor.");if(r!=null)t.add(r)}while(r!=null);return n}function Kw(e,n){let t=e.find((o)=>o.flowId==n);if(t!=null)return t;let r=e.filter((o)=>o.name==n);if(r.length==1)return r[0];if(r.length>1)throw new C("flow.ambiguous",`Flow name ${JSON.stringify(n)} is ambiguous.`,{candidates:r.map(({flowId:o,name:i})=>({flowId:o,name:i}))});throw new C("flow.not-found",`Flow ${JSON.stringify(n)} was not found.`)}async function he(e,n){try{return await e.getFlow(n)}catch(t){if(!(t instanceof Ee)||t.code!="flow.invalid"&&t.code!="flow.not-found")throw t}return Kw(await Bw(e),n)}async function Sm(e,n,t){if(t.expectedRevision!=null&&t.expectedRevision!=n.draftRevisionId&&!t.options.includes("idempotency-key"))throw new C("flow.revision-conflict","The Flow Draft changed. Inspect it before submitting a new mutation.",{expectedRevisionId:t.expectedRevision,actualRevisionId:n.draftRevisionId,flowId:n.flowId});let r=await e.getRevision(n.flowId,t.expectedRevision??n.draftRevisionId);return{draft:r,flow:n,graph:r.content.document.graph}}function Ww(e,n){let t=e.find((o)=>o.actionId==n);if(t!=null)return t;let r=e.filter((o)=>o.name==n);if(r.length==1)return r[0];if(r.length>1)throw new C("connector.action-ambiguous",`Connector Action name ${JSON.stringify(n)} is ambiguous.`,{candidates:r.map(({actionId:o,name:i,serviceId:s})=>({actionId:o,name:i,serviceId:s}))});throw new C("connector.action-not-found",`Connector Action ${JSON.stringify(n)} was not found.`)}async function Im(e,n,t){try{return await e.getConnectorAction(n,void 0,t)}catch(r){if(!(r instanceof Ee)||r.status!=404)throw r}return Ww(await e.searchConnectorActions(n,void 0,t),n)}function Cm(e,n){let t=Object.entries(e.document.graph.nodes).filter((i)=>!("inputs"in i[1])),r=t?.find(([i])=>i==n);if(r!=null)return{trigger:r[1],triggerId:r[0]};let o=t?.filter(([,i])=>i.name==n)??[];if(o.length==1)return{trigger:o[0][1],triggerId:o[0][0]};if(o.length>1)throw new C("trigger.ambiguous",`Trigger name ${JSON.stringify(n)} is ambiguous.`,{candidates:o.map(([i,s])=>({name:s.name,triggerId:i}))});throw new C("trigger.not-found",`Trigger ${JSON.stringify(n)} was not found.`)}function ta(e){return`${e.displayName} ${e.key} ${e.provider} ${e.type}`}async function Em(e,n){try{return await e.getTriggerKey(n)}catch(o){if(!(o instanceof Ee)||o.status!=404)throw o}let r=(await e.listTriggerKeys()).filter((o)=>o.name==n||o.displayName==n);if(r.length==1)return await e.getTriggerKey(r[0].key);if(r.length>1)throw new C("trigger-key.ambiguous",`Trigger Key name ${JSON.stringify(n)} is ambiguous.`,{candidates:r.map(({displayName:o,key:i,provider:s})=>({displayName:o,key:i,provider:s}))});throw new C("trigger-key.not-found",`Trigger Key ${JSON.stringify(n)} was not found.`)}function Om(e){return`${e.displayName} ${e.connectionId} ${e.serviceId} ${e.status}${e.isDefault?"\tdefault":""}`}function ra(e){return`${e.name} ${e.actionId} ${e.serviceName} ${e.serviceId}`}function oe(e,n,t){if(e.length!=n)throw new C("cli.invalid-arguments",`Usage: ${t}`)}function V(e,n,t,r){e.stdout.write(n?`${JSON.stringify(t)}
|
|
60
60
|
`:`${r}
|
|
61
61
|
`)}function Cn(e){return`${e.name} ${e.flowId} ${e.status}`}function ur(e){return`${e.operation} ${e.publicationId} ${e.revisionId} ${e.createdAt}`}function lr(e){let n=e.source=="draft"?"":` ${e.publicationId}`;return`${e.source} ${e.status} ${e.runId} ${e.revisionId}${n}${e.waits.length==0?"":`
|
|
62
|
-
${JSON.stringify(e.waits)}`}`}function Om(e){return`${e.source} ${e.status} ${e.runId} ${e.revisionId}`}function Rm(e){return`${e.sequence} ${e.kind} ${JSON.stringify(e.payload)}`}async function ln(e,n,t,r){try{if(e=="-")return await r.readStdin();if(!e.startsWith("@"))return e;let o=e.slice(1);if(o.length==0)throw new C("cli.invalid-arguments",`${n} @ requires a file path.`);return await r.readFile(o)}catch(o){if(o instanceof C)throw o;throw new C(t,o instanceof Error?o.message:String(o))}}async function Am(e,n){if(e.input==null)return{};let t=await ln(e.input,"--input","run.input-unreadable",n),r;try{r=JSON.parse(t)}catch{throw new C("run.input-invalid","Run input must be valid JSON.")}if(r==null||typeof r!="object"||Array.isArray(r))throw new C("run.input-invalid","Run input must be an object keyed by node ID.");for(let o of Object.values(r))if(o==null||typeof o!="object"||Array.isArray(o))throw new C("run.input-invalid","Each Run input node must contain an object keyed by input handle.");return r}async function dr(e,n,t){let r=new Set,o;do{let i=await e.listPublications(n,{cursor:o,limit:Xs}),s=i.publications.find((a)=>a.publicationId==t);if(s!=null)return s;if(o=i.nextCursor,o!=null&&r.has(o))throw new C("page.invalid-cursor","The deployment returned a repeated Publication cursor.");if(o!=null)r.add(o)}while(o!=null);throw new C("publication.not-found",`Publication ${JSON.stringify(t)} was not found.`)}async function ra(e,n,t,r=60000){let o=Date.now()+r,i=n;while(!Jw.has(i.status)&&i.waits.length==0){let s=o-Date.now();if(s<=0)return{run:i,timedOut:!0};if(await t.wait(Math.min(1000,s)),Date.now()>=o)return{run:i,timedOut:!0};try{i=await e.getRun(i.runId,AbortSignal.timeout(Math.max(1,o-Date.now())))}catch(a){if(Date.now()>=o||a instanceof Error&&a.name=="TimeoutError")return{run:i,timedOut:!0};throw new C("run.wait-failed",a instanceof Error?a.message:String(a),{runId:i.runId})}}return{run:i,timedOut:!1}}function pr(e,n=!1){if(n)return 3;if(e.waits.length>0)return 2;return e.status=="failed"||e.status=="canceled"||e.status=="indeterminate"?1:0}function jm(e){return new C(e.code,e.message,{status:e.status,...e.details})}async function oa(e,n,t,r,o=60000){let i=Date.now()+o,s=t;while(s.status=="pending"){let a=i-Date.now();if(a<=0)return{operation:s,timedOut:!0};if(await r.wait(Math.min(1000,a)),Date.now()>=i)return{operation:s,timedOut:!0};try{s=await e.getPublishOperation(n,s.operationId,AbortSignal.timeout(Math.max(1,i-Date.now())))}catch(c){if(Date.now()>=i||c instanceof Error&&c.name=="TimeoutError")return{operation:s,timedOut:!0};throw new C("publication.wait-failed",c instanceof Error?c.message:String(c),{flowId:n,operationId:s.operationId})}}return{operation:s,timedOut:!1}}var Kw=new Set(Co);function Pm(e){let n=Bw(),t,r=[],o=[],i,s,a,c,u,l,p,m,h,g,E,P,N,L,M,De,pe,Y,je,Zn=!1,Fn,Jn=!1,Ln,pt,gr=[],ya="draft",To,zo,ba=!1,Do,Vo,Mo,wa=[],xa=!1,va=!1;for(let ft=0;ft<e.length;ft+=1){let mt=e[ft],hr=mt.startsWith("--")?mt.indexOf("="):-1,A=hr<0?mt:mt.slice(0,hr),yr=hr<0?void 0:mt.slice(hr+1);if(yr!=null&&["--json","--follow","--wait","--yes","--full","--pending-wait"].includes(A))throw new C("cli.invalid-arguments",`${A} does not accept a value.`);if(A.startsWith("--")){let F=A.slice(2);if(o.includes(F)&&F!="set"&&F!="unset")throw new C("cli.invalid-arguments",`Duplicate option --${F}.`);o.push(F)}if(A=="--json")Jn=!0;else if(A=="--follow")Zn=!0;else if(A=="--wait")xa=!0;else if(A=="--yes")va=!0;else if(A=="--pending-wait")To=!0;else if(A=="--full")ba=!0;else if(A=="--idempotency-key"||A=="--expected-publication"||A=="--revision"||A=="--publication"||A=="--pointer"||A=="--offset"||A=="--max-bytes"||A=="--code"||A=="--connection"||A=="--cron"||A=="--description"||A=="--every"||A=="--expected-revision"||A=="--file"||A=="--flow"||A=="--name"||A=="--source"||A=="--input"||A=="--trigger"||A=="--outputs"||A=="--status"||A=="--cursor"||A=="--limit"||A=="--after"||A=="--comment"||A=="--timeout"||A=="--timezone"||A=="--set"||A=="--unset"){let F=yr??e[ft+1];if(F==null||F.length==0||yr==null&&F.startsWith("-")&&F!="-")throw new C("cli.invalid-arguments",`${A} requires a value.`);if(yr==null)ft++;if(A=="--idempotency-key")n=F;else if(A=="--expected-publication")t=F;else if(A=="--revision")a=F;else if(A=="--publication")c=F;else if(A=="--pointer")u=F;else if(A=="--after")h=F;else if(A=="--code")E=F;else if(A=="--connection")P=F;else if(A=="--cron")N=F;else if(A=="--description")M=F;else if(A=="--every")De=F;else if(A=="--expected-revision")pe=F;else if(A=="--file")Y=F;else if(A=="--flow")je=F;else if(A=="--name")pt=F;else if(A=="--comment")Do=F;else if(A=="--input")Fn=F;else if(A=="--trigger")i=F;else if(A=="--outputs")s=F;else if(A=="--cursor")L=F;else if(A=="--timezone")Mo=F;else if(A=="--set")gr.push(F);else if(A=="--unset")wa.push(F);else if(A=="--source"){if(F!="draft"&&F!="live")throw new C("cli.invalid-arguments","--source must be draft or live.");ya=F}else if(A=="--status"){if(!Kw.has(F))throw new C("cli.invalid-arguments",`Unknown Run status ${JSON.stringify(F)}.`);zo=F}else{let dn=Number(F),yg=A=="--offset"?0:1;if(!Number.isSafeInteger(dn)||dn<yg||A=="--limit"&&dn>100||A=="--max-bytes"&&dn>1048576)throw new C("cli.invalid-arguments",`${A} has an invalid value.`);if(A=="--limit")Ln=dn;else if(A=="--offset")l=dn;else if(A=="--max-bytes")p=dn;else Vo=dn}}else if(A.startsWith("-"))throw new C("cli.invalid-arguments",`Unknown option ${JSON.stringify(A)}.`);else r.push(A)}if(h!=null){if(r[0]=="runs"&&r[1]=="results")m=h;else if(g=Number(h),!Number.isSafeInteger(g)||g<0)throw new C("cli.invalid-arguments","--after must be a non-negative event sequence.")}return{idempotencyKey:n,...m==null?{}:{resultAfter:m},...p==null?{}:{maxBytes:p},...l==null?{}:{offset:l},...u==null?{}:{pointer:u},...a==null?{}:{revision:a},...c==null?{}:{publication:c},...Do==null?{}:{comment:Do},...t==null?{}:{expectedPublication:t},...g==null?{}:{after:g},...E==null?{}:{code:E},...P==null?{}:{connection:P},...N==null?{}:{cron:N},...L==null?{}:{cursor:L},...M==null?{}:{description:M},...De==null?{}:{every:De},...pe==null?{}:{expectedRevision:pe},...Y==null?{}:{file:Y},...je==null?{}:{flow:je},follow:Zn,...Fn==null?{}:{input:Fn},json:Jn,...Ln==null?{}:{limit:Ln},...pt==null?{}:{name:pt},positionals:r,options:o,...i==null?{}:{trigger:i},...s==null?{}:{outputs:s},sets:gr,source:ya,...zo==null?{}:{status:zo},...To==null?{}:{pendingWait:To},full:ba,...Vo==null?{}:{timeoutMs:Vo},...Mo==null?{}:{timezone:Mo},unsets:wa,wait:xa,yes:va}}var Ww=0.1,Gw=3,Mn=jn("type",[k({type:x("focus"),nodeId:R().min(1)}),k({type:x("zoom"),zoom:ue().min(Ww).max(Gw)}),k({type:x("pan"),dx:ue(),dy:ue()}),k({type:x("fit")})]);var ia=R().trim().refine((e)=>[...e].length<=2000,"Wait comment must contain at most 2,000 Unicode code points.").nullable().optional();var lt=R().min(1),ax=_e(),cx=k({kind:x("graph.trigger.create"),nodeId:lt,key:lt,connectionId:lt.optional(),name:lt.optional(),config:ee(lt,ax),schedule:yn.readonly().optional()});function sa(e){return Pn(e),j(Wn()).min(1).parse(e).map((n,t)=>{let{kind:r}=Mt(n,t,I({kind:lt}).parse);return r=="graph.trigger.create"?Mt(n,t,cx.parse):fp(n,t)})}var $m=R().min(1).max(256),_m=R().regex(/^[a-z][a-z0-9_.]{0,127}$/),Nm=R().trim().min(1).max(128),jo=R().min(1).max(256),Tm=k({version:x(1),name:Nm,connectionId:$m,teamId:$m.nullable(),verificationToken:jo,encryptKey:jo,eventTypes:j(_m).min(1).max(200).refine((e)=>new Set(e).size==e.length),manageSubscriptions:le()}),zm=k({version:x(1),expectedRevision:ge().positive(),name:Nm,enabled:le(),eventTypes:j(_m).min(1).max(200).refine((e)=>new Set(e).size==e.length),verificationToken:jo.optional(),encryptKey:jo.optional()}),Dm=k({version:x(1),expectedRevision:ge().positive()});var Vm={start:"A Start node with a required message parameter. Supply it through trigger.outputs.",error:"A Flow Error node. Select upstream Flows, then publish and enable this Flow to listen for failures in their automatic runs.",webhook:"A Webhook start node.",cron:"An hourly scheduled start node.",poll:"Gmail polling by key; replace CONNECTION_ID with an active Gmail connection.",integration:"Telegram webhook integration by key; replace CONNECTION_ID with an active Telegram connection.",decision:"AI Decision evaluates named questions against target and returns a complete answer object per output. Configure target before running.",openapi:"A fixed JSON API operation. Replace the example document and URL before running.",connector:"A Connector Task and its node. Replace ACTION_ID, CONNECTION_ID and port definitions using connector_get / connector show.",code:"A JavaScript module and its node. Use Code for custom computation; use Connector Tasks for existing actions.",condition:"A condition with true and false execution branches.",value:"A fixed value node.",approval:"An Approval with approve and reject decision branches and a built-in notification output.",wait:"A Wait with a continue action and a built-in notification output.",agent:"An Agent with code computation enabled. Configure a model available in the deployment.","llm-chat":"An LLM chat Task and its node; configure a model available in the deployment.","llm-json":"An LLM JSON Task and its node; configure a model available in the deployment.","poll-notification":"Gmail events \u2192 JavaScript text formatting \u2192 Connector notification. Replace connection/action IDs and match the notification input ports."},ux=Object.keys(Vm),lx=ux.map((e)=>({name:e,description:Vm[e]}));var BP=k({comment:ia}),fr=_e(),xe=R().min(1),we=x(1),aa=xe.refine((e)=>e==e.trim()&&to(e)==null,"Flow name is invalid."),Mm=ee(R(),ee(R(),fr)),Zm=k({nodeId:xe,outputs:ee(R(),fr)}),H={canvas:k({command:Mn,version:we}),authoringCheck:Ds,authoringEdit:rr,authoringRead:mo,authoringSearch:go,authoringSchema:kf,loadOpenApiDocument:k({url:R().min(1).max(8192),version:we}),createEventSource:Tm,updateEventSource:zm,eventSourceRevision:Dm,importFlow:k({file:fr,name:aa.optional(),teamId:xe.optional(),version:we}),createFlow:k({name:aa,teamId:xe.optional(),version:we}),renameFlow:k({name:aa,version:we}),changeDraft:k({expectedRevisionId:xe,operations:j(fr).min(1),version:we}),repairDraft:k({expectedRevisionId:xe,version:we}),upgradeDraft:k({expectedRevisionId:xe,version:we}),setEnabled:k({enabled:le(),expectedPublicationId:xe,version:we}),updatePresentation:k({expectedRevision:ge().positive(),value:ee(R(),fr),version:we}),checkFlow:k({engineContract:xe,version:we}),publishFlow:k({engineContract:xe,expectedLivePublicationId:xe.nullable(),version:we}),rollbackFlow:k({expectedLivePublicationId:xe,version:we}),createDraftRun:k({engineContract:xe,inputs:Mm,trigger:Zm,version:x(2)}),createLiveRun:k({publicationId:xe,inputs:Mm,trigger:Zm,version:x(2)}),resolveWait:k({action:ce(["approve","continue","reject"]),comment:ia,version:we}),putVariable:k({value:R().refine((e)=>new TextEncoder().encode(e).byteLength<=65536,"Variable value is too large.")}),queryConnectorAccessCandidates:k({providerIds:j(xe.max(256)).min(1).refine((e)=>new Set(e).size==e.length,"Duplicate provider IDs."),version:we}),removeConnectionUsage:k({connectionId:xe,expectedRevisionId:xe,expectedAccessRevision:ge().nonnegative(),version:we}),setConnectorService:k({expectedAccessRevision:ge().nonnegative(),version:we}),addProviderAccessBinding:k({accessBindingId:xe,expectedAccessRevision:ge().nonnegative(),version:we}),removeProviderAccessBinding:k({accessBindingId:xe,expectedAccessRevision:ge().nonnegative(),version:we}),versionOnly:k({version:we})};function Q(e){return(n)=>e.parse(n)}var Po={canvas:Q(H.canvas),authoringCheck:Q(H.authoringCheck),authoringEdit:Q(H.authoringEdit),authoringRead:Q(H.authoringRead),authoringSearch:Q(H.authoringSearch),authoringSchema:Q(H.authoringSchema),loadOpenApiDocument:Q(H.loadOpenApiDocument),createEventSource:Q(H.createEventSource),updateEventSource:Q(H.updateEventSource),eventSourceRevision:Q(H.eventSourceRevision),importFlow:Q(H.importFlow),createFlow:Q(H.createFlow),renameFlow:Q(H.renameFlow),changeDraft(e){let n=H.changeDraft.parse(e);return{...n,operations:sa(n.operations)}},repairDraft:Q(H.repairDraft),upgradeDraft:Q(H.upgradeDraft),setEnabled:Q(H.setEnabled),updatePresentation:Q(H.updatePresentation),checkFlow:Q(H.checkFlow),publishFlow:Q(H.publishFlow),rollbackFlow:Q(H.rollbackFlow),createDraftRun:Q(H.createDraftRun),createLiveRun:Q(H.createLiveRun),resolveWait:Q(H.resolveWait),putVariable:Q(H.putVariable),queryConnectorAccessCandidates:Q(H.queryConnectorAccessCandidates),removeConnectionUsage:Q(H.removeConnectionUsage),setConnectorService:Q(H.setConnectorService),addProviderAccessBinding:Q(H.addProviderAccessBinding),removeProviderAccessBinding:Q(H.removeProviderAccessBinding),versionOnly:Q(H.versionOnly)};var ca=["expected-revision","idempotency-key"],ua=["cursor","limit"],Fm=[["canvas","<flow> (--input JSON|@file|- | --file path|-)",["input","file"]],["read","<flow> [--input JSON|@file|- | --file path|-]",["input","file"]],["search","<flow> (--input JSON|@file|- | --file path|-)",["input","file"]],["edit","<flow> (--input JSON|@file|- | --file path|-)",["input","file"]],["list","[--cursor <cursor>] [--limit <count>]",ua],["export","<flow>",[]],["import","--file <path|->",["file","name","idempotency-key"]],["create","<name>",["idempotency-key"]],["show","<flow>",[]],["live","<flow>",[]],["rename","<flow> <new-name>",[]],["delete","<flow> --yes",["yes"]],["check","<flow> [--revision <revisionId>]",["revision"]],["enable","<flow> --expected-publication <publicationId>",["expected-publication"]],["disable","<flow> --expected-publication <publicationId>",["expected-publication"]],["connector code-access","<flow> [--publication <publicationId>]",["publication"]],["connector candidates","<flow> <provider> [provider ...]",[]],["connector code-allow","<flow> <provider> <binding> <access-revision>",[]],["connector code-remove","<flow> <provider> <binding> <access-revision>",[]],["connector remove-usage","<flow> <connection> <access-revision>",ca],["connector providers","[--flow <flow>]",["flow"]],["connector teams","",[]],["connector search","<query> [--flow <flow>]",["flow"]],["connector show","<action> [--flow <flow>]",["flow"]],["connector connections","<service> [--flow <flow>]",["flow"]],["event-source list","",[]],["trigger search","[query]",[]],["trigger show","<key>",[]],["run","<flow>",[...ca,"expected-publication","source","trigger","outputs","input","wait","timeout"]],["runs list","--flow <flow>",["flow","status","pending-wait",...ua]],["runs show","<run>",[]],["runs wait","<run>",["timeout"]],["runs resolve","<run> <wait> <continue|approve|reject>",["comment"]],["runs events","<run>",["after","limit","follow","timeout"]],["runs result","<run>",[]],["runs results","<run> [--after <resultId>]",["after"]],["runs read-result","<run> <result>",["pointer","offset","limit","max-bytes"]],["runs download-result","<run> <result>",[]],["runs cancel","<run>",[]],["publish","<flow>",[...ca,"expected-publication","timeout"]],["publications list","<flow>",ua],["publications show","<flow> <publication>",[]],["publications wait","<flow> <operation>",["timeout"]],["publications operation","<flow> <operation>",[]],["rollback","<flow> <publication>",["expected-publication","idempotency-key"]],["open","[flow]",[]],["workbench","[flow]",[]],["schema","[read|search|edit|check|node-type]",["flow","input"]]],px={revision:{description:"Exact Revision to read or check; defaults to the current Draft.",type:"string"},publication:{description:"Exact Publication ID whose fixed Code connections are read; defaults to the Draft.",type:"string"},pointer:{description:"JSON Pointer within the stored result; defaults to the root.",type:"string"},offset:{description:"Page offset at the selected pointer.",type:"integer",minimum:0,default:0},"max-bytes":{description:"Maximum result page bytes.",type:"integer",minimum:1,maximum:1048576,default:15000},"expected-revision":{description:"Base Revision ID from read. Required with an explicit idempotency key for draft edits and draft runs.",type:"string"},"expected-publication":{description:"Fixed Publication ID. Use none when publishing without a Live Publication.",type:"string"},"idempotency-key":{description:"Stable identity of one mutation. Reuse only with the identical arguments and base identity.",type:"string"},source:{description:"Execution source.",type:"string",enum:["draft","live"],default:"draft"},trigger:{description:"Exact Trigger ID or unambiguous name. The Start node is selected automatically; a sole legacy Manual Trigger remains supported.",type:"string"},timeout:{description:"Wait budget in milliseconds; expiration does not cancel the operation. For node set, the node execution timeout.",type:"integer",minimum:1,default:60000},limit:{description:"Maximum items in one page.",type:"integer",minimum:1,maximum:100,default:100},after:{description:"Resume events after this sequence number; use nextAfter from the preceding response.",type:"integer",minimum:0,default:0},cursor:{description:"Opaque nextCursor from the preceding page; keep the same filters.",type:"string"},comment:{description:"Optional plain-text Wait decision comment (up to 2,000 Unicode code points).",type:"string"},"pending-wait":{description:"List runs with unresolved waits, including running and queued runs.",type:"boolean"},status:{description:"Filter runs by status.",type:"string",enum:["queued","starting","running","waiting","completed","failed","canceled","indeterminate"]},file:{description:"Authoring request or workflow JSON file path, or - for stdin.",type:"string"},code:{description:"JavaScript source, @file, or - for stdin.",type:"string"},input:{description:"Authoring request JSON; literal JSON, @file, or -. For run, node ID to input values.",type:"string"},outputs:{description:"Start parameters or other Trigger outputs: literal JSON, @file, or -. Defaults to {}.",type:"string"},set:{description:"handle=value; repeat for multiple fields. Values use port schemas, JSON, @file, or -.",type:"string"},unset:{description:"Input/config handle to remove; repeat for multiple fields.",type:"string"},connection:{description:"Exact active Connection ID, unambiguous display name, or default.",type:"string"},flow:{description:"Exact Flow ID or unambiguous name; fixes Connector Team scope.",type:"string"},name:{description:"Display name.",type:"string"},description:{description:"Trigger description.",type:"string"},cron:{description:"Cron expression; combine with --timezone. Mutually exclusive with --every.",type:"string"},timezone:{description:"IANA time zone for --cron.",type:"string"},every:{description:"Interval such as 5m, 1h, or 1d. Mutually exclusive with --cron.",type:"string"},wait:{description:"Wait until terminal, waiting for an action, or the wait budget expires."},follow:{description:"Stream event pages as NDJSON with --json; stop on terminal, Wait, or timeout."},full:{description:"Include complete Revision content, schemas, source code and revision metadata."},yes:{description:"Confirm the requested deletion."},json:{description:"Machine-readable JSON results and errors; NDJSON for followed events."},help:{description:"Show this command contract without contacting the host."}};function la(e,n="oo flow"){let t=e.join(" ");return Fm.filter(([r])=>t==""||r==t||r.startsWith(`${t} `)).map(([r,o,i])=>({command:r,usage:`${n} ${r} ${o} [--json]`,options:[...i,"json","help"].map((s)=>Object.assign({name:`--${s}`,value:!["json","help","wait","follow","full","yes","pending-wait"].includes(s),repeatable:s=="set"||s=="unset"},px[s],r=="runs results"&&s=="after"?{type:"string",minimum:void 0,default:void 0,description:"Result ID from nextAfter on the preceding page."}:{},r=="runs read-result"&&s=="limit"?{default:20}:{}))}))}function Jm(e){return Fm.find(([n])=>n==e.slice(0,n.split(" ").length).join(" "))?.[2]}function Lm(e="edits"){let n=Vs(e);if(n!=null)return n;if(e=="edits")return Ms();if(e=="outputs")return{$schema:"https://json-schema.org/draft/2020-12/schema",type:"object",description:"Named Start parameters or other Trigger outputs. Start uses the workflow inputDefs returned by flow read; other triggers define their own output contracts. Omitted nullable Start parameters become null; required parameters must be supplied."};if(po.includes(e))return Ms(e);if(e=="input")return{$schema:"https://json-schema.org/draft/2020-12/schema",type:"object",additionalProperties:{type:"object",additionalProperties:!0},description:"Node ID -> input handle -> JSON value."};return}function da(e){if(e=="canvas")return{request:Nt(Mn,{io:"input"}),guidance:"Broadcast transient viewport commands; success does not confirm execution. No Presentation save, offline queue or replay. Pan uses screen pixels; zoom is an absolute ratio (0.1\u20133); fit includes all nodes. Repeating pan moves again; do not automatically retry an uncertain response.",examples:[{type:"focus",nodeId:"NODE_ID"},{type:"zoom",zoom:0.8},{type:"pan",dx:200,dy:-100},{type:"fit"}]};return Vs(e)}function qm(e,n="oo flow"){if(e=="export")return[`${n} export FLOW_ID > template.openflow.json`];if(e=="import")return[`${n} import --file template.openflow.json --name "Imported workflow" --idempotency-key IMPORT_KEY --json`];if(e=="schema")return[`${n} schema read --json`,`${n} schema agent --json`,`${n} schema --flow FLOW_ID --input '{"action":"ACTION_ID"}' --json`];let t=da(e);if(t==null)return fx(n);if(e=="check")return[`${n} check FLOW_ID --revision REVISION --json`];return t.examples.map((r)=>`${n} ${e} FLOW_ID${Object.keys(r).length==0?"":` --input '${JSON.stringify(r)}'`} --json`)}function fx(e){return[`${e} list --limit 20 --json`,`${e} read FLOW_ID --json`,`${e} live FLOW_ID --json`,`${e} schema code --json`,`${e} edit FLOW_ID --file edits.json --json`,`${e} connector search email --flow FLOW_ID --json`,`${e} run FLOW_ID --expected-revision REVISION_ID --idempotency-key RUN_KEY --wait --timeout 60000 --json`,`${e} runs wait RUN_ID --timeout 60000 --json`,`${e} runs resolve RUN_ID WAIT_ID approve --json`,`${e} runs events RUN_ID --after 0 --follow --timeout 60000 --json`]}import{basename as gx}from"path";async function Um(e,n,t,r,o){let[i,s,a,...c]=t;switch(i){case"code-access":case"candidates":case"code-allow":case"code-remove":case"remove-usage":{let u=i=="code-access"?1:i=="candidates"?2:i=="remove-usage"?3:4;if(i=="candidates"?t.length<u+1:t.length!=u+1)throw new C("cli.invalid-arguments",`Invalid arguments for connector ${i}. See --help.`);let l=mx(n),p;if(i=="code-access")p=r.publication==null?await e.getConnectorAccess(l):await e.getPublishedConnectorAccess(l,r.publication);else if(i=="candidates")p=await e.listProviderAccessBindingCandidates(l,t.slice(2));else{let m=Number(t.at(-1));if(!Number.isSafeInteger(m)||m<0)throw new C("cli.invalid-arguments","Access revision must be a nonnegative integer.");if(i=="remove-usage"){let h=await km(e,n,r);p=await e.removeConnectionUsage(l,a,h.draft.revisionId,m,r.idempotencyKey)}else if(i=="code-allow")p=await e.addProviderAccessBinding(l,a,c[0],m);else p=await e.removeProviderAccessBinding(l,a,c[0],m)}V(o,r.json,{...p,kind:`connector.${i}`},JSON.stringify(p,null,2));return}case"providers":{if(s!=null)throw new C("cli.invalid-arguments",`Usage: ${o.commandPrefix??"oo flow"} connector providers [--flow <flow>] [--json]`);let u=await e.listConnectorProviders(void 0,n?.flowId);V(o,r.json,{providers:u,kind:"connector.providers",version:1},u.map((l)=>`${l.serviceName} ${l.serviceId}`).join(`
|
|
62
|
+
${JSON.stringify(e.waits)}`}`}function Rm(e){return`${e.source} ${e.status} ${e.runId} ${e.revisionId}`}function Am(e){return`${e.sequence} ${e.kind} ${JSON.stringify(e.payload)}`}async function ln(e,n,t,r){try{if(e=="-")return await r.readStdin();if(!e.startsWith("@"))return e;let o=e.slice(1);if(o.length==0)throw new C("cli.invalid-arguments",`${n} @ requires a file path.`);return await r.readFile(o)}catch(o){if(o instanceof C)throw o;throw new C(t,o instanceof Error?o.message:String(o))}}async function jm(e,n){if(e.input==null)return{};let t=await ln(e.input,"--input","run.input-unreadable",n),r;try{r=JSON.parse(t)}catch{throw new C("run.input-invalid","Run input must be valid JSON.")}if(r==null||typeof r!="object"||Array.isArray(r))throw new C("run.input-invalid","Run input must be an object keyed by node ID.");for(let o of Object.values(r))if(o==null||typeof o!="object"||Array.isArray(o))throw new C("run.input-invalid","Each Run input node must contain an object keyed by input handle.");return r}async function dr(e,n,t){let r=new Set,o;do{let i=await e.listPublications(n,{cursor:o,limit:ea}),s=i.publications.find((a)=>a.publicationId==t);if(s!=null)return s;if(o=i.nextCursor,o!=null&&r.has(o))throw new C("page.invalid-cursor","The deployment returned a repeated Publication cursor.");if(o!=null)r.add(o)}while(o!=null);throw new C("publication.not-found",`Publication ${JSON.stringify(t)} was not found.`)}async function oa(e,n,t,r=60000){let o=Date.now()+r,i=n;while(!Uw.has(i.status)&&i.waits.length==0){let s=o-Date.now();if(s<=0)return{run:i,timedOut:!0};if(await t.wait(Math.min(1000,s)),Date.now()>=o)return{run:i,timedOut:!0};try{i=await e.getRun(i.runId,AbortSignal.timeout(Math.max(1,o-Date.now())))}catch(a){if(Date.now()>=o||a instanceof Error&&a.name=="TimeoutError")return{run:i,timedOut:!0};throw new C("run.wait-failed",a instanceof Error?a.message:String(a),{runId:i.runId})}}return{run:i,timedOut:!1}}function pr(e,n=!1){if(n)return 3;if(e.waits.length>0)return 2;return e.status=="failed"||e.status=="canceled"||e.status=="indeterminate"?1:0}function Pm(e){return new C(e.code,e.message,{status:e.status,...e.details})}async function ia(e,n,t,r,o=60000){let i=Date.now()+o,s=t;while(s.status=="pending"){let a=i-Date.now();if(a<=0)return{operation:s,timedOut:!0};if(await r.wait(Math.min(1000,a)),Date.now()>=i)return{operation:s,timedOut:!0};try{s=await e.getPublishOperation(n,s.operationId,AbortSignal.timeout(Math.max(1,i-Date.now())))}catch(c){if(Date.now()>=i||c instanceof Error&&c.name=="TimeoutError")return{operation:s,timedOut:!0};throw new C("publication.wait-failed",c instanceof Error?c.message:String(c),{flowId:n,operationId:s.operationId})}}return{operation:s,timedOut:!1}}var Hw=new Set(Eo);function $m(e){let n=Gw(),t,r=[],o=[],i,s,a,c,u,l,f,m,h,g,E,P,T,L,M,De,pe,Y,je,Zn=!1,Fn,Jn=!1,Ln,pt,gr=[],ba="draft",zo,Do,wa=!1,Vo,Mo,Zo,xa=[],va=!1,ka=!1;for(let ft=0;ft<e.length;ft+=1){let mt=e[ft],hr=mt.startsWith("--")?mt.indexOf("="):-1,A=hr<0?mt:mt.slice(0,hr),yr=hr<0?void 0:mt.slice(hr+1);if(yr!=null&&["--json","--follow","--wait","--yes","--full","--pending-wait"].includes(A))throw new C("cli.invalid-arguments",`${A} does not accept a value.`);if(A.startsWith("--")){let F=A.slice(2);if(o.includes(F)&&F!="set"&&F!="unset")throw new C("cli.invalid-arguments",`Duplicate option --${F}.`);o.push(F)}if(A=="--json")Jn=!0;else if(A=="--follow")Zn=!0;else if(A=="--wait")va=!0;else if(A=="--yes")ka=!0;else if(A=="--pending-wait")zo=!0;else if(A=="--full")wa=!0;else if(A=="--idempotency-key"||A=="--expected-publication"||A=="--revision"||A=="--publication"||A=="--pointer"||A=="--offset"||A=="--max-bytes"||A=="--code"||A=="--connection"||A=="--cron"||A=="--description"||A=="--every"||A=="--expected-revision"||A=="--file"||A=="--flow"||A=="--name"||A=="--source"||A=="--input"||A=="--trigger"||A=="--outputs"||A=="--status"||A=="--cursor"||A=="--limit"||A=="--after"||A=="--comment"||A=="--timeout"||A=="--timezone"||A=="--set"||A=="--unset"){let F=yr??e[ft+1];if(F==null||F.length==0||yr==null&&F.startsWith("-")&&F!="-")throw new C("cli.invalid-arguments",`${A} requires a value.`);if(yr==null)ft++;if(A=="--idempotency-key")n=F;else if(A=="--expected-publication")t=F;else if(A=="--revision")a=F;else if(A=="--publication")c=F;else if(A=="--pointer")u=F;else if(A=="--after")h=F;else if(A=="--code")E=F;else if(A=="--connection")P=F;else if(A=="--cron")T=F;else if(A=="--description")M=F;else if(A=="--every")De=F;else if(A=="--expected-revision")pe=F;else if(A=="--file")Y=F;else if(A=="--flow")je=F;else if(A=="--name")pt=F;else if(A=="--comment")Vo=F;else if(A=="--input")Fn=F;else if(A=="--trigger")i=F;else if(A=="--outputs")s=F;else if(A=="--cursor")L=F;else if(A=="--timezone")Zo=F;else if(A=="--set")gr.push(F);else if(A=="--unset")xa.push(F);else if(A=="--source"){if(F!="draft"&&F!="live")throw new C("cli.invalid-arguments","--source must be draft or live.");ba=F}else if(A=="--status"){if(!Hw.has(F))throw new C("cli.invalid-arguments",`Unknown Run status ${JSON.stringify(F)}.`);Do=F}else{let dn=Number(F),bg=A=="--offset"?0:1;if(!Number.isSafeInteger(dn)||dn<bg||A=="--limit"&&dn>100||A=="--max-bytes"&&dn>1048576)throw new C("cli.invalid-arguments",`${A} has an invalid value.`);if(A=="--limit")Ln=dn;else if(A=="--offset")l=dn;else if(A=="--max-bytes")f=dn;else Mo=dn}}else if(A.startsWith("-"))throw new C("cli.invalid-arguments",`Unknown option ${JSON.stringify(A)}.`);else r.push(A)}if(h!=null){if(r[0]=="runs"&&r[1]=="results")m=h;else if(g=Number(h),!Number.isSafeInteger(g)||g<0)throw new C("cli.invalid-arguments","--after must be a non-negative event sequence.")}return{idempotencyKey:n,...m==null?{}:{resultAfter:m},...f==null?{}:{maxBytes:f},...l==null?{}:{offset:l},...u==null?{}:{pointer:u},...a==null?{}:{revision:a},...c==null?{}:{publication:c},...Vo==null?{}:{comment:Vo},...t==null?{}:{expectedPublication:t},...g==null?{}:{after:g},...E==null?{}:{code:E},...P==null?{}:{connection:P},...T==null?{}:{cron:T},...L==null?{}:{cursor:L},...M==null?{}:{description:M},...De==null?{}:{every:De},...pe==null?{}:{expectedRevision:pe},...Y==null?{}:{file:Y},...je==null?{}:{flow:je},follow:Zn,...Fn==null?{}:{input:Fn},json:Jn,...Ln==null?{}:{limit:Ln},...pt==null?{}:{name:pt},positionals:r,options:o,...i==null?{}:{trigger:i},...s==null?{}:{outputs:s},sets:gr,source:ba,...Do==null?{}:{status:Do},...zo==null?{}:{pendingWait:zo},full:wa,...Mo==null?{}:{timeoutMs:Mo},...Zo==null?{}:{timezone:Zo},unsets:xa,wait:va,yes:ka}}var Qw=0.1,Yw=3,Mn=jn("type",[v({type:x("focus"),nodeId:R().min(1)}),v({type:x("zoom"),zoom:ue().min(Qw).max(Yw)}),v({type:x("pan"),dx:ue(),dy:ue()}),v({type:x("fit")})]);var sa=R().trim().refine((e)=>[...e].length<=2000,"Wait comment must contain at most 2,000 Unicode code points.").nullable().optional();var lt=R().min(1),lx=_e(),dx=v({kind:x("graph.trigger.create"),nodeId:lt,key:lt,connectionId:lt.optional(),name:lt.optional(),config:ee(lt,lx),schedule:yn.readonly().optional()});function aa(e){return Pn(e),j(Wn()).min(1).parse(e).map((n,t)=>{let{kind:r}=Mt(n,t,I({kind:lt}).parse);return r=="graph.trigger.create"?Mt(n,t,dx.parse):mp(n,t)})}var _m=R().min(1).max(256),Tm=R().regex(/^[a-z][a-z0-9_.]{0,127}$/),Nm=R().trim().min(1).max(128),Po=R().min(1).max(256),zm=v({version:x(1),name:Nm,connectionId:_m,teamId:_m.nullable(),verificationToken:Po,encryptKey:Po,eventTypes:j(Tm).min(1).max(200).refine((e)=>new Set(e).size==e.length),manageSubscriptions:le()}),Dm=v({version:x(1),expectedRevision:ge().positive(),name:Nm,enabled:le(),eventTypes:j(Tm).min(1).max(200).refine((e)=>new Set(e).size==e.length),verificationToken:Po.optional(),encryptKey:Po.optional()}),Vm=v({version:x(1),expectedRevision:ge().positive()});var Mm={start:"A Start node with a required message parameter. Supply it through trigger.outputs.",error:"A Flow Error node. Select upstream Flows, then publish and enable this Flow to listen for failures in their automatic runs.",webhook:"A Webhook start node.",cron:"An hourly scheduled start node.",poll:"Gmail polling by key; replace CONNECTION_ID with an active Gmail connection.",integration:"Telegram webhook integration by key; replace CONNECTION_ID with an active Telegram connection.",decision:"AI Decision evaluates named questions against target and returns a complete answer object per output. Configure target before running.",openapi:"A fixed JSON API operation. Replace the example document and URL before running.",connector:"A Connector Task and its node. Replace ACTION_ID, CONNECTION_ID and port definitions using connector_get / connector show. Set connectionId to an empty string to defer account configuration; execution will require an account.",code:"A JavaScript module and its node. Use Code for custom computation; use Connector Tasks for existing actions.",condition:"A condition with true and false execution branches.",value:"A fixed value node.",approval:"An Approval with approve and reject decision branches and a built-in notification output.",wait:"A Wait with a continue action and a built-in notification output.",agent:"An Agent with code computation enabled. Configure a model available in the deployment.","llm-chat":"An LLM chat Task and its node; configure a model available in the deployment.","llm-json":"An LLM JSON Task and its node; configure a model available in the deployment.","poll-notification":"Gmail events \u2192 JavaScript text formatting \u2192 Connector notification. Replace connection/action IDs and match the notification input ports."},px=Object.keys(Mm),fx=px.map((e)=>({name:e,description:Mm[e]}));var GP=v({comment:sa}),fr=_e(),xe=R().min(1),we=x(1),ca=xe.refine((e)=>e==e.trim()&&ro(e)==null,"Flow name is invalid."),Zm=ee(R(),ee(R(),fr)),Fm=v({nodeId:xe,outputs:ee(R(),fr)}),H={canvas:v({command:Mn,version:we}),authoringCheck:Vs,authoringEdit:rr,authoringRead:go,authoringSearch:ho,authoringSchema:Sf,loadOpenApiDocument:v({url:R().min(1).max(8192),version:we}),createEventSource:zm,updateEventSource:Dm,eventSourceRevision:Vm,importFlow:v({file:fr,name:ca.optional(),teamId:xe.optional(),version:we}),createFlow:v({name:ca,teamId:xe.optional(),version:we}),renameFlow:v({name:ca,version:we}),changeDraft:v({expectedRevisionId:xe,operations:j(fr).min(1),version:we}),repairDraft:v({expectedRevisionId:xe,version:we}),upgradeDraft:v({expectedRevisionId:xe,version:we}),setEnabled:v({enabled:le(),expectedPublicationId:xe,version:we}),updatePresentation:v({expectedRevision:ge().positive(),value:ee(R(),fr),version:we}),checkFlow:v({engineContract:xe,version:we}),publishFlow:v({engineContract:xe,expectedLivePublicationId:xe.nullable(),version:we}),rollbackFlow:v({expectedLivePublicationId:xe,version:we}),createDraftRun:v({engineContract:xe,inputs:Zm,trigger:Fm,version:x(2)}),createLiveRun:v({publicationId:xe,inputs:Zm,trigger:Fm,version:x(2)}),resolveWait:v({action:ce(["approve","continue","reject"]),comment:sa,version:we}),putVariable:v({value:R().refine((e)=>new TextEncoder().encode(e).byteLength<=65536,"Variable value is too large.")}),queryConnectorAccessCandidates:v({providerIds:j(xe.max(256)).min(1).refine((e)=>new Set(e).size==e.length,"Duplicate provider IDs."),version:we}),removeConnectionUsage:v({connectionId:xe,expectedRevisionId:xe,expectedAccessRevision:ge().nonnegative(),version:we}),setConnectorService:v({expectedAccessRevision:ge().nonnegative(),version:we}),addProviderAccessBinding:v({accessBindingId:xe,expectedAccessRevision:ge().nonnegative(),version:we}),removeProviderAccessBinding:v({accessBindingId:xe,expectedAccessRevision:ge().nonnegative(),version:we}),versionOnly:v({version:we})};function Q(e){return(n)=>e.parse(n)}var $o={canvas:Q(H.canvas),authoringCheck:Q(H.authoringCheck),authoringEdit:Q(H.authoringEdit),authoringRead:Q(H.authoringRead),authoringSearch:Q(H.authoringSearch),authoringSchema:Q(H.authoringSchema),loadOpenApiDocument:Q(H.loadOpenApiDocument),createEventSource:Q(H.createEventSource),updateEventSource:Q(H.updateEventSource),eventSourceRevision:Q(H.eventSourceRevision),importFlow:Q(H.importFlow),createFlow:Q(H.createFlow),renameFlow:Q(H.renameFlow),changeDraft(e){let n=H.changeDraft.parse(e);return{...n,operations:aa(n.operations)}},repairDraft:Q(H.repairDraft),upgradeDraft:Q(H.upgradeDraft),setEnabled:Q(H.setEnabled),updatePresentation:Q(H.updatePresentation),checkFlow:Q(H.checkFlow),publishFlow:Q(H.publishFlow),rollbackFlow:Q(H.rollbackFlow),createDraftRun:Q(H.createDraftRun),createLiveRun:Q(H.createLiveRun),resolveWait:Q(H.resolveWait),putVariable:Q(H.putVariable),queryConnectorAccessCandidates:Q(H.queryConnectorAccessCandidates),removeConnectionUsage:Q(H.removeConnectionUsage),setConnectorService:Q(H.setConnectorService),addProviderAccessBinding:Q(H.addProviderAccessBinding),removeProviderAccessBinding:Q(H.removeProviderAccessBinding),versionOnly:Q(H.versionOnly)};var ua=["expected-revision","idempotency-key"],la=["cursor","limit"],Jm=[["canvas","<flow> (--input JSON|@file|- | --file path|-)",["input","file"]],["read","<flow> [--input JSON|@file|- | --file path|-]",["input","file"]],["search","<flow> (--input JSON|@file|- | --file path|-)",["input","file"]],["edit","<flow> (--input JSON|@file|- | --file path|-)",["input","file"]],["list","[--cursor <cursor>] [--limit <count>]",la],["export","<flow>",[]],["import","--file <path|->",["file","name","idempotency-key"]],["create","<name>",["idempotency-key"]],["show","<flow>",[]],["live","<flow>",[]],["rename","<flow> <new-name>",[]],["delete","<flow> --yes",["yes"]],["check","<flow> [--revision <revisionId>]",["revision"]],["enable","<flow> --expected-publication <publicationId>",["expected-publication"]],["disable","<flow> --expected-publication <publicationId>",["expected-publication"]],["connector code-access","<flow> [--publication <publicationId>]",["publication"]],["connector candidates","<flow> <provider> [provider ...]",[]],["connector code-allow","<flow> <provider> <binding> <access-revision>",[]],["connector code-remove","<flow> <provider> <binding> <access-revision>",[]],["connector remove-usage","<flow> <connection> <access-revision>",ua],["connector providers","[--flow <flow>]",["flow"]],["connector teams","",[]],["connector search","<query> [--flow <flow>]",["flow"]],["connector show","<action> [--flow <flow>]",["flow"]],["connector connections","<service> [--flow <flow>]",["flow"]],["event-source list","",[]],["trigger search","[query]",[]],["trigger show","<key>",[]],["run","<flow>",[...ua,"expected-publication","source","trigger","outputs","input","wait","timeout"]],["runs list","--flow <flow>",["flow","status","pending-wait",...la]],["runs show","<run>",[]],["runs wait","<run>",["timeout"]],["runs resolve","<run> <wait> <continue|approve|reject>",["comment"]],["runs events","<run>",["after","limit","follow","timeout"]],["runs result","<run>",[]],["runs results","<run> [--after <resultId>]",["after"]],["runs read-result","<run> <result>",["pointer","offset","limit","max-bytes"]],["runs download-result","<run> <result>",[]],["runs cancel","<run>",[]],["publish","<flow>",[...ua,"expected-publication","timeout"]],["publications list","<flow>",la],["publications show","<flow> <publication>",[]],["publications wait","<flow> <operation>",["timeout"]],["publications operation","<flow> <operation>",[]],["rollback","<flow> <publication>",["expected-publication","idempotency-key"]],["open","[flow]",[]],["workbench","[flow]",[]],["schema","[read|search|edit|check|node-type]",["flow","input"]]],gx={revision:{description:"Exact Revision to read or check; defaults to the current Draft.",type:"string"},publication:{description:"Exact Publication ID whose fixed Code connections are read; defaults to the Draft.",type:"string"},pointer:{description:"JSON Pointer within the stored result; defaults to the root.",type:"string"},offset:{description:"Page offset at the selected pointer.",type:"integer",minimum:0,default:0},"max-bytes":{description:"Maximum result page bytes.",type:"integer",minimum:1,maximum:1048576,default:15000},"expected-revision":{description:"Base Revision ID from read. Required with an explicit idempotency key for draft edits and draft runs.",type:"string"},"expected-publication":{description:"Fixed Publication ID. Use none when publishing without a Live Publication.",type:"string"},"idempotency-key":{description:"Stable identity of one mutation. Reuse only with the identical arguments and base identity.",type:"string"},source:{description:"Execution source.",type:"string",enum:["draft","live"],default:"draft"},trigger:{description:"Exact Trigger ID or unambiguous name. The Start node is selected automatically; a sole legacy Manual Trigger remains supported.",type:"string"},timeout:{description:"Wait budget in milliseconds; expiration does not cancel the operation. For node set, the node execution timeout.",type:"integer",minimum:1,default:60000},limit:{description:"Maximum items in one page.",type:"integer",minimum:1,maximum:100,default:100},after:{description:"Resume events after this sequence number; use nextAfter from the preceding response.",type:"integer",minimum:0,default:0},cursor:{description:"Opaque nextCursor from the preceding page; keep the same filters.",type:"string"},comment:{description:"Optional plain-text Wait decision comment (up to 2,000 Unicode code points).",type:"string"},"pending-wait":{description:"List runs with unresolved waits, including running and queued runs.",type:"boolean"},status:{description:"Filter runs by status.",type:"string",enum:["queued","starting","running","waiting","completed","failed","canceled","indeterminate"]},file:{description:"Authoring request or workflow JSON file path, or - for stdin.",type:"string"},code:{description:"JavaScript source, @file, or - for stdin.",type:"string"},input:{description:"Authoring request JSON; literal JSON, @file, or -. For run, node ID to input values.",type:"string"},outputs:{description:"Start parameters or other Trigger outputs: literal JSON, @file, or -. Defaults to {}.",type:"string"},set:{description:"handle=value; repeat for multiple fields. Values use port schemas, JSON, @file, or -.",type:"string"},unset:{description:"Input/config handle to remove; repeat for multiple fields.",type:"string"},connection:{description:"Exact active Connection ID, unambiguous display name, or default.",type:"string"},flow:{description:"Exact Flow ID or unambiguous name; fixes Connector Team scope.",type:"string"},name:{description:"Display name.",type:"string"},description:{description:"Trigger description.",type:"string"},cron:{description:"Cron expression; combine with --timezone. Mutually exclusive with --every.",type:"string"},timezone:{description:"IANA time zone for --cron.",type:"string"},every:{description:"Interval such as 5m, 1h, or 1d. Mutually exclusive with --cron.",type:"string"},wait:{description:"Wait until terminal, waiting for an action, or the wait budget expires."},follow:{description:"Stream event pages as NDJSON with --json; stop on terminal, Wait, or timeout."},full:{description:"Include complete Revision content, schemas, source code and revision metadata."},yes:{description:"Confirm the requested deletion."},json:{description:"Machine-readable JSON results and errors; NDJSON for followed events."},help:{description:"Show this command contract without contacting the host."}};function da(e,n="oo flow"){let t=e.join(" ");return Jm.filter(([r])=>t==""||r==t||r.startsWith(`${t} `)).map(([r,o,i])=>({command:r,usage:`${n} ${r} ${o} [--json]`,options:[...i,"json","help"].map((s)=>Object.assign({name:`--${s}`,value:!["json","help","wait","follow","full","yes","pending-wait"].includes(s),repeatable:s=="set"||s=="unset"},gx[s],r=="runs results"&&s=="after"?{type:"string",minimum:void 0,default:void 0,description:"Result ID from nextAfter on the preceding page."}:{},r=="runs read-result"&&s=="limit"?{default:20}:{}))}))}function Lm(e){return Jm.find(([n])=>n==e.slice(0,n.split(" ").length).join(" "))?.[2]}function qm(e="edits"){let n=Ms(e);if(n!=null)return n;if(e=="edits")return Zs();if(e=="outputs")return{$schema:"https://json-schema.org/draft/2020-12/schema",type:"object",description:"Named Start parameters or other Trigger outputs. Start uses the workflow inputDefs returned by flow read; other triggers define their own output contracts. Omitted nullable Start parameters become null; required parameters must be supplied."};if(fo.includes(e))return Zs(e);if(e=="input")return{$schema:"https://json-schema.org/draft/2020-12/schema",type:"object",additionalProperties:{type:"object",additionalProperties:!0},description:"Node ID -> input handle -> JSON value."};return}function pa(e){if(e=="canvas")return{request:Tt(Mn,{io:"input"}),guidance:"Broadcast transient viewport commands; success does not confirm execution. No Presentation save, offline queue or replay. Pan uses screen pixels; zoom is an absolute ratio (0.1\u20133); fit includes all nodes. Repeating pan moves again; do not automatically retry an uncertain response.",examples:[{type:"focus",nodeId:"NODE_ID"},{type:"zoom",zoom:0.8},{type:"pan",dx:200,dy:-100},{type:"fit"}]};return Ms(e)}function Um(e,n="oo flow"){if(e=="export")return[`${n} export FLOW_ID > template.openflow.json`];if(e=="import")return[`${n} import --file template.openflow.json --name "Imported workflow" --idempotency-key IMPORT_KEY --json`];if(e=="schema")return[`${n} schema read --json`,`${n} schema agent --json`,`${n} schema --flow FLOW_ID --input '{"action":"ACTION_ID"}' --json`];let t=pa(e);if(t==null)return hx(n);if(e=="check")return[`${n} check FLOW_ID --revision REVISION --json`];return t.examples.map((r)=>`${n} ${e} FLOW_ID${Object.keys(r).length==0?"":` --input '${JSON.stringify(r)}'`} --json`)}function hx(e){return[`${e} list --limit 20 --json`,`${e} read FLOW_ID --json`,`${e} live FLOW_ID --json`,`${e} schema code --json`,`${e} edit FLOW_ID --file edits.json --json`,`${e} connector search email --flow FLOW_ID --json`,`${e} run FLOW_ID --expected-revision REVISION_ID --idempotency-key RUN_KEY --wait --timeout 60000 --json`,`${e} runs wait RUN_ID --timeout 60000 --json`,`${e} runs resolve RUN_ID WAIT_ID approve --json`,`${e} runs events RUN_ID --after 0 --follow --timeout 60000 --json`]}import{basename as bx}from"path";async function Bm(e,n,t,r,o){let[i,s,a,...c]=t;switch(i){case"code-access":case"candidates":case"code-allow":case"code-remove":case"remove-usage":{let u=i=="code-access"?1:i=="candidates"?2:i=="remove-usage"?3:4;if(i=="candidates"?t.length<u+1:t.length!=u+1)throw new C("cli.invalid-arguments",`Invalid arguments for connector ${i}. See --help.`);let l=yx(n),f;if(i=="code-access")f=r.publication==null?await e.getConnectorAccess(l):await e.getPublishedConnectorAccess(l,r.publication);else if(i=="candidates")f=await e.listProviderAccessBindingCandidates(l,t.slice(2));else{let m=Number(t.at(-1));if(!Number.isSafeInteger(m)||m<0)throw new C("cli.invalid-arguments","Access revision must be a nonnegative integer.");if(i=="remove-usage"){let h=await Sm(e,n,r);f=await e.removeConnectionUsage(l,a,h.draft.revisionId,m,r.idempotencyKey)}else if(i=="code-allow")f=await e.addProviderAccessBinding(l,a,c[0],m);else f=await e.removeProviderAccessBinding(l,a,c[0],m)}V(o,r.json,{...f,kind:`connector.${i}`},JSON.stringify(f,null,2));return}case"providers":{if(s!=null)throw new C("cli.invalid-arguments",`Usage: ${o.commandPrefix??"oo flow"} connector providers [--flow <flow>] [--json]`);let u=await e.listConnectorProviders(void 0,n?.flowId);V(o,r.json,{providers:u,kind:"connector.providers",version:1},u.map((l)=>`${l.serviceName} ${l.serviceId}`).join(`
|
|
63
63
|
`));return}case"teams":{if(s!=null)throw new C("cli.invalid-arguments",`Usage: ${o.commandPrefix??"oo flow"} connector teams [--json]`);let u=await e.listConnectorTeams();V(o,r.json,{...u,kind:"connector.teams"},u.teams.map((l)=>`${l.name} ${l.id}`).join(`
|
|
64
|
-
`));return}case"search":{if(s==null||a!=null)throw new C("cli.invalid-arguments",`Usage: ${o.commandPrefix??"oo flow"} connector search <query> [--json]`);let u=s.trim();if(u.length==0||u.length>256)throw new C("cli.invalid-arguments","Connector search query must contain 1\u2013256 characters.");let l=await e.searchConnectorActions(u,void 0,n?.flowId);V(o,r.json,{actions:l.map(
|
|
65
|
-
`));return}case"show":{if(s==null||a!=null)throw new C("cli.invalid-arguments",`Usage: ${o.commandPrefix??"oo flow"} connector show <action> [--json]`);let u=await
|
|
66
|
-
`));return}default:throw new C("cli.invalid-arguments",`Usage: ${o.commandPrefix??"oo flow"} connector <providers|teams|search|show|connections> ...`)}}async function
|
|
67
|
-
`));return}case"show":{if(i==null||s!=null)throw new C("cli.invalid-arguments",`Usage: ${r.commandPrefix??"oo flow"} trigger show <key> [--json]`);let a=await
|
|
68
|
-
`)}async function
|
|
69
|
-
`));return}case"show":{oe(i,1,`${r.commandPrefix??"oo flow"} runs show <run> [--json]`);let s=await e.getRun(i[0]);V(r,t.json,{kind:"run.show",run:s,version:1},lr(s));return}case"wait":{oe(i,1,`${r.commandPrefix??"oo flow"} runs wait <run> [--timeout <milliseconds>] [--json]`);let s=i[0],a=Date.now()+(t.timeoutMs??60000);try{let c=await e.getRun(s,AbortSignal.timeout(t.timeoutMs??60000)),u=await
|
|
70
|
-
`)),!t.follow)return;if(u=await e.getRun(s,AbortSignal.timeout(Math.max(1,c-Date.now()))),
|
|
71
|
-
`))}async function
|
|
72
|
-
`));return}if((o=="operation"||o=="wait")&&s!=null){let u=Date.now()+(t.timeoutMs??60000);try{let l=await e.getPublishOperation(c.flowId,s,o=="wait"?AbortSignal.timeout(t.timeoutMs??60000):void 0),
|
|
73
|
-
`);return}case"connector":{let a=["code-access","candidates","code-allow","code-remove","remove-usage"].includes(i[0]??"")?await
|
|
74
|
-
`));return}case"run":return await
|
|
75
|
-
`));return}case"export":{oe(i,1,`${r.commandPrefix??"oo flow"} export <flow>`);let s=await he(e,i[0]);r.stdout.write(Zf(await e.exportFlow(s.flowId)));return}case"import":{if(oe(i,0,`${r.commandPrefix??"oo flow"} import --file <path|-> [--name name] [--json]`),t.file==null)throw new C("cli.invalid-arguments","Import requires --file <path|->.");let s=Mf(await ln(t.file=="-"?"-":`@${t.file}`,"file","flow.import-unreadable",r)),a=t.name??s.name??(t.file=="-"?Ca(r.language??"en"):Ff(gx(t.file))),c=await e.importFlow(s,{name:Ao(a,"Flow"),idempotencyKey:t.idempotencyKey});V(r,t.json,{flow:c,idempotencyKey:t.idempotencyKey,kind:"flow.import",version:1},Cn(c));return}case"create":{oe(i,1,`${r.commandPrefix??"oo flow"} create <name> [--json]`);let s=await e.createFlow(Ao(i[0],"Flow"),t.idempotencyKey);V(r,t.json,{flow:s,idempotencyKey:t.idempotencyKey,kind:"flow.create",version:1},Cn(s));return}case"live":{oe(i,1,`${r.commandPrefix??"oo flow"} live <flow> [--json]`);let s=await he(e,i[0]),a=await e.getLiveDetails(s.flowId);V(r,t.json,{kind:"flow.live",live:a,version:1},$o(a));return}case"show":{oe(i,1,`${r.commandPrefix??"oo flow"} show <flow> [--json]`);let s=await he(e,i[0]);V(r,t.json,{flow:s,kind:"flow.show",version:1},Cn(s));return}case"rename":{oe(i,2,`${r.commandPrefix??"oo flow"} rename <flow> <new-name> [--json]`);let s=await he(e,i[0]),a=await e.renameFlow(s.flowId,Ao(i[1],"Flow"));V(r,t.json,{flow:a,kind:"flow.rename",version:1},Cn(a));return}case"delete":{if(oe(i,1,`${r.commandPrefix??"oo flow"} delete <flow> --yes [--json]`),!t.yes)throw new C("flow.confirmation-required","Flow deletion requires --yes.");let s=await he(e,i[0]),a=await e.deleteFlow(s.flowId);V(r,t.json,{flow:a,kind:"flow.delete",version:1},Cn(a));return}case"enable":case"disable":{if(oe(i,1,`${r.commandPrefix??"oo flow"} ${o} <flow> --expected-publication <publicationId>`),t.expectedPublication==null||t.expectedPublication=="none")throw new C("cli.invalid-arguments","--expected-publication must identify the observed Live publication.");let s=await he(e,i[0]),a=await e.setFlowEnabled(s.flowId,t.expectedPublication,o=="enable");V(r,t.json,{flow:a,kind:`flow.${o}`,version:1},Cn(a));return}case"check":{oe(i,1,`${r.commandPrefix??"oo flow"} check <flow> [--revision <revisionId>] [--json]`);let s=await he(e,i[0]),a=t.revision??s.draftRevisionId,c=await e.checkAuthoring(s.flowId,a);return V(r,t.json,{check:c,valid:c.valid,revisionId:a,kind:"flow.check",scope:"revision",version:1},`${c.valid?"valid":"invalid"} revision ${s.name} ${s.flowId}`),c.valid?0:1}default:throw new C("cli.invalid-arguments",`Usage: ${r.commandPrefix??"oo flow"} <list|create|show|live|read|search|edit|canvas|schema|rename|delete|check|enable|disable|connector|event-source|trigger|run|runs|publish|publications|rollback|workbench>`)}}async function hx(e,n){let t=n[0];if(t==null)throw new C("cli.invalid-arguments","A Flow reference is required.");return await he(e,t)}var dt={};var eg=(e)=>e,_o=Object.is,yx=(e,n)=>{if(_o(e,n))return!0;if(!Array.isArray(e)||!Array.isArray(n))return!1;let t=e.length;if(n.length!==t)return!1;for(let r=0;r<t;r++)if(!_o(e[r],n[r]))return!1;return!0},bx=(e)=>e.value,wx=(e)=>e.map(bx),xx=(e)=>e.$version,No=(e,n)=>{try{e(n)}catch(t){console.error(t)}},ng=(e,n)=>(e.set=n,e);var vx=Promise.resolve(),pa=new Set,kx=new Set,mr=pa,fa,Sx=()=>{let e=mr;mr=mr===pa?kx:pa,fa=!1;for(let n of e)n.t();e.clear()},Ix=(e)=>{mr.add(e),fa=fa||vx.then(Sx)},Cx=(e)=>mr.delete(e);var Xm=new FinalizationRegistry(No),tg=class{constructor(e,n,t){if(this.#r=e,this.q=(n?.equal??_o)||void 0,this.e=n?.eager,this.m=n?.name,this.#n=n?.onDisposeValue,t){let r=new WeakRef(this),o=()=>{if(i){let s=i;i=void 0,s()}},i=t(()=>{let s=r.deref();if(s)s.n();else o()});if(i)Xm.register(this,this.#e=o)}}g=this;b=new Map;s=4;v;c=dt;q;e;m;u=()=>{if(this.s&4){this.s&=-5;let e=this.#r();if(this.c===dt)this.w(e);else if(!this.q?.(e,this.c)){if(this.w(e),this.s&1)this.s|=2}}return this.c};n=()=>{if(this.#o)console.error(this.c,Error(`${this.m||""} disposed`));if(this.s|=4,this.b.size){if(this.s|=1,this[3])this.#t(3);if(this[2]){if(this.u(),this.s&2)this.#t(2)}if(this[1])Ix(this);else this.s&=-4}};a(e,n){let t=this.b.get(e);if(t)this[t]--;return this.b.set(e,n),this[n]++,()=>this.r(e)}r(e){if(e){let n=this.b.get(e);if(n)this.b.delete(e),this[n]--}else this.b.clear(),this[1]=this[2]=this[3]=0,Cx(this)}t(){if(this[1]){if(this.u(),this.s&2)this.#t(1)}this.s&=-4}d(){let e=this.c;if(this.r(),Xm.unregister(this),this.#e?.(),this.#o=!0,this.#n&&e!==dt)this.#n(e)}w(e){this.w=this.q?.(e,e)?this.y:this.x,this.w(e)}x(e){let n=this.c;if(this.c=e,this.v=Symbol(),this.#n&&n!==dt&&n!==e)this.#n(n)}y(e){let n=this.c;if(this.c=this.v=e,this.#n&&n!==dt&&n!==e)this.#n(n)}[1]=0;[2]=0;[3]=0;#e;#n;#r;#t(e){for(let[n,t]of this.b)if(t===e)No(n,this.c)}#o},Ex=class{#e=new WeakSet;constructor(e){this.g=e.g,this.e=e.e,this.u=e.u,this.n=e.n,this.b=e.b}get v(){return this.g.v}g;b;e;u;n;a(e,n){return this.#e.add(e),this.g.a(e,n)}r(e){if(e){if(this.#e.has(e))this.#e.delete(e),this.g.r(e)}else for(let n of this.g.b.keys())this.r(n)}d(){this.r()}},ma=class{#e;constructor(e){this.#e=e,this.get=e.u,e.u()}get name(){return this.#e.m}get $version(){return this.get(),this.#e.v}get value(){return this.get()}set value(e){this.set?.(e)}set;get;ref(e){let n=new ma(new Ex(this.#e));return e&&this.set?ng(n,this.set):n}reaction(e,n=this.#e.e){return this.#e.a(e,n?2:1)}subscribe(e,n=this.#e.e){let t=this.reaction(e,n);return No(e,this.get()),t}$valCompute(e){return this.#e.a(e,3)}unsubscribe(e){this.#e.r(e)}dispose(){this.#e.d()}toString(){return String(this.get())}toJSON(e){let n=this.get();return n&&n.toJSON?n.toJSON(e):n}},Ox=(e,n)=>{let t=e,o=new tg(()=>t,n),i=(a)=>{if(!o.q?.(a,t))t=a,o.n()};return[new ma(o),i]},ga=(e,n)=>ng(...Ox(e,n));var rg=(e,n,t)=>new ma(new tg(e,t,n)),og=(e,n=eg,t)=>{let r,o;return rg(()=>{let i=e.map(xx);if(!o||!yx(i,o))o=i,r=n(wx(e));return r},(i)=>{let s=e.map((a)=>a.$valCompute(i));return()=>s.forEach(No)},t)};var ha=(e,n=eg,t)=>{let r,o=dt;return rg(()=>{let i=e.$version;if(!_o(i,o))o=i,r=n(e.value);return r},(i)=>e.$valCompute(i),t)};var ig=(e,n={},t="")=>{for(let[r,o]of Object.entries(e))if(typeof o==="string")n[t+r]=o;else ig(o,n,t+r+".");return n},Rx=(e)=>{let n=[],t=[],r=/{{(\S+?)}}/gi,o,i=0;while(o=r.exec(e))n.push(e.slice(i,o.index),""),t.push(o[1]),i=o.index+o[0].length;if(n.push(e.slice(i)),t.length<=0)return!1;return(s)=>{for(let a=t.length-1;a>=0;a--)n[a*2+1]=s[t[a]]??t[a];return n.join("")}},sg=class e{constructor(n,t,r){this.t=(i,s)=>this.t$.get()(i,s),this.fetcher=r?.fetcher;let o=new Map;this.locales$=ga(t),this.lang$=ga(n),this.locale$=og([this.lang$,this.locales$],([i,s])=>s[i]||{}),this.a=ha(this.locale$,ig),this.t$=ha(this.a,(i)=>((s,a,c)=>{if(c){let u=c["@"];if(u!=null){let l=`${a}@${u}`;if(s[l])a=l}else{let l=c[":option"];if(l!=null){let p;a=s[p=`${a}.${l}`]||s[p=`${a}.other`]?p:a}}if(s[a]){let l=o.get(a);if(l??o.set(a,l=Rx(s[a])),l)return l(c)}}return s[a]||a}).bind(o.clear(),i))}static async preload(n,t){return new e(n,{[n]:await t(n)},{fetcher:t})}get lang(){return this.lang$.value}get locales(){return this.locales$.value}get locale(){return this.locale$.value}async switchLang(n){if(!this.locales$.value[n]&&this.fetcher)this.addLocale(n,await this.fetcher(n));this.lang$.set(n)}hasKey(n){return!!this.a.value[n]}addLocale(n,t){this.locales$.set({...this.locales,[n]:t})}dispose(){this.lang$.dispose(),this.t$.dispose(),this.locales$.dispose(),this.locale$.dispose(),this.a.dispose()}};var ag={help:{usage:"Usage: {{command}}",title:"Open Flow commands",options:"Options: --json, --cursor <cursor>, --limit <count>"}};var cg={help:{usage:"Utilisation : {{command}}",title:"Commandes Open Flow",options:"Options : --json, --cursor <cursor>, --limit <count>"}};var ug={help:{usage:"\u4F7F\u3044\u65B9\uFF1A{{command}}",title:"Open Flow \u30B3\u30DE\u30F3\u30C9",options:"\u30AA\u30D7\u30B7\u30E7\u30F3\uFF1A--json\u3001--cursor <cursor>\u3001--limit <count>"}};var lg={help:{usage:"\uC0AC\uC6A9\uBC95: {{command}}",title:"Open Flow \uBA85\uB839\uC5B4",options:"\uC635\uC158: --json, --cursor <cursor>, --limit <count>"}};var dg={help:{usage:"\u0418\u0441\u043F\u043E\u043B\u044C\u0437\u043E\u0432\u0430\u043D\u0438\u0435: {{command}}",title:"\u041A\u043E\u043C\u0430\u043D\u0434\u044B Open Flow",options:"\u041F\u0430\u0440\u0430\u043C\u0435\u0442\u0440\u044B: --json, --cursor <cursor>, --limit <count>"}};var pg={help:{usage:"\u7528\u6CD5\uFF1A{{command}}",title:"Open Flow \u547D\u4EE4",options:"\u9009\u9879\uFF1A--json\u3001--cursor <cursor>\u3001--limit <count>"}};var fg={help:{usage:"\u7528\u6CD5\uFF1A{{command}}",title:"Open Flow \u547D\u4EE4",options:"\u9078\u9805\uFF1A--json\u3001--cursor <cursor>\u3001--limit <count>"}};var zx={en:ag,"zh-CN":pg,"zh-TW":fg,ja:ug,ko:lg,ru:dg,fr:cg},Dx=Object.fromEntries(Fo.map((e)=>[e,zx[e]]));function mg(e=Sa){return new sg(br([e]),Dx)}function Vx(e,n){let t=n.filter((i)=>!i.startsWith("-")),r=la(t,e.commandPrefix);while(r.length==0&&t.length>0)t.pop(),r=la(t,e.commandPrefix);let o=mg(e.language);try{let i=r.length==1?da(r[0].command):void 0,s=qm(r.length==1?r[0].command:"",e.commandPrefix),a={kind:"cli.help",version:1,commands:r.length==1?r:r.map(({command:c,usage:u})=>({command:c,usage:u})),...i==null?{}:{request:i.request},examples:s,exitCodes:{0:"Success or accepted asynchronous operation.",1:"Error or unsuccessful terminal Run.",2:"Run is waiting for an explicit action; inspect run.waits.",3:"Waiting timed out or publication is pending; the operation continues."},notes:i==null?[...e.scopeGuidance??["The oo host selects the team for the whole invocation with --team <name>; Flow commands use that authenticated scope."],"--timeout is a wait budget in milliseconds (default 60000).","--follow --json writes NDJSON pages immediately; resume from nextAfter.","Use read/search to locate nodes, schema read|search|edit|check for requests, and schema <type> for configuration and ports.","Use edit with baseRevision, requestId and an ordered edits array. Read selected text before an exact text.edit.","Retry mutations with the same idempotency key, fixed revision/publication and identical arguments."]:[i.guidance,...r[0].command=="check"?[]:["Use either --input (literal JSON, @file, or - for stdin) or --file (path or -), never both."]]};return n.includes("--json")?JSON.stringify(a):[o.t("help.title"),"",...r.map((c)=>r.length!=1?c.usage:`${c.usage}
|
|
64
|
+
`));return}case"search":{if(s==null||a!=null)throw new C("cli.invalid-arguments",`Usage: ${o.commandPrefix??"oo flow"} connector search <query> [--json]`);let u=s.trim();if(u.length==0||u.length>256)throw new C("cli.invalid-arguments","Connector search query must contain 1\u2013256 characters.");let l=await e.searchConnectorActions(u,void 0,n?.flowId);V(o,r.json,{actions:l.map(Ks),kind:"connector.search",query:u,version:1},l.map(ra).join(`
|
|
65
|
+
`));return}case"show":{if(s==null||a!=null)throw new C("cli.invalid-arguments",`Usage: ${o.commandPrefix??"oo flow"} connector show <action> [--json]`);let u=await Im(e,s,n?.flowId);V(o,r.json,{action:u,kind:"connector.show",version:1},ra(u));return}case"connections":{if(s==null||a!=null)throw new C("cli.invalid-arguments",`Usage: ${o.commandPrefix??"oo flow"} connector connections <service> [--json]`);let u=await e.listConnectorConnections(s,void 0,n?.flowId);V(o,r.json,{connections:u,kind:"connector.connections",serviceId:s,version:1},u.map(Om).join(`
|
|
66
|
+
`));return}default:throw new C("cli.invalid-arguments",`Usage: ${o.commandPrefix??"oo flow"} connector <providers|teams|search|show|connections> ...`)}}async function Km(e,n,t,r){let[o,i,s]=n;switch(o){case"search":{if(s!=null)throw new C("cli.invalid-arguments",`Usage: ${r.commandPrefix??"oo flow"} trigger search [query] [--json]`);let a=i?.trim().toLowerCase();if(a!=null&&(a.length==0||a.length>256))throw new C("cli.invalid-arguments","Trigger search query must contain 1\u2013256 characters.");let c=Hs(await e.listTriggerKeys(),a);V(r,t.json,{keys:c,kind:"trigger.search",query:a,version:1},c.map(ta).join(`
|
|
67
|
+
`));return}case"show":{if(i==null||s!=null)throw new C("cli.invalid-arguments",`Usage: ${r.commandPrefix??"oo flow"} trigger show <key> [--json]`);let a=await Em(e,i);V(r,t.json,{definition:a,kind:"trigger.show",version:1},ta(a));return}default:throw new C("cli.invalid-arguments",`Usage: ${r.commandPrefix??"oo flow"} trigger <search|show> ...`)}}function yx(e){if(e==null)throw new C("cli.invalid-arguments","A Flow reference is required.");return e.flowId}function _o(e){if(e.publication==null)return`not-published ${e.flowId}`;return[`live ${e.flowId} ${e.publication.publicationId} ${e.publication.revisionId} ${e.status} enabled=${e.enabled}`,`inputDefs=${JSON.stringify(e.inputDefs)}`,...e.entries.flatMap((n)=>[`${n.type} ${n.nodeId} ${n.name}`,..."binding"in n?[` health=${n.binding.health}${n.binding.lastErrorCode==null?"":` error=${n.binding.lastErrorCode}`}`,...n.binding.listener==null?[]:[` listener=${JSON.stringify(n.binding.listener)}`],...n.binding.endpointUrl==null?[]:[` url=${n.binding.endpointUrl}`]]:[],..."provider"in n?[` provider=${n.provider} inputs=${JSON.stringify(n.inputs)}`]:[],` config=${JSON.stringify(n.config)}`])].join(`
|
|
68
|
+
`)}async function Wm(e,n,t,r){oe(n,1,`${r.commandPrefix??"oo flow"} run <flow> [--source draft|live] [--trigger <name|id>] [--outputs <json|@file|->] [--input <json|@file|->] [--wait] [--json]`);let o=await he(e,n[0]),i=await jm(t,r),s=t.source=="live"?t.expectedPublication==null?await e.getLive(o.flowId):{publication:await dr(e,o.flowId,t.expectedPublication)}:void 0;if(t.source=="live"&&s?.publication==null)throw new C("live.not-found",`Flow ${JSON.stringify(n[0])} has no Live Publication.`);let a=s?.publication?.revisionId??t.expectedRevision??o.draftRevisionId,c=await e.getRevision(o.flowId,a),u=Object.entries(c.content.document.graph.nodes).filter(([,L])=>!("inputs"in L)),l=u.filter(([,L])=>L.kind=="start"),f=l.length==1?l[0][0]:u.length==1&&u[0]?.[1].kind=="manual"?u[0][0]:void 0,m=t.trigger??f;if(m==null)throw new C("run.trigger-required","Choose a start node with --trigger <name|id>.",{candidates:u.map(([L,M])=>({triggerId:L,name:M.name}))});let h=Cm(c.content,m),g={};if(t.outputs!=null){let L=await ln(t.outputs,"--outputs","run.input-unreadable",r);try{let M=JSON.parse(L);if(M==null||typeof M!=="object"||Array.isArray(M))throw Error("Expected output object.");g=M}catch{throw new C("run.input-invalid","Trigger outputs must be valid JSON.")}}let E={nodeId:h.triggerId,outputs:g},P;if(s?.publication!=null)P=await e.createLiveRun(s.publication.publicationId,{inputs:i,trigger:E,idempotencyKey:t.idempotencyKey});else P=await e.createDraftRun(o.flowId,a,{inputs:i,trigger:E,idempotencyKey:t.idempotencyKey});let T=t.wait?await oa(e,P,r,t.timeoutMs):{run:P,timedOut:!1};return V(r,t.json,{kind:"run.create",idempotencyKey:t.idempotencyKey,...T,version:1},lr(T.run)),pr(T.run,T.timedOut)}async function Gm(e,n,t,r){let[o,...i]=n;switch(o){case"list":{if(oe(i,0,`${r.commandPrefix??"oo flow"} runs list --flow <flow> [--status <status>] [--pending-wait] [--cursor <cursor>] [--limit <count>] [--json]`),t.flow==null)throw new C("cli.invalid-arguments",`${r.commandPrefix??"oo flow"} runs list requires --flow <flow>.`);let s=await he(e,t.flow),a=await e.listRuns(s.flowId,{...t.cursor==null?{}:{cursor:t.cursor},limit:t.limit??na,...t.status==null?{}:{status:t.status},...t.pendingWait==null?{}:{pendingWait:t.pendingWait}});V(r,t.json,{kind:"run.list",...a,version:1},a.runs.map(Rm).join(`
|
|
69
|
+
`));return}case"show":{oe(i,1,`${r.commandPrefix??"oo flow"} runs show <run> [--json]`);let s=await e.getRun(i[0]);V(r,t.json,{kind:"run.show",run:s,version:1},lr(s));return}case"wait":{oe(i,1,`${r.commandPrefix??"oo flow"} runs wait <run> [--timeout <milliseconds>] [--json]`);let s=i[0],a=Date.now()+(t.timeoutMs??60000);try{let c=await e.getRun(s,AbortSignal.timeout(t.timeoutMs??60000)),u=await oa(e,c,r,Math.max(0,a-Date.now()));return V(r,t.json,{kind:"run.wait",runId:s,...u,version:1},lr(u.run)),pr(u.run,u.timedOut)}catch(c){if(Date.now()>=a||c instanceof Error&&c.name=="TimeoutError")return V(r,t.json,{kind:"run.wait",runId:s,timedOut:!0,version:1},`timeout ${s}`),3;if(c instanceof C)throw c;throw new C("run.wait-failed",c instanceof Error?c.message:String(c),{runId:s})}}case"resolve":{oe(i,3,`${r.commandPrefix??"oo flow"} runs resolve <run> <wait> <continue|approve|reject> [--comment <text>] [--json]`);let[s,a,c]=i;if(c!="continue"&&c!="approve"&&c!="reject")throw new C("cli.invalid-arguments","Invalid Wait action.");let u=await e.resolveRunWait(s,a,c,t.comment);V(r,t.json,{kind:"run.resolve",resolution:u,version:1},JSON.stringify(u));return}case"events":{oe(i,1,`${r.commandPrefix??"oo flow"} runs events <run> [--after <sequence>] [--limit <count>] [--follow] [--timeout <milliseconds>] [--json]`);let s=i[0],a=t.after??0,c=Date.now()+(t.timeoutMs??60000),u;try{do{if(t.follow&&Date.now()>=c)break;let l=await e.getRunEvents(s,{after:a,limit:t.limit??na},t.follow?AbortSignal.timeout(Math.max(1,c-Date.now())):void 0);if(a=l.nextAfter,V(r,t.json,{...l,kind:"run.events",runId:s,version:1},l.events.map(Am).join(`
|
|
70
|
+
`)),!t.follow)return;if(u=await e.getRun(s,AbortSignal.timeout(Math.max(1,c-Date.now()))),km(l.events.at(-1)))return pr(u);if(t.after!=null&&l.events.length==0&&l.done)return pr(u);if(u.waits.length>0)return V(r,t.json,{kind:"run.wait",runId:s,run:u,nextAfter:a,timedOut:!1,version:1},lr(u)),2;let f=c-Date.now();if(f<=0)break;if(l.events.length==0)await r.wait(Math.min(1000,f))}while(t.follow)}catch(l){if(!t.follow||Date.now()<c&&!(l instanceof Error&&l.name=="TimeoutError"))throw new C("run.events-failed",l instanceof Error?l.message:String(l),{runId:s,nextAfter:a})}return V(r,t.json,{kind:"run.wait",runId:s,run:u,nextAfter:a,timedOut:!0,version:1},`timeout ${s} ${a}`),3}case"results":{oe(i,1,`${r.commandPrefix??"oo flow"} runs results <run> [--after <resultId>]`);let s=await e.listRunResults(i[0],t.resultAfter);V(r,t.json,{kind:"run.results",...s},JSON.stringify(s));return}case"read-result":{oe(i,2,`${r.commandPrefix??"oo flow"} runs read-result <run> <result> [--pointer <pointer>] [--offset <offset>] [--limit <limit>] [--max-bytes <bytes>]`);let s=await e.readRunResult(i[0],i[1],{pointer:t.pointer??"",offset:t.offset??0,...t.limit==null?{}:{limit:t.limit},...t.maxBytes==null?{}:{maxBytes:t.maxBytes}});V(r,t.json,{kind:"run.result-page",...s},JSON.stringify(s));return}case"download-result":{oe(i,2,`${r.commandPrefix??"oo flow"} runs download-result <run> <result>`);let s=await e.downloadRunResult(i[0],i[1]);r.stdout.write(await s.text());return}case"result":{oe(i,1,`${r.commandPrefix??"oo flow"} runs result <run> [--json]`);let s=await e.getRunResult(i[0]);return V(r,t.json,{kind:"run.result",result:s,version:1},JSON.stringify(s)),s.status=="completed"?0:1}case"cancel":{oe(i,1,`${r.commandPrefix??"oo flow"} runs cancel <run> [--json]`);let s=await e.cancelRun(i[0]);V(r,t.json,{cancellation:s,kind:"run.cancel",version:1},`${s.status} ${s.runId} ${s.cancelAccepted?"accepted":"already-terminal"}`);return}default:throw new C("cli.invalid-arguments",`Usage: ${r.commandPrefix??"oo flow"} runs <list|show|wait|resolve|events|result|results|read-result|download-result|cancel>`)}}async function Hm(e,n,t,r){oe(n,1,`${r.commandPrefix??"oo flow"} publish <flow> [--json]`);let o=await he(e,n[0]),i=t.expectedPublication=="none"?null:t.expectedPublication??(await e.getLive(o.flowId)).publication?.publicationId??null,s=await e.publishFlow(o.flowId,t.expectedRevision??o.draftRevisionId,i,{idempotencyKey:t.idempotencyKey}),a=await ia(e,o.flowId,s,r,t.timeoutMs);if(s=a.operation,s.status=="pending")return V(r,t.json,{kind:"publication.publish",expectedPublicationId:i,idempotencyKey:t.idempotencyKey,flowId:o.flowId,...a,version:1},JSON.stringify(s)),3;if(s.status=="failed")throw new C(s.issue.code,s.issue.message,{...s.issue.nodeId==null?{}:{nodeId:s.issue.nodeId},operationId:s.operationId,flowId:o.flowId,idempotencyKey:t.idempotencyKey});let c=[],u=`${r.commandPrefix??"oo flow"} live ${o.flowId} --json`,l;try{if(l=await e.getLiveDetails(o.flowId),l.publication?.publicationId!=s.publicationId)c.push({code:"live.publication-changed",message:`Publication ${s.publicationId} succeeded. Current Live is ${l.publication?.publicationId??"not-published"}; the returned entries describe that current version.`})}catch{c.push({code:"live.details-read-failed",message:`Publication ${s.publicationId} succeeded, but its current online entries could not be read. Query ${u}.`})}let f=l?.publication?.publicationId==s.publicationId?l.publication:void 0;if(f==null)try{f=await dr(e,o.flowId,s.publicationId)}catch{c.push({code:"publication.read-failed",message:`Publication ${s.publicationId} succeeded, but its metadata could not be read. Query ${u}.`})}V(r,t.json,{kind:"publication.publish",expectedPublicationId:i,idempotencyKey:t.idempotencyKey,operation:s,...f==null?{}:{publication:f},...l==null?{}:{live:l},...c.length==0?{}:{warnings:c},version:1},[f==null?`published ${s.publicationId} ${s.revisionId}`:ur(f),...l==null?[]:[_o(l)],...c.map((m)=>`Warning: ${m.message}`)].join(`
|
|
71
|
+
`))}async function Qm(e,n,t,r){let[o,i,s,...a]=n;if(i==null||a.length>0)throw new C("cli.invalid-arguments",`Usage: ${r.commandPrefix??"oo flow"} publications <list|show> <flow> [publication]`);let c=await he(e,i);if(o=="list"){if(s!=null)throw new C("cli.invalid-arguments",`Usage: ${r.commandPrefix??"oo flow"} publications list <flow> [--cursor <cursor>] [--limit <count>]`);let u=await e.listPublications(c.flowId,{...t.cursor==null?{}:{cursor:t.cursor},limit:t.limit??ea});V(r,t.json,{flow:c,kind:"publication.list",...u,version:1},u.publications.map(ur).join(`
|
|
72
|
+
`));return}if((o=="operation"||o=="wait")&&s!=null){let u=Date.now()+(t.timeoutMs??60000);try{let l=await e.getPublishOperation(c.flowId,s,o=="wait"?AbortSignal.timeout(t.timeoutMs??60000):void 0),f=o=="wait"?await ia(e,c.flowId,l,r,Math.max(0,u-Date.now())):{operation:l,timedOut:!1};return V(r,t.json,{kind:`publication.${o}`,flowId:c.flowId,...f,version:1},JSON.stringify(f.operation)),f.operation.status=="failed"?1:f.operation.status=="pending"?3:0}catch(l){if(o=="wait"&&(Date.now()>=u||l instanceof Error&&l.name=="TimeoutError"))return V(r,t.json,{kind:"publication.wait",flowId:c.flowId,operationId:s,timedOut:!0,version:1},`timeout ${s}`),3;if(l instanceof C)throw l;throw new C("publication.wait-failed",l instanceof Error?l.message:String(l),{flowId:c.flowId,operationId:s})}}if(o=="show"&&s!=null){let u=await dr(e,c.flowId,s);V(r,t.json,{kind:"publication.show",publication:u,version:1},ur(u));return}throw new C("cli.invalid-arguments",`Usage: ${r.commandPrefix??"oo flow"} publications <list|show> <flow> [publication]`)}async function Ym(e,n,t,r){oe(n,2,`${r.commandPrefix??"oo flow"} rollback <flow> <publication> [--json]`);let o=await he(e,n[0]),i=await dr(e,o.flowId,n[1]),s=t.expectedPublication??(await e.getLive(o.flowId)).publication?.publicationId;if(s==null)throw new C("live.not-found",`Flow ${JSON.stringify(n[0])} has no Live Publication.`);let a=await e.rollbackFlow(o.flowId,i.publicationId,s,{idempotencyKey:t.idempotencyKey});V(r,t.json,{kind:"publication.rollback",expectedPublicationId:s,idempotencyKey:t.idempotencyKey,publication:a,version:1},ur(a))}async function Xm(e,n,t,r){let[o,...i]=t.positionals;switch(o){case"canvas":{if(oe(i,1,`${r.commandPrefix??"oo flow"} canvas <flow> (--input JSON|@file|- | --file path|-) [--json]`),t.file!=null&&t.input!=null)throw new C("cli.invalid-arguments","Choose --input or --file.");let s=t.file==null?t.input:t.file=="-"?"-":`@${t.file}`;if(s==null)throw new C("cli.invalid-arguments","Canvas requires --input or --file.");let a=Mn.safeParse(JSON.parse(await ln(s,"input","flow.authoring-unreadable",r)));if(!a.success)throw new C("cli.invalid-arguments",a.error.message);let c=await he(e,i[0]),u=await e.broadcastCanvas(c.flowId,a.data);V(r,t.json,{...u,kind:"flow.canvas"},`Broadcast canvas ${a.data.type} for ${c.flowId}; execution is not confirmed.`);return}case"read":case"search":case"edit":{oe(i,1,`${r.commandPrefix??"oo flow"} ${o} <flow> [--input JSON|@file|-] [--file path|-] --json`);let s=await he(e,i[0]);if(t.file!=null&&t.input!=null)throw new C("cli.invalid-arguments","Choose --input or --file.");let a=t.file==null?t.input:t.file=="-"?"-":`@${t.file}`,c=a==null?{}:JSON.parse(await ln(a,"input","flow.authoring-unreadable",r)),u=o=="read"?await e.readAuthoring(s.flowId,$o.authoringRead(c)):o=="search"?await e.searchAuthoring(s.flowId,$o.authoringSearch(c)):await e.editAuthoring(s.flowId,$o.authoringEdit(c));r.stdout.write(`${JSON.stringify(u)}
|
|
73
|
+
`);return}case"connector":{let a=["code-access","candidates","code-allow","code-remove","remove-usage"].includes(i[0]??"")?await wx(e,i.slice(1)):t.flow==null?void 0:await he(e,t.flow);return await Bm(e,a,i,t,r)}case"event-source":{if(i.length!=1||i[0]!="list")throw new C("cli.invalid-arguments",`Usage: ${r.commandPrefix??"oo flow"} event-source list [--json]`);let s=await e.listEventSources(),a=`No event sources are visible to this identity. Run "${r.commandPrefix??"oo flow"} workbench" to create and verify a Feishu event source, then list again.`;V(r,t.json,{...s,kind:"event-source.list",...s.sources.length==0?{guidance:a}:{}},s.sources.length==0?a:s.sources.map((c)=>[c.sourceId,c.name,c.teamId??"-",c.connectionId,!c.enabled?"disabled":c.verifiedAt==null?"unverified":"verified",c.eventTypes.join(",")].join("\t")).join(`
|
|
74
|
+
`));return}case"run":return await Wm(e,i,t,r);case"runs":return await Gm(e,i,t,r);case"publish":return await Hm(e,i,t,r);case"publications":return await Qm(e,i,t,r);case"rollback":return await Ym(e,i,t,r);case"trigger":return await Km(e,i,t,r);case"open":case"workbench":{if(i.length>1)throw new C("cli.invalid-arguments",`Usage: ${r.commandPrefix??"oo flow"} ${o} [flow] [--json]`);if(n.getWorkbenchUrl==null)throw new C("workbench.unavailable","This CLI host cannot provide a Workbench URL.");let s=i[0]==null?void 0:await he(e,i[0]),a=await n.getWorkbenchUrl(s?.flowId);if(o=="open")await r.openUrl(a);V(r,t.json,{...s==null?{}:{flow:s},kind:`flow.${o}`,url:a,version:1},a);return}case"list":{oe(i,0,`${r.commandPrefix??"oo flow"} list [--json]`);let s=await e.listFlows({cursor:t.cursor,limit:t.limit??100});V(r,t.json,{...s,kind:"flow.list",version:1},s.flows.map(Cn).join(`
|
|
75
|
+
`));return}case"export":{oe(i,1,`${r.commandPrefix??"oo flow"} export <flow>`);let s=await he(e,i[0]);r.stdout.write(Ff(await e.exportFlow(s.flowId)));return}case"import":{if(oe(i,0,`${r.commandPrefix??"oo flow"} import --file <path|-> [--name name] [--json]`),t.file==null)throw new C("cli.invalid-arguments","Import requires --file <path|->.");let s=Zf(await ln(t.file=="-"?"-":`@${t.file}`,"file","flow.import-unreadable",r)),a=t.name??s.name??(t.file=="-"?Ea(r.language??"en"):Jf(bx(t.file))),c=await e.importFlow(s,{name:jo(a,"Flow"),idempotencyKey:t.idempotencyKey});V(r,t.json,{flow:c,idempotencyKey:t.idempotencyKey,kind:"flow.import",version:1},Cn(c));return}case"create":{oe(i,1,`${r.commandPrefix??"oo flow"} create <name> [--json]`);let s=await e.createFlow(jo(i[0],"Flow"),t.idempotencyKey);V(r,t.json,{flow:s,idempotencyKey:t.idempotencyKey,kind:"flow.create",version:1},Cn(s));return}case"live":{oe(i,1,`${r.commandPrefix??"oo flow"} live <flow> [--json]`);let s=await he(e,i[0]),a=await e.getLiveDetails(s.flowId);V(r,t.json,{kind:"flow.live",live:a,version:1},_o(a));return}case"show":{oe(i,1,`${r.commandPrefix??"oo flow"} show <flow> [--json]`);let s=await he(e,i[0]);V(r,t.json,{flow:s,kind:"flow.show",version:1},Cn(s));return}case"rename":{oe(i,2,`${r.commandPrefix??"oo flow"} rename <flow> <new-name> [--json]`);let s=await he(e,i[0]),a=await e.renameFlow(s.flowId,jo(i[1],"Flow"));V(r,t.json,{flow:a,kind:"flow.rename",version:1},Cn(a));return}case"delete":{if(oe(i,1,`${r.commandPrefix??"oo flow"} delete <flow> --yes [--json]`),!t.yes)throw new C("flow.confirmation-required","Flow deletion requires --yes.");let s=await he(e,i[0]),a=await e.deleteFlow(s.flowId);V(r,t.json,{flow:a,kind:"flow.delete",version:1},Cn(a));return}case"enable":case"disable":{if(oe(i,1,`${r.commandPrefix??"oo flow"} ${o} <flow> --expected-publication <publicationId>`),t.expectedPublication==null||t.expectedPublication=="none")throw new C("cli.invalid-arguments","--expected-publication must identify the observed Live publication.");let s=await he(e,i[0]),a=await e.setFlowEnabled(s.flowId,t.expectedPublication,o=="enable");V(r,t.json,{flow:a,kind:`flow.${o}`,version:1},Cn(a));return}case"check":{oe(i,1,`${r.commandPrefix??"oo flow"} check <flow> [--revision <revisionId>] [--json]`);let s=await he(e,i[0]),a=t.revision??s.draftRevisionId,c=await e.checkAuthoring(s.flowId,a);return V(r,t.json,{check:c,valid:c.valid,revisionId:a,kind:"flow.check",scope:"revision",version:1},`${c.valid?"valid":"invalid"} revision ${s.name} ${s.flowId}`),c.valid?0:1}default:throw new C("cli.invalid-arguments",`Usage: ${r.commandPrefix??"oo flow"} <list|create|show|live|read|search|edit|canvas|schema|rename|delete|check|enable|disable|connector|event-source|trigger|run|runs|publish|publications|rollback|workbench>`)}}async function wx(e,n){let t=n[0];if(t==null)throw new C("cli.invalid-arguments","A Flow reference is required.");return await he(e,t)}var dt={};var ng=(e)=>e,To=Object.is,xx=(e,n)=>{if(To(e,n))return!0;if(!Array.isArray(e)||!Array.isArray(n))return!1;let t=e.length;if(n.length!==t)return!1;for(let r=0;r<t;r++)if(!To(e[r],n[r]))return!1;return!0},vx=(e)=>e.value,kx=(e)=>e.map(vx),Sx=(e)=>e.$version,No=(e,n)=>{try{e(n)}catch(t){console.error(t)}},tg=(e,n)=>(e.set=n,e);var Ix=Promise.resolve(),fa=new Set,Cx=new Set,mr=fa,ma,Ex=()=>{let e=mr;mr=mr===fa?Cx:fa,ma=!1;for(let n of e)n.t();e.clear()},Ox=(e)=>{mr.add(e),ma=ma||Ix.then(Ex)},Rx=(e)=>mr.delete(e);var eg=new FinalizationRegistry(No),rg=class{constructor(e,n,t){if(this.#r=e,this.q=(n?.equal??To)||void 0,this.e=n?.eager,this.m=n?.name,this.#n=n?.onDisposeValue,t){let r=new WeakRef(this),o=()=>{if(i){let s=i;i=void 0,s()}},i=t(()=>{let s=r.deref();if(s)s.n();else o()});if(i)eg.register(this,this.#e=o)}}g=this;b=new Map;s=4;v;c=dt;q;e;m;u=()=>{if(this.s&4){this.s&=-5;let e=this.#r();if(this.c===dt)this.w(e);else if(!this.q?.(e,this.c)){if(this.w(e),this.s&1)this.s|=2}}return this.c};n=()=>{if(this.#o)console.error(this.c,Error(`${this.m||""} disposed`));if(this.s|=4,this.b.size){if(this.s|=1,this[3])this.#t(3);if(this[2]){if(this.u(),this.s&2)this.#t(2)}if(this[1])Ox(this);else this.s&=-4}};a(e,n){let t=this.b.get(e);if(t)this[t]--;return this.b.set(e,n),this[n]++,()=>this.r(e)}r(e){if(e){let n=this.b.get(e);if(n)this.b.delete(e),this[n]--}else this.b.clear(),this[1]=this[2]=this[3]=0,Rx(this)}t(){if(this[1]){if(this.u(),this.s&2)this.#t(1)}this.s&=-4}d(){let e=this.c;if(this.r(),eg.unregister(this),this.#e?.(),this.#o=!0,this.#n&&e!==dt)this.#n(e)}w(e){this.w=this.q?.(e,e)?this.y:this.x,this.w(e)}x(e){let n=this.c;if(this.c=e,this.v=Symbol(),this.#n&&n!==dt&&n!==e)this.#n(n)}y(e){let n=this.c;if(this.c=this.v=e,this.#n&&n!==dt&&n!==e)this.#n(n)}[1]=0;[2]=0;[3]=0;#e;#n;#r;#t(e){for(let[n,t]of this.b)if(t===e)No(n,this.c)}#o},Ax=class{#e=new WeakSet;constructor(e){this.g=e.g,this.e=e.e,this.u=e.u,this.n=e.n,this.b=e.b}get v(){return this.g.v}g;b;e;u;n;a(e,n){return this.#e.add(e),this.g.a(e,n)}r(e){if(e){if(this.#e.has(e))this.#e.delete(e),this.g.r(e)}else for(let n of this.g.b.keys())this.r(n)}d(){this.r()}},ga=class{#e;constructor(e){this.#e=e,this.get=e.u,e.u()}get name(){return this.#e.m}get $version(){return this.get(),this.#e.v}get value(){return this.get()}set value(e){this.set?.(e)}set;get;ref(e){let n=new ga(new Ax(this.#e));return e&&this.set?tg(n,this.set):n}reaction(e,n=this.#e.e){return this.#e.a(e,n?2:1)}subscribe(e,n=this.#e.e){let t=this.reaction(e,n);return No(e,this.get()),t}$valCompute(e){return this.#e.a(e,3)}unsubscribe(e){this.#e.r(e)}dispose(){this.#e.d()}toString(){return String(this.get())}toJSON(e){let n=this.get();return n&&n.toJSON?n.toJSON(e):n}},jx=(e,n)=>{let t=e,o=new rg(()=>t,n),i=(a)=>{if(!o.q?.(a,t))t=a,o.n()};return[new ga(o),i]},ha=(e,n)=>tg(...jx(e,n));var og=(e,n,t)=>new ga(new rg(e,t,n)),ig=(e,n=ng,t)=>{let r,o;return og(()=>{let i=e.map(Sx);if(!o||!xx(i,o))o=i,r=n(kx(e));return r},(i)=>{let s=e.map((a)=>a.$valCompute(i));return()=>s.forEach(No)},t)};var ya=(e,n=ng,t)=>{let r,o=dt;return og(()=>{let i=e.$version;if(!To(i,o))o=i,r=n(e.value);return r},(i)=>e.$valCompute(i),t)};var sg=(e,n={},t="")=>{for(let[r,o]of Object.entries(e))if(typeof o==="string")n[t+r]=o;else sg(o,n,t+r+".");return n},Px=(e)=>{let n=[],t=[],r=/{{(\S+?)}}/gi,o,i=0;while(o=r.exec(e))n.push(e.slice(i,o.index),""),t.push(o[1]),i=o.index+o[0].length;if(n.push(e.slice(i)),t.length<=0)return!1;return(s)=>{for(let a=t.length-1;a>=0;a--)n[a*2+1]=s[t[a]]??t[a];return n.join("")}},ag=class e{constructor(n,t,r){this.t=(i,s)=>this.t$.get()(i,s),this.fetcher=r?.fetcher;let o=new Map;this.locales$=ha(t),this.lang$=ha(n),this.locale$=ig([this.lang$,this.locales$],([i,s])=>s[i]||{}),this.a=ya(this.locale$,sg),this.t$=ya(this.a,(i)=>((s,a,c)=>{if(c){let u=c["@"];if(u!=null){let l=`${a}@${u}`;if(s[l])a=l}else{let l=c[":option"];if(l!=null){let f;a=s[f=`${a}.${l}`]||s[f=`${a}.other`]?f:a}}if(s[a]){let l=o.get(a);if(l??o.set(a,l=Px(s[a])),l)return l(c)}}return s[a]||a}).bind(o.clear(),i))}static async preload(n,t){return new e(n,{[n]:await t(n)},{fetcher:t})}get lang(){return this.lang$.value}get locales(){return this.locales$.value}get locale(){return this.locale$.value}async switchLang(n){if(!this.locales$.value[n]&&this.fetcher)this.addLocale(n,await this.fetcher(n));this.lang$.set(n)}hasKey(n){return!!this.a.value[n]}addLocale(n,t){this.locales$.set({...this.locales,[n]:t})}dispose(){this.lang$.dispose(),this.t$.dispose(),this.locales$.dispose(),this.locale$.dispose(),this.a.dispose()}};var cg={help:{usage:"Usage: {{command}}",title:"Open Flow commands",options:"Options: --json, --cursor <cursor>, --limit <count>"}};var ug={help:{usage:"Utilisation : {{command}}",title:"Commandes Open Flow",options:"Options : --json, --cursor <cursor>, --limit <count>"}};var lg={help:{usage:"\u4F7F\u3044\u65B9\uFF1A{{command}}",title:"Open Flow \u30B3\u30DE\u30F3\u30C9",options:"\u30AA\u30D7\u30B7\u30E7\u30F3\uFF1A--json\u3001--cursor <cursor>\u3001--limit <count>"}};var dg={help:{usage:"\uC0AC\uC6A9\uBC95: {{command}}",title:"Open Flow \uBA85\uB839\uC5B4",options:"\uC635\uC158: --json, --cursor <cursor>, --limit <count>"}};var pg={help:{usage:"\u0418\u0441\u043F\u043E\u043B\u044C\u0437\u043E\u0432\u0430\u043D\u0438\u0435: {{command}}",title:"\u041A\u043E\u043C\u0430\u043D\u0434\u044B Open Flow",options:"\u041F\u0430\u0440\u0430\u043C\u0435\u0442\u0440\u044B: --json, --cursor <cursor>, --limit <count>"}};var fg={help:{usage:"\u7528\u6CD5\uFF1A{{command}}",title:"Open Flow \u547D\u4EE4",options:"\u9009\u9879\uFF1A--json\u3001--cursor <cursor>\u3001--limit <count>"}};var mg={help:{usage:"\u7528\u6CD5\uFF1A{{command}}",title:"Open Flow \u547D\u4EE4",options:"\u9078\u9805\uFF1A--json\u3001--cursor <cursor>\u3001--limit <count>"}};var Mx={en:cg,"zh-CN":fg,"zh-TW":mg,ja:lg,ko:dg,ru:pg,fr:ug},Zx=Object.fromEntries(Jo.map((e)=>[e,Mx[e]]));function gg(e=Ia){return new ag(br([e]),Zx)}function Fx(e,n){let t=n.filter((i)=>!i.startsWith("-")),r=da(t,e.commandPrefix);while(r.length==0&&t.length>0)t.pop(),r=da(t,e.commandPrefix);let o=gg(e.language);try{let i=r.length==1?pa(r[0].command):void 0,s=Um(r.length==1?r[0].command:"",e.commandPrefix),a={kind:"cli.help",version:1,commands:r.length==1?r:r.map(({command:c,usage:u})=>({command:c,usage:u})),...i==null?{}:{request:i.request},examples:s,exitCodes:{0:"Success or accepted asynchronous operation.",1:"Error or unsuccessful terminal Run.",2:"Run is waiting for an explicit action; inspect run.waits.",3:"Waiting timed out or publication is pending; the operation continues."},notes:i==null?[...e.scopeGuidance??["The oo host selects the team for the whole invocation with --team <name>; Flow commands use that authenticated scope."],"--timeout is a wait budget in milliseconds (default 60000).","--follow --json writes NDJSON pages immediately; resume from nextAfter.","Use read/search to locate nodes, schema read|search|edit|check for requests, and schema <type> for configuration and ports.","Use edit with baseRevision, requestId and an ordered edits array. Read selected text before an exact text.edit.","Retry mutations with the same idempotency key, fixed revision/publication and identical arguments."]:[i.guidance,...r[0].command=="check"?[]:["Use either --input (literal JSON, @file, or - for stdin) or --file (path or -), never both."]]};return n.includes("--json")?JSON.stringify(a):[o.t("help.title"),"",...r.map((c)=>r.length!=1?c.usage:`${c.usage}
|
|
76
76
|
Options: ${c.options.map((u)=>u.name+(u.value?" <value>":"")+(u.description==null?"":`: ${u.description}`)).join(`
|
|
77
77
|
`)}`),"",o.t("help.options"),"",...a.notes,"",...s].join(`
|
|
78
|
-
`)}finally{o.dispose()}}function
|
|
79
|
-
`),0;r
|
|
80
|
-
`),0}let s=new
|
|
81
|
-
`),0}return await
|
|
78
|
+
`)}finally{o.dispose()}}function Jx(e){return e.length==0||e.includes("--help")||e.includes("-h")}function Lx(e){return e.positionals[0]=="schema"&&e.flow==null}async function hg(e,n,t){let r,o;try{if(Jx(e))return t.stdout.write(`${Fx(t,e)}
|
|
79
|
+
`),0;r=$m(e);let i=Lm(r.positionals);if(i==null)throw new C("cli.invalid-arguments",`Unknown command. Use ${t.commandPrefix??"oo flow"} --help.`);for(let a of r.options)if(a!="json"&&!i.includes(a))throw new C("cli.invalid-arguments",`Option --${a} is not supported by this command.`);if(r.options.includes("idempotency-key")){let a=r.positionals[0]=="run"&&r.source=="live";if(i.includes("expected-revision")&&!a&&r.expectedRevision==null)throw new C("cli.invalid-arguments","An explicit idempotency key requires --expected-revision for a repeatable mutation.");if((a||r.positionals[0]=="publish"||r.positionals[0]=="rollback")&&r.expectedPublication==null)throw new C("cli.invalid-arguments","An explicit idempotency key requires --expected-publication (use none for the first publication).")}if(r.timeoutMs!=null&&r.positionals[0]=="run"&&!r.wait)throw new C("cli.invalid-arguments","--timeout requires --wait for run.");if(r.timeoutMs!=null&&r.positionals[0]=="runs"&&r.positionals[1]=="events"&&!r.follow)throw new C("cli.invalid-arguments","--timeout requires --follow for events.");if(r.positionals[0]=="run"&&(r.source=="live"&&r.expectedRevision!=null||r.source=="draft"&&r.expectedPublication!=null))throw new C("cli.invalid-arguments","Use --expected-revision for draft runs and --expected-publication for live runs.");if(Lx(r)){if(r.positionals.length>2)throw new C("cli.invalid-arguments",`Usage: ${t.commandPrefix??"oo flow"} schema [read|search|edit|check|edits|node-type|input|outputs]`);let a=qm(r.positionals[1]);if(a==null)throw new C("cli.invalid-arguments","Unknown schema. Use read, search, edit, check, or a node type such as agent or code.");return t.stdout.write(`${JSON.stringify(a)}
|
|
80
|
+
`),0}let s=new Xs(async(a,c)=>{let u=new Headers(c?.headers).get("idempotency-key");return o=u==null?void 0:{path:a,idempotencyKey:u,...typeof c?.body=="string"?{request:JSON.parse(c.body)}:{}},await n.request(a,c)},"cli");if(r.positionals[0]=="schema"&&r.flow!=null){let a=r.input==null?{type:r.positionals[1]}:JSON.parse(await ln(r.input,"input","flow.authoring-unreadable",t)),c=await he(s,r.flow);return t.stdout.write(`${JSON.stringify(await s.authoringSchema(c.flowId,a))}
|
|
81
|
+
`),0}return await Xm(s,n,r,t)??0}catch(i){let s;if(i instanceof C)s=i;else if(i instanceof Ee)s=Pm(i);else s=new C("flow.unexpected",i instanceof Error?i.message:String(i));if(o!=null&&(!(i instanceof Ee)&&!(i instanceof C)||i instanceof Ee&&i.code=="response.invalid"))s=new C("flow.mutation-outcome-unknown","The mutation outcome is unknown. Retry the exact request with the same idempotency key.",o);if(e.includes("--json"))t.stderr.write(`${JSON.stringify({error:{code:s.code,...s.details==null?{}:{details:s.details},message:s.message},version:1})}
|
|
82
82
|
`);else t.stderr.write(`${s.code}: ${s.message}
|
|
83
|
-
`);return 1}}async function
|
|
83
|
+
`);return 1}}async function Kx(e){let n=process.platform=="darwin"?["open",e]:process.platform=="win32"?["rundll32","url.dll,FileProtocolHandler",e]:["xdg-open",e],t=qx(n[0],n.slice(1),{stdio:"ignore"});if(await new Promise((o,i)=>{t.once("error",i),t.once("exit",o)})!=0)throw Error("The system browser could not be opened.")}async function yg(e,n,t){if(e.includes("--version")||e.includes("-v"))return process.stdout.write(e.includes("--json")?`${JSON.stringify({version:t.version})}
|
|
84
84
|
`:`${t.version}
|
|
85
|
-
`),0;return await
|
|
85
|
+
`),0;return await hg(e,{request:n.cloudRequest??(async()=>{throw new C("host.unavailable","Open Flow Control API is not configured in this CLI host.")}),getWorkbenchUrl:n.getWorkbenchUrl},{commandPrefix:t.commandPrefix,scopeGuidance:t.scopeGuidance,env:process.env,language:br([n.language]),openUrl:Kx,readFile:async(r)=>await Ux(r,"utf8"),readStdin:async()=>{let r="";for await(let o of process.stdin)r+=String(o);return r},stderr:process.stderr,stdout:process.stdout,wait:async(r)=>await Bx(r)})}async function c_(e,n={}){return await yg(e,n,{version:Sa})}export{c_ as runOpenFlowCommand};
|