@miravo/cli-linux-arm64-musl 0.10.0 → 0.11.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/console-dist/assets/{AnimatePresence-BZCmb1bq.js → AnimatePresence-BSSlw02V.js} +3 -3
- package/console-dist/assets/{activity-Cn48I9qe.js → activity-Cy_niK56.js} +1 -1
- package/console-dist/assets/{api-kPM52mb-.js → api-B2QJEzbS.js} +1 -1
- package/console-dist/assets/api-Vq4lny_H.js +1 -0
- package/console-dist/assets/arrow-up-right-CwPw_2U1.js +1 -0
- package/console-dist/assets/asset-detail-E-TllNHT.js +1 -0
- package/console-dist/assets/asset-detail-actions-jjbvaDES.js +1 -0
- package/console-dist/assets/asset-panel-DDziFlFl.js +1 -0
- package/console-dist/assets/{auth-screen-backdrop-hcEYy3K4.js → auth-screen-backdrop-CEykEbfF.js} +1 -1
- package/console-dist/assets/backup-power-BDMAO2bO.js +1 -0
- package/console-dist/assets/badge-Bk1DaL6C.js +1 -0
- package/console-dist/assets/boiler-CWAR1Nq2.js +1 -0
- package/console-dist/assets/by-path-VBqTBdlG.js +1 -0
- package/console-dist/assets/catalog-BlkPPAWE.js +1 -0
- package/console-dist/assets/catalog-CQopEu5C.js +1 -0
- package/console-dist/assets/{catalog-source-2aT9qob-.js → catalog-source-B4L5N-a1.js} +1 -1
- package/console-dist/assets/catalog-template-icons-BOSywIKV.js +1 -0
- package/console-dist/assets/check-B-yvIfMj.js +1 -0
- package/console-dist/assets/checkbox-DEAkDfFr.js +1 -0
- package/console-dist/assets/chevron-down-x70Pto6j.js +1 -0
- package/console-dist/assets/chevron-left-XHFooLn1.js +1 -0
- package/console-dist/assets/chevron-right-CMSQPSEo.js +1 -0
- package/console-dist/assets/chiller-BSx8eUMN.js +1 -0
- package/console-dist/assets/{circle-x-CGcRflg7.js → circle-x-_o0nl0Rg.js} +1 -1
- package/console-dist/assets/combobox-B8h0-NHs.js +1 -0
- package/console-dist/assets/commercial-building-CNvi6IZK.js +1 -0
- package/console-dist/assets/compressor-D63w6Ir2.js +1 -0
- package/console-dist/assets/console-panel-CMDoBJiO.js +1 -0
- package/console-dist/assets/control-CBviLxJB.js +1 -0
- package/console-dist/assets/control-jNqzZWa9.js +1 -0
- package/console-dist/assets/copy-button-CSUP1VjU.js +1 -0
- package/console-dist/assets/{dialog-Di9Bs0FH.js → dialog-B5PqrKVw.js} +1 -1
- package/console-dist/assets/district-heating-Cr4CrgCA.js +1 -0
- package/console-dist/assets/dom-Cm_OH5jc.js +1 -0
- package/console-dist/assets/{download-B9e1wNK4.js → download-i8CTJ7oi.js} +1 -1
- package/console-dist/assets/{local-flag-CPAqDO-L.js → dropdown-menu-B_MMNbTy.js} +1 -1
- package/console-dist/assets/events-D531_1EZ.js +1 -0
- package/console-dist/assets/events-RmbRTKFV.js +1 -0
- package/console-dist/assets/events-format-C5HTkIsC.js +1 -0
- package/console-dist/assets/export-tab-fZDO4r2u.js +1 -0
- package/console-dist/assets/factory-C2OucdpQ.js +1 -0
- package/console-dist/assets/factory-CgSIjU5V.js +1 -0
- package/console-dist/assets/factory-DLE12zAd.js +1 -0
- package/console-dist/assets/floor-page-D0mX5OuA.js +1 -0
- package/console-dist/assets/floor-page-E-0txA4z.css +1 -0
- package/console-dist/assets/format-Bx7DF-TB.js +1 -0
- package/console-dist/assets/genset-BRgqR1AT.js +1 -0
- package/console-dist/assets/{get-error-message-eGdenTLv.js → get-error-message-dM0BMfdP.js} +1 -1
- package/console-dist/assets/index-CrLa65Ur.css +2 -0
- package/console-dist/assets/index-CvuwOe37.js +12 -0
- package/console-dist/assets/{integration-api-Bg7D1eQc.js → integration-api-D2tA69Yb.js} +1 -1
- package/console-dist/assets/integrations-BLG4PT3c.js +1 -0
- package/console-dist/assets/integrations-iAjWxaDS.js +1 -0
- package/console-dist/assets/{label-DWyy9MeT.js → label-2sIXTEUK.js} +1 -1
- package/console-dist/assets/loader-circle-DjgHgHHl.js +1 -0
- package/console-dist/assets/{login-BZKYK0yZ.js → login-DpNKicxy.js} +1 -1
- package/console-dist/assets/minus-CaT9UaQx.js +1 -0
- package/console-dist/assets/model-schemas-3w38IPdc.js +1 -0
- package/console-dist/assets/models-CMN9Eppf.js +1 -0
- package/console-dist/assets/models-I_V8J5Y0.js +1 -0
- package/console-dist/assets/not-found-C4YVKP97.js +1 -0
- package/console-dist/assets/pause-CqW7v5Dc.js +1 -0
- package/console-dist/assets/pharma-cleanroom-ClJRwROz.js +1 -0
- package/console-dist/assets/play-kg50os4l.js +1 -0
- package/console-dist/assets/plus-Cl4Ay5Ry.js +1 -0
- package/console-dist/assets/protocol-card-ARSwIjkN.js +1 -0
- package/console-dist/assets/proxy-CWZabK8f.js +1 -0
- package/console-dist/assets/query-fetch-error-CWLZA2L5.js +1 -0
- package/console-dist/assets/{radio-DRkzblxj.js → radio-BxpVYiyS.js} +1 -1
- package/console-dist/assets/registry-Dau_GjK6.js +2 -0
- package/console-dist/assets/{rocket-807Pf7C1.js → rocket-KZ5oHK1G.js} +1 -1
- package/console-dist/assets/rtu-D-1lltcO.js +1 -0
- package/console-dist/assets/select-BWlrSYlA.js +1 -0
- package/console-dist/assets/{select-display-items-D-L3PesO.js → select-display-items-DN2G8DNG.js} +1 -1
- package/console-dist/assets/{server-CS2Tw__K.js → server-BVem_egD.js} +1 -1
- package/console-dist/assets/sliders-horizontal-BNKmYQgd.js +1 -0
- package/console-dist/assets/smart-factory-cem4tLAv.js +1 -0
- package/console-dist/assets/{source-host-miravo-D_AecPVc.js → source-host-miravo-B8eM2IHw.js} +1 -1
- package/console-dist/assets/stages-hidkaJPI.js +1 -0
- package/console-dist/assets/status-CZFZLqVk.js +1 -0
- package/console-dist/assets/tabs-BbQkzBZZ.js +1 -0
- package/console-dist/assets/tags-BBz30-eV.js +4 -0
- package/console-dist/assets/tags-K96jT8PY.js +1 -0
- package/console-dist/assets/tank-THHXGdzg.js +1 -0
- package/console-dist/assets/tooltip-B3vOB1Vu.js +1 -0
- package/console-dist/assets/{transition-nav-link-cn4KZD6W.js → transition-nav-link-B11-gXld.js} +1 -1
- package/console-dist/assets/{trash-2-BJ-1df0F.js → trash-2-BH9HDsZv.js} +1 -1
- package/console-dist/assets/{triangle-alert-D1AraFcP.js → triangle-alert-DoAwrRgk.js} +1 -1
- package/console-dist/assets/use-engine-command-mutation-CHqjOqfS.js +1 -0
- package/console-dist/assets/use-transition-navigate-B-nk4aWh.js +2 -0
- package/console-dist/assets/useQuery-M9KTdi7Q.js +1 -0
- package/console-dist/assets/validation-BkfmaBBi.js +1 -0
- package/console-dist/assets/water-treatment-CfVR0p0L.js +1 -0
- package/console-dist/index.html +68 -54
- package/miravo +2 -2
- package/package.json +1 -1
- package/console-dist/assets/api-DybIIqOe.js +0 -1
- package/console-dist/assets/asset-detail-tmOrYE8x.js +0 -1
- package/console-dist/assets/badge-D4jktT8T.js +0 -1
- package/console-dist/assets/catalog-DN-klsod.js +0 -1
- package/console-dist/assets/catalog-M-k7Y9Sp.js +0 -1
- package/console-dist/assets/catalog-template-icons-C7KJdJJX.js +0 -1
- package/console-dist/assets/checkbox-AaJhjtZk.js +0 -1
- package/console-dist/assets/chevron-down-CAk5w9Wt.js +0 -1
- package/console-dist/assets/chevron-right-BfZjrUWh.js +0 -1
- package/console-dist/assets/combobox-BFEY6lgO.js +0 -1
- package/console-dist/assets/control-CD9UoTvu.js +0 -1
- package/console-dist/assets/control-DHa2-a2v.js +0 -1
- package/console-dist/assets/copy-button-DHm7RGJ5.js +0 -1
- package/console-dist/assets/events-D19CzgoQ.js +0 -1
- package/console-dist/assets/events-DmftG8n5.js +0 -1
- package/console-dist/assets/export-tab-ouFgYEU_.js +0 -1
- package/console-dist/assets/factory-CT2VYi0n.js +0 -1
- package/console-dist/assets/factory-DSrBtcG2.js +0 -1
- package/console-dist/assets/format-OUFL_tef.js +0 -1
- package/console-dist/assets/index-DuJJSpJp.js +0 -12
- package/console-dist/assets/index-iEV9hU2I.css +0 -2
- package/console-dist/assets/integrations-DWW9HjH0.js +0 -1
- package/console-dist/assets/integrations-DoXNrzD5.js +0 -1
- package/console-dist/assets/models-CrDBHBV5.js +0 -1
- package/console-dist/assets/models-jBVcY8Xd.js +0 -1
- package/console-dist/assets/not-found-BqVny4Md.js +0 -1
- package/console-dist/assets/play-TTg_EXSa.js +0 -1
- package/console-dist/assets/plus-BbVbvFTe.js +0 -1
- package/console-dist/assets/protocol-card-B2SpAJKe.js +0 -1
- package/console-dist/assets/query-fetch-error-C2Ec4RQS.js +0 -1
- package/console-dist/assets/select-Bg6PPro0.js +0 -1
- package/console-dist/assets/tabs-bI9sskHy.js +0 -1
- package/console-dist/assets/tags-B7e7VYVW.js +0 -1
- package/console-dist/assets/tags-DJJKQRZZ.js +0 -4
- package/console-dist/assets/use-engine-command-mutation-DMkQxmt9.js +0 -1
- package/console-dist/assets/use-transition-navigate-BiV2QCcA.js +0 -2
- package/console-dist/assets/validation-q38DYDwu.js +0 -1
- /package/console-dist/assets/{chunk-OE4NN4TA-Q4iNR9l9.js → chunk-OE4NN4TA-DBWZidbW.js} +0 -0
- /package/console-dist/assets/{dist-CtuJWBnP.js → dist-xY0pK9Wy.js} +0 -0
- /package/console-dist/assets/{integration-targets-BehiqWyT.js → integration-targets-Byvdd3Or.js} +0 -0
- /package/console-dist/assets/{runtime-link-ChF8TM68.js → runtime-link-vBANRqcD.js} +0 -0
- /package/console-dist/assets/{transition-types-049V0Kr0.js → transition-types-BKZuWApE.js} +0 -0
- /package/console-dist/assets/{utils-BO2u-wC_.js → utils-XFKvwlFT.js} +0 -0
- /package/console-dist/assets/{vendor-table-Br-cHaxY.js → vendor-table-B0Z9e_sn.js} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,r as t}from"./rolldown-runtime-COnpUsM8.js";import{c as n}from"./vendor-charts-95ykyDlI.js";var r=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},i=new class extends r{#e;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e();return window.addEventListener(`visibilitychange`,t,!1),()=>{window.removeEventListener(`visibilitychange`,t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(e=>{typeof e==`boolean`?this.setFocused(e):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e==`boolean`?this.#e:globalThis.document?.visibilityState!==`hidden`}},a={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},o=new class{#e=a;setTimeoutProvider(e){this.#e=e}setTimeout(e,t){return this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}};function s(e){setTimeout(e,0)}var c=typeof window>`u`||`Deno`in globalThis;function l(){}function u(e,t){return typeof e==`function`?e(t):e}function d(e){return typeof e==`number`&&e>=0&&e!==1/0}function f(e,t){return Math.max(e+(t||0)-Date.now(),0)}function p(e,t){return typeof e==`function`?e(t):e}function m(e,t){return typeof e==`function`?e(t):e}function ee(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==ne(o,t.options))return!1}else if(!ie(t.queryKey,o))return!1}if(n!==`all`){let e=t.isActive();if(n===`active`&&!e||n===`inactive`&&e)return!1}return!(typeof s==`boolean`&&t.isStale()!==s||i&&i!==t.state.fetchStatus||a&&!a(t))}function te(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(re(t.options.mutationKey)!==re(a))return!1}else if(!ie(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function ne(e,t){return(t?.queryKeyHashFn||re)(e)}function re(e){return JSON.stringify(e,(e,t)=>le(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function ie(e,t){return e===t?!0:typeof e==typeof t&&e&&t&&typeof e==`object`&&typeof t==`object`?Object.keys(t).every(n=>ie(e[n],t[n])):!1}var ae=Object.prototype.hasOwnProperty;function oe(e,t,n=0){if(e===t)return e;if(n>500)return t;let r=ce(e)&&ce(t);if(!r&&!(le(e)&&le(t)))return t;let i=(r?e:Object.keys(e)).length,a=r?t:Object.keys(t),o=a.length,s=r?Array(o):{},c=0;for(let l=0;l<o;l++){let o=r?l:a[l],u=e[o],d=t[o];if(u===d){s[o]=u,(r?l<i:ae.call(e,o))&&c++;continue}if(u===null||d===null||typeof u!=`object`||typeof d!=`object`){s[o]=d;continue}let f=oe(u,d,n+1);s[o]=f,f===u&&c++}return i===o&&c===i?e:s}function se(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function ce(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function le(e){if(!ue(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!ue(n)||!n.hasOwnProperty(`isPrototypeOf`)||Object.getPrototypeOf(e)!==Object.prototype)}function ue(e){return Object.prototype.toString.call(e)===`[object Object]`}function de(e){return new Promise(t=>{o.setTimeout(t,e)})}function fe(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:oe(e,t)}function pe(e){return e}function me(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function he(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var ge=Symbol();function _e(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===ge?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function ve(e,t){return typeof e==`function`?e(...t):!!e}function ye(e,t,n){let r=!1,i;return Object.defineProperty(e,`signal`,{enumerable:!0,get:()=>(i??=t(),r?i:(r=!0,i.aborted?n():i.addEventListener(`abort`,n,{once:!0}),i))}),e}var be=(()=>{let e=()=>c;return{isServer(){return e()},setIsServer(t){e=t}}})();function xe(){let e,t,n=new Promise((n,r)=>{e=n,t=r});n.status=`pending`,n.catch(()=>{});function r(e){Object.assign(n,e),delete n.resolve,delete n.reject}return n.resolve=t=>{r({status:`fulfilled`,value:t}),e(t)},n.reject=e=>{r({status:`rejected`,reason:e}),t(e)},n}function Se(e){let t;if(e.then(e=>(t=e,e),l)?.catch(l),t!==void 0)return{data:t}}function Ce(e){return e}function we(e){return{mutationKey:e.options.mutationKey,state:e.state,...e.options.scope&&{scope:e.options.scope},...e.meta&&{meta:e.meta}}}function Te(e,t,n){let r=()=>{let r=e.promise?.then(t).catch(e=>n(e)?Promise.reject(Error(`redacted`)):Promise.reject(e));return r?.catch(l),r};return{dehydratedAt:Date.now(),state:{...e.state,...e.state.data!==void 0&&{data:t(e.state.data)}},queryKey:e.queryKey,queryHash:e.queryHash,...e.state.status===`pending`&&{promise:r()},...e.meta&&{meta:e.meta}}}function Ee(e){return e.state.isPaused}function De(e){return e.state.status===`success`}function Oe(e){return!0}function ke(e,t={}){let n=t.shouldDehydrateMutation??e.getDefaultOptions().dehydrate?.shouldDehydrateMutation??Ee,r=e.getMutationCache().getAll().flatMap(e=>n(e)?[we(e)]:[]),i=t.shouldDehydrateQuery??e.getDefaultOptions().dehydrate?.shouldDehydrateQuery??De,a=t.shouldRedactErrors??e.getDefaultOptions().dehydrate?.shouldRedactErrors??Oe,o=t.serializeData??e.getDefaultOptions().dehydrate?.serializeData??Ce;return{mutations:r,queries:e.getQueryCache().getAll().flatMap(e=>i(e)?[Te(e,o,a)]:[])}}function Ae(e,t,n){if(typeof t!=`object`||!t)return;let r=e.getMutationCache(),i=e.getQueryCache(),a=n?.defaultOptions?.deserializeData??e.getDefaultOptions().hydrate?.deserializeData??Ce,o=t.mutations||[],s=t.queries||[];o.forEach(({state:t,...i})=>{r.build(e,{...e.getDefaultOptions().hydrate?.mutations,...n?.defaultOptions?.mutations,...i},t)}),s.forEach(({queryKey:t,state:r,queryHash:o,meta:s,promise:c,dehydratedAt:u})=>{let d=c?Se(c):void 0,f=r.data===void 0?d?.data:r.data,p=f===void 0?f:a(f),m=i.get(o),ee=m?.state.status===`pending`,te=m?.state.fetchStatus===`fetching`;if(m){let e=d&&u!==void 0&&u>m.state.dataUpdatedAt;if(r.dataUpdatedAt>m.state.dataUpdatedAt||e){let{fetchStatus:e,...t}=r;m.setState({...t,data:p})}}else m=i.build(e,{...e.getDefaultOptions().hydrate?.queries,...n?.defaultOptions?.queries,queryKey:t,queryHash:o,meta:s},{...r,data:p,fetchStatus:`idle`,status:p===void 0?r.status:`success`});c&&!ee&&!te&&(u===void 0||u>m.state.dataUpdatedAt)&&m.fetch(void 0,{initialPromise:Promise.resolve(c).then(a)}).catch(l)})}var je=s;function Me(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=je,a=r=>{t?e.push(r):i(()=>{n(r)})},o=()=>{let t=e;e=[],t.length&&i(()=>{r(()=>{t.forEach(e=>{n(e)})})})};return{batch:e=>{let n;t++;try{n=e()}finally{t--,t||o()}return n},batchCalls:e=>(...t)=>{a(()=>{e(...t)})},schedule:a,setNotifyFunction:e=>{n=e},setBatchNotifyFunction:e=>{r=e},setScheduler:e=>{i=e}}}var h=Me(),Ne=new class extends r{#e=!0;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e(!0),n=()=>e(!1);return window.addEventListener(`online`,t,!1),window.addEventListener(`offline`,n,!1),()=>{window.removeEventListener(`online`,t),window.removeEventListener(`offline`,n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(t=>{t(e)}))}isOnline(){return this.#e}};function Pe(e){return Math.min(1e3*2**e,3e4)}function Fe(e){return(e??`online`)===`online`?Ne.isOnline():!0}var Ie=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function Le(e){let t=!1,n=0,r,a=xe(),o=()=>a.status!==`pending`,s=t=>{if(!o()){let n=new Ie(t);p(n),e.onCancel?.(n)}},c=()=>{t=!0},l=()=>{t=!1},u=()=>i.isFocused()&&(e.networkMode===`always`||Ne.isOnline())&&e.canRun(),d=()=>Fe(e.networkMode)&&e.canRun(),f=e=>{o()||(r?.(),a.resolve(e))},p=e=>{o()||(r?.(),a.reject(e))},m=()=>new Promise(t=>{r=e=>{(o()||u())&&t(e)},e.onPause?.()}).then(()=>{r=void 0,o()||e.onContinue?.()}),ee=()=>{if(o())return;let r,i=n===0?e.initialPromise:void 0;try{r=i??e.fn()}catch(e){r=Promise.reject(e)}Promise.resolve(r).then(f).catch(r=>{if(o())return;let i=e.retry??(be.isServer()?0:3),a=e.retryDelay??Pe,s=typeof a==`function`?a(n,r):a,c=i===!0||typeof i==`number`&&n<i||typeof i==`function`&&i(n,r);if(t||!c){p(r);return}n++,e.onFail?.(n,r),de(s).then(()=>u()?void 0:m()).then(()=>{t?p(r):ee()})})};return{promise:a,status:()=>a.status,cancel:s,continue:()=>(r?.(),a),cancelRetry:c,continueRetry:l,canStart:d,start:()=>(d()?ee():m().then(ee),a)}}var Re=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),d(this.gcTime)&&(this.#e=o.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(be.isServer()?1/0:300*1e3))}clearGcTimeout(){this.#e!==void 0&&(o.clearTimeout(this.#e),this.#e=void 0)}},ze=class extends Re{#e;#t;#n;#r;#i;#a;#o;constructor(e){super(),this.#o=!1,this.#a=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#r=e.client,this.#n=this.#r.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#e=He(this.options),this.state=e.state??this.#e,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#i?.promise}setOptions(e){if(this.options={...this.#a,...e},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let e=He(this.options);e.data!==void 0&&(this.setState(Ve(e.data,e.dataUpdatedAt)),this.#e=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus===`idle`&&this.#n.remove(this)}setData(e,t){let n=fe(this.state.data,e,this.options);return this.#c({data:n,type:`success`,dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e,t){this.#c({type:`setState`,state:e,setStateOptions:t})}cancel(e){let t=this.#i?.promise;return this.#i?.cancel(e),t?t.then(l).catch(l):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#e}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>m(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===ge||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>p(e.options.staleTime,this)===`static`):!1}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e===`static`?!1:this.state.isInvalidated?!0:!f(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#i?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#i?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#i&&(this.#o||this.#s()?this.#i.cancel({revert:!0}):this.#i.cancelRetry()),this.scheduleGc()),this.#n.notify({type:`observerRemoved`,query:this,observer:e}))}getObserversCount(){return this.observers.length}#s(){return this.state.fetchStatus===`paused`&&this.state.status===`pending`}invalidate(){this.state.isInvalidated||this.#c({type:`invalidate`})}async fetch(e,t){if(this.state.fetchStatus!==`idle`&&this.#i?.status()!==`rejected`){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#i)return this.#i.continueRetry(),this.#i.promise}if(e&&this.setOptions(e),!this.options.queryFn){let e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}let n=new AbortController,r=e=>{Object.defineProperty(e,`signal`,{enumerable:!0,get:()=>(this.#o=!0,n.signal)})},i=()=>{let e=_e(this.options,t),n=(()=>{let e={client:this.#r,queryKey:this.queryKey,meta:this.meta};return r(e),e})();return this.#o=!1,this.options.persister?this.options.persister(e,n,this):e(n)},a=(()=>{let e={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#r,state:this.state,fetchFn:i};return r(e),e})();this.options.behavior?.onFetch(a,this),this.#t=this.state,(this.state.fetchStatus===`idle`||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#c({type:`fetch`,meta:a.fetchOptions?.meta}),this.#i=Le({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:e=>{e instanceof Ie&&e.revert&&this.setState({...this.#t,fetchStatus:`idle`}),n.abort()},onFail:(e,t)=>{this.#c({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#c({type:`pause`})},onContinue:()=>{this.#c({type:`continue`})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0});try{let e=await this.#i.start();if(e===void 0)throw Error(`${this.queryHash} data is undefined`);return this.setData(e),this.#n.config.onSuccess?.(e,this),this.#n.config.onSettled?.(e,this.state.error,this),e}catch(e){if(e instanceof Ie){if(e.silent)return this.#i.promise;if(e.revert){if(this.state.data===void 0)throw e;return this.state.data}}throw this.#c({type:`error`,error:e}),this.#n.config.onError?.(e,this),this.#n.config.onSettled?.(this.state.data,e,this),e}finally{this.scheduleGc()}}#c(e){this.state=(t=>{switch(e.type){case`failed`:return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case`pause`:return{...t,fetchStatus:`paused`};case`continue`:return{...t,fetchStatus:`fetching`};case`fetch`:return{...t,...Be(t.data,this.options),fetchMeta:e.meta??null};case`success`:let n={...t,...Ve(e.data,e.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!e.manual&&{fetchStatus:`idle`,fetchFailureCount:0,fetchFailureReason:null}};return this.#t=e.manual?n:void 0,n;case`error`:let r=e.error;return{...t,error:r,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:`idle`,status:`error`,isInvalidated:!0};case`invalidate`:return{...t,isInvalidated:!0};case`setState`:return{...t,...e.state}}})(this.state),h.batch(()=>{this.observers.forEach(e=>{e.onQueryUpdate()}),this.#n.notify({query:this,type:`updated`,action:e})})}};function Be(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Fe(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function Ve(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:`success`}}function He(e){let t=typeof e.initialData==`function`?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt==`function`?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?`success`:`pending`,fetchStatus:`idle`}}function Ue(e){return{onFetch:(t,n)=>{let r=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,a=t.state.data?.pages||[],o=t.state.data?.pageParams||[],s={pages:[],pageParams:[]},c=0,l=async()=>{let n=!1,l=e=>{ye(e,()=>t.signal,()=>n=!0)},u=_e(t.options,t.fetchOptions),d=async(e,r,i)=>{if(n)return Promise.reject();if(r==null&&e.pages.length)return Promise.resolve(e);let a=await u((()=>{let e={client:t.client,queryKey:t.queryKey,pageParam:r,direction:i?`backward`:`forward`,meta:t.options.meta};return l(e),e})()),{maxPages:o}=t.options,s=i?he:me;return{pages:s(e.pages,a,o),pageParams:s(e.pageParams,r,o)}};if(i&&a.length){let e=i===`backward`,t=e?Ge:We,n={pages:a,pageParams:o};s=await d(n,t(r,n),e)}else{let t=e??a.length;do{let e=c===0?o[0]??r.initialPageParam:We(r,s);if(c>0&&e==null)break;s=await d(s,e),c++}while(c<t)}return s};t.options.persister?t.fetchFn=()=>t.options.persister?.(l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):t.fetchFn=l}}}function We(e,{pages:t,pageParams:n}){let r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function Ge(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}function Ke(e,t){return t?We(e,t)!=null:!1}function qe(e,t){return!t||!e.getPreviousPageParam?!1:Ge(e,t)!=null}var Je=class extends Re{#e;#t;#n;#r;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||Ye(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:`observerRemoved`,mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status===`pending`?this.scheduleGc():this.#n.remove(this))}continue(){return this.#r?.continue()??this.execute(this.state.variables)}async execute(e){let t=()=>{this.#i({type:`continue`})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#r=Le({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(Error(`No mutationFn found`)),onFail:(e,t)=>{this.#i({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#i({type:`pause`})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)});let r=this.state.status===`pending`,i=!this.#r.canStart();try{if(r)t();else{this.#i({type:`pending`,variables:e,isPaused:i}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);let t=await this.options.onMutate?.(e,n);t!==this.state.context&&this.#i({type:`pending`,context:t,variables:e,isPaused:i})}let a=await this.#r.start();return await this.#n.config.onSuccess?.(a,e,this.state.context,this,n),await this.options.onSuccess?.(a,e,this.state.context,n),await this.#n.config.onSettled?.(a,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(a,null,e,this.state.context,n),this.#i({type:`success`,data:a}),a}catch(t){try{await this.#n.config.onError?.(t,e,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,n)}catch(e){Promise.reject(e)}try{await this.#n.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,n)}catch(e){Promise.reject(e)}throw this.#i({type:`error`,error:t}),t}finally{this.#n.runNext(this)}}#i(e){this.state=(t=>{switch(e.type){case`failed`:return{...t,failureCount:e.failureCount,failureReason:e.error};case`pause`:return{...t,isPaused:!0};case`continue`:return{...t,isPaused:!1};case`pending`:return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:`pending`,variables:e.variables,submittedAt:Date.now()};case`success`:return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:`success`,isPaused:!1};case`error`:return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:`error`}}})(this.state),h.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function Ye(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var Xe=class extends r{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}#e;#t;#n;build(e,t,n){let r=new Je({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=Ze(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=Ze(e);if(typeof t==`string`){let n=this.#t.get(t);if(n)if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=Ze(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}else return!0}runNext(e){let t=Ze(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){h.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>te(t,e))}findAll(e={}){return this.getAll().filter(t=>te(e,t))}notify(e){h.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return h.batch(()=>Promise.all(e.map(e=>e.continue().catch(l))))}};function Ze(e){return e.options.scope?.id}var Qe=class extends r{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,n){let r=t.queryKey,i=t.queryHash??ne(r,t),a=this.get(i);return a||(a=new ze({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){h.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>ee(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>ee(e,t)):t}notify(e){h.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){h.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){h.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},$e=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new Qe,this.#t=e.mutationCache||new Xe,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=i.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=Ne.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(p(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=u(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return h.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;h.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return h.batch(()=>(n.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,...e},t)))}cancelQueries(e,t={}){let n={revert:!0,...t},r=h.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(l).catch(l)}invalidateQueries(e,t={}){return h.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=h.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(l)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(l)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(p(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(l).catch(l)}fetchInfiniteQuery(e){return e.behavior=Ue(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(l).catch(l)}ensureInfiniteQueryData(e){return e.behavior=Ue(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return Ne.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(re(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{ie(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(re(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{ie(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=ne(t.queryKey,t),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===ge&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},et=e(n(),1),tt=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e))},o=t=e(r,i,a);return a},nt=(e=>e?tt(e):tt),rt=e=>e;function it(e,t=rt){let n=et.useSyncExternalStore(e.subscribe,et.useCallback(()=>t(e.getState()),[e,t]),et.useCallback(()=>t(e.getInitialState()),[e,t]));return et.useDebugValue(n),n}var at=e=>{let t=nt(e),n=e=>it(t,e);return Object.assign(n,t),n},ot=(e=>e?at(e):at),st=200,ct=60,lt=1e3,ut=`miravo:runtime-snapshot`;function dt(e){try{sessionStorage.setItem(ut,JSON.stringify(e))}catch{}}function ft(){try{sessionStorage.removeItem(ut)}catch{}}function pt(e){if(typeof e!=`object`||!e)return!1;let t=e;if(typeof t.revision!=`number`||typeof t.state!=`object`||t.state===null||typeof t.metrics!=`object`||t.metrics===null)return!1;let n=t.metrics;return typeof n.core!=`object`||n.core===null?!1:Array.isArray(t.templates)}function mt(){try{let e=sessionStorage.getItem(ut);if(!e)return null;let t=JSON.parse(e);return pt(t)?t:(ft(),null)}catch{return ft(),null}}function ht(e){let t=e.metrics.core.tickCount,n=e.metrics.core.actualTicksPerSecond,r=Date.now();return{connectionState:`live`,connectionStateSince:r,reconnectAttempts:0,fatalError:null,lastRevision:e.revision,factoryName:e.state.factoryName??e.metrics.factoryName??``,seed:e.state.config.seed,engineState:e.metrics.core.state,tick:t,simulationTime:e.metrics.core.simulationTimeSeconds,tickIntervalMs:e.state.config.tickIntervalMs,lastTickReceivedAt:r,assetCount:e.metrics.core.assetCount,memberValueCount:e.metrics.core.memberValueCount,quarantinedAssetCount:e.metrics.core.quarantinedAssetCount,engineErrorsCount:e.metrics.core.engineErrorsCount,tickOverrunsCount:e.metrics.core.tickOverrunsCount,circuitBreakerTripsCount:e.metrics.core.circuitBreakerTripsCount,tps:n,uptimeMs:e.metrics.core.uptimeMs,speedMultiplier:e.state.config.timeMultiplier,assets:[...e.state.assets],models:[...e.state.models],tpsHistory:[{tick:t,tps:n,sampledAtMs:r}],lines:[...e.state.lines??[]],templates:[...e.templates],bootTemplate:e.state.config.template,availableAdapters:e.state.availableAdapters??[],adapterMetrics:e.metrics.adapters??[],memberValues:new Map,events:[]}}function gt(e,t){return{connectionState:`live`,connectionStateSince:e.connectionState===`live`?e.connectionStateSince:t,reconnectAttempts:0,fatalError:null}}var _t=ot((e,t)=>({connectionState:`booting`,connectionStateSince:Date.now(),reconnectAttempts:0,fatalError:null,lastRevision:0,factoryName:``,seed:null,engineState:`idle`,tick:0,simulationTime:0,tickIntervalMs:1e3,lastTickReceivedAt:0,assetCount:0,memberValueCount:0,quarantinedAssetCount:0,engineErrorsCount:0,tickOverrunsCount:0,circuitBreakerTripsCount:0,tps:0,uptimeMs:0,speedMultiplier:1,assets:[],models:[],tpsHistory:[],lines:[],templates:[],bootTemplate:void 0,availableAdapters:[],adapterMetrics:[],memberValues:new Map,events:[],replaceRuntime:(n,r)=>{let i=t().lastRevision;i>0&&(n.revision<i&&!r?.allowRevisionRewind||n.revision===i&&!r?.allowSameRevision)||(e(()=>ht(n)),dt(n))},applyTick:n=>{let r=t();if(n.revision<=r.lastRevision)return;let i=n.delta??[],a=n.tick??r.tick,o=n.simulationTime??r.simulationTime,s=n.assetCount??r.assetCount,c=n.metrics.core.actualTicksPerSecond,l=Date.now();if(!(i.length>0||a!==r.tick||o!==r.simulationTime||s!==r.assetCount||n.metrics.adapters!==r.adapterMetrics||n.metrics.core.engineErrorsCount!==r.engineErrorsCount||n.metrics.core.tickOverrunsCount!==r.tickOverrunsCount||n.metrics.core.circuitBreakerTripsCount!==r.circuitBreakerTripsCount||n.metrics.core.memberValueCount!==r.memberValueCount||n.metrics.core.quarantinedAssetCount!==r.quarantinedAssetCount||c!==r.tps)){e({...gt(r,l),lastTickReceivedAt:l,lastRevision:n.revision});return}let u={...gt(r,l),tick:a,simulationTime:o,lastTickReceivedAt:l,assetCount:s,memberValueCount:n.metrics.core.memberValueCount,quarantinedAssetCount:n.metrics.core.quarantinedAssetCount,engineErrorsCount:n.metrics.core.engineErrorsCount,tickOverrunsCount:n.metrics.core.tickOverrunsCount,circuitBreakerTripsCount:n.metrics.core.circuitBreakerTripsCount,tps:c,uptimeMs:n.metrics.core.uptimeMs,adapterMetrics:n.metrics.adapters,lastRevision:n.revision},d=r.tpsHistory.at(-1),f={tps:c,tick:a,sampledAtMs:l};if(!d||l-d.sampledAtMs>=lt?u.tpsHistory=[...r.tpsHistory,f].slice(-ct):u.tpsHistory=[...r.tpsHistory.slice(0,-1),f],i.length>0){let e=new Map(r.memberValues),t=new Set;for(let n of i){if(!t.has(n.assetId)){let r=e.get(n.assetId);e.set(n.assetId,new Map(r)),t.add(n.assetId)}e.get(n.assetId)?.set(n.memberName,{value:n.value,quality:n.quality})}u.memberValues=e}e(u)},applyEvent:(n,r)=>{let i=t();if(r<=i.lastRevision)return;let a=Date.now(),o=[n,...i.events].slice(0,st),s={...gt(i,a),events:o,lastRevision:r};if(n.kind===`asset:removed`){let t=new Map(i.memberValues);t.delete(n.id),e({...s,memberValues:t});return}if(n.kind===`fault:triggered`||n.kind===`fault:cleared`){let t=i.assets.map(e=>{if(e.id!==n.assetId)return e;let t=n.kind===`fault:triggered`?[...e.activeFaults,n.fault]:e.activeFaults.filter(e=>e!==n.fault);return{...e,activeFaults:t}});e({...s,assets:t});return}if(n.kind===`lifecycle:changed`||n.kind===`asset:maintenance`){let t=i.assets.map(e=>e.id===n.assetId?{...e,lifecycleStage:n.to,operatingHours:n.operatingHours}:e);e({...s,assets:t});return}if(n.kind===`engine:state`){e({...s,engineState:n.to});return}e(s)},markConnection:n=>{t().connectionState!==n&&e({connectionState:n,connectionStateSince:Date.now()})},markFatal:t=>{e({connectionState:`fatal`,connectionStateSince:Date.now(),fatalError:t})},markUnauthenticated:()=>{t().connectionState!==`unauthenticated`&&e({connectionState:`unauthenticated`,connectionStateSince:Date.now()})},noteReconnectAttempt:()=>{e(e=>({reconnectAttempts:e.reconnectAttempts+1}))},resetReconnectAttempts:()=>{t().reconnectAttempts!==0&&e({reconnectAttempts:0})}})),g;(function(e){e.assertEqual=e=>{};function t(e){}e.assertIs=t;function n(e){throw Error()}e.assertNever=n,e.arrayToEnum=e=>{let t={};for(let n of e)t[n]=n;return t},e.getValidEnumValues=t=>{let n=e.objectKeys(t).filter(e=>typeof t[t[e]]!=`number`),r={};for(let e of n)r[e]=t[e];return e.objectValues(r)},e.objectValues=t=>e.objectKeys(t).map(function(e){return t[e]}),e.objectKeys=typeof Object.keys==`function`?e=>Object.keys(e):e=>{let t=[];for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t},e.find=(e,t)=>{for(let n of e)if(t(n))return n},e.isInteger=typeof Number.isInteger==`function`?e=>Number.isInteger(e):e=>typeof e==`number`&&Number.isFinite(e)&&Math.floor(e)===e;function r(e,t=` | `){return e.map(e=>typeof e==`string`?`'${e}'`:e).join(t)}e.joinValues=r,e.jsonStringifyReplacer=(e,t)=>typeof t==`bigint`?t.toString():t})(g||={});var vt;(function(e){e.mergeShapes=(e,t)=>({...e,...t})})(vt||={});var _=g.arrayToEnum([`string`,`nan`,`number`,`integer`,`float`,`boolean`,`date`,`bigint`,`symbol`,`function`,`undefined`,`null`,`array`,`object`,`unknown`,`promise`,`void`,`never`,`map`,`set`]),v=e=>{switch(typeof e){case`undefined`:return _.undefined;case`string`:return _.string;case`number`:return Number.isNaN(e)?_.nan:_.number;case`boolean`:return _.boolean;case`function`:return _.function;case`bigint`:return _.bigint;case`symbol`:return _.symbol;case`object`:return Array.isArray(e)?_.array:e===null?_.null:e.then&&typeof e.then==`function`&&e.catch&&typeof e.catch==`function`?_.promise:typeof Map<`u`&&e instanceof Map?_.map:typeof Set<`u`&&e instanceof Set?_.set:typeof Date<`u`&&e instanceof Date?_.date:_.object;default:return _.unknown}},y=g.arrayToEnum([`invalid_type`,`invalid_literal`,`custom`,`invalid_union`,`invalid_union_discriminator`,`invalid_enum_value`,`unrecognized_keys`,`invalid_arguments`,`invalid_return_type`,`invalid_date`,`invalid_string`,`too_small`,`too_big`,`invalid_intersection_types`,`not_multiple_of`,`not_finite`]),yt=e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,`$1:`),b=class e extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name=`ZodError`,this.issues=e}format(e){let t=e||function(e){return e.message},n={_errors:[]},r=e=>{for(let i of e.issues)if(i.code===`invalid_union`)i.unionErrors.map(r);else if(i.code===`invalid_return_type`)r(i.returnTypeError);else if(i.code===`invalid_arguments`)r(i.argumentsError);else if(i.path.length===0)n._errors.push(t(i));else{let e=n,r=0;for(;r<i.path.length;){let n=i.path[r];r===i.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(i))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(this),n}static assert(t){if(!(t instanceof e))throw Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,g.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=e=>e.message){let t={},n=[];for(let r of this.issues)if(r.path.length>0){let n=r.path[0];t[n]=t[n]||[],t[n].push(e(r))}else n.push(e(r));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};b.create=e=>new b(e);var bt=(e,t)=>{let n;switch(e.code){case y.invalid_type:n=e.received===_.undefined?`Required`:`Expected ${e.expected}, received ${e.received}`;break;case y.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,g.jsonStringifyReplacer)}`;break;case y.unrecognized_keys:n=`Unrecognized key(s) in object: ${g.joinValues(e.keys,`, `)}`;break;case y.invalid_union:n=`Invalid input`;break;case y.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${g.joinValues(e.options)}`;break;case y.invalid_enum_value:n=`Invalid enum value. Expected ${g.joinValues(e.options)}, received '${e.received}'`;break;case y.invalid_arguments:n=`Invalid function arguments`;break;case y.invalid_return_type:n=`Invalid function return type`;break;case y.invalid_date:n=`Invalid date`;break;case y.invalid_string:typeof e.validation==`object`?`includes`in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position==`number`&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):`startsWith`in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:`endsWith`in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:g.assertNever(e.validation):n=e.validation===`regex`?`Invalid`:`Invalid ${e.validation}`;break;case y.too_small:n=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at least`:`more than`} ${e.minimum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at least`:`over`} ${e.minimum} character(s)`:e.type===`number`||e.type===`bigint`?`Number must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${e.minimum}`:e.type===`date`?`Date must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${new Date(Number(e.minimum))}`:`Invalid input`;break;case y.too_big:n=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at most`:`less than`} ${e.maximum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at most`:`under`} ${e.maximum} character(s)`:e.type===`number`?`Number must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`bigint`?`BigInt must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`date`?`Date must be ${e.exact?`exactly`:e.inclusive?`smaller than or equal to`:`smaller than`} ${new Date(Number(e.maximum))}`:`Invalid input`;break;case y.custom:n=`Invalid input`;break;case y.invalid_intersection_types:n=`Intersection results could not be merged`;break;case y.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case y.not_finite:n=`Number must be finite`;break;default:n=t.defaultError,g.assertNever(e)}return{message:n}},xt=bt;function St(e){xt=e}function Ct(){return xt}var wt=e=>{let{data:t,path:n,errorMaps:r,issueData:i}=e,a=[...n,...i.path||[]],o={...i,path:a};if(i.message!==void 0)return{...i,path:a,message:i.message};let s=``,c=r.filter(e=>!!e).slice().reverse();for(let e of c)s=e(o,{data:t,defaultError:s}).message;return{...i,path:a,message:s}},Tt=[];function x(e,t){let n=Ct(),r=wt({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===bt?void 0:bt].filter(e=>!!e)});e.common.issues.push(r)}var S=class e{constructor(){this.value=`valid`}dirty(){this.value===`valid`&&(this.value=`dirty`)}abort(){this.value!==`aborted`&&(this.value=`aborted`)}static mergeArray(e,t){let n=[];for(let r of t){if(r.status===`aborted`)return C;r.status===`dirty`&&e.dirty(),n.push(r.value)}return{status:e.value,value:n}}static async mergeObjectAsync(t,n){let r=[];for(let e of n){let t=await e.key,n=await e.value;r.push({key:t,value:n})}return e.mergeObjectSync(t,r)}static mergeObjectSync(e,t){let n={};for(let r of t){let{key:t,value:i}=r;if(t.status===`aborted`||i.status===`aborted`)return C;t.status===`dirty`&&e.dirty(),i.status===`dirty`&&e.dirty(),t.value!==`__proto__`&&(i.value!==void 0||r.alwaysSet)&&(n[t.value]=i.value)}return{status:e.value,value:n}}},C=Object.freeze({status:`aborted`}),Et=e=>({status:`dirty`,value:e}),w=e=>({status:`valid`,value:e}),Dt=e=>e.status===`aborted`,Ot=e=>e.status===`dirty`,kt=e=>e.status===`valid`,At=e=>typeof Promise<`u`&&e instanceof Promise,T;(function(e){e.errToObj=e=>typeof e==`string`?{message:e}:e||{},e.toString=e=>typeof e==`string`?e:e?.message})(T||={});var E=class{constructor(e,t,n,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=r}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},jt=(e,t)=>{if(kt(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw Error(`Validation failed but no issues detected.`);return{success:!1,get error(){return this._error||=new b(e.common.issues),this._error}}};function D(e){if(!e)return{};let{errorMap:t,invalid_type_error:n,required_error:r,description:i}=e;if(t&&(n||r))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(t,i)=>{let{message:a}=e;return t.code===`invalid_enum_value`?{message:a??i.defaultError}:i.data===void 0?{message:a??r??i.defaultError}:t.code===`invalid_type`?{message:a??n??i.defaultError}:{message:i.defaultError}},description:i}}var O=class{get description(){return this._def.description}_getType(e){return v(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:v(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new S,ctx:{common:e.parent.common,data:e.data,parsedType:v(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(At(t))throw Error(`Synchronous parse encountered promise.`);return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){let n={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:v(e)};return jt(n,this._parseSync({data:e,path:n.path,parent:n}))}"~validate"(e){let t={common:{issues:[],async:!!this[`~standard`].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:v(e)};if(!this[`~standard`].async)try{let n=this._parseSync({data:e,path:[],parent:t});return kt(n)?{value:n.value}:{issues:t.common.issues}}catch(e){e?.message?.toLowerCase()?.includes(`encountered`)&&(this[`~standard`].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(e=>kt(e)?{value:e.value}:{issues:t.common.issues})}async parseAsync(e,t){let n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){let n={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:v(e)},r=this._parse({data:e,path:n.path,parent:n});return jt(n,await(At(r)?r:Promise.resolve(r)))}refine(e,t){let n=e=>typeof t==`string`||t===void 0?{message:t}:typeof t==`function`?t(e):t;return this._refinement((t,r)=>{let i=e(t),a=()=>r.addIssue({code:y.custom,...n(t)});return typeof Promise<`u`&&i instanceof Promise?i.then(e=>e?!0:(a(),!1)):i?!0:(a(),!1)})}refinement(e,t){return this._refinement((n,r)=>e(n)?!0:(r.addIssue(typeof t==`function`?t(n,r):t),!1))}_refinement(e){return new N({schema:this,typeName:I.ZodEffects,effect:{type:`refinement`,refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this[`~standard`]={version:1,vendor:`zod`,validate:e=>this[`~validate`](e)}}optional(){return P.create(this,this._def)}nullable(){return F.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return hn.create(this)}promise(){return An.create(this,this._def)}or(e){return _n.create([this,e],this._def)}and(e){return bn.create(this,e,this._def)}transform(e){return new N({...D(this._def),schema:this,typeName:I.ZodEffects,effect:{type:`transform`,transform:e}})}default(e){let t=typeof e==`function`?e:()=>e;return new jn({...D(this._def),innerType:this,defaultValue:t,typeName:I.ZodDefault})}brand(){return new Fn({typeName:I.ZodBranded,type:this,...D(this._def)})}catch(e){let t=typeof e==`function`?e:()=>e;return new Mn({...D(this._def),innerType:this,catchValue:t,typeName:I.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return In.create(this,e)}readonly(){return Ln.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Mt=/^c[^\s-]{8,}$/i,Nt=/^[0-9a-z]+$/,Pt=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Ft=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,It=/^[a-z0-9_-]{21}$/i,Lt=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Rt=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,zt=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Bt=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,Vt,Ht=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Ut=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,Wt=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Gt=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Kt=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,qt=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Jt=`((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))`,Yt=RegExp(`^${Jt}$`);function Xt(e){let t=`[0-5]\\d`;e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision??(t=`${t}(\\.\\d+)?`);let n=e.precision?`+`:`?`;return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function Zt(e){return RegExp(`^${Xt(e)}$`)}function Qt(e){let t=`${Jt}T${Xt(e)}`,n=[];return n.push(e.local?`Z?`:`Z`),e.offset&&n.push(`([+-]\\d{2}:?\\d{2})`),t=`${t}(${n.join(`|`)})`,RegExp(`^${t}$`)}function $t(e,t){return!!((t===`v4`||!t)&&Ht.test(e)||(t===`v6`||!t)&&Wt.test(e))}function en(e,t){if(!Lt.test(e))return!1;try{let[n]=e.split(`.`);if(!n)return!1;let r=n.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(n.length+(4-n.length%4)%4,`=`),i=JSON.parse(atob(r));return!(typeof i!=`object`||!i||`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&i.alg!==t)}catch{return!1}}function tn(e,t){return!!((t===`v4`||!t)&&Ut.test(e)||(t===`v6`||!t)&&Gt.test(e))}var nn=class e extends O{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==_.string){let t=this._getOrReturnCtx(e);return x(t,{code:y.invalid_type,expected:_.string,received:t.parsedType}),C}let t=new S,n;for(let r of this._def.checks)if(r.kind===`min`)e.data.length<r.value&&(n=this._getOrReturnCtx(e,n),x(n,{code:y.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind===`max`)e.data.length>r.value&&(n=this._getOrReturnCtx(e,n),x(n,{code:y.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind===`length`){let i=e.data.length>r.value,a=e.data.length<r.value;(i||a)&&(n=this._getOrReturnCtx(e,n),i?x(n,{code:y.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}):a&&x(n,{code:y.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}),t.dirty())}else if(r.kind===`email`)zt.test(e.data)||(n=this._getOrReturnCtx(e,n),x(n,{validation:`email`,code:y.invalid_string,message:r.message}),t.dirty());else if(r.kind===`emoji`)Vt||=new RegExp(Bt,`u`),Vt.test(e.data)||(n=this._getOrReturnCtx(e,n),x(n,{validation:`emoji`,code:y.invalid_string,message:r.message}),t.dirty());else if(r.kind===`uuid`)Ft.test(e.data)||(n=this._getOrReturnCtx(e,n),x(n,{validation:`uuid`,code:y.invalid_string,message:r.message}),t.dirty());else if(r.kind===`nanoid`)It.test(e.data)||(n=this._getOrReturnCtx(e,n),x(n,{validation:`nanoid`,code:y.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid`)Mt.test(e.data)||(n=this._getOrReturnCtx(e,n),x(n,{validation:`cuid`,code:y.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid2`)Nt.test(e.data)||(n=this._getOrReturnCtx(e,n),x(n,{validation:`cuid2`,code:y.invalid_string,message:r.message}),t.dirty());else if(r.kind===`ulid`)Pt.test(e.data)||(n=this._getOrReturnCtx(e,n),x(n,{validation:`ulid`,code:y.invalid_string,message:r.message}),t.dirty());else if(r.kind===`url`)try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),x(n,{validation:`url`,code:y.invalid_string,message:r.message}),t.dirty()}else r.kind===`regex`?(r.regex.lastIndex=0,r.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),x(n,{validation:`regex`,code:y.invalid_string,message:r.message}),t.dirty())):r.kind===`trim`?e.data=e.data.trim():r.kind===`includes`?e.data.includes(r.value,r.position)||(n=this._getOrReturnCtx(e,n),x(n,{code:y.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),t.dirty()):r.kind===`toLowerCase`?e.data=e.data.toLowerCase():r.kind===`toUpperCase`?e.data=e.data.toUpperCase():r.kind===`startsWith`?e.data.startsWith(r.value)||(n=this._getOrReturnCtx(e,n),x(n,{code:y.invalid_string,validation:{startsWith:r.value},message:r.message}),t.dirty()):r.kind===`endsWith`?e.data.endsWith(r.value)||(n=this._getOrReturnCtx(e,n),x(n,{code:y.invalid_string,validation:{endsWith:r.value},message:r.message}),t.dirty()):r.kind===`datetime`?Qt(r).test(e.data)||(n=this._getOrReturnCtx(e,n),x(n,{code:y.invalid_string,validation:`datetime`,message:r.message}),t.dirty()):r.kind===`date`?Yt.test(e.data)||(n=this._getOrReturnCtx(e,n),x(n,{code:y.invalid_string,validation:`date`,message:r.message}),t.dirty()):r.kind===`time`?Zt(r).test(e.data)||(n=this._getOrReturnCtx(e,n),x(n,{code:y.invalid_string,validation:`time`,message:r.message}),t.dirty()):r.kind===`duration`?Rt.test(e.data)||(n=this._getOrReturnCtx(e,n),x(n,{validation:`duration`,code:y.invalid_string,message:r.message}),t.dirty()):r.kind===`ip`?$t(e.data,r.version)||(n=this._getOrReturnCtx(e,n),x(n,{validation:`ip`,code:y.invalid_string,message:r.message}),t.dirty()):r.kind===`jwt`?en(e.data,r.alg)||(n=this._getOrReturnCtx(e,n),x(n,{validation:`jwt`,code:y.invalid_string,message:r.message}),t.dirty()):r.kind===`cidr`?tn(e.data,r.version)||(n=this._getOrReturnCtx(e,n),x(n,{validation:`cidr`,code:y.invalid_string,message:r.message}),t.dirty()):r.kind===`base64`?Kt.test(e.data)||(n=this._getOrReturnCtx(e,n),x(n,{validation:`base64`,code:y.invalid_string,message:r.message}),t.dirty()):r.kind===`base64url`?qt.test(e.data)||(n=this._getOrReturnCtx(e,n),x(n,{validation:`base64url`,code:y.invalid_string,message:r.message}),t.dirty()):g.assertNever(r);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(t=>e.test(t),{validation:t,code:y.invalid_string,...T.errToObj(n)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(e){return this._addCheck({kind:`email`,...T.errToObj(e)})}url(e){return this._addCheck({kind:`url`,...T.errToObj(e)})}emoji(e){return this._addCheck({kind:`emoji`,...T.errToObj(e)})}uuid(e){return this._addCheck({kind:`uuid`,...T.errToObj(e)})}nanoid(e){return this._addCheck({kind:`nanoid`,...T.errToObj(e)})}cuid(e){return this._addCheck({kind:`cuid`,...T.errToObj(e)})}cuid2(e){return this._addCheck({kind:`cuid2`,...T.errToObj(e)})}ulid(e){return this._addCheck({kind:`ulid`,...T.errToObj(e)})}base64(e){return this._addCheck({kind:`base64`,...T.errToObj(e)})}base64url(e){return this._addCheck({kind:`base64url`,...T.errToObj(e)})}jwt(e){return this._addCheck({kind:`jwt`,...T.errToObj(e)})}ip(e){return this._addCheck({kind:`ip`,...T.errToObj(e)})}cidr(e){return this._addCheck({kind:`cidr`,...T.errToObj(e)})}datetime(e){return typeof e==`string`?this._addCheck({kind:`datetime`,precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:`datetime`,precision:e?.precision===void 0?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...T.errToObj(e?.message)})}date(e){return this._addCheck({kind:`date`,message:e})}time(e){return typeof e==`string`?this._addCheck({kind:`time`,precision:null,message:e}):this._addCheck({kind:`time`,precision:e?.precision===void 0?null:e?.precision,...T.errToObj(e?.message)})}duration(e){return this._addCheck({kind:`duration`,...T.errToObj(e)})}regex(e,t){return this._addCheck({kind:`regex`,regex:e,...T.errToObj(t)})}includes(e,t){return this._addCheck({kind:`includes`,value:e,position:t?.position,...T.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:`startsWith`,value:e,...T.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:`endsWith`,value:e,...T.errToObj(t)})}min(e,t){return this._addCheck({kind:`min`,value:e,...T.errToObj(t)})}max(e,t){return this._addCheck({kind:`max`,value:e,...T.errToObj(t)})}length(e,t){return this._addCheck({kind:`length`,value:e,...T.errToObj(t)})}nonempty(e){return this.min(1,T.errToObj(e))}trim(){return new e({...this._def,checks:[...this._def.checks,{kind:`trim`}]})}toLowerCase(){return new e({...this._def,checks:[...this._def.checks,{kind:`toLowerCase`}]})}toUpperCase(){return new e({...this._def,checks:[...this._def.checks,{kind:`toUpperCase`}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind===`datetime`)}get isDate(){return!!this._def.checks.find(e=>e.kind===`date`)}get isTime(){return!!this._def.checks.find(e=>e.kind===`time`)}get isDuration(){return!!this._def.checks.find(e=>e.kind===`duration`)}get isEmail(){return!!this._def.checks.find(e=>e.kind===`email`)}get isURL(){return!!this._def.checks.find(e=>e.kind===`url`)}get isEmoji(){return!!this._def.checks.find(e=>e.kind===`emoji`)}get isUUID(){return!!this._def.checks.find(e=>e.kind===`uuid`)}get isNANOID(){return!!this._def.checks.find(e=>e.kind===`nanoid`)}get isCUID(){return!!this._def.checks.find(e=>e.kind===`cuid`)}get isCUID2(){return!!this._def.checks.find(e=>e.kind===`cuid2`)}get isULID(){return!!this._def.checks.find(e=>e.kind===`ulid`)}get isIP(){return!!this._def.checks.find(e=>e.kind===`ip`)}get isCIDR(){return!!this._def.checks.find(e=>e.kind===`cidr`)}get isBase64(){return!!this._def.checks.find(e=>e.kind===`base64`)}get isBase64url(){return!!this._def.checks.find(e=>e.kind===`base64url`)}get minLength(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};nn.create=e=>new nn({checks:[],typeName:I.ZodString,coerce:e?.coerce??!1,...D(e)});function rn(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=(t.toString().split(`.`)[1]||``).length,i=n>r?n:r;return Number.parseInt(e.toFixed(i).replace(`.`,``))%Number.parseInt(t.toFixed(i).replace(`.`,``))/10**i}var an=class e extends O{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==_.number){let t=this._getOrReturnCtx(e);return x(t,{code:y.invalid_type,expected:_.number,received:t.parsedType}),C}let t,n=new S;for(let r of this._def.checks)r.kind===`int`?g.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),x(t,{code:y.invalid_type,expected:`integer`,received:`float`,message:r.message}),n.dirty()):r.kind===`min`?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),x(t,{code:y.too_small,minimum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind===`max`?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),x(t,{code:y.too_big,maximum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind===`multipleOf`?rn(e.data,r.value)!==0&&(t=this._getOrReturnCtx(e,t),x(t,{code:y.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):r.kind===`finite`?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),x(t,{code:y.not_finite,message:r.message}),n.dirty()):g.assertNever(r);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit(`min`,e,!0,T.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,T.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,T.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,T.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:T.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(e){return this._addCheck({kind:`int`,message:T.toString(e)})}positive(e){return this._addCheck({kind:`min`,value:0,inclusive:!1,message:T.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:0,inclusive:!1,message:T.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:0,inclusive:!0,message:T.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:0,inclusive:!0,message:T.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:T.toString(t)})}finite(e){return this._addCheck({kind:`finite`,message:T.toString(e)})}safe(e){return this._addCheck({kind:`min`,inclusive:!0,value:-(2**53-1),message:T.toString(e)})._addCheck({kind:`max`,inclusive:!0,value:2**53-1,message:T.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind===`int`||e.kind===`multipleOf`&&g.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let n of this._def.checks)if(n.kind===`finite`||n.kind===`int`||n.kind===`multipleOf`)return!0;else n.kind===`min`?(t===null||n.value>t)&&(t=n.value):n.kind===`max`&&(e===null||n.value<e)&&(e=n.value);return Number.isFinite(t)&&Number.isFinite(e)}};an.create=e=>new an({checks:[],typeName:I.ZodNumber,coerce:e?.coerce||!1,...D(e)});var on=class e extends O{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==_.bigint)return this._getInvalidInput(e);let t,n=new S;for(let r of this._def.checks)r.kind===`min`?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),x(t,{code:y.too_small,type:`bigint`,minimum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind===`max`?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),x(t,{code:y.too_big,type:`bigint`,maximum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind===`multipleOf`?e.data%r.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),x(t,{code:y.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):g.assertNever(r);return{status:n.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return x(t,{code:y.invalid_type,expected:_.bigint,received:t.parsedType}),C}gte(e,t){return this.setLimit(`min`,e,!0,T.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,T.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,T.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,T.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:T.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}positive(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!1,message:T.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!1,message:T.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!0,message:T.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!0,message:T.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:T.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};on.create=e=>new on({checks:[],typeName:I.ZodBigInt,coerce:e?.coerce??!1,...D(e)});var sn=class extends O{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==_.boolean){let t=this._getOrReturnCtx(e);return x(t,{code:y.invalid_type,expected:_.boolean,received:t.parsedType}),C}return w(e.data)}};sn.create=e=>new sn({typeName:I.ZodBoolean,coerce:e?.coerce||!1,...D(e)});var cn=class e extends O{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==_.date){let t=this._getOrReturnCtx(e);return x(t,{code:y.invalid_type,expected:_.date,received:t.parsedType}),C}if(Number.isNaN(e.data.getTime()))return x(this._getOrReturnCtx(e),{code:y.invalid_date}),C;let t=new S,n;for(let r of this._def.checks)r.kind===`min`?e.data.getTime()<r.value&&(n=this._getOrReturnCtx(e,n),x(n,{code:y.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:`date`}),t.dirty()):r.kind===`max`?e.data.getTime()>r.value&&(n=this._getOrReturnCtx(e,n),x(n,{code:y.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:`date`}),t.dirty()):g.assertNever(r);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}min(e,t){return this._addCheck({kind:`min`,value:e.getTime(),message:T.toString(t)})}max(e,t){return this._addCheck({kind:`max`,value:e.getTime(),message:T.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e==null?null:new Date(e)}get maxDate(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e==null?null:new Date(e)}};cn.create=e=>new cn({checks:[],coerce:e?.coerce||!1,typeName:I.ZodDate,...D(e)});var ln=class extends O{_parse(e){if(this._getType(e)!==_.symbol){let t=this._getOrReturnCtx(e);return x(t,{code:y.invalid_type,expected:_.symbol,received:t.parsedType}),C}return w(e.data)}};ln.create=e=>new ln({typeName:I.ZodSymbol,...D(e)});var un=class extends O{_parse(e){if(this._getType(e)!==_.undefined){let t=this._getOrReturnCtx(e);return x(t,{code:y.invalid_type,expected:_.undefined,received:t.parsedType}),C}return w(e.data)}};un.create=e=>new un({typeName:I.ZodUndefined,...D(e)});var dn=class extends O{_parse(e){if(this._getType(e)!==_.null){let t=this._getOrReturnCtx(e);return x(t,{code:y.invalid_type,expected:_.null,received:t.parsedType}),C}return w(e.data)}};dn.create=e=>new dn({typeName:I.ZodNull,...D(e)});var fn=class extends O{constructor(){super(...arguments),this._any=!0}_parse(e){return w(e.data)}};fn.create=e=>new fn({typeName:I.ZodAny,...D(e)});var pn=class extends O{constructor(){super(...arguments),this._unknown=!0}_parse(e){return w(e.data)}};pn.create=e=>new pn({typeName:I.ZodUnknown,...D(e)});var k=class extends O{_parse(e){let t=this._getOrReturnCtx(e);return x(t,{code:y.invalid_type,expected:_.never,received:t.parsedType}),C}};k.create=e=>new k({typeName:I.ZodNever,...D(e)});var mn=class extends O{_parse(e){if(this._getType(e)!==_.undefined){let t=this._getOrReturnCtx(e);return x(t,{code:y.invalid_type,expected:_.void,received:t.parsedType}),C}return w(e.data)}};mn.create=e=>new mn({typeName:I.ZodVoid,...D(e)});var hn=class e extends O{_parse(e){let{ctx:t,status:n}=this._processInputParams(e),r=this._def;if(t.parsedType!==_.array)return x(t,{code:y.invalid_type,expected:_.array,received:t.parsedType}),C;if(r.exactLength!==null){let e=t.data.length>r.exactLength.value,i=t.data.length<r.exactLength.value;(e||i)&&(x(t,{code:e?y.too_big:y.too_small,minimum:i?r.exactLength.value:void 0,maximum:e?r.exactLength.value:void 0,type:`array`,inclusive:!0,exact:!0,message:r.exactLength.message}),n.dirty())}if(r.minLength!==null&&t.data.length<r.minLength.value&&(x(t,{code:y.too_small,minimum:r.minLength.value,type:`array`,inclusive:!0,exact:!1,message:r.minLength.message}),n.dirty()),r.maxLength!==null&&t.data.length>r.maxLength.value&&(x(t,{code:y.too_big,maximum:r.maxLength.value,type:`array`,inclusive:!0,exact:!1,message:r.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((e,n)=>r.type._parseAsync(new E(t,e,t.path,n)))).then(e=>S.mergeArray(n,e));let i=[...t.data].map((e,n)=>r.type._parseSync(new E(t,e,t.path,n)));return S.mergeArray(n,i)}get element(){return this._def.type}min(t,n){return new e({...this._def,minLength:{value:t,message:T.toString(n)}})}max(t,n){return new e({...this._def,maxLength:{value:t,message:T.toString(n)}})}length(t,n){return new e({...this._def,exactLength:{value:t,message:T.toString(n)}})}nonempty(e){return this.min(1,e)}};hn.create=(e,t)=>new hn({type:e,minLength:null,maxLength:null,exactLength:null,typeName:I.ZodArray,...D(t)});function gn(e){if(e instanceof A){let t={};for(let n in e.shape){let r=e.shape[n];t[n]=P.create(gn(r))}return new A({...e._def,shape:()=>t})}else if(e instanceof hn)return new hn({...e._def,type:gn(e.element)});else if(e instanceof P)return P.create(gn(e.unwrap()));else if(e instanceof F)return F.create(gn(e.unwrap()));else if(e instanceof M)return M.create(e.items.map(e=>gn(e)));else return e}var A=class e extends O{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape();return this._cached={shape:e,keys:g.objectKeys(e)},this._cached}_parse(e){if(this._getType(e)!==_.object){let t=this._getOrReturnCtx(e);return x(t,{code:y.invalid_type,expected:_.object,received:t.parsedType}),C}let{status:t,ctx:n}=this._processInputParams(e),{shape:r,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof k&&this._def.unknownKeys===`strip`))for(let e in n.data)i.includes(e)||a.push(e);let o=[];for(let e of i){let t=r[e],i=n.data[e];o.push({key:{status:`valid`,value:e},value:t._parse(new E(n,i,n.path,e)),alwaysSet:e in n.data})}if(this._def.catchall instanceof k){let e=this._def.unknownKeys;if(e===`passthrough`)for(let e of a)o.push({key:{status:`valid`,value:e},value:{status:`valid`,value:n.data[e]}});else if(e===`strict`)a.length>0&&(x(n,{code:y.unrecognized_keys,keys:a}),t.dirty());else if(e!==`strip`)throw Error(`Internal ZodObject error: invalid unknownKeys value.`)}else{let e=this._def.catchall;for(let t of a){let r=n.data[t];o.push({key:{status:`valid`,value:t},value:e._parse(new E(n,r,n.path,t)),alwaysSet:t in n.data})}}return n.common.async?Promise.resolve().then(async()=>{let e=[];for(let t of o){let n=await t.key,r=await t.value;e.push({key:n,value:r,alwaysSet:t.alwaysSet})}return e}).then(e=>S.mergeObjectSync(t,e)):S.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(t){return T.errToObj,new e({...this._def,unknownKeys:`strict`,...t===void 0?{}:{errorMap:(e,n)=>{let r=this._def.errorMap?.(e,n).message??n.defaultError;return e.code===`unrecognized_keys`?{message:T.errToObj(t).message??r}:{message:r}}}})}strip(){return new e({...this._def,unknownKeys:`strip`})}passthrough(){return new e({...this._def,unknownKeys:`passthrough`})}extend(t){return new e({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new e({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:I.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(t){return new e({...this._def,catchall:t})}pick(t){let n={};for(let e of g.objectKeys(t))t[e]&&this.shape[e]&&(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}omit(t){let n={};for(let e of g.objectKeys(this.shape))t[e]||(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}deepPartial(){return gn(this)}partial(t){let n={};for(let e of g.objectKeys(this.shape)){let r=this.shape[e];t&&!t[e]?n[e]=r:n[e]=r.optional()}return new e({...this._def,shape:()=>n})}required(t){let n={};for(let e of g.objectKeys(this.shape))if(t&&!t[e])n[e]=this.shape[e];else{let t=this.shape[e];for(;t instanceof P;)t=t._def.innerType;n[e]=t}return new e({...this._def,shape:()=>n})}keyof(){return Dn(g.objectKeys(this.shape))}};A.create=(e,t)=>new A({shape:()=>e,unknownKeys:`strip`,catchall:k.create(),typeName:I.ZodObject,...D(t)}),A.strictCreate=(e,t)=>new A({shape:()=>e,unknownKeys:`strict`,catchall:k.create(),typeName:I.ZodObject,...D(t)}),A.lazycreate=(e,t)=>new A({shape:e,unknownKeys:`strip`,catchall:k.create(),typeName:I.ZodObject,...D(t)});var _n=class extends O{_parse(e){let{ctx:t}=this._processInputParams(e),n=this._def.options;function r(e){for(let t of e)if(t.result.status===`valid`)return t.result;for(let n of e)if(n.result.status===`dirty`)return t.common.issues.push(...n.ctx.common.issues),n.result;let n=e.map(e=>new b(e.ctx.common.issues));return x(t,{code:y.invalid_union,unionErrors:n}),C}if(t.common.async)return Promise.all(n.map(async e=>{let n={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:n}),ctx:n}})).then(r);{let e,r=[];for(let i of n){let n={...t,common:{...t.common,issues:[]},parent:null},a=i._parseSync({data:t.data,path:t.path,parent:n});if(a.status===`valid`)return a;a.status===`dirty`&&!e&&(e={result:a,ctx:n}),n.common.issues.length&&r.push(n.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;let i=r.map(e=>new b(e));return x(t,{code:y.invalid_union,unionErrors:i}),C}}get options(){return this._def.options}};_n.create=(e,t)=>new _n({options:e,typeName:I.ZodUnion,...D(t)});var j=e=>e instanceof Tn?j(e.schema):e instanceof N?j(e.innerType()):e instanceof En?[e.value]:e instanceof On?e.options:e instanceof kn?g.objectValues(e.enum):e instanceof jn?j(e._def.innerType):e instanceof un?[void 0]:e instanceof dn?[null]:e instanceof P?[void 0,...j(e.unwrap())]:e instanceof F?[null,...j(e.unwrap())]:e instanceof Fn||e instanceof Ln?j(e.unwrap()):e instanceof Mn?j(e._def.innerType):[],vn=class e extends O{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==_.object)return x(t,{code:y.invalid_type,expected:_.object,received:t.parsedType}),C;let n=this.discriminator,r=t.data[n],i=this.optionsMap.get(r);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):(x(t,{code:y.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),C)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,r){let i=new Map;for(let e of n){let n=j(e.shape[t]);if(!n.length)throw Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let r of n){if(i.has(r))throw Error(`Discriminator property ${String(t)} has duplicate value ${String(r)}`);i.set(r,e)}}return new e({typeName:I.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,...D(r)})}};function yn(e,t){let n=v(e),r=v(t);if(e===t)return{valid:!0,data:e};if(n===_.object&&r===_.object){let n=g.objectKeys(t),r=g.objectKeys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=yn(e[n],t[n]);if(!r.valid)return{valid:!1};i[n]=r.data}return{valid:!0,data:i}}else if(n===_.array&&r===_.array){if(e.length!==t.length)return{valid:!1};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=yn(i,a);if(!o.valid)return{valid:!1};n.push(o.data)}return{valid:!0,data:n}}else if(n===_.date&&r===_.date&&+e==+t)return{valid:!0,data:e};else return{valid:!1}}var bn=class extends O{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=(e,r)=>{if(Dt(e)||Dt(r))return C;let i=yn(e.value,r.value);return i.valid?((Ot(e)||Ot(r))&&t.dirty(),{status:t.value,value:i.data}):(x(n,{code:y.invalid_intersection_types}),C)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([e,t])=>r(e,t)):r(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};bn.create=(e,t,n)=>new bn({left:e,right:t,typeName:I.ZodIntersection,...D(n)});var M=class e extends O{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==_.array)return x(n,{code:y.invalid_type,expected:_.array,received:n.parsedType}),C;if(n.data.length<this._def.items.length)return x(n,{code:y.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),C;!this._def.rest&&n.data.length>this._def.items.length&&(x(n,{code:y.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),t.dirty());let r=[...n.data].map((e,t)=>{let r=this._def.items[t]||this._def.rest;return r?r._parse(new E(n,e,n.path,t)):null}).filter(e=>!!e);return n.common.async?Promise.all(r).then(e=>S.mergeArray(t,e)):S.mergeArray(t,r)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};M.create=(e,t)=>{if(!Array.isArray(e))throw Error(`You must pass an array of schemas to z.tuple([ ... ])`);return new M({items:e,typeName:I.ZodTuple,rest:null,...D(t)})};var xn=class e extends O{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==_.object)return x(n,{code:y.invalid_type,expected:_.object,received:n.parsedType}),C;let r=[],i=this._def.keyType,a=this._def.valueType;for(let e in n.data)r.push({key:i._parse(new E(n,e,n.path,e)),value:a._parse(new E(n,n.data[e],n.path,e)),alwaysSet:e in n.data});return n.common.async?S.mergeObjectAsync(t,r):S.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof O?new e({keyType:t,valueType:n,typeName:I.ZodRecord,...D(r)}):new e({keyType:nn.create(),valueType:t,typeName:I.ZodRecord,...D(n)})}},Sn=class extends O{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==_.map)return x(n,{code:y.invalid_type,expected:_.map,received:n.parsedType}),C;let r=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([e,t],a)=>({key:r._parse(new E(n,e,n.path,[a,`key`])),value:i._parse(new E(n,t,n.path,[a,`value`]))}));if(n.common.async){let e=new Map;return Promise.resolve().then(async()=>{for(let n of a){let r=await n.key,i=await n.value;if(r.status===`aborted`||i.status===`aborted`)return C;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}})}else{let e=new Map;for(let n of a){let r=n.key,i=n.value;if(r.status===`aborted`||i.status===`aborted`)return C;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}}}};Sn.create=(e,t,n)=>new Sn({valueType:t,keyType:e,typeName:I.ZodMap,...D(n)});var Cn=class e extends O{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==_.set)return x(n,{code:y.invalid_type,expected:_.set,received:n.parsedType}),C;let r=this._def;r.minSize!==null&&n.data.size<r.minSize.value&&(x(n,{code:y.too_small,minimum:r.minSize.value,type:`set`,inclusive:!0,exact:!1,message:r.minSize.message}),t.dirty()),r.maxSize!==null&&n.data.size>r.maxSize.value&&(x(n,{code:y.too_big,maximum:r.maxSize.value,type:`set`,inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());let i=this._def.valueType;function a(e){let n=new Set;for(let r of e){if(r.status===`aborted`)return C;r.status===`dirty`&&t.dirty(),n.add(r.value)}return{status:t.value,value:n}}let o=[...n.data.values()].map((e,t)=>i._parse(new E(n,e,n.path,t)));return n.common.async?Promise.all(o).then(e=>a(e)):a(o)}min(t,n){return new e({...this._def,minSize:{value:t,message:T.toString(n)}})}max(t,n){return new e({...this._def,maxSize:{value:t,message:T.toString(n)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};Cn.create=(e,t)=>new Cn({valueType:e,minSize:null,maxSize:null,typeName:I.ZodSet,...D(t)});var wn=class e extends O{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==_.function)return x(t,{code:y.invalid_type,expected:_.function,received:t.parsedType}),C;function n(e,n){return wt({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Ct(),bt].filter(e=>!!e),issueData:{code:y.invalid_arguments,argumentsError:n}})}function r(e,n){return wt({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Ct(),bt].filter(e=>!!e),issueData:{code:y.invalid_return_type,returnTypeError:n}})}let i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof An){let e=this;return w(async function(...t){let o=new b([]),s=await e._def.args.parseAsync(t,i).catch(e=>{throw o.addIssue(n(t,e)),o}),c=await Reflect.apply(a,this,s);return await e._def.returns._def.type.parseAsync(c,i).catch(e=>{throw o.addIssue(r(c,e)),o})})}else{let e=this;return w(function(...t){let o=e._def.args.safeParse(t,i);if(!o.success)throw new b([n(t,o.error)]);let s=Reflect.apply(a,this,o.data),c=e._def.returns.safeParse(s,i);if(!c.success)throw new b([r(s,c.error)]);return c.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:M.create(t).rest(pn.create())})}returns(t){return new e({...this._def,returns:t})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(t,n,r){return new e({args:t||M.create([]).rest(pn.create()),returns:n||pn.create(),typeName:I.ZodFunction,...D(r)})}},Tn=class extends O{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};Tn.create=(e,t)=>new Tn({getter:e,typeName:I.ZodLazy,...D(t)});var En=class extends O{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return x(t,{received:t.data,code:y.invalid_literal,expected:this._def.value}),C}return{status:`valid`,value:e.data}}get value(){return this._def.value}};En.create=(e,t)=>new En({value:e,typeName:I.ZodLiteral,...D(t)});function Dn(e,t){return new On({values:e,typeName:I.ZodEnum,...D(t)})}var On=class e extends O{_parse(e){if(typeof e.data!=`string`){let t=this._getOrReturnCtx(e),n=this._def.values;return x(t,{expected:g.joinValues(n),received:t.parsedType,code:y.invalid_type}),C}if(this._cache||=new Set(this._def.values),!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),n=this._def.values;return x(t,{received:t.data,code:y.invalid_enum_value,options:n}),C}return w(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(t,n=this._def){return e.create(t,{...this._def,...n})}exclude(t,n=this._def){return e.create(this.options.filter(e=>!t.includes(e)),{...this._def,...n})}};On.create=Dn;var kn=class extends O{_parse(e){let t=g.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==_.string&&n.parsedType!==_.number){let e=g.objectValues(t);return x(n,{expected:g.joinValues(e),received:n.parsedType,code:y.invalid_type}),C}if(this._cache||=new Set(g.getValidEnumValues(this._def.values)),!this._cache.has(e.data)){let e=g.objectValues(t);return x(n,{received:n.data,code:y.invalid_enum_value,options:e}),C}return w(e.data)}get enum(){return this._def.values}};kn.create=(e,t)=>new kn({values:e,typeName:I.ZodNativeEnum,...D(t)});var An=class extends O{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);return t.parsedType!==_.promise&&t.common.async===!1?(x(t,{code:y.invalid_type,expected:_.promise,received:t.parsedType}),C):w((t.parsedType===_.promise?t.data:Promise.resolve(t.data)).then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}};An.create=(e,t)=>new An({type:e,typeName:I.ZodPromise,...D(t)});var N=class extends O{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===I.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=this._def.effect||null,i={addIssue:e=>{x(n,e),e.fatal?t.abort():t.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),r.type===`preprocess`){let e=r.transform(n.data,i);if(n.common.async)return Promise.resolve(e).then(async e=>{if(t.value===`aborted`)return C;let r=await this._def.schema._parseAsync({data:e,path:n.path,parent:n});return r.status===`aborted`?C:r.status===`dirty`||t.value===`dirty`?Et(r.value):r});{if(t.value===`aborted`)return C;let r=this._def.schema._parseSync({data:e,path:n.path,parent:n});return r.status===`aborted`?C:r.status===`dirty`||t.value===`dirty`?Et(r.value):r}}if(r.type===`refinement`){let e=e=>{let t=r.refinement(e,i);if(n.common.async)return Promise.resolve(t);if(t instanceof Promise)throw Error(`Async refinement encountered during synchronous parse operation. Use .parseAsync instead.`);return e};if(n.common.async===!1){let r=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return r.status===`aborted`?C:(r.status===`dirty`&&t.dirty(),e(r.value),{status:t.value,value:r.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(n=>n.status===`aborted`?C:(n.status===`dirty`&&t.dirty(),e(n.value).then(()=>({status:t.value,value:n.value}))))}if(r.type===`transform`)if(n.common.async===!1){let e=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!kt(e))return C;let a=r.transform(e.value,i);if(a instanceof Promise)throw Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);return{status:t.value,value:a}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(e=>kt(e)?Promise.resolve(r.transform(e.value,i)).then(e=>({status:t.value,value:e})):C);g.assertNever(r)}};N.create=(e,t,n)=>new N({schema:e,typeName:I.ZodEffects,effect:t,...D(n)}),N.createWithPreprocess=(e,t,n)=>new N({schema:t,effect:{type:`preprocess`,transform:e},typeName:I.ZodEffects,...D(n)});var P=class extends O{_parse(e){return this._getType(e)===_.undefined?w(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};P.create=(e,t)=>new P({innerType:e,typeName:I.ZodOptional,...D(t)});var F=class extends O{_parse(e){return this._getType(e)===_.null?w(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};F.create=(e,t)=>new F({innerType:e,typeName:I.ZodNullable,...D(t)});var jn=class extends O{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return t.parsedType===_.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};jn.create=(e,t)=>new jn({innerType:e,typeName:I.ZodDefault,defaultValue:typeof t.default==`function`?t.default:()=>t.default,...D(t)});var Mn=class extends O{_parse(e){let{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return At(r)?r.then(e=>({status:`valid`,value:e.status===`valid`?e.value:this._def.catchValue({get error(){return new b(n.common.issues)},input:n.data})})):{status:`valid`,value:r.status===`valid`?r.value:this._def.catchValue({get error(){return new b(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};Mn.create=(e,t)=>new Mn({innerType:e,typeName:I.ZodCatch,catchValue:typeof t.catch==`function`?t.catch:()=>t.catch,...D(t)});var Nn=class extends O{_parse(e){if(this._getType(e)!==_.nan){let t=this._getOrReturnCtx(e);return x(t,{code:y.invalid_type,expected:_.nan,received:t.parsedType}),C}return{status:`valid`,value:e.data}}};Nn.create=e=>new Nn({typeName:I.ZodNaN,...D(e)});var Pn=Symbol(`zod_brand`),Fn=class extends O{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}},In=class e extends O{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let e=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?C:e.status===`dirty`?(t.dirty(),Et(e.value)):this._def.out._parseAsync({data:e.value,path:n.path,parent:n})})();{let e=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?C:e.status===`dirty`?(t.dirty(),{status:`dirty`,value:e.value}):this._def.out._parseSync({data:e.value,path:n.path,parent:n})}}static create(t,n){return new e({in:t,out:n,typeName:I.ZodPipeline})}},Ln=class extends O{_parse(e){let t=this._def.innerType._parse(e),n=e=>(kt(e)&&(e.value=Object.freeze(e.value)),e);return At(t)?t.then(e=>n(e)):n(t)}unwrap(){return this._def.innerType}};Ln.create=(e,t)=>new Ln({innerType:e,typeName:I.ZodReadonly,...D(t)});function Rn(e,t){let n=typeof e==`function`?e(t):typeof e==`string`?{message:e}:e;return typeof n==`string`?{message:n}:n}function zn(e,t={},n){return e?fn.create().superRefine((r,i)=>{let a=e(r);if(a instanceof Promise)return a.then(e=>{if(!e){let e=Rn(t,r),a=e.fatal??n??!0;i.addIssue({code:`custom`,...e,fatal:a})}});if(!a){let e=Rn(t,r),a=e.fatal??n??!0;i.addIssue({code:`custom`,...e,fatal:a})}}):fn.create()}var Bn={object:A.lazycreate},I;(function(e){e.ZodString=`ZodString`,e.ZodNumber=`ZodNumber`,e.ZodNaN=`ZodNaN`,e.ZodBigInt=`ZodBigInt`,e.ZodBoolean=`ZodBoolean`,e.ZodDate=`ZodDate`,e.ZodSymbol=`ZodSymbol`,e.ZodUndefined=`ZodUndefined`,e.ZodNull=`ZodNull`,e.ZodAny=`ZodAny`,e.ZodUnknown=`ZodUnknown`,e.ZodNever=`ZodNever`,e.ZodVoid=`ZodVoid`,e.ZodArray=`ZodArray`,e.ZodObject=`ZodObject`,e.ZodUnion=`ZodUnion`,e.ZodDiscriminatedUnion=`ZodDiscriminatedUnion`,e.ZodIntersection=`ZodIntersection`,e.ZodTuple=`ZodTuple`,e.ZodRecord=`ZodRecord`,e.ZodMap=`ZodMap`,e.ZodSet=`ZodSet`,e.ZodFunction=`ZodFunction`,e.ZodLazy=`ZodLazy`,e.ZodLiteral=`ZodLiteral`,e.ZodEnum=`ZodEnum`,e.ZodEffects=`ZodEffects`,e.ZodNativeEnum=`ZodNativeEnum`,e.ZodOptional=`ZodOptional`,e.ZodNullable=`ZodNullable`,e.ZodDefault=`ZodDefault`,e.ZodCatch=`ZodCatch`,e.ZodPromise=`ZodPromise`,e.ZodBranded=`ZodBranded`,e.ZodPipeline=`ZodPipeline`,e.ZodReadonly=`ZodReadonly`})(I||={});var Vn=(e,t={message:`Input not instance of ${e.name}`})=>zn(t=>t instanceof e,t),L=nn.create,R=an.create,Hn=Nn.create,Un=on.create,z=sn.create,Wn=cn.create,Gn=ln.create,Kn=un.create,qn=dn.create,Jn=fn.create,B=pn.create,Yn=k.create,Xn=mn.create,V=hn.create,H=A.create,Zn=A.strictCreate,Qn=_n.create,U=vn.create,$n=bn.create,er=M.create,W=xn.create,tr=Sn.create,nr=Cn.create,rr=wn.create,ir=Tn.create,G=En.create,K=On.create,ar=kn.create,or=An.create,sr=N.create,cr=P.create,lr=F.create,ur=N.createWithPreprocess,dr=In.create,fr=()=>L().optional(),pr=()=>R().optional(),mr=()=>z().optional(),hr={string:(e=>nn.create({...e,coerce:!0})),number:(e=>an.create({...e,coerce:!0})),boolean:(e=>sn.create({...e,coerce:!0})),bigint:(e=>on.create({...e,coerce:!0})),date:(e=>cn.create({...e,coerce:!0}))},gr=C,_r=t({BRAND:()=>Pn,DIRTY:()=>Et,EMPTY_PATH:()=>Tt,INVALID:()=>C,NEVER:()=>gr,OK:()=>w,ParseStatus:()=>S,Schema:()=>O,ZodAny:()=>fn,ZodArray:()=>hn,ZodBigInt:()=>on,ZodBoolean:()=>sn,ZodBranded:()=>Fn,ZodCatch:()=>Mn,ZodDate:()=>cn,ZodDefault:()=>jn,ZodDiscriminatedUnion:()=>vn,ZodEffects:()=>N,ZodEnum:()=>On,ZodError:()=>b,ZodFirstPartyTypeKind:()=>I,ZodFunction:()=>wn,ZodIntersection:()=>bn,ZodIssueCode:()=>y,ZodLazy:()=>Tn,ZodLiteral:()=>En,ZodMap:()=>Sn,ZodNaN:()=>Nn,ZodNativeEnum:()=>kn,ZodNever:()=>k,ZodNull:()=>dn,ZodNullable:()=>F,ZodNumber:()=>an,ZodObject:()=>A,ZodOptional:()=>P,ZodParsedType:()=>_,ZodPipeline:()=>In,ZodPromise:()=>An,ZodReadonly:()=>Ln,ZodRecord:()=>xn,ZodSchema:()=>O,ZodSet:()=>Cn,ZodString:()=>nn,ZodSymbol:()=>ln,ZodTransformer:()=>N,ZodTuple:()=>M,ZodType:()=>O,ZodUndefined:()=>un,ZodUnion:()=>_n,ZodUnknown:()=>pn,ZodVoid:()=>mn,addIssueToContext:()=>x,any:()=>Jn,array:()=>V,bigint:()=>Un,boolean:()=>z,coerce:()=>hr,custom:()=>zn,date:()=>Wn,datetimeRegex:()=>Qt,defaultErrorMap:()=>bt,discriminatedUnion:()=>U,effect:()=>sr,enum:()=>K,function:()=>rr,getErrorMap:()=>Ct,getParsedType:()=>v,instanceof:()=>Vn,intersection:()=>$n,isAborted:()=>Dt,isAsync:()=>At,isDirty:()=>Ot,isValid:()=>kt,late:()=>Bn,lazy:()=>ir,literal:()=>G,makeIssue:()=>wt,map:()=>tr,nan:()=>Hn,nativeEnum:()=>ar,never:()=>Yn,null:()=>qn,nullable:()=>lr,number:()=>R,object:()=>H,objectUtil:()=>vt,oboolean:()=>mr,onumber:()=>pr,optional:()=>cr,ostring:()=>fr,pipeline:()=>dr,preprocess:()=>ur,promise:()=>or,quotelessJson:()=>yt,record:()=>W,set:()=>nr,setErrorMap:()=>St,strictObject:()=>Zn,string:()=>L,symbol:()=>Gn,transformer:()=>sr,tuple:()=>er,undefined:()=>Kn,union:()=>Qn,unknown:()=>B,util:()=>g,void:()=>Xn}),vr=H({username:L().min(1),password:L().min(1)}),yr=H({ok:G(!0),changePassword:z()}),br=H({oldPassword:L().min(1),newPassword:L().min(6)}),xr=H({ok:G(!0)}),Sr=H({authenticated:z(),username:L().optional()});H({password:L().min(1)});var Cr=class extends Error{fix;context;constructor(e,t,n){super(e),this.name=`MiravoError`,this.fix=t,this.context=n}},wr=`0.10.0`,Tr=1883,Er=4840,Dr=1502,Or={mqtt:Tr,opcua:Er,modbus:Dr},kr=65535;function Ar(e){return typeof e==`number`&&Number.isInteger(e)&&e>=1&&e<=65535}var jr=1e4,Mr=1e3,Nr=1e6,Pr=1e5,q=/^[a-zA-Z0-9_-]{1,64}$/,Fr=/^\$param\.(\S+)$/,Ir=R().int().min(1).max(kr),Lr=H({state:K([`healthy`,`busy`,`saturated`]),pendingWorkCount:R().finite().int().nonnegative(),completedLastTick:R().finite().int().nonnegative()}),Rr=H({active:R().finite().int().nonnegative(),subscriptions:R().finite().int().nonnegative().optional(),reads:R().finite().int().nonnegative().optional(),writes:R().finite().int().nonnegative().optional()}),zr=H({connected:z(),messagesPublished:R().finite().int().nonnegative(),messagesAttempted:R().finite().int().nonnegative(),messagesFiltered:R().finite().int().nonnegative(),errorsCount:R().finite().int().nonnegative(),rejectedWrites:R().finite().int().nonnegative().optional(),lastPublishMs:R().finite().nonnegative(),health:Lr.optional(),clients:Rr.optional()});H({name:L().min(1),enabled:z().default(!0)}).passthrough();var Br=H({name:L().min(1),enabled:z(),pending:z().optional(),endpoint:L().optional(),boundPort:Ir.optional(),config:W(L(),B())}),J=H({factoryName:L().min(1).optional(),core:H({state:K([`idle`,`running`,`paused`,`stopped`]),tickCount:R().int().nonnegative(),simulationTimeSeconds:R().finite().nonnegative(),pauseAtSimulationSeconds:R().finite().positive().optional(),assetCount:R().int().nonnegative(),memberValueCount:R().int().nonnegative(),quarantinedAssetCount:R().int().nonnegative(),engineErrorsCount:R().int().nonnegative(),lastEngineError:H({context:L(),message:L()}).optional(),tickOverrunsCount:R().int().nonnegative(),circuitBreakerTripsCount:R().int().nonnegative(),uptimeMs:R().finite().nonnegative(),actualTicksPerSecond:R().finite().nonnegative()}),fleet:H({modelBreakdown:V(H({model:L().min(1),count:R().int().nonnegative()})),lifecycleBreakdown:W(L(),R().int().nonnegative()),activeFaultCount:R().int().nonnegative(),faultBreakdown:V(H({fault:L().min(1),count:R().int().nonnegative()}))}),adapters:V(H({name:L().min(1),metrics:zr}))}),Vr=H({lines:V(H({line:L(),stations:V(H({id:L(),state:L(),good:R().int().nonnegative(),scrap:R().int().nonnegative()})),buffers:V(H({after:L(),level:R().int().nonnegative(),capacity:R().int().positive()}))})).optional(),factoryName:L().min(1).optional(),models:V(H({name:L().min(1),memberCount:R().int().nonnegative(),faultCount:R().int().nonnegative(),faultNames:V(L().min(1)),hasLifecycle:z()})),assets:V(H({id:L().min(1),model:L().min(1),browsePath:V(L().min(1)),lifecycleStage:L().min(1),operatingHours:R().finite().nonnegative(),activeFaults:V(L().min(1)),isQuarantined:z(),production:W(L(),Qn([R(),L(),z()])).optional()})),config:H({seed:R().int().nonnegative(),tickIntervalMs:R().int().positive(),timeMultiplier:R().finite().positive(),adapters:V(L().min(1)),template:H({name:L().min(1),path:L().min(1)}).optional()}),availableAdapters:V(Br).optional()}),Hr=H({templateId:L().min(1),templateName:L().min(1),templatePath:L().min(1),entryHash:L().min(1).optional(),assetIds:V(L().min(1)),models:V(L().min(1)),areas:V(H({name:L().min(1),lines:V(L().min(1))}))}),Ur=H({state:Vr,metrics:J,templates:V(Hr),revision:R().int().nonnegative()}),Wr=U(`authenticated`,[H({authenticated:G(!1)}),H({authenticated:G(!0),username:L().min(1),runtime:Ur})]),Gr=H({assetId:L().min(1),memberName:L().min(1),value:Qn([R().finite(),L(),z()]),quality:K([`good`,`bad`,`uncertain`]),timestamp:R().finite().optional()}),Kr=U(`kind`,[H({kind:G(`fault:triggered`),assetId:L().min(1),fault:L().min(1),effects:W(L(),B())}),H({kind:G(`fault:cleared`),assetId:L().min(1),fault:L().min(1)}),H({kind:G(`lifecycle:changed`),assetId:L().min(1),from:L().min(1),to:L().min(1),operatingHours:R().finite().nonnegative()}),H({kind:G(`asset:maintenance`),assetId:L().min(1),from:L().min(1),to:L().min(1),operatingHours:R().finite().nonnegative(),reason:K([`manual`,`scheduled`])}),H({kind:G(`asset:created`),id:L().min(1),assetType:L().min(1),browsePath:V(L().min(1))}),H({kind:G(`asset:removed`),id:L().min(1)}),H({kind:K([`template:loaded`,`template:unloaded`]),templateId:L().min(1),assetCount:R().int().nonnegative()}),H({kind:G(`engine:state`),from:J.shape.core.shape.state,to:J.shape.core.shape.state}),H({kind:G(`engine:error`),context:L(),message:L(),fix:L().optional()}),H({kind:G(`adapter:enabled`),name:L().min(1),endpoint:L().min(1)}),H({kind:G(`adapter:disabled`),name:L().min(1)})]),qr=H({core:H({memberValueCount:J.shape.core.shape.memberValueCount,quarantinedAssetCount:J.shape.core.shape.quarantinedAssetCount,engineErrorsCount:J.shape.core.shape.engineErrorsCount,tickOverrunsCount:J.shape.core.shape.tickOverrunsCount,circuitBreakerTripsCount:J.shape.core.shape.circuitBreakerTripsCount,uptimeMs:J.shape.core.shape.uptimeMs,actualTicksPerSecond:J.shape.core.shape.actualTicksPerSecond}),adapters:J.shape.adapters}),Jr=U(`type`,[H({type:G(`runtime:snapshot`),snapshot:Ur}),H({type:G(`runtime:tick`),revision:R().int().nonnegative(),tick:R().int().nonnegative(),simulationTime:R().finite().nonnegative(),delta:V(Gr),assetCount:R().int().nonnegative(),metrics:qr}),H({type:G(`runtime:event`),revision:R().int().nonnegative(),event:Kr}),H({type:G(`runtime:resync-required`),revision:R().int().nonnegative(),reason:L().min(1)})]),Yr=/^[A-Za-z0-9_-]+$/;function Xr(e){let t=/^(.+)-(\d+)$/.exec(e);if(!t)return null;let n=t[1],r=t[2];if(!n||!r)return null;let i=Number(r);return!Number.isSafeInteger(i)||i<1?null:{prefix:n,counter:i}}function Zr(e){let t=e.trim();if(t.length===0)return`Name is required.`;let n=t.split(`-`);if(n.some(e=>e.length===0))return`Use hyphen-delimited segments without empty parts.`;for(let e of n)if(!Yr.test(e))return`Use only letters, numbers, underscores, and hyphens.`;return null}function Qr(e){let t=e.trim();return t.length===0?null:t.length>120?`Use at most 120 characters.`:Zr(e)}var Y=`Must be 1-64 chars and contain only letters, numbers, underscores, or hyphens.`,X=K([`mqtt`,`opcua`,`modbus`]),$r=V(X).min(1),ei=H({asset:L().regex(q,Y),member:L().regex(q,Y)}).strict(),ti=H({model:L().min(1),id:L().regex(q,Y).optional(),count:R().int().positive().default(1),variation:R().min(0).max(1).default(0),parameters:W(L(),R().finite()).optional(),inputs:W(L().regex(q,Y),ei).optional(),starting_hours:R().finite().nonnegative().optional(),protocol_scope:$r.optional()}).strict(),ni=H({asset:L().min(1),ideal_cycle_s:R().finite().positive(),scrap_rate:R().finite().min(0).max(1).default(0),buffer_after:H({capacity:R().int().positive(),initial:R().int().nonnegative().default(0)}).strict().refine(e=>e.initial<=e.capacity,`Reduce initial to buffer capacity.`).optional()}).strict(),ri=H({source:G(`unlimited`),stations:V(ni).min(1)}).strict(),ii=K([`mon`,`tue`,`wed`,`thu`,`fri`,`sat`,`sun`]),ai=L().regex(/^([01]\d|2[0-3]):[0-5]\d$/,`Use HH:MM (00:00–23:59).`),oi=H({start:L().regex(/^(mon|tue|wed|thu|fri|sat|sun) ([01]\d|2[0-3]):[0-5]\d$/,`Use <day> HH:MM, e.g. mon 06:00.`).default(`mon 06:00`),timezone_offset_h:R().finite().min(-14).max(14).default(0),pattern:V(H({days:V(ii).min(1),start:ai,end:ai,breaks:V(H({start:ai,minutes:R().finite().positive()}).strict()).default([])}).strict()).min(1),changeovers:V(H({every_parts:R().int().positive(),minutes:R().finite().positive(),station:L().min(1)}).strict()).default([])}).strict(),si=H({name:L().regex(q,Y),assets:V(ti).min(1),flow:ri.optional(),protocol_scope:$r.optional()}).strict(),ci=H({name:L().regex(q,Y),lines:V(si).min(1),protocol_scope:$r.optional()}).strict(),li=Qn([H({enterprise:L().regex(q,Y),site:L().regex(q,Y)}).strict(),H({prefix:L().regex(q,Y)}).strict()]),ui=H({maxAttempts:R().finite().int().min(0).default(0),initialDelayMs:R().finite().int().positive().default(1e3),maxDelayMs:R().finite().int().positive().default(3e4)}).strict(),di=H({enabled:z().default(!1),deadband:R().finite().nonnegative().default(0)}).strict(),fi=K([`base`,`full`]),pi=H({embedded:z().default(!0),port:R().int().min(0).max(65535).default(1883),host:L().default(`127.0.0.1`),external:L().optional(),retain:z().default(!0),username:L().optional(),password:L().optional(),reconnect:ui.optional(),rbe:di.optional(),metadata:fi.default(`base`),drain_budget:R().int().min(512).max(65536).optional(),batch_size:R().int().min(64).max(16384).optional(),broker_concurrency:R().int().min(10).max(5e3).optional()});function mi(e){return e.refine(e=>!(e.embedded&&e.external),{message:`Cannot use both 'embedded: true' and 'external' URL. Set 'embedded: false' when using an external broker.`}).refine(e=>!e.password||e.username,{message:`Cannot set 'password' without 'username'.`})}mi(pi);var hi=H({port:R().int().min(0).max(65535).default(Er),host:L().default(`127.0.0.1`),security:K([`none`]).default(`none`),buildInfo:H({productName:L().default(`Miravo`)}).strict().optional(),write_budget:R().int().min(512).max(65536).optional()}).strict(),gi=H({port:R().int().min(0).max(65535).default(Dr),host:L().default(`127.0.0.1`)}).strict(),_i=H({mqtt:mi(pi.strict()).optional(),opcua:hi.optional(),modbus:gi.optional()}).strict(),vi=H({max_members_per_model:R().int().positive().max(Pr).default(Mr),max_asset_count:R().int().positive().max(Nr).default(jr)}).strict(),yi=H({tick_interval_ms:R().int().positive().default(1e3),max_step_s:R().finite().positive().default(1),max_substeps:R().int().min(1).default(60),time_multiplier:R().positive().max(1e3).default(1),seed:R().int().optional(),overrun_threshold_multiplier:R().min(1).max(10).optional(),limits:vi.optional()}).strict();H({kind:G(`MiravoTemplate`),version:G(`1`),name:L().min(1),description:L().optional(),namespace:li.optional(),areas:V(ci).min(1),protocols:_i.optional(),shifts:oi.optional(),settings:yi.optional()}).strict().superRefine((e,t)=>{let n=new Set,r=new Set;e.areas.forEach((e,i)=>{e.lines.forEach((e,a)=>{let o=[`areas`,i,`lines`,a];e.assets.forEach((e,r)=>{e.id&&(e.count!==1||n.has(e.id))&&t.addIssue({code:y.custom,path:[...o,`assets`,r],message:`Assignment id '${e.id}' must be unique with count: 1. Fix: use a unique id and count: 1.`}),e.id&&n.add(e.id)});let s=e.flow;(s?.stations??[]).forEach((n,i)=>{let a=[...o,`flow`,`stations`,i],c=e.assets.find(e=>e.id===n.asset);(!c||c.count!==1||r.has(n.asset))&&t.addIssue({code:y.custom,path:[...a,`asset`],message:`Invalid station '${n.asset}'. Fix: reference a unique assignment id with count: 1 in this same line.`}),r.add(n.asset),s&&i<s.stations.length-1&&!n.buffer_after&&t.addIssue({code:y.custom,path:a,message:`Station '${n.asset}' needs buffer_after. Fix: add buffer_after: { capacity: 1 }.`})})})});for(let n of e.shifts?.changeovers??[])r.has(n.station)||t.addIssue({code:y.custom,message:`Unknown changeover station '${n.station}'. Fix: reference a flow station id.`});let i=e.settings?.limits?.max_asset_count??1e4;for(let n=0;n<e.areas.length;n++){let r=e.areas[n];if(r)for(let e=0;e<r.lines.length;e++){let a=r.lines[e];if(a)for(let r=0;r<a.assets.length;r++){let o=a.assets[r];!o||o.count<=i||t.addIssue({code:y.custom,path:[`areas`,n,`lines`,e,`assets`,r,`count`],message:`Asset assignment count must be at most ${i}. Fix: reduce count or set settings.limits.max_asset_count higher.`})}}}});var bi=1e3,Z=H({correlationId:L().optional()}),xi=L().trim().min(1).superRefine((e,t)=>{let n=Qr(e);n&&t.addIssue({code:y.custom,message:n})}),Si=Z.extend({type:G(`spawn`),model:L().min(1),count:R().int().positive().max(jr),assetName:xi.optional(),assetPrefix:xi.optional(),protocolScope:$r.optional(),dryRun:z().optional()}),Ci=Z.extend({type:G(`removeAsset`),assetId:L().min(1)}),wi=Z.extend({type:G(`setParameter`),assetId:L().min(1),parameter:L().min(1),value:R().finite()}),Ti=Z.extend({type:G(`triggerFault`),assetId:L().min(1),fault:L().min(1)}),Ei=Z.extend({type:G(`clearFault`),assetId:L().min(1),fault:L().min(1)}),Di=Z.extend({type:G(`pause`)}),Oi=Z.extend({type:G(`resume`)}),ki=Z.extend({type:G(`setSpeed`),multiplier:R().positive().finite().max(bi)}),Ai=Z.extend({type:G(`unquarantine`),assetId:L().min(1)}),ji=Z.extend({type:G(`invokeMethod`),assetId:L().min(1),method:L().min(1),arguments:W(L().min(1),Qn([R().finite(),L(),z()])).optional()}),Mi=Z.extend({type:G(`loadTemplate`),templatePath:L().min(1)}),Ni=Z.extend({type:G(`unloadTemplate`),templateId:L().min(1)}),Pi=Z.extend({type:G(`resetFactory`)}),Fi=Z.extend({type:G(`enableAdapter`),adapter:L().min(1),config:W(L(),B()).optional()}),Ii=Z.extend({type:G(`disableAdapter`),adapter:L().min(1)}),Li=U(`type`,[Si,Ci,wi,Ti,Ei,Di,Oi,ki,Ai,ji,Mi,Ni,Pi,Fi,Ii]),Ri=H({success:z(),command:L(),correlationId:L().optional(),message:L(),data:B().optional(),error:L().optional()}),zi=`/api`,Bi=Qn([R().finite(),L(),z()]),Vi=er([R().finite(),R().finite()]),Hi=H({name:L().min(1),dataType:L().min(1),description:L().nullable()}),Ui=H({description:L().nullable(),inputArguments:V(Hi),outputArguments:V(Hi)}),Wi=H({id:L().min(1),assetType:L().min(1),browsePath:V(L().min(1)),lifecycleStage:L().min(1),operatingHours:R().finite().nonnegative(),activeFaults:V(L().min(1)),isQuarantined:z(),parameters:W(L().min(1),H({value:Bi,type:L().min(1),unit:L().optional()})),inputs:W(L().min(1),H({value:R().finite(),default:R().finite(),unit:L().optional(),binding:H({asset:L().min(1),member:L().min(1)}).nullable()})),members:W(L().min(1),H({value:Bi,quality:K([`good`,`bad`,`uncertain`]),timestamp:R().finite(),meta:H({kind:L().min(1),dataType:L().min(1),access:L().min(1),unit:L().nullable(),euRange:Vi.nullable()})})),methods:W(L().min(1),Ui)}),Gi=H({name:L().min(1),description:L().nullable(),memberCount:R().int().nonnegative(),methodCount:R().int().nonnegative(),faultCount:R().int().nonnegative(),hasLifecycle:z(),lifecycleStageCount:R().int().nonnegative(),source:L().min(1)}),Ki=H({model:L().min(1),count:R().int().nonnegative(),variation:R().finite().nonnegative(),parameters:W(L().min(1),R().finite()).optional(),protocol_scope:V(X).optional()}),qi=H({name:L().min(1),assets:V(Ki),protocol_scope:V(X).optional()}),Ji=H({name:L().min(1),lines:V(qi),protocol_scope:V(X).optional()}),Yi=H({id:L().min(1),name:L().min(1),description:L().nullable(),category:L().min(1),models:V(L().min(1)),assetCount:R().int().nonnegative(),memberCount:R().int().nonnegative(),source:L().min(1)}),Xi=Yi,Zi=Yi.extend({topology:V(Ji),namespace:H({enterprise:L().min(1).optional(),site:L().min(1).optional(),prefix:L().min(1).optional()}).optional(),settings:H({tickIntervalMs:R().int().positive().optional(),timeMultiplier:R().finite().positive().optional(),limits:H({maxMembersPerModel:R().int().positive().optional(),maxAssetCount:R().int().positive().optional()}).optional()}).optional()}),Qi=K([`idle`,`running`,`paused`,`stopped`]),$i=H({events:V(U(`type`,[H({id:R().int().nonnegative(),type:G(`fault:triggered`),assetId:L().min(1),fault:L().min(1),effects:W(L(),B()),tick:R().int().nonnegative(),simulationTime:R().finite().nonnegative(),timestamp:R().finite().nonnegative()}),H({id:R().int().nonnegative(),type:G(`fault:cleared`),assetId:L().min(1),fault:L().min(1),tick:R().int().nonnegative(),simulationTime:R().finite().nonnegative(),timestamp:R().finite().nonnegative()}),H({id:R().int().nonnegative(),type:G(`lifecycle:changed`),assetId:L().min(1),from:L().min(1),to:L().min(1),operatingHours:R().finite().nonnegative(),tick:R().int().nonnegative(),simulationTime:R().finite().nonnegative(),timestamp:R().finite().nonnegative()}),H({id:R().int().nonnegative(),type:G(`asset:maintenance`),assetId:L().min(1),from:L().min(1),to:L().min(1),operatingHours:R().finite().nonnegative(),reason:K([`manual`,`scheduled`]),tick:R().int().nonnegative(),simulationTime:R().finite().nonnegative(),timestamp:R().finite().nonnegative()}),H({id:R().int().nonnegative(),type:G(`asset:created`),assetId:L().min(1),assetType:L().min(1),browsePath:V(L().min(1)),tick:R().int().nonnegative(),simulationTime:R().finite().nonnegative(),timestamp:R().finite().nonnegative()}),H({id:R().int().nonnegative(),type:G(`asset:removed`),assetId:L().min(1),tick:R().int().nonnegative(),simulationTime:R().finite().nonnegative(),timestamp:R().finite().nonnegative()}),H({id:R().int().nonnegative(),type:K([`template:loaded`,`template:unloaded`]),templateId:L().min(1),assetCount:R().int().nonnegative(),tick:R().int().nonnegative(),simulationTime:R().finite().nonnegative(),timestamp:R().finite().nonnegative()}),H({id:R().int().nonnegative(),type:G(`engine:state-changed`),from:Qi,to:Qi,tick:R().int().nonnegative(),simulationTime:R().finite().nonnegative(),timestamp:R().finite().nonnegative()}),H({id:R().int().nonnegative(),type:G(`engine:error`),context:L(),message:L(),fix:L().optional(),tick:R().int().nonnegative(),simulationTime:R().finite().nonnegative(),timestamp:R().finite().nonnegative()}),H({id:R().int().nonnegative(),type:G(`integration:resource`),operationId:L().min(1),operationType:K([`apply`,`cleanup`]),templateId:L().min(1),targetLabel:L().min(1),hostname:L().min(1),phase:L().min(1),resourceType:L().min(1),resourceName:L().min(1),action:L().min(1),status:K([`success`,`failed`]),error:L().optional(),tick:R().int().nonnegative(),simulationTime:R().finite().nonnegative(),timestamp:R().finite().nonnegative()}),H({id:R().int().nonnegative(),type:G(`integration:operation`),operationId:L().min(1),operationType:K([`apply`,`cleanup`]),templateId:L().min(1),targetLabel:L().min(1),hostname:L().min(1),applied:R().int().nonnegative(),failed:R().int().nonnegative(),duration:R().int().nonnegative(),tick:R().int().nonnegative(),simulationTime:R().finite().nonnegative(),timestamp:R().finite().nonnegative()})])),nextCursor:R().int().nonnegative().nullable(),hasMore:z()}),ea=`litmus-edge`,ta=W(X,Ir),na=H({id:L().min(1),integrationId:L().min(1),label:L().min(1),hostname:L().min(1),apiTokenSet:z(),sourceHostname:L().min(1),exposedPorts:ta.optional(),lastUsedAt:R().int().nonnegative().optional()}).strict(),ra=H({targets:V(na)}).strict(),ia=H({integrationId:L().min(1).default(ea),label:L().min(1),hostname:L().min(1),apiToken:L().min(1),sourceHostname:L().min(1)}),aa=H({integrationId:L().min(1).optional(),label:L().min(1).optional(),hostname:L().min(1).optional(),apiToken:L().min(1).optional(),sourceHostname:L().min(1).optional()}),oa=H({targetId:L().min(1).optional(),hostname:L().min(1),apiToken:L().min(1).optional(),sourceHostname:L().min(1)}).superRefine((e,t)=>{!e.targetId&&!e.apiToken&&t.addIssue({code:y.custom,message:`apiToken is required when targetId is omitted.`,path:[`apiToken`]})}),sa=U(`connected`,[H({connected:G(!0),hostname:L().min(1),sourceHostname:L().min(1),litmusEdgeVersion:L().min(1).optional(),warning:L().min(1).optional()}),H({connected:G(!1),error:L().min(1)})]),ca=K([`devices`,`models`,`assets`]),la=K([`create`,`update`,`replace`,`delete`,`noop`,`blocked`]),ua=K([`device`,`model`,`asset`,`param-sync`]),da=K([`apply`,`cleanup`]),fa=K([`success`,`partial`,`blocked`,`noop`,`failed`]);K([`device`,`model`,`asset`,`param-sync`]),K([`create`,`update`,`replace`,`delete`]);var pa=H({area:L().min(1).optional(),line:L().min(1).optional(),asset:L().min(1).optional()}),ma=H({action:la,resourceType:ua,name:L().min(1),resourceId:L().min(1).optional(),protocol:X.optional(),endpoint:L().min(1).optional(),detail:L().min(1).optional(),blockReason:L().min(1).optional()}),ha=H({sourceMode:K([`static`,`managed`]),targetHost:L().min(1),sourceHostname:L().min(1).optional(),scope:V(ca),filters:pa,entries:V(ma)}),ga=H({plan:ha}),_a=`Provide exactly one of 'templateId' (a running template) or 'assetId' (a running standalone asset).`;function va(e,t){let n=(e,n)=>{if(e.code===`unrecognized_keys`&&e.keys.some(e=>e===`templateId`||e===`assetId`))return{message:t};if(e.code!==`invalid_union`)return{message:n.defaultError};let r=n.data,i=typeof r==`object`&&r?r:{},a=`templateId`in i;return a===`assetId`in i?{message:t}:{message:e.unionErrors[+!a]?.issues.map(e=>e.message).join(`; `)??t}};return Qn([H({...e,templateId:L().min(1)},{errorMap:n}).strict(),H({...e,assetId:L().min(1)},{errorMap:n}).strict()],{errorMap:n})}var ya=va({targetId:L().min(1),protocol:X.optional(),scope:V(ca).optional(),ifUnmanaged:K([`fail`,`skip`]).optional(),exposedPorts:ta.optional()},_a),ba=H({plan:ha,applied:R().int().nonnegative(),failed:R().int().nonnegative(),error:L().min(1).optional()}),xa=va({targetId:L().min(1),scope:V(ca).optional()},`Provide exactly one of 'templateId' or 'assetId'.`),Sa=H({plan:ha,deleted:R().int().nonnegative(),failed:R().int().nonnegative(),error:L().min(1).optional()}),Ca=H({create:R().int().nonnegative(),update:R().int().nonnegative(),replace:R().int().nonnegative(),delete:R().int().nonnegative(),noop:R().int().nonnegative(),failed:R().int().nonnegative(),total:R().int().nonnegative()}),wa=H({device:Ca,model:Ca,asset:Ca,"param-sync":Ca}),Ta=H({operations:V(H({schemaVersion:G(1),operationId:L().min(1),operationType:da,status:fa,factoryName:L().min(1),templateId:L().min(1).optional(),assetId:L().min(1).optional(),targetId:L().min(1),targetLabel:L().min(1),hostname:L().min(1),scope:V(L().min(1)),successCount:R().int().nonnegative(),failedCount:R().int().nonnegative(),blockedCount:R().int().nonnegative(),startedAt:R().int().nonnegative(),completedAt:R().int().nonnegative(),durationMs:R().int().nonnegative(),resourceCounts:wa,error:L().min(1).optional()}).refine(e=>e.templateId===void 0!=(e.assetId===void 0),{message:`An operation record names exactly one of 'templateId' or 'assetId'.`})),total:R().int().nonnegative(),hasMore:z()}),Ea=H({type:da.optional(),targetId:L().min(1).optional(),templateId:L().min(1).optional(),assetId:L().min(1).optional(),limit:hr.number().int().positive().max(500).optional(),offset:hr.number().int().nonnegative().optional()}),Da=H({cancelled:G(!0)}),Oa=H({operationId:L().min(1),type:da,templateId:L().min(1).optional(),assetId:L().min(1).optional(),targetLabel:L().min(1),totalPlanned:R().int().nonnegative(),attempt:R().int().positive().optional(),maxAttempts:R().int().positive().optional()}),ka=H({operationId:L().min(1),type:da,targetId:L().min(1).optional(),templateId:L().min(1).optional(),assetId:L().min(1).optional()}),Aa=H({operationId:L().min(1),phase:ua,total:R().int().nonnegative()}),ja=H({operationId:L().min(1),phase:ua,name:L().min(1),action:la,status:K([`success`,`failed`]),error:L().min(1).optional(),index:R().int().positive(),of:R().int().positive()}),Ma=H({operationId:L().min(1),applied:R().int().nonnegative().optional(),deleted:R().int().nonnegative().optional(),failed:R().int().nonnegative(),duration:R().int().nonnegative(),plan:ha}),Na=Ma,Pa=Ma,Fa=H({operationId:L().min(1),attempt:R().int().positive(),maxAttempts:R().int().positive(),delayMs:R().int().nonnegative(),error:L().min(1)}),Ia=H({message:L().min(1)}),La=H({level:K([`info`,`warn`,`error`]),message:L().min(1),protocol:X.optional(),port:Ir.optional(),templatePort:Ir.optional()}),Ra=U(`event`,[H({event:G(`log`),data:La}),H({event:G(`started`),data:Oa}),H({event:G(`accepted`),data:ka}),H({event:G(`phase`),data:Aa}),H({event:G(`resource`),data:ja}),H({event:G(`complete`),data:Na}),H({event:G(`cancelled`),data:Pa}),H({event:G(`retrying`),data:Fa}),H({event:G(`error`),data:Ia})]),za=H({enabled:z(),port:R().int().positive().optional()}),Ba=H({asset:L().min(1),browsePath:L(),member:L().min(1),model:L().min(1),dataType:L().min(1),unit:L().optional(),euRange:er([R().finite(),R().finite()]).optional(),access:L().min(1),kind:K([`variable`,`property`]),protocols:W(L(),W(L(),B()))}),Va=H({template:L().min(1).optional(),generatedAt:L().datetime(),protocols:W(L(),za),tags:V(Ba),summary:H({totalTags:R().int().nonnegative(),totalAssets:R().int().nonnegative(),enabledProtocols:V(L().min(1))})}),Ha=H({name:L().min(1),description:L().nullable(),parameters:W(L().min(1),H({type:L().min(1),default:Bi,unit:L().optional()})),inputs:W(L().min(1),H({default:R().finite(),unit:L().optional(),description:L().optional()})).optional(),members:W(L().min(1),H({kind:L().min(1),dataType:L().min(1),access:L().min(1),unit:L().nullable(),euRange:Vi.nullable(),default:Bi.nullable()})),methods:W(L().min(1),Ui),faults:V(L().min(1)),lifecycle:H({stages:V(L().min(1)),totalHours:R().finite().nonnegative()}).nullable()}),Ua=H({status:K([`ok`,`fail`]),factoryState:J.shape.core.shape.state,tickCount:R().int().nonnegative(),mqttEnabled:z(),mqttConnected:z().nullable(),opcuaEnabled:z(),opcuaConnected:z().nullable(),modbusEnabled:z(),modbusConnected:z().nullable(),stalled:z(),reason:L().optional(),factoryName:L().min(1).optional(),processId:L().min(1).optional()}),Wa=H({reason:L().min(1).optional()}),Ga=H({status:G(`shutting_down`)}),Ka=H({id:L().min(1)}),qa=H({name:L().min(1)}),Ja=H({id:L().min(1)}),Ya=H({operationId:L().min(1)}),Xa=H({id:L().min(1)}),Za=H({type:K([`fault:triggered`,`fault:cleared`,`lifecycle:changed`,`asset:maintenance`,`asset:created`,`asset:removed`,`template:loaded`,`template:unloaded`,`engine:state-changed`,`engine:error`,`integration:resource`,`integration:operation`]).optional(),assetId:L().min(1).optional(),limit:hr.number().int().positive().max(1e3).optional(),cursor:hr.number().int().nonnegative().optional()}),Qa=hr.number().int().min(1).max(kr).optional(),$a=H({host:L().min(1),protocol:X.optional(),modbusPort:Qa,opcuaPort:Qa,mqttPort:Qa}),eo=W(L(),B()),to=W(L(),B());function Q(e){return`${zi}${e}`}var no=[{method:`GET`,path:Q(`/openapi.json`),operationId:`openApiDocument`,auth:`none`,response:{kind:`json`,schema:to},description:`Generated OpenAPI document for the Miravo admin API.`},{method:`GET`,path:Q(`/healthz`),operationId:`health`,auth:`none`,response:{kind:`json`,schema:Ua},description:`Liveness probe for the Miravo admin server.`},{method:`GET`,path:Q(`/readyz`),operationId:`readiness`,auth:`none`,response:{kind:`json`,schema:Ua},description:`Readiness probe for the Miravo admin server.`},{method:`GET`,path:Q(`/metrics`),operationId:`metrics`,auth:`required`,response:{kind:`json`,schema:J},description:`Engine metrics snapshot.`},{method:`GET`,path:Q(`/state`),operationId:`state`,auth:`required`,response:{kind:`json`,schema:Vr},description:`Engine state snapshot.`},{method:`GET`,path:Q(`/bootstrap`),operationId:`bootstrap`,auth:`none`,response:{kind:`json`,schema:Wr},description:`Console bootstrap payload.`},{method:`POST`,path:Q(`/commands`),operationId:`commands`,auth:`required`,body:Li,response:{kind:`json`,schema:Ri},description:`Execute an engine command.`},{method:`POST`,path:Q(`/shutdown`),operationId:`shutdown`,auth:`required`,body:Wa,response:{kind:`json`,schema:Ga},description:`Request graceful shutdown.`},{method:`GET`,path:Q(`/assets/:id`),operationId:`assetDetail`,auth:`required`,params:Ka,response:{kind:`json`,schema:Wi},description:`Inspect a running asset.`},{method:`GET`,path:Q(`/models/:name`),operationId:`modelDetail`,auth:`required`,params:qa,response:{kind:`json`,schema:Ha},description:`Inspect a registered model schema.`},{method:`GET`,path:Q(`/events`),operationId:`events`,auth:`required`,query:Za,response:{kind:`json`,schema:$i},description:`Read paginated event log entries.`},{method:`GET`,path:Q(`/catalog/models`),operationId:`catalogModels`,auth:`required`,response:{kind:`json`,schema:V(Gi)},description:`List catalog models.`},{method:`GET`,path:Q(`/catalog/models/:name/le-dt.json`),operationId:`catalogModelLeDt`,auth:`required`,params:qa,response:{kind:`json`,schema:eo},description:`Download LE Digital Twin JSON for a catalog model.`},{method:`GET`,path:Q(`/catalog/models/:name/yaml`),operationId:`catalogModelYaml`,auth:`required`,params:qa,response:{kind:`yaml`},description:`Read raw YAML for a catalog model.`},{method:`GET`,path:Q(`/catalog/models/:name`),operationId:`catalogModelDetail`,auth:`required`,params:qa,response:{kind:`json`,schema:Ha},description:`Read catalog model schema.`},{method:`GET`,path:Q(`/catalog/templates/:id/le-template.json`),operationId:`catalogTemplateLeTemplateJson`,auth:`required`,params:Ja,query:$a,response:{kind:`passthrough`},description:`Download LE template JSON export.`},{method:`GET`,path:Q(`/catalog/templates/:id/le-tags.csv`),operationId:`catalogTemplateLeTagsCsv`,auth:`required`,params:Ja,query:$a,response:{kind:`passthrough`},description:`Download LE tags CSV export.`},{method:`GET`,path:Q(`/catalog/templates/:id/yaml`),operationId:`catalogTemplateYaml`,auth:`required`,params:Ja,response:{kind:`yaml`},description:`Read raw YAML for a catalog template.`},{method:`GET`,path:Q(`/catalog/templates/:id`),operationId:`catalogTemplateDetail`,auth:`required`,params:Ja,response:{kind:`json`,schema:Zi},description:`Read catalog template detail.`},{method:`GET`,path:Q(`/catalog/templates`),operationId:`catalogTemplates`,auth:`required`,response:{kind:`json`,schema:V(Xi)},description:`List catalog templates.`},{method:`GET`,path:Q(`/templates`),operationId:`templates`,auth:`required`,response:{kind:`json`,schema:V(Hr)},description:`List templates loaded into the factory.`},{method:`GET`,path:Q(`/manifest`),operationId:`manifest`,auth:`required`,response:{kind:`json`,schema:Va},description:`Read unified protocol manifest.`},{method:`POST`,path:Q(`/auth/login`),operationId:`authLogin`,auth:`none`,body:vr,response:{kind:`json`,schema:yr},description:`Authenticate and create an admin session.`},{method:`POST`,path:Q(`/auth/logout`),operationId:`authLogout`,auth:`none`,response:{kind:`json`,schema:xr},description:`Destroy the current admin session.`},{method:`PUT`,path:Q(`/auth/password`),operationId:`authPassword`,auth:`required`,body:br,response:{kind:`json`,schema:xr},description:`Change the admin password.`},{method:`GET`,path:Q(`/auth/status`),operationId:`authStatus`,auth:`none`,response:{kind:`json`,schema:Sr},description:`Check the current auth status.`},{method:`GET`,path:Q(`/ws`),operationId:`runtimeWebSocket`,auth:`required`,response:{kind:`passthrough`},description:`Upgrade to the runtime WebSocket stream.`},{method:`GET`,path:Q(`/integrations/le/operations`),operationId:`integrationOperations`,auth:`required`,query:Ea,response:{kind:`json`,schema:Ta},description:`List persisted integration operation summaries, optionally for one template or asset.`},{method:`GET`,path:Q(`/integrations/le/targets`),operationId:`integrationTargets`,auth:`required`,response:{kind:`json`,schema:ra},description:`List saved LE targets.`},{method:`POST`,path:Q(`/integrations/le/targets`),operationId:`integrationTargetCreate`,auth:`required`,body:ia,response:{kind:`json`,schema:na},description:`Create an LE target.`},{method:`POST`,path:Q(`/integrations/le/targets/test`),operationId:`integrationConnectionTest`,auth:`required`,body:oa,response:{kind:`json`,schema:sa},description:`Test LE target connectivity.`},{method:`GET`,path:Q(`/integrations/le/targets/:id`),operationId:`integrationTargetDetail`,auth:`required`,params:Xa,response:{kind:`json`,schema:na},description:`Read one LE target.`},{method:`PUT`,path:Q(`/integrations/le/targets/:id`),operationId:`integrationTargetById`,auth:`required`,params:Xa,body:aa,response:{kind:`json`,schema:na},description:`Update one LE target.`},{method:`DELETE`,path:Q(`/integrations/le/targets/:id`),operationId:`integrationTargetDelete`,auth:`required`,params:Xa,response:{kind:`json`,schema:H({message:L().min(1)})},description:`Delete one LE target.`},{method:`POST`,path:Q(`/integrations/le/plan`),operationId:`integrationPlan`,auth:`required`,body:ya,response:{kind:`json`,schema:ga},description:`Preview applying a running template or standalone asset to an LE target.`},{method:`POST`,path:Q(`/integrations/le/apply`),operationId:`integrationApply`,auth:`required`,body:ya,response:{kind:`json`,schema:ba},additionalSuccessResponses:{207:ba},description:`Apply a running template or standalone asset to an LE target.`},{method:`POST`,path:Q(`/integrations/le/cleanup/plan`),operationId:`integrationCleanupPlan`,auth:`required`,body:xa,response:{kind:`json`,schema:ga},description:`Preview removing what a template or standalone asset of this factory applied to an LE target.`},{method:`POST`,path:Q(`/integrations/le/cleanup`),operationId:`integrationCleanup`,auth:`required`,body:xa,response:{kind:`json`,schema:Sa},additionalSuccessResponses:{207:Sa},description:`Remove what a template or standalone asset of this factory applied to an LE target.`},{method:`POST`,path:Q(`/integrations/le/operations/:operationId/cancel`),operationId:`integrationOperationCancel`,auth:`required`,params:Ya,response:{kind:`json`,schema:Da},description:`Cancel an in-flight streaming LE operation.`},{method:`POST`,path:Q(`/integrations/le/apply/stream`),operationId:`integrationApplyStream`,auth:`required`,body:ya,response:{kind:`passthrough`},description:`Stream LE apply progress over SSE.`},{method:`POST`,path:Q(`/integrations/le/cleanup/stream`),operationId:`integrationCleanupStream`,auth:`required`,body:xa,response:{kind:`passthrough`},description:`Stream LE cleanup progress over SSE.`}],ro=H({code:K([`UNAUTHORIZED`,`NOT_FOUND`,`INVALID_REQUEST`,`INTERNAL_ERROR`]),message:L(),hint:L().optional()}),io={UNAUTHORIZED:401,NOT_FOUND:404,INVALID_REQUEST:400,INTERNAL_ERROR:500},ao=class extends Error{code;status;hint;constructor(e){super(e.message),this.name=`ApiError`,this.code=e.code,this.status=e.status??io[e.code],this.hint=e.hint}static is(e){return e instanceof Error&&e.name===`ApiError`}};function oo(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function so(e,t){return e?._def?.typeName===t}function co(e,t){let n=e.ZodType.prototype[t];e.ZodType.prototype[t]=function(...e){let t=n.apply(this,e);return t._def.openapi=this._def.openapi,t}}function lo(e){if(e.ZodType.prototype.openapi!==void 0)return;e.ZodType.prototype.openapi=function(e,t){let n=(typeof e==`string`?t:e)??{},{param:r}=n,i=oo(n,[`param`]),a=Object.assign(Object.assign({},this._def.openapi?._internal),typeof e==`string`?{refId:e}:void 0),o=Object.assign(Object.assign(Object.assign({},this._def.openapi?.metadata),i),this._def.openapi?.metadata?.param||r?{param:Object.assign(Object.assign({},this._def.openapi?.metadata?.param),r)}:void 0),s=new this.constructor(Object.assign(Object.assign({},this._def),{openapi:Object.assign(Object.assign({},Object.keys(a).length>0?{_internal:a}:void 0),Object.keys(o).length>0?{metadata:o}:void 0)}));if(so(this,`ZodObject`)){let e=this.extend;s.extend=function(...t){let n=e.apply(this,t);return n._def.openapi={_internal:{extendedFrom:this._def.openapi?._internal?.refId?{refId:this._def.openapi?._internal?.refId,schema:this}:this._def.openapi?._internal?.extendedFrom},metadata:n._def.openapi?.metadata},n}}return s},co(e,`optional`),co(e,`nullable`),co(e,`default`),co(e,`transform`),co(e,`refine`);let t=e.ZodObject.prototype.deepPartial;e.ZodObject.prototype.deepPartial=function(){let e=this._def.shape(),n=t.apply(this),r=n._def.shape();return Object.entries(r).forEach(([t,n])=>{n._def.openapi=e[t]?._def?.openapi}),n._def.openapi=void 0,n};let n=e.ZodObject.prototype.pick;e.ZodObject.prototype.pick=function(...e){let t=n.apply(this,e);return t._def.openapi=void 0,t};let r=e.ZodObject.prototype.omit;e.ZodObject.prototype.omit=function(...e){let t=r.apply(this,e);return t._def.openapi=void 0,t}}var uo=class{constructor(e){this.parents=e,this._definitions=[]}get definitions(){return[...this.parents?.flatMap(e=>e.definitions)??[],...this._definitions]}register(e,t){let n=this.schemaWithRefId(e,t);return this._definitions.push({type:`schema`,schema:n}),n}registerParameter(e,t){let n=this.schemaWithRefId(e,t),r=n._def.openapi?.metadata,i=n.openapi(Object.assign(Object.assign({},r),{param:Object.assign(Object.assign({},r?.param),{name:r?.param?.name??e})}));return this._definitions.push({type:`parameter`,schema:i}),i}registerPath(e){this._definitions.push({type:`route`,route:e})}registerWebhook(e){this._definitions.push({type:`webhook`,webhook:e})}registerComponent(e,t,n){return this._definitions.push({type:`component`,componentType:e,name:t,component:n}),{name:t,ref:{$ref:`#/components/${e}/${t}`}}}schemaWithRefId(e,t){return t.openapi(e)}};lo(_r),new uo,U(`type`,[Si.openapi(`SpawnCommand`),Ci.openapi(`RemoveAssetCommand`),wi.openapi(`SetParameterCommand`),Ti.openapi(`TriggerFaultCommand`),Ei.openapi(`ClearFaultCommand`),Di.openapi(`PauseCommand`),Oi.openapi(`ResumeCommand`),ki.openapi(`SetSpeedCommand`),Ai.openapi(`UnquarantineCommand`),ji.openapi(`InvokeMethodCommand`),Mi.openapi(`LoadTemplateCommand`),Ni.openapi(`UnloadTemplateCommand`),Pi.openapi(`ResetFactoryCommand`),Fi.openapi(`EnableAdapterCommand`),Ii.openapi(`DisableAdapterCommand`)]).openapi(`EngineCommand`);var fo=new Map(no.map(e=>[`${e.method} ${e.path}`,e]));function $(e,t){let n=fo.get(`${e} ${t}`);if(!n)throw Error(`Missing admin route definition for ${e} ${t}`);return n}var po={assetDetail:$(`GET`,`/api/assets/:id`),authLogin:$(`POST`,`/api/auth/login`),authLogout:$(`POST`,`/api/auth/logout`),authPassword:$(`PUT`,`/api/auth/password`),authStatus:$(`GET`,`/api/auth/status`),bootstrap:$(`GET`,`/api/bootstrap`),catalogModelDetail:$(`GET`,`/api/catalog/models/:name`),catalogModelLeDt:$(`GET`,`/api/catalog/models/:name/le-dt.json`),catalogModels:$(`GET`,`/api/catalog/models`),catalogModelYaml:$(`GET`,`/api/catalog/models/:name/yaml`),catalogTemplateDetail:$(`GET`,`/api/catalog/templates/:id`),catalogTemplateLeTagsCsv:$(`GET`,`/api/catalog/templates/:id/le-tags.csv`),catalogTemplateLeTemplateJson:$(`GET`,`/api/catalog/templates/:id/le-template.json`),catalogTemplates:$(`GET`,`/api/catalog/templates`),catalogTemplateYaml:$(`GET`,`/api/catalog/templates/:id/yaml`),commands:$(`POST`,`/api/commands`),events:$(`GET`,`/api/events`),health:$(`GET`,`/api/healthz`),integrationApply:$(`POST`,`/api/integrations/le/apply`),integrationApplyStream:$(`POST`,`/api/integrations/le/apply/stream`),integrationCleanup:$(`POST`,`/api/integrations/le/cleanup`),integrationCleanupPlan:$(`POST`,`/api/integrations/le/cleanup/plan`),integrationCleanupStream:$(`POST`,`/api/integrations/le/cleanup/stream`),integrationConnectionTest:$(`POST`,`/api/integrations/le/targets/test`),integrationOperationCancel:$(`POST`,`/api/integrations/le/operations/:operationId/cancel`),integrationOperations:$(`GET`,`/api/integrations/le/operations`),integrationPlan:$(`POST`,`/api/integrations/le/plan`),integrationTargetById:$(`PUT`,`/api/integrations/le/targets/:id`),integrationTargetCreate:$(`POST`,`/api/integrations/le/targets`),integrationTargetDelete:$(`DELETE`,`/api/integrations/le/targets/:id`),integrationTargetDetail:$(`GET`,`/api/integrations/le/targets/:id`),integrationTargets:$(`GET`,`/api/integrations/le/targets`),manifest:$(`GET`,`/api/manifest`),metrics:$(`GET`,`/api/metrics`),modelDetail:$(`GET`,`/api/models/:name`),openApiDocument:$(`GET`,`/api/openapi.json`),readiness:$(`GET`,`/api/readyz`),runtimeWebSocket:$(`GET`,`/api/ws`),shutdown:$(`POST`,`/api/shutdown`),state:$(`GET`,`/api/state`),templates:$(`GET`,`/api/templates`)},mo=`miravo:console-username`;function ho(){try{let e=sessionStorage.getItem(mo);return typeof e==`string`&&e.length>0?e:``}catch{return``}}function go(e){try{e!==null&&e.length>0?sessionStorage.setItem(mo,e):sessionStorage.removeItem(mo)}catch{}}var _o=new $e({defaultOptions:{queries:{staleTime:3e4,gcTime:10*6e4,retry:(e,t)=>{if(t instanceof Error&&t.message===`Session expired`)return!1;if(ao.is(t)){let e=t.status;if(e>=400&&e<500)return!1}return e<2},refetchOnWindowFocus:!1}}}),vo={catalog:{templates:()=>[`catalog`,`templates`],models:()=>[`catalog`,`models`],templateDetail:e=>[`catalog`,`template`,e],modelSchema:e=>[`catalog`,`model-schema`,e],modelSchemasBatch:e=>[`catalog`,`model-schemas-batch`,e]},spawnPreviewAll:[`spawn`,`preview`],spawnPreview:(e,t,n,r)=>[`spawn`,`preview`,e,t,n,r],events:(e,t)=>[`events`,e,t],tags:{manifest:e=>[`tags`,`manifest`,e]},integrations:{targets:()=>[`integrations`,`targets`],operationsList:()=>[`integrations`,`operations`,`list`],operationsFactory:()=>[`integrations`,`operations`,`factory`],plan:(e,t)=>[`integrations`,`plan`,e,t],operationsForTarget:e=>[`integrations`,`operations`,`target`,e],operations:()=>[`integrations`,`operations`]},assets:{detail:e=>[`assets`,e]}},yo=`miravo:query-cache:v2`,bo=5*6e4,xo=vo.integrations.targets(),So=`bootstrap`,Co=!0;function wo(e){try{let t=sessionStorage.getItem(yo);if(!t)return;let n=JSON.parse(t);if(typeof n!=`object`||!n)return;let r=n;if(typeof r.timestamp!=`number`)return;if(Date.now()-r.timestamp>bo){sessionStorage.removeItem(yo);return}Ae(e,r.state)}catch{}}function To(e){try{let t=ke(e,{shouldDehydrateQuery:e=>e.state.status===`success`&&e.queryKey[0]!==So&&!(e.queryKey[0]===xo[0]&&e.queryKey[1]===xo[1])}),n={timestamp:Date.now(),state:t};sessionStorage.setItem(yo,JSON.stringify(n))}catch{}}function Eo(e){let t=null,n=e.getQueryCache().subscribe(()=>{Co&&(t&&clearTimeout(t),t=setTimeout(()=>{Co&&To(e)},500))});return()=>{t&&clearTimeout(t),n()}}function Do(){try{sessionStorage.removeItem(yo)}catch{}}function Oo(){Co=!0}function ko(){Co=!1}var Ao=(void 0)?.trim()||`/api`;function jo(e,t){return`${e.trim().replace(/\/+$/,``)||`/api`}${t.startsWith(`/`)?t:`/${t}`}`}function Mo(){ko(),_o.cancelQueries(),_o.setQueryData([`bootstrap`],{authenticated:!1}),_o.removeQueries({predicate:e=>e.queryKey[0]!==`bootstrap`}),Do(),ft(),go(null)}function No(){typeof window>`u`||(Mo(),window.location.pathname!==`/login`&&window.location.replace(`/login`))}var Po=class extends Error{result;constructor(e){super(e.message),this.name=`CommandError`,this.result=e}};function Fo(e,t){let n=`${e} ${t}`;return e===502||e===503||e===504?`${n} — the Miravo server may not be running, or a reverse proxy cannot reach it.`:n}async function Io(e){try{let t=await e.json(),n=ro.safeParse(t);if(n.success)return new ao({code:n.data.code,status:e.status,message:n.data.message,hint:n.data.hint})}catch{}return Error(Fo(e.status,e.statusText))}async function Lo(e,t){return Bo(`/auth/login`,po.authLogin,{body:{username:e,password:t}})}async function Ro(){await Bo(`/auth/logout`,po.authLogout)}function zo(e,t){if(e.response.kind!==`json`)throw Error(`requestJSON requires a JSON route definition for ${e.method} ${e.path}`);return e.additionalSuccessResponses?.[t]??e.response.schema}async function Bo(e,t,n={}){let{body:r,init:i}=n,a={method:t.method,credentials:`include`,...i};if(t.body){let e=t.body.safeParse(r);if(!e.success)throw Error(`Invalid request for ${t.method} ${t.path}: ${e.error.message}`);a.headers={"content-type":`application/json`,...i?.headers??{}},a.body=JSON.stringify(e.data)}else if(r!==void 0)throw Error(`Route ${t.method} ${t.path} does not accept a JSON body.`);let o=await fetch(jo(Ao,e),a);if(o.status===401&&t.auth===`required`)throw No(),Error(`Session expired`);if(!o.ok)throw await Io(o);let s;try{s=await o.json()}catch{throw Error(`Invalid JSON response for ${t.method} ${t.path}`)}let c=zo(t,o.status).safeParse(s);if(!c.success)throw Error(`Invalid response for ${t.method} ${t.path}: ${c.error.message}`);return c.data}async function Vo(e,t){return Bo(`/auth/password`,po.authPassword,{body:{oldPassword:e,newPassword:t}})}async function Ho(){return Bo(`/bootstrap`,po.bootstrap)}async function Uo(e,t){return Bo(e,t)}async function Wo(e){let t=await Bo(`/commands`,po.commands,{body:e});if(!t.success)throw new Po(t);return t}async function Go(e,t){if(t.response.kind!==`passthrough`)throw Error(`fetchBlob requires a passthrough route definition for ${t.method} ${t.path}`);let n=await fetch(jo(Ao,e),{credentials:`include`});if(n.status===401&&t.auth===`required`)throw No(),Error(`Session expired`);if(!n.ok)throw Error(Fo(n.status,n.statusText));return n.blob()}async function Ko(e,t){if(t.response.kind!==`yaml`)throw Error(`fetchText requires a YAML route definition for ${t.method} ${t.path}`);let n=await fetch(jo(Ao,e),{credentials:`include`});if(n.status===401&&t.auth===`required`)throw No(),Error(`Session expired`);if(!n.ok)throw Error(Fo(n.status,n.statusText));return n.text()}export{L as $,Xr as A,wr as B,ao as C,ve as Ct,ei as D,r as Dt,zi as E,i as Et,Tr as F,z as G,Ar as H,Er as I,ir as J,U as K,Or as L,Qr as M,Jr as N,X as O,Dr as P,W as Q,q as R,po as S,se as St,Ra as T,o as Tt,Cr as U,Fr as V,V as W,R as X,G as Y,H as Z,Eo as _,l as _t,Go as a,mt as at,go as b,m as bt,Ho as c,Ke as ct,Wo as d,Be as dt,er as et,No as f,h as ft,wo as g,pe as gt,Oo as h,d as ht,Mo as i,ft as it,Zr as j,$r as k,Lo as l,qe as lt,jo as m,be as mt,Po as n,B as nt,Uo as o,_t as ot,Bo as p,xe as pt,K as q,Vo as r,y as rt,Ko as s,ot as st,Ao as t,Qn as tt,Ro as u,Ue as ut,vo as v,fe as vt,ro as w,f as wt,ho as x,p as xt,_o as y,oe as yt,Mr as z};
|
|
1
|
+
import{a as e,r as t}from"./rolldown-runtime-COnpUsM8.js";import{c as n}from"./vendor-charts-95ykyDlI.js";var r=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},i=new class extends r{#e;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e();return window.addEventListener(`visibilitychange`,t,!1),()=>{window.removeEventListener(`visibilitychange`,t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(e=>{typeof e==`boolean`?this.setFocused(e):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e==`boolean`?this.#e:globalThis.document?.visibilityState!==`hidden`}},a={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},o=new class{#e=a;setTimeoutProvider(e){this.#e=e}setTimeout(e,t){return this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}};function s(e){setTimeout(e,0)}var c=typeof window>`u`||`Deno`in globalThis;function l(){}function u(e,t){return typeof e==`function`?e(t):e}function d(e){return typeof e==`number`&&e>=0&&e!==1/0}function f(e,t){return Math.max(e+(t||0)-Date.now(),0)}function p(e,t){return typeof e==`function`?e(t):e}function m(e,t){return typeof e==`function`?e(t):e}function ee(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==ne(o,t.options))return!1}else if(!ie(t.queryKey,o))return!1}if(n!==`all`){let e=t.isActive();if(n===`active`&&!e||n===`inactive`&&e)return!1}return!(typeof s==`boolean`&&t.isStale()!==s||i&&i!==t.state.fetchStatus||a&&!a(t))}function te(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(re(t.options.mutationKey)!==re(a))return!1}else if(!ie(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function ne(e,t){return(t?.queryKeyHashFn||re)(e)}function re(e){return JSON.stringify(e,(e,t)=>le(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function ie(e,t){return e===t?!0:typeof e==typeof t&&e&&t&&typeof e==`object`&&typeof t==`object`?Object.keys(t).every(n=>ie(e[n],t[n])):!1}var ae=Object.prototype.hasOwnProperty;function oe(e,t,n=0){if(e===t)return e;if(n>500)return t;let r=ce(e)&&ce(t);if(!r&&!(le(e)&&le(t)))return t;let i=(r?e:Object.keys(e)).length,a=r?t:Object.keys(t),o=a.length,s=r?Array(o):{},c=0;for(let l=0;l<o;l++){let o=r?l:a[l],u=e[o],d=t[o];if(u===d){s[o]=u,(r?l<i:ae.call(e,o))&&c++;continue}if(u===null||d===null||typeof u!=`object`||typeof d!=`object`){s[o]=d;continue}let f=oe(u,d,n+1);s[o]=f,f===u&&c++}return i===o&&c===i?e:s}function se(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function ce(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function le(e){if(!ue(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!ue(n)||!n.hasOwnProperty(`isPrototypeOf`)||Object.getPrototypeOf(e)!==Object.prototype)}function ue(e){return Object.prototype.toString.call(e)===`[object Object]`}function de(e){return new Promise(t=>{o.setTimeout(t,e)})}function fe(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:oe(e,t)}function pe(e){return e}function me(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function he(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var ge=Symbol();function _e(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===ge?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function ve(e,t){return typeof e==`function`?e(...t):!!e}function ye(e,t,n){let r=!1,i;return Object.defineProperty(e,`signal`,{enumerable:!0,get:()=>(i??=t(),r?i:(r=!0,i.aborted?n():i.addEventListener(`abort`,n,{once:!0}),i))}),e}var be=(()=>{let e=()=>c;return{isServer(){return e()},setIsServer(t){e=t}}})();function xe(){let e,t,n=new Promise((n,r)=>{e=n,t=r});n.status=`pending`,n.catch(()=>{});function r(e){Object.assign(n,e),delete n.resolve,delete n.reject}return n.resolve=t=>{r({status:`fulfilled`,value:t}),e(t)},n.reject=e=>{r({status:`rejected`,reason:e}),t(e)},n}function Se(e){let t;if(e.then(e=>(t=e,e),l)?.catch(l),t!==void 0)return{data:t}}function Ce(e){return e}function we(e){return{mutationKey:e.options.mutationKey,state:e.state,...e.options.scope&&{scope:e.options.scope},...e.meta&&{meta:e.meta}}}function Te(e,t,n){let r=()=>{let r=e.promise?.then(t).catch(e=>n(e)?Promise.reject(Error(`redacted`)):Promise.reject(e));return r?.catch(l),r};return{dehydratedAt:Date.now(),state:{...e.state,...e.state.data!==void 0&&{data:t(e.state.data)}},queryKey:e.queryKey,queryHash:e.queryHash,...e.state.status===`pending`&&{promise:r()},...e.meta&&{meta:e.meta}}}function Ee(e){return e.state.isPaused}function De(e){return e.state.status===`success`}function Oe(e){return!0}function ke(e,t={}){let n=t.shouldDehydrateMutation??e.getDefaultOptions().dehydrate?.shouldDehydrateMutation??Ee,r=e.getMutationCache().getAll().flatMap(e=>n(e)?[we(e)]:[]),i=t.shouldDehydrateQuery??e.getDefaultOptions().dehydrate?.shouldDehydrateQuery??De,a=t.shouldRedactErrors??e.getDefaultOptions().dehydrate?.shouldRedactErrors??Oe,o=t.serializeData??e.getDefaultOptions().dehydrate?.serializeData??Ce;return{mutations:r,queries:e.getQueryCache().getAll().flatMap(e=>i(e)?[Te(e,o,a)]:[])}}function Ae(e,t,n){if(typeof t!=`object`||!t)return;let r=e.getMutationCache(),i=e.getQueryCache(),a=n?.defaultOptions?.deserializeData??e.getDefaultOptions().hydrate?.deserializeData??Ce,o=t.mutations||[],s=t.queries||[];o.forEach(({state:t,...i})=>{r.build(e,{...e.getDefaultOptions().hydrate?.mutations,...n?.defaultOptions?.mutations,...i},t)}),s.forEach(({queryKey:t,state:r,queryHash:o,meta:s,promise:c,dehydratedAt:u})=>{let d=c?Se(c):void 0,f=r.data===void 0?d?.data:r.data,p=f===void 0?f:a(f),m=i.get(o),ee=m?.state.status===`pending`,te=m?.state.fetchStatus===`fetching`;if(m){let e=d&&u!==void 0&&u>m.state.dataUpdatedAt;if(r.dataUpdatedAt>m.state.dataUpdatedAt||e){let{fetchStatus:e,...t}=r;m.setState({...t,data:p})}}else m=i.build(e,{...e.getDefaultOptions().hydrate?.queries,...n?.defaultOptions?.queries,queryKey:t,queryHash:o,meta:s},{...r,data:p,fetchStatus:`idle`,status:p===void 0?r.status:`success`});c&&!ee&&!te&&(u===void 0||u>m.state.dataUpdatedAt)&&m.fetch(void 0,{initialPromise:Promise.resolve(c).then(a)}).catch(l)})}var je=s;function Me(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=je,a=r=>{t?e.push(r):i(()=>{n(r)})},o=()=>{let t=e;e=[],t.length&&i(()=>{r(()=>{t.forEach(e=>{n(e)})})})};return{batch:e=>{let n;t++;try{n=e()}finally{t--,t||o()}return n},batchCalls:e=>(...t)=>{a(()=>{e(...t)})},schedule:a,setNotifyFunction:e=>{n=e},setBatchNotifyFunction:e=>{r=e},setScheduler:e=>{i=e}}}var h=Me(),Ne=new class extends r{#e=!0;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&window.addEventListener){let t=()=>e(!0),n=()=>e(!1);return window.addEventListener(`online`,t,!1),window.addEventListener(`offline`,n,!1),()=>{window.removeEventListener(`online`,t),window.removeEventListener(`offline`,n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(t=>{t(e)}))}isOnline(){return this.#e}};function Pe(e){return Math.min(1e3*2**e,3e4)}function Fe(e){return(e??`online`)===`online`?Ne.isOnline():!0}var Ie=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function Le(e){let t=!1,n=0,r,a=xe(),o=()=>a.status!==`pending`,s=t=>{if(!o()){let n=new Ie(t);p(n),e.onCancel?.(n)}},c=()=>{t=!0},l=()=>{t=!1},u=()=>i.isFocused()&&(e.networkMode===`always`||Ne.isOnline())&&e.canRun(),d=()=>Fe(e.networkMode)&&e.canRun(),f=e=>{o()||(r?.(),a.resolve(e))},p=e=>{o()||(r?.(),a.reject(e))},m=()=>new Promise(t=>{r=e=>{(o()||u())&&t(e)},e.onPause?.()}).then(()=>{r=void 0,o()||e.onContinue?.()}),ee=()=>{if(o())return;let r,i=n===0?e.initialPromise:void 0;try{r=i??e.fn()}catch(e){r=Promise.reject(e)}Promise.resolve(r).then(f).catch(r=>{if(o())return;let i=e.retry??(be.isServer()?0:3),a=e.retryDelay??Pe,s=typeof a==`function`?a(n,r):a,c=i===!0||typeof i==`number`&&n<i||typeof i==`function`&&i(n,r);if(t||!c){p(r);return}n++,e.onFail?.(n,r),de(s).then(()=>u()?void 0:m()).then(()=>{t?p(r):ee()})})};return{promise:a,status:()=>a.status,cancel:s,continue:()=>(r?.(),a),cancelRetry:c,continueRetry:l,canStart:d,start:()=>(d()?ee():m().then(ee),a)}}var Re=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),d(this.gcTime)&&(this.#e=o.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(be.isServer()?1/0:300*1e3))}clearGcTimeout(){this.#e!==void 0&&(o.clearTimeout(this.#e),this.#e=void 0)}},ze=class extends Re{#e;#t;#n;#r;#i;#a;#o;constructor(e){super(),this.#o=!1,this.#a=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#r=e.client,this.#n=this.#r.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#e=He(this.options),this.state=e.state??this.#e,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#i?.promise}setOptions(e){if(this.options={...this.#a,...e},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let e=He(this.options);e.data!==void 0&&(this.setState(Ve(e.data,e.dataUpdatedAt)),this.#e=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus===`idle`&&this.#n.remove(this)}setData(e,t){let n=fe(this.state.data,e,this.options);return this.#c({data:n,type:`success`,dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e,t){this.#c({type:`setState`,state:e,setStateOptions:t})}cancel(e){let t=this.#i?.promise;return this.#i?.cancel(e),t?t.then(l).catch(l):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#e}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>m(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===ge||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>p(e.options.staleTime,this)===`static`):!1}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e===`static`?!1:this.state.isInvalidated?!0:!f(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#i?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#i?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#i&&(this.#o||this.#s()?this.#i.cancel({revert:!0}):this.#i.cancelRetry()),this.scheduleGc()),this.#n.notify({type:`observerRemoved`,query:this,observer:e}))}getObserversCount(){return this.observers.length}#s(){return this.state.fetchStatus===`paused`&&this.state.status===`pending`}invalidate(){this.state.isInvalidated||this.#c({type:`invalidate`})}async fetch(e,t){if(this.state.fetchStatus!==`idle`&&this.#i?.status()!==`rejected`){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#i)return this.#i.continueRetry(),this.#i.promise}if(e&&this.setOptions(e),!this.options.queryFn){let e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}let n=new AbortController,r=e=>{Object.defineProperty(e,`signal`,{enumerable:!0,get:()=>(this.#o=!0,n.signal)})},i=()=>{let e=_e(this.options,t),n=(()=>{let e={client:this.#r,queryKey:this.queryKey,meta:this.meta};return r(e),e})();return this.#o=!1,this.options.persister?this.options.persister(e,n,this):e(n)},a=(()=>{let e={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#r,state:this.state,fetchFn:i};return r(e),e})();this.options.behavior?.onFetch(a,this),this.#t=this.state,(this.state.fetchStatus===`idle`||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#c({type:`fetch`,meta:a.fetchOptions?.meta}),this.#i=Le({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:e=>{e instanceof Ie&&e.revert&&this.setState({...this.#t,fetchStatus:`idle`}),n.abort()},onFail:(e,t)=>{this.#c({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#c({type:`pause`})},onContinue:()=>{this.#c({type:`continue`})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0});try{let e=await this.#i.start();if(e===void 0)throw Error(`${this.queryHash} data is undefined`);return this.setData(e),this.#n.config.onSuccess?.(e,this),this.#n.config.onSettled?.(e,this.state.error,this),e}catch(e){if(e instanceof Ie){if(e.silent)return this.#i.promise;if(e.revert){if(this.state.data===void 0)throw e;return this.state.data}}throw this.#c({type:`error`,error:e}),this.#n.config.onError?.(e,this),this.#n.config.onSettled?.(this.state.data,e,this),e}finally{this.scheduleGc()}}#c(e){this.state=(t=>{switch(e.type){case`failed`:return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case`pause`:return{...t,fetchStatus:`paused`};case`continue`:return{...t,fetchStatus:`fetching`};case`fetch`:return{...t,...Be(t.data,this.options),fetchMeta:e.meta??null};case`success`:let n={...t,...Ve(e.data,e.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!e.manual&&{fetchStatus:`idle`,fetchFailureCount:0,fetchFailureReason:null}};return this.#t=e.manual?n:void 0,n;case`error`:let r=e.error;return{...t,error:r,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:`idle`,status:`error`,isInvalidated:!0};case`invalidate`:return{...t,isInvalidated:!0};case`setState`:return{...t,...e.state}}})(this.state),h.batch(()=>{this.observers.forEach(e=>{e.onQueryUpdate()}),this.#n.notify({query:this,type:`updated`,action:e})})}};function Be(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Fe(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function Ve(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:`success`}}function He(e){let t=typeof e.initialData==`function`?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt==`function`?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?`success`:`pending`,fetchStatus:`idle`}}function Ue(e){return{onFetch:(t,n)=>{let r=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,a=t.state.data?.pages||[],o=t.state.data?.pageParams||[],s={pages:[],pageParams:[]},c=0,l=async()=>{let n=!1,l=e=>{ye(e,()=>t.signal,()=>n=!0)},u=_e(t.options,t.fetchOptions),d=async(e,r,i)=>{if(n)return Promise.reject();if(r==null&&e.pages.length)return Promise.resolve(e);let a=await u((()=>{let e={client:t.client,queryKey:t.queryKey,pageParam:r,direction:i?`backward`:`forward`,meta:t.options.meta};return l(e),e})()),{maxPages:o}=t.options,s=i?he:me;return{pages:s(e.pages,a,o),pageParams:s(e.pageParams,r,o)}};if(i&&a.length){let e=i===`backward`,t=e?Ge:We,n={pages:a,pageParams:o};s=await d(n,t(r,n),e)}else{let t=e??a.length;do{let e=c===0?o[0]??r.initialPageParam:We(r,s);if(c>0&&e==null)break;s=await d(s,e),c++}while(c<t)}return s};t.options.persister?t.fetchFn=()=>t.options.persister?.(l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):t.fetchFn=l}}}function We(e,{pages:t,pageParams:n}){let r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function Ge(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}function Ke(e,t){return t?We(e,t)!=null:!1}function qe(e,t){return!t||!e.getPreviousPageParam?!1:Ge(e,t)!=null}var Je=class extends Re{#e;#t;#n;#r;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||Ye(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:`observerRemoved`,mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status===`pending`?this.scheduleGc():this.#n.remove(this))}continue(){return this.#r?.continue()??this.execute(this.state.variables)}async execute(e){let t=()=>{this.#i({type:`continue`})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#r=Le({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(Error(`No mutationFn found`)),onFail:(e,t)=>{this.#i({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#i({type:`pause`})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)});let r=this.state.status===`pending`,i=!this.#r.canStart();try{if(r)t();else{this.#i({type:`pending`,variables:e,isPaused:i}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);let t=await this.options.onMutate?.(e,n);t!==this.state.context&&this.#i({type:`pending`,context:t,variables:e,isPaused:i})}let a=await this.#r.start();return await this.#n.config.onSuccess?.(a,e,this.state.context,this,n),await this.options.onSuccess?.(a,e,this.state.context,n),await this.#n.config.onSettled?.(a,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(a,null,e,this.state.context,n),this.#i({type:`success`,data:a}),a}catch(t){try{await this.#n.config.onError?.(t,e,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,n)}catch(e){Promise.reject(e)}try{await this.#n.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,n)}catch(e){Promise.reject(e)}throw this.#i({type:`error`,error:t}),t}finally{this.#n.runNext(this)}}#i(e){this.state=(t=>{switch(e.type){case`failed`:return{...t,failureCount:e.failureCount,failureReason:e.error};case`pause`:return{...t,isPaused:!0};case`continue`:return{...t,isPaused:!1};case`pending`:return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:`pending`,variables:e.variables,submittedAt:Date.now()};case`success`:return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:`success`,isPaused:!1};case`error`:return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:`error`}}})(this.state),h.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function Ye(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var Xe=class extends r{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}#e;#t;#n;build(e,t,n){let r=new Je({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=Ze(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=Ze(e);if(typeof t==`string`){let n=this.#t.get(t);if(n)if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=Ze(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}else return!0}runNext(e){let t=Ze(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){h.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>te(t,e))}findAll(e={}){return this.getAll().filter(t=>te(e,t))}notify(e){h.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return h.batch(()=>Promise.all(e.map(e=>e.continue().catch(l))))}};function Ze(e){return e.options.scope?.id}var Qe=class extends r{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,n){let r=t.queryKey,i=t.queryHash??ne(r,t),a=this.get(i);return a||(a=new ze({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){h.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>ee(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>ee(e,t)):t}notify(e){h.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){h.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){h.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},$e=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new Qe,this.#t=e.mutationCache||new Xe,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=i.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=Ne.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(p(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=u(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return h.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;h.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return h.batch(()=>(n.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,...e},t)))}cancelQueries(e,t={}){let n={revert:!0,...t},r=h.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(l).catch(l)}invalidateQueries(e,t={}){return h.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=h.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(l)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(l)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(p(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(l).catch(l)}fetchInfiniteQuery(e){return e.behavior=Ue(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(l).catch(l)}ensureInfiniteQueryData(e){return e.behavior=Ue(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return Ne.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(re(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{ie(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(re(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{ie(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=ne(t.queryKey,t),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===ge&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},et=e(n(),1),tt=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e))},o=t=e(r,i,a);return a},nt=(e=>e?tt(e):tt),rt=e=>e;function it(e,t=rt){let n=et.useSyncExternalStore(e.subscribe,et.useCallback(()=>t(e.getState()),[e,t]),et.useCallback(()=>t(e.getInitialState()),[e,t]));return et.useDebugValue(n),n}var at=e=>{let t=nt(e),n=e=>it(t,e);return Object.assign(n,t),n},ot=(e=>e?at(e):at),st=200,ct=60,lt=1e3,ut=`miravo:runtime-snapshot`;function dt(e){try{sessionStorage.setItem(ut,JSON.stringify(e))}catch{}}function ft(){try{sessionStorage.removeItem(ut)}catch{}}function pt(e){if(typeof e!=`object`||!e)return!1;let t=e;if(typeof t.revision!=`number`||typeof t.state!=`object`||t.state===null||typeof t.metrics!=`object`||t.metrics===null)return!1;let n=t.metrics;return typeof n.core!=`object`||n.core===null?!1:Array.isArray(t.templates)}function mt(){try{let e=sessionStorage.getItem(ut);if(!e)return null;let t=JSON.parse(e);return pt(t)?t:(ft(),null)}catch{return ft(),null}}function ht(e){let t=e.metrics.core.tickCount,n=e.metrics.core.actualTicksPerSecond,r=Date.now();return{connectionState:`live`,connectionStateSince:r,reconnectAttempts:0,fatalError:null,lastRevision:e.revision,factoryName:e.state.factoryName??e.metrics.factoryName??``,seed:e.state.config.seed,engineState:e.metrics.core.state,tick:t,simulationTime:e.metrics.core.simulationTimeSeconds,tickIntervalMs:e.state.config.tickIntervalMs,lastTickReceivedAt:r,assetCount:e.metrics.core.assetCount,memberValueCount:e.metrics.core.memberValueCount,quarantinedAssetCount:e.metrics.core.quarantinedAssetCount,engineErrorsCount:e.metrics.core.engineErrorsCount,tickOverrunsCount:e.metrics.core.tickOverrunsCount,circuitBreakerTripsCount:e.metrics.core.circuitBreakerTripsCount,tps:n,uptimeMs:e.metrics.core.uptimeMs,speedMultiplier:e.state.config.timeMultiplier,assets:[...e.state.assets],models:[...e.state.models],tpsHistory:[{tick:t,tps:n,sampledAtMs:r}],lines:[...e.state.lines??[]],templates:[...e.templates],bootTemplate:e.state.config.template,availableAdapters:e.state.availableAdapters??[],adapterMetrics:e.metrics.adapters??[],memberValues:new Map,events:[]}}function gt(e,t){return{connectionState:`live`,connectionStateSince:e.connectionState===`live`?e.connectionStateSince:t,reconnectAttempts:0,fatalError:null}}var _t=ot((e,t)=>({connectionState:`booting`,connectionStateSince:Date.now(),reconnectAttempts:0,fatalError:null,lastRevision:0,factoryName:``,seed:null,engineState:`idle`,tick:0,simulationTime:0,tickIntervalMs:1e3,lastTickReceivedAt:0,assetCount:0,memberValueCount:0,quarantinedAssetCount:0,engineErrorsCount:0,tickOverrunsCount:0,circuitBreakerTripsCount:0,tps:0,uptimeMs:0,speedMultiplier:1,assets:[],models:[],tpsHistory:[],lines:[],templates:[],bootTemplate:void 0,availableAdapters:[],adapterMetrics:[],memberValues:new Map,events:[],replaceRuntime:(n,r)=>{let i=t().lastRevision;i>0&&(n.revision<i&&!r?.allowRevisionRewind||n.revision===i&&!r?.allowSameRevision)||(e(()=>ht(n)),dt(n))},applyTick:n=>{let r=t();if(n.revision<=r.lastRevision)return;let i=n.delta??[],a=n.tick??r.tick,o=n.simulationTime??r.simulationTime,s=n.assetCount??r.assetCount,c=n.metrics.core.actualTicksPerSecond,l=Date.now();if(!(i.length>0||a!==r.tick||o!==r.simulationTime||s!==r.assetCount||n.metrics.adapters!==r.adapterMetrics||n.metrics.core.engineErrorsCount!==r.engineErrorsCount||n.metrics.core.tickOverrunsCount!==r.tickOverrunsCount||n.metrics.core.circuitBreakerTripsCount!==r.circuitBreakerTripsCount||n.metrics.core.memberValueCount!==r.memberValueCount||n.metrics.core.quarantinedAssetCount!==r.quarantinedAssetCount||c!==r.tps)){e({...gt(r,l),lastTickReceivedAt:l,lastRevision:n.revision});return}let u={...gt(r,l),tick:a,simulationTime:o,lastTickReceivedAt:l,assetCount:s,memberValueCount:n.metrics.core.memberValueCount,quarantinedAssetCount:n.metrics.core.quarantinedAssetCount,engineErrorsCount:n.metrics.core.engineErrorsCount,tickOverrunsCount:n.metrics.core.tickOverrunsCount,circuitBreakerTripsCount:n.metrics.core.circuitBreakerTripsCount,tps:c,uptimeMs:n.metrics.core.uptimeMs,adapterMetrics:n.metrics.adapters,lastRevision:n.revision},d=r.tpsHistory.at(-1),f={tps:c,tick:a,sampledAtMs:l};if(!d||l-d.sampledAtMs>=lt?u.tpsHistory=[...r.tpsHistory,f].slice(-ct):u.tpsHistory=[...r.tpsHistory.slice(0,-1),f],i.length>0){let e=new Map(r.memberValues),t=new Set;for(let n of i){if(!t.has(n.assetId)){let r=e.get(n.assetId);e.set(n.assetId,new Map(r)),t.add(n.assetId)}e.get(n.assetId)?.set(n.memberName,{value:n.value,quality:n.quality})}u.memberValues=e}e(u)},applyEvent:(n,r)=>{let i=t();if(r<=i.lastRevision)return;let a=Date.now(),o=[n,...i.events].slice(0,st),s={...gt(i,a),events:o,lastRevision:r};if(n.kind===`asset:removed`){let t=new Map(i.memberValues);t.delete(n.id),e({...s,memberValues:t});return}if(n.kind===`fault:triggered`||n.kind===`fault:cleared`){let t=i.assets.map(e=>{if(e.id!==n.assetId)return e;let t=n.kind===`fault:triggered`?[...e.activeFaults,n.fault]:e.activeFaults.filter(e=>e!==n.fault);return{...e,activeFaults:t}});e({...s,assets:t});return}if(n.kind===`lifecycle:changed`||n.kind===`asset:maintenance`){let t=i.assets.map(e=>e.id===n.assetId?{...e,lifecycleStage:n.to,operatingHours:n.operatingHours}:e);e({...s,assets:t});return}if(n.kind===`engine:state`){e({...s,engineState:n.to});return}e(s)},markConnection:n=>{t().connectionState!==n&&e({connectionState:n,connectionStateSince:Date.now()})},markFatal:t=>{e({connectionState:`fatal`,connectionStateSince:Date.now(),fatalError:t})},markUnauthenticated:()=>{t().connectionState!==`unauthenticated`&&e({connectionState:`unauthenticated`,connectionStateSince:Date.now()})},noteReconnectAttempt:()=>{e(e=>({reconnectAttempts:e.reconnectAttempts+1}))},resetReconnectAttempts:()=>{t().reconnectAttempts!==0&&e({reconnectAttempts:0})}})),g;(function(e){e.assertEqual=e=>{};function t(e){}e.assertIs=t;function n(e){throw Error()}e.assertNever=n,e.arrayToEnum=e=>{let t={};for(let n of e)t[n]=n;return t},e.getValidEnumValues=t=>{let n=e.objectKeys(t).filter(e=>typeof t[t[e]]!=`number`),r={};for(let e of n)r[e]=t[e];return e.objectValues(r)},e.objectValues=t=>e.objectKeys(t).map(function(e){return t[e]}),e.objectKeys=typeof Object.keys==`function`?e=>Object.keys(e):e=>{let t=[];for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t},e.find=(e,t)=>{for(let n of e)if(t(n))return n},e.isInteger=typeof Number.isInteger==`function`?e=>Number.isInteger(e):e=>typeof e==`number`&&Number.isFinite(e)&&Math.floor(e)===e;function r(e,t=` | `){return e.map(e=>typeof e==`string`?`'${e}'`:e).join(t)}e.joinValues=r,e.jsonStringifyReplacer=(e,t)=>typeof t==`bigint`?t.toString():t})(g||={});var vt;(function(e){e.mergeShapes=(e,t)=>({...e,...t})})(vt||={});var _=g.arrayToEnum([`string`,`nan`,`number`,`integer`,`float`,`boolean`,`date`,`bigint`,`symbol`,`function`,`undefined`,`null`,`array`,`object`,`unknown`,`promise`,`void`,`never`,`map`,`set`]),v=e=>{switch(typeof e){case`undefined`:return _.undefined;case`string`:return _.string;case`number`:return Number.isNaN(e)?_.nan:_.number;case`boolean`:return _.boolean;case`function`:return _.function;case`bigint`:return _.bigint;case`symbol`:return _.symbol;case`object`:return Array.isArray(e)?_.array:e===null?_.null:e.then&&typeof e.then==`function`&&e.catch&&typeof e.catch==`function`?_.promise:typeof Map<`u`&&e instanceof Map?_.map:typeof Set<`u`&&e instanceof Set?_.set:typeof Date<`u`&&e instanceof Date?_.date:_.object;default:return _.unknown}},y=g.arrayToEnum([`invalid_type`,`invalid_literal`,`custom`,`invalid_union`,`invalid_union_discriminator`,`invalid_enum_value`,`unrecognized_keys`,`invalid_arguments`,`invalid_return_type`,`invalid_date`,`invalid_string`,`too_small`,`too_big`,`invalid_intersection_types`,`not_multiple_of`,`not_finite`]),yt=e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,`$1:`),b=class e extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name=`ZodError`,this.issues=e}format(e){let t=e||function(e){return e.message},n={_errors:[]},r=e=>{for(let i of e.issues)if(i.code===`invalid_union`)i.unionErrors.map(r);else if(i.code===`invalid_return_type`)r(i.returnTypeError);else if(i.code===`invalid_arguments`)r(i.argumentsError);else if(i.path.length===0)n._errors.push(t(i));else{let e=n,r=0;for(;r<i.path.length;){let n=i.path[r];r===i.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(i))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(this),n}static assert(t){if(!(t instanceof e))throw Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,g.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=e=>e.message){let t={},n=[];for(let r of this.issues)if(r.path.length>0){let n=r.path[0];t[n]=t[n]||[],t[n].push(e(r))}else n.push(e(r));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};b.create=e=>new b(e);var bt=(e,t)=>{let n;switch(e.code){case y.invalid_type:n=e.received===_.undefined?`Required`:`Expected ${e.expected}, received ${e.received}`;break;case y.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,g.jsonStringifyReplacer)}`;break;case y.unrecognized_keys:n=`Unrecognized key(s) in object: ${g.joinValues(e.keys,`, `)}`;break;case y.invalid_union:n=`Invalid input`;break;case y.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${g.joinValues(e.options)}`;break;case y.invalid_enum_value:n=`Invalid enum value. Expected ${g.joinValues(e.options)}, received '${e.received}'`;break;case y.invalid_arguments:n=`Invalid function arguments`;break;case y.invalid_return_type:n=`Invalid function return type`;break;case y.invalid_date:n=`Invalid date`;break;case y.invalid_string:typeof e.validation==`object`?`includes`in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position==`number`&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):`startsWith`in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:`endsWith`in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:g.assertNever(e.validation):n=e.validation===`regex`?`Invalid`:`Invalid ${e.validation}`;break;case y.too_small:n=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at least`:`more than`} ${e.minimum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at least`:`over`} ${e.minimum} character(s)`:e.type===`number`||e.type===`bigint`?`Number must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${e.minimum}`:e.type===`date`?`Date must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${new Date(Number(e.minimum))}`:`Invalid input`;break;case y.too_big:n=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at most`:`less than`} ${e.maximum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at most`:`under`} ${e.maximum} character(s)`:e.type===`number`?`Number must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`bigint`?`BigInt must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`date`?`Date must be ${e.exact?`exactly`:e.inclusive?`smaller than or equal to`:`smaller than`} ${new Date(Number(e.maximum))}`:`Invalid input`;break;case y.custom:n=`Invalid input`;break;case y.invalid_intersection_types:n=`Intersection results could not be merged`;break;case y.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case y.not_finite:n=`Number must be finite`;break;default:n=t.defaultError,g.assertNever(e)}return{message:n}},xt=bt;function St(e){xt=e}function Ct(){return xt}var wt=e=>{let{data:t,path:n,errorMaps:r,issueData:i}=e,a=[...n,...i.path||[]],o={...i,path:a};if(i.message!==void 0)return{...i,path:a,message:i.message};let s=``,c=r.filter(e=>!!e).slice().reverse();for(let e of c)s=e(o,{data:t,defaultError:s}).message;return{...i,path:a,message:s}},Tt=[];function x(e,t){let n=Ct(),r=wt({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===bt?void 0:bt].filter(e=>!!e)});e.common.issues.push(r)}var S=class e{constructor(){this.value=`valid`}dirty(){this.value===`valid`&&(this.value=`dirty`)}abort(){this.value!==`aborted`&&(this.value=`aborted`)}static mergeArray(e,t){let n=[];for(let r of t){if(r.status===`aborted`)return C;r.status===`dirty`&&e.dirty(),n.push(r.value)}return{status:e.value,value:n}}static async mergeObjectAsync(t,n){let r=[];for(let e of n){let t=await e.key,n=await e.value;r.push({key:t,value:n})}return e.mergeObjectSync(t,r)}static mergeObjectSync(e,t){let n={};for(let r of t){let{key:t,value:i}=r;if(t.status===`aborted`||i.status===`aborted`)return C;t.status===`dirty`&&e.dirty(),i.status===`dirty`&&e.dirty(),t.value!==`__proto__`&&(i.value!==void 0||r.alwaysSet)&&(n[t.value]=i.value)}return{status:e.value,value:n}}},C=Object.freeze({status:`aborted`}),Et=e=>({status:`dirty`,value:e}),w=e=>({status:`valid`,value:e}),Dt=e=>e.status===`aborted`,Ot=e=>e.status===`dirty`,kt=e=>e.status===`valid`,At=e=>typeof Promise<`u`&&e instanceof Promise,T;(function(e){e.errToObj=e=>typeof e==`string`?{message:e}:e||{},e.toString=e=>typeof e==`string`?e:e?.message})(T||={});var E=class{constructor(e,t,n,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=r}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},jt=(e,t)=>{if(kt(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw Error(`Validation failed but no issues detected.`);return{success:!1,get error(){return this._error||=new b(e.common.issues),this._error}}};function D(e){if(!e)return{};let{errorMap:t,invalid_type_error:n,required_error:r,description:i}=e;if(t&&(n||r))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(t,i)=>{let{message:a}=e;return t.code===`invalid_enum_value`?{message:a??i.defaultError}:i.data===void 0?{message:a??r??i.defaultError}:t.code===`invalid_type`?{message:a??n??i.defaultError}:{message:i.defaultError}},description:i}}var O=class{get description(){return this._def.description}_getType(e){return v(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:v(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new S,ctx:{common:e.parent.common,data:e.data,parsedType:v(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(At(t))throw Error(`Synchronous parse encountered promise.`);return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){let n={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:v(e)};return jt(n,this._parseSync({data:e,path:n.path,parent:n}))}"~validate"(e){let t={common:{issues:[],async:!!this[`~standard`].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:v(e)};if(!this[`~standard`].async)try{let n=this._parseSync({data:e,path:[],parent:t});return kt(n)?{value:n.value}:{issues:t.common.issues}}catch(e){e?.message?.toLowerCase()?.includes(`encountered`)&&(this[`~standard`].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(e=>kt(e)?{value:e.value}:{issues:t.common.issues})}async parseAsync(e,t){let n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){let n={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:v(e)},r=this._parse({data:e,path:n.path,parent:n});return jt(n,await(At(r)?r:Promise.resolve(r)))}refine(e,t){let n=e=>typeof t==`string`||t===void 0?{message:t}:typeof t==`function`?t(e):t;return this._refinement((t,r)=>{let i=e(t),a=()=>r.addIssue({code:y.custom,...n(t)});return typeof Promise<`u`&&i instanceof Promise?i.then(e=>e?!0:(a(),!1)):i?!0:(a(),!1)})}refinement(e,t){return this._refinement((n,r)=>e(n)?!0:(r.addIssue(typeof t==`function`?t(n,r):t),!1))}_refinement(e){return new M({schema:this,typeName:F.ZodEffects,effect:{type:`refinement`,refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this[`~standard`]={version:1,vendor:`zod`,validate:e=>this[`~validate`](e)}}optional(){return N.create(this,this._def)}nullable(){return P.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return hn.create(this)}promise(){return jn.create(this,this._def)}or(e){return _n.create([this,e],this._def)}and(e){return xn.create(this,e,this._def)}transform(e){return new M({...D(this._def),schema:this,typeName:F.ZodEffects,effect:{type:`transform`,transform:e}})}default(e){let t=typeof e==`function`?e:()=>e;return new Mn({...D(this._def),innerType:this,defaultValue:t,typeName:F.ZodDefault})}brand(){return new In({typeName:F.ZodBranded,type:this,...D(this._def)})}catch(e){let t=typeof e==`function`?e:()=>e;return new Nn({...D(this._def),innerType:this,catchValue:t,typeName:F.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Ln.create(this,e)}readonly(){return Rn.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Mt=/^c[^\s-]{8,}$/i,Nt=/^[0-9a-z]+$/,Pt=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Ft=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,It=/^[a-z0-9_-]{21}$/i,Lt=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Rt=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,zt=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Bt=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,Vt,Ht=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Ut=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,Wt=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Gt=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Kt=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,qt=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Jt=`((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))`,Yt=RegExp(`^${Jt}$`);function Xt(e){let t=`[0-5]\\d`;e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision??(t=`${t}(\\.\\d+)?`);let n=e.precision?`+`:`?`;return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function Zt(e){return RegExp(`^${Xt(e)}$`)}function Qt(e){let t=`${Jt}T${Xt(e)}`,n=[];return n.push(e.local?`Z?`:`Z`),e.offset&&n.push(`([+-]\\d{2}:?\\d{2})`),t=`${t}(${n.join(`|`)})`,RegExp(`^${t}$`)}function $t(e,t){return!!((t===`v4`||!t)&&Ht.test(e)||(t===`v6`||!t)&&Wt.test(e))}function en(e,t){if(!Lt.test(e))return!1;try{let[n]=e.split(`.`);if(!n)return!1;let r=n.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(n.length+(4-n.length%4)%4,`=`),i=JSON.parse(atob(r));return!(typeof i!=`object`||!i||`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&i.alg!==t)}catch{return!1}}function tn(e,t){return!!((t===`v4`||!t)&&Ut.test(e)||(t===`v6`||!t)&&Gt.test(e))}var nn=class e extends O{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==_.string){let t=this._getOrReturnCtx(e);return x(t,{code:y.invalid_type,expected:_.string,received:t.parsedType}),C}let t=new S,n;for(let r of this._def.checks)if(r.kind===`min`)e.data.length<r.value&&(n=this._getOrReturnCtx(e,n),x(n,{code:y.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind===`max`)e.data.length>r.value&&(n=this._getOrReturnCtx(e,n),x(n,{code:y.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind===`length`){let i=e.data.length>r.value,a=e.data.length<r.value;(i||a)&&(n=this._getOrReturnCtx(e,n),i?x(n,{code:y.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}):a&&x(n,{code:y.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}),t.dirty())}else if(r.kind===`email`)zt.test(e.data)||(n=this._getOrReturnCtx(e,n),x(n,{validation:`email`,code:y.invalid_string,message:r.message}),t.dirty());else if(r.kind===`emoji`)Vt||=new RegExp(Bt,`u`),Vt.test(e.data)||(n=this._getOrReturnCtx(e,n),x(n,{validation:`emoji`,code:y.invalid_string,message:r.message}),t.dirty());else if(r.kind===`uuid`)Ft.test(e.data)||(n=this._getOrReturnCtx(e,n),x(n,{validation:`uuid`,code:y.invalid_string,message:r.message}),t.dirty());else if(r.kind===`nanoid`)It.test(e.data)||(n=this._getOrReturnCtx(e,n),x(n,{validation:`nanoid`,code:y.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid`)Mt.test(e.data)||(n=this._getOrReturnCtx(e,n),x(n,{validation:`cuid`,code:y.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid2`)Nt.test(e.data)||(n=this._getOrReturnCtx(e,n),x(n,{validation:`cuid2`,code:y.invalid_string,message:r.message}),t.dirty());else if(r.kind===`ulid`)Pt.test(e.data)||(n=this._getOrReturnCtx(e,n),x(n,{validation:`ulid`,code:y.invalid_string,message:r.message}),t.dirty());else if(r.kind===`url`)try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),x(n,{validation:`url`,code:y.invalid_string,message:r.message}),t.dirty()}else r.kind===`regex`?(r.regex.lastIndex=0,r.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),x(n,{validation:`regex`,code:y.invalid_string,message:r.message}),t.dirty())):r.kind===`trim`?e.data=e.data.trim():r.kind===`includes`?e.data.includes(r.value,r.position)||(n=this._getOrReturnCtx(e,n),x(n,{code:y.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),t.dirty()):r.kind===`toLowerCase`?e.data=e.data.toLowerCase():r.kind===`toUpperCase`?e.data=e.data.toUpperCase():r.kind===`startsWith`?e.data.startsWith(r.value)||(n=this._getOrReturnCtx(e,n),x(n,{code:y.invalid_string,validation:{startsWith:r.value},message:r.message}),t.dirty()):r.kind===`endsWith`?e.data.endsWith(r.value)||(n=this._getOrReturnCtx(e,n),x(n,{code:y.invalid_string,validation:{endsWith:r.value},message:r.message}),t.dirty()):r.kind===`datetime`?Qt(r).test(e.data)||(n=this._getOrReturnCtx(e,n),x(n,{code:y.invalid_string,validation:`datetime`,message:r.message}),t.dirty()):r.kind===`date`?Yt.test(e.data)||(n=this._getOrReturnCtx(e,n),x(n,{code:y.invalid_string,validation:`date`,message:r.message}),t.dirty()):r.kind===`time`?Zt(r).test(e.data)||(n=this._getOrReturnCtx(e,n),x(n,{code:y.invalid_string,validation:`time`,message:r.message}),t.dirty()):r.kind===`duration`?Rt.test(e.data)||(n=this._getOrReturnCtx(e,n),x(n,{validation:`duration`,code:y.invalid_string,message:r.message}),t.dirty()):r.kind===`ip`?$t(e.data,r.version)||(n=this._getOrReturnCtx(e,n),x(n,{validation:`ip`,code:y.invalid_string,message:r.message}),t.dirty()):r.kind===`jwt`?en(e.data,r.alg)||(n=this._getOrReturnCtx(e,n),x(n,{validation:`jwt`,code:y.invalid_string,message:r.message}),t.dirty()):r.kind===`cidr`?tn(e.data,r.version)||(n=this._getOrReturnCtx(e,n),x(n,{validation:`cidr`,code:y.invalid_string,message:r.message}),t.dirty()):r.kind===`base64`?Kt.test(e.data)||(n=this._getOrReturnCtx(e,n),x(n,{validation:`base64`,code:y.invalid_string,message:r.message}),t.dirty()):r.kind===`base64url`?qt.test(e.data)||(n=this._getOrReturnCtx(e,n),x(n,{validation:`base64url`,code:y.invalid_string,message:r.message}),t.dirty()):g.assertNever(r);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(t=>e.test(t),{validation:t,code:y.invalid_string,...T.errToObj(n)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(e){return this._addCheck({kind:`email`,...T.errToObj(e)})}url(e){return this._addCheck({kind:`url`,...T.errToObj(e)})}emoji(e){return this._addCheck({kind:`emoji`,...T.errToObj(e)})}uuid(e){return this._addCheck({kind:`uuid`,...T.errToObj(e)})}nanoid(e){return this._addCheck({kind:`nanoid`,...T.errToObj(e)})}cuid(e){return this._addCheck({kind:`cuid`,...T.errToObj(e)})}cuid2(e){return this._addCheck({kind:`cuid2`,...T.errToObj(e)})}ulid(e){return this._addCheck({kind:`ulid`,...T.errToObj(e)})}base64(e){return this._addCheck({kind:`base64`,...T.errToObj(e)})}base64url(e){return this._addCheck({kind:`base64url`,...T.errToObj(e)})}jwt(e){return this._addCheck({kind:`jwt`,...T.errToObj(e)})}ip(e){return this._addCheck({kind:`ip`,...T.errToObj(e)})}cidr(e){return this._addCheck({kind:`cidr`,...T.errToObj(e)})}datetime(e){return typeof e==`string`?this._addCheck({kind:`datetime`,precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:`datetime`,precision:e?.precision===void 0?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...T.errToObj(e?.message)})}date(e){return this._addCheck({kind:`date`,message:e})}time(e){return typeof e==`string`?this._addCheck({kind:`time`,precision:null,message:e}):this._addCheck({kind:`time`,precision:e?.precision===void 0?null:e?.precision,...T.errToObj(e?.message)})}duration(e){return this._addCheck({kind:`duration`,...T.errToObj(e)})}regex(e,t){return this._addCheck({kind:`regex`,regex:e,...T.errToObj(t)})}includes(e,t){return this._addCheck({kind:`includes`,value:e,position:t?.position,...T.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:`startsWith`,value:e,...T.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:`endsWith`,value:e,...T.errToObj(t)})}min(e,t){return this._addCheck({kind:`min`,value:e,...T.errToObj(t)})}max(e,t){return this._addCheck({kind:`max`,value:e,...T.errToObj(t)})}length(e,t){return this._addCheck({kind:`length`,value:e,...T.errToObj(t)})}nonempty(e){return this.min(1,T.errToObj(e))}trim(){return new e({...this._def,checks:[...this._def.checks,{kind:`trim`}]})}toLowerCase(){return new e({...this._def,checks:[...this._def.checks,{kind:`toLowerCase`}]})}toUpperCase(){return new e({...this._def,checks:[...this._def.checks,{kind:`toUpperCase`}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind===`datetime`)}get isDate(){return!!this._def.checks.find(e=>e.kind===`date`)}get isTime(){return!!this._def.checks.find(e=>e.kind===`time`)}get isDuration(){return!!this._def.checks.find(e=>e.kind===`duration`)}get isEmail(){return!!this._def.checks.find(e=>e.kind===`email`)}get isURL(){return!!this._def.checks.find(e=>e.kind===`url`)}get isEmoji(){return!!this._def.checks.find(e=>e.kind===`emoji`)}get isUUID(){return!!this._def.checks.find(e=>e.kind===`uuid`)}get isNANOID(){return!!this._def.checks.find(e=>e.kind===`nanoid`)}get isCUID(){return!!this._def.checks.find(e=>e.kind===`cuid`)}get isCUID2(){return!!this._def.checks.find(e=>e.kind===`cuid2`)}get isULID(){return!!this._def.checks.find(e=>e.kind===`ulid`)}get isIP(){return!!this._def.checks.find(e=>e.kind===`ip`)}get isCIDR(){return!!this._def.checks.find(e=>e.kind===`cidr`)}get isBase64(){return!!this._def.checks.find(e=>e.kind===`base64`)}get isBase64url(){return!!this._def.checks.find(e=>e.kind===`base64url`)}get minLength(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};nn.create=e=>new nn({checks:[],typeName:F.ZodString,coerce:e?.coerce??!1,...D(e)});function rn(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=(t.toString().split(`.`)[1]||``).length,i=n>r?n:r;return Number.parseInt(e.toFixed(i).replace(`.`,``))%Number.parseInt(t.toFixed(i).replace(`.`,``))/10**i}var an=class e extends O{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==_.number){let t=this._getOrReturnCtx(e);return x(t,{code:y.invalid_type,expected:_.number,received:t.parsedType}),C}let t,n=new S;for(let r of this._def.checks)r.kind===`int`?g.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),x(t,{code:y.invalid_type,expected:`integer`,received:`float`,message:r.message}),n.dirty()):r.kind===`min`?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),x(t,{code:y.too_small,minimum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind===`max`?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),x(t,{code:y.too_big,maximum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind===`multipleOf`?rn(e.data,r.value)!==0&&(t=this._getOrReturnCtx(e,t),x(t,{code:y.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):r.kind===`finite`?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),x(t,{code:y.not_finite,message:r.message}),n.dirty()):g.assertNever(r);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit(`min`,e,!0,T.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,T.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,T.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,T.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:T.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(e){return this._addCheck({kind:`int`,message:T.toString(e)})}positive(e){return this._addCheck({kind:`min`,value:0,inclusive:!1,message:T.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:0,inclusive:!1,message:T.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:0,inclusive:!0,message:T.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:0,inclusive:!0,message:T.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:T.toString(t)})}finite(e){return this._addCheck({kind:`finite`,message:T.toString(e)})}safe(e){return this._addCheck({kind:`min`,inclusive:!0,value:-(2**53-1),message:T.toString(e)})._addCheck({kind:`max`,inclusive:!0,value:2**53-1,message:T.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind===`int`||e.kind===`multipleOf`&&g.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let n of this._def.checks)if(n.kind===`finite`||n.kind===`int`||n.kind===`multipleOf`)return!0;else n.kind===`min`?(t===null||n.value>t)&&(t=n.value):n.kind===`max`&&(e===null||n.value<e)&&(e=n.value);return Number.isFinite(t)&&Number.isFinite(e)}};an.create=e=>new an({checks:[],typeName:F.ZodNumber,coerce:e?.coerce||!1,...D(e)});var on=class e extends O{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==_.bigint)return this._getInvalidInput(e);let t,n=new S;for(let r of this._def.checks)r.kind===`min`?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),x(t,{code:y.too_small,type:`bigint`,minimum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind===`max`?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),x(t,{code:y.too_big,type:`bigint`,maximum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind===`multipleOf`?e.data%r.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),x(t,{code:y.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):g.assertNever(r);return{status:n.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return x(t,{code:y.invalid_type,expected:_.bigint,received:t.parsedType}),C}gte(e,t){return this.setLimit(`min`,e,!0,T.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,T.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,T.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,T.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:T.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}positive(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!1,message:T.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!1,message:T.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!0,message:T.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!0,message:T.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:T.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};on.create=e=>new on({checks:[],typeName:F.ZodBigInt,coerce:e?.coerce??!1,...D(e)});var sn=class extends O{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==_.boolean){let t=this._getOrReturnCtx(e);return x(t,{code:y.invalid_type,expected:_.boolean,received:t.parsedType}),C}return w(e.data)}};sn.create=e=>new sn({typeName:F.ZodBoolean,coerce:e?.coerce||!1,...D(e)});var cn=class e extends O{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==_.date){let t=this._getOrReturnCtx(e);return x(t,{code:y.invalid_type,expected:_.date,received:t.parsedType}),C}if(Number.isNaN(e.data.getTime()))return x(this._getOrReturnCtx(e),{code:y.invalid_date}),C;let t=new S,n;for(let r of this._def.checks)r.kind===`min`?e.data.getTime()<r.value&&(n=this._getOrReturnCtx(e,n),x(n,{code:y.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:`date`}),t.dirty()):r.kind===`max`?e.data.getTime()>r.value&&(n=this._getOrReturnCtx(e,n),x(n,{code:y.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:`date`}),t.dirty()):g.assertNever(r);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}min(e,t){return this._addCheck({kind:`min`,value:e.getTime(),message:T.toString(t)})}max(e,t){return this._addCheck({kind:`max`,value:e.getTime(),message:T.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e==null?null:new Date(e)}get maxDate(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e==null?null:new Date(e)}};cn.create=e=>new cn({checks:[],coerce:e?.coerce||!1,typeName:F.ZodDate,...D(e)});var ln=class extends O{_parse(e){if(this._getType(e)!==_.symbol){let t=this._getOrReturnCtx(e);return x(t,{code:y.invalid_type,expected:_.symbol,received:t.parsedType}),C}return w(e.data)}};ln.create=e=>new ln({typeName:F.ZodSymbol,...D(e)});var un=class extends O{_parse(e){if(this._getType(e)!==_.undefined){let t=this._getOrReturnCtx(e);return x(t,{code:y.invalid_type,expected:_.undefined,received:t.parsedType}),C}return w(e.data)}};un.create=e=>new un({typeName:F.ZodUndefined,...D(e)});var dn=class extends O{_parse(e){if(this._getType(e)!==_.null){let t=this._getOrReturnCtx(e);return x(t,{code:y.invalid_type,expected:_.null,received:t.parsedType}),C}return w(e.data)}};dn.create=e=>new dn({typeName:F.ZodNull,...D(e)});var fn=class extends O{constructor(){super(...arguments),this._any=!0}_parse(e){return w(e.data)}};fn.create=e=>new fn({typeName:F.ZodAny,...D(e)});var pn=class extends O{constructor(){super(...arguments),this._unknown=!0}_parse(e){return w(e.data)}};pn.create=e=>new pn({typeName:F.ZodUnknown,...D(e)});var k=class extends O{_parse(e){let t=this._getOrReturnCtx(e);return x(t,{code:y.invalid_type,expected:_.never,received:t.parsedType}),C}};k.create=e=>new k({typeName:F.ZodNever,...D(e)});var mn=class extends O{_parse(e){if(this._getType(e)!==_.undefined){let t=this._getOrReturnCtx(e);return x(t,{code:y.invalid_type,expected:_.void,received:t.parsedType}),C}return w(e.data)}};mn.create=e=>new mn({typeName:F.ZodVoid,...D(e)});var hn=class e extends O{_parse(e){let{ctx:t,status:n}=this._processInputParams(e),r=this._def;if(t.parsedType!==_.array)return x(t,{code:y.invalid_type,expected:_.array,received:t.parsedType}),C;if(r.exactLength!==null){let e=t.data.length>r.exactLength.value,i=t.data.length<r.exactLength.value;(e||i)&&(x(t,{code:e?y.too_big:y.too_small,minimum:i?r.exactLength.value:void 0,maximum:e?r.exactLength.value:void 0,type:`array`,inclusive:!0,exact:!0,message:r.exactLength.message}),n.dirty())}if(r.minLength!==null&&t.data.length<r.minLength.value&&(x(t,{code:y.too_small,minimum:r.minLength.value,type:`array`,inclusive:!0,exact:!1,message:r.minLength.message}),n.dirty()),r.maxLength!==null&&t.data.length>r.maxLength.value&&(x(t,{code:y.too_big,maximum:r.maxLength.value,type:`array`,inclusive:!0,exact:!1,message:r.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((e,n)=>r.type._parseAsync(new E(t,e,t.path,n)))).then(e=>S.mergeArray(n,e));let i=[...t.data].map((e,n)=>r.type._parseSync(new E(t,e,t.path,n)));return S.mergeArray(n,i)}get element(){return this._def.type}min(t,n){return new e({...this._def,minLength:{value:t,message:T.toString(n)}})}max(t,n){return new e({...this._def,maxLength:{value:t,message:T.toString(n)}})}length(t,n){return new e({...this._def,exactLength:{value:t,message:T.toString(n)}})}nonempty(e){return this.min(1,e)}};hn.create=(e,t)=>new hn({type:e,minLength:null,maxLength:null,exactLength:null,typeName:F.ZodArray,...D(t)});function gn(e){if(e instanceof A){let t={};for(let n in e.shape){let r=e.shape[n];t[n]=N.create(gn(r))}return new A({...e._def,shape:()=>t})}else if(e instanceof hn)return new hn({...e._def,type:gn(e.element)});else if(e instanceof N)return N.create(gn(e.unwrap()));else if(e instanceof P)return P.create(gn(e.unwrap()));else if(e instanceof j)return j.create(e.items.map(e=>gn(e)));else return e}var A=class e extends O{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape();return this._cached={shape:e,keys:g.objectKeys(e)},this._cached}_parse(e){if(this._getType(e)!==_.object){let t=this._getOrReturnCtx(e);return x(t,{code:y.invalid_type,expected:_.object,received:t.parsedType}),C}let{status:t,ctx:n}=this._processInputParams(e),{shape:r,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof k&&this._def.unknownKeys===`strip`))for(let e in n.data)i.includes(e)||a.push(e);let o=[];for(let e of i){let t=r[e],i=n.data[e];o.push({key:{status:`valid`,value:e},value:t._parse(new E(n,i,n.path,e)),alwaysSet:e in n.data})}if(this._def.catchall instanceof k){let e=this._def.unknownKeys;if(e===`passthrough`)for(let e of a)o.push({key:{status:`valid`,value:e},value:{status:`valid`,value:n.data[e]}});else if(e===`strict`)a.length>0&&(x(n,{code:y.unrecognized_keys,keys:a}),t.dirty());else if(e!==`strip`)throw Error(`Internal ZodObject error: invalid unknownKeys value.`)}else{let e=this._def.catchall;for(let t of a){let r=n.data[t];o.push({key:{status:`valid`,value:t},value:e._parse(new E(n,r,n.path,t)),alwaysSet:t in n.data})}}return n.common.async?Promise.resolve().then(async()=>{let e=[];for(let t of o){let n=await t.key,r=await t.value;e.push({key:n,value:r,alwaysSet:t.alwaysSet})}return e}).then(e=>S.mergeObjectSync(t,e)):S.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(t){return T.errToObj,new e({...this._def,unknownKeys:`strict`,...t===void 0?{}:{errorMap:(e,n)=>{let r=this._def.errorMap?.(e,n).message??n.defaultError;return e.code===`unrecognized_keys`?{message:T.errToObj(t).message??r}:{message:r}}}})}strip(){return new e({...this._def,unknownKeys:`strip`})}passthrough(){return new e({...this._def,unknownKeys:`passthrough`})}extend(t){return new e({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new e({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:F.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(t){return new e({...this._def,catchall:t})}pick(t){let n={};for(let e of g.objectKeys(t))t[e]&&this.shape[e]&&(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}omit(t){let n={};for(let e of g.objectKeys(this.shape))t[e]||(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}deepPartial(){return gn(this)}partial(t){let n={};for(let e of g.objectKeys(this.shape)){let r=this.shape[e];t&&!t[e]?n[e]=r:n[e]=r.optional()}return new e({...this._def,shape:()=>n})}required(t){let n={};for(let e of g.objectKeys(this.shape))if(t&&!t[e])n[e]=this.shape[e];else{let t=this.shape[e];for(;t instanceof N;)t=t._def.innerType;n[e]=t}return new e({...this._def,shape:()=>n})}keyof(){return On(g.objectKeys(this.shape))}};A.create=(e,t)=>new A({shape:()=>e,unknownKeys:`strip`,catchall:k.create(),typeName:F.ZodObject,...D(t)}),A.strictCreate=(e,t)=>new A({shape:()=>e,unknownKeys:`strict`,catchall:k.create(),typeName:F.ZodObject,...D(t)}),A.lazycreate=(e,t)=>new A({shape:e,unknownKeys:`strip`,catchall:k.create(),typeName:F.ZodObject,...D(t)});var _n=class extends O{_parse(e){let{ctx:t}=this._processInputParams(e),n=this._def.options;function r(e){for(let t of e)if(t.result.status===`valid`)return t.result;for(let n of e)if(n.result.status===`dirty`)return t.common.issues.push(...n.ctx.common.issues),n.result;let n=e.map(e=>new b(e.ctx.common.issues));return x(t,{code:y.invalid_union,unionErrors:n}),C}if(t.common.async)return Promise.all(n.map(async e=>{let n={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:n}),ctx:n}})).then(r);{let e,r=[];for(let i of n){let n={...t,common:{...t.common,issues:[]},parent:null},a=i._parseSync({data:t.data,path:t.path,parent:n});if(a.status===`valid`)return a;a.status===`dirty`&&!e&&(e={result:a,ctx:n}),n.common.issues.length&&r.push(n.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;let i=r.map(e=>new b(e));return x(t,{code:y.invalid_union,unionErrors:i}),C}}get options(){return this._def.options}};_n.create=(e,t)=>new _n({options:e,typeName:F.ZodUnion,...D(t)});var vn=e=>e instanceof En?vn(e.schema):e instanceof M?vn(e.innerType()):e instanceof Dn?[e.value]:e instanceof kn?e.options:e instanceof An?g.objectValues(e.enum):e instanceof Mn?vn(e._def.innerType):e instanceof un?[void 0]:e instanceof dn?[null]:e instanceof N?[void 0,...vn(e.unwrap())]:e instanceof P?[null,...vn(e.unwrap())]:e instanceof In||e instanceof Rn?vn(e.unwrap()):e instanceof Nn?vn(e._def.innerType):[],yn=class e extends O{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==_.object)return x(t,{code:y.invalid_type,expected:_.object,received:t.parsedType}),C;let n=this.discriminator,r=t.data[n],i=this.optionsMap.get(r);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):(x(t,{code:y.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),C)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,r){let i=new Map;for(let e of n){let n=vn(e.shape[t]);if(!n.length)throw Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let r of n){if(i.has(r))throw Error(`Discriminator property ${String(t)} has duplicate value ${String(r)}`);i.set(r,e)}}return new e({typeName:F.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,...D(r)})}};function bn(e,t){let n=v(e),r=v(t);if(e===t)return{valid:!0,data:e};if(n===_.object&&r===_.object){let n=g.objectKeys(t),r=g.objectKeys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=bn(e[n],t[n]);if(!r.valid)return{valid:!1};i[n]=r.data}return{valid:!0,data:i}}else if(n===_.array&&r===_.array){if(e.length!==t.length)return{valid:!1};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=bn(i,a);if(!o.valid)return{valid:!1};n.push(o.data)}return{valid:!0,data:n}}else if(n===_.date&&r===_.date&&+e==+t)return{valid:!0,data:e};else return{valid:!1}}var xn=class extends O{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=(e,r)=>{if(Dt(e)||Dt(r))return C;let i=bn(e.value,r.value);return i.valid?((Ot(e)||Ot(r))&&t.dirty(),{status:t.value,value:i.data}):(x(n,{code:y.invalid_intersection_types}),C)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([e,t])=>r(e,t)):r(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};xn.create=(e,t,n)=>new xn({left:e,right:t,typeName:F.ZodIntersection,...D(n)});var j=class e extends O{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==_.array)return x(n,{code:y.invalid_type,expected:_.array,received:n.parsedType}),C;if(n.data.length<this._def.items.length)return x(n,{code:y.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),C;!this._def.rest&&n.data.length>this._def.items.length&&(x(n,{code:y.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),t.dirty());let r=[...n.data].map((e,t)=>{let r=this._def.items[t]||this._def.rest;return r?r._parse(new E(n,e,n.path,t)):null}).filter(e=>!!e);return n.common.async?Promise.all(r).then(e=>S.mergeArray(t,e)):S.mergeArray(t,r)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};j.create=(e,t)=>{if(!Array.isArray(e))throw Error(`You must pass an array of schemas to z.tuple([ ... ])`);return new j({items:e,typeName:F.ZodTuple,rest:null,...D(t)})};var Sn=class e extends O{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==_.object)return x(n,{code:y.invalid_type,expected:_.object,received:n.parsedType}),C;let r=[],i=this._def.keyType,a=this._def.valueType;for(let e in n.data)r.push({key:i._parse(new E(n,e,n.path,e)),value:a._parse(new E(n,n.data[e],n.path,e)),alwaysSet:e in n.data});return n.common.async?S.mergeObjectAsync(t,r):S.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof O?new e({keyType:t,valueType:n,typeName:F.ZodRecord,...D(r)}):new e({keyType:nn.create(),valueType:t,typeName:F.ZodRecord,...D(n)})}},Cn=class extends O{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==_.map)return x(n,{code:y.invalid_type,expected:_.map,received:n.parsedType}),C;let r=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([e,t],a)=>({key:r._parse(new E(n,e,n.path,[a,`key`])),value:i._parse(new E(n,t,n.path,[a,`value`]))}));if(n.common.async){let e=new Map;return Promise.resolve().then(async()=>{for(let n of a){let r=await n.key,i=await n.value;if(r.status===`aborted`||i.status===`aborted`)return C;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}})}else{let e=new Map;for(let n of a){let r=n.key,i=n.value;if(r.status===`aborted`||i.status===`aborted`)return C;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}}}};Cn.create=(e,t,n)=>new Cn({valueType:t,keyType:e,typeName:F.ZodMap,...D(n)});var wn=class e extends O{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==_.set)return x(n,{code:y.invalid_type,expected:_.set,received:n.parsedType}),C;let r=this._def;r.minSize!==null&&n.data.size<r.minSize.value&&(x(n,{code:y.too_small,minimum:r.minSize.value,type:`set`,inclusive:!0,exact:!1,message:r.minSize.message}),t.dirty()),r.maxSize!==null&&n.data.size>r.maxSize.value&&(x(n,{code:y.too_big,maximum:r.maxSize.value,type:`set`,inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());let i=this._def.valueType;function a(e){let n=new Set;for(let r of e){if(r.status===`aborted`)return C;r.status===`dirty`&&t.dirty(),n.add(r.value)}return{status:t.value,value:n}}let o=[...n.data.values()].map((e,t)=>i._parse(new E(n,e,n.path,t)));return n.common.async?Promise.all(o).then(e=>a(e)):a(o)}min(t,n){return new e({...this._def,minSize:{value:t,message:T.toString(n)}})}max(t,n){return new e({...this._def,maxSize:{value:t,message:T.toString(n)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};wn.create=(e,t)=>new wn({valueType:e,minSize:null,maxSize:null,typeName:F.ZodSet,...D(t)});var Tn=class e extends O{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==_.function)return x(t,{code:y.invalid_type,expected:_.function,received:t.parsedType}),C;function n(e,n){return wt({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Ct(),bt].filter(e=>!!e),issueData:{code:y.invalid_arguments,argumentsError:n}})}function r(e,n){return wt({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Ct(),bt].filter(e=>!!e),issueData:{code:y.invalid_return_type,returnTypeError:n}})}let i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof jn){let e=this;return w(async function(...t){let o=new b([]),s=await e._def.args.parseAsync(t,i).catch(e=>{throw o.addIssue(n(t,e)),o}),c=await Reflect.apply(a,this,s);return await e._def.returns._def.type.parseAsync(c,i).catch(e=>{throw o.addIssue(r(c,e)),o})})}else{let e=this;return w(function(...t){let o=e._def.args.safeParse(t,i);if(!o.success)throw new b([n(t,o.error)]);let s=Reflect.apply(a,this,o.data),c=e._def.returns.safeParse(s,i);if(!c.success)throw new b([r(s,c.error)]);return c.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:j.create(t).rest(pn.create())})}returns(t){return new e({...this._def,returns:t})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(t,n,r){return new e({args:t||j.create([]).rest(pn.create()),returns:n||pn.create(),typeName:F.ZodFunction,...D(r)})}},En=class extends O{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};En.create=(e,t)=>new En({getter:e,typeName:F.ZodLazy,...D(t)});var Dn=class extends O{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return x(t,{received:t.data,code:y.invalid_literal,expected:this._def.value}),C}return{status:`valid`,value:e.data}}get value(){return this._def.value}};Dn.create=(e,t)=>new Dn({value:e,typeName:F.ZodLiteral,...D(t)});function On(e,t){return new kn({values:e,typeName:F.ZodEnum,...D(t)})}var kn=class e extends O{_parse(e){if(typeof e.data!=`string`){let t=this._getOrReturnCtx(e),n=this._def.values;return x(t,{expected:g.joinValues(n),received:t.parsedType,code:y.invalid_type}),C}if(this._cache||=new Set(this._def.values),!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),n=this._def.values;return x(t,{received:t.data,code:y.invalid_enum_value,options:n}),C}return w(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(t,n=this._def){return e.create(t,{...this._def,...n})}exclude(t,n=this._def){return e.create(this.options.filter(e=>!t.includes(e)),{...this._def,...n})}};kn.create=On;var An=class extends O{_parse(e){let t=g.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==_.string&&n.parsedType!==_.number){let e=g.objectValues(t);return x(n,{expected:g.joinValues(e),received:n.parsedType,code:y.invalid_type}),C}if(this._cache||=new Set(g.getValidEnumValues(this._def.values)),!this._cache.has(e.data)){let e=g.objectValues(t);return x(n,{received:n.data,code:y.invalid_enum_value,options:e}),C}return w(e.data)}get enum(){return this._def.values}};An.create=(e,t)=>new An({values:e,typeName:F.ZodNativeEnum,...D(t)});var jn=class extends O{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);return t.parsedType!==_.promise&&t.common.async===!1?(x(t,{code:y.invalid_type,expected:_.promise,received:t.parsedType}),C):w((t.parsedType===_.promise?t.data:Promise.resolve(t.data)).then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}};jn.create=(e,t)=>new jn({type:e,typeName:F.ZodPromise,...D(t)});var M=class extends O{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===F.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=this._def.effect||null,i={addIssue:e=>{x(n,e),e.fatal?t.abort():t.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),r.type===`preprocess`){let e=r.transform(n.data,i);if(n.common.async)return Promise.resolve(e).then(async e=>{if(t.value===`aborted`)return C;let r=await this._def.schema._parseAsync({data:e,path:n.path,parent:n});return r.status===`aborted`?C:r.status===`dirty`||t.value===`dirty`?Et(r.value):r});{if(t.value===`aborted`)return C;let r=this._def.schema._parseSync({data:e,path:n.path,parent:n});return r.status===`aborted`?C:r.status===`dirty`||t.value===`dirty`?Et(r.value):r}}if(r.type===`refinement`){let e=e=>{let t=r.refinement(e,i);if(n.common.async)return Promise.resolve(t);if(t instanceof Promise)throw Error(`Async refinement encountered during synchronous parse operation. Use .parseAsync instead.`);return e};if(n.common.async===!1){let r=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return r.status===`aborted`?C:(r.status===`dirty`&&t.dirty(),e(r.value),{status:t.value,value:r.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(n=>n.status===`aborted`?C:(n.status===`dirty`&&t.dirty(),e(n.value).then(()=>({status:t.value,value:n.value}))))}if(r.type===`transform`)if(n.common.async===!1){let e=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!kt(e))return C;let a=r.transform(e.value,i);if(a instanceof Promise)throw Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);return{status:t.value,value:a}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(e=>kt(e)?Promise.resolve(r.transform(e.value,i)).then(e=>({status:t.value,value:e})):C);g.assertNever(r)}};M.create=(e,t,n)=>new M({schema:e,typeName:F.ZodEffects,effect:t,...D(n)}),M.createWithPreprocess=(e,t,n)=>new M({schema:t,effect:{type:`preprocess`,transform:e},typeName:F.ZodEffects,...D(n)});var N=class extends O{_parse(e){return this._getType(e)===_.undefined?w(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};N.create=(e,t)=>new N({innerType:e,typeName:F.ZodOptional,...D(t)});var P=class extends O{_parse(e){return this._getType(e)===_.null?w(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};P.create=(e,t)=>new P({innerType:e,typeName:F.ZodNullable,...D(t)});var Mn=class extends O{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return t.parsedType===_.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};Mn.create=(e,t)=>new Mn({innerType:e,typeName:F.ZodDefault,defaultValue:typeof t.default==`function`?t.default:()=>t.default,...D(t)});var Nn=class extends O{_parse(e){let{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return At(r)?r.then(e=>({status:`valid`,value:e.status===`valid`?e.value:this._def.catchValue({get error(){return new b(n.common.issues)},input:n.data})})):{status:`valid`,value:r.status===`valid`?r.value:this._def.catchValue({get error(){return new b(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};Nn.create=(e,t)=>new Nn({innerType:e,typeName:F.ZodCatch,catchValue:typeof t.catch==`function`?t.catch:()=>t.catch,...D(t)});var Pn=class extends O{_parse(e){if(this._getType(e)!==_.nan){let t=this._getOrReturnCtx(e);return x(t,{code:y.invalid_type,expected:_.nan,received:t.parsedType}),C}return{status:`valid`,value:e.data}}};Pn.create=e=>new Pn({typeName:F.ZodNaN,...D(e)});var Fn=Symbol(`zod_brand`),In=class extends O{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}},Ln=class e extends O{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let e=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?C:e.status===`dirty`?(t.dirty(),Et(e.value)):this._def.out._parseAsync({data:e.value,path:n.path,parent:n})})();{let e=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?C:e.status===`dirty`?(t.dirty(),{status:`dirty`,value:e.value}):this._def.out._parseSync({data:e.value,path:n.path,parent:n})}}static create(t,n){return new e({in:t,out:n,typeName:F.ZodPipeline})}},Rn=class extends O{_parse(e){let t=this._def.innerType._parse(e),n=e=>(kt(e)&&(e.value=Object.freeze(e.value)),e);return At(t)?t.then(e=>n(e)):n(t)}unwrap(){return this._def.innerType}};Rn.create=(e,t)=>new Rn({innerType:e,typeName:F.ZodReadonly,...D(t)});function zn(e,t){let n=typeof e==`function`?e(t):typeof e==`string`?{message:e}:e;return typeof n==`string`?{message:n}:n}function Bn(e,t={},n){return e?fn.create().superRefine((r,i)=>{let a=e(r);if(a instanceof Promise)return a.then(e=>{if(!e){let e=zn(t,r),a=e.fatal??n??!0;i.addIssue({code:`custom`,...e,fatal:a})}});if(!a){let e=zn(t,r),a=e.fatal??n??!0;i.addIssue({code:`custom`,...e,fatal:a})}}):fn.create()}var Vn={object:A.lazycreate},F;(function(e){e.ZodString=`ZodString`,e.ZodNumber=`ZodNumber`,e.ZodNaN=`ZodNaN`,e.ZodBigInt=`ZodBigInt`,e.ZodBoolean=`ZodBoolean`,e.ZodDate=`ZodDate`,e.ZodSymbol=`ZodSymbol`,e.ZodUndefined=`ZodUndefined`,e.ZodNull=`ZodNull`,e.ZodAny=`ZodAny`,e.ZodUnknown=`ZodUnknown`,e.ZodNever=`ZodNever`,e.ZodVoid=`ZodVoid`,e.ZodArray=`ZodArray`,e.ZodObject=`ZodObject`,e.ZodUnion=`ZodUnion`,e.ZodDiscriminatedUnion=`ZodDiscriminatedUnion`,e.ZodIntersection=`ZodIntersection`,e.ZodTuple=`ZodTuple`,e.ZodRecord=`ZodRecord`,e.ZodMap=`ZodMap`,e.ZodSet=`ZodSet`,e.ZodFunction=`ZodFunction`,e.ZodLazy=`ZodLazy`,e.ZodLiteral=`ZodLiteral`,e.ZodEnum=`ZodEnum`,e.ZodEffects=`ZodEffects`,e.ZodNativeEnum=`ZodNativeEnum`,e.ZodOptional=`ZodOptional`,e.ZodNullable=`ZodNullable`,e.ZodDefault=`ZodDefault`,e.ZodCatch=`ZodCatch`,e.ZodPromise=`ZodPromise`,e.ZodBranded=`ZodBranded`,e.ZodPipeline=`ZodPipeline`,e.ZodReadonly=`ZodReadonly`})(F||={});var Hn=(e,t={message:`Input not instance of ${e.name}`})=>Bn(t=>t instanceof e,t),I=nn.create,L=an.create,Un=Pn.create,Wn=on.create,R=sn.create,Gn=cn.create,Kn=ln.create,qn=un.create,Jn=dn.create,Yn=fn.create,z=pn.create,Xn=k.create,Zn=mn.create,B=hn.create,V=A.create,Qn=A.strictCreate,H=_n.create,U=yn.create,$n=xn.create,er=j.create,W=Sn.create,tr=Cn.create,nr=wn.create,rr=Tn.create,ir=En.create,G=Dn.create,K=kn.create,ar=An.create,or=jn.create,sr=M.create,cr=N.create,lr=P.create,ur=M.createWithPreprocess,dr=Ln.create,fr=()=>I().optional(),pr=()=>L().optional(),mr=()=>R().optional(),hr={string:(e=>nn.create({...e,coerce:!0})),number:(e=>an.create({...e,coerce:!0})),boolean:(e=>sn.create({...e,coerce:!0})),bigint:(e=>on.create({...e,coerce:!0})),date:(e=>cn.create({...e,coerce:!0}))},gr=C,_r=t({BRAND:()=>Fn,DIRTY:()=>Et,EMPTY_PATH:()=>Tt,INVALID:()=>C,NEVER:()=>gr,OK:()=>w,ParseStatus:()=>S,Schema:()=>O,ZodAny:()=>fn,ZodArray:()=>hn,ZodBigInt:()=>on,ZodBoolean:()=>sn,ZodBranded:()=>In,ZodCatch:()=>Nn,ZodDate:()=>cn,ZodDefault:()=>Mn,ZodDiscriminatedUnion:()=>yn,ZodEffects:()=>M,ZodEnum:()=>kn,ZodError:()=>b,ZodFirstPartyTypeKind:()=>F,ZodFunction:()=>Tn,ZodIntersection:()=>xn,ZodIssueCode:()=>y,ZodLazy:()=>En,ZodLiteral:()=>Dn,ZodMap:()=>Cn,ZodNaN:()=>Pn,ZodNativeEnum:()=>An,ZodNever:()=>k,ZodNull:()=>dn,ZodNullable:()=>P,ZodNumber:()=>an,ZodObject:()=>A,ZodOptional:()=>N,ZodParsedType:()=>_,ZodPipeline:()=>Ln,ZodPromise:()=>jn,ZodReadonly:()=>Rn,ZodRecord:()=>Sn,ZodSchema:()=>O,ZodSet:()=>wn,ZodString:()=>nn,ZodSymbol:()=>ln,ZodTransformer:()=>M,ZodTuple:()=>j,ZodType:()=>O,ZodUndefined:()=>un,ZodUnion:()=>_n,ZodUnknown:()=>pn,ZodVoid:()=>mn,addIssueToContext:()=>x,any:()=>Yn,array:()=>B,bigint:()=>Wn,boolean:()=>R,coerce:()=>hr,custom:()=>Bn,date:()=>Gn,datetimeRegex:()=>Qt,defaultErrorMap:()=>bt,discriminatedUnion:()=>U,effect:()=>sr,enum:()=>K,function:()=>rr,getErrorMap:()=>Ct,getParsedType:()=>v,instanceof:()=>Hn,intersection:()=>$n,isAborted:()=>Dt,isAsync:()=>At,isDirty:()=>Ot,isValid:()=>kt,late:()=>Vn,lazy:()=>ir,literal:()=>G,makeIssue:()=>wt,map:()=>tr,nan:()=>Un,nativeEnum:()=>ar,never:()=>Xn,null:()=>Jn,nullable:()=>lr,number:()=>L,object:()=>V,objectUtil:()=>vt,oboolean:()=>mr,onumber:()=>pr,optional:()=>cr,ostring:()=>fr,pipeline:()=>dr,preprocess:()=>ur,promise:()=>or,quotelessJson:()=>yt,record:()=>W,set:()=>nr,setErrorMap:()=>St,strictObject:()=>Qn,string:()=>I,symbol:()=>Kn,transformer:()=>sr,tuple:()=>er,undefined:()=>qn,union:()=>H,unknown:()=>z,util:()=>g,void:()=>Zn}),vr=V({username:I().min(1),password:I().min(1)}),yr=V({ok:G(!0),changePassword:R()}),br=V({oldPassword:I().min(1),newPassword:I().min(6)}),xr=V({ok:G(!0)}),Sr=V({authenticated:R(),username:I().optional()});V({password:I().min(1)});var Cr=class extends Error{fix;context;constructor(e,t,n){super(e),this.name=`MiravoError`,this.fix=t,this.context=n}},wr=`0.11.0`,Tr=1883,Er=4840,Dr=1502,Or={mqtt:Tr,opcua:Er,modbus:Dr},kr=65535;function Ar(e){return typeof e==`number`&&Number.isInteger(e)&&e>=1&&e<=65535}var jr=1e4,Mr=1e3,Nr=1e6,Pr=1e5,q=/^[a-zA-Z0-9_-]{1,64}$/,Fr=/^\$param\.(\S+)$/,Ir=L().int().min(1).max(kr),Lr=V({state:K([`healthy`,`busy`,`saturated`]),pendingWorkCount:L().finite().int().nonnegative(),completedLastTick:L().finite().int().nonnegative()}),Rr=V({active:L().finite().int().nonnegative(),subscriptions:L().finite().int().nonnegative().optional(),reads:L().finite().int().nonnegative().optional(),writes:L().finite().int().nonnegative().optional()}),zr=V({connected:R(),messagesPublished:L().finite().int().nonnegative(),messagesAttempted:L().finite().int().nonnegative(),messagesFiltered:L().finite().int().nonnegative(),errorsCount:L().finite().int().nonnegative(),rejectedWrites:L().finite().int().nonnegative().optional(),lastPublishMs:L().finite().nonnegative(),health:Lr.optional(),clients:Rr.optional()});V({name:I().min(1),enabled:R().default(!0)}).passthrough();var Br=V({name:I().min(1),enabled:R(),pending:R().optional(),endpoint:I().optional(),boundPort:Ir.optional(),config:W(I(),z())}),J=V({factoryName:I().min(1).optional(),core:V({state:K([`idle`,`running`,`paused`,`stopped`]),tickCount:L().int().nonnegative(),simulationTimeSeconds:L().finite().nonnegative(),pauseAtSimulationSeconds:L().finite().positive().optional(),assetCount:L().int().nonnegative(),memberValueCount:L().int().nonnegative(),quarantinedAssetCount:L().int().nonnegative(),engineErrorsCount:L().int().nonnegative(),lastEngineError:V({context:I(),message:I()}).optional(),tickOverrunsCount:L().int().nonnegative(),circuitBreakerTripsCount:L().int().nonnegative(),uptimeMs:L().finite().nonnegative(),actualTicksPerSecond:L().finite().nonnegative()}),fleet:V({modelBreakdown:B(V({model:I().min(1),count:L().int().nonnegative()})),lifecycleBreakdown:W(I(),L().int().nonnegative()),activeFaultCount:L().int().nonnegative(),faultBreakdown:B(V({fault:I().min(1),count:L().int().nonnegative()}))}),adapters:B(V({name:I().min(1),metrics:zr}))}),Vr=V({lines:B(V({line:I(),stations:B(V({id:I(),state:I(),good:L().int().nonnegative(),scrap:L().int().nonnegative()})),buffers:B(V({after:I(),level:L().int().nonnegative(),capacity:L().int().positive()}))})).optional(),factoryName:I().min(1).optional(),models:B(V({name:I().min(1),memberCount:L().int().nonnegative(),faultCount:L().int().nonnegative(),faultNames:B(I().min(1)),hasLifecycle:R()})),assets:B(V({id:I().min(1),model:I().min(1),browsePath:B(I().min(1)),lifecycleStage:I().min(1),operatingHours:L().finite().nonnegative(),activeFaults:B(I().min(1)),isQuarantined:R(),production:W(I(),H([L(),I(),R()])).optional()})),config:V({seed:L().int().nonnegative(),tickIntervalMs:L().int().positive(),timeMultiplier:L().finite().positive(),adapters:B(I().min(1)),template:V({name:I().min(1),path:I().min(1)}).optional()}),availableAdapters:B(Br).optional()}),Hr=V({templateId:I().min(1),templateName:I().min(1),templatePath:I().min(1),entryHash:I().min(1).optional(),assetIds:B(I().min(1)),models:B(I().min(1)),areas:B(V({name:I().min(1),lines:B(I().min(1))}))}),Ur=V({name:I().min(1),value:H([L().finite(),I(),R()]),quality:K([`good`,`bad`,`uncertain`]),unit:I().nullable(),kind:I().min(1),dataType:I().min(1)}),Wr=V({id:I().min(1),name:I().min(1),members:B(Ur),inputs:B(V({port:I().min(1),asset:I().min(1),member:I().min(1)}))}),Gr=V({state:Vr,metrics:J,templates:B(Hr),assetDetails:B(Wr),revision:L().int().nonnegative()}),Kr=U(`authenticated`,[V({authenticated:G(!1)}),V({authenticated:G(!0),username:I().min(1),runtime:Gr,viewToken:I().min(1).optional()})]),qr=V({assetId:I().min(1),memberName:I().min(1),value:H([L().finite(),I(),R()]),quality:K([`good`,`bad`,`uncertain`]),timestamp:L().finite().optional()}),Jr=U(`kind`,[V({kind:G(`fault:triggered`),assetId:I().min(1),fault:I().min(1),effects:W(I(),z())}),V({kind:G(`fault:cleared`),assetId:I().min(1),fault:I().min(1)}),V({kind:G(`lifecycle:changed`),assetId:I().min(1),from:I().min(1),to:I().min(1),operatingHours:L().finite().nonnegative()}),V({kind:G(`asset:maintenance`),assetId:I().min(1),from:I().min(1),to:I().min(1),operatingHours:L().finite().nonnegative(),reason:K([`manual`,`scheduled`])}),V({kind:G(`asset:created`),id:I().min(1),assetType:I().min(1),browsePath:B(I().min(1))}),V({kind:G(`asset:removed`),id:I().min(1)}),V({kind:K([`template:loaded`,`template:unloaded`]),templateId:I().min(1),assetCount:L().int().nonnegative()}),V({kind:G(`engine:state`),from:J.shape.core.shape.state,to:J.shape.core.shape.state}),V({kind:G(`engine:error`),context:I(),message:I(),fix:I().optional()}),V({kind:G(`adapter:enabled`),name:I().min(1),endpoint:I().min(1)}),V({kind:G(`adapter:disabled`),name:I().min(1)})]),Yr=V({core:V({memberValueCount:J.shape.core.shape.memberValueCount,quarantinedAssetCount:J.shape.core.shape.quarantinedAssetCount,engineErrorsCount:J.shape.core.shape.engineErrorsCount,tickOverrunsCount:J.shape.core.shape.tickOverrunsCount,circuitBreakerTripsCount:J.shape.core.shape.circuitBreakerTripsCount,uptimeMs:J.shape.core.shape.uptimeMs,actualTicksPerSecond:J.shape.core.shape.actualTicksPerSecond}),adapters:J.shape.adapters}),Xr=U(`type`,[V({type:G(`runtime:snapshot`),snapshot:Gr}),V({type:G(`runtime:tick`),revision:L().int().nonnegative(),tick:L().int().nonnegative(),simulationTime:L().finite().nonnegative(),delta:B(qr),assetCount:L().int().nonnegative(),lines:Vr.shape.lines.unwrap(),timeMultiplier:L().finite().positive(),metrics:Yr}),V({type:G(`runtime:event`),revision:L().int().nonnegative(),event:Jr}),V({type:G(`runtime:resync-required`),revision:L().int().nonnegative(),reason:I().min(1)})]),Zr=/^[A-Za-z0-9_-]+$/;function Qr(e){let t=/^(.+)-(\d+)$/.exec(e);if(!t)return null;let n=t[1],r=t[2];if(!n||!r)return null;let i=Number(r);return!Number.isSafeInteger(i)||i<1?null:{prefix:n,counter:i}}function $r(e){let t=e.trim();if(t.length===0)return`Name is required.`;let n=t.split(`-`);if(n.some(e=>e.length===0))return`Use hyphen-delimited segments without empty parts.`;for(let e of n)if(!Zr.test(e))return`Use only letters, numbers, underscores, and hyphens.`;return null}function ei(e){let t=e.trim();return t.length===0?null:t.length>120?`Use at most 120 characters.`:$r(e)}var Y=`Must be 1-64 chars and contain only letters, numbers, underscores, or hyphens.`,X=K([`mqtt`,`opcua`,`modbus`]),ti=B(X).min(1),ni=V({asset:I().regex(q,Y),member:I().regex(q,Y)}).strict(),ri=V({model:I().min(1),id:I().regex(q,Y).optional(),count:L().int().positive().default(1),variation:L().min(0).max(1).default(0),parameters:W(I(),L().finite()).optional(),inputs:W(I().regex(q,Y),ni).optional(),starting_hours:L().finite().nonnegative().optional(),protocol_scope:ti.optional()}).strict(),ii=V({asset:I().min(1),ideal_cycle_s:L().finite().positive(),scrap_rate:L().finite().min(0).max(1).default(0),cycle_cv:L().finite().min(0).max(.5).default(.02),buffer_after:V({capacity:L().int().positive(),initial:L().int().nonnegative().default(0)}).strict().refine(e=>e.initial<=e.capacity,`Reduce initial to buffer capacity.`).optional()}).strict(),ai=V({source:G(`unlimited`),stations:B(ii).min(1)}).strict(),oi=K([`mon`,`tue`,`wed`,`thu`,`fri`,`sat`,`sun`]),si=I().regex(/^([01]\d|2[0-3]):[0-5]\d$/,`Use HH:MM (00:00–23:59).`),ci=V({start:I().regex(/^(mon|tue|wed|thu|fri|sat|sun) ([01]\d|2[0-3]):[0-5]\d$/,`Use <day> HH:MM, e.g. mon 06:00.`).default(`mon 06:00`),timezone_offset_h:L().finite().min(-14).max(14).default(0),pattern:B(V({days:B(oi).min(1),start:si,end:si,breaks:B(V({start:si,minutes:L().finite().positive()}).strict()).default([])}).strict()).min(1),changeovers:B(V({every_parts:L().int().positive(),minutes:L().finite().positive(),station:I().min(1)}).strict()).default([])}).strict(),li=V({name:I().regex(q,Y),assets:B(ri).min(1),flow:ai.optional(),protocol_scope:ti.optional()}).strict(),ui=V({name:I().regex(q,Y),lines:B(li).min(1),protocol_scope:ti.optional()}).strict(),di=H([V({enterprise:I().regex(q,Y),site:I().regex(q,Y)}).strict(),V({prefix:I().regex(q,Y)}).strict()]),fi=V({maxAttempts:L().finite().int().min(0).default(0),initialDelayMs:L().finite().int().positive().default(1e3),maxDelayMs:L().finite().int().positive().default(3e4)}).strict(),pi=V({enabled:R().default(!1),deadband:L().finite().nonnegative().default(0)}).strict(),mi=K([`base`,`full`]),hi=V({embedded:R().default(!0),port:L().int().min(0).max(65535).default(1883),host:I().default(`127.0.0.1`),external:I().optional(),retain:R().default(!0),username:I().optional(),password:I().optional(),reconnect:fi.optional(),rbe:pi.optional(),metadata:mi.default(`base`),drain_budget:L().int().min(512).max(65536).optional(),batch_size:L().int().min(64).max(16384).optional(),broker_concurrency:L().int().min(10).max(5e3).optional()});function gi(e){return e.refine(e=>!(e.embedded&&e.external),{message:`Cannot use both 'embedded: true' and 'external' URL. Set 'embedded: false' when using an external broker.`}).refine(e=>!e.password||e.username,{message:`Cannot set 'password' without 'username'.`})}gi(hi);var _i=V({port:L().int().min(0).max(65535).default(Er),host:I().default(`127.0.0.1`),security:K([`none`]).default(`none`),buildInfo:V({productName:I().default(`Miravo`)}).strict().optional(),write_budget:L().int().min(512).max(65536).optional()}).strict(),vi=V({port:L().int().min(0).max(65535).default(Dr),host:I().default(`127.0.0.1`)}).strict(),yi=V({mqtt:gi(hi.strict()).optional(),opcua:_i.optional(),modbus:vi.optional()}).strict(),bi=V({max_members_per_model:L().int().positive().max(Pr).default(Mr),max_asset_count:L().int().positive().max(Nr).default(jr)}).strict(),xi=V({tick_interval_ms:L().int().min(10).default(1e3),max_step_s:L().finite().positive().default(1),max_substeps:L().int().min(1).default(60),time_multiplier:L().positive().max(1e3).default(1),random_faults:R().default(!0),seed:L().int().optional(),overrun_threshold_multiplier:L().min(1).max(10).optional(),limits:bi.optional()}).strict();V({kind:G(`MiravoTemplate`),version:G(`1`),name:I().min(1),description:I().optional(),namespace:di.optional(),areas:B(ui).min(1),protocols:yi.optional(),shifts:ci.optional(),settings:xi.optional()}).strict().superRefine((e,t)=>{let n=new Set,r=new Set;e.areas.forEach((e,i)=>{e.lines.forEach((e,a)=>{let o=[`areas`,i,`lines`,a];e.assets.forEach((e,r)=>{e.id&&(e.count!==1||n.has(e.id))&&t.addIssue({code:y.custom,path:[...o,`assets`,r],message:`Assignment id '${e.id}' must be unique with count: 1. Fix: use a unique id and count: 1.`}),e.id&&n.add(e.id)});let s=e.flow;(s?.stations??[]).forEach((n,i)=>{let a=[...o,`flow`,`stations`,i],c=e.assets.find(e=>e.id===n.asset);(!c||c.count!==1||r.has(n.asset))&&t.addIssue({code:y.custom,path:[...a,`asset`],message:`Invalid station '${n.asset}'. Fix: reference a unique assignment id with count: 1 in this same line.`}),r.add(n.asset),s&&i<s.stations.length-1&&!n.buffer_after&&t.addIssue({code:y.custom,path:a,message:`Station '${n.asset}' needs buffer_after. Fix: add buffer_after: { capacity: 1 }.`})})})});for(let n of e.shifts?.changeovers??[])r.has(n.station)||t.addIssue({code:y.custom,message:`Unknown changeover station '${n.station}'. Fix: reference a flow station id.`});let i=e.settings?.limits?.max_asset_count??1e4;for(let n=0;n<e.areas.length;n++){let r=e.areas[n];if(r)for(let e=0;e<r.lines.length;e++){let a=r.lines[e];if(a)for(let r=0;r<a.assets.length;r++){let o=a.assets[r];!o||o.count<=i||t.addIssue({code:y.custom,path:[`areas`,n,`lines`,e,`assets`,r,`count`],message:`Asset assignment count must be at most ${i}. Fix: reduce count or set settings.limits.max_asset_count higher.`})}}}});var Si=1e3,Z=V({correlationId:I().optional()}),Ci=I().trim().min(1).superRefine((e,t)=>{let n=ei(e);n&&t.addIssue({code:y.custom,message:n})}),wi=Z.extend({type:G(`spawn`),model:I().min(1),count:L().int().positive().max(jr),assetName:Ci.optional(),assetPrefix:Ci.optional(),protocolScope:ti.optional(),dryRun:R().optional()}),Ti=Z.extend({type:G(`removeAsset`),assetId:I().min(1)}),Ei=Z.extend({type:G(`setParameter`),assetId:I().min(1),parameter:I().min(1),value:L().finite()}),Di=Z.extend({type:G(`triggerFault`),assetId:I().min(1),fault:I().min(1)}),Oi=Z.extend({type:G(`clearFault`),assetId:I().min(1),fault:I().min(1)}),ki=Z.extend({type:G(`pause`)}),Ai=Z.extend({type:G(`resume`)}),ji=Z.extend({type:G(`setSpeed`),multiplier:L().positive().finite().max(Si)}),Mi=Z.extend({type:G(`unquarantine`),assetId:I().min(1)}),Ni=Z.extend({type:G(`invokeMethod`),assetId:I().min(1),method:I().min(1),arguments:W(I().min(1),H([L().finite(),I(),R()])).optional()}),Pi=Z.extend({type:G(`loadTemplate`),templatePath:I().min(1)}),Fi=Z.extend({type:G(`unloadTemplate`),templateId:I().min(1)}),Ii=Z.extend({type:G(`resetFactory`)}),Li=Z.extend({type:G(`enableAdapter`),adapter:I().min(1),config:W(I(),z()).optional()}),Ri=Z.extend({type:G(`disableAdapter`),adapter:I().min(1)}),zi=U(`type`,[wi,Ti,Ei,Di,Oi,ki,Ai,ji,Mi,Ni,Pi,Fi,Ii,Li,Ri]),Bi=V({success:R(),command:I(),correlationId:I().optional(),message:I(),data:z().optional(),error:I().optional()}),Vi=`/api`,Hi=H([L().finite(),I(),R()]),Ui=er([L().finite(),L().finite()]),Wi=V({name:I().min(1),dataType:I().min(1),description:I().nullable()}),Gi=V({description:I().nullable(),inputArguments:B(Wi),outputArguments:B(Wi)}),Ki=V({id:I().min(1),assetType:I().min(1),browsePath:B(I().min(1)),lifecycleStage:I().min(1),operatingHours:L().finite().nonnegative(),activeFaults:B(I().min(1)),isQuarantined:R(),parameters:W(I().min(1),V({value:Hi,type:I().min(1),unit:I().optional()})),inputs:W(I().min(1),V({value:L().finite(),default:L().finite(),unit:I().optional(),binding:V({asset:I().min(1),member:I().min(1)}).nullable()})),members:W(I().min(1),V({value:Hi,quality:K([`good`,`bad`,`uncertain`]),timestamp:L().finite(),meta:V({kind:I().min(1),dataType:I().min(1),access:I().min(1),unit:I().nullable(),euRange:Ui.nullable()})})),methods:W(I().min(1),Gi)}),qi=V({name:I().min(1),description:I().nullable(),memberCount:L().int().nonnegative(),methodCount:L().int().nonnegative(),faultCount:L().int().nonnegative(),hasLifecycle:R(),lifecycleStageCount:L().int().nonnegative(),source:I().min(1)}),Ji=V({model:I().min(1),count:L().int().nonnegative(),variation:L().finite().nonnegative(),parameters:W(I().min(1),L().finite()).optional(),protocol_scope:B(X).optional()}),Yi=V({name:I().min(1),assets:B(Ji),protocol_scope:B(X).optional()}),Xi=V({name:I().min(1),lines:B(Yi),protocol_scope:B(X).optional()}),Zi=V({id:I().min(1),name:I().min(1),description:I().nullable(),category:I().min(1),models:B(I().min(1)),assetCount:L().int().nonnegative(),memberCount:L().int().nonnegative(),source:I().min(1)}),Qi=Zi,$i=Zi.extend({topology:B(Xi),namespace:V({enterprise:I().min(1).optional(),site:I().min(1).optional(),prefix:I().min(1).optional()}).optional(),settings:V({tickIntervalMs:L().int().positive().optional(),timeMultiplier:L().finite().positive().optional(),limits:V({maxMembersPerModel:L().int().positive().optional(),maxAssetCount:L().int().positive().optional()}).optional()}).optional()}),ea=K([`idle`,`running`,`paused`,`stopped`]),ta=V({events:B(U(`type`,[V({id:L().int().nonnegative(),type:G(`fault:triggered`),assetId:I().min(1),fault:I().min(1),effects:W(I(),z()),tick:L().int().nonnegative(),simulationTime:L().finite().nonnegative(),timestamp:L().finite().nonnegative()}),V({id:L().int().nonnegative(),type:G(`fault:cleared`),assetId:I().min(1),fault:I().min(1),tick:L().int().nonnegative(),simulationTime:L().finite().nonnegative(),timestamp:L().finite().nonnegative()}),V({id:L().int().nonnegative(),type:G(`lifecycle:changed`),assetId:I().min(1),from:I().min(1),to:I().min(1),operatingHours:L().finite().nonnegative(),tick:L().int().nonnegative(),simulationTime:L().finite().nonnegative(),timestamp:L().finite().nonnegative()}),V({id:L().int().nonnegative(),type:G(`asset:maintenance`),assetId:I().min(1),from:I().min(1),to:I().min(1),operatingHours:L().finite().nonnegative(),reason:K([`manual`,`scheduled`]),tick:L().int().nonnegative(),simulationTime:L().finite().nonnegative(),timestamp:L().finite().nonnegative()}),V({id:L().int().nonnegative(),type:G(`asset:created`),assetId:I().min(1),assetType:I().min(1),browsePath:B(I().min(1)),tick:L().int().nonnegative(),simulationTime:L().finite().nonnegative(),timestamp:L().finite().nonnegative()}),V({id:L().int().nonnegative(),type:G(`asset:removed`),assetId:I().min(1),tick:L().int().nonnegative(),simulationTime:L().finite().nonnegative(),timestamp:L().finite().nonnegative()}),V({id:L().int().nonnegative(),type:K([`template:loaded`,`template:unloaded`]),templateId:I().min(1),assetCount:L().int().nonnegative(),tick:L().int().nonnegative(),simulationTime:L().finite().nonnegative(),timestamp:L().finite().nonnegative()}),V({id:L().int().nonnegative(),type:G(`engine:state-changed`),from:ea,to:ea,tick:L().int().nonnegative(),simulationTime:L().finite().nonnegative(),timestamp:L().finite().nonnegative()}),V({id:L().int().nonnegative(),type:G(`engine:error`),context:I(),message:I(),fix:I().optional(),tick:L().int().nonnegative(),simulationTime:L().finite().nonnegative(),timestamp:L().finite().nonnegative()}),V({id:L().int().nonnegative(),type:G(`integration:resource`),operationId:I().min(1),operationType:K([`apply`,`cleanup`]),templateId:I().min(1),targetLabel:I().min(1),hostname:I().min(1),phase:I().min(1),resourceType:I().min(1),resourceName:I().min(1),action:I().min(1),status:K([`success`,`failed`]),error:I().optional(),tick:L().int().nonnegative(),simulationTime:L().finite().nonnegative(),timestamp:L().finite().nonnegative()}),V({id:L().int().nonnegative(),type:G(`integration:operation`),operationId:I().min(1),operationType:K([`apply`,`cleanup`]),templateId:I().min(1),targetLabel:I().min(1),hostname:I().min(1),applied:L().int().nonnegative(),failed:L().int().nonnegative(),duration:L().int().nonnegative(),tick:L().int().nonnegative(),simulationTime:L().finite().nonnegative(),timestamp:L().finite().nonnegative()})])),nextCursor:L().int().nonnegative().nullable(),hasMore:R()}),na=`litmus-edge`,ra=W(X,Ir),ia=V({id:I().min(1),integrationId:I().min(1),label:I().min(1),hostname:I().min(1),apiTokenSet:R(),sourceHostname:I().min(1),exposedPorts:ra.optional(),lastUsedAt:L().int().nonnegative().optional()}).strict(),aa=V({targets:B(ia)}).strict(),oa=V({integrationId:I().min(1).default(na),label:I().min(1),hostname:I().min(1),apiToken:I().min(1),sourceHostname:I().min(1)}),sa=V({integrationId:I().min(1).optional(),label:I().min(1).optional(),hostname:I().min(1).optional(),apiToken:I().min(1).optional(),sourceHostname:I().min(1).optional()}),ca=V({targetId:I().min(1).optional(),hostname:I().min(1),apiToken:I().min(1).optional(),sourceHostname:I().min(1)}).superRefine((e,t)=>{!e.targetId&&!e.apiToken&&t.addIssue({code:y.custom,message:`apiToken is required when targetId is omitted.`,path:[`apiToken`]})}),la=U(`connected`,[V({connected:G(!0),hostname:I().min(1),sourceHostname:I().min(1),litmusEdgeVersion:I().min(1).optional(),warning:I().min(1).optional()}),V({connected:G(!1),error:I().min(1)})]),ua=K([`devices`,`models`,`assets`]),da=K([`create`,`update`,`replace`,`delete`,`noop`,`blocked`]),fa=K([`device`,`model`,`asset`,`param-sync`]),pa=K([`apply`,`cleanup`]),ma=K([`success`,`partial`,`blocked`,`noop`,`failed`]);K([`device`,`model`,`asset`,`param-sync`]),K([`create`,`update`,`replace`,`delete`]);var ha=V({area:I().min(1).optional(),line:I().min(1).optional(),asset:I().min(1).optional()}),ga=V({action:da,resourceType:fa,name:I().min(1),resourceId:I().min(1).optional(),protocol:X.optional(),endpoint:I().min(1).optional(),detail:I().min(1).optional(),blockReason:I().min(1).optional()}),_a=V({sourceMode:K([`static`,`managed`]),targetHost:I().min(1),sourceHostname:I().min(1).optional(),scope:B(ua),filters:ha,entries:B(ga)}),va=V({plan:_a}),ya=`Provide exactly one of 'templateId' (a running template) or 'assetId' (a running standalone asset).`;function ba(e,t){let n=(e,n)=>{if(e.code===`unrecognized_keys`&&e.keys.some(e=>e===`templateId`||e===`assetId`))return{message:t};if(e.code!==`invalid_union`)return{message:n.defaultError};let r=n.data,i=typeof r==`object`&&r?r:{},a=`templateId`in i;return a===`assetId`in i?{message:t}:{message:e.unionErrors[+!a]?.issues.map(e=>e.message).join(`; `)??t}};return H([V({...e,templateId:I().min(1)},{errorMap:n}).strict(),V({...e,assetId:I().min(1)},{errorMap:n}).strict()],{errorMap:n})}var xa=ba({targetId:I().min(1),protocol:X.optional(),scope:B(ua).optional(),ifUnmanaged:K([`fail`,`skip`]).optional(),exposedPorts:ra.optional()},ya),Sa=V({plan:_a,applied:L().int().nonnegative(),failed:L().int().nonnegative(),error:I().min(1).optional()}),Ca=ba({targetId:I().min(1),scope:B(ua).optional()},`Provide exactly one of 'templateId' or 'assetId'.`),wa=V({plan:_a,deleted:L().int().nonnegative(),failed:L().int().nonnegative(),error:I().min(1).optional()}),Ta=V({create:L().int().nonnegative(),update:L().int().nonnegative(),replace:L().int().nonnegative(),delete:L().int().nonnegative(),noop:L().int().nonnegative(),failed:L().int().nonnegative(),total:L().int().nonnegative()}),Ea=V({device:Ta,model:Ta,asset:Ta,"param-sync":Ta}),Da=V({operations:B(V({schemaVersion:G(1),operationId:I().min(1),operationType:pa,status:ma,factoryName:I().min(1),templateId:I().min(1).optional(),assetId:I().min(1).optional(),targetId:I().min(1),targetLabel:I().min(1),hostname:I().min(1),scope:B(I().min(1)),successCount:L().int().nonnegative(),failedCount:L().int().nonnegative(),blockedCount:L().int().nonnegative(),startedAt:L().int().nonnegative(),completedAt:L().int().nonnegative(),durationMs:L().int().nonnegative(),resourceCounts:Ea,error:I().min(1).optional()}).refine(e=>e.templateId===void 0!=(e.assetId===void 0),{message:`An operation record names exactly one of 'templateId' or 'assetId'.`})),total:L().int().nonnegative(),hasMore:R()}),Oa=V({type:pa.optional(),targetId:I().min(1).optional(),templateId:I().min(1).optional(),assetId:I().min(1).optional(),limit:hr.number().int().positive().max(500).optional(),offset:hr.number().int().nonnegative().optional()}),ka=V({cancelled:G(!0)}),Aa=V({operationId:I().min(1),type:pa,templateId:I().min(1).optional(),assetId:I().min(1).optional(),targetLabel:I().min(1),totalPlanned:L().int().nonnegative(),attempt:L().int().positive().optional(),maxAttempts:L().int().positive().optional()}),ja=V({operationId:I().min(1),type:pa,targetId:I().min(1).optional(),templateId:I().min(1).optional(),assetId:I().min(1).optional()}),Ma=V({operationId:I().min(1),phase:fa,total:L().int().nonnegative()}),Na=V({operationId:I().min(1),phase:fa,name:I().min(1),action:da,status:K([`success`,`failed`]),error:I().min(1).optional(),index:L().int().positive(),of:L().int().positive()}),Pa=V({operationId:I().min(1),applied:L().int().nonnegative().optional(),deleted:L().int().nonnegative().optional(),failed:L().int().nonnegative(),duration:L().int().nonnegative(),plan:_a}),Fa=Pa,Ia=Pa,La=V({operationId:I().min(1),attempt:L().int().positive(),maxAttempts:L().int().positive(),delayMs:L().int().nonnegative(),error:I().min(1)}),Ra=V({message:I().min(1)}),za=V({level:K([`info`,`warn`,`error`]),message:I().min(1),protocol:X.optional(),port:Ir.optional(),templatePort:Ir.optional()}),Ba=U(`event`,[V({event:G(`log`),data:za}),V({event:G(`started`),data:Aa}),V({event:G(`accepted`),data:ja}),V({event:G(`phase`),data:Ma}),V({event:G(`resource`),data:Na}),V({event:G(`complete`),data:Fa}),V({event:G(`cancelled`),data:Ia}),V({event:G(`retrying`),data:La}),V({event:G(`error`),data:Ra})]),Va=V({enabled:R(),port:L().int().positive().optional()}),Ha=V({asset:I().min(1),browsePath:I(),member:I().min(1),model:I().min(1),dataType:I().min(1),unit:I().optional(),euRange:er([L().finite(),L().finite()]).optional(),access:I().min(1),kind:K([`variable`,`property`]),protocols:W(I(),W(I(),z()))}),Ua=V({template:I().min(1).optional(),generatedAt:I().datetime(),protocols:W(I(),Va),tags:B(Ha),summary:V({totalTags:L().int().nonnegative(),totalAssets:L().int().nonnegative(),enabledProtocols:B(I().min(1))})}),Wa=V({name:I().min(1),description:I().nullable(),parameters:W(I().min(1),V({type:I().min(1),default:Hi,unit:I().optional()})),inputs:W(I().min(1),V({default:L().finite(),unit:I().optional(),description:I().optional()})).optional(),members:W(I().min(1),V({kind:I().min(1),dataType:I().min(1),access:I().min(1),unit:I().nullable(),euRange:Ui.nullable(),default:Hi.nullable()})),methods:W(I().min(1),Gi),faults:B(I().min(1)),lifecycle:V({stages:B(I().min(1)),totalHours:L().finite().nonnegative()}).nullable()}),Ga=V({status:K([`ok`,`fail`]),factoryState:J.shape.core.shape.state,tickCount:L().int().nonnegative(),mqttEnabled:R(),mqttConnected:R().nullable(),opcuaEnabled:R(),opcuaConnected:R().nullable(),modbusEnabled:R(),modbusConnected:R().nullable(),stalled:R(),reason:I().optional(),factoryName:I().min(1).optional(),processId:I().min(1).optional()}),Ka=V({reason:I().min(1).optional()}),qa=V({status:G(`shutting_down`)}),Ja=V({id:I().min(1)}),Ya=V({name:I().min(1)}),Xa=V({id:I().min(1)}),Za=V({operationId:I().min(1)}),Qa=V({id:I().min(1)}),$a=V({type:K([`fault:triggered`,`fault:cleared`,`lifecycle:changed`,`asset:maintenance`,`asset:created`,`asset:removed`,`template:loaded`,`template:unloaded`,`engine:state-changed`,`engine:error`,`integration:resource`,`integration:operation`]).optional(),assetId:I().min(1).optional(),limit:hr.number().int().positive().max(1e3).optional(),cursor:hr.number().int().nonnegative().optional()}),eo=hr.number().int().min(1).max(kr).optional(),to=V({host:I().min(1),protocol:X.optional(),modbusPort:eo,opcuaPort:eo,mqttPort:eo}),no=W(I(),z()),ro=W(I(),z());function Q(e){return`${Vi}${e}`}var io=[{method:`GET`,path:Q(`/openapi.json`),operationId:`openApiDocument`,auth:`none`,response:{kind:`json`,schema:ro},description:`Generated OpenAPI document for the Miravo admin API.`},{method:`GET`,path:Q(`/healthz`),operationId:`health`,auth:`none`,response:{kind:`json`,schema:Ga},description:`Liveness probe for the Miravo admin server.`},{method:`GET`,path:Q(`/readyz`),operationId:`readiness`,auth:`none`,response:{kind:`json`,schema:Ga},description:`Readiness probe for the Miravo admin server.`},{method:`GET`,path:Q(`/metrics`),operationId:`metrics`,auth:`required`,response:{kind:`json`,schema:J},description:`Engine metrics snapshot.`},{method:`GET`,path:Q(`/state`),operationId:`state`,auth:`required`,response:{kind:`json`,schema:Vr},description:`Engine state snapshot.`},{method:`GET`,path:Q(`/bootstrap`),operationId:`bootstrap`,auth:`none`,response:{kind:`json`,schema:Kr},description:`Console bootstrap payload.`},{method:`POST`,path:Q(`/commands`),operationId:`commands`,auth:`required`,body:zi,response:{kind:`json`,schema:Bi},description:`Execute an engine command.`},{method:`POST`,path:Q(`/shutdown`),operationId:`shutdown`,auth:`required`,body:Ka,response:{kind:`json`,schema:qa},description:`Request graceful shutdown.`},{method:`GET`,path:Q(`/assets/:id`),operationId:`assetDetail`,auth:`required`,params:Ja,response:{kind:`json`,schema:Ki},description:`Inspect a running asset.`},{method:`GET`,path:Q(`/models/:name`),operationId:`modelDetail`,auth:`required`,params:Ya,response:{kind:`json`,schema:Wa},description:`Inspect a registered model schema.`},{method:`GET`,path:Q(`/events`),operationId:`events`,auth:`required`,query:$a,response:{kind:`json`,schema:ta},description:`Read paginated event log entries.`},{method:`GET`,path:Q(`/catalog/models`),operationId:`catalogModels`,auth:`required`,response:{kind:`json`,schema:B(qi)},description:`List catalog models.`},{method:`GET`,path:Q(`/catalog/models/:name/le-dt.json`),operationId:`catalogModelLeDt`,auth:`required`,params:Ya,response:{kind:`json`,schema:no},description:`Download LE Digital Twin JSON for a catalog model.`},{method:`GET`,path:Q(`/catalog/models/:name/yaml`),operationId:`catalogModelYaml`,auth:`required`,params:Ya,response:{kind:`yaml`},description:`Read raw YAML for a catalog model.`},{method:`GET`,path:Q(`/catalog/models/:name`),operationId:`catalogModelDetail`,auth:`required`,params:Ya,response:{kind:`json`,schema:Wa},description:`Read catalog model schema.`},{method:`GET`,path:Q(`/catalog/templates/:id/le-template.json`),operationId:`catalogTemplateLeTemplateJson`,auth:`required`,params:Xa,query:to,response:{kind:`passthrough`},description:`Download LE template JSON export.`},{method:`GET`,path:Q(`/catalog/templates/:id/le-tags.csv`),operationId:`catalogTemplateLeTagsCsv`,auth:`required`,params:Xa,query:to,response:{kind:`passthrough`},description:`Download LE tags CSV export.`},{method:`GET`,path:Q(`/catalog/templates/:id/yaml`),operationId:`catalogTemplateYaml`,auth:`required`,params:Xa,response:{kind:`yaml`},description:`Read raw YAML for a catalog template.`},{method:`GET`,path:Q(`/catalog/templates/:id`),operationId:`catalogTemplateDetail`,auth:`required`,params:Xa,response:{kind:`json`,schema:$i},description:`Read catalog template detail.`},{method:`GET`,path:Q(`/catalog/templates`),operationId:`catalogTemplates`,auth:`required`,response:{kind:`json`,schema:B(Qi)},description:`List catalog templates.`},{method:`GET`,path:Q(`/templates`),operationId:`templates`,auth:`required`,response:{kind:`json`,schema:B(Hr)},description:`List templates loaded into the factory.`},{method:`GET`,path:Q(`/manifest`),operationId:`manifest`,auth:`required`,response:{kind:`json`,schema:Ua},description:`Read unified protocol manifest.`},{method:`POST`,path:Q(`/auth/login`),operationId:`authLogin`,auth:`none`,body:vr,response:{kind:`json`,schema:yr},description:`Authenticate and create an admin session.`},{method:`POST`,path:Q(`/auth/logout`),operationId:`authLogout`,auth:`none`,response:{kind:`json`,schema:xr},description:`Destroy the current admin session.`},{method:`PUT`,path:Q(`/auth/password`),operationId:`authPassword`,auth:`required`,body:br,response:{kind:`json`,schema:xr},description:`Change the admin password.`},{method:`GET`,path:Q(`/auth/status`),operationId:`authStatus`,auth:`none`,response:{kind:`json`,schema:Sr},description:`Check the current auth status.`},{method:`GET`,path:Q(`/ws`),operationId:`runtimeWebSocket`,auth:`required`,response:{kind:`passthrough`},description:`Upgrade to the runtime WebSocket stream.`},{method:`GET`,path:Q(`/integrations/le/operations`),operationId:`integrationOperations`,auth:`required`,query:Oa,response:{kind:`json`,schema:Da},description:`List persisted integration operation summaries, optionally for one template or asset.`},{method:`GET`,path:Q(`/integrations/le/targets`),operationId:`integrationTargets`,auth:`required`,response:{kind:`json`,schema:aa},description:`List saved LE targets.`},{method:`POST`,path:Q(`/integrations/le/targets`),operationId:`integrationTargetCreate`,auth:`required`,body:oa,response:{kind:`json`,schema:ia},description:`Create an LE target.`},{method:`POST`,path:Q(`/integrations/le/targets/test`),operationId:`integrationConnectionTest`,auth:`required`,body:ca,response:{kind:`json`,schema:la},description:`Test LE target connectivity.`},{method:`GET`,path:Q(`/integrations/le/targets/:id`),operationId:`integrationTargetDetail`,auth:`required`,params:Qa,response:{kind:`json`,schema:ia},description:`Read one LE target.`},{method:`PUT`,path:Q(`/integrations/le/targets/:id`),operationId:`integrationTargetById`,auth:`required`,params:Qa,body:sa,response:{kind:`json`,schema:ia},description:`Update one LE target.`},{method:`DELETE`,path:Q(`/integrations/le/targets/:id`),operationId:`integrationTargetDelete`,auth:`required`,params:Qa,response:{kind:`json`,schema:V({message:I().min(1)})},description:`Delete one LE target.`},{method:`POST`,path:Q(`/integrations/le/plan`),operationId:`integrationPlan`,auth:`required`,body:xa,response:{kind:`json`,schema:va},description:`Preview applying a running template or standalone asset to an LE target.`},{method:`POST`,path:Q(`/integrations/le/apply`),operationId:`integrationApply`,auth:`required`,body:xa,response:{kind:`json`,schema:Sa},additionalSuccessResponses:{207:Sa},description:`Apply a running template or standalone asset to an LE target.`},{method:`POST`,path:Q(`/integrations/le/cleanup/plan`),operationId:`integrationCleanupPlan`,auth:`required`,body:Ca,response:{kind:`json`,schema:va},description:`Preview removing what a template or standalone asset of this factory applied to an LE target.`},{method:`POST`,path:Q(`/integrations/le/cleanup`),operationId:`integrationCleanup`,auth:`required`,body:Ca,response:{kind:`json`,schema:wa},additionalSuccessResponses:{207:wa},description:`Remove what a template or standalone asset of this factory applied to an LE target.`},{method:`POST`,path:Q(`/integrations/le/operations/:operationId/cancel`),operationId:`integrationOperationCancel`,auth:`required`,params:Za,response:{kind:`json`,schema:ka},description:`Cancel an in-flight streaming LE operation.`},{method:`POST`,path:Q(`/integrations/le/apply/stream`),operationId:`integrationApplyStream`,auth:`required`,body:xa,response:{kind:`passthrough`},description:`Stream LE apply progress over SSE.`},{method:`POST`,path:Q(`/integrations/le/cleanup/stream`),operationId:`integrationCleanupStream`,auth:`required`,body:Ca,response:{kind:`passthrough`},description:`Stream LE cleanup progress over SSE.`}],ao=V({code:K([`UNAUTHORIZED`,`NOT_FOUND`,`INVALID_REQUEST`,`INTERNAL_ERROR`]),message:I(),hint:I().optional()}),oo={UNAUTHORIZED:401,NOT_FOUND:404,INVALID_REQUEST:400,INTERNAL_ERROR:500},so=class extends Error{code;status;hint;constructor(e){super(e.message),this.name=`ApiError`,this.code=e.code,this.status=e.status??oo[e.code],this.hint=e.hint}static is(e){return e instanceof Error&&e.name===`ApiError`}};function co(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function lo(e,t){return e?._def?.typeName===t}function uo(e,t){let n=e.ZodType.prototype[t];e.ZodType.prototype[t]=function(...e){let t=n.apply(this,e);return t._def.openapi=this._def.openapi,t}}function fo(e){if(e.ZodType.prototype.openapi!==void 0)return;e.ZodType.prototype.openapi=function(e,t){let n=(typeof e==`string`?t:e)??{},{param:r}=n,i=co(n,[`param`]),a=Object.assign(Object.assign({},this._def.openapi?._internal),typeof e==`string`?{refId:e}:void 0),o=Object.assign(Object.assign(Object.assign({},this._def.openapi?.metadata),i),this._def.openapi?.metadata?.param||r?{param:Object.assign(Object.assign({},this._def.openapi?.metadata?.param),r)}:void 0),s=new this.constructor(Object.assign(Object.assign({},this._def),{openapi:Object.assign(Object.assign({},Object.keys(a).length>0?{_internal:a}:void 0),Object.keys(o).length>0?{metadata:o}:void 0)}));if(lo(this,`ZodObject`)){let e=this.extend;s.extend=function(...t){let n=e.apply(this,t);return n._def.openapi={_internal:{extendedFrom:this._def.openapi?._internal?.refId?{refId:this._def.openapi?._internal?.refId,schema:this}:this._def.openapi?._internal?.extendedFrom},metadata:n._def.openapi?.metadata},n}}return s},uo(e,`optional`),uo(e,`nullable`),uo(e,`default`),uo(e,`transform`),uo(e,`refine`);let t=e.ZodObject.prototype.deepPartial;e.ZodObject.prototype.deepPartial=function(){let e=this._def.shape(),n=t.apply(this),r=n._def.shape();return Object.entries(r).forEach(([t,n])=>{n._def.openapi=e[t]?._def?.openapi}),n._def.openapi=void 0,n};let n=e.ZodObject.prototype.pick;e.ZodObject.prototype.pick=function(...e){let t=n.apply(this,e);return t._def.openapi=void 0,t};let r=e.ZodObject.prototype.omit;e.ZodObject.prototype.omit=function(...e){let t=r.apply(this,e);return t._def.openapi=void 0,t}}var po=class{constructor(e){this.parents=e,this._definitions=[]}get definitions(){return[...this.parents?.flatMap(e=>e.definitions)??[],...this._definitions]}register(e,t){let n=this.schemaWithRefId(e,t);return this._definitions.push({type:`schema`,schema:n}),n}registerParameter(e,t){let n=this.schemaWithRefId(e,t),r=n._def.openapi?.metadata,i=n.openapi(Object.assign(Object.assign({},r),{param:Object.assign(Object.assign({},r?.param),{name:r?.param?.name??e})}));return this._definitions.push({type:`parameter`,schema:i}),i}registerPath(e){this._definitions.push({type:`route`,route:e})}registerWebhook(e){this._definitions.push({type:`webhook`,webhook:e})}registerComponent(e,t,n){return this._definitions.push({type:`component`,componentType:e,name:t,component:n}),{name:t,ref:{$ref:`#/components/${e}/${t}`}}}schemaWithRefId(e,t){return t.openapi(e)}};fo(_r),new po,U(`type`,[wi.openapi(`SpawnCommand`),Ti.openapi(`RemoveAssetCommand`),Ei.openapi(`SetParameterCommand`),Di.openapi(`TriggerFaultCommand`),Oi.openapi(`ClearFaultCommand`),ki.openapi(`PauseCommand`),Ai.openapi(`ResumeCommand`),ji.openapi(`SetSpeedCommand`),Mi.openapi(`UnquarantineCommand`),Ni.openapi(`InvokeMethodCommand`),Pi.openapi(`LoadTemplateCommand`),Fi.openapi(`UnloadTemplateCommand`),Ii.openapi(`ResetFactoryCommand`),Li.openapi(`EnableAdapterCommand`),Ri.openapi(`DisableAdapterCommand`)]).openapi(`EngineCommand`);var mo=new Map(io.map(e=>[`${e.method} ${e.path}`,e]));function $(e,t){let n=mo.get(`${e} ${t}`);if(!n)throw Error(`Missing admin route definition for ${e} ${t}`);return n}var ho={assetDetail:$(`GET`,`/api/assets/:id`),authLogin:$(`POST`,`/api/auth/login`),authLogout:$(`POST`,`/api/auth/logout`),authPassword:$(`PUT`,`/api/auth/password`),authStatus:$(`GET`,`/api/auth/status`),bootstrap:$(`GET`,`/api/bootstrap`),catalogModelDetail:$(`GET`,`/api/catalog/models/:name`),catalogModelLeDt:$(`GET`,`/api/catalog/models/:name/le-dt.json`),catalogModels:$(`GET`,`/api/catalog/models`),catalogModelYaml:$(`GET`,`/api/catalog/models/:name/yaml`),catalogTemplateDetail:$(`GET`,`/api/catalog/templates/:id`),catalogTemplateLeTagsCsv:$(`GET`,`/api/catalog/templates/:id/le-tags.csv`),catalogTemplateLeTemplateJson:$(`GET`,`/api/catalog/templates/:id/le-template.json`),catalogTemplates:$(`GET`,`/api/catalog/templates`),catalogTemplateYaml:$(`GET`,`/api/catalog/templates/:id/yaml`),commands:$(`POST`,`/api/commands`),events:$(`GET`,`/api/events`),health:$(`GET`,`/api/healthz`),integrationApply:$(`POST`,`/api/integrations/le/apply`),integrationApplyStream:$(`POST`,`/api/integrations/le/apply/stream`),integrationCleanup:$(`POST`,`/api/integrations/le/cleanup`),integrationCleanupPlan:$(`POST`,`/api/integrations/le/cleanup/plan`),integrationCleanupStream:$(`POST`,`/api/integrations/le/cleanup/stream`),integrationConnectionTest:$(`POST`,`/api/integrations/le/targets/test`),integrationOperationCancel:$(`POST`,`/api/integrations/le/operations/:operationId/cancel`),integrationOperations:$(`GET`,`/api/integrations/le/operations`),integrationPlan:$(`POST`,`/api/integrations/le/plan`),integrationTargetById:$(`PUT`,`/api/integrations/le/targets/:id`),integrationTargetCreate:$(`POST`,`/api/integrations/le/targets`),integrationTargetDelete:$(`DELETE`,`/api/integrations/le/targets/:id`),integrationTargetDetail:$(`GET`,`/api/integrations/le/targets/:id`),integrationTargets:$(`GET`,`/api/integrations/le/targets`),manifest:$(`GET`,`/api/manifest`),metrics:$(`GET`,`/api/metrics`),modelDetail:$(`GET`,`/api/models/:name`),openApiDocument:$(`GET`,`/api/openapi.json`),readiness:$(`GET`,`/api/readyz`),runtimeWebSocket:$(`GET`,`/api/ws`),shutdown:$(`POST`,`/api/shutdown`),state:$(`GET`,`/api/state`),templates:$(`GET`,`/api/templates`)},go=`miravo:console-username`;function _o(){try{let e=sessionStorage.getItem(go);return typeof e==`string`&&e.length>0?e:``}catch{return``}}function vo(e){try{e!==null&&e.length>0?sessionStorage.setItem(go,e):sessionStorage.removeItem(go)}catch{}}var yo=new $e({defaultOptions:{queries:{staleTime:3e4,gcTime:10*6e4,retry:(e,t)=>{if(t instanceof Error&&t.message===`Session expired`)return!1;if(so.is(t)){let e=t.status;if(e>=400&&e<500)return!1}return e<2},refetchOnWindowFocus:!1}}}),bo={catalog:{templates:()=>[`catalog`,`templates`],models:()=>[`catalog`,`models`],templateDetail:e=>[`catalog`,`template`,e],modelSchema:e=>[`catalog`,`model-schema`,e],modelSchemasBatch:e=>[`catalog`,`model-schemas-batch`,e]},spawnPreviewAll:[`spawn`,`preview`],spawnPreview:(e,t,n,r)=>[`spawn`,`preview`,e,t,n,r],events:(e,t)=>[`events`,e,t],tags:{manifest:e=>[`tags`,`manifest`,e]},integrations:{targets:()=>[`integrations`,`targets`],operationsList:()=>[`integrations`,`operations`,`list`],operationsFactory:()=>[`integrations`,`operations`,`factory`],plan:(e,t)=>[`integrations`,`plan`,e,t],operationsForTarget:e=>[`integrations`,`operations`,`target`,e],operations:()=>[`integrations`,`operations`]},assets:{detail:e=>[`assets`,e]},floor:{state:()=>[`floor`,`state`]}},xo=`miravo:query-cache:v2`,So=5*6e4,Co=bo.integrations.targets(),wo=`bootstrap`,To=!0;function Eo(e){try{let t=sessionStorage.getItem(xo);if(!t)return;let n=JSON.parse(t);if(typeof n!=`object`||!n)return;let r=n;if(typeof r.timestamp!=`number`)return;if(Date.now()-r.timestamp>So){sessionStorage.removeItem(xo);return}Ae(e,r.state)}catch{}}function Do(e){try{let t=ke(e,{shouldDehydrateQuery:e=>e.state.status===`success`&&e.queryKey[0]!==wo&&!(e.queryKey[0]===Co[0]&&e.queryKey[1]===Co[1])}),n={timestamp:Date.now(),state:t};sessionStorage.setItem(xo,JSON.stringify(n))}catch{}}function Oo(e){let t=null,n=e.getQueryCache().subscribe(()=>{To&&(t&&clearTimeout(t),t=setTimeout(()=>{To&&Do(e)},500))});return()=>{t&&clearTimeout(t),n()}}function ko(){try{sessionStorage.removeItem(xo)}catch{}}function Ao(){To=!0}function jo(){To=!1}var Mo=(void 0)?.trim()||`/api`;function No(e,t){return`${e.trim().replace(/\/+$/,``)||`/api`}${t.startsWith(`/`)?t:`/${t}`}`}function Po(){jo(),yo.cancelQueries(),yo.setQueryData([`bootstrap`],{authenticated:!1}),yo.removeQueries({predicate:e=>e.queryKey[0]!==`bootstrap`}),ko(),ft(),vo(null)}function Fo(){typeof window>`u`||(Po(),window.location.pathname!==`/login`&&window.location.replace(`/login`))}var Io=class extends Error{result;constructor(e){super(e.message),this.name=`CommandError`,this.result=e}};function Lo(e,t){let n=`${e} ${t}`;return e===502||e===503||e===504?`${n} — the Miravo server may not be running, or a reverse proxy cannot reach it.`:n}async function Ro(e){try{let t=await e.json(),n=ao.safeParse(t);if(n.success)return new so({code:n.data.code,status:e.status,message:n.data.message,hint:n.data.hint})}catch{}return Error(Lo(e.status,e.statusText))}async function zo(e,t){return Ho(`/auth/login`,ho.authLogin,{body:{username:e,password:t}})}async function Bo(){await Ho(`/auth/logout`,ho.authLogout)}function Vo(e,t){if(e.response.kind!==`json`)throw Error(`requestJSON requires a JSON route definition for ${e.method} ${e.path}`);return e.additionalSuccessResponses?.[t]??e.response.schema}async function Ho(e,t,n={}){let{body:r,init:i}=n,a={method:t.method,credentials:`include`,...i};if(t.body){let e=t.body.safeParse(r);if(!e.success)throw Error(`Invalid request for ${t.method} ${t.path}: ${e.error.message}`);a.headers={"content-type":`application/json`,...i?.headers??{}},a.body=JSON.stringify(e.data)}else if(r!==void 0)throw Error(`Route ${t.method} ${t.path} does not accept a JSON body.`);let o=await fetch(No(Mo,e),a);if(o.status===401&&t.auth===`required`)throw Fo(),Error(`Session expired`);if(!o.ok)throw await Ro(o);let s;try{s=await o.json()}catch{throw Error(`Invalid JSON response for ${t.method} ${t.path}`)}let c=Vo(t,o.status).safeParse(s);if(!c.success)throw Error(`Invalid response for ${t.method} ${t.path}: ${c.error.message}`);return c.data}async function Uo(e,t){return Ho(`/auth/password`,ho.authPassword,{body:{oldPassword:e,newPassword:t}})}async function Wo(){return Ho(`/bootstrap`,ho.bootstrap)}async function Go(e,t){return Ho(e,t)}async function Ko(e){let t=await Ho(`/commands`,ho.commands,{body:e});if(!t.success)throw new Io(t);return t}async function qo(e,t){if(t.response.kind!==`passthrough`)throw Error(`fetchBlob requires a passthrough route definition for ${t.method} ${t.path}`);let n=await fetch(No(Mo,e),{credentials:`include`});if(n.status===401&&t.auth===`required`)throw Fo(),Error(`Session expired`);if(!n.ok)throw Error(Lo(n.status,n.statusText));return n.blob()}async function Jo(e,t){if(t.response.kind!==`yaml`)throw Error(`fetchText requires a YAML route definition for ${t.method} ${t.path}`);let n=await fetch(No(Mo,e),{credentials:`include`});if(n.status===401&&t.auth===`required`)throw Fo(),Error(`Session expired`);if(!n.ok)throw Error(Lo(n.status,n.statusText));return n.text()}export{I as $,Qr as A,wr as B,so as C,ve as Ct,ni as D,r as Dt,Vi as E,i as Et,Tr as F,R as G,Ar as H,Er as I,ir as J,U as K,Or as L,ei as M,Xr as N,X as O,Dr as P,W as Q,q as R,ho as S,se as St,Ba as T,o as Tt,Cr as U,Fr as V,B as W,L as X,G as Y,V as Z,Oo as _,l as _t,qo as a,mt as at,vo as b,m as bt,Wo as c,Ke as ct,Ko as d,Be as dt,er as et,Fo as f,h as ft,Eo as g,pe as gt,Ao as h,d as ht,Po as i,ft as it,$r as j,ti as k,zo as l,qe as lt,No as m,be as mt,Io as n,z as nt,Go as o,_t as ot,Ho as p,xe as pt,K as q,Uo as r,y as rt,Jo as s,ot as st,Mo as t,H as tt,Bo as u,Ue as ut,bo as v,fe as vt,ao as w,f as wt,_o as x,p as xt,yo as y,oe as yt,Mr as z};
|