@transai/connector-runner-xylem 0.1.7 → 1.0.0

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/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ ## 0.2.0 (2026-11-19)
2
+
3
+ ### 🧱 Updated Dependencies
4
+
5
+ - Updated @transai/connector-runtime-sdk to 0.24.0
6
+
7
+ ## 0.1.7 (2026-11-18)
8
+
9
+ ### 🧱 Updated Dependencies
10
+
11
+ - Updated @transai/connector-runtime-sdk to 0.23.0
12
+
1
13
  ## 0.1.6 (2026-11-02)
2
14
 
3
15
  ### 🧱 Updated Dependencies
package/DOCUMENTATION.md CHANGED
@@ -24,6 +24,8 @@ The Xylem connector polls configured Xylem controllers for live data and forward
24
24
 
25
25
  `controllers` is required and must contain at least one controller. Each controller requires a unique `id`, `baseUrl`, `username`, `password`, and `intervalSeconds`. `name`, `location`, `endpoint`, and `timeoutMs` are optional. The default endpoint is `/api/v1/livedata`.
26
26
 
27
+ All collection names start with the datasource identifier, which defaults to `xylem`. Setting `datasourceIdentifier` to `line2` gives `line2_controllers`. Datasets and metrics must then use the same prefixed collection names.
28
+
27
29
  The connector authenticates requests using HTTP Digest Authentication. The poll interval and request timeout are configured independently for each controller.
28
30
 
29
31
  ## Polling and data
@@ -32,19 +34,21 @@ The connector immediately polls each configured controller when it starts, and c
32
34
 
33
35
  The following collections are emitted:
34
36
 
35
- | Collection | Contents |
36
- | ------------------ | ----------------------------------------------------------------------------- |
37
- | `controllers` | Controller identity and metadata, including firmware and payload information. |
38
- | `sensors` | Sensor identity, model, serial number, state, and configuration details. |
39
- | `values` | Main and sub-values, value state, units, display values, and ranges. |
40
- | `notifications` | Controller notifications with codes, types, timestamps, and raw data words. |
41
- | `sensor_status` | Numeric sensor state and the original Xylem sensor state. |
42
- | `connector_status` | Poll success or failure, state code, duration, and error details. |
37
+ | Collection | Contents |
38
+ | -------------------------- | ----------------------------------------------------------------------------- |
39
+ | `xylem_controllers` | Controller identity and metadata, including firmware and payload information. |
40
+ | `xylem_sensors` | Sensor identity, model, serial number, state, and configuration details. |
41
+ | `xylem_measurement_points` | Main and sub-values, value state, units, display values, and ranges. |
42
+ | `xylem_notifications` | Controller notifications with codes, types, timestamps, and raw data words. |
43
+ | `xylem_sensor_status` | Numeric sensor state and the original Xylem sensor state. |
44
+ | `xylem_connector_status` | Poll success or failure, state code, duration, and error details. |
45
+
46
+ The names above use the default prefix.
43
47
 
44
- Measurements are emitted to `values` with `value` and `valueState` in the metric body. Sensor status is emitted to `sensor_status` with `state_code` and `sensorState` in the metric body. Controller, sensor, value, and notification records are sent as documents with stable identity fields to support upserts.
48
+ Measurements are emitted to `xylem_measurement_points` with `value` and `valueState` in the metric body. Sensor status is emitted to `xylem_sensor_status` with `state_code` and `sensorState` in the metric body. Controller, sensor, value, and notification records are sent as documents with stable identity fields to support upserts.
45
49
 
46
50
  ## Failure behavior
47
51
 
48
- HTTP errors, request timeouts, invalid responses, and ingestion failures are logged and emit a failed `connector_status` record with state `0`. Successful polls emit a `connector_status` record with state `1` and the poll duration. Overlapping polls for the same controller are skipped and logged as errors.
52
+ HTTP errors, request timeouts, invalid responses, and ingestion failures are logged and emit a failed `xylem_connector_status` record with state `0`. Successful polls emit a `xylem_connector_status` record with state `1` and the poll duration. Overlapping polls for the same controller are skipped and logged as errors.
49
53
 
50
54
  Sensors with a normalized state of `-1` generate a warning while the remaining payload data continues to be processed.
package/index.cjs CHANGED
@@ -59,5 +59,5 @@ ${c}`:c:"",l=Function,d=`return (input) => {
59
59
  ${c}
60
60
  }`,f;try{f=new l(...a,d)(...u)}catch(m){throw new U(`this schema (generated code failed to evaluate: ${m.message})`)}return r?.debug&&(f.code=s),f.definite=o.definite,f}function z(e,r){for(let[o,t]of e.constants)if(t===r)return o;let i=`c${e.constantCounter++}`;return e.constants.set(i,r),i}function Ke(e,r){return e.definite=!1,z(e,r)}function w(e){return`v${e.varCounter++}`}function ch(e,r){let i=e._zod.run({value:r,issues:[]},{});if(i&&typeof i.then=="function")return Q;let o=i;return o.issues.length===0?o.value:Q}function q(e,r,i,o,t=!0){let n=e.content.length,a=r.constants.size,u=r.constantCounter,c=r.varCounter;try{return M(e,r,i,o,t)}catch(s){if(!(s instanceof U)||!s.islandable)throw s;if(e.content.length=n,r.constants.size>a){let l=Array.from(r.constants.keys()).slice(a);for(let d of l)r.constants.delete(d)}return r.constantCounter=u,r.varCounter=c,sh(e,r,i,o)}}function sh(e,r,i,o){r.definite=!1;let t=z(r,i),n=z(r,ch),a=w(r);return e.write(`const ${a} = ${n}(${t}, ${o});`),e.write(`if (${a} === INVALID) return INVALID;`),a}var lh=new Set(["max_size","min_size","size_equals","max_length","min_length","length_equals"]);function dh(e,r,i,o){let t=i._zod.def.checks;if(!t||t.length===0)return o;let n=o;for(let a of t){let u=a._zod.def;if(u.when&&!lh.has(u.check))throw new U('check with a custom "when" condition');switch(u.check){case"greater_than":fh(e,r,u,n);break;case"less_than":mh(e,r,u,n);break;case"multiple_of":ph(e,r,u,n);break;case"number_format":em(e,u,n);break;case"min_length":{let c=De(u.minimum,"min_length"),s=Xu(e,r,n,`${n}.length >= ${c} && ${n}.length < ${u.minimum*2}`);e.write(`if (${s} < ${c}) return INVALID;`);break}case"max_length":{let c=De(u.maximum,"max_length"),s=Xu(e,r,n,`${n}.length > ${c}`);e.write(`if (${s} > ${c}) return INVALID;`);break}case"length_equals":{let c=De(u.length,"length_equals"),s=Xu(e,r,n,`${n}.length >= ${c} && ${n}.length <= ${u.length*2}`);e.write(`if (${s} !== ${c}) return INVALID;`);break}case"min_size":e.write(`if (${n}.size < ${De(u.minimum,"min_size")}) return INVALID;`);break;case"max_size":e.write(`if (${n}.size > ${De(u.maximum,"max_size")}) return INVALID;`);break;case"size_equals":e.write(`if (${n}.size !== ${De(u.size,"size_equals")}) return INVALID;`);break;case"string_format":n=tm(e,r,u,n);break;case"custom":n=_h(e,r,a,n);break;case"bigint_format":gh(e,u,n);break;case"mime_type":vh(e,r,u,n);break;case"property":hh(e,r,u,n);break;case"properties":$h(e,r,u,n);break;case"overwrite":{let c=w(r);yh(e,r,a,n,c),n=c;break}default:throw new U(`check type ${u.check}`)}}return n}function Xu(e,r,i,o){let t=z(r,Re),n=w(r);return e.write(`const ${n} = typeof ${i} === "string" && ${o} ? ${t}(${i}) : ${i}.length;`),n}function De(e,r){if(typeof e!="number"||!Number.isFinite(e))throw new U(`${r} bound of type ${typeof e}`);return`${e}`}function Qf(e,r){if(typeof r=="bigint")return`${r}n`;if(typeof r=="number"){if(Number.isNaN(r))throw new U("comparison check with NaN bound");return`${r}`}if(r instanceof Date){if(Number.isNaN(r.getTime()))throw new U("comparison check with Invalid Date bound");return z(e,r)}throw new U(`comparison check bound of type ${typeof r}`)}function fh(e,r,i,o){let t=i.inclusive?"<":"<=";e.write(`if (${o} ${t} ${Qf(r,i.value)}) return INVALID;`)}function mh(e,r,i,o){let t=i.inclusive?">":">=";e.write(`if (${o} ${t} ${Qf(r,i.value)}) return INVALID;`)}function ph(e,r,i,o){if(typeof i.value=="bigint"){if(i.value===BigInt(0))throw new U("multiple_of check with a zero divisor");e.write(`if (${o} % ${i.value}n !== 0n) return INVALID;`)}else{let t=z(r,Xt);e.write(`if (${t}(${o}, ${De(i.value,"multiple_of")}) !== 0) return INVALID;`)}}function em(e,r,i){let o=r.format;switch(o){case"safeint":e.write(`if (!Number.isSafeInteger(${i})) return INVALID;`);break;case"int32":e.write(`if (!Number.isInteger(${i}) || ${i} < -2147483648 || ${i} > 2147483647) return INVALID;`);break;case"uint32":e.write(`if (!Number.isInteger(${i}) || ${i} < 0 || ${i} > 4294967295) return INVALID;`);break;case"float32":e.write(`if (!Number.isFinite(${i}) || ${i} < -3.4028234663852886e38 || ${i} > 3.4028234663852886e38) return INVALID;`);break;case"float64":e.write(`if (!Number.isFinite(${i})) return INVALID;`);break;default:throw new U(`number format ${o}`)}}function gh(e,r,i){let o=r.format;if(o)switch(o){case"int64":e.write(`if (${i} < -9223372036854775808n || ${i} > 9223372036854775807n) return INVALID;`);break;case"uint64":e.write(`if (${i} < 0n || ${i} > 18446744073709551615n) return INVALID;`);break;default:throw new U(`bigint format ${o}`)}}function vh(e,r,i,o){let t=i.mime;if(t&&t.length>0){let n=z(r,new Set(t));e.write(`if (!${n}.has(${o}.type)) return INVALID;`)}}function $h(e,r,i,o){if(i.when)throw new U('check with a custom "when" condition');e.write(`if (${o} == null) return INVALID;`);let t=i.shape;for(let n of Reflect.ownKeys(t)){let a=typeof n=="symbol"?z(r,n):H(n),u=w(r);e.write(`const ${u} = ${o}[${a}];`),q(e,r,t[n],u,!1)}}function hh(e,r,i,o){let t=`${o}[${JSON.stringify(i.property)}]`;M(e,r,i.schema,t)}function yh(e,r,i,o,t){let n=i._zod.def.tx;if(!n)throw new U("overwrite check without a transform function");if(Xe(n))throw new me("z.compile: async overwrite transforms are not supported");let a=z(r,n);e.write(`const ${t} = ${a}(${o});`)}function Gu(){throw new ie}function Hu(e){this.issues.push(e)}function _h(e,r,i,o){let t=i._zod.def;if(t.fn){if(Xe(t.fn))throw new me("z.compile: async .refine() predicates are not supported");let n=Ke(r,t.fn),a=z(r,Gu),u=w(r);return e.write(`const ${u} = ${n}(${o});`),e.write(`if (${u} instanceof Promise) ${a}();`),e.write(`if (!${u}) return INVALID;`),o}if(i._zod.check){if(Xe(i._zod.check))throw new me("z.compile: async .superRefine() / check functions are not supported");let n=i._zod.check,u=Ke(r,s=>{let l={value:s,issues:[],addIssue:Hu};return n(l)instanceof Promise&&Gu(),l.issues.length===0?l.value:Q}),c=w(r);return e.write(`const ${c} = ${u}(${o});`),e.write(`if (${c} === INVALID) return INVALID;`),c}throw new U("custom check without a predicate or check function")}var bh=new Set(["cidrv4","cuid","cuid2","date","datetime","duration","e164","email","emoji","ends_with","guid","includes","ipv4","ksuid","lowercase","mac","nanoid","regex","starts_with","time","ulid","uppercase","uuid","xid"]);function tm(e,r,i,o,t=!0){let n=i.format;if(n==="base64"){let s=z(r,mr);return e.write(`if (!${s}(${o})) return INVALID;`),o}if(n==="base64url"){let s=z(r,Dn);return e.write(`if (!${s}(${o})) return INVALID;`),o}if(n==="jwt"){let s=z(r,Nn),l=z(r,i.alg??null);return e.write(`if (!${s}(${o}, ${l})) return INVALID;`),o}if(n==="ipv6"){let s=z(r,fr);return e.write(`if (!${s}(${o})) return INVALID;`),o}if(n==="cidrv6"){let s=z(r,Sn);return e.write(`if (!${s}(${o})) return INVALID;`),o}if(n==="credit_card"){let s=z(r,Pn);return e.write(`if (!${s}(${o})) return INVALID;`),o}if(n==="iban"){let s=z(r,On);return e.write(`if (!${s}(${o})) return INVALID;`),o}let a=i;if(n==="url"||n==="httpurl"||a.normalize||a.hostname!==void 0||a.protocol!==void 0){let s=z(r,xn),l=z(r,i),d=w(r),f=w(r);if(e.write(`const ${d} = ${o}.trim();`),e.write(`const ${f} = ${s}(${d}, ${l});`),e.write(`if (typeof ${f} === "number") return INVALID;`),a.hostname!==void 0){let _=z(r,In);e.write(`if (!${_}(${f}, ${l}.hostname)) return INVALID;`)}if(a.protocol!==void 0){let _=z(r,wn);e.write(`if (!${_}(${f}, ${l}.protocol)) return INVALID;`)}if(!t)return null;let m=w(r),v=a.normalize?`${f}.href`:`${z(r,dr)}(${d})`;return e.write(`const ${m} = ${v};`),m}let u=i.fn;if(u){if(Xe(u))throw new U(`async string format ${n}`);let s=z(r,u);return e.write(`if (!${s}(${o})) return INVALID;`),o}if(bh.has(n)&&i.pattern){let s=z(r,i.pattern);return e.write(`${s}.lastIndex = 0;`),e.write(`if (!${s}.test(${o})) return INVALID;`),o}let c=i.format;switch(c){case"regex":throw new U("regex format without a pattern");case"lowercase":e.write(`if (${o} !== ${o}.toLowerCase()) return INVALID;`);break;case"uppercase":e.write(`if (${o} !== ${o}.toUpperCase()) return INVALID;`);break;case"includes":e.write(`if (!${o}.includes(${H(i.includes)})) return INVALID;`);break;case"starts_with":{let s=i.prefix;e.write(`if (${o}.slice(0, ${s.length}) !== ${H(s)}) return INVALID;`);break}case"ends_with":{let s=i.suffix;e.write(`if (${o}.slice(-${s.length}) !== ${H(s)}) return INVALID;`);break}default:throw new U(`string format ${c}`)}return o}function M(e,r,i,o,t=!0){let n=i._zod.def,a=n.type;if(n.coerce)throw new U(`coercion (z.coerce.${a}())`);let u=t||!!n.checks?.length,c;switch(a){case"string":c=kh(e,r,i,o,u);break;case"number":c=xh(e,i,o);break;case"boolean":c=Ih(e,o);break;case"bigint":c=wh(e,i,o);break;case"symbol":c=Sh(e,o);break;case"undefined":c=zh(e,o);break;case"null":c=Dh(e,o);break;case"any":case"unknown":c=o;break;case"never":e.write("return INVALID;"),c=o;break;case"void":c=Ph(e,o);break;case"nan":c=Oh(e,o);break;case"date":c=Nh(e,o);break;case"object":c=jh(e,r,i,o,u);break;case"optional":c=Uh(e,r,i,o,u);break;case"nullable":c=Ch(e,r,i,o,u);break;case"array":c=Zh(e,r,i,o,u);break;case"literal":c=Eh(e,r,i,o);break;case"enum":c=Lh(e,r,i,o);break;case"readonly":{let s=qf(e,r,i,o),l=w(r);e.write(`const ${l} = Object.freeze(${s});`),c=l;break}case"success":qf(e,r,i,o),c="true";break;case"default":case"prefault":c=Vh(e,r,i,o);break;case"nonoptional":c=Rh(e,r,i,o);break;case"tuple":c=Mh(e,r,i,o);break;case"union":c=Fh(e,r,i,o);break;case"intersection":c=Kh(e,r,i,o);break;case"record":c=Xh(e,r,i,o);break;case"map":c=Wh(e,r,i,o);break;case"set":c=qh(e,r,i,o);break;case"file":c=Hh(e,o);break;case"template_literal":c=Yh(e,r,i,o);break;case"lazy":c=Qh(e,r,i,o);break;case"pipe":c=ey(e,r,i,o);break;case"custom":c=ty(e,r,i,o);break;case"transform":c=iy(e,r,i,o);break;case"catch":c=ny(e,r,i,o);break;default:throw new U(`schema type ${a}`)}return c===null?null:dh(e,r,i,c)}function kh(e,r,i,o,t=!0){e.write(`if (typeof ${o} !== "string") return INVALID;`);let n=i._zod.def;return n.format===void 0?o:tm(e,r,n,o,t)}function xh(e,r,i){e.write(`if (typeof ${i} !== "number" || !Number.isFinite(${i})) return INVALID;`);let o=r._zod.def;return o.check==="number_format"&&o.format&&em(e,{format:o.format},i),i}function Ih(e,r){return e.write(`if (typeof ${r} !== "boolean") return INVALID;`),r}function wh(e,r,i){e.write(`if (typeof ${i} !== "bigint") return INVALID;`);let o=r._zod.def;if(o.format)switch(o.format){case"int64":e.write(`if (${i} < -9223372036854775808n || ${i} > 9223372036854775807n) return INVALID;`);break;case"uint64":e.write(`if (${i} < 0n || ${i} > 18446744073709551615n) return INVALID;`);break}return i}function Sh(e,r){return e.write(`if (typeof ${r} !== "symbol") return INVALID;`),r}function zh(e,r){return e.write(`if (${r} !== undefined) return INVALID;`),r}function Dh(e,r){return e.write(`if (${r} !== null) return INVALID;`),r}function Ph(e,r){return e.write(`if (${r} !== undefined) return INVALID;`),r}function Oh(e,r){return e.write(`if (typeof ${r} !== "number" || !Number.isNaN(${r})) return INVALID;`),r}function Nh(e,r){return e.write(`if (!(${r} instanceof Date) || Number.isNaN(${r}.getTime())) return INVALID;`),r}function jh(e,r,i,o,t=!0){let n=i._zod.def;e.write(`if (typeof ${o} !== "object" || ${o} === null || Array.isArray(${o})) return INVALID;`);let a=n.shape,u=Object.keys(a),c=Object.getOwnPropertySymbols(a),s=c.length?[...u,...c]:u,l=I=>typeof I=="symbol"?z(r,I):H(I),d=I=>typeof I=="symbol"?`[${l(I)}]`:H(I),f=a;if(u.includes("__proto__"))throw new U('object shape key "__proto__"');let m=new Map;for(let I of s){let P=f[I],T=l(I),R=w(r);if(e.write(`const ${R} = ${o}[${T}];`),P._zod.optin!==void 0){let A=w(r);e.write(`let ${A} = (() => {`),e.indented(W=>{let Jt=q(W,r,P,R);W.write(`return ${Jt};`)}),e.write("})();"),P._zod.optout==="optional"?(e.write(`if (${A} === INVALID) {`),e.indented(W=>{W.write(`if (${T} in ${o}) return INVALID;`),W.write(`${A} = undefined;`)}),e.write("}")):e.write(`if (${A} === INVALID) return INVALID;`),m.set(I,A)}else{Th(P)&&e.write(`if (!(${T} in ${o})) return INVALID;`);let A=q(e,r,P,R,t);A!==null&&m.set(I,A)}}let v=n.catchall,_="none";if(v){let I=v._zod.def.type;if(I==="never"){let P=u.map(T=>`k !== ${H(T)}`).join(" && ")||"true";e.write(`for (const k in ${o}) {`),e.indented(T=>{T.write(`if (${P}) return INVALID;`)}),e.write("}")}else(I==="unknown"||I==="any")&&!v._zod.def.checks?.length?_="passthrough":_="schema"}let k=w(r),S=s.some(I=>Wf(f[I])||Wu(f[I]));if(!t){if(_==="schema"){let I=u.length>0?z(r,new Set(u)):null;e.write(`for (const k in ${o}) {`),e.indented(P=>{P.write('if (k === "__proto__") continue;'),I&&P.write(`if (${I}.has(k)) continue;`);let T=w(r);P.write(`const ${T} = ${o}[k];`),q(P,r,v,T,!1)}),e.write("}")}return null}if(S){e.write(`const ${k} = {};`);for(let I of s){let P=l(I),T=m.get(I);Wu(f[I])?e.write(`if (${P} in ${o}) ${k}[${P}] = ${T};`):Wf(f[I])?e.write(`if (${T} !== undefined || ${P} in ${o}) ${k}[${P}] = ${T};`):e.write(`${k}[${P}] = ${T};`)}}else{let I=s.map(P=>`${d(P)}: ${m.get(P)}`).join(", ");e.write(`const ${k} = { ${I} };`)}if(_!=="none"){let I=u.length>0?z(r,new Set(u)):null;e.write(`for (const k in ${o}) {`),e.indented(P=>{if(P.write('if (k === "__proto__") continue;'),I&&P.write(`if (${I}.has(k)) continue;`),_==="passthrough")P.write(`${k}[k] = ${o}[k];`);else{let T=w(r);P.write(`const ${T} = ${o}[k];`);let R=q(P,r,v,T);P.write(`${k}[k] = ${R};`)}}),e.write("}")}return k}function Uh(e,r,i,o,t=!0){let n=i._zod.def;if(Ah(i))return M(e,r,n.innerType,o,t);if(n.innerType._zod.optin==="defaulted"){let u=w(r),c=w(r);return e.write(`let ${u};`),e.write(`if (${o} === undefined) {`),e.indented(s=>{s.write(`const ${c} = (() => {`),s.indented(l=>{let d=M(l,r,n.innerType,o);l.write(`return ${d};`)}),s.write("})();"),s.write(`if (${c} !== INVALID) ${u} = ${c};`)}),e.write("} else {"),e.indented(s=>{let l=M(s,r,n.innerType,o);s.write(`${u} = ${l};`)}),e.write("}"),u}let a=t?w(r):null;return a&&e.write(`let ${a};`),e.write(`if (${o} !== undefined) {`),e.indented(u=>{let c=M(u,r,n.innerType,o,t);a&&c!==null&&u.write(`${a} = ${c};`)}),e.write("}"),a}function Ah(e){return e._zod.traits?.has("$ZodExactOptional")===!0}function Th(e){return e._zod.optin===void 0&&Be(e)}function Be(e){if(e._zod.def.coerce)return!0;let r=e._zod.def;switch(r.type){case"any":case"unknown":case"undefined":case"void":case"default":case"prefault":case"transform":case"custom":case"lazy":return!0;case"string":case"number":case"boolean":case"bigint":case"symbol":case"null":case"never":case"nan":case"date":case"object":case"array":case"tuple":case"record":case"map":case"set":case"file":case"template_literal":return!1;case"nonoptional":return r.innerType?Be(r.innerType):!1;case"literal":return!!r.values?.includes(void 0);case"enum":return!!e._zod.values?.has(void 0);case"optional":case"nullable":case"readonly":case"success":return r.innerType?Be(r.innerType):!0;case"catch":return!0;case"union":return r.options?r.options.some(Be):!0;case"intersection":return!r.left||!r.right?!0:Be(r.left)&&Be(r.right);case"pipe":return r.in?Be(r.in):!0;default:return!0}}function Wu(e){return e._zod.optin==="optional"&&e._zod.optout==="optional"}function Wf(e){return(e._zod.optin!=="defaulted"||e._zod.optout==="optional")&&yt(e)}function yt(e){let r=e._zod.def;switch(r.type){case"string":case"number":case"boolean":case"bigint":case"symbol":case"null":case"nan":case"date":case"object":case"array":case"tuple":case"record":case"map":case"set":case"file":case"template_literal":case"never":case"success":return!1;case"literal":return!!r.values?.includes(void 0);case"enum":return!!e._zod.values?.has(void 0);case"optional":return!0;case"nullable":case"readonly":case"nonoptional":return r.innerType?yt(r.innerType):!0;case"union":return r.options?r.options.some(yt):!0;case"intersection":return!r.left||!r.right||yt(r.left)||yt(r.right);case"pipe":return r.out?yt(r.out):!0;default:return!0}}function Ch(e,r,i,o,t=!0){let n=i._zod.def,a=t?w(r):null;return a&&e.write(`let ${a} = null;`),e.write(`if (${o} !== null) {`),e.indented(u=>{let c=M(u,r,n.innerType,o,t);a&&c!==null&&u.write(`${a} = ${c};`)}),e.write("}"),a}function Yu(e,r,i){for(let[o,t]of st(r._zod.def.checks))e.write(`if (${i} > ${De(o,t._zod.def.check)}) return INVALID;`)}function Zh(e,r,i,o,t=!0){let n=i._zod.def;e.write(`if (!Array.isArray(${o})) return INVALID;`),Yu(e,i,`${o}.length`);let a=t?w(r):null,u=w(r),c=w(r);return a&&e.write(`const ${a} = new Array(${o}.length);`),e.write(`for (let ${u} = 0; ${u} < ${o}.length; ${u}++) {`),e.indented(s=>{s.write(`const ${c} = ${o}[${u}];`);let l=q(s,r,n.element,c,t);a&&l!==null&&s.write(`${a}[${u}] = ${l};`)}),e.write("}"),a}function Eh(e,r,i,o){let n=i._zod.def.values;if(n.length!==1){let u=z(r,new Set(n));return e.write(`if (!${u}.has(${o})) return INVALID;`),o}let a=n[0];if(typeof a=="number"&&Number.isNaN(a)){let u=z(r,new Set(n));return e.write(`if (!${u}.has(${o})) return INVALID;`),o}if(typeof a=="string")e.write(`if (${o} !== ${H(a)}) return INVALID;`);else if(typeof a=="number"||typeof a=="boolean")e.write(`if (${o} !== ${a}) return INVALID;`);else if(a===null)e.write(`if (${o} !== null) return INVALID;`);else if(a===void 0)e.write(`if (${o} !== undefined) return INVALID;`);else if(typeof a=="bigint")e.write(`if (${o} !== ${a}n) return INVALID;`);else throw new U(`literal type ${typeof a}`);return o}function Lh(e,r,i,o){let t=i._zod.values;if(!t)throw new U("enum schema without enumerated values");let n=z(r,t);return e.write(`if (!${n}.has(${o})) return INVALID;`),o}function qf(e,r,i,o){let t=i._zod.def;return M(e,r,t.innerType,o)}function Vh(e,r,i,o){let t=i._zod.def,a=Object.getOwnPropertyDescriptor(i._zod.def,"defaultValue")?()=>i._zod.def.defaultValue:void 0;if(i._zod.def.type==="prefault"){if(!a)return M(e,r,t.innerType,o);let c=z(r,a),s=w(r);return e.write(`let ${s} = ${o};`),e.write(`if (${o} === undefined) ${s} = ${c}();`),M(e,r,t.innerType,s)}let u=w(r);if(a){let c=z(r,a),s=z(r,Gt);e.write(`let ${u};`),e.write(`if (${o} === undefined) {`),e.indented(l=>{l.write(`${u} = ${s}(${c}());`)}),e.write("} else {"),e.indented(l=>{let d=M(l,r,t.innerType,o);l.write(`${u} = ${d} === undefined ? ${s}(${c}()) : ${d};`)}),e.write("}")}else e.write(`let ${u};`),e.write(`if (${o} !== undefined) {`),e.indented(c=>{let s=M(c,r,t.innerType,o);c.write(`${u} = ${s};`)}),e.write("}");return u}function Rh(e,r,i,o){let t=i._zod.def,n=M(e,r,t.innerType,o),a=w(r);return e.write(`const ${a} = ${n};`),e.write(`if (${a} === undefined) return INVALID;`),a}function Mh(e,r,i,o){let t=i._zod.def,n=t.items,a=t.rest;e.write(`if (!Array.isArray(${o})) return INVALID;`);let u=Hf(n,"optin"),c=Hf(n,"optout");a?e.write(`if (${o}.length < ${u}) return INVALID;`):e.write(`if (${o}.length < ${u} || ${o}.length > ${n.length}) return INVALID;`);let s=w(r);e.write(`const ${s} = [];`);for(let l=0;l<n.length;l++){let d=n[l];if(l>=c)e.write(`if (${s}.length === ${l}) {`),e.indented(f=>{f.write(`if (${l} < ${o}.length) {`),f.indented(m=>{let v=w(r);m.write(`const ${v} = ${o}[${l}];`);let _=q(m,r,d,v);m.write(`${s}[${l}] = ${_};`)}),f.write("} else {"),f.indented(m=>{if(Wu(d)){m.write(`${s}.length = ${l};`);return}let v=w(r),_=w(r);m.write(`const ${v} = undefined;`),m.write(`const ${_} = (() => {`),m.indented(k=>{let S=q(k,r,d,v);k.write(`return ${S};`)}),m.write("})();"),m.write(`if (${_} === INVALID || ${_} === undefined) ${s}.length = ${l};`),m.write(`else ${s}[${l}] = ${_};`)}),f.write("}")}),e.write("}");else{let f=w(r);e.write(`const ${f} = ${o}[${l}];`);let m=q(e,r,d,f);e.write(`${s}[${l}] = ${m};`)}}if(a){let l=w(r),d=w(r);e.write(`for (let ${l} = ${n.length}; ${l} < ${o}.length; ${l}++) {`),e.indented(f=>{f.write(`const ${d} = ${o}[${l}];`);let m=q(f,r,a,d);f.write(`${s}[${l}] = ${m};`)}),e.write("}")}return s}function Hf(e,r){for(let i=e.length-1;i>=0;i--)if(!(r==="optin"?e[i]._zod.optin!==void 0:e[i]._zod.optout==="optional"))return i+1;return 0}function Fh(e,r,i,o){let t=i._zod.def,n=t.options;if(t.discriminator)return Jh(e,r,t,o);if(t.inclusive===!1)throw new U("exclusive unions (z.xor)");if(n.length===0)return e.write("return INVALID;"),o;if(n.length===1)return M(e,r,n[0],o);if(n.every(c=>c._zod.def.type==="literal"&&!c._zod.def.checks?.length)){let c=new Set(n.flatMap(l=>l._zod.def.values)),s=z(r,c);return e.write(`if (!${s}.has(${o})) return INVALID;`),o}let u=w(r);e.write(`let ${u};`);for(let c=0;c<n.length;c++){let s=n[c];c===0?e.write(`${u} = (() => {`):e.write(`if (${u} === INVALID) ${u} = (() => {`),e.indented(l=>{let d=M(l,r,s,o);l.write(`return ${d};`)}),e.write("})();")}return e.write(`if (${u} === INVALID) return INVALID;`),u}function Jh(e,r,i,o){if(i.unionFallback)throw new U("discriminated union with unionFallback");if(i.options.length===0)return e.write("return INVALID;"),o;let t=w(r),n=w(r);e.write(`const ${t} = ${o}?.[${H(i.discriminator)}];`),e.write(`let ${n};`);let a=!0,u=new Set;for(let c of i.options){let s=c._zod.propValues?.[i.discriminator];if(!s||s.size===0)throw new U("discriminated union option without static discriminator values");for(let f of s){if(u.has(f))throw new U(`duplicate discriminator value ${String(f)}`);u.add(f)}let l=Array.from(s,f=>Bh(r,t,f)),d=a?"if":"else if";e.write(`${d} (${l.join(" || ")}) {`),e.indented(f=>{let m=M(f,r,c,o);f.write(`${n} = ${m};`)}),e.write("}"),a=!1}return e.write("else { return INVALID; }"),n}function Bh(e,r,i){if(typeof i=="string")return`${r} === ${H(i)}`;if(typeof i=="number")return Number.isNaN(i)?`Number.isNaN(${r})`:`${r} === ${i}`;if(typeof i=="boolean")return`${r} === ${i}`;if(i===null)return`${r} === null`;if(i===void 0)return`${r} === undefined`;if(typeof i=="bigint")return`${r} === ${i}n`;if(typeof i=="symbol"){let o=z(e,i);return`${r} === ${o}`}throw new U(`literal discriminator value ${String(i)}`)}function Kh(e,r,i,o){let t=i._zod.def;r.definite=!1;let n=q(e,r,t.left,o),a=q(e,r,t.right,o),u=z(r,vt),c=w(r);return e.write(`const ${c} = ${u}(${n}, ${a});`),e.write(`if (!${c}.valid) return INVALID;`),`${c}.data`}function Xh(e,r,i,o){let t=i._zod.def,n=z(r,se);e.write(`if (!${n}(${o})) return INVALID;`);let a=w(r),u=w(r),c=w(r);e.write(`const ${a} = {};`);let s=t,l=s.partial?void 0:t.keyType._zod.values;if(l){let m=[];for(let _ of l){if(!(typeof _=="string"||typeof _=="number"||typeof _=="symbol"))throw new U(`record key value ${String(_)}`);let k=typeof _=="number"?_.toString():_;if(k==="__proto__")throw new U('record key "__proto__"');m.push(k);let S=z(r,_),I=M(e,r,t.keyType,S),P=w(r);e.write(`const ${P} = ${o}[${Gh(r,k)}];`);let T=q(e,r,t.valueType,P);e.write(`${a}[${I}] = ${T};`)}let v=z(r,new Set(m));return e.write(`for (const ${u} in ${o}) {`),e.indented(_=>{_.write(`if (${v}.has(${u})) continue;`),s.mode==="loose"?_.write(`if (${u} !== "__proto__") ${a}[${u}] = ${o}[${u}];`):_.write("return INVALID;")}),e.write("}"),a}let d=t.keyType._zod.def;if(!(d.type==="string"&&d.format===void 0&&!d.coerce&&(d.checks?.length??0)===0)){let m=t.mode==="loose",v=Wn(t.keyType);v.definite===!1&&(r.definite=!1);let _=z(r,v),k=z(r,ke),S=w(r);return Yf(e,r,o,u,I=>{I.write(`let ${S} = ${_}(${u});`),I.write(`if (${S} === INVALID && typeof ${u} === "string" && ${k}.test(${u})) ${S} = ${_}(Number(${u}));`),m?I.write(`if (${S} === INVALID) { ${a}[${u}] = ${o}[${u}]; continue; }`):I.write(`if (${S} === INVALID) return INVALID;`),I.write(`if (${S} === "__proto__") continue;`);let P=w(r);I.write(`const ${P} = ${o}[${u}];`);let T=q(I,r,t.valueType,P);I.write(`${a}[${S}] = ${T};`)}),a}return Yf(e,r,o,u,m=>{m.write(`const ${c} = ${o}[${u}];`);let v=q(m,r,t.valueType,c);m.write(`${a}[${u}] = ${v};`)},"return INVALID;"),a}function Yf(e,r,i,o,t,n){let a=z(r,Object.prototype.propertyIsEnumerable),u=w(r),c=w(r),s=w(r);e.write(`const ${u} = Object.getOwnPropertySymbols(${i});`),e.write(`const ${c} = Object.getOwnPropertyNames(${i});`),e.write(`for (let ${s} = 0; ${s} < ${c}.length; ${s}++) {`),e.indented(l=>{l.write(`const ${o} = ${c}[${s}];`),l.write(`if (${o} === "__proto__" || !${a}.call(${i}, ${o})) continue;`),t(l)}),e.write("}"),e.write(`for (let ${s} = 0; ${s} < ${u}.length; ${s}++) {`),e.indented(l=>{l.write(`const ${o} = ${u}[${s}];`),l.write(`if (!${a}.call(${i}, ${o})) continue;`),n?l.write(n):t(l)}),e.write("}")}function Gh(e,r){return typeof r=="string"?H(r):z(e,r)}function Wh(e,r,i,o){let t=i._zod.def;e.write(`if (!(${o} instanceof Map)) return INVALID;`),Yu(e,i,`${o}.size`);let n=w(r),a=w(r),u=w(r);return e.write(`const ${n} = new Map();`),e.write(`for (const [${a}, ${u}] of ${o}) {`),e.indented(c=>{let s=M(c,r,t.keyType,a),l=M(c,r,t.valueType,u);c.write(`${n}.set(${s}, ${l});`)}),e.write("}"),n}function qh(e,r,i,o){let t=i._zod.def;e.write(`if (!(${o} instanceof Set)) return INVALID;`),Yu(e,i,`${o}.size`);let n=w(r),a=w(r);return e.write(`const ${n} = new Set();`),e.write(`for (const ${a} of ${o}) {`),e.indented(u=>{let c=M(u,r,t.valueType,a);u.write(`${n}.add(${c});`)}),e.write("}"),n}function Hh(e,r){return e.write(`if (!(${r} instanceof File)) return INVALID;`),r}function Yh(e,r,i,o){e.write(`if (typeof ${o} !== "string") return INVALID;`);let t=i._zod.pattern;if(t){let n=z(r,t);e.write(`${n}.lastIndex = 0;`),e.write(`if (!${n}.test(${o})) return INVALID;`)}return o}function Qh(e,r,i,o){let t=i._zod.def,n=Ke(r,t.getter),a=z(r,{parser:null});e.write(`if (!${a}.parser) {`),e.indented(c=>{c.write(`const inner = ${n}();`),c.write(`${a}.parser = function(input) {`),c.indented(s=>{s.write("const result = inner._zod.run({ value: input, issues: [] }, {});"),s.write("return result.issues.length === 0 ? result.value : INVALID;")}),c.write("};")}),e.write("}");let u=w(r);return e.write(`const ${u} = ${a}.parser(${o});`),e.write(`if (${u} === INVALID) return INVALID;`),u}function ey(e,r,i,o){let t=i._zod.def,n=M(e,r,t.in,o);if(t.transform){if(Xe(t.transform))throw new me("z.compile: async transforms in pipes are not supported");let a=t.transform,c=Ke(r,l=>{let d={value:l,issues:[],addIssue:Hu},f=a(l,d);return f instanceof Promise?Q:d.issues.length===0?f:Q}),s=w(r);return e.write(`const ${s} = ${c}(${n});`),e.write(`if (${s} === INVALID) return INVALID;`),M(e,r,t.out,s)}else return M(e,r,t.out,n)}function Xe(e){return typeof e=="function"&&(e.constructor.name==="AsyncFunction"||e[Symbol.toStringTag]==="AsyncFunction")}function ty(e,r,i,o){let t=i._zod.def;if(t.fn){if(Xe(t.fn))throw new me("z.compile: async custom predicates are not supported");let n=Ke(r,t.fn),a=z(r,Gu),u=w(r);e.write(`const ${u} = ${n}(${o});`),e.write(`if (${u} instanceof Promise) ${a}();`),e.write(`if (!${u}) return INVALID;`)}else throw new U("custom schema without a predicate function");return o}function ry(e,r,i){let o=e._zod.run({value:i,issues:[]},{});if(o&&typeof o.then=="function")return Q;let t=o;return t.issues.length===0?t.value:r()}function ny(e,r,i,o){let t=i._zod.def;if(!t.catchValue[Qr])throw new U("catch with a callback (only a constant catch value compiles)",!1);let n=w(r);e.write(`let ${n} = (() => {`),e.indented(s=>{let l=q(s,r,t.innerType,o);s.write(`return ${l};`)}),e.write("})();");let a=z(r,t.innerType),u=Ke(r,t.catchValue),c=z(r,ry);return e.write(`if (${n} === INVALID) {`),e.indented(s=>{s.write(`${n} = ${c}(${a}, ${u}, ${o});`),s.write(`if (${n} === INVALID) return INVALID;`)}),e.write("}"),n}function iy(e,r,i,o){let t=i._zod.def;if(t.transform){if(Xe(t.transform))throw new me("z.compile: async transforms are not supported");let n=t.transform,u=Ke(r,s=>{let l={value:s,issues:[],addIssue:Hu},d=n(s,l);return d instanceof Promise?Q:l.issues.length===0?d:Q}),c=w(r);return e.write(`const ${c} = ${u}(${o});`),e.write(`if (${c} === INVALID) return INVALID;`),c}return o}function qn(e){return e.checks&&(e.checks=[...e.checks]),e}function Qu(e,r){return new e(qn({type:"string",...b(r)}))}function ec(e,r){return new e(qn({type:"string",coerce:!0,...b(r)}))}function Hn(e,r){return new e({type:"string",format:"email",check:"string_format",abort:!1,...b(r)})}function Yn(e,r){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...b(r)})}function Qn(e,r){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...b(r)})}function ei(e,r){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...b(r)})}function ti(e,r){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...b(r)})}function ri(e,r){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...b(r)})}function Ir(e,r){return new e({type:"string",format:"url",check:"string_format",abort:!1,...b(r)})}function ni(e,r){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...b(r)})}function ii(e,r){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...b(r)})}function oi(e,r){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...b(r)})}function ai(e,r){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...b(r)})}function ui(e,r){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...b(r)})}function ci(e,r){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...b(r)})}function si(e,r){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...b(r)})}function li(e,r){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...b(r)})}function di(e,r){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...b(r)})}function tc(e,r){return new e({type:"string",format:"mac",check:"string_format",abort:!1,...b(r)})}function fi(e,r){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...b(r)})}function mi(e,r){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...b(r)})}function pi(e,r){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...b(r)})}function gi(e,r){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...b(r)})}function vi(e,r){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...b(r)})}function rc(e,r){return new e({type:"string",format:"credit_card",check:"string_format",abort:!1,...b(r)})}function nc(e,r){return new e({type:"string",format:"iban",check:"string_format",abort:!1,...b(r)})}function $i(e,r){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...b(r)})}var ic={Any:null,Minute:-1,Second:0,Millisecond:3,Microsecond:6};function wr(e,r){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...b(r)})}function Sr(e,r){return new e({type:"string",format:"date",check:"string_format",...b(r)})}function zr(e,r){return new e({type:"string",format:"time",check:"string_format",precision:null,...b(r)})}function Dr(e,r){return new e({type:"string",format:"duration",check:"string_format",...b(r)})}function oc(e,r){return new e(qn({type:"number",checks:[],...b(r)}))}function ac(e,r){return new e(qn({type:"number",coerce:!0,checks:[],...b(r)}))}function uc(e,r){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...b(r)})}function cc(e,r){return new e({type:"number",check:"number_format",abort:!1,format:"float32",...b(r)})}function sc(e,r){return new e({type:"number",check:"number_format",abort:!1,format:"float64",...b(r)})}function lc(e,r){return new e({type:"number",check:"number_format",abort:!1,format:"int32",...b(r)})}function dc(e,r){return new e({type:"number",check:"number_format",abort:!1,format:"uint32",...b(r)})}function fc(e,r){return new e({type:"boolean",...b(r)})}function mc(e,r){return new e({type:"boolean",coerce:!0,...b(r)})}function pc(e,r){return new e({type:"bigint",...b(r)})}function gc(e,r){return new e({type:"bigint",coerce:!0,...b(r)})}function vc(e,r){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"int64",...b(r)})}function $c(e,r){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"uint64",...b(r)})}function hc(e,r){return new e({type:"symbol",...b(r)})}function yc(e,r){return new e({type:"undefined",...b(r)})}function _c(e,r){return new e({type:"null",...b(r)})}function bc(e){return new e({type:"any"})}function kc(e){return new e({type:"unknown"})}function xc(e,r){return new e({type:"never",...b(r)})}function Ic(e,r){return new e({type:"void",...b(r)})}function wc(e,r){return new e({type:"date",...b(r)})}function Sc(e,r){return new e({type:"date",coerce:!0,...b(r)})}function zc(e,r){return new e({type:"nan",...b(r)})}function ve(e,r){return new vn({check:"less_than",...b(r),value:e,inclusive:!1})}function ue(e,r){return new vn({check:"less_than",...b(r),value:e,inclusive:!0})}function $e(e,r){return new $n({check:"greater_than",...b(r),value:e,inclusive:!1})}function ce(e,r){return new $n({check:"greater_than",...b(r),value:e,inclusive:!0})}function hi(e){return $e(0,e)}function yi(e){return ve(0,e)}function _i(e){return ue(0,e)}function bi(e){return ce(0,e)}function Pe(e,r){return new sa({check:"multiple_of",...b(r),value:e})}function Oe(e,r){return new fa({check:"max_size",...b(r),maximum:e})}function he(e,r){return new ma({check:"min_size",...b(r),minimum:e})}function Ge(e,r){return new pa({check:"size_equals",...b(r),size:e})}function We(e,r){return new ga({check:"max_length",...b(r),maximum:e})}function xe(e,r){return new va({check:"min_length",...b(r),minimum:e})}function qe(e,r){return new $a({check:"length_equals",...b(r),length:e})}function _t(e,r){return new ha({check:"string_format",format:"regex",...b(r),pattern:e})}function bt(e){return new ya({check:"string_format",format:"lowercase",...b(e)})}function kt(e){return new _a({check:"string_format",format:"uppercase",...b(e)})}function xt(e,r){return new ba({check:"string_format",format:"includes",...b(r),includes:e})}function It(e,r){return new ka({check:"string_format",format:"starts_with",...b(r),prefix:e})}function wt(e,r){return new xa({check:"string_format",format:"ends_with",...b(r),suffix:e})}function ki(e,r,i){return new Ia({check:"property",property:e,schema:r,...b(i)})}function St(e,r){return new wa({check:"properties",shape:e,...b(r)})}function zt(e,r){return new Sa({check:"mime_type",mime:e,...b(r)})}function pe(e){return new za({check:"overwrite",tx:e})}function Dt(e){return pe(r=>r.normalize(e))}function Pt(){return pe(e=>e.trim())}function Ot(){return pe(e=>e.toLowerCase())}function Nt(){return pe(e=>e.toUpperCase())}function jt(){return pe(e=>lo(e))}function Dc(e,r,i){return new e({type:"array",element:r,...b(i)})}function oy(e,r,i){return new e({type:"union",options:r,...b(i)})}function ay(e,r,i){return new e({type:"union",options:r,inclusive:!1,...b(i)})}function uy(e,r,i,o){return new e({type:"union",options:i,discriminator:r,...b(o)})}function cy(e,r,i){return new e({type:"intersection",left:r,right:i})}function sy(e,r,i,o){let t=i instanceof D,n=t?o:i,a=t?i:null;return new e({type:"tuple",items:r,rest:a,...b(n)})}function ly(e,r,i,o){return new e({type:"record",keyType:r,valueType:i,...b(o)})}function dy(e,r,i,o){return new e({type:"map",keyType:r,valueType:i,...b(o)})}function fy(e,r,i){return new e({type:"set",valueType:r,...b(i)})}function my(e,r,i){let o=Array.isArray(r)?Object.fromEntries(r.map(t=>[t,t])):r;return new e({type:"enum",entries:o,...b(i)})}function py(e,r,i){return new e({type:"enum",entries:r,...b(i)})}function gy(e,r,i){return new e({type:"literal",values:Array.isArray(r)?r:[r],...b(i)})}function Pc(e,r){return new e({type:"file",...b(r)})}function vy(e,r){return new e({type:"transform",transform:r})}function $y(e,r){return new e({type:"optional",innerType:r})}function hy(e,r){return new e({type:"nullable",innerType:r})}function yy(e,r,i){return new e({type:"default",innerType:r,get defaultValue(){return typeof i=="function"?i():Gt(i)}})}function _y(e,r,i){return new e({type:"nonoptional",innerType:r,...b(i)})}function by(e,r){return new e({type:"success",innerType:r})}function ky(e,r,i){return new e({type:"catch",innerType:r,catchValue:typeof i=="function"?i:$o(i)})}function xy(e,r,i){return new e({type:"pipe",in:r,out:i})}function Iy(e,r){return new e({type:"readonly",innerType:r})}function wy(e,r,i){return new e({type:"template_literal",parts:r,...b(i)})}function Sy(e,r){return new e({type:"lazy",getter:r})}function zy(e,r){return new e({type:"promise",innerType:r})}function Oc(e,r,i){let o=b(i);return o.abort??(o.abort=!0),new e({type:"custom",check:"custom",fn:r,...o})}function Nc(e,r,i){return new e({type:"custom",check:"custom",fn:r,...b(i)})}function jc(e,r){let i=rm(o=>(o.addIssue=t=>{if(typeof t=="string")o.issues.push(lt(t,o.value,i._zod.def));else{let n=t;n.fatal&&(n.continue=!1),n.code??(n.code="custom"),"input"in n||(n.input=o.value),n.inst??(n.inst=i),n.continue??(n.continue=!i._zod.def.abort),o.issues.push(lt(n))}},e(o.value,o)),r);return i}function rm(e,r){let i=new V({check:"custom",...b(r)});return i._zod.check=e,i}function Uc(e){let r=new V({check:"describe"});return r._zod.onattach=[i=>{let o=G.get(i)??{};G.add(i,{...o,description:e})}],r._zod.check=()=>{},r}function Ac(e){let r=new V({check:"meta"});return r._zod.onattach=[i=>{let o=G.get(i)??{};G.add(i,{...o,...e})}],r._zod.check=()=>{},r}function Tc(e,r){let i=b(r),o=i.truthy??["true","1","yes","on","y","enabled"],t=i.falsy??["false","0","no","off","n","disabled"];i.case!=="sensitive"&&(o=o.map(m=>typeof m=="string"?m.toLowerCase():m),t=t.map(m=>typeof m=="string"?m.toLowerCase():m));let n=new Set(o),a=new Set(t),u=e.Codec??$r,c=e.Boolean??gr,s=e.String??Je,l=new s({type:"string",error:i.error}),d=new c({type:"boolean",error:i.error}),f=new u({type:"pipe",in:l,out:d,transform:((m,v)=>{let _=m;return i.case!=="sensitive"&&(_=_.toLowerCase()),n.has(_)?!0:a.has(_)?!1:(v.issues.push({code:"invalid_value",expected:"stringbool",values:[...n,...a],input:v.value,inst:f,continue:!1}),{})}),reverseTransform:((m,v)=>m===!0?o[0]||"true":t[0]||"false"),error:i.error});return f._zod.bag.truthy=o,f._zod.bag.falsy=t,f._zod.bag.case=i.case??"insensitive",f}function He(e,r,i,o={}){let t=b(o),n={check:"string_format",type:"string",format:r,fn:typeof i=="function"?i:u=>i.test(u),...t};return i instanceof RegExp&&(n.pattern=i),new e(n)}function Pr(e,...r){for(let i of r)for(let o of Reflect.ownKeys(i))Object.prototype.propertyIsEnumerable.call(i,o)&&X(e,o,i[o]);return e}function Ne(e){let r=e?.target??"draft-2020-12";return r==="draft-4"&&(r="draft-04"),r==="draft-7"&&(r="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??G,target:r,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 J(e,r,i,o,t){let n=typeof r.unrepresentable=="function"?r.unrepresentable({zodSchema:e,path:o.path,message:t}):r.unrepresentable;if(n==="any")return!1;if(n===void 0||n==="throw")throw new Error(t);return Object.assign(i,n),!0}function E(e,r,i={path:[],schemaPath:[]}){var o;let t=e._zod.def,n=r.seen.get(e);if(n)return n.count++,i.schemaPath.includes(e)&&(n.cycle=i.path),n.schema;let a={schema:{},count:1,cycle:void 0,path:i.path};r.seen.set(e,a),r.sharedDefsExtractedFor=void 0,r.sharedEmitDoneFor=void 0;let u=e._zod.toJSONSchema?.();if(u)a.schema=u;else{let l={...i,schemaPath:[...i.schemaPath,e],path:i.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(r,a.schema,l);else{let f=a.schema,m=r.processors[t.type];if(!m)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${t.type}`);m(e,r,f,l)}let d=e._zod.parent;d&&(a.ref||(a.ref=d),E(d,r,l),r.seen.get(d).isParent=!0)}let c=r.metadataRegistry.get(e);return c&&Pr(a.schema,c),r.io==="input"&&ee(e)&&(delete a.schema.examples,delete a.schema.default),r.io==="input"&&"_prefault"in a.schema&&((o=a.schema).default??(o.default=a.schema._prefault)),delete a.schema._prefault,r.seen.get(e).schema}function nm(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function je(e,r){let i=e.seen.get(r);if(!i)throw new Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;let o=new Map;for(let a of e.seen.entries()){let u=e.metadataRegistry.get(a[0])?.id;if(u){let c=o.get(u);if(c&&c!==a[0])throw new Error(`Duplicate schema id "${u}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);o.set(u,a[0])}}let t=a=>{let u=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let d=e.external.registry.get(a[0])?.id,f=e.external.uri??(v=>v);if(d)return{ref:f(d)};let m=a[1].defId??a[1].schema.id??`schema${e.counter++}`;return a[1].defId=m,{defId:m,ref:`${f("__shared")}#/${u}/${nm(m)}`}}let c="#",s=`${c}/${u}/`;if(a[1]===i&&!a[1].schema.id)return{ref:c};let l=a[1].schema.id??`__schema${e.counter++}`;return{defId:l,ref:s+nm(l)}},n=a=>{if(a[1].schema.$ref)return;let u=a[1],{ref:c,defId:s}=t(a);u.def={...u.schema},s&&(u.defId=s);let l=u.schema;for(let d in l)delete l[d];l.$ref=c};if(e.cycles==="throw")for(let a of e.seen.entries()){let u=a[1];if(u.cycle)throw new Error(`Cycle detected: #/${u.cycle?.join("/")}/<root>
61
61
 
62
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let a of e.seen.entries()){let u=a[1];if(r===a[0]){n(a);continue}if(e.external){let s=e.external.registry.get(a[0])?.id;if(r!==a[0]&&s){n(a);continue}}if(e.metadataRegistry.get(a[0])?.id){n(a);continue}if(u.cycle){n(a);continue}u.count>1&&e.reused==="ref"&&n(a)}e.external&&(e.sharedDefsExtractedFor=e.external)}function am(e){let r=e.anyOf;if(!Array.isArray(r)||r.length===0||e.type!==void 0)return;let i=[];for(let o of r){if(!o||typeof o!="object")return;am(o);let t=Object.keys(o);if(t.length!==1||t[0]!=="type")return;let n=o.type;for(let a of Array.isArray(n)?n:[n]){if(typeof a!="string")return;i.includes(a)||i.push(a)}}delete e.anyOf,e.type=i.length===1?i[0]:i}var um=new Set(["type","properties","required","additionalProperties"]),im=["oneOf","anyOf"];function om(e){let r=e.additionalProperties;return r===void 0||r===!1||typeof r!="object"||r===null?null:Object.keys(r).length?r:null}function Cc(e){let r=[];for(let n of e){if(typeof n!="object"||n.type!=="object")return null;for(let a in n)if(!um.has(a))return null;r.push(n)}let i={},o=new Set;for(let n of r){for(let a in n.properties){if(Object.prototype.hasOwnProperty.call(i,a))continue;let u=[];for(let s of r){let l=s.properties?.[a]??om(s);l!=null&&(u.some(d=>JSON.stringify(d)===JSON.stringify(l))||u.push(l))}let c=u.length===1?u[0]:Cc(u)??{allOf:u};X(i,a,c)}for(let a of n.required??[])o.add(a)}let t={type:"object",properties:i};if(o.size&&(t.required=[...o]),r.every(n=>n.additionalProperties===!1))t.additionalProperties=!1;else{let n=[];for(let a of r){let u=om(a);u&&!n.some(c=>JSON.stringify(c)===JSON.stringify(u))&&n.push(u)}n.length===1?t.additionalProperties=n[0]:n.length>1&&(t.additionalProperties={allOf:n})}return t}function Dy(e){let r=e.allOf;if(!Array.isArray(r)||r.length<2)return;for(let t of um)if(t in e)return;let i=r.filter(t=>im.some(n=>Array.isArray(t[n]))),o=null;if(!i.length)o=Cc(r);else{let t=i[0],n=im.find(c=>Array.isArray(t[c]));if(Object.keys(t).length!==1)return;let a=r.filter(c=>c!==t),u=t[n].map(c=>Cc([...a,c]));if(u.some(c=>!c))return;o={[n]:u}}o&&(delete e.allOf,Pr(e,o))}function Ue(e,r){let i=e.seen.get(r);if(!i)throw new Error("Unprocessed schema. This is a bug in Zod.");let o=u=>{let c=e.seen.get(u);if(c.ref===null)return;let s=c.def??c.schema,l={...s},d=c.ref;if(c.ref=null,d){o(d);let m=e.seen.get(d),v=m.schema;if(v.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(s.allOf=s.allOf??[],s.allOf.push(v)):Pr(s,v),Pr(s,l),u._zod.parent===d)for(let k in s)k==="$ref"||k==="allOf"||k in l||delete s[k];if(v.$ref&&m.def)for(let k in s)k==="$ref"||k==="allOf"||k in m.def&&JSON.stringify(s[k])===JSON.stringify(m.def[k])&&delete s[k]}let f=u._zod.parent;if(f&&f!==d){o(f);let m=e.seen.get(f);if(m?.schema.$ref&&(s.$ref=m.schema.$ref,m.def))for(let v in s)v==="$ref"||v==="allOf"||v in m.def&&JSON.stringify(s[v])===JSON.stringify(m.def[v])&&delete s[v]}e.override({zodSchema:u,jsonSchema:s,path:c.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let u of[...e.seen.entries()].reverse())o(u[0]);if(e.target!=="openapi-3.0")for(let u of e.seen.entries())am(u[1].def??u[1].schema);for(let u of e.deferred)u();if(e.intersections.length){let u=new Map;for(let c of e.seen.values())for(let s of[c.schema,c.def]){let l=s?.allOf;if(!Array.isArray(l))continue;let d=u.get(l);d?d.push(s):u.set(l,[s])}for(let c of e.intersections)for(let s of u.get(c)??[])Dy(s)}}let t={};if(e.target==="draft-2020-12"?t.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?t.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?t.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){let u=e.external.registry.get(r)?.id;if(!u)throw new Error("Schema is missing an `id` property");t.$id=e.external.uri(u)}Pr(t,i.defId?i.schema:i.def??i.schema);let n=e.metadataRegistry.get(r)?.id;n!==void 0&&t.id===n&&delete t.id;let a=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let u of e.seen.entries()){let c=u[1];c.def&&c.defId&&(c.def.id===c.defId&&delete c.def.id,X(a,c.defId,c.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(a).length>0&&(e.target==="draft-2020-12"?t.$defs=a:t.definitions=a);try{let u=JSON.parse(JSON.stringify(t));return Object.defineProperty(u,"~standard",{value:{...r["~standard"],jsonSchema:{input:Ut(r,"input",e.processors),output:Ut(r,"output",e.processors)}},enumerable:!1,writable:!1}),u}catch{throw new Error("Error converting schema to JSON.")}}function ee(e,r){let i=r??{seen:new Set};if(i.seen.has(e))return!1;i.seen.add(e);let o=e._zod.def;if(o.type==="transform")return!0;if(o.type==="array")return ee(o.element,i);if(o.type==="set")return ee(o.valueType,i);if(o.type==="lazy")return ee(o.getter(),i);if(o.type==="promise"||o.type==="optional"||o.type==="nonoptional"||o.type==="nullable"||o.type==="readonly"||o.type==="default"||o.type==="prefault"||o.type==="catch")return ee(o.innerType,i);if(o.type==="intersection")return ee(o.left,i)||ee(o.right,i);if(o.type==="record"||o.type==="map")return ee(o.keyType,i)||ee(o.valueType,i);if(o.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:ee(o.in,i)||ee(o.out,i);if(o.type==="object"){for(let t in o.shape)if(ee(o.shape[t],i))return!0;return!1}if(o.type==="union"){for(let t of o.options)if(ee(t,i))return!0;return!1}if(o.type==="tuple"){for(let t of o.items)if(ee(t,i))return!0;return!!(o.rest&&ee(o.rest,i))}return!1}var Zc=(e,r={})=>i=>{let o=Ne({...i,processors:r});return E(e,o),je(o,e),Ue(o,e)},Ut=(e,r,i={})=>o=>{let{libraryOptions:t,target:n}=o??{},a=Ne({...t??{},target:n,io:r,processors:i});return E(e,a),je(a,e),Ue(a,e)};var At=(e,r,i)=>{(e[r]===void 0||i>e[r])&&(e[r]=i)},Tt=(e,r,i)=>{(e[r]===void 0||i<e[r])&&(e[r]=i)},cm=(e,r)=>{At(e,"minimum",r),Tt(e,"maximum",r)},fm=(e,r)=>{e.multipleOf??(e.multipleOf=[]),e.multipleOf.includes(r)||e.multipleOf.push(r)},mm=(e,r)=>{e.patterns??(e.patterns=new Set),e.patterns.add(r)},pm=(e,r)=>{e.mime=e.mime?e.mime.filter(i=>r.includes(i)):[...r]},gm=(e,r)=>{e.format=r,r.includes("int")&&(e.isInt=!0)},sm=(e,r)=>At(e,"minimum",r.minimum),lm=(e,r)=>Tt(e,"maximum",r.maximum),dm=e=>(r,i)=>{gm(r,i.format);let[o,t]=e[i.format];At(r,"minimum",o),Tt(r,"maximum",t)},Py={greater_than:(e,r)=>At(e,r.inclusive?"minimum":"exclusiveMinimum",r.value),less_than:(e,r)=>Tt(e,r.inclusive?"maximum":"exclusiveMaximum",r.value),multiple_of:(e,r)=>fm(e,r.value),number_format:dm(qt),bigint_format:dm(Ht),min_length:sm,max_length:lm,length_equals:(e,r)=>cm(e,r.length),min_size:sm,max_size:lm,size_equals:(e,r)=>cm(e,r.size),string_format:(e,r)=>{gm(e,r.format),r.pattern&&mm(e,r.pattern),(r.format==="base64"||r.format==="base64url")&&(e.contentEncoding=r.format),(r.local||r.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,r)=>pm(e,r.mime)};function B(e){let r={},i=e._zod.def,o=e._zod.traits.has("$ZodCheck")?[e,...i.checks??[]]:i.checks??[];for(let n of o)Py[n._zod.def.check]?.(r,n._zod.def);let t=e._zod.bag;t.minimum!==void 0&&At(r,"minimum",t.minimum),t.exclusiveMinimum!==void 0&&At(r,"exclusiveMinimum",t.exclusiveMinimum),t.maximum!==void 0&&Tt(r,"maximum",t.maximum),t.exclusiveMaximum!==void 0&&Tt(r,"exclusiveMaximum",t.exclusiveMaximum),t.multipleOf!==void 0&&fm(r,t.multipleOf),t.format!==void 0&&(r.format??(r.format=t.format),t.format.includes("int")&&(r.isInt=!0)),t.mime&&pm(r,t.mime);for(let n of t.patterns??[])mm(r,n);return r}var Oy={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Ny=new Map([[zn,Fo],[pr,Jo]]),vm=e=>Ny.get(e)??e,Vc=(e,r,i,o)=>{let t=i;t.type="string";let{minimum:n,maximum:a,format:u,patterns:c,contentEncoding:s,laxFormat:l}=B(e);if(typeof n=="number"&&(t.minLength=n),typeof a=="number"&&(t.maxLength=a),u&&(t.format=Oy[u]??u,t.format===""&&delete t.format,(u==="time"||l)&&delete t.format),s&&(t.contentEncoding=s),c&&c.size>0){let d=[...c].map(vm);d.length===1?t.pattern=d[0].source:d.length>1&&(t.allOf=[...d.map(f=>({...r.target==="draft-07"||r.target==="draft-04"||r.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))])}},Rc=(e,r,i,o)=>{let t=i,{minimum:n,maximum:a,multipleOf:u,exclusiveMaximum:c,exclusiveMinimum:s,isInt:l}=B(e);t.type=l?"integer":"number";let d=typeof s=="number"&&s>=(n??Number.NEGATIVE_INFINITY),f=typeof c=="number"&&c<=(a??Number.POSITIVE_INFINITY),m=r.target==="draft-04"||r.target==="openapi-3.0";if(d?m?(t.minimum=s,t.exclusiveMinimum=!0):t.exclusiveMinimum=s:typeof n=="number"&&(t.minimum=n),f?m?(t.maximum=c,t.exclusiveMaximum=!0):t.exclusiveMaximum=c:typeof a=="number"&&(t.maximum=a),u){let v=new Set;for(let S of u)Number.isFinite(S)&&S!==0?v.add(Math.abs(S)):J(e,r,t,o,`A multipleOf divisor of ${S} cannot be represented in JSON Schema`);let[_,...k]=v;_!==void 0&&(t.multipleOf=_),k.length&&(t.allOf=[...t.allOf??[],...k.map(S=>({multipleOf:S}))])}},Mc=(e,r,i,o)=>{i.type="boolean"},Fc=(e,r,i,o)=>{J(e,r,i,o,"BigInt cannot be represented in JSON Schema")},Jc=(e,r,i,o)=>{J(e,r,i,o,"Symbols cannot be represented in JSON Schema")},Bc=(e,r,i,o)=>{r.target==="openapi-3.0"?(i.type="string",i.nullable=!0,i.enum=[null]):i.type="null"},Kc=(e,r,i,o)=>{J(e,r,i,o,"Undefined cannot be represented in JSON Schema")},Xc=(e,r,i,o)=>{J(e,r,i,o,"Void cannot be represented in JSON Schema")},Gc=(e,r,i,o)=>{i.not={}},Wc=(e,r,i,o)=>{},qc=(e,r,i,o)=>{},Hc=(e,r,i,o)=>{J(e,r,i,o,"Date cannot be represented in JSON Schema")},Yc=(e,r,i,o)=>{let t=e._zod.def,n=ot(t.entries);if(n.length===0){i.not={};return}n.every(a=>typeof a=="number")&&(i.type="number"),n.every(a=>typeof a=="string")&&(i.type="string"),i.enum=n},Qc=(e,r,i,o)=>{let t=e._zod.def;if(t.values.length===0){i.not={};return}let n=[];for(let a of t.values)if(a===void 0){if(J(e,r,i,o,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof a=="bigint"){if(J(e,r,i,o,"BigInt literals cannot be represented in JSON Schema"))return;n.push(Number(a))}else n.push(a);if(n.length!==0)if(n.length===1){let a=n[0];i.type=a===null?"null":typeof a,r.target==="draft-04"||r.target==="openapi-3.0"?i.enum=[a]:i.const=a}else n.every(a=>typeof a=="number")&&(i.type="number"),n.every(a=>typeof a=="string")&&(i.type="string"),n.every(a=>typeof a=="boolean")&&(i.type="boolean"),n.every(a=>a===null)&&(i.type="null"),i.enum=n},es=(e,r,i,o)=>{J(e,r,i,o,"NaN cannot be represented in JSON Schema")},ts=(e,r,i,o)=>{let t=i,n=e._zod.pattern;if(!n)throw new Error("Pattern not found in template literal");t.type="string",t.pattern=n.source},rs=(e,r,i,o)=>{let t=i;t.type="string",t.format="binary",t.contentEncoding="binary";let{minimum:n,maximum:a,mime:u}=B(e);n!==void 0&&(t.minLength=n),a!==void 0&&(t.maxLength=a),u&&(u.length===0?t.not={}:u.length===1?t.contentMediaType=u[0]:t.anyOf=u.map(c=>({contentMediaType:c})))},ns=(e,r,i,o)=>{i.type="boolean"},is=(e,r,i,o)=>{J(e,r,i,o,"Custom types cannot be represented in JSON Schema")},os=(e,r,i,o)=>{J(e,r,i,o,"Function types cannot be represented in JSON Schema")},as=(e,r,i,o)=>{J(e,r,i,o,"Transforms cannot be represented in JSON Schema")},us=(e,r,i,o)=>{J(e,r,i,o,"Map cannot be represented in JSON Schema")},cs=(e,r,i,o)=>{J(e,r,i,o,"Set cannot be represented in JSON Schema")},ss=(e,r,i,o)=>{let t=i,n=e._zod.def,{minimum:a,maximum:u}=B(e);typeof a=="number"&&(t.minItems=a),typeof u=="number"&&(t.maxItems=u),t.type="array",t.items=E(n.element,r,{...o,path:[...o.path,"items"]})};function Or(e){let r=e._zod.def;return r.type==="pipe"&&r.in._zod.traits.has("$ZodTransform")?Or(r.out):r.type==="catch"?Or(r.innerType):e._zod.optin}var ls=(e,r,i,o)=>{let t=i,n=e._zod.def,a=n.shape;if(Object.getOwnPropertySymbols(a).length&&J(e,r,t,o,"Symbol keys cannot be represented in JSON Schema"))return;t.type="object",t.properties={};for(let s in a)X(t.properties,s,E(a[s],r,{...o,path:[...o.path,"properties",s]}));let c=[];for(let s of Object.keys(a)){let l=n.shape[s];(r.io==="input"?Or(l)===void 0:l._zod.optout===void 0)&&c.push(s)}c.length>0&&(t.required=c),n.catchall?._zod.def.type==="never"?t.additionalProperties=!1:n.catchall?n.catchall&&(t.additionalProperties=E(n.catchall,r,{...o,path:[...o.path,"additionalProperties"]})):r.io==="output"&&(t.additionalProperties=!1)},Ii=(e,r,i,o)=>{let t=e._zod.def,n=t.inclusive===!1,a=t.options.map((u,c)=>E(u,r,{...o,path:[...o.path,n?"oneOf":"anyOf",c]}));n?i.oneOf=a:i.anyOf=a},ds=(e,r,i,o)=>{let t=e._zod.def,n=E(t.left,r,{...o,path:[...o.path,"allOf",0]}),a=E(t.right,r,{...o,path:[...o.path,"allOf",1]}),u=s=>"allOf"in s&&Object.keys(s).length===1,c=[...u(n)?n.allOf:[n],...u(a)?a.allOf:[a]];i.allOf=c,r.intersections.push(c)},fs=(e,r,i,o)=>{let t=i,n=e._zod.def;t.type="array";let a=r.target==="draft-2020-12"?"prefixItems":"items",u=r.target==="draft-2020-12"||r.target==="openapi-3.0"?"items":"additionalItems",c=n.items.map((_,k)=>E(_,r,{...o,path:[...o.path,a,k]})),s=n.rest?E(n.rest,r,{...o,path:[...o.path,u,...r.target==="openapi-3.0"?[n.items.length]:[]]}):null,l=n.items.length;for(;l>0;){let _=n.items[l-1];if(!(r.io==="input"?Or(_)!==void 0:_._zod.optout==="optional"))break;l--}let d=n.items.length,f=!n.rest;r.target==="draft-2020-12"?(t.prefixItems=c,f?t.items=!1:s&&(t.items=s),l>0&&(t.minItems=l),f&&(t.maxItems=d)):r.target==="openapi-3.0"?(t.items={anyOf:c},s&&t.items.anyOf.push(s),l>0&&(t.minItems=l),f&&(t.maxItems=d)):(t.items=c,f?t.additionalItems=!1:s&&(t.additionalItems=s),l>0&&(t.minItems=l),f&&(t.maxItems=d));let{minimum:m,maximum:v}=B(e);typeof m=="number"&&(t.minItems=m),typeof v=="number"&&(t.maxItems=v)};function Ec(e,r,i){if(r.$ref){if(i.has(r))return r;i.add(r);let v=e.get(r)?.def;if(!v)return r;let _=Ec(e,v,i);return _===v?r:_}for(let v of["anyOf","oneOf"]){let _=r[v];if(!Array.isArray(_))continue;let k=_.map(S=>Ec(e,S,i));k.some((S,I)=>S!==_[I])&&(r={...r,[v]:k})}let o=Array.isArray(r.type)?r.type:[r.type],t=!o.includes("string")&&o.some(v=>v==="number"||v==="integer"),n=r.enum??(r.const!==void 0?[r.const]:void 0);if(!t&&!n?.some(v=>typeof v=="number"))return r;let{minimum:a,maximum:u,exclusiveMinimum:c,exclusiveMaximum:s,multipleOf:l,format:d,id:f,...m}=r;return m.enum?m.enum=m.enum.map(v=>typeof v=="number"?String(v):v):typeof m.const=="number"&&(m.const=String(m.const)),t&&(m.type="string",n||(m.pattern=(o.includes("number")?ke:ur).source)),m}var Lc=new WeakMap;function jy(e){let r=new Map;for(let o of e.seen.values())o.def&&!r.has(o.schema)&&r.set(o.schema,o);let i=new Map;for(let o of Lc.get(e)??[]){let t=e.seen.get(o),n=(t?.def??t?.schema)?.propertyNames;if(!n||n===!0||i.has(n))continue;let a=Ec(r,n,new Set);a!==n&&i.set(n,a)}if(i.size)for(let o of e.seen.values())for(let t of[o.schema,o.def]){let n=t&&i.get(t.propertyNames);n&&(t.propertyNames=n)}}var ms=(e,r,i,o)=>{let t=i,n=e._zod.def;t.type="object";let a=n.keyType,u=B(a).patterns;if(n.mode==="loose"&&u&&u.size>0){let l=E(n.valueType,r,{...o,path:[...o.path,"patternProperties","*"]});t.patternProperties={};for(let d of u)X(t.patternProperties,vm(d).source,l)}else{if(r.target==="draft-07"||r.target==="draft-2020-12"){t.propertyNames=E(n.keyType,r,{...o,path:[...o.path,"propertyNames"]});let l=Lc.get(r);l||(l=[],Lc.set(r,l),r.deferred.push(()=>jy(r))),l.push(e)}t.additionalProperties=E(n.valueType,r,{...o,path:[...o.path,"additionalProperties"]})}let c=a._zod.values,s=r.io==="input"&&Or(n.valueType)!==void 0;if(c&&!n.partial&&!s){let l=[...c].filter(d=>typeof d=="string"||typeof d=="number");l.length>0&&(t.required=l.map(String))}},ps=(e,r,i,o)=>{let t=e._zod.def,n=E(t.innerType,r,o),a=r.seen.get(e);r.target==="openapi-3.0"?(a.ref=t.innerType,i.nullable=!0):i.anyOf=[n,{type:"null"}]},gs=(e,r,i,o)=>{let t=e._zod.def;E(t.innerType,r,o);let n=r.seen.get(e);n.ref=t.innerType},vs=Symbol();function $m(e,r,i,o,t){let n=!1,a=JSON.stringify(e,(u,c)=>typeof c!="bigint"?c:(n=!0,null));return n?(J(r,i,o,t,"BigInt defaults cannot be represented in JSON Schema"),vs):JSON.parse(a)}var $s=(e,r,i,o)=>{let t=e._zod.def;E(t.innerType,r,o);let n=r.seen.get(e);n.ref=t.innerType;let a=$m(t.defaultValue,e,r,i,o);a!==vs&&(i.default=a)},hs=(e,r,i,o)=>{let t=e._zod.def;E(t.innerType,r,o);let n=r.seen.get(e);if(n.ref=t.innerType,r.io!=="input")return;let a=$m(t.defaultValue,e,r,i,o);a!==vs&&(i._prefault=a)},ys=(e,r,i,o)=>{let t=e._zod.def;E(t.innerType,r,o);let n=r.seen.get(e);n.ref=t.innerType;let a;try{a=t.catchValue(void 0)}catch{J(e,r,i,o,"Dynamic catch values are not supported in JSON Schema");return}i.default=a},_s=(e,r,i,o)=>{let t=e._zod.def,n=t.in._zod.traits.has("$ZodTransform"),a=r.io==="input"?n?t.out:t.in:t.out;E(a,r,o);let u=r.seen.get(e);u.ref=a},bs=(e,r,i,o)=>{let t=e._zod.def;E(t.innerType,r,o);let n=r.seen.get(e);n.ref=t.innerType,i.readOnly=!0},ks=(e,r,i,o)=>{let t=e._zod.def;E(t.innerType,r,o);let n=r.seen.get(e);n.ref=t.innerType},wi=(e,r,i,o)=>{let t=e._zod.def;E(t.innerType,r,o);let n=r.seen.get(e);n.ref=t.innerType},xs=(e,r,i,o)=>{let t=e._zod.innerType;E(t,r,o);let n=r.seen.get(e);n.ref=t},xi={string:Vc,number:Rc,boolean:Mc,bigint:Fc,symbol:Jc,null:Bc,undefined:Kc,void:Xc,never:Gc,any:Wc,unknown:qc,date:Hc,enum:Yc,literal:Qc,nan:es,template_literal:ts,file:rs,success:ns,custom:is,function:os,transform:as,map:us,set:cs,array:ss,object:ls,union:Ii,intersection:ds,tuple:fs,record:ms,nullable:ps,nonoptional:gs,default:$s,prefault:hs,catch:ys,pipe:_s,readonly:bs,promise:ks,optional:wi,lazy:xs};function Si(e,r){if("_idmap"in e){let o=e,t=Ne({...r,processors:xi}),n={};for(let c of o._idmap.entries()){let[s,l]=c;E(l,t)}let a={},u={registry:o,uri:r?.uri,defs:n};t.external=u;for(let c of o._idmap.entries()){let[s,l]=c;je(t,l),X(a,s,Ue(t,l))}if(Object.keys(n).length>0){let c=t.target==="draft-2020-12"?"$defs":"definitions";a.__shared={[c]:n}}return{schemas:a}}let i=Ne({...r,processors:xi});return E(e,i),je(i,e),Ue(i,e)}var zi=class{get metadataRegistry(){return this.ctx.metadataRegistry}get target(){return this.ctx.target}get unrepresentable(){return this.ctx.unrepresentable}get override(){return this.ctx.override}get io(){return this.ctx.io}get counter(){return this.ctx.counter}set counter(r){this.ctx.counter=r}get seen(){return this.ctx.seen}constructor(r){let i=r?.target??"draft-2020-12";i==="draft-4"&&(i="draft-04"),i==="draft-7"&&(i="draft-07"),this.ctx=Ne({processors:xi,target:i,...r?.metadata&&{metadata:r.metadata},...r?.unrepresentable&&{unrepresentable:r.unrepresentable},...r?.override&&{override:r.override},...r?.io&&{io:r.io}})}process(r,i={path:[],schemaPath:[]}){return E(r,this.ctx,i)}emit(r,i){i&&(i.cycles&&(this.ctx.cycles=i.cycles),i.reused&&(this.ctx.reused=i.reused),i.external&&(this.ctx.external=i.external)),this.ctx.sharedDefsExtractedFor=void 0,this.ctx.sharedEmitDoneFor=void 0,je(this.ctx,r);let o=Ue(this.ctx,r),{"~standard":t,...n}=o;return n}};var hm={};var Ft={};ge(Ft,{ZodAny:()=>Bs,ZodArray:()=>Ws,ZodBase64:()=>Ki,ZodBase64URL:()=>Xi,ZodBigInt:()=>Rt,ZodBigIntFormat:()=>qi,ZodBoolean:()=>Vt,ZodCIDRv4:()=>Ji,ZodCIDRv6:()=>Bi,ZodCUID:()=>Zi,ZodCUID2:()=>Ei,ZodCatch:()=>vl,ZodCodec:()=>Vr,ZodCreditCard:()=>Zs,ZodCustom:()=>Rr,ZodCustomStringFormat:()=>tt,ZodDate:()=>Ar,ZodDefault:()=>ll,ZodDiscriminatedUnion:()=>Hs,ZodE164:()=>Gi,ZodEmail:()=>Ui,ZodEmoji:()=>Ti,ZodEnum:()=>Zt,ZodExactOptional:()=>eo,ZodFile:()=>al,ZodFunction:()=>Sl,ZodGUID:()=>Ai,ZodIBAN:()=>Es,ZodIPv4:()=>Mi,ZodIPv6:()=>Fi,ZodISODate:()=>Te,ZodISODateTime:()=>Ae,ZodISODuration:()=>Ze,ZodISOTime:()=>Ce,ZodInstanceOf:()=>Pl,ZodIntersection:()=>Ys,ZodJWT:()=>Wi,ZodKSUID:()=>Ri,ZodLazy:()=>xl,ZodLiteral:()=>ol,ZodMAC:()=>Cs,ZodMap:()=>nl,ZodNaN:()=>hl,ZodNanoID:()=>Ci,ZodNever:()=>Xs,ZodNonOptional:()=>to,ZodNull:()=>Fs,ZodNullable:()=>sl,ZodNumber:()=>Lt,ZodNumberFormat:()=>rt,ZodObject:()=>Cr,ZodOptional:()=>Er,ZodPipe:()=>Lr,ZodPrefault:()=>fl,ZodPreprocess:()=>yl,ZodPromise:()=>wl,ZodReadonly:()=>_l,ZodRecord:()=>Ct,ZodSet:()=>il,ZodString:()=>Et,ZodStringFormat:()=>L,ZodSuccess:()=>gl,ZodSymbol:()=>Rs,ZodTemplateLiteral:()=>kl,ZodTransform:()=>ul,ZodTuple:()=>el,ZodType:()=>N,ZodULID:()=>Li,ZodURL:()=>Ur,ZodUUID:()=>ye,ZodUndefined:()=>Ms,ZodUnion:()=>Zr,ZodUnknown:()=>Ks,ZodVoid:()=>Gs,ZodXID:()=>Vi,ZodXor:()=>qs,_ZodString:()=>ji,_default:()=>dl,_function:()=>Op,any:()=>up,array:()=>Tr,base64:()=>Rm,base64url:()=>Mm,bigint:()=>rp,boolean:()=>Vs,catch:()=>$l,check:()=>Np,cidrv4:()=>Lm,cidrv6:()=>Vm,codec:()=>Sp,creditCard:()=>Jm,cuid:()=>Nm,cuid2:()=>jm,currencyCode:()=>qm,custom:()=>jp,date:()=>sp,describe:()=>Up,discriminatedUnion:()=>gp,e164:()=>Fm,email:()=>bm,emoji:()=>Pm,enum:()=>Yi,exactOptional:()=>cl,file:()=>kp,float32:()=>Ym,float64:()=>Qm,function:()=>Op,guid:()=>km,hash:()=>Hm,hex:()=>Wm,hostname:()=>Gm,httpUrl:()=>Dm,iban:()=>Bm,instanceof:()=>Tp,int:()=>Oi,int32:()=>ep,int64:()=>np,intersection:()=>Qs,invertCodec:()=>zp,ipv4:()=>Cm,ipv6:()=>Em,json:()=>Zp,jwt:()=>Km,keyof:()=>lp,ksuid:()=>Tm,lazy:()=>Il,literal:()=>bp,looseObject:()=>mp,looseRecord:()=>$p,mac:()=>Zm,map:()=>hp,meta:()=>Ap,nan:()=>wp,nanoid:()=>Om,nativeEnum:()=>_p,never:()=>Hi,nonoptional:()=>pl,null:()=>Js,nullable:()=>jr,nullish:()=>xp,number:()=>Ls,object:()=>dp,optional:()=>Qe,partialRecord:()=>vp,pipe:()=>Ni,prefault:()=>ml,preprocess:()=>Ep,promise:()=>Pp,readonly:()=>bl,record:()=>rl,refine:()=>zl,set:()=>yp,strictObject:()=>fp,string:()=>Nr,stringFormat:()=>Xm,stringbool:()=>Cp,success:()=>Ip,superRefine:()=>Dl,symbol:()=>op,templateLiteral:()=>Dp,transform:()=>Qi,tuple:()=>tl,uint32:()=>tp,uint64:()=>ip,ulid:()=>Um,undefined:()=>ap,union:()=>Mt,unknown:()=>Ye,url:()=>zm,uuid:()=>xm,uuidv4:()=>Im,uuidv6:()=>wm,uuidv7:()=>Sm,void:()=>cp,xid:()=>Am,xor:()=>pp});var Di={};ge(Di,{endsWith:()=>wt,gt:()=>$e,gte:()=>ce,includes:()=>xt,length:()=>qe,lowercase:()=>bt,lt:()=>ve,lte:()=>ue,maxLength:()=>We,maxSize:()=>Oe,mime:()=>zt,minLength:()=>xe,minSize:()=>he,multipleOf:()=>Pe,negative:()=>yi,nonnegative:()=>bi,nonpositive:()=>_i,normalize:()=>Dt,overwrite:()=>pe,positive:()=>hi,properties:()=>St,property:()=>ki,regex:()=>_t,size:()=>Ge,slugify:()=>jt,startsWith:()=>It,toLowerCase:()=>Ot,toUpperCase:()=>Nt,trim:()=>Pt,uppercase:()=>kt});var ym=new WeakSet([Object.prototype,Error.prototype]);function Pi(e,r,i){Object.defineProperty(e,r,{configurable:!0,enumerable:!1,get(){let o=i(this);return Object.defineProperty(this,r,{value:o,configurable:!0,writable:!0}),o},set(o){Object.defineProperty(this,r,{value:o,configurable:!0,writable:!0})}})}var _m=(e,r)=>{xo.init(e,r),e.name="ZodError";let i=Object.getPrototypeOf(e);ym.has(i)||(ym.add(i),Pi(i,"format",o=>t=>nr(o,t)),Pi(i,"flatten",o=>t=>rr(o,t)),Pi(i,"addIssue",o=>t=>{o.issues.push(t),o.message=JSON.stringify(o.issues,at,2)}),Pi(i,"addIssues",o=>t=>{o.issues.push(...t),o.message=JSON.stringify(o.issues,at,2)}),Object.defineProperty(i,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},Ay=p("ZodError",_m),ae=p("ZodError",_m,void 0,{Parent:Error});var Is=dt(ae),ws=ft(ae),Ss=mt(ae),zs=pt(ae),Ds=nn(ae),Ps=on(ae),Os=an(ae),Ns=un(ae),js=cn(ae),Us=sn(ae),As=ln(ae),Ts=dn(ae);function Cy(){K.localeError||F(Fn())}function et(){K.memoizer||F({memoizer:br()})}var N=p("ZodType",(e,r)=>(Cy(),D.init(e,r),e.def=r,e.type=r.type,e),{check(...e){let r=this.def;return this.clone($.mergeDefs(r,{checks:[...r.checks??[],...e.map(i=>typeof i=="function"?{_zod:{check:i,def:{check:"custom"},onattach:[]}}:i)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,r){return C(this,e,r)},brand(){return this},register(e,r){return e.add(this,r),this},refine(e,r){return this.check(zl(e,r))},superRefine(e,r){return this.check(Dl(e,r))},overwrite(e){return this.check(pe(e))},optional(){return Qe(this)},exactOptional(){return cl(this)},nullable(){return jr(this)},nullish(){return Qe(jr(this))},nonoptional(e){return pl(this,e)},array(){return Tr(this)},or(e){return Mt([this,e])},and(e){return Qs(this,e)},transform(e){return Ni(this,Qi(e))},default(e){return dl(this,e)},prefault(e){return ml(this,e)},catch(e){return $l(this,e)},pipe(e){return Ni(this,e)},readonly(){return bl(this)},describe(e){let r=this.clone();return G.add(r,{description:e}),r},meta(...e){if(e.length===0)return G.get(this);let r=this.clone();return G.add(r,e[0]),r},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...r){return r.length===0?e(this):e(this,...r)},get"~standard"(){return $.hide(this,"~standard",{...kn(this),jsonSchema:{input:Ut(this,"input"),output:Ut(this,"output")}})},set"~standard"(e){$.own(this,"~standard",e)},parse:function e(r,i){return Is(this,r,i,{callee:e})},parseAsync:async function e(r,i){return await ws(this,r,i,{callee:e})},safeParse(e,r){return Ss(this,e,r)},async safeParseAsync(e,r){return zs(this,e,r)},get spa(){return this?.safeParseAsync},set spa(e){$.own(this,"spa",e)},validate(e,r){return ir(this,e,r)},validateAsync(e,r){return or(this,e,r)},encode:function e(r,i){return Ds(this,r,i,{callee:e})},decode:function e(r,i){return Ps(this,r,i,{callee:e})},encodeAsync:async function e(r,i){return await Os(this,r,i,{callee:e})},decodeAsync:async function e(r,i){return await Ns(this,r,i,{callee:e})},safeEncode(e,r){return js(this,e,r)},safeDecode(e,r){return Us(this,e,r)},async safeEncodeAsync(e,r){return As(this,e,r)},async safeDecodeAsync(e,r){return Ts(this,e,r)},toJSONSchema(e){return Zc(this,{})(e)},get description(){return G.get(this)?.description},get _def(){return this._zod.def}}),ji=p("_ZodString",(e,r)=>{Je.init(e,r),N.init(e,r),e._zod.processJSONSchema=(i,o,t)=>Vc(e,i,o,t)},$.derived({format:e=>B(e).format??null,minLength:e=>B(e).minimum??null,maxLength:e=>B(e).maximum??null},{regex(...e){return this.check(_t(...e))},includes(...e){return this.check(xt(...e))},startsWith(...e){return this.check(It(...e))},endsWith(...e){return this.check(wt(...e))},min(...e){return this.check(xe(...e))},max(...e){return this.check(We(...e))},length(...e){return this.check(qe(...e))},nonempty(...e){return this.check(xe(1,...e))},lowercase(e){return this.check(bt(e))},uppercase(e){return this.check(kt(e))},trim(){return this.check(Pt())},normalize(...e){return this.check(Dt(...e))},toLowerCase(){return this.check(Ot())},toUpperCase(){return this.check(Nt())},slugify(){return this.check(jt())}})),Et=p("ZodString",(e,r)=>{Je.init(e,r),ji.init(e,r)},{email(e){return this.check(Hn(Ui,e))},url(e){return this.check(Ir(Ur,e))},jwt(e){return this.check($i(Wi,e))},emoji(e){return this.check(ni(Ti,e))},guid(e){return this.check(Yn(Ai,e))},uuid(e){return this.check(Qn(ye,e))},uuidv4(e){return this.check(ei(ye,e))},uuidv6(e){return this.check(ti(ye,e))},uuidv7(e){return this.check(ri(ye,e))},nanoid(e){return this.check(ii(Ci,e))},cuid(e){return this.check(oi(Zi,e))},cuid2(e){return this.check(ai(Ei,e))},ulid(e){return this.check(ui(Li,e))},base64(e){return this.check(pi(Ki,e))},base64url(e){return this.check(gi(Xi,e))},xid(e){return this.check(ci(Vi,e))},ksuid(e){return this.check(si(Ri,e))},ipv4(e){return this.check(li(Mi,e))},ipv6(e){return this.check(di(Fi,e))},cidrv4(e){return this.check(fi(Ji,e))},cidrv6(e){return this.check(mi(Bi,e))},e164(e){return this.check(vi(Gi,e))},datetime(e){return this.check(wr(Ae,e))},date(e){return this.check(Sr(Te,e))},time(e){return this.check(zr(Ce,e))},duration(e){return this.check(Dr(Ze,e))}});function Nr(e){return Qu(Et,e)}var L=p("ZodStringFormat",(e,r)=>{Z.init(e,r),ji.init(e,r)}),Ae=p("ZodISODateTime",(e,r)=>{Fa.init(e,r),L.init(e,r)}),Te=p("ZodISODate",(e,r)=>{Ja.init(e,r),L.init(e,r)}),Ce=p("ZodISOTime",(e,r)=>{Ba.init(e,r),L.init(e,r)}),Ze=p("ZodISODuration",(e,r)=>{Ka.init(e,r),L.init(e,r)}),Ui=p("ZodEmail",(e,r)=>{ja.init(e,r),L.init(e,r)});function bm(e){return Hn(Ui,e)}var Ai=p("ZodGUID",(e,r)=>{Oa.init(e,r),L.init(e,r)});function km(e){return Yn(Ai,e)}var ye=p("ZodUUID",(e,r)=>{Na.init(e,r),L.init(e,r)});function xm(e){return Qn(ye,e)}function Im(e){return ei(ye,e)}function wm(e){return ti(ye,e)}function Sm(e){return ri(ye,e)}var Ur=p("ZodURL",(e,r)=>{Ta.init(e,r),L.init(e,r)});function zm(e){return Ir(Ur,e)}function Dm(e){return Ir(Ur,{protocol:ar,hostname:Ko,...$.normalizeParams(e)})}var Ti=p("ZodEmoji",(e,r)=>{Ca.init(e,r),L.init(e,r)});function Pm(e){return ni(Ti,e)}var Ci=p("ZodNanoID",(e,r)=>{Za.init(e,r),L.init(e,r)});function Om(e){return ii(Ci,e)}var Zi=p("ZodCUID",(e,r)=>{Ea.init(e,r),L.init(e,r)});function Nm(e){return oi(Zi,e)}var Ei=p("ZodCUID2",(e,r)=>{La.init(e,r),L.init(e,r)});function jm(e){return ai(Ei,e)}var Li=p("ZodULID",(e,r)=>{Va.init(e,r),L.init(e,r)});function Um(e){return ui(Li,e)}var Vi=p("ZodXID",(e,r)=>{Ra.init(e,r),L.init(e,r)});function Am(e){return ci(Vi,e)}var Ri=p("ZodKSUID",(e,r)=>{Ma.init(e,r),L.init(e,r)});function Tm(e){return si(Ri,e)}var Mi=p("ZodIPv4",(e,r)=>{Xa.init(e,r),L.init(e,r)});function Cm(e){return li(Mi,e)}var Cs=p("ZodMAC",(e,r)=>{Wa.init(e,r),L.init(e,r)});function Zm(e){return tc(Cs,e)}var Fi=p("ZodIPv6",(e,r)=>{Ga.init(e,r),L.init(e,r)});function Em(e){return di(Fi,e)}var Ji=p("ZodCIDRv4",(e,r)=>{qa.init(e,r),L.init(e,r)});function Lm(e){return fi(Ji,e)}var Bi=p("ZodCIDRv6",(e,r)=>{Ha.init(e,r),L.init(e,r)});function Vm(e){return mi(Bi,e)}var Ki=p("ZodBase64",(e,r)=>{Ya.init(e,r),L.init(e,r)});function Rm(e){return pi(Ki,e)}var Xi=p("ZodBase64URL",(e,r)=>{Qa.init(e,r),L.init(e,r)});function Mm(e){return gi(Xi,e)}var Gi=p("ZodE164",(e,r)=>{eu.init(e,r),L.init(e,r)});function Fm(e){return vi(Gi,e)}var Zs=p("ZodCreditCard",(e,r)=>{tu.init(e,r),L.init(e,r)});function Jm(e){return rc(Zs,e)}var Es=p("ZodIBAN",(e,r)=>{ru.init(e,r),L.init(e,r)});function Bm(e){return nc(Es,e)}var Wi=p("ZodJWT",(e,r)=>{nu.init(e,r),L.init(e,r)});function Km(e){return $i(Wi,e)}var tt=p("ZodCustomStringFormat",(e,r)=>{iu.init(e,r),L.init(e,r)});function Xm(e,r,i={}){return He(tt,e,r,i)}function Gm(e){return He(tt,"hostname",Bo,e)}function Wm(e){return He(tt,"hex",aa,e)}function qm(e){return He(tt,"currency_code",Go,e)}function Hm(e,r){let i=r?.enc??"hex",o=`${e}_${i}`,t=de[o];if(!t)throw new Error(`Unrecognized hash format: ${o}`);return He(tt,o,t,r)}var Lt=p("ZodNumber",(e,r)=>{jn.init(e,r),N.init(e,r),e._zod.processJSONSchema=(i,o,t)=>Rc(e,i,o,t),e.isFinite=!0},$.derived({minValue:e=>{let{minimum:r,exclusiveMinimum:i}=B(e);return Math.max(r??Number.NEGATIVE_INFINITY,i??Number.NEGATIVE_INFINITY)},maxValue:e=>{let{maximum:r,exclusiveMaximum:i}=B(e);return Math.min(r??Number.POSITIVE_INFINITY,i??Number.POSITIVE_INFINITY)},isInt:e=>{let{isInt:r,multipleOf:i}=B(e);return!!r||!!i?.some(Number.isSafeInteger)},format:e=>B(e).format??null},{gt(e,r){return this.check($e(e,r))},gte(e,r){return this.check(ce(e,r))},min(e,r){return this.check(ce(e,r))},lt(e,r){return this.check(ve(e,r))},lte(e,r){return this.check(ue(e,r))},max(e,r){return this.check(ue(e,r))},int(e){return this.check(Oi(e))},safe(e){return this.check(Oi(e))},positive(e){return this.check($e(0,e))},nonnegative(e){return this.check(ce(0,e))},negative(e){return this.check(ve(0,e))},nonpositive(e){return this.check(ue(0,e))},multipleOf(e,r){return this.check(Pe(e,r))},step(e,r){return this.check(Pe(e,r))},finite(){return this}}));function Ls(e){return oc(Lt,e)}var rt=p("ZodNumberFormat",(e,r)=>{ou.init(e,r),Lt.init(e,r)});function Oi(e){return uc(rt,e)}function Ym(e){return cc(rt,e)}function Qm(e){return sc(rt,e)}function ep(e){return lc(rt,e)}function tp(e){return dc(rt,e)}var Vt=p("ZodBoolean",(e,r)=>{gr.init(e,r),N.init(e,r),e._zod.processJSONSchema=(i,o,t)=>Mc(e,i,o,t)});function Vs(e){return fc(Vt,e)}var Rt=p("ZodBigInt",(e,r)=>{Un.init(e,r),N.init(e,r),e._zod.processJSONSchema=(i,o,t)=>Fc(e,i,o,t)},$.derived({minValue:e=>B(e).minimum??null,maxValue:e=>B(e).maximum??null,format:e=>B(e).format??null},{gte(e,r){return this.check(ce(e,r))},min(e,r){return this.check(ce(e,r))},gt(e,r){return this.check($e(e,r))},lt(e,r){return this.check(ve(e,r))},lte(e,r){return this.check(ue(e,r))},max(e,r){return this.check(ue(e,r))},positive(e){return this.check($e(BigInt(0),e))},negative(e){return this.check(ve(BigInt(0),e))},nonpositive(e){return this.check(ue(BigInt(0),e))},nonnegative(e){return this.check(ce(BigInt(0),e))},multipleOf(e,r){return this.check(Pe(e,r))}}));function rp(e){return pc(Rt,e)}var qi=p("ZodBigIntFormat",(e,r)=>{au.init(e,r),Rt.init(e,r)});function np(e){return vc(qi,e)}function ip(e){return $c(qi,e)}var Rs=p("ZodSymbol",(e,r)=>{uu.init(e,r),N.init(e,r),e._zod.processJSONSchema=(i,o,t)=>Jc(e,i,o,t)});function op(e){return hc(Rs,e)}var Ms=p("ZodUndefined",(e,r)=>{cu.init(e,r),N.init(e,r),e._zod.processJSONSchema=(i,o,t)=>Kc(e,i,o,t)});function ap(e){return yc(Ms,e)}var Fs=p("ZodNull",(e,r)=>{su.init(e,r),N.init(e,r),e._zod.processJSONSchema=(i,o,t)=>Bc(e,i,o,t)});function Js(e){return _c(Fs,e)}var Bs=p("ZodAny",(e,r)=>{lu.init(e,r),N.init(e,r),e._zod.processJSONSchema=(i,o,t)=>Wc(e,i,o,t)});function up(){return bc(Bs)}var Ks=p("ZodUnknown",(e,r)=>{du.init(e,r),N.init(e,r),e._zod.processJSONSchema=(i,o,t)=>qc(e,i,o,t)});function Ye(){return kc(Ks)}var Xs=p("ZodNever",(e,r)=>{fu.init(e,r),N.init(e,r),e._zod.processJSONSchema=(i,o,t)=>Gc(e,i,o,t)});function Hi(e){return xc(Xs,e)}var Gs=p("ZodVoid",(e,r)=>{mu.init(e,r),N.init(e,r),e._zod.processJSONSchema=(i,o,t)=>Xc(e,i,o,t)});function cp(e){return Ic(Gs,e)}var Ar=p("ZodDate",(e,r)=>{pu.init(e,r),N.init(e,r),e._zod.processJSONSchema=(i,o,t)=>Hc(e,i,o,t),e.min=(i,o)=>e.check(ce(i,o)),e.max=(i,o)=>e.check(ue(i,o))},$.derived({minDate:e=>{let{minimum:r}=B(e);return r?new Date(r):null},maxDate:e=>{let{maximum:r}=B(e);return r?new Date(r):null}},{}));function sp(e){return wc(Ar,e)}var Ws=p("ZodArray",(e,r)=>{et(),vu.init(e,r),N.init(e,r),e._zod.processJSONSchema=(i,o,t)=>ss(e,i,o,t),e.element=r.element},{min(e,r){return this.check(xe(e,r))},nonempty(e){return this.check(xe(1,e))},max(e,r){return this.check(We(e,r))},length(e,r){return this.check(qe(e,r))},unwrap(){return this.element}});function Tr(e,r){return Dc(Ws,e,r)}function lp(e){let r=e._zod.def.shape;return Yi(Object.keys(r))}var Cr=p("ZodObject",(e,r)=>{et(),$u.init(e,r),N.init(e,r),e._zod.processJSONSchema=(i,o,t)=>ls(e,i,o,t),$.installLazyProp(e,"shape",i=>i._zod.def.shape,!1)},{keyof(){return Yi(Object.keys(this._zod.def.shape))},catchall(e){return this.clone($.mergeDefs(this._zod.def,{catchall:e}))},passthrough(){return this.clone($.mergeDefs(this._zod.def,{catchall:Ye()}))},loose(){return this.clone($.mergeDefs(this._zod.def,{catchall:Ye()}))},strict(){return this.clone($.mergeDefs(this._zod.def,{catchall:Hi()}))},strip(){return this.clone($.mergeDefs(this._zod.def,{catchall:void 0}))},extend(e){return $.extend(this,e)},safeExtend(e){return $.safeExtend(this,e)},merge(e){return $.merge(this,e)},pick(e){return $.pick(this,e)},omit(e){return $.omit(this,e)},partial(...e){return $.partial(Er,this,e[0])},exactPartial(...e){return $.partial(eo,this,e[0],"exactPartial")},required(...e){return $.required(to,this,e[0])}});function dp(e,r){let i={type:"object",shape:e??{},...$.normalizeParams(r)};return new Cr(i)}function fp(e,r){return new Cr({type:"object",shape:e,catchall:Hi(),...$.normalizeParams(r)})}function mp(e,r){return new Cr({type:"object",shape:e,catchall:Ye(),...$.normalizeParams(r)})}var Zr=p("ZodUnion",(e,r)=>{vr.init(e,r),N.init(e,r),e._zod.processJSONSchema=(i,o,t)=>Ii(e,i,o,t),e.options=r.options});function Mt(e,r){return new Zr({type:"union",options:e,...$.normalizeParams(r)})}var qs=p("ZodXor",(e,r)=>{Zr.init(e,r),hu.init(e,r),e._zod.processJSONSchema=(i,o,t)=>Ii(e,i,o,t),e.options=r.options});function pp(e,r){return new qs({type:"union",options:e,inclusive:!1,...$.normalizeParams(r)})}var Hs=p("ZodDiscriminatedUnion",(e,r)=>{Zr.init(e,r),_u.init(e,r)});function gp(e,r,i){return new Hs({type:"union",options:r,discriminator:e,...$.normalizeParams(i)})}var Ys=p("ZodIntersection",(e,r)=>{bu.init(e,r),N.init(e,r),e._zod.processJSONSchema=(i,o,t)=>ds(e,i,o,t)});function Qs(e,r){return new Ys({type:"intersection",left:e,right:r})}var el=p("ZodTuple",(e,r)=>{et(),An.init(e,r),N.init(e,r),e._zod.processJSONSchema=(i,o,t)=>fs(e,i,o,t)},{rest(e){return this.clone({...this._zod.def,rest:e})},partial(){let e=this._zod.def;if(e.checks?.length)throw new Error(".partial() cannot be used on tuple schemas containing refinements");return this.clone({...e,items:e.items.map(r=>new Er({type:"optional",innerType:r}))})}});function tl(e,r,i){let o=r instanceof D,t=o?i:r,n=o?r:null;return new el({type:"tuple",items:e,rest:n,...$.normalizeParams(t)})}var Ct=p("ZodRecord",(e,r)=>{et(),ku.init(e,r),N.init(e,r),e._zod.processJSONSchema=(i,o,t)=>ms(e,i,o,t),e.keyType=r.keyType,e.valueType=r.valueType});function rl(e,r,i){return!r||!r._zod?new Ct({type:"record",keyType:Nr(),valueType:e,...$.normalizeParams(r)}):new Ct({type:"record",keyType:e,valueType:r,...$.normalizeParams(i)})}function vp(e,r,i){return new Ct({type:"record",keyType:e,valueType:r,...$.normalizeParams(i),partial:!0})}function $p(e,r,i){return new Ct({type:"record",keyType:e,valueType:r,mode:"loose",...$.normalizeParams(i)})}var nl=p("ZodMap",(e,r)=>{et(),xu.init(e,r),N.init(e,r),e._zod.processJSONSchema=(i,o,t)=>us(e,i,o,t),e.keyType=r.keyType,e.valueType=r.valueType,e.min=(...i)=>e.check(he(...i)),e.nonempty=i=>e.check(he(1,i)),e.max=(...i)=>e.check(Oe(...i)),e.size=(...i)=>e.check(Ge(...i))});function hp(e,r,i){return new nl({type:"map",keyType:e,valueType:r,...$.normalizeParams(i)})}var il=p("ZodSet",(e,r)=>{et(),Iu.init(e,r),N.init(e,r),e._zod.processJSONSchema=(i,o,t)=>cs(e,i,o,t),e.min=(...i)=>e.check(he(...i)),e.nonempty=i=>e.check(he(1,i)),e.max=(...i)=>e.check(Oe(...i)),e.size=(...i)=>e.check(Ge(...i))});function yp(e,r){return new il({type:"set",valueType:e,...$.normalizeParams(r)})}var Zt=p("ZodEnum",(e,r)=>{wu.init(e,r),N.init(e,r),e._zod.processJSONSchema=(o,t,n)=>Yc(e,o,t,n),e.enum=r.entries,e.options=[...e._zod.values];let i=new Set(Object.keys(r.entries));e.extract=(o,t)=>{let n={};for(let a of o)if(i.has(a))n[a]=r.entries[a];else throw new Error(`Key ${a} not found in enum`);return new Zt({...r,checks:[],...$.normalizeParams(t),entries:n})},e.exclude=(o,t)=>{let n={...r.entries};for(let a of o)if(i.has(a))delete n[a];else throw new Error(`Key ${a} not found in enum`);return new Zt({...r,checks:[],...$.normalizeParams(t),entries:n})}});function Yi(e,r){let i=Array.isArray(e)?Object.fromEntries(e.map(o=>[o,o])):e;return new Zt({type:"enum",entries:i,...$.normalizeParams(r)})}function _p(e,r){return new Zt({type:"enum",entries:e,...$.normalizeParams(r)})}var ol=p("ZodLiteral",(e,r)=>{Su.init(e,r),N.init(e,r),e._zod.processJSONSchema=(i,o,t)=>Qc(e,i,o,t),e.values=new Set(r.values),Object.defineProperty(e,"value",{get(){if(r.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return r.values[0]}})});function bp(e,r){return new ol({type:"literal",values:Array.isArray(e)?e:[e],...$.normalizeParams(r)})}var al=p("ZodFile",(e,r)=>{zu.init(e,r),N.init(e,r),e._zod.processJSONSchema=(i,o,t)=>rs(e,i,o,t),e.min=(i,o)=>e.check(he(i,o)),e.max=(i,o)=>e.check(Oe(i,o)),e.mime=(i,o)=>e.check(zt(Array.isArray(i)?i:[i],o))});function kp(e){return Pc(al,e)}var ul=p("ZodTransform",(e,r)=>{et(),Du.init(e,r),N.init(e,r),e._zod.processJSONSchema=(i,o,t)=>as(e,i,o,t),e._zod.parse=(i,o)=>{if(o.direction==="backward")throw new ze(e.constructor.name);i.addIssue=n=>{if(typeof n=="string")i.issues.push($.issue(n,i.value,r));else{let a=n;a.fatal&&(a.continue=!1),a.code??(a.code="custom"),"input"in a||(a.input=i.value),a.inst??(a.inst=e),i.issues.push($.issue(a))}};let t=r.transform(i.value,i);return t instanceof Promise?t.then(n=>(i.value=n,i)):(i.value=t,i)}});function Qi(e){return new ul({type:"transform",transform:e})}var Er=p("ZodOptional",(e,r)=>{Tn.init(e,r),N.init(e,r),e._zod.processJSONSchema=(i,o,t)=>wi(e,i,o,t),e.unwrap=()=>e._zod.def.innerType});function Qe(e){return new Er({type:"optional",innerType:e})}var eo=p("ZodExactOptional",(e,r)=>{Pu.init(e,r),N.init(e,r),e._zod.processJSONSchema=(i,o,t)=>wi(e,i,o,t),e.unwrap=()=>e._zod.def.innerType});function cl(e){return new eo({type:"optional",innerType:e})}var sl=p("ZodNullable",(e,r)=>{Ou.init(e,r),N.init(e,r),e._zod.processJSONSchema=(i,o,t)=>ps(e,i,o,t),e.unwrap=()=>e._zod.def.innerType});function jr(e){return new sl({type:"nullable",innerType:e})}function xp(e){return Qe(jr(e))}var ll=p("ZodDefault",(e,r)=>{Nu.init(e,r),N.init(e,r),e._zod.processJSONSchema=(i,o,t)=>$s(e,i,o,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function dl(e,r){return new ll({type:"default",innerType:e,get defaultValue(){return typeof r=="function"?r():$.shallowClone(r)}})}var fl=p("ZodPrefault",(e,r)=>{ju.init(e,r),N.init(e,r),e._zod.processJSONSchema=(i,o,t)=>hs(e,i,o,t),e.unwrap=()=>e._zod.def.innerType});function ml(e,r){return new fl({type:"prefault",innerType:e,get defaultValue(){return typeof r=="function"?r():$.shallowClone(r)}})}var to=p("ZodNonOptional",(e,r)=>{Uu.init(e,r),N.init(e,r),e._zod.processJSONSchema=(i,o,t)=>gs(e,i,o,t),e.unwrap=()=>e._zod.def.innerType});function pl(e,r){return new to({type:"nonoptional",innerType:e,...$.normalizeParams(r)})}var gl=p("ZodSuccess",(e,r)=>{Au.init(e,r),N.init(e,r),e._zod.processJSONSchema=(i,o,t)=>ns(e,i,o,t),e.unwrap=()=>e._zod.def.innerType});function Ip(e){return new gl({type:"success",innerType:e})}var vl=p("ZodCatch",(e,r)=>{Tu.init(e,r),N.init(e,r),e._zod.processJSONSchema=(i,o,t)=>ys(e,i,o,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function $l(e,r){return new vl({type:"catch",innerType:e,catchValue:typeof r=="function"?r:$.constantCatch(r)})}var hl=p("ZodNaN",(e,r)=>{Cu.init(e,r),N.init(e,r),e._zod.processJSONSchema=(i,o,t)=>es(e,i,o,t)});function wp(e){return zc(hl,e)}var Lr=p("ZodPipe",(e,r)=>{Cn.init(e,r),N.init(e,r),e._zod.processJSONSchema=(i,o,t)=>_s(e,i,o,t),e.in=r.in,e.out=r.out});function Ni(e,r){return new Lr({type:"pipe",in:e,out:r})}var Vr=p("ZodCodec",(e,r)=>{Lr.init(e,r),$r.init(e,r)});function Sp(e,r,i){return new Vr({type:"pipe",in:e,out:r,transform:i.decode,reverseTransform:i.encode})}function zp(e){let r=e._zod.def;return new Vr({type:"pipe",in:r.out,out:r.in,transform:r.reverseTransform,reverseTransform:r.transform})}var yl=p("ZodPreprocess",(e,r)=>{Lr.init(e,r),Zu.init(e,r)}),_l=p("ZodReadonly",(e,r)=>{Eu.init(e,r),N.init(e,r),e._zod.processJSONSchema=(i,o,t)=>bs(e,i,o,t),e.unwrap=()=>e._zod.def.innerType});function bl(e){return new _l({type:"readonly",innerType:e})}var kl=p("ZodTemplateLiteral",(e,r)=>{Lu.init(e,r),N.init(e,r),e._zod.processJSONSchema=(i,o,t)=>ts(e,i,o,t)});function Dp(e,r){return new kl({type:"template_literal",parts:e,...$.normalizeParams(r)})}var xl=p("ZodLazy",(e,r)=>{hr.init(e,r),N.init(e,r),e._zod.processJSONSchema=(i,o,t)=>xs(e,i,o,t),e.unwrap=()=>e._zod.def.getter()});function Il(e){return new xl({type:"lazy",getter:e})}var wl=p("ZodPromise",(e,r)=>{Ru.init(e,r),N.init(e,r),e._zod.processJSONSchema=(i,o,t)=>ks(e,i,o,t),e.unwrap=()=>e._zod.def.innerType});function Pp(e){return new wl({type:"promise",innerType:e})}var Sl=p("ZodFunction",(e,r)=>{Vu.init(e,r),N.init(e,r),e._zod.processJSONSchema=(i,o,t)=>os(e,i,o,t)});function Op(e){return new Sl({type:"function",input:Array.isArray(e?.input)?tl(e?.input):e?.input??Tr(Ye()),output:e?.output??Ye()})}var Rr=p("ZodCustom",(e,r)=>{Mu.init(e,r),N.init(e,r),e._zod.processJSONSchema=(i,o,t)=>is(e,i,o,t)});function Np(e){let r=new V({check:"custom"});return r._zod.check=e,r}function jp(e,r){return Oc(Rr,e??(()=>!0),r)}function zl(e,r={}){return Nc(Rr,e,r)}function Dl(e,r){return jc(e,r)}var Up=Uc,Ap=Ac,Pl=p("ZodInstanceOf",(e,r)=>{Rr.init(e,r)},{properties(e,r){return this.check(St(e,r))}});function Tp(e,r={}){let i=new Pl({type:"custom",check:"custom",fn:o=>o instanceof e,abort:!0,...$.normalizeParams(r)});return i._zod.bag.Class=e,i._zod.check=o=>{o.value instanceof e||o.issues.push({code:"invalid_type",expected:e.name,input:o.value,inst:i,path:[...i._zod.def.path??[]]})},i}var Cp=(...e)=>Tc({Codec:Vr,Boolean:Vt,String:Et},...e);function Zp(e){let r=Il(()=>Mt([Nr(e),Ls(),Vs(),Js(),Tr(r),rl(Nr(),r)]));return r}function Ep(e,r){return new yl({type:"pipe",in:Qi(e),out:r})}var Zy={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};function Ey(e){F({customError:e})}function Ly(){return F().customError}var Ol;Ol||(Ol={});var Mr={};ge(Mr,{ZodISODate:()=>Te,ZodISODateTime:()=>Ae,ZodISODuration:()=>Ze,ZodISOTime:()=>Ce,date:()=>Ry,datetime:()=>Vy,duration:()=>Fy,time:()=>My});function Vy(e){return wr(Ae,e)}function Ry(e){return Sr(Te,e)}function My(e){return zr(Ce,e)}function Fy(e){return Dr(Ze,e)}var x={...Ft,...Di,iso:Mr},Jy=new Set(["$schema","$ref","$defs","definitions","$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor","type","enum","const","anyOf","oneOf","allOf","not","properties","required","additionalProperties","patternProperties","propertyNames","minProperties","maxProperties","items","prefixItems","additionalItems","minItems","maxItems","uniqueItems","contains","minContains","maxContains","minLength","maxLength","pattern","format","minimum","maximum","exclusiveMinimum","exclusiveMaximum","multipleOf","description","default","contentEncoding","contentMediaType","contentSchema","unevaluatedItems","unevaluatedProperties","if","then","else","dependentSchemas","dependentRequired","nullable","readOnly"]);function By(e,r){let i=e.$schema;return i==="https://json-schema.org/draft/2020-12/schema"?"draft-2020-12":i==="http://json-schema.org/draft-07/schema#"?"draft-7":i==="http://json-schema.org/draft-04/schema#"?"draft-4":r??"draft-2020-12"}function Lp(e,r){return e.map((i,o)=>o<r?i:i.optional())}function Ky(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function Xy(e,r){if(!e.startsWith("#"))throw new Error("External $ref is not supported, only local refs (#/...) are allowed");let i=e.slice(1).split("/").filter(Boolean);if(i.length===0)return r.rootSchema;let o=r.version==="draft-2020-12"?"$defs":"definitions";if(i[0]===o){let t=i[1]===void 0?void 0:Ky(i[1]);if(!t||!r.defs[t])throw new Error(`Reference not found: ${e}`);return r.defs[t]}throw new Error(`Reference not found: ${e}`)}function Gy(e,r){return x.transform(o=>o).check(o=>{let t=o.value;if(typeof t!="object"||t===null||Array.isArray(t))return;let n=Object.getOwnPropertyNames(t);if(r.minProperties!==void 0&&n.length<r.minProperties&&o.issues.push({origin:"object",code:"too_small",minimum:r.minProperties,inclusive:!0,message:`Too small: expected object to have >=${r.minProperties} properties`,input:t,inst:e,continue:!0}),r.maxProperties!==void 0&&n.length>r.maxProperties&&o.issues.push({origin:"object",code:"too_big",maximum:r.maxProperties,inclusive:!0,message:`Too big: expected object to have <=${r.maxProperties} properties`,input:t,inst:e,continue:!0}),r.keySchema)for(let a of n){let u=r.keySchema.safeParse(a);u.success||o.issues.push({code:"invalid_key",origin:"record",issues:u.error.issues,input:a,path:[a],continue:!0})}}).pipe(e)}function Nl(e,r){if(e===null)return"z";let i=typeof e;if(i!=="object"){if(i==="number"&&Number.isNaN(e))return null;let o=String(e);return`${i[0]}${o.length}:${o}`}if(r.has(e))return null;r.add(e);try{if(Array.isArray(e)){let n=[];for(let a of e){let u=Nl(a,r);if(u===null)return null;n.push(u)}return`a${n.length}:[${n.join(",")}]`}let o=Object.keys(e).sort(),t=[];for(let n of o){let a=Nl(e[n],r);if(a===null)return null;t.push(`${n.length}:${n}=${a}`)}return`o${t.length}:{${t.join(",")}}`}finally{r.delete(e)}}var Wy=new Set(["items","prefixItems","additionalItems","additionalProperties","contains","propertyNames","not","if","then","else","allOf","anyOf","oneOf","unevaluatedItems","unevaluatedProperties","contentSchema"]),qy=new Set(["properties","patternProperties","dependentSchemas","dependencies","$defs","definitions"]);function Fr(e){return typeof e!="object"||e===null?!1:Array.isArray(e)?e.some(Fr):typeof e.$ref=="string"?!0:Object.entries(e).some(([r,i])=>Wy.has(r)?Fr(i):!qy.has(r)||typeof i!="object"||i===null?!1:Object.values(i).some(Fr))}function Vp(e){return e===1?"element":"elements"}function Hy(e,r){return x.transform(o=>o).check(o=>{let t=o.value;if(Array.isArray(t)){if(r.uniqueItems===!0){let n=new Map;for(let a=0;a<t.length;a++){let u=Nl(t[a],new Set);if(u===null)continue;let c=n.get(u);if(c===void 0){n.set(u,a);continue}o.issues.push({code:"custom",message:`Array items must be unique: element at index ${a} duplicates the one at index ${c}`,input:t,path:[a],continue:!0})}}if(r.containsSchema){let n=r.minContains??1,a=r.maxContains!==void 0?r.maxContains+1:Number.POSITIVE_INFINITY,u=0;for(let c of t)if(r.containsSchema.safeParse(c).success&&++u>=a)break;u<n&&o.issues.push({code:"custom",message:`Array must contain at least ${n} matching ${Vp(n)}; found ${u}`,input:t,continue:!0}),r.maxContains!==void 0&&u>r.maxContains&&o.issues.push({code:"custom",message:`Array must contain at most ${r.maxContains} matching ${Vp(r.maxContains)}`,input:t,continue:!0})}}}).pipe(e)}function Rp(e,r){if(e!==!1)return e===void 0||e===!0?x.any():te(e,r)}var Yy=/^(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/;function Mp(e,r){if(e.not!==void 0){if(typeof e.not=="object"&&Object.keys(e.not).length===0)return x.never();throw new Error("not is not supported in Zod (except { not: {} } for never)")}if(e.unevaluatedItems!==void 0)throw new Error("unevaluatedItems is not supported");if(e.unevaluatedProperties!==void 0)throw new Error("unevaluatedProperties is not supported");if(e.if!==void 0||e.then!==void 0||e.else!==void 0)throw new Error("Conditional schemas (if/then/else) are not supported");if(e.dependentSchemas!==void 0||e.dependentRequired!==void 0)throw new Error("dependentSchemas and dependentRequired are not supported");if(e.$ref){let t=e.$ref;if(r.refs.has(t))return r.refs.get(t);if(r.processing.has(t))return x.lazy(()=>{if(!r.refs.has(t))throw new Error(`Circular reference not resolved: ${t}`);return r.refs.get(t)});r.processing.add(t);let n=Xy(t,r),a=te(n,r);return r.refs.set(t,a),r.processing.delete(t),a}if(e.enum!==void 0){let t=e.enum;if(r.version==="openapi-3.0"&&e.nullable===!0&&t.length===1&&t[0]===null)return x.null();if(t.length===0)return x.never();if(t.length===1)return x.literal(t[0]);if(t.every(a=>typeof a=="string"))return x.enum(t);let n=t.map(a=>x.literal(a));return n.length<2?n[0]:x.union([n[0],n[1],...n.slice(2)])}if(e.const!==void 0)return x.literal(e.const);let i=e.type;if(Array.isArray(i)){let t=i.map(n=>{let a={...e,type:n};return Mp(a,r)});return t.length===0?x.never():t.length===1?t[0]:x.union(t)}if(!i)return x.any();let o;switch(i){case"string":{let t=x.string();if(e.format){let n=e.format;n==="email"?t=t.check(x.email()):n==="uri"||n==="uri-reference"?t=t.check(x.url()):n==="uuid"||n==="guid"?t=t.check(x.uuid()):n==="date-time"?t=t.check(x.iso.datetime({offset:!0})):n==="date"?t=t.check(x.iso.date()):n==="time"?t=t.check(x.regex(Yy)):n==="duration"?t=t.check(x.iso.duration()):n==="hostname"?t=t.check(x.hostname()):n==="ipv4"?t=t.check(x.ipv4()):n==="ipv6"?t=t.check(x.ipv6()):n==="mac"?t=t.check(x.mac()):n==="cidr"?t=t.check(x.cidrv4()):n==="cidr-v6"?t=t.check(x.cidrv6()):n==="base64"?t=t.check(x.base64()):n==="base64url"?t=t.check(x.base64url()):n==="e164"?t=t.check(x.e164()):n==="credit_card"?t=t.check(x.creditCard()):n==="iban"?t=t.check(x.iban()):n==="jwt"?t=t.check(x.jwt()):n==="emoji"?t=t.check(x.emoji()):n==="nanoid"?t=t.check(x.nanoid()):n==="cuid"?t=t.check(x.cuid()):n==="cuid2"?t=t.check(x.cuid2()):n==="ulid"?t=t.check(x.ulid()):n==="xid"?t=t.check(x.xid()):n==="ksuid"&&(t=t.check(x.ksuid()))}typeof e.minLength=="number"&&(t=t.min(e.minLength)),typeof e.maxLength=="number"&&(t=t.max(e.maxLength)),e.pattern&&(t=t.regex(new RegExp(e.pattern))),o=t;break}case"number":case"integer":{let t=i==="integer"?x.number().int():x.number();typeof e.minimum=="number"&&e.exclusiveMinimum!==!0&&(t=t.min(e.minimum)),typeof e.maximum=="number"&&e.exclusiveMaximum!==!0&&(t=t.max(e.maximum)),typeof e.exclusiveMinimum=="number"?t=t.gt(e.exclusiveMinimum):e.exclusiveMinimum===!0&&typeof e.minimum=="number"&&(t=t.gt(e.minimum)),typeof e.exclusiveMaximum=="number"?t=t.lt(e.exclusiveMaximum):e.exclusiveMaximum===!0&&typeof e.maximum=="number"&&(t=t.lt(e.maximum)),typeof e.multipleOf=="number"&&(t=t.multipleOf(e.multipleOf)),o=t;break}case"boolean":{o=x.boolean();break}case"null":{o=x.null();break}case"object":{let t={},n=e.properties||{},a=new Set(e.required||[]),u=typeof e.additionalProperties=="object"?te(e.additionalProperties,r):void 0;for(let[d,f]of Object.entries(n)){let m=te(f,r);X(t,d,a.has(d)?m:m.optional())}if(e.patternProperties){let d=e.patternProperties,f=Object.keys(d),m=[];for(let _ of f){let k=te(d[_],r),S=x.string().regex(new RegExp(_));m.push(x.looseRecord(S,k))}let v=[];if(Object.keys(t).length>0&&v.push(x.object(t).passthrough()),v.push(...m),v.length===0)o=x.object({}).passthrough();else if(v.length===1)o=v[0];else{let _=x.intersection(v[0],v[1]);for(let k=2;k<v.length;k++)_=x.intersection(_,v[k]);o=_}if(e.additionalProperties===!1){let _=Object.keys(t),k=f.map(I=>new RegExp(I)),S=o;o=o.check(I=>{if(!se(I.value))return;let P=[];for(let T of Object.keys(I.value))_.includes(T)||k.some(R=>R.test(T))||P.push(T);P.length&&I.issues.push({code:"unrecognized_keys",keys:P,input:I.value,inst:S})})}}else{let d=x.object(t);e.additionalProperties===!1?o=d.strict():u?o=d.catchall(u):o=d.passthrough()}let c=e.propertyNames!==void 0&&e.propertyNames!==!0,s=typeof e.minProperties=="number"?e.minProperties:void 0,l=typeof e.maxProperties=="number"?e.maxProperties:void 0;if(c||s!==void 0||l!==void 0){let d;if(c){let f=typeof e.propertyNames=="object"&&e.propertyNames.type===void 0?{type:"string",...e.propertyNames}:e.propertyNames;d=te(f,r)}o=Gy(o,{keySchema:d,minProperties:s,maxProperties:l})}break}case"array":{let t=e.prefixItems,n=e.items;if(t&&Array.isArray(t)){let a=typeof e.minItems=="number"?e.minItems:0,u=t.map(d=>te(d,r)),c=Lp(u,a),s=Array.isArray(n)?void 0:Rp(n,r),l=x.tuple(c);o=s?l.rest(s):l,typeof e.minItems=="number"&&(o=o.check(x.minLength(e.minItems))),typeof e.maxItems=="number"&&(o=o.check(x.maxLength(e.maxItems)))}else if(Array.isArray(n)){let a=typeof e.minItems=="number"?e.minItems:0,u=n.map(d=>te(d,r)),c=Lp(u,a),s=Rp(e.additionalItems,r),l=x.tuple(c);o=s?l.rest(s):l,typeof e.minItems=="number"&&(o=o.check(x.minLength(e.minItems))),typeof e.maxItems=="number"&&(o=o.check(x.maxLength(e.maxItems)))}else if(n!==void 0){let a=te(n,r),u=x.array(a);typeof e.minItems=="number"&&(u=u.min(e.minItems)),typeof e.maxItems=="number"&&(u=u.max(e.maxItems)),o=u}else o=x.array(x.any());(e.uniqueItems===!0||e.contains!==void 0)&&(o=Hy(o,{uniqueItems:e.uniqueItems===!0,containsSchema:e.contains!==void 0?te(e.contains,r):void 0,minContains:typeof e.minContains=="number"?e.minContains:void 0,maxContains:typeof e.maxContains=="number"?e.maxContains:void 0}));break}default:throw new Error(`Unsupported type: ${i}`)}return o}function te(e,r){if(typeof e=="boolean")return e?x.any():x.never();let i=Mp(e,r),o=e.type||e.enum!==void 0||e.const!==void 0;if(e.anyOf&&Array.isArray(e.anyOf)){let u=e.anyOf.map(s=>te(s,r)),c=x.union(u);i=o?x.intersection(i,c):c}if(e.oneOf&&Array.isArray(e.oneOf)){let u=e.oneOf.map(s=>te(s,r)),c=x.xor(u);i=o?x.intersection(i,c):c}if(e.allOf&&Array.isArray(e.allOf))if(e.allOf.length===0)i=o?i:x.any();else{let u=o?i:te(e.allOf[0],r),c=o?0:1;for(let s=c;s<e.allOf.length;s++)u=x.intersection(u,te(e.allOf[s],r));i=u}e.nullable===!0&&r.version==="openapi-3.0"&&(i=x.nullable(i)),e.readOnly===!0&&(i=x.readonly(i)),e.default!==void 0&&(i=i.default(e.default));let t={},n=["$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor"];for(let u of n)u in e&&(t[u]=e[u]);let a=["contentEncoding","contentMediaType","contentSchema"];for(let u of a)u in e&&(t[u]=e[u]);if(e.type==="object"&&e.$ref===void 0){e.propertyNames!==void 0&&!Fr(e.propertyNames)&&(t.propertyNames=e.propertyNames);for(let u of["minProperties","maxProperties"])e[u]!==void 0&&(t[u]=e[u])}if(e.type==="array"&&e.$ref===void 0){e.contains!==void 0&&!Fr(e.contains)&&(t.contains=e.contains);for(let u of["uniqueItems","minContains","maxContains"])e[u]!==void 0&&(t[u]=e[u])}for(let u of Object.keys(e))Jy.has(u)||X(t,u,e[u]);return Object.keys(t).length>0&&r.registry.add(i,t),e.description&&(i=i.describe(e.description)),i}function Fp(e,r){if(typeof e=="boolean")return e?x.any():x.never();let i;try{i=JSON.parse(JSON.stringify(e))}catch{throw new Error("fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas")}let o=By(i,r?.defaultTarget),t=i.$defs||i.definitions||{},n={version:o,defs:t,refs:new Map,processing:new Set,rootSchema:i,registry:r?.registry??G};return te(i,n)}var Jp=Symbol("z.visit/resolving");function Jr(e,r){let i=typeof r=="function"?r:(a,u)=>{let c=r[a._zod.def.type];return c?c(a,u):a},o=new Map;function t(a){let u=o.get(a);if(u===Jp)return new hr({type:"lazy",getter:()=>o.get(a)});if(u!==void 0)return u;o.set(a,Jp);let c=n(a),s=i(c,c!==a);return o.set(a,s),s}function n(a){let u=a._zod.def,c=u.type;switch(c){case"object":{let s=u.shape,l=Object.keys(s),d=!1,f={};for(let v of l){let _=t(s[v]);_!==s[v]&&(d=!0),f[v]=_}let m=u.catchall;return u.catchall&&(m=t(u.catchall),m!==u.catchall&&(d=!0)),d?C(a,{...u,shape:f,catchall:m}):a}case"array":{let s=t(u.element);return s===u.element?a:C(a,{...u,element:s})}case"tuple":{let s=u.items,l=!1,d=[];for(let m of s){let v=t(m);v!==m&&(l=!0),d.push(v)}let f=u.rest;return u.rest&&(f=t(u.rest),f!==u.rest&&(l=!0)),l?C(a,{...u,items:d,rest:f}):a}case"record":case"map":{let s=t(u.keyType),l=t(u.valueType);return s===u.keyType&&l===u.valueType?a:C(a,{...u,keyType:s,valueType:l})}case"set":{let s=t(u.valueType);return s===u.valueType?a:C(a,{...u,valueType:s})}case"union":{let s=u.options,l=!1,d=[];for(let f of s){let m=t(f);m!==f&&(l=!0),d.push(m)}return l?C(a,{...u,options:d}):a}case"intersection":{let s=t(u.left),l=t(u.right);return s===u.left&&l===u.right?a:C(a,{...u,left:s,right:l})}case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":{let s=t(u.innerType);return s===u.innerType?a:C(a,{...u,innerType:s})}case"pipe":{let s=t(u.in),l=t(u.out);return s===u.in&&l===u.out?a:C(a,{...u,in:s,out:l})}case"function":{let s=t(u.input),l=t(u.output);return s===u.input&&l===u.output?a:C(a,{...u,input:s,output:l})}case"lazy":{let s=u.getter,{_cachedInner:l,...d}=u;return C(a,{...d,getter:()=>t(s())})}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":return a;default:return a}}return t(e)}function Bp(e){return Jr(e,{object:r=>r.partial(),union:r=>{let i=r._zod.def;return i.discriminator===void 0?r:Mt(i.options)}})}function Qy(e,r){if(!r?.length)return e;let i=e._zod.def;return C(e,fe(i,{checks:[...i.checks??[],...r]}),{parent:!0})}function Kp(e){return Qy(e.out,e.checks)}function e_(e){return e.in._zod.traits.has("$ZodTransform")?Kp(e):e.in}function Xp(e){return Jr(e,{pipe:r=>e_(r._zod.def),default:(r,i)=>i?Qe(r._zod.def.innerType):r,catch:(r,i)=>i?r._zod.def.innerType:r})}function Gp(e){return Jr(e,{pipe:r=>Kp(r._zod.def),prefault:(r,i)=>i?r._zod.def.innerType:r})}var jl={};ge(jl,{bigint:()=>i_,boolean:()=>n_,date:()=>o_,number:()=>r_,string:()=>t_});function t_(e){return ec(Et,e)}function r_(e){return ac(Lt,e)}function n_(e){return mc(Vt,e)}function i_(e){return gc(Rt,e)}function o_(e){return Sc(Ar,e)}var Ul=O.object({valueState:O.string().min(1),value:O.number().optional(),UoM:O.string().optional(),valueToShow:O.string().optional(),UoMToShow:O.string().optional(),range:O.tuple([O.number(),O.number()]).optional()}).passthrough(),Wp=O.object({id:O.string().min(1),name:O.string(),model:O.string(),typeCode:O.string(),serialNo:O.string(),sensorState:O.string().min(1),sensorPod:O.object({typeCode:O.string(),model:O.string()}).passthrough().optional(),measuringModeCode:O.number().int().optional(),statusInfo:O.number().int().optional(),mainValue:Ul.optional(),subValue:Ul.optional()}).passthrough(),qp=O.object({id:O.number().int(),timestamp:O.number().int().nonnegative(),code:O.string(),type:O.string(),typeCode:O.string(),serialNo:O.string(),dw1:O.number(),dw2:O.number()}).passthrough(),Al=O.object({webServer:O.string(),payloadType:O.literal("livedata"),payloadVersion:O.string(),controllerTime:O.number().int().nonnegative(),controllerType:O.string(),controllerSerial:O.string().min(1),controllerName:O.string(),controllerSW:O.string(),sensors:O.array(Wp),notifications:O.array(qp)}).passthrough();function a_(e){return e==="INACTIVE"?0:e==="MEASURING"?1:e==="MAINTENANCE"?2:e==="ERROR"?3:-1}function u_(e){return e==="VALID"?0:e==="OFL"?1:e==="INVALID"?2:e==="MISSING"?3:-1}function Tl(...e){return e.map(r=>encodeURIComponent(String(r))).join(":")}function c_(e,r,i,o){return{...e,sensorId:r.id,id:r.id,name:r.name,model:r.model,typeCode:r.typeCode,serialNo:r.serialNo,...r.sensorPod===void 0?{}:{sensorPodTypeCode:r.sensorPod.typeCode,sensorPodModel:r.sensorPod.model},measuringModeCode:r.measuringModeCode,statusInfo:r.statusInfo,valueKind:i,valueState:o.valueState,valueStateCode:u_(o.valueState),value:o.value,...o.UoM===void 0?{}:{unit:o.UoM},...o.valueToShow===void 0?{}:{valueToShow:o.valueToShow},...o.UoMToShow===void 0?{}:{unitToShow:o.UoMToShow},...o.range===void 0?{}:{range:o.range}}}function s_(e,r){let{value:i,valueToShow:o,unitToShow:t,valueState:n,valueStateCode:a,...u}=e;return{...u,valueIdentity:Tl(e.controllerSerial,e.sensorId,e.valueKind),controllerTimestamp:r}}function l_(e){try{let r=new URL(e);return r.username="",r.password="",r.search="",r.hash="",r.toString()}catch{return/^(?:[a-z][a-z\d+.-]*:\/\/|\/\/)/i.test(e)||/[?#]/.test(e)||/(?:^|[/?#])[^\s:@]+:[^\s@]+@/.test(e)||/(?:token|secret|password|authorization)\s*[:=]/i.test(e)?"[redacted]":e}}function ro(e,r){let i={webServer:l_(r.webServer),payloadType:r.payloadType,payloadVersion:r.payloadVersion,controllerType:r.controllerType,controllerSerial:r.controllerSerial,controllerName:r.controllerName,controllerSW:r.controllerSW},o=new Date(r.controllerTime*1e3),t=r.sensors.map(a=>({...i,sensorId:a.id,sensorIdentity:Tl(r.controllerSerial,a.id),id:a.id,name:a.name,model:a.model,typeCode:a.typeCode,serialNo:a.serialNo,...a.sensorPod===void 0?{}:{sensorPodTypeCode:a.sensorPod.typeCode,sensorPodModel:a.sensorPod.model},...a.measuringModeCode===void 0?{}:{measuringModeCode:a.measuringModeCode},...a.statusInfo===void 0?{}:{statusInfo:a.statusInfo}})),n=r.sensors.flatMap(a=>["main","sub"].flatMap(u=>{let c=u==="main"?a.mainValue:a.subValue;return c===void 0?[]:[c_(i,a,u,c)]}));return{timestamp:o,controllers:[{...i,lastSeenAt:o}],sensors:t,values:n.map(a=>s_(a,r.controllerTime)),sensorStatuses:r.sensors.map(a=>({...i,sensorId:a.id,id:a.id,name:a.name,model:a.model,typeCode:a.typeCode,serialNo:a.serialNo,sensorState:a.sensorState,state:a_(a.sensorState),...a.sensorPod===void 0?{}:{sensorPod:{typeCode:a.sensorPod.typeCode,model:a.sensorPod.model}},...a.measuringModeCode===void 0?{}:{measuringModeCode:a.measuringModeCode},...a.statusInfo===void 0?{}:{statusInfo:a.statusInfo}})),measurements:n,notifications:r.notifications.map(a=>({...i,id:a.id,timestamp:new Date(a.timestamp*1e3),code:a.code,type:a.type,typeCode:a.typeCode,serialNo:a.serialNo,dw1:a.dw1,dw2:a.dw2,notificationIdentity:Tl(r.controllerSerial,a.id)}))}}var Cl="controllers",Zl="sensors",no="measurement_points",El="notifications",Ll="sensor_status",Vl="connector_status";var Hp="/api/v1/livedata",Br=class{#t;#e;#r=!1;constructor(r,i){this.#t=r,this.#e=i}get name(){return`xylem-controller-${this.#e.id}`}async onRun(){if(this.#r){this.#t.logger.error({controllerId:this.#e.id,error:{message:"Xylem poll already running"}});return}this.#r=!0;let r=Date.now(),i;try{let o=Wl(this.#t.httpClient({baseUrl:this.#e.baseUrl,timeout:this.#e.timeoutMs}),this.#e.username,this.#e.password,this.#t.logger);this.#t.logger.verbose("[Xylem Digest] Starting poll request",{controllerId:this.#e.id,method:"GET",url:new URL(this.#c()).pathname,timeoutMs:this.#e.timeoutMs});let t=await o.get(this.#c());i=t.status,await this.#s(t.data,r)}catch(o){i===void 0&&typeof o=="object"&&o!==null&&"status"in o&&typeof o.status=="number"&&(i=o.status);let t=`Unable to poll Xylem connector ${this.#e.id}, http status: ${i??"unknown"}`;await this.#i(t,r)}finally{this.#r=!1}}async#s(r,i){let o;try{o=Al.parse(r)}catch(t){await this.#i(t instanceof Error?t.message:String(t),i);return}try{let t=ro(this.#e,o);await this.#n(t.controllers.map(n=>({...n,controllerIdentity:n.controllerSerial})),Cl,"controllerIdentity"),await this.#n(t.sensors,Zl,"sensorIdentity"),await this.#n(t.values,no,"valueIdentity"),await this.#n(t.notifications,El,"notificationIdentity"),t.sensorStatuses.forEach(n=>{n.state===-1&&this.#t.logger.warn({controllerId:this.#e.id,sensorId:n.sensorId,rawState:n.sensorState})}),await this.#u(t.measurements,no,["value","valueState","valueStateCode"]),await this.#u(t.sensorStatuses,Ll,["state_code","sensorState"],["state","sensorState"]),await this.#a({controllerSerial:o.controllerSerial,controllerTime:o.controllerTime,status:"success",state:1,duration:Date.now()-i})}catch{await this.#i("Unable to ingest Xylem payload",i)}}async#i(r,i){this.#t.logger.error({controllerId:this.#e.id,error:{message:r}});try{await this.#a({status:"failure",state:0,duration:Date.now()-i,error:r})}catch{this.#t.logger.error({controllerId:this.#e.id,error:{message:r}})}}async#a(r,i){let{state:o,duration:t,controllerTime:n,...a}=r;this.#o(await this.#t.sender.metrics([{state_code:o,duration:t,...n===void 0?{}:{controllerTime:n}}],{collection:Vl,...a},i===void 0?void 0:{timestamp:i}))}async#u(r,i,o,t=o,n=t,a){(await Promise.all(r.map(async c=>{let s=Object.fromEntries(o.map((d,f)=>[d,c[t[f]]])),l=Object.fromEntries(Object.entries(c).filter(([d])=>!n.includes(d)));return this.#t.sender.metrics([s],{collection:i,...l},a===void 0?void 0:{timestamp:a})}))).forEach(c=>this.#o(c))}async#n(r,i,o,t){this.#o(await this.#t.sender.documents(r,{collection:i,keyField:o},t===void 0?void 0:{timestamp:t}))}#o(r){if(r===!1||typeof r=="object"&&Object.values(r).some(i=>!i))throw new Error("Xylem metric send failed")}#c(){let r=this.#e.endpoint??Hp;return new URL(r,this.#e.baseUrl).toString()}};var Rl=class extends Xr{init=async()=>{await Promise.all(this.connectorSDK.config.controllers.map(r=>this.connectorSDK.processing.registerInterval(r.intervalSeconds,new Br(this.connectorSDK,r),{immediate:!0})))}};0&&(module.exports={ConnectorRunnerXylem,DEFAULT_XYLEM_ENDPOINT,XYLEM_CONNECTOR_STATUS_COLLECTION,XYLEM_CONTROLLERS_COLLECTION,XYLEM_MEASUREMENT_POINTS_COLLECTION,XYLEM_NOTIFICATIONS_COLLECTION,XYLEM_SENSORS_COLLECTION,XYLEM_SENSOR_STATUS_COLLECTION,XylemControllerPoller,XylemLiveDataSchema,XylemNotificationSchema,XylemSensorSchema,XylemValueSchema,normalizeXylemLiveData});
62
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let a of e.seen.entries()){let u=a[1];if(r===a[0]){n(a);continue}if(e.external){let s=e.external.registry.get(a[0])?.id;if(r!==a[0]&&s){n(a);continue}}if(e.metadataRegistry.get(a[0])?.id){n(a);continue}if(u.cycle){n(a);continue}u.count>1&&e.reused==="ref"&&n(a)}e.external&&(e.sharedDefsExtractedFor=e.external)}function am(e){let r=e.anyOf;if(!Array.isArray(r)||r.length===0||e.type!==void 0)return;let i=[];for(let o of r){if(!o||typeof o!="object")return;am(o);let t=Object.keys(o);if(t.length!==1||t[0]!=="type")return;let n=o.type;for(let a of Array.isArray(n)?n:[n]){if(typeof a!="string")return;i.includes(a)||i.push(a)}}delete e.anyOf,e.type=i.length===1?i[0]:i}var um=new Set(["type","properties","required","additionalProperties"]),im=["oneOf","anyOf"];function om(e){let r=e.additionalProperties;return r===void 0||r===!1||typeof r!="object"||r===null?null:Object.keys(r).length?r:null}function Cc(e){let r=[];for(let n of e){if(typeof n!="object"||n.type!=="object")return null;for(let a in n)if(!um.has(a))return null;r.push(n)}let i={},o=new Set;for(let n of r){for(let a in n.properties){if(Object.prototype.hasOwnProperty.call(i,a))continue;let u=[];for(let s of r){let l=s.properties?.[a]??om(s);l!=null&&(u.some(d=>JSON.stringify(d)===JSON.stringify(l))||u.push(l))}let c=u.length===1?u[0]:Cc(u)??{allOf:u};X(i,a,c)}for(let a of n.required??[])o.add(a)}let t={type:"object",properties:i};if(o.size&&(t.required=[...o]),r.every(n=>n.additionalProperties===!1))t.additionalProperties=!1;else{let n=[];for(let a of r){let u=om(a);u&&!n.some(c=>JSON.stringify(c)===JSON.stringify(u))&&n.push(u)}n.length===1?t.additionalProperties=n[0]:n.length>1&&(t.additionalProperties={allOf:n})}return t}function Dy(e){let r=e.allOf;if(!Array.isArray(r)||r.length<2)return;for(let t of um)if(t in e)return;let i=r.filter(t=>im.some(n=>Array.isArray(t[n]))),o=null;if(!i.length)o=Cc(r);else{let t=i[0],n=im.find(c=>Array.isArray(t[c]));if(Object.keys(t).length!==1)return;let a=r.filter(c=>c!==t),u=t[n].map(c=>Cc([...a,c]));if(u.some(c=>!c))return;o={[n]:u}}o&&(delete e.allOf,Pr(e,o))}function Ue(e,r){let i=e.seen.get(r);if(!i)throw new Error("Unprocessed schema. This is a bug in Zod.");let o=u=>{let c=e.seen.get(u);if(c.ref===null)return;let s=c.def??c.schema,l={...s},d=c.ref;if(c.ref=null,d){o(d);let m=e.seen.get(d),v=m.schema;if(v.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(s.allOf=s.allOf??[],s.allOf.push(v)):Pr(s,v),Pr(s,l),u._zod.parent===d)for(let k in s)k==="$ref"||k==="allOf"||k in l||delete s[k];if(v.$ref&&m.def)for(let k in s)k==="$ref"||k==="allOf"||k in m.def&&JSON.stringify(s[k])===JSON.stringify(m.def[k])&&delete s[k]}let f=u._zod.parent;if(f&&f!==d){o(f);let m=e.seen.get(f);if(m?.schema.$ref&&(s.$ref=m.schema.$ref,m.def))for(let v in s)v==="$ref"||v==="allOf"||v in m.def&&JSON.stringify(s[v])===JSON.stringify(m.def[v])&&delete s[v]}e.override({zodSchema:u,jsonSchema:s,path:c.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let u of[...e.seen.entries()].reverse())o(u[0]);if(e.target!=="openapi-3.0")for(let u of e.seen.entries())am(u[1].def??u[1].schema);for(let u of e.deferred)u();if(e.intersections.length){let u=new Map;for(let c of e.seen.values())for(let s of[c.schema,c.def]){let l=s?.allOf;if(!Array.isArray(l))continue;let d=u.get(l);d?d.push(s):u.set(l,[s])}for(let c of e.intersections)for(let s of u.get(c)??[])Dy(s)}}let t={};if(e.target==="draft-2020-12"?t.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?t.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?t.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){let u=e.external.registry.get(r)?.id;if(!u)throw new Error("Schema is missing an `id` property");t.$id=e.external.uri(u)}Pr(t,i.defId?i.schema:i.def??i.schema);let n=e.metadataRegistry.get(r)?.id;n!==void 0&&t.id===n&&delete t.id;let a=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let u of e.seen.entries()){let c=u[1];c.def&&c.defId&&(c.def.id===c.defId&&delete c.def.id,X(a,c.defId,c.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(a).length>0&&(e.target==="draft-2020-12"?t.$defs=a:t.definitions=a);try{let u=JSON.parse(JSON.stringify(t));return Object.defineProperty(u,"~standard",{value:{...r["~standard"],jsonSchema:{input:Ut(r,"input",e.processors),output:Ut(r,"output",e.processors)}},enumerable:!1,writable:!1}),u}catch{throw new Error("Error converting schema to JSON.")}}function ee(e,r){let i=r??{seen:new Set};if(i.seen.has(e))return!1;i.seen.add(e);let o=e._zod.def;if(o.type==="transform")return!0;if(o.type==="array")return ee(o.element,i);if(o.type==="set")return ee(o.valueType,i);if(o.type==="lazy")return ee(o.getter(),i);if(o.type==="promise"||o.type==="optional"||o.type==="nonoptional"||o.type==="nullable"||o.type==="readonly"||o.type==="default"||o.type==="prefault"||o.type==="catch")return ee(o.innerType,i);if(o.type==="intersection")return ee(o.left,i)||ee(o.right,i);if(o.type==="record"||o.type==="map")return ee(o.keyType,i)||ee(o.valueType,i);if(o.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:ee(o.in,i)||ee(o.out,i);if(o.type==="object"){for(let t in o.shape)if(ee(o.shape[t],i))return!0;return!1}if(o.type==="union"){for(let t of o.options)if(ee(t,i))return!0;return!1}if(o.type==="tuple"){for(let t of o.items)if(ee(t,i))return!0;return!!(o.rest&&ee(o.rest,i))}return!1}var Zc=(e,r={})=>i=>{let o=Ne({...i,processors:r});return E(e,o),je(o,e),Ue(o,e)},Ut=(e,r,i={})=>o=>{let{libraryOptions:t,target:n}=o??{},a=Ne({...t??{},target:n,io:r,processors:i});return E(e,a),je(a,e),Ue(a,e)};var At=(e,r,i)=>{(e[r]===void 0||i>e[r])&&(e[r]=i)},Tt=(e,r,i)=>{(e[r]===void 0||i<e[r])&&(e[r]=i)},cm=(e,r)=>{At(e,"minimum",r),Tt(e,"maximum",r)},fm=(e,r)=>{e.multipleOf??(e.multipleOf=[]),e.multipleOf.includes(r)||e.multipleOf.push(r)},mm=(e,r)=>{e.patterns??(e.patterns=new Set),e.patterns.add(r)},pm=(e,r)=>{e.mime=e.mime?e.mime.filter(i=>r.includes(i)):[...r]},gm=(e,r)=>{e.format=r,r.includes("int")&&(e.isInt=!0)},sm=(e,r)=>At(e,"minimum",r.minimum),lm=(e,r)=>Tt(e,"maximum",r.maximum),dm=e=>(r,i)=>{gm(r,i.format);let[o,t]=e[i.format];At(r,"minimum",o),Tt(r,"maximum",t)},Py={greater_than:(e,r)=>At(e,r.inclusive?"minimum":"exclusiveMinimum",r.value),less_than:(e,r)=>Tt(e,r.inclusive?"maximum":"exclusiveMaximum",r.value),multiple_of:(e,r)=>fm(e,r.value),number_format:dm(qt),bigint_format:dm(Ht),min_length:sm,max_length:lm,length_equals:(e,r)=>cm(e,r.length),min_size:sm,max_size:lm,size_equals:(e,r)=>cm(e,r.size),string_format:(e,r)=>{gm(e,r.format),r.pattern&&mm(e,r.pattern),(r.format==="base64"||r.format==="base64url")&&(e.contentEncoding=r.format),(r.local||r.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,r)=>pm(e,r.mime)};function B(e){let r={},i=e._zod.def,o=e._zod.traits.has("$ZodCheck")?[e,...i.checks??[]]:i.checks??[];for(let n of o)Py[n._zod.def.check]?.(r,n._zod.def);let t=e._zod.bag;t.minimum!==void 0&&At(r,"minimum",t.minimum),t.exclusiveMinimum!==void 0&&At(r,"exclusiveMinimum",t.exclusiveMinimum),t.maximum!==void 0&&Tt(r,"maximum",t.maximum),t.exclusiveMaximum!==void 0&&Tt(r,"exclusiveMaximum",t.exclusiveMaximum),t.multipleOf!==void 0&&fm(r,t.multipleOf),t.format!==void 0&&(r.format??(r.format=t.format),t.format.includes("int")&&(r.isInt=!0)),t.mime&&pm(r,t.mime);for(let n of t.patterns??[])mm(r,n);return r}var Oy={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Ny=new Map([[zn,Fo],[pr,Jo]]),vm=e=>Ny.get(e)??e,Vc=(e,r,i,o)=>{let t=i;t.type="string";let{minimum:n,maximum:a,format:u,patterns:c,contentEncoding:s,laxFormat:l}=B(e);if(typeof n=="number"&&(t.minLength=n),typeof a=="number"&&(t.maxLength=a),u&&(t.format=Oy[u]??u,t.format===""&&delete t.format,(u==="time"||l)&&delete t.format),s&&(t.contentEncoding=s),c&&c.size>0){let d=[...c].map(vm);d.length===1?t.pattern=d[0].source:d.length>1&&(t.allOf=[...d.map(f=>({...r.target==="draft-07"||r.target==="draft-04"||r.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))])}},Rc=(e,r,i,o)=>{let t=i,{minimum:n,maximum:a,multipleOf:u,exclusiveMaximum:c,exclusiveMinimum:s,isInt:l}=B(e);t.type=l?"integer":"number";let d=typeof s=="number"&&s>=(n??Number.NEGATIVE_INFINITY),f=typeof c=="number"&&c<=(a??Number.POSITIVE_INFINITY),m=r.target==="draft-04"||r.target==="openapi-3.0";if(d?m?(t.minimum=s,t.exclusiveMinimum=!0):t.exclusiveMinimum=s:typeof n=="number"&&(t.minimum=n),f?m?(t.maximum=c,t.exclusiveMaximum=!0):t.exclusiveMaximum=c:typeof a=="number"&&(t.maximum=a),u){let v=new Set;for(let S of u)Number.isFinite(S)&&S!==0?v.add(Math.abs(S)):J(e,r,t,o,`A multipleOf divisor of ${S} cannot be represented in JSON Schema`);let[_,...k]=v;_!==void 0&&(t.multipleOf=_),k.length&&(t.allOf=[...t.allOf??[],...k.map(S=>({multipleOf:S}))])}},Mc=(e,r,i,o)=>{i.type="boolean"},Fc=(e,r,i,o)=>{J(e,r,i,o,"BigInt cannot be represented in JSON Schema")},Jc=(e,r,i,o)=>{J(e,r,i,o,"Symbols cannot be represented in JSON Schema")},Bc=(e,r,i,o)=>{r.target==="openapi-3.0"?(i.type="string",i.nullable=!0,i.enum=[null]):i.type="null"},Kc=(e,r,i,o)=>{J(e,r,i,o,"Undefined cannot be represented in JSON Schema")},Xc=(e,r,i,o)=>{J(e,r,i,o,"Void cannot be represented in JSON Schema")},Gc=(e,r,i,o)=>{i.not={}},Wc=(e,r,i,o)=>{},qc=(e,r,i,o)=>{},Hc=(e,r,i,o)=>{J(e,r,i,o,"Date cannot be represented in JSON Schema")},Yc=(e,r,i,o)=>{let t=e._zod.def,n=ot(t.entries);if(n.length===0){i.not={};return}n.every(a=>typeof a=="number")&&(i.type="number"),n.every(a=>typeof a=="string")&&(i.type="string"),i.enum=n},Qc=(e,r,i,o)=>{let t=e._zod.def;if(t.values.length===0){i.not={};return}let n=[];for(let a of t.values)if(a===void 0){if(J(e,r,i,o,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof a=="bigint"){if(J(e,r,i,o,"BigInt literals cannot be represented in JSON Schema"))return;n.push(Number(a))}else n.push(a);if(n.length!==0)if(n.length===1){let a=n[0];i.type=a===null?"null":typeof a,r.target==="draft-04"||r.target==="openapi-3.0"?i.enum=[a]:i.const=a}else n.every(a=>typeof a=="number")&&(i.type="number"),n.every(a=>typeof a=="string")&&(i.type="string"),n.every(a=>typeof a=="boolean")&&(i.type="boolean"),n.every(a=>a===null)&&(i.type="null"),i.enum=n},es=(e,r,i,o)=>{J(e,r,i,o,"NaN cannot be represented in JSON Schema")},ts=(e,r,i,o)=>{let t=i,n=e._zod.pattern;if(!n)throw new Error("Pattern not found in template literal");t.type="string",t.pattern=n.source},rs=(e,r,i,o)=>{let t=i;t.type="string",t.format="binary",t.contentEncoding="binary";let{minimum:n,maximum:a,mime:u}=B(e);n!==void 0&&(t.minLength=n),a!==void 0&&(t.maxLength=a),u&&(u.length===0?t.not={}:u.length===1?t.contentMediaType=u[0]:t.anyOf=u.map(c=>({contentMediaType:c})))},ns=(e,r,i,o)=>{i.type="boolean"},is=(e,r,i,o)=>{J(e,r,i,o,"Custom types cannot be represented in JSON Schema")},os=(e,r,i,o)=>{J(e,r,i,o,"Function types cannot be represented in JSON Schema")},as=(e,r,i,o)=>{J(e,r,i,o,"Transforms cannot be represented in JSON Schema")},us=(e,r,i,o)=>{J(e,r,i,o,"Map cannot be represented in JSON Schema")},cs=(e,r,i,o)=>{J(e,r,i,o,"Set cannot be represented in JSON Schema")},ss=(e,r,i,o)=>{let t=i,n=e._zod.def,{minimum:a,maximum:u}=B(e);typeof a=="number"&&(t.minItems=a),typeof u=="number"&&(t.maxItems=u),t.type="array",t.items=E(n.element,r,{...o,path:[...o.path,"items"]})};function Or(e){let r=e._zod.def;return r.type==="pipe"&&r.in._zod.traits.has("$ZodTransform")?Or(r.out):r.type==="catch"?Or(r.innerType):e._zod.optin}var ls=(e,r,i,o)=>{let t=i,n=e._zod.def,a=n.shape;if(Object.getOwnPropertySymbols(a).length&&J(e,r,t,o,"Symbol keys cannot be represented in JSON Schema"))return;t.type="object",t.properties={};for(let s in a)X(t.properties,s,E(a[s],r,{...o,path:[...o.path,"properties",s]}));let c=[];for(let s of Object.keys(a)){let l=n.shape[s];(r.io==="input"?Or(l)===void 0:l._zod.optout===void 0)&&c.push(s)}c.length>0&&(t.required=c),n.catchall?._zod.def.type==="never"?t.additionalProperties=!1:n.catchall?n.catchall&&(t.additionalProperties=E(n.catchall,r,{...o,path:[...o.path,"additionalProperties"]})):r.io==="output"&&(t.additionalProperties=!1)},Ii=(e,r,i,o)=>{let t=e._zod.def,n=t.inclusive===!1,a=t.options.map((u,c)=>E(u,r,{...o,path:[...o.path,n?"oneOf":"anyOf",c]}));n?i.oneOf=a:i.anyOf=a},ds=(e,r,i,o)=>{let t=e._zod.def,n=E(t.left,r,{...o,path:[...o.path,"allOf",0]}),a=E(t.right,r,{...o,path:[...o.path,"allOf",1]}),u=s=>"allOf"in s&&Object.keys(s).length===1,c=[...u(n)?n.allOf:[n],...u(a)?a.allOf:[a]];i.allOf=c,r.intersections.push(c)},fs=(e,r,i,o)=>{let t=i,n=e._zod.def;t.type="array";let a=r.target==="draft-2020-12"?"prefixItems":"items",u=r.target==="draft-2020-12"||r.target==="openapi-3.0"?"items":"additionalItems",c=n.items.map((_,k)=>E(_,r,{...o,path:[...o.path,a,k]})),s=n.rest?E(n.rest,r,{...o,path:[...o.path,u,...r.target==="openapi-3.0"?[n.items.length]:[]]}):null,l=n.items.length;for(;l>0;){let _=n.items[l-1];if(!(r.io==="input"?Or(_)!==void 0:_._zod.optout==="optional"))break;l--}let d=n.items.length,f=!n.rest;r.target==="draft-2020-12"?(t.prefixItems=c,f?t.items=!1:s&&(t.items=s),l>0&&(t.minItems=l),f&&(t.maxItems=d)):r.target==="openapi-3.0"?(t.items={anyOf:c},s&&t.items.anyOf.push(s),l>0&&(t.minItems=l),f&&(t.maxItems=d)):(t.items=c,f?t.additionalItems=!1:s&&(t.additionalItems=s),l>0&&(t.minItems=l),f&&(t.maxItems=d));let{minimum:m,maximum:v}=B(e);typeof m=="number"&&(t.minItems=m),typeof v=="number"&&(t.maxItems=v)};function Ec(e,r,i){if(r.$ref){if(i.has(r))return r;i.add(r);let v=e.get(r)?.def;if(!v)return r;let _=Ec(e,v,i);return _===v?r:_}for(let v of["anyOf","oneOf"]){let _=r[v];if(!Array.isArray(_))continue;let k=_.map(S=>Ec(e,S,i));k.some((S,I)=>S!==_[I])&&(r={...r,[v]:k})}let o=Array.isArray(r.type)?r.type:[r.type],t=!o.includes("string")&&o.some(v=>v==="number"||v==="integer"),n=r.enum??(r.const!==void 0?[r.const]:void 0);if(!t&&!n?.some(v=>typeof v=="number"))return r;let{minimum:a,maximum:u,exclusiveMinimum:c,exclusiveMaximum:s,multipleOf:l,format:d,id:f,...m}=r;return m.enum?m.enum=m.enum.map(v=>typeof v=="number"?String(v):v):typeof m.const=="number"&&(m.const=String(m.const)),t&&(m.type="string",n||(m.pattern=(o.includes("number")?ke:ur).source)),m}var Lc=new WeakMap;function jy(e){let r=new Map;for(let o of e.seen.values())o.def&&!r.has(o.schema)&&r.set(o.schema,o);let i=new Map;for(let o of Lc.get(e)??[]){let t=e.seen.get(o),n=(t?.def??t?.schema)?.propertyNames;if(!n||n===!0||i.has(n))continue;let a=Ec(r,n,new Set);a!==n&&i.set(n,a)}if(i.size)for(let o of e.seen.values())for(let t of[o.schema,o.def]){let n=t&&i.get(t.propertyNames);n&&(t.propertyNames=n)}}var ms=(e,r,i,o)=>{let t=i,n=e._zod.def;t.type="object";let a=n.keyType,u=B(a).patterns;if(n.mode==="loose"&&u&&u.size>0){let l=E(n.valueType,r,{...o,path:[...o.path,"patternProperties","*"]});t.patternProperties={};for(let d of u)X(t.patternProperties,vm(d).source,l)}else{if(r.target==="draft-07"||r.target==="draft-2020-12"){t.propertyNames=E(n.keyType,r,{...o,path:[...o.path,"propertyNames"]});let l=Lc.get(r);l||(l=[],Lc.set(r,l),r.deferred.push(()=>jy(r))),l.push(e)}t.additionalProperties=E(n.valueType,r,{...o,path:[...o.path,"additionalProperties"]})}let c=a._zod.values,s=r.io==="input"&&Or(n.valueType)!==void 0;if(c&&!n.partial&&!s){let l=[...c].filter(d=>typeof d=="string"||typeof d=="number");l.length>0&&(t.required=l.map(String))}},ps=(e,r,i,o)=>{let t=e._zod.def,n=E(t.innerType,r,o),a=r.seen.get(e);r.target==="openapi-3.0"?(a.ref=t.innerType,i.nullable=!0):i.anyOf=[n,{type:"null"}]},gs=(e,r,i,o)=>{let t=e._zod.def;E(t.innerType,r,o);let n=r.seen.get(e);n.ref=t.innerType},vs=Symbol();function $m(e,r,i,o,t){let n=!1,a=JSON.stringify(e,(u,c)=>typeof c!="bigint"?c:(n=!0,null));return n?(J(r,i,o,t,"BigInt defaults cannot be represented in JSON Schema"),vs):JSON.parse(a)}var $s=(e,r,i,o)=>{let t=e._zod.def;E(t.innerType,r,o);let n=r.seen.get(e);n.ref=t.innerType;let a=$m(t.defaultValue,e,r,i,o);a!==vs&&(i.default=a)},hs=(e,r,i,o)=>{let t=e._zod.def;E(t.innerType,r,o);let n=r.seen.get(e);if(n.ref=t.innerType,r.io!=="input")return;let a=$m(t.defaultValue,e,r,i,o);a!==vs&&(i._prefault=a)},ys=(e,r,i,o)=>{let t=e._zod.def;E(t.innerType,r,o);let n=r.seen.get(e);n.ref=t.innerType;let a;try{a=t.catchValue(void 0)}catch{J(e,r,i,o,"Dynamic catch values are not supported in JSON Schema");return}i.default=a},_s=(e,r,i,o)=>{let t=e._zod.def,n=t.in._zod.traits.has("$ZodTransform"),a=r.io==="input"?n?t.out:t.in:t.out;E(a,r,o);let u=r.seen.get(e);u.ref=a},bs=(e,r,i,o)=>{let t=e._zod.def;E(t.innerType,r,o);let n=r.seen.get(e);n.ref=t.innerType,i.readOnly=!0},ks=(e,r,i,o)=>{let t=e._zod.def;E(t.innerType,r,o);let n=r.seen.get(e);n.ref=t.innerType},wi=(e,r,i,o)=>{let t=e._zod.def;E(t.innerType,r,o);let n=r.seen.get(e);n.ref=t.innerType},xs=(e,r,i,o)=>{let t=e._zod.innerType;E(t,r,o);let n=r.seen.get(e);n.ref=t},xi={string:Vc,number:Rc,boolean:Mc,bigint:Fc,symbol:Jc,null:Bc,undefined:Kc,void:Xc,never:Gc,any:Wc,unknown:qc,date:Hc,enum:Yc,literal:Qc,nan:es,template_literal:ts,file:rs,success:ns,custom:is,function:os,transform:as,map:us,set:cs,array:ss,object:ls,union:Ii,intersection:ds,tuple:fs,record:ms,nullable:ps,nonoptional:gs,default:$s,prefault:hs,catch:ys,pipe:_s,readonly:bs,promise:ks,optional:wi,lazy:xs};function Si(e,r){if("_idmap"in e){let o=e,t=Ne({...r,processors:xi}),n={};for(let c of o._idmap.entries()){let[s,l]=c;E(l,t)}let a={},u={registry:o,uri:r?.uri,defs:n};t.external=u;for(let c of o._idmap.entries()){let[s,l]=c;je(t,l),X(a,s,Ue(t,l))}if(Object.keys(n).length>0){let c=t.target==="draft-2020-12"?"$defs":"definitions";a.__shared={[c]:n}}return{schemas:a}}let i=Ne({...r,processors:xi});return E(e,i),je(i,e),Ue(i,e)}var zi=class{get metadataRegistry(){return this.ctx.metadataRegistry}get target(){return this.ctx.target}get unrepresentable(){return this.ctx.unrepresentable}get override(){return this.ctx.override}get io(){return this.ctx.io}get counter(){return this.ctx.counter}set counter(r){this.ctx.counter=r}get seen(){return this.ctx.seen}constructor(r){let i=r?.target??"draft-2020-12";i==="draft-4"&&(i="draft-04"),i==="draft-7"&&(i="draft-07"),this.ctx=Ne({processors:xi,target:i,...r?.metadata&&{metadata:r.metadata},...r?.unrepresentable&&{unrepresentable:r.unrepresentable},...r?.override&&{override:r.override},...r?.io&&{io:r.io}})}process(r,i={path:[],schemaPath:[]}){return E(r,this.ctx,i)}emit(r,i){i&&(i.cycles&&(this.ctx.cycles=i.cycles),i.reused&&(this.ctx.reused=i.reused),i.external&&(this.ctx.external=i.external)),this.ctx.sharedDefsExtractedFor=void 0,this.ctx.sharedEmitDoneFor=void 0,je(this.ctx,r);let o=Ue(this.ctx,r),{"~standard":t,...n}=o;return n}};var hm={};var Ft={};ge(Ft,{ZodAny:()=>Bs,ZodArray:()=>Ws,ZodBase64:()=>Ki,ZodBase64URL:()=>Xi,ZodBigInt:()=>Rt,ZodBigIntFormat:()=>qi,ZodBoolean:()=>Vt,ZodCIDRv4:()=>Ji,ZodCIDRv6:()=>Bi,ZodCUID:()=>Zi,ZodCUID2:()=>Ei,ZodCatch:()=>vl,ZodCodec:()=>Vr,ZodCreditCard:()=>Zs,ZodCustom:()=>Rr,ZodCustomStringFormat:()=>tt,ZodDate:()=>Ar,ZodDefault:()=>ll,ZodDiscriminatedUnion:()=>Hs,ZodE164:()=>Gi,ZodEmail:()=>Ui,ZodEmoji:()=>Ti,ZodEnum:()=>Zt,ZodExactOptional:()=>eo,ZodFile:()=>al,ZodFunction:()=>Sl,ZodGUID:()=>Ai,ZodIBAN:()=>Es,ZodIPv4:()=>Mi,ZodIPv6:()=>Fi,ZodISODate:()=>Te,ZodISODateTime:()=>Ae,ZodISODuration:()=>Ze,ZodISOTime:()=>Ce,ZodInstanceOf:()=>Pl,ZodIntersection:()=>Ys,ZodJWT:()=>Wi,ZodKSUID:()=>Ri,ZodLazy:()=>xl,ZodLiteral:()=>ol,ZodMAC:()=>Cs,ZodMap:()=>nl,ZodNaN:()=>hl,ZodNanoID:()=>Ci,ZodNever:()=>Xs,ZodNonOptional:()=>to,ZodNull:()=>Fs,ZodNullable:()=>sl,ZodNumber:()=>Lt,ZodNumberFormat:()=>rt,ZodObject:()=>Cr,ZodOptional:()=>Er,ZodPipe:()=>Lr,ZodPrefault:()=>fl,ZodPreprocess:()=>yl,ZodPromise:()=>wl,ZodReadonly:()=>_l,ZodRecord:()=>Ct,ZodSet:()=>il,ZodString:()=>Et,ZodStringFormat:()=>L,ZodSuccess:()=>gl,ZodSymbol:()=>Rs,ZodTemplateLiteral:()=>kl,ZodTransform:()=>ul,ZodTuple:()=>el,ZodType:()=>N,ZodULID:()=>Li,ZodURL:()=>Ur,ZodUUID:()=>ye,ZodUndefined:()=>Ms,ZodUnion:()=>Zr,ZodUnknown:()=>Ks,ZodVoid:()=>Gs,ZodXID:()=>Vi,ZodXor:()=>qs,_ZodString:()=>ji,_default:()=>dl,_function:()=>Op,any:()=>up,array:()=>Tr,base64:()=>Rm,base64url:()=>Mm,bigint:()=>rp,boolean:()=>Vs,catch:()=>$l,check:()=>Np,cidrv4:()=>Lm,cidrv6:()=>Vm,codec:()=>Sp,creditCard:()=>Jm,cuid:()=>Nm,cuid2:()=>jm,currencyCode:()=>qm,custom:()=>jp,date:()=>sp,describe:()=>Up,discriminatedUnion:()=>gp,e164:()=>Fm,email:()=>bm,emoji:()=>Pm,enum:()=>Yi,exactOptional:()=>cl,file:()=>kp,float32:()=>Ym,float64:()=>Qm,function:()=>Op,guid:()=>km,hash:()=>Hm,hex:()=>Wm,hostname:()=>Gm,httpUrl:()=>Dm,iban:()=>Bm,instanceof:()=>Tp,int:()=>Oi,int32:()=>ep,int64:()=>np,intersection:()=>Qs,invertCodec:()=>zp,ipv4:()=>Cm,ipv6:()=>Em,json:()=>Zp,jwt:()=>Km,keyof:()=>lp,ksuid:()=>Tm,lazy:()=>Il,literal:()=>bp,looseObject:()=>mp,looseRecord:()=>$p,mac:()=>Zm,map:()=>hp,meta:()=>Ap,nan:()=>wp,nanoid:()=>Om,nativeEnum:()=>_p,never:()=>Hi,nonoptional:()=>pl,null:()=>Js,nullable:()=>jr,nullish:()=>xp,number:()=>Ls,object:()=>dp,optional:()=>Qe,partialRecord:()=>vp,pipe:()=>Ni,prefault:()=>ml,preprocess:()=>Ep,promise:()=>Pp,readonly:()=>bl,record:()=>rl,refine:()=>zl,set:()=>yp,strictObject:()=>fp,string:()=>Nr,stringFormat:()=>Xm,stringbool:()=>Cp,success:()=>Ip,superRefine:()=>Dl,symbol:()=>op,templateLiteral:()=>Dp,transform:()=>Qi,tuple:()=>tl,uint32:()=>tp,uint64:()=>ip,ulid:()=>Um,undefined:()=>ap,union:()=>Mt,unknown:()=>Ye,url:()=>zm,uuid:()=>xm,uuidv4:()=>Im,uuidv6:()=>wm,uuidv7:()=>Sm,void:()=>cp,xid:()=>Am,xor:()=>pp});var Di={};ge(Di,{endsWith:()=>wt,gt:()=>$e,gte:()=>ce,includes:()=>xt,length:()=>qe,lowercase:()=>bt,lt:()=>ve,lte:()=>ue,maxLength:()=>We,maxSize:()=>Oe,mime:()=>zt,minLength:()=>xe,minSize:()=>he,multipleOf:()=>Pe,negative:()=>yi,nonnegative:()=>bi,nonpositive:()=>_i,normalize:()=>Dt,overwrite:()=>pe,positive:()=>hi,properties:()=>St,property:()=>ki,regex:()=>_t,size:()=>Ge,slugify:()=>jt,startsWith:()=>It,toLowerCase:()=>Ot,toUpperCase:()=>Nt,trim:()=>Pt,uppercase:()=>kt});var ym=new WeakSet([Object.prototype,Error.prototype]);function Pi(e,r,i){Object.defineProperty(e,r,{configurable:!0,enumerable:!1,get(){let o=i(this);return Object.defineProperty(this,r,{value:o,configurable:!0,writable:!0}),o},set(o){Object.defineProperty(this,r,{value:o,configurable:!0,writable:!0})}})}var _m=(e,r)=>{xo.init(e,r),e.name="ZodError";let i=Object.getPrototypeOf(e);ym.has(i)||(ym.add(i),Pi(i,"format",o=>t=>nr(o,t)),Pi(i,"flatten",o=>t=>rr(o,t)),Pi(i,"addIssue",o=>t=>{o.issues.push(t),o.message=JSON.stringify(o.issues,at,2)}),Pi(i,"addIssues",o=>t=>{o.issues.push(...t),o.message=JSON.stringify(o.issues,at,2)}),Object.defineProperty(i,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},Ay=p("ZodError",_m),ae=p("ZodError",_m,void 0,{Parent:Error});var Is=dt(ae),ws=ft(ae),Ss=mt(ae),zs=pt(ae),Ds=nn(ae),Ps=on(ae),Os=an(ae),Ns=un(ae),js=cn(ae),Us=sn(ae),As=ln(ae),Ts=dn(ae);function Cy(){K.localeError||F(Fn())}function et(){K.memoizer||F({memoizer:br()})}var N=p("ZodType",(e,r)=>(Cy(),D.init(e,r),e.def=r,e.type=r.type,e),{check(...e){let r=this.def;return this.clone($.mergeDefs(r,{checks:[...r.checks??[],...e.map(i=>typeof i=="function"?{_zod:{check:i,def:{check:"custom"},onattach:[]}}:i)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,r){return C(this,e,r)},brand(){return this},register(e,r){return e.add(this,r),this},refine(e,r){return this.check(zl(e,r))},superRefine(e,r){return this.check(Dl(e,r))},overwrite(e){return this.check(pe(e))},optional(){return Qe(this)},exactOptional(){return cl(this)},nullable(){return jr(this)},nullish(){return Qe(jr(this))},nonoptional(e){return pl(this,e)},array(){return Tr(this)},or(e){return Mt([this,e])},and(e){return Qs(this,e)},transform(e){return Ni(this,Qi(e))},default(e){return dl(this,e)},prefault(e){return ml(this,e)},catch(e){return $l(this,e)},pipe(e){return Ni(this,e)},readonly(){return bl(this)},describe(e){let r=this.clone();return G.add(r,{description:e}),r},meta(...e){if(e.length===0)return G.get(this);let r=this.clone();return G.add(r,e[0]),r},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...r){return r.length===0?e(this):e(this,...r)},get"~standard"(){return $.hide(this,"~standard",{...kn(this),jsonSchema:{input:Ut(this,"input"),output:Ut(this,"output")}})},set"~standard"(e){$.own(this,"~standard",e)},parse:function e(r,i){return Is(this,r,i,{callee:e})},parseAsync:async function e(r,i){return await ws(this,r,i,{callee:e})},safeParse(e,r){return Ss(this,e,r)},async safeParseAsync(e,r){return zs(this,e,r)},get spa(){return this?.safeParseAsync},set spa(e){$.own(this,"spa",e)},validate(e,r){return ir(this,e,r)},validateAsync(e,r){return or(this,e,r)},encode:function e(r,i){return Ds(this,r,i,{callee:e})},decode:function e(r,i){return Ps(this,r,i,{callee:e})},encodeAsync:async function e(r,i){return await Os(this,r,i,{callee:e})},decodeAsync:async function e(r,i){return await Ns(this,r,i,{callee:e})},safeEncode(e,r){return js(this,e,r)},safeDecode(e,r){return Us(this,e,r)},async safeEncodeAsync(e,r){return As(this,e,r)},async safeDecodeAsync(e,r){return Ts(this,e,r)},toJSONSchema(e){return Zc(this,{})(e)},get description(){return G.get(this)?.description},get _def(){return this._zod.def}}),ji=p("_ZodString",(e,r)=>{Je.init(e,r),N.init(e,r),e._zod.processJSONSchema=(i,o,t)=>Vc(e,i,o,t)},$.derived({format:e=>B(e).format??null,minLength:e=>B(e).minimum??null,maxLength:e=>B(e).maximum??null},{regex(...e){return this.check(_t(...e))},includes(...e){return this.check(xt(...e))},startsWith(...e){return this.check(It(...e))},endsWith(...e){return this.check(wt(...e))},min(...e){return this.check(xe(...e))},max(...e){return this.check(We(...e))},length(...e){return this.check(qe(...e))},nonempty(...e){return this.check(xe(1,...e))},lowercase(e){return this.check(bt(e))},uppercase(e){return this.check(kt(e))},trim(){return this.check(Pt())},normalize(...e){return this.check(Dt(...e))},toLowerCase(){return this.check(Ot())},toUpperCase(){return this.check(Nt())},slugify(){return this.check(jt())}})),Et=p("ZodString",(e,r)=>{Je.init(e,r),ji.init(e,r)},{email(e){return this.check(Hn(Ui,e))},url(e){return this.check(Ir(Ur,e))},jwt(e){return this.check($i(Wi,e))},emoji(e){return this.check(ni(Ti,e))},guid(e){return this.check(Yn(Ai,e))},uuid(e){return this.check(Qn(ye,e))},uuidv4(e){return this.check(ei(ye,e))},uuidv6(e){return this.check(ti(ye,e))},uuidv7(e){return this.check(ri(ye,e))},nanoid(e){return this.check(ii(Ci,e))},cuid(e){return this.check(oi(Zi,e))},cuid2(e){return this.check(ai(Ei,e))},ulid(e){return this.check(ui(Li,e))},base64(e){return this.check(pi(Ki,e))},base64url(e){return this.check(gi(Xi,e))},xid(e){return this.check(ci(Vi,e))},ksuid(e){return this.check(si(Ri,e))},ipv4(e){return this.check(li(Mi,e))},ipv6(e){return this.check(di(Fi,e))},cidrv4(e){return this.check(fi(Ji,e))},cidrv6(e){return this.check(mi(Bi,e))},e164(e){return this.check(vi(Gi,e))},datetime(e){return this.check(wr(Ae,e))},date(e){return this.check(Sr(Te,e))},time(e){return this.check(zr(Ce,e))},duration(e){return this.check(Dr(Ze,e))}});function Nr(e){return Qu(Et,e)}var L=p("ZodStringFormat",(e,r)=>{Z.init(e,r),ji.init(e,r)}),Ae=p("ZodISODateTime",(e,r)=>{Fa.init(e,r),L.init(e,r)}),Te=p("ZodISODate",(e,r)=>{Ja.init(e,r),L.init(e,r)}),Ce=p("ZodISOTime",(e,r)=>{Ba.init(e,r),L.init(e,r)}),Ze=p("ZodISODuration",(e,r)=>{Ka.init(e,r),L.init(e,r)}),Ui=p("ZodEmail",(e,r)=>{ja.init(e,r),L.init(e,r)});function bm(e){return Hn(Ui,e)}var Ai=p("ZodGUID",(e,r)=>{Oa.init(e,r),L.init(e,r)});function km(e){return Yn(Ai,e)}var ye=p("ZodUUID",(e,r)=>{Na.init(e,r),L.init(e,r)});function xm(e){return Qn(ye,e)}function Im(e){return ei(ye,e)}function wm(e){return ti(ye,e)}function Sm(e){return ri(ye,e)}var Ur=p("ZodURL",(e,r)=>{Ta.init(e,r),L.init(e,r)});function zm(e){return Ir(Ur,e)}function Dm(e){return Ir(Ur,{protocol:ar,hostname:Ko,...$.normalizeParams(e)})}var Ti=p("ZodEmoji",(e,r)=>{Ca.init(e,r),L.init(e,r)});function Pm(e){return ni(Ti,e)}var Ci=p("ZodNanoID",(e,r)=>{Za.init(e,r),L.init(e,r)});function Om(e){return ii(Ci,e)}var Zi=p("ZodCUID",(e,r)=>{Ea.init(e,r),L.init(e,r)});function Nm(e){return oi(Zi,e)}var Ei=p("ZodCUID2",(e,r)=>{La.init(e,r),L.init(e,r)});function jm(e){return ai(Ei,e)}var Li=p("ZodULID",(e,r)=>{Va.init(e,r),L.init(e,r)});function Um(e){return ui(Li,e)}var Vi=p("ZodXID",(e,r)=>{Ra.init(e,r),L.init(e,r)});function Am(e){return ci(Vi,e)}var Ri=p("ZodKSUID",(e,r)=>{Ma.init(e,r),L.init(e,r)});function Tm(e){return si(Ri,e)}var Mi=p("ZodIPv4",(e,r)=>{Xa.init(e,r),L.init(e,r)});function Cm(e){return li(Mi,e)}var Cs=p("ZodMAC",(e,r)=>{Wa.init(e,r),L.init(e,r)});function Zm(e){return tc(Cs,e)}var Fi=p("ZodIPv6",(e,r)=>{Ga.init(e,r),L.init(e,r)});function Em(e){return di(Fi,e)}var Ji=p("ZodCIDRv4",(e,r)=>{qa.init(e,r),L.init(e,r)});function Lm(e){return fi(Ji,e)}var Bi=p("ZodCIDRv6",(e,r)=>{Ha.init(e,r),L.init(e,r)});function Vm(e){return mi(Bi,e)}var Ki=p("ZodBase64",(e,r)=>{Ya.init(e,r),L.init(e,r)});function Rm(e){return pi(Ki,e)}var Xi=p("ZodBase64URL",(e,r)=>{Qa.init(e,r),L.init(e,r)});function Mm(e){return gi(Xi,e)}var Gi=p("ZodE164",(e,r)=>{eu.init(e,r),L.init(e,r)});function Fm(e){return vi(Gi,e)}var Zs=p("ZodCreditCard",(e,r)=>{tu.init(e,r),L.init(e,r)});function Jm(e){return rc(Zs,e)}var Es=p("ZodIBAN",(e,r)=>{ru.init(e,r),L.init(e,r)});function Bm(e){return nc(Es,e)}var Wi=p("ZodJWT",(e,r)=>{nu.init(e,r),L.init(e,r)});function Km(e){return $i(Wi,e)}var tt=p("ZodCustomStringFormat",(e,r)=>{iu.init(e,r),L.init(e,r)});function Xm(e,r,i={}){return He(tt,e,r,i)}function Gm(e){return He(tt,"hostname",Bo,e)}function Wm(e){return He(tt,"hex",aa,e)}function qm(e){return He(tt,"currency_code",Go,e)}function Hm(e,r){let i=r?.enc??"hex",o=`${e}_${i}`,t=de[o];if(!t)throw new Error(`Unrecognized hash format: ${o}`);return He(tt,o,t,r)}var Lt=p("ZodNumber",(e,r)=>{jn.init(e,r),N.init(e,r),e._zod.processJSONSchema=(i,o,t)=>Rc(e,i,o,t),e.isFinite=!0},$.derived({minValue:e=>{let{minimum:r,exclusiveMinimum:i}=B(e);return Math.max(r??Number.NEGATIVE_INFINITY,i??Number.NEGATIVE_INFINITY)},maxValue:e=>{let{maximum:r,exclusiveMaximum:i}=B(e);return Math.min(r??Number.POSITIVE_INFINITY,i??Number.POSITIVE_INFINITY)},isInt:e=>{let{isInt:r,multipleOf:i}=B(e);return!!r||!!i?.some(Number.isSafeInteger)},format:e=>B(e).format??null},{gt(e,r){return this.check($e(e,r))},gte(e,r){return this.check(ce(e,r))},min(e,r){return this.check(ce(e,r))},lt(e,r){return this.check(ve(e,r))},lte(e,r){return this.check(ue(e,r))},max(e,r){return this.check(ue(e,r))},int(e){return this.check(Oi(e))},safe(e){return this.check(Oi(e))},positive(e){return this.check($e(0,e))},nonnegative(e){return this.check(ce(0,e))},negative(e){return this.check(ve(0,e))},nonpositive(e){return this.check(ue(0,e))},multipleOf(e,r){return this.check(Pe(e,r))},step(e,r){return this.check(Pe(e,r))},finite(){return this}}));function Ls(e){return oc(Lt,e)}var rt=p("ZodNumberFormat",(e,r)=>{ou.init(e,r),Lt.init(e,r)});function Oi(e){return uc(rt,e)}function Ym(e){return cc(rt,e)}function Qm(e){return sc(rt,e)}function ep(e){return lc(rt,e)}function tp(e){return dc(rt,e)}var Vt=p("ZodBoolean",(e,r)=>{gr.init(e,r),N.init(e,r),e._zod.processJSONSchema=(i,o,t)=>Mc(e,i,o,t)});function Vs(e){return fc(Vt,e)}var Rt=p("ZodBigInt",(e,r)=>{Un.init(e,r),N.init(e,r),e._zod.processJSONSchema=(i,o,t)=>Fc(e,i,o,t)},$.derived({minValue:e=>B(e).minimum??null,maxValue:e=>B(e).maximum??null,format:e=>B(e).format??null},{gte(e,r){return this.check(ce(e,r))},min(e,r){return this.check(ce(e,r))},gt(e,r){return this.check($e(e,r))},lt(e,r){return this.check(ve(e,r))},lte(e,r){return this.check(ue(e,r))},max(e,r){return this.check(ue(e,r))},positive(e){return this.check($e(BigInt(0),e))},negative(e){return this.check(ve(BigInt(0),e))},nonpositive(e){return this.check(ue(BigInt(0),e))},nonnegative(e){return this.check(ce(BigInt(0),e))},multipleOf(e,r){return this.check(Pe(e,r))}}));function rp(e){return pc(Rt,e)}var qi=p("ZodBigIntFormat",(e,r)=>{au.init(e,r),Rt.init(e,r)});function np(e){return vc(qi,e)}function ip(e){return $c(qi,e)}var Rs=p("ZodSymbol",(e,r)=>{uu.init(e,r),N.init(e,r),e._zod.processJSONSchema=(i,o,t)=>Jc(e,i,o,t)});function op(e){return hc(Rs,e)}var Ms=p("ZodUndefined",(e,r)=>{cu.init(e,r),N.init(e,r),e._zod.processJSONSchema=(i,o,t)=>Kc(e,i,o,t)});function ap(e){return yc(Ms,e)}var Fs=p("ZodNull",(e,r)=>{su.init(e,r),N.init(e,r),e._zod.processJSONSchema=(i,o,t)=>Bc(e,i,o,t)});function Js(e){return _c(Fs,e)}var Bs=p("ZodAny",(e,r)=>{lu.init(e,r),N.init(e,r),e._zod.processJSONSchema=(i,o,t)=>Wc(e,i,o,t)});function up(){return bc(Bs)}var Ks=p("ZodUnknown",(e,r)=>{du.init(e,r),N.init(e,r),e._zod.processJSONSchema=(i,o,t)=>qc(e,i,o,t)});function Ye(){return kc(Ks)}var Xs=p("ZodNever",(e,r)=>{fu.init(e,r),N.init(e,r),e._zod.processJSONSchema=(i,o,t)=>Gc(e,i,o,t)});function Hi(e){return xc(Xs,e)}var Gs=p("ZodVoid",(e,r)=>{mu.init(e,r),N.init(e,r),e._zod.processJSONSchema=(i,o,t)=>Xc(e,i,o,t)});function cp(e){return Ic(Gs,e)}var Ar=p("ZodDate",(e,r)=>{pu.init(e,r),N.init(e,r),e._zod.processJSONSchema=(i,o,t)=>Hc(e,i,o,t),e.min=(i,o)=>e.check(ce(i,o)),e.max=(i,o)=>e.check(ue(i,o))},$.derived({minDate:e=>{let{minimum:r}=B(e);return r?new Date(r):null},maxDate:e=>{let{maximum:r}=B(e);return r?new Date(r):null}},{}));function sp(e){return wc(Ar,e)}var Ws=p("ZodArray",(e,r)=>{et(),vu.init(e,r),N.init(e,r),e._zod.processJSONSchema=(i,o,t)=>ss(e,i,o,t),e.element=r.element},{min(e,r){return this.check(xe(e,r))},nonempty(e){return this.check(xe(1,e))},max(e,r){return this.check(We(e,r))},length(e,r){return this.check(qe(e,r))},unwrap(){return this.element}});function Tr(e,r){return Dc(Ws,e,r)}function lp(e){let r=e._zod.def.shape;return Yi(Object.keys(r))}var Cr=p("ZodObject",(e,r)=>{et(),$u.init(e,r),N.init(e,r),e._zod.processJSONSchema=(i,o,t)=>ls(e,i,o,t),$.installLazyProp(e,"shape",i=>i._zod.def.shape,!1)},{keyof(){return Yi(Object.keys(this._zod.def.shape))},catchall(e){return this.clone($.mergeDefs(this._zod.def,{catchall:e}))},passthrough(){return this.clone($.mergeDefs(this._zod.def,{catchall:Ye()}))},loose(){return this.clone($.mergeDefs(this._zod.def,{catchall:Ye()}))},strict(){return this.clone($.mergeDefs(this._zod.def,{catchall:Hi()}))},strip(){return this.clone($.mergeDefs(this._zod.def,{catchall:void 0}))},extend(e){return $.extend(this,e)},safeExtend(e){return $.safeExtend(this,e)},merge(e){return $.merge(this,e)},pick(e){return $.pick(this,e)},omit(e){return $.omit(this,e)},partial(...e){return $.partial(Er,this,e[0])},exactPartial(...e){return $.partial(eo,this,e[0],"exactPartial")},required(...e){return $.required(to,this,e[0])}});function dp(e,r){let i={type:"object",shape:e??{},...$.normalizeParams(r)};return new Cr(i)}function fp(e,r){return new Cr({type:"object",shape:e,catchall:Hi(),...$.normalizeParams(r)})}function mp(e,r){return new Cr({type:"object",shape:e,catchall:Ye(),...$.normalizeParams(r)})}var Zr=p("ZodUnion",(e,r)=>{vr.init(e,r),N.init(e,r),e._zod.processJSONSchema=(i,o,t)=>Ii(e,i,o,t),e.options=r.options});function Mt(e,r){return new Zr({type:"union",options:e,...$.normalizeParams(r)})}var qs=p("ZodXor",(e,r)=>{Zr.init(e,r),hu.init(e,r),e._zod.processJSONSchema=(i,o,t)=>Ii(e,i,o,t),e.options=r.options});function pp(e,r){return new qs({type:"union",options:e,inclusive:!1,...$.normalizeParams(r)})}var Hs=p("ZodDiscriminatedUnion",(e,r)=>{Zr.init(e,r),_u.init(e,r)});function gp(e,r,i){return new Hs({type:"union",options:r,discriminator:e,...$.normalizeParams(i)})}var Ys=p("ZodIntersection",(e,r)=>{bu.init(e,r),N.init(e,r),e._zod.processJSONSchema=(i,o,t)=>ds(e,i,o,t)});function Qs(e,r){return new Ys({type:"intersection",left:e,right:r})}var el=p("ZodTuple",(e,r)=>{et(),An.init(e,r),N.init(e,r),e._zod.processJSONSchema=(i,o,t)=>fs(e,i,o,t)},{rest(e){return this.clone({...this._zod.def,rest:e})},partial(){let e=this._zod.def;if(e.checks?.length)throw new Error(".partial() cannot be used on tuple schemas containing refinements");return this.clone({...e,items:e.items.map(r=>new Er({type:"optional",innerType:r}))})}});function tl(e,r,i){let o=r instanceof D,t=o?i:r,n=o?r:null;return new el({type:"tuple",items:e,rest:n,...$.normalizeParams(t)})}var Ct=p("ZodRecord",(e,r)=>{et(),ku.init(e,r),N.init(e,r),e._zod.processJSONSchema=(i,o,t)=>ms(e,i,o,t),e.keyType=r.keyType,e.valueType=r.valueType});function rl(e,r,i){return!r||!r._zod?new Ct({type:"record",keyType:Nr(),valueType:e,...$.normalizeParams(r)}):new Ct({type:"record",keyType:e,valueType:r,...$.normalizeParams(i)})}function vp(e,r,i){return new Ct({type:"record",keyType:e,valueType:r,...$.normalizeParams(i),partial:!0})}function $p(e,r,i){return new Ct({type:"record",keyType:e,valueType:r,mode:"loose",...$.normalizeParams(i)})}var nl=p("ZodMap",(e,r)=>{et(),xu.init(e,r),N.init(e,r),e._zod.processJSONSchema=(i,o,t)=>us(e,i,o,t),e.keyType=r.keyType,e.valueType=r.valueType,e.min=(...i)=>e.check(he(...i)),e.nonempty=i=>e.check(he(1,i)),e.max=(...i)=>e.check(Oe(...i)),e.size=(...i)=>e.check(Ge(...i))});function hp(e,r,i){return new nl({type:"map",keyType:e,valueType:r,...$.normalizeParams(i)})}var il=p("ZodSet",(e,r)=>{et(),Iu.init(e,r),N.init(e,r),e._zod.processJSONSchema=(i,o,t)=>cs(e,i,o,t),e.min=(...i)=>e.check(he(...i)),e.nonempty=i=>e.check(he(1,i)),e.max=(...i)=>e.check(Oe(...i)),e.size=(...i)=>e.check(Ge(...i))});function yp(e,r){return new il({type:"set",valueType:e,...$.normalizeParams(r)})}var Zt=p("ZodEnum",(e,r)=>{wu.init(e,r),N.init(e,r),e._zod.processJSONSchema=(o,t,n)=>Yc(e,o,t,n),e.enum=r.entries,e.options=[...e._zod.values];let i=new Set(Object.keys(r.entries));e.extract=(o,t)=>{let n={};for(let a of o)if(i.has(a))n[a]=r.entries[a];else throw new Error(`Key ${a} not found in enum`);return new Zt({...r,checks:[],...$.normalizeParams(t),entries:n})},e.exclude=(o,t)=>{let n={...r.entries};for(let a of o)if(i.has(a))delete n[a];else throw new Error(`Key ${a} not found in enum`);return new Zt({...r,checks:[],...$.normalizeParams(t),entries:n})}});function Yi(e,r){let i=Array.isArray(e)?Object.fromEntries(e.map(o=>[o,o])):e;return new Zt({type:"enum",entries:i,...$.normalizeParams(r)})}function _p(e,r){return new Zt({type:"enum",entries:e,...$.normalizeParams(r)})}var ol=p("ZodLiteral",(e,r)=>{Su.init(e,r),N.init(e,r),e._zod.processJSONSchema=(i,o,t)=>Qc(e,i,o,t),e.values=new Set(r.values),Object.defineProperty(e,"value",{get(){if(r.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return r.values[0]}})});function bp(e,r){return new ol({type:"literal",values:Array.isArray(e)?e:[e],...$.normalizeParams(r)})}var al=p("ZodFile",(e,r)=>{zu.init(e,r),N.init(e,r),e._zod.processJSONSchema=(i,o,t)=>rs(e,i,o,t),e.min=(i,o)=>e.check(he(i,o)),e.max=(i,o)=>e.check(Oe(i,o)),e.mime=(i,o)=>e.check(zt(Array.isArray(i)?i:[i],o))});function kp(e){return Pc(al,e)}var ul=p("ZodTransform",(e,r)=>{et(),Du.init(e,r),N.init(e,r),e._zod.processJSONSchema=(i,o,t)=>as(e,i,o,t),e._zod.parse=(i,o)=>{if(o.direction==="backward")throw new ze(e.constructor.name);i.addIssue=n=>{if(typeof n=="string")i.issues.push($.issue(n,i.value,r));else{let a=n;a.fatal&&(a.continue=!1),a.code??(a.code="custom"),"input"in a||(a.input=i.value),a.inst??(a.inst=e),i.issues.push($.issue(a))}};let t=r.transform(i.value,i);return t instanceof Promise?t.then(n=>(i.value=n,i)):(i.value=t,i)}});function Qi(e){return new ul({type:"transform",transform:e})}var Er=p("ZodOptional",(e,r)=>{Tn.init(e,r),N.init(e,r),e._zod.processJSONSchema=(i,o,t)=>wi(e,i,o,t),e.unwrap=()=>e._zod.def.innerType});function Qe(e){return new Er({type:"optional",innerType:e})}var eo=p("ZodExactOptional",(e,r)=>{Pu.init(e,r),N.init(e,r),e._zod.processJSONSchema=(i,o,t)=>wi(e,i,o,t),e.unwrap=()=>e._zod.def.innerType});function cl(e){return new eo({type:"optional",innerType:e})}var sl=p("ZodNullable",(e,r)=>{Ou.init(e,r),N.init(e,r),e._zod.processJSONSchema=(i,o,t)=>ps(e,i,o,t),e.unwrap=()=>e._zod.def.innerType});function jr(e){return new sl({type:"nullable",innerType:e})}function xp(e){return Qe(jr(e))}var ll=p("ZodDefault",(e,r)=>{Nu.init(e,r),N.init(e,r),e._zod.processJSONSchema=(i,o,t)=>$s(e,i,o,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function dl(e,r){return new ll({type:"default",innerType:e,get defaultValue(){return typeof r=="function"?r():$.shallowClone(r)}})}var fl=p("ZodPrefault",(e,r)=>{ju.init(e,r),N.init(e,r),e._zod.processJSONSchema=(i,o,t)=>hs(e,i,o,t),e.unwrap=()=>e._zod.def.innerType});function ml(e,r){return new fl({type:"prefault",innerType:e,get defaultValue(){return typeof r=="function"?r():$.shallowClone(r)}})}var to=p("ZodNonOptional",(e,r)=>{Uu.init(e,r),N.init(e,r),e._zod.processJSONSchema=(i,o,t)=>gs(e,i,o,t),e.unwrap=()=>e._zod.def.innerType});function pl(e,r){return new to({type:"nonoptional",innerType:e,...$.normalizeParams(r)})}var gl=p("ZodSuccess",(e,r)=>{Au.init(e,r),N.init(e,r),e._zod.processJSONSchema=(i,o,t)=>ns(e,i,o,t),e.unwrap=()=>e._zod.def.innerType});function Ip(e){return new gl({type:"success",innerType:e})}var vl=p("ZodCatch",(e,r)=>{Tu.init(e,r),N.init(e,r),e._zod.processJSONSchema=(i,o,t)=>ys(e,i,o,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function $l(e,r){return new vl({type:"catch",innerType:e,catchValue:typeof r=="function"?r:$.constantCatch(r)})}var hl=p("ZodNaN",(e,r)=>{Cu.init(e,r),N.init(e,r),e._zod.processJSONSchema=(i,o,t)=>es(e,i,o,t)});function wp(e){return zc(hl,e)}var Lr=p("ZodPipe",(e,r)=>{Cn.init(e,r),N.init(e,r),e._zod.processJSONSchema=(i,o,t)=>_s(e,i,o,t),e.in=r.in,e.out=r.out});function Ni(e,r){return new Lr({type:"pipe",in:e,out:r})}var Vr=p("ZodCodec",(e,r)=>{Lr.init(e,r),$r.init(e,r)});function Sp(e,r,i){return new Vr({type:"pipe",in:e,out:r,transform:i.decode,reverseTransform:i.encode})}function zp(e){let r=e._zod.def;return new Vr({type:"pipe",in:r.out,out:r.in,transform:r.reverseTransform,reverseTransform:r.transform})}var yl=p("ZodPreprocess",(e,r)=>{Lr.init(e,r),Zu.init(e,r)}),_l=p("ZodReadonly",(e,r)=>{Eu.init(e,r),N.init(e,r),e._zod.processJSONSchema=(i,o,t)=>bs(e,i,o,t),e.unwrap=()=>e._zod.def.innerType});function bl(e){return new _l({type:"readonly",innerType:e})}var kl=p("ZodTemplateLiteral",(e,r)=>{Lu.init(e,r),N.init(e,r),e._zod.processJSONSchema=(i,o,t)=>ts(e,i,o,t)});function Dp(e,r){return new kl({type:"template_literal",parts:e,...$.normalizeParams(r)})}var xl=p("ZodLazy",(e,r)=>{hr.init(e,r),N.init(e,r),e._zod.processJSONSchema=(i,o,t)=>xs(e,i,o,t),e.unwrap=()=>e._zod.def.getter()});function Il(e){return new xl({type:"lazy",getter:e})}var wl=p("ZodPromise",(e,r)=>{Ru.init(e,r),N.init(e,r),e._zod.processJSONSchema=(i,o,t)=>ks(e,i,o,t),e.unwrap=()=>e._zod.def.innerType});function Pp(e){return new wl({type:"promise",innerType:e})}var Sl=p("ZodFunction",(e,r)=>{Vu.init(e,r),N.init(e,r),e._zod.processJSONSchema=(i,o,t)=>os(e,i,o,t)});function Op(e){return new Sl({type:"function",input:Array.isArray(e?.input)?tl(e?.input):e?.input??Tr(Ye()),output:e?.output??Ye()})}var Rr=p("ZodCustom",(e,r)=>{Mu.init(e,r),N.init(e,r),e._zod.processJSONSchema=(i,o,t)=>is(e,i,o,t)});function Np(e){let r=new V({check:"custom"});return r._zod.check=e,r}function jp(e,r){return Oc(Rr,e??(()=>!0),r)}function zl(e,r={}){return Nc(Rr,e,r)}function Dl(e,r){return jc(e,r)}var Up=Uc,Ap=Ac,Pl=p("ZodInstanceOf",(e,r)=>{Rr.init(e,r)},{properties(e,r){return this.check(St(e,r))}});function Tp(e,r={}){let i=new Pl({type:"custom",check:"custom",fn:o=>o instanceof e,abort:!0,...$.normalizeParams(r)});return i._zod.bag.Class=e,i._zod.check=o=>{o.value instanceof e||o.issues.push({code:"invalid_type",expected:e.name,input:o.value,inst:i,path:[...i._zod.def.path??[]]})},i}var Cp=(...e)=>Tc({Codec:Vr,Boolean:Vt,String:Et},...e);function Zp(e){let r=Il(()=>Mt([Nr(e),Ls(),Vs(),Js(),Tr(r),rl(Nr(),r)]));return r}function Ep(e,r){return new yl({type:"pipe",in:Qi(e),out:r})}var Zy={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};function Ey(e){F({customError:e})}function Ly(){return F().customError}var Ol;Ol||(Ol={});var Mr={};ge(Mr,{ZodISODate:()=>Te,ZodISODateTime:()=>Ae,ZodISODuration:()=>Ze,ZodISOTime:()=>Ce,date:()=>Ry,datetime:()=>Vy,duration:()=>Fy,time:()=>My});function Vy(e){return wr(Ae,e)}function Ry(e){return Sr(Te,e)}function My(e){return zr(Ce,e)}function Fy(e){return Dr(Ze,e)}var x={...Ft,...Di,iso:Mr},Jy=new Set(["$schema","$ref","$defs","definitions","$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor","type","enum","const","anyOf","oneOf","allOf","not","properties","required","additionalProperties","patternProperties","propertyNames","minProperties","maxProperties","items","prefixItems","additionalItems","minItems","maxItems","uniqueItems","contains","minContains","maxContains","minLength","maxLength","pattern","format","minimum","maximum","exclusiveMinimum","exclusiveMaximum","multipleOf","description","default","contentEncoding","contentMediaType","contentSchema","unevaluatedItems","unevaluatedProperties","if","then","else","dependentSchemas","dependentRequired","nullable","readOnly"]);function By(e,r){let i=e.$schema;return i==="https://json-schema.org/draft/2020-12/schema"?"draft-2020-12":i==="http://json-schema.org/draft-07/schema#"?"draft-7":i==="http://json-schema.org/draft-04/schema#"?"draft-4":r??"draft-2020-12"}function Lp(e,r){return e.map((i,o)=>o<r?i:i.optional())}function Ky(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function Xy(e,r){if(!e.startsWith("#"))throw new Error("External $ref is not supported, only local refs (#/...) are allowed");let i=e.slice(1).split("/").filter(Boolean);if(i.length===0)return r.rootSchema;let o=r.version==="draft-2020-12"?"$defs":"definitions";if(i[0]===o){let t=i[1]===void 0?void 0:Ky(i[1]);if(!t||!r.defs[t])throw new Error(`Reference not found: ${e}`);return r.defs[t]}throw new Error(`Reference not found: ${e}`)}function Gy(e,r){return x.transform(o=>o).check(o=>{let t=o.value;if(typeof t!="object"||t===null||Array.isArray(t))return;let n=Object.getOwnPropertyNames(t);if(r.minProperties!==void 0&&n.length<r.minProperties&&o.issues.push({origin:"object",code:"too_small",minimum:r.minProperties,inclusive:!0,message:`Too small: expected object to have >=${r.minProperties} properties`,input:t,inst:e,continue:!0}),r.maxProperties!==void 0&&n.length>r.maxProperties&&o.issues.push({origin:"object",code:"too_big",maximum:r.maxProperties,inclusive:!0,message:`Too big: expected object to have <=${r.maxProperties} properties`,input:t,inst:e,continue:!0}),r.keySchema)for(let a of n){let u=r.keySchema.safeParse(a);u.success||o.issues.push({code:"invalid_key",origin:"record",issues:u.error.issues,input:a,path:[a],continue:!0})}}).pipe(e)}function Nl(e,r){if(e===null)return"z";let i=typeof e;if(i!=="object"){if(i==="number"&&Number.isNaN(e))return null;let o=String(e);return`${i[0]}${o.length}:${o}`}if(r.has(e))return null;r.add(e);try{if(Array.isArray(e)){let n=[];for(let a of e){let u=Nl(a,r);if(u===null)return null;n.push(u)}return`a${n.length}:[${n.join(",")}]`}let o=Object.keys(e).sort(),t=[];for(let n of o){let a=Nl(e[n],r);if(a===null)return null;t.push(`${n.length}:${n}=${a}`)}return`o${t.length}:{${t.join(",")}}`}finally{r.delete(e)}}var Wy=new Set(["items","prefixItems","additionalItems","additionalProperties","contains","propertyNames","not","if","then","else","allOf","anyOf","oneOf","unevaluatedItems","unevaluatedProperties","contentSchema"]),qy=new Set(["properties","patternProperties","dependentSchemas","dependencies","$defs","definitions"]);function Fr(e){return typeof e!="object"||e===null?!1:Array.isArray(e)?e.some(Fr):typeof e.$ref=="string"?!0:Object.entries(e).some(([r,i])=>Wy.has(r)?Fr(i):!qy.has(r)||typeof i!="object"||i===null?!1:Object.values(i).some(Fr))}function Vp(e){return e===1?"element":"elements"}function Hy(e,r){return x.transform(o=>o).check(o=>{let t=o.value;if(Array.isArray(t)){if(r.uniqueItems===!0){let n=new Map;for(let a=0;a<t.length;a++){let u=Nl(t[a],new Set);if(u===null)continue;let c=n.get(u);if(c===void 0){n.set(u,a);continue}o.issues.push({code:"custom",message:`Array items must be unique: element at index ${a} duplicates the one at index ${c}`,input:t,path:[a],continue:!0})}}if(r.containsSchema){let n=r.minContains??1,a=r.maxContains!==void 0?r.maxContains+1:Number.POSITIVE_INFINITY,u=0;for(let c of t)if(r.containsSchema.safeParse(c).success&&++u>=a)break;u<n&&o.issues.push({code:"custom",message:`Array must contain at least ${n} matching ${Vp(n)}; found ${u}`,input:t,continue:!0}),r.maxContains!==void 0&&u>r.maxContains&&o.issues.push({code:"custom",message:`Array must contain at most ${r.maxContains} matching ${Vp(r.maxContains)}`,input:t,continue:!0})}}}).pipe(e)}function Rp(e,r){if(e!==!1)return e===void 0||e===!0?x.any():te(e,r)}var Yy=/^(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/;function Mp(e,r){if(e.not!==void 0){if(typeof e.not=="object"&&Object.keys(e.not).length===0)return x.never();throw new Error("not is not supported in Zod (except { not: {} } for never)")}if(e.unevaluatedItems!==void 0)throw new Error("unevaluatedItems is not supported");if(e.unevaluatedProperties!==void 0)throw new Error("unevaluatedProperties is not supported");if(e.if!==void 0||e.then!==void 0||e.else!==void 0)throw new Error("Conditional schemas (if/then/else) are not supported");if(e.dependentSchemas!==void 0||e.dependentRequired!==void 0)throw new Error("dependentSchemas and dependentRequired are not supported");if(e.$ref){let t=e.$ref;if(r.refs.has(t))return r.refs.get(t);if(r.processing.has(t))return x.lazy(()=>{if(!r.refs.has(t))throw new Error(`Circular reference not resolved: ${t}`);return r.refs.get(t)});r.processing.add(t);let n=Xy(t,r),a=te(n,r);return r.refs.set(t,a),r.processing.delete(t),a}if(e.enum!==void 0){let t=e.enum;if(r.version==="openapi-3.0"&&e.nullable===!0&&t.length===1&&t[0]===null)return x.null();if(t.length===0)return x.never();if(t.length===1)return x.literal(t[0]);if(t.every(a=>typeof a=="string"))return x.enum(t);let n=t.map(a=>x.literal(a));return n.length<2?n[0]:x.union([n[0],n[1],...n.slice(2)])}if(e.const!==void 0)return x.literal(e.const);let i=e.type;if(Array.isArray(i)){let t=i.map(n=>{let a={...e,type:n};return Mp(a,r)});return t.length===0?x.never():t.length===1?t[0]:x.union(t)}if(!i)return x.any();let o;switch(i){case"string":{let t=x.string();if(e.format){let n=e.format;n==="email"?t=t.check(x.email()):n==="uri"||n==="uri-reference"?t=t.check(x.url()):n==="uuid"||n==="guid"?t=t.check(x.uuid()):n==="date-time"?t=t.check(x.iso.datetime({offset:!0})):n==="date"?t=t.check(x.iso.date()):n==="time"?t=t.check(x.regex(Yy)):n==="duration"?t=t.check(x.iso.duration()):n==="hostname"?t=t.check(x.hostname()):n==="ipv4"?t=t.check(x.ipv4()):n==="ipv6"?t=t.check(x.ipv6()):n==="mac"?t=t.check(x.mac()):n==="cidr"?t=t.check(x.cidrv4()):n==="cidr-v6"?t=t.check(x.cidrv6()):n==="base64"?t=t.check(x.base64()):n==="base64url"?t=t.check(x.base64url()):n==="e164"?t=t.check(x.e164()):n==="credit_card"?t=t.check(x.creditCard()):n==="iban"?t=t.check(x.iban()):n==="jwt"?t=t.check(x.jwt()):n==="emoji"?t=t.check(x.emoji()):n==="nanoid"?t=t.check(x.nanoid()):n==="cuid"?t=t.check(x.cuid()):n==="cuid2"?t=t.check(x.cuid2()):n==="ulid"?t=t.check(x.ulid()):n==="xid"?t=t.check(x.xid()):n==="ksuid"&&(t=t.check(x.ksuid()))}typeof e.minLength=="number"&&(t=t.min(e.minLength)),typeof e.maxLength=="number"&&(t=t.max(e.maxLength)),e.pattern&&(t=t.regex(new RegExp(e.pattern))),o=t;break}case"number":case"integer":{let t=i==="integer"?x.number().int():x.number();typeof e.minimum=="number"&&e.exclusiveMinimum!==!0&&(t=t.min(e.minimum)),typeof e.maximum=="number"&&e.exclusiveMaximum!==!0&&(t=t.max(e.maximum)),typeof e.exclusiveMinimum=="number"?t=t.gt(e.exclusiveMinimum):e.exclusiveMinimum===!0&&typeof e.minimum=="number"&&(t=t.gt(e.minimum)),typeof e.exclusiveMaximum=="number"?t=t.lt(e.exclusiveMaximum):e.exclusiveMaximum===!0&&typeof e.maximum=="number"&&(t=t.lt(e.maximum)),typeof e.multipleOf=="number"&&(t=t.multipleOf(e.multipleOf)),o=t;break}case"boolean":{o=x.boolean();break}case"null":{o=x.null();break}case"object":{let t={},n=e.properties||{},a=new Set(e.required||[]),u=typeof e.additionalProperties=="object"?te(e.additionalProperties,r):void 0;for(let[d,f]of Object.entries(n)){let m=te(f,r);X(t,d,a.has(d)?m:m.optional())}if(e.patternProperties){let d=e.patternProperties,f=Object.keys(d),m=[];for(let _ of f){let k=te(d[_],r),S=x.string().regex(new RegExp(_));m.push(x.looseRecord(S,k))}let v=[];if(Object.keys(t).length>0&&v.push(x.object(t).passthrough()),v.push(...m),v.length===0)o=x.object({}).passthrough();else if(v.length===1)o=v[0];else{let _=x.intersection(v[0],v[1]);for(let k=2;k<v.length;k++)_=x.intersection(_,v[k]);o=_}if(e.additionalProperties===!1){let _=Object.keys(t),k=f.map(I=>new RegExp(I)),S=o;o=o.check(I=>{if(!se(I.value))return;let P=[];for(let T of Object.keys(I.value))_.includes(T)||k.some(R=>R.test(T))||P.push(T);P.length&&I.issues.push({code:"unrecognized_keys",keys:P,input:I.value,inst:S})})}}else{let d=x.object(t);e.additionalProperties===!1?o=d.strict():u?o=d.catchall(u):o=d.passthrough()}let c=e.propertyNames!==void 0&&e.propertyNames!==!0,s=typeof e.minProperties=="number"?e.minProperties:void 0,l=typeof e.maxProperties=="number"?e.maxProperties:void 0;if(c||s!==void 0||l!==void 0){let d;if(c){let f=typeof e.propertyNames=="object"&&e.propertyNames.type===void 0?{type:"string",...e.propertyNames}:e.propertyNames;d=te(f,r)}o=Gy(o,{keySchema:d,minProperties:s,maxProperties:l})}break}case"array":{let t=e.prefixItems,n=e.items;if(t&&Array.isArray(t)){let a=typeof e.minItems=="number"?e.minItems:0,u=t.map(d=>te(d,r)),c=Lp(u,a),s=Array.isArray(n)?void 0:Rp(n,r),l=x.tuple(c);o=s?l.rest(s):l,typeof e.minItems=="number"&&(o=o.check(x.minLength(e.minItems))),typeof e.maxItems=="number"&&(o=o.check(x.maxLength(e.maxItems)))}else if(Array.isArray(n)){let a=typeof e.minItems=="number"?e.minItems:0,u=n.map(d=>te(d,r)),c=Lp(u,a),s=Rp(e.additionalItems,r),l=x.tuple(c);o=s?l.rest(s):l,typeof e.minItems=="number"&&(o=o.check(x.minLength(e.minItems))),typeof e.maxItems=="number"&&(o=o.check(x.maxLength(e.maxItems)))}else if(n!==void 0){let a=te(n,r),u=x.array(a);typeof e.minItems=="number"&&(u=u.min(e.minItems)),typeof e.maxItems=="number"&&(u=u.max(e.maxItems)),o=u}else o=x.array(x.any());(e.uniqueItems===!0||e.contains!==void 0)&&(o=Hy(o,{uniqueItems:e.uniqueItems===!0,containsSchema:e.contains!==void 0?te(e.contains,r):void 0,minContains:typeof e.minContains=="number"?e.minContains:void 0,maxContains:typeof e.maxContains=="number"?e.maxContains:void 0}));break}default:throw new Error(`Unsupported type: ${i}`)}return o}function te(e,r){if(typeof e=="boolean")return e?x.any():x.never();let i=Mp(e,r),o=e.type||e.enum!==void 0||e.const!==void 0;if(e.anyOf&&Array.isArray(e.anyOf)){let u=e.anyOf.map(s=>te(s,r)),c=x.union(u);i=o?x.intersection(i,c):c}if(e.oneOf&&Array.isArray(e.oneOf)){let u=e.oneOf.map(s=>te(s,r)),c=x.xor(u);i=o?x.intersection(i,c):c}if(e.allOf&&Array.isArray(e.allOf))if(e.allOf.length===0)i=o?i:x.any();else{let u=o?i:te(e.allOf[0],r),c=o?0:1;for(let s=c;s<e.allOf.length;s++)u=x.intersection(u,te(e.allOf[s],r));i=u}e.nullable===!0&&r.version==="openapi-3.0"&&(i=x.nullable(i)),e.readOnly===!0&&(i=x.readonly(i)),e.default!==void 0&&(i=i.default(e.default));let t={},n=["$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor"];for(let u of n)u in e&&(t[u]=e[u]);let a=["contentEncoding","contentMediaType","contentSchema"];for(let u of a)u in e&&(t[u]=e[u]);if(e.type==="object"&&e.$ref===void 0){e.propertyNames!==void 0&&!Fr(e.propertyNames)&&(t.propertyNames=e.propertyNames);for(let u of["minProperties","maxProperties"])e[u]!==void 0&&(t[u]=e[u])}if(e.type==="array"&&e.$ref===void 0){e.contains!==void 0&&!Fr(e.contains)&&(t.contains=e.contains);for(let u of["uniqueItems","minContains","maxContains"])e[u]!==void 0&&(t[u]=e[u])}for(let u of Object.keys(e))Jy.has(u)||X(t,u,e[u]);return Object.keys(t).length>0&&r.registry.add(i,t),e.description&&(i=i.describe(e.description)),i}function Fp(e,r){if(typeof e=="boolean")return e?x.any():x.never();let i;try{i=JSON.parse(JSON.stringify(e))}catch{throw new Error("fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas")}let o=By(i,r?.defaultTarget),t=i.$defs||i.definitions||{},n={version:o,defs:t,refs:new Map,processing:new Set,rootSchema:i,registry:r?.registry??G};return te(i,n)}var Jp=Symbol("z.visit/resolving");function Jr(e,r){let i=typeof r=="function"?r:(a,u)=>{let c=r[a._zod.def.type];return c?c(a,u):a},o=new Map;function t(a){let u=o.get(a);if(u===Jp)return new hr({type:"lazy",getter:()=>o.get(a)});if(u!==void 0)return u;o.set(a,Jp);let c=n(a),s=i(c,c!==a);return o.set(a,s),s}function n(a){let u=a._zod.def,c=u.type;switch(c){case"object":{let s=u.shape,l=Object.keys(s),d=!1,f={};for(let v of l){let _=t(s[v]);_!==s[v]&&(d=!0),f[v]=_}let m=u.catchall;return u.catchall&&(m=t(u.catchall),m!==u.catchall&&(d=!0)),d?C(a,{...u,shape:f,catchall:m}):a}case"array":{let s=t(u.element);return s===u.element?a:C(a,{...u,element:s})}case"tuple":{let s=u.items,l=!1,d=[];for(let m of s){let v=t(m);v!==m&&(l=!0),d.push(v)}let f=u.rest;return u.rest&&(f=t(u.rest),f!==u.rest&&(l=!0)),l?C(a,{...u,items:d,rest:f}):a}case"record":case"map":{let s=t(u.keyType),l=t(u.valueType);return s===u.keyType&&l===u.valueType?a:C(a,{...u,keyType:s,valueType:l})}case"set":{let s=t(u.valueType);return s===u.valueType?a:C(a,{...u,valueType:s})}case"union":{let s=u.options,l=!1,d=[];for(let f of s){let m=t(f);m!==f&&(l=!0),d.push(m)}return l?C(a,{...u,options:d}):a}case"intersection":{let s=t(u.left),l=t(u.right);return s===u.left&&l===u.right?a:C(a,{...u,left:s,right:l})}case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":{let s=t(u.innerType);return s===u.innerType?a:C(a,{...u,innerType:s})}case"pipe":{let s=t(u.in),l=t(u.out);return s===u.in&&l===u.out?a:C(a,{...u,in:s,out:l})}case"function":{let s=t(u.input),l=t(u.output);return s===u.input&&l===u.output?a:C(a,{...u,input:s,output:l})}case"lazy":{let s=u.getter,{_cachedInner:l,...d}=u;return C(a,{...d,getter:()=>t(s())})}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":return a;default:return a}}return t(e)}function Bp(e){return Jr(e,{object:r=>r.partial(),union:r=>{let i=r._zod.def;return i.discriminator===void 0?r:Mt(i.options)}})}function Qy(e,r){if(!r?.length)return e;let i=e._zod.def;return C(e,fe(i,{checks:[...i.checks??[],...r]}),{parent:!0})}function Kp(e){return Qy(e.out,e.checks)}function e_(e){return e.in._zod.traits.has("$ZodTransform")?Kp(e):e.in}function Xp(e){return Jr(e,{pipe:r=>e_(r._zod.def),default:(r,i)=>i?Qe(r._zod.def.innerType):r,catch:(r,i)=>i?r._zod.def.innerType:r})}function Gp(e){return Jr(e,{pipe:r=>Kp(r._zod.def),prefault:(r,i)=>i?r._zod.def.innerType:r})}var jl={};ge(jl,{bigint:()=>i_,boolean:()=>n_,date:()=>o_,number:()=>r_,string:()=>t_});function t_(e){return ec(Et,e)}function r_(e){return ac(Lt,e)}function n_(e){return mc(Vt,e)}function i_(e){return gc(Rt,e)}function o_(e){return Sc(Ar,e)}var Ul=O.object({valueState:O.string().min(1),value:O.number().optional(),UoM:O.string().optional(),valueToShow:O.string().optional(),UoMToShow:O.string().optional(),range:O.tuple([O.number(),O.number()]).optional()}).passthrough(),Wp=O.object({id:O.string().min(1),name:O.string(),model:O.string(),typeCode:O.string(),serialNo:O.string(),sensorState:O.string().min(1),sensorPod:O.object({typeCode:O.string(),model:O.string()}).passthrough().optional(),measuringModeCode:O.number().int().optional(),statusInfo:O.number().int().optional(),mainValue:Ul.optional(),subValue:Ul.optional()}).passthrough(),qp=O.object({id:O.number().int(),timestamp:O.number().int().nonnegative(),code:O.string(),type:O.string(),typeCode:O.string(),serialNo:O.string(),dw1:O.number(),dw2:O.number()}).passthrough(),Al=O.object({webServer:O.string(),payloadType:O.literal("livedata"),payloadVersion:O.string(),controllerTime:O.number().int().nonnegative(),controllerType:O.string(),controllerSerial:O.string().min(1),controllerName:O.string(),controllerSW:O.string(),sensors:O.array(Wp),notifications:O.array(qp)}).passthrough();function a_(e){return e==="INACTIVE"?0:e==="MEASURING"?1:e==="MAINTENANCE"?2:e==="ERROR"?3:-1}function u_(e){return e==="VALID"?0:e==="OFL"?1:e==="INVALID"?2:e==="MISSING"?3:-1}function Tl(...e){return e.map(r=>encodeURIComponent(String(r))).join(":")}function c_(e,r,i,o){return{...e,sensorId:r.id,id:r.id,name:r.name,model:r.model,typeCode:r.typeCode,serialNo:r.serialNo,...r.sensorPod===void 0?{}:{sensorPodTypeCode:r.sensorPod.typeCode,sensorPodModel:r.sensorPod.model},measuringModeCode:r.measuringModeCode,statusInfo:r.statusInfo,valueKind:i,valueState:o.valueState,valueStateCode:u_(o.valueState),value:o.value,...o.UoM===void 0?{}:{unit:o.UoM},...o.valueToShow===void 0?{}:{valueToShow:o.valueToShow},...o.UoMToShow===void 0?{}:{unitToShow:o.UoMToShow},...o.range===void 0?{}:{range:o.range}}}function s_(e,r){let{value:i,valueToShow:o,unitToShow:t,valueState:n,valueStateCode:a,...u}=e;return{...u,valueIdentity:Tl(e.controllerSerial,e.sensorId,e.valueKind),controllerTimestamp:r}}function l_(e){try{let r=new URL(e);return r.username="",r.password="",r.search="",r.hash="",r.toString()}catch{return/^(?:[a-z][a-z\d+.-]*:\/\/|\/\/)/i.test(e)||/[?#]/.test(e)||/(?:^|[/?#])[^\s:@]+:[^\s@]+@/.test(e)||/(?:token|secret|password|authorization)\s*[:=]/i.test(e)?"[redacted]":e}}function ro(e,r){let i={webServer:l_(r.webServer),payloadType:r.payloadType,payloadVersion:r.payloadVersion,controllerType:r.controllerType,controllerSerial:r.controllerSerial,controllerName:r.controllerName,controllerSW:r.controllerSW},o=new Date(r.controllerTime*1e3),t=r.sensors.map(a=>({...i,sensorId:a.id,sensorIdentity:Tl(r.controllerSerial,a.id),id:a.id,name:a.name,model:a.model,typeCode:a.typeCode,serialNo:a.serialNo,...a.sensorPod===void 0?{}:{sensorPodTypeCode:a.sensorPod.typeCode,sensorPodModel:a.sensorPod.model},...a.measuringModeCode===void 0?{}:{measuringModeCode:a.measuringModeCode},...a.statusInfo===void 0?{}:{statusInfo:a.statusInfo}})),n=r.sensors.flatMap(a=>["main","sub"].flatMap(u=>{let c=u==="main"?a.mainValue:a.subValue;return c===void 0?[]:[c_(i,a,u,c)]}));return{timestamp:o,controllers:[{...i,lastSeenAt:o}],sensors:t,values:n.map(a=>s_(a,r.controllerTime)),sensorStatuses:r.sensors.map(a=>({...i,sensorId:a.id,id:a.id,name:a.name,model:a.model,typeCode:a.typeCode,serialNo:a.serialNo,sensorState:a.sensorState,state:a_(a.sensorState),...a.sensorPod===void 0?{}:{sensorPod:{typeCode:a.sensorPod.typeCode,model:a.sensorPod.model}},...a.measuringModeCode===void 0?{}:{measuringModeCode:a.measuringModeCode},...a.statusInfo===void 0?{}:{statusInfo:a.statusInfo}})),measurements:n,notifications:r.notifications.map(a=>({...i,id:a.id,timestamp:new Date(a.timestamp*1e3),code:a.code,type:a.type,typeCode:a.typeCode,serialNo:a.serialNo,dw1:a.dw1,dw2:a.dw2,notificationIdentity:Tl(r.controllerSerial,a.id)}))}}var Cl="controllers",Zl="sensors",no="measurement_points",El="notifications",Ll="sensor_status",Vl="connector_status";var Hp="/api/v1/livedata",Br=class{#t;#e;#r=!1;constructor(r,i){this.#t=r,this.#e=i}get name(){return`xylem-controller-${this.#e.id}`}async onRun(){if(this.#r){this.#t.logger.error({controllerId:this.#e.id,error:{message:"Xylem poll already running"}});return}this.#r=!0;let r=Date.now(),i;try{let o=Wl(this.#t.httpClient({baseUrl:this.#e.baseUrl,timeout:this.#e.timeoutMs}),this.#e.username,this.#e.password,this.#t.logger);this.#t.logger.verbose("[Xylem Digest] Starting poll request",{controllerId:this.#e.id,method:"GET",url:new URL(this.#s()).pathname,timeoutMs:this.#e.timeoutMs});let t=await o.get(this.#s());i=t.status,await this.#l(t.data,r)}catch(o){i===void 0&&typeof o=="object"&&o!==null&&"status"in o&&typeof o.status=="number"&&(i=o.status);let t=`Unable to poll Xylem connector ${this.#e.id}, http status: ${i??"unknown"}`;await this.#i(t,r)}finally{this.#r=!1}}async#l(r,i){let o;try{o=Al.parse(r)}catch(t){await this.#i(t instanceof Error?t.message:String(t),i);return}try{let t=ro(this.#e,o);await this.#n(t.controllers.map(n=>({...n,controllerIdentity:n.controllerSerial})),Cl,"controllerIdentity"),await this.#n(t.sensors,Zl,"sensorIdentity"),await this.#n(t.values,no,"valueIdentity"),await this.#n(t.notifications,El,"notificationIdentity"),t.sensorStatuses.forEach(n=>{n.state===-1&&this.#t.logger.warn({controllerId:this.#e.id,sensorId:n.sensorId,rawState:n.sensorState})}),await this.#c(t.measurements,no,["value","valueState","valueStateCode"]),await this.#c(t.sensorStatuses,Ll,["state_code","sensorState"],["state","sensorState"]),await this.#u({controllerSerial:o.controllerSerial,controllerTime:o.controllerTime,status:"success",state:1,duration:Date.now()-i})}catch{await this.#i("Unable to ingest Xylem payload",i)}}async#i(r,i){this.#t.logger.error({controllerId:this.#e.id,error:{message:r}});try{await this.#u({status:"failure",state:0,duration:Date.now()-i,error:r})}catch{this.#t.logger.error({controllerId:this.#e.id,error:{message:r}})}}async#u(r,i){let{state:o,duration:t,controllerTime:n,...a}=r;this.#o(await this.#t.sender.metrics([{state_code:o,duration:t,...n===void 0?{}:{controllerTime:n}}],{collection:this.#a(Vl),...a},i===void 0?void 0:{timestamp:i}))}async#c(r,i,o,t=o,n=t,a){(await Promise.all(r.map(async c=>{let s=Object.fromEntries(o.map((d,f)=>[d,c[t[f]]])),l=Object.fromEntries(Object.entries(c).filter(([d])=>!n.includes(d)));return this.#t.sender.metrics([s],{collection:this.#a(i),...l},a===void 0?void 0:{timestamp:a})}))).forEach(c=>this.#o(c))}async#n(r,i,o,t){this.#o(await this.#t.sender.documents(r,{collection:this.#a(i),keyField:o},t===void 0?void 0:{timestamp:t}))}#o(r){if(r===!1||typeof r=="object"&&Object.values(r).some(i=>!i))throw new Error("Xylem metric send failed")}#a(r){return`${this.#t.config.datasourceIdentifier}_${r}`}#s(){let r=this.#e.endpoint??Hp;return new URL(r,this.#e.baseUrl).toString()}};var Rl=class extends Xr{init=async()=>{await Promise.all(this.connectorSDK.config.controllers.map(r=>this.connectorSDK.processing.registerInterval(r.intervalSeconds,new Br(this.connectorSDK,r),{immediate:!0})))}};0&&(module.exports={ConnectorRunnerXylem,DEFAULT_XYLEM_ENDPOINT,XYLEM_CONNECTOR_STATUS_COLLECTION,XYLEM_CONTROLLERS_COLLECTION,XYLEM_MEASUREMENT_POINTS_COLLECTION,XYLEM_NOTIFICATIONS_COLLECTION,XYLEM_SENSORS_COLLECTION,XYLEM_SENSOR_STATUS_COLLECTION,XylemControllerPoller,XylemLiveDataSchema,XylemNotificationSchema,XylemSensorSchema,XylemValueSchema,normalizeXylemLiveData});
63
63
  //# sourceMappingURL=index.cjs.map