@lobu/runtime-server 24.10.0 → 24.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/dist/catalogs/connectors.json +1 -1
- package/dist/component.json +1 -1
- package/dist/connectors/linkedin-inbox-adapter.js +13 -3
- package/dist/connectors/whatsapp-web-adapter.js +14 -13
- package/dist/connectors/whatsapp-web-helpers.ts +37 -1
- package/dist/connectors/whatsapp_web.ts +5 -5
- package/dist/connectors/x-dm-adapter.js +17 -3
- package/dist/db/migrations/20261113170000_member_sql_rls.sql +254 -0
- package/dist/db/migrations/20261113180000_member_sql_rls_parallel_plans.sql +192 -0
- package/dist/db/migrations/20261113190000_member_sql_schema_usage.sql +24 -0
- package/dist/db/migrations/20261114120000_events_owner_only_visibility.sql +39 -0
- package/dist/dependencies.bun.lock +10 -10
- package/dist/embeddings-server.mjs +1 -1
- package/dist/guest.bundle.js +1 -1
- package/dist/owletto/dist/assets/_-BDMUN9XZ.js +2 -0
- package/dist/owletto/dist/assets/_-CF5X4ANe.js +3 -0
- package/dist/owletto/dist/assets/{_agentId-DN0EwMAC.js → _agentId-CGScf8z_.js} +2 -2
- package/dist/owletto/dist/assets/_agentId-EQU2aUP0.js +2 -0
- package/dist/owletto/dist/assets/_automationId-PXZ33jsF.js +2 -0
- package/dist/owletto/dist/assets/{_connectorKey._connectionId-CVKfL9AG.js → _connectorKey._connectionId-DcI29kGy.js} +2 -2
- package/dist/owletto/dist/assets/_connectorKey.index-Cr2NDJWX.js +2 -0
- package/dist/owletto/dist/assets/{_conversationId-CPpNySjO.js → _conversationId-CnmLYlVS.js} +2 -2
- package/dist/owletto/dist/assets/_eventId-w5sDz5oa.js +2 -0
- package/dist/owletto/dist/assets/_owner-CkOZR4n0.js +3 -0
- package/dist/owletto/dist/assets/_shape-C_FmSf9G.js +2 -0
- package/dist/owletto/dist/assets/{_slug-DJx_8fsV.js → _slug-COPpRXLt.js} +2 -2
- package/dist/owletto/dist/assets/_viewKey-BVdJiilV.js +2 -0
- package/dist/owletto/dist/assets/_viewKey-mxxpqjtC.js +2 -0
- package/dist/owletto/dist/assets/{accept-invitation-Dwq1GAnG.js → accept-invitation-BKeIzZXE.js} +2 -2
- package/dist/owletto/dist/assets/{activity-route-location-C1jcXC7v.js → activity-route-location-sLvKaSCa.js} +2 -2
- package/dist/owletto/dist/assets/activity-route-view-msesKUwn.js +2 -0
- package/dist/owletto/dist/assets/{agent-connect-pages-DoI9UR0a.js → agent-connect-pages-DVq9nAR7.js} +3 -3
- package/dist/owletto/dist/assets/{agent-editor-form-DlavYg2q.js → agent-editor-form-DVFyyMyd.js} +2 -2
- package/dist/owletto/dist/assets/{agent-loading-shells-DYqQphN7.js → agent-loading-shells-BLNHIy-r.js} +2 -2
- package/dist/owletto/dist/assets/{agent-permissions-matrix-C1L8IcYR.js → agent-permissions-matrix-UBKRR5vs.js} +2 -2
- package/dist/owletto/dist/assets/{agent-skill-context-D1nMrVod.js → agent-skill-context-fqedKd0D.js} +2 -2
- package/dist/owletto/dist/assets/{agent-subpage-shell-2w7vTeXw.js → agent-subpage-shell-BUCoY2Nf.js} +2 -2
- package/dist/owletto/dist/assets/{agent-thread-BopD-2k1.js → agent-thread-Cqf9ITrT.js} +2 -2
- package/dist/owletto/dist/assets/app-bridge-B-L0rGz9.js +121 -0
- package/dist/owletto/dist/assets/{app._appId-BXeFXW1w.js → app._appId-ByIypCL9.js} +2 -2
- package/dist/owletto/dist/assets/{assist-composer-CL5x8pNt.js → assist-composer-kG_heHXo.js} +2 -2
- package/dist/owletto/dist/assets/{automation-run-now-MtxUTfzd.js → automation-run-now-C5XTS00o.js} +2 -2
- package/dist/owletto/dist/assets/{callback-BgfwP1Eo.js → callback-Pz5uS-k7.js} +2 -2
- package/dist/owletto/dist/assets/{card-DtLIFq7D.js → card-CAPpY9P5.js} +2 -2
- package/dist/owletto/dist/assets/{claim-CT3hYVMF.js → claim-DgWWK0KI.js} +2 -2
- package/dist/owletto/dist/assets/{client-activity-scopes-BPbRX-Pe.js → client-activity-scopes-Aqdo6Pdr.js} +2 -2
- package/dist/owletto/dist/assets/{client-rows-vrNA6FLs.js → client-rows-Dd5YV8vn.js} +2 -2
- package/dist/owletto/dist/assets/{clients-xnzZeEdZ.js → clients-Bf7ZgGro.js} +2 -2
- package/dist/owletto/dist/assets/{code-editor-mrKkAfcE.js → code-editor-z1Sy_hiX.js} +2 -2
- package/dist/owletto/dist/assets/connect-BFNp1y_s.js +2 -0
- package/dist/owletto/dist/assets/{connect-menu-C6iVtuSo.js → connect-menu-BWrAhMqO.js} +2 -2
- package/dist/owletto/dist/assets/connect._clientId-CSPfwYIN.js +2 -0
- package/dist/owletto/dist/assets/{connected._clientId-ROfVgp9h.js → connected._clientId-CuOeHafK.js} +2 -2
- package/dist/owletto/dist/assets/{connection-BMz740Wi.js → connection-CVeHmDLs.js} +2 -2
- package/dist/owletto/dist/assets/{connection-feed-detail-0VAJiZTP.js → connection-feed-detail-BYo7zdVD.js} +2 -2
- package/dist/owletto/dist/assets/{connector-page-shell-BFv21yuv.js → connector-page-shell-an3SYLim.js} +2 -2
- package/dist/owletto/dist/assets/{connector-provenance-b59RfBtk.js → connector-provenance-mSZCOud-.js} +2 -2
- package/dist/owletto/dist/assets/{connectors-nYS31lO2.js → connectors-DBEM9QQz.js} +2 -2
- package/dist/owletto/dist/assets/{consent-cPRF9JQv.js → consent-1ulwyJ3k.js} +2 -2
- package/dist/owletto/dist/assets/{copy-button-C3wMMv63.js → copy-button-Xhh7ZnjO.js} +2 -2
- package/dist/owletto/dist/assets/{core.esm-C9QlSrgK.js → core.esm-Ctg_pXLe.js} +2 -2
- package/dist/owletto/dist/assets/{create-CGOWfMk4.js → create-CGuoqPh8.js} +2 -2
- package/dist/owletto/dist/assets/create-Ccb5R-S4.js +2 -0
- package/dist/owletto/dist/assets/{create-ASRN3Obq.js → create-DmhbacIa.js} +2 -2
- package/dist/owletto/dist/assets/{create-automation-form-CLicoPH5.js → create-automation-form-CD6jSlWL.js} +2 -2
- package/dist/owletto/dist/assets/create._connectorKey-CZsAqj1p.js +2 -0
- package/dist/owletto/dist/assets/{custom-guardrail-edits-BUL7nmuO.js → custom-guardrail-edits-Ce_BwiwD.js} +2 -2
- package/dist/owletto/dist/assets/{definition-comparison-4UYMI6BK.js → definition-comparison-D_qP25jR.js} +2 -2
- package/dist/owletto/dist/assets/{detail-page-skeleton-C8v3rJXK.js → detail-page-skeleton-CPAfZLG0.js} +2 -2
- package/dist/owletto/dist/assets/{device-BBwsOi7q.js → device-DDl5XKvt.js} +2 -2
- package/dist/owletto/dist/assets/{device-pin-tombstone-Bcpe7nAA.js → device-pin-tombstone-Dkj7hrBE.js} +2 -2
- package/dist/owletto/dist/assets/{device._deviceId-DLT4jh0Z.js → device._deviceId-bNhTcops.js} +2 -2
- package/dist/owletto/dist/assets/{dynamic-schema-form-BDT8x0Vg.js → dynamic-schema-form-CRyUchXo.js} +2 -2
- package/dist/owletto/dist/assets/{entity-options-B9hm9V87.js → entity-options-D4t-NAcg.js} +2 -2
- package/dist/owletto/dist/assets/entity-page-BOOL_vy3.js +2 -0
- package/dist/owletto/dist/assets/{entity-pages-BWBpttz3.js → entity-pages-_nuesgnp.js} +2 -2
- package/dist/owletto/dist/assets/{entity-schema-graph-lMMx3HhR.js → entity-schema-graph-Cq96SJ3c.js} +2 -2
- package/dist/owletto/dist/assets/{entity-type-page-CkQm0yEu.js → entity-type-page-CkCSbkBx.js} +2 -2
- package/dist/owletto/dist/assets/event-detail-DUvlqn9b.js +2 -0
- package/dist/owletto/dist/assets/{events-feed-DmRzikZW.js → events-feed-DcKTkJVe.js} +2 -2
- package/dist/owletto/dist/assets/{filter-editors-CQoSj-20.js → filter-editors-DGVl9U4D.js} +3 -3
- package/dist/owletto/dist/assets/{full-page-spinner-CYyCnKve.js → full-page-spinner-CtVlF8GQ.js} +2 -2
- package/dist/owletto/dist/assets/index-BUlkNJzX.js +2 -0
- package/dist/owletto/dist/assets/{index-BS5Ty3tf.js → index-BifR-LE9.js} +2 -2
- package/dist/owletto/dist/assets/{index-DByaMzsG.js → index-BoqrvLHQ.js} +1383 -1383
- package/dist/owletto/dist/assets/index-CA9mW_ZM.js +2 -0
- package/dist/owletto/dist/assets/index-CH0GzG4i.js +2 -0
- package/dist/owletto/dist/assets/index-CK5GDX4B.js +2 -0
- package/dist/owletto/dist/assets/index-CtI5Eomq.js +2 -0
- package/dist/owletto/dist/assets/{index-CUndAH6o.js → index-DbjbHlDe.js} +2 -2
- package/dist/owletto/dist/assets/index-DmtQ0bds.js +2 -0
- package/dist/owletto/dist/assets/{index-CDyFQ32o.js → index-Du_J8hnx.js} +2 -2
- package/dist/owletto/dist/assets/{index-ittfA0k8.js → index-DvuJ_S_o.js} +2 -2
- package/dist/owletto/dist/assets/index-Pae_f9LM.css +1 -0
- package/dist/owletto/dist/assets/{index-C3hz9tzx.js → index-XETZnN7L.js} +2 -2
- package/dist/owletto/dist/assets/{json-diff-mcDgyct_.js → json-diff-OjtREegr.js} +2 -2
- package/dist/owletto/dist/assets/{list-skeleton-DsYGUHxi.js → list-skeleton-CH0qQBYk.js} +2 -2
- package/dist/owletto/dist/assets/{login-EoLq136v.js → login-DG0b9uSC.js} +2 -2
- package/dist/owletto/dist/assets/{logout-gLgEQOiX.js → logout-DfdgOLoM.js} +2 -2
- package/dist/owletto/dist/assets/{member-scope-gate-vvkgSAb2.js → member-scope-gate-Cxg2zGQT.js} +2 -2
- package/dist/owletto/dist/assets/memory-browse-page-qEDQ9Z18.js +74 -0
- package/dist/owletto/dist/assets/missing-view-xT0B-f5z.js +2 -0
- package/dist/owletto/dist/assets/{model-selector-D3vSMLO2.js → model-selector-D2OpDkwH.js} +2 -2
- package/dist/owletto/dist/assets/{needs-you-list-B5Bgd05M.js → needs-you-list-3uMsWcDv.js} +2 -2
- package/dist/owletto/dist/assets/{new-dLXsCHBd.js → new-AdGV6a8R.js} +2 -2
- package/dist/owletto/dist/assets/new-BdtIhBpo.js +2 -0
- package/dist/owletto/dist/assets/{new-Bk_flKQO.js → new-BjGwX6s6.js} +2 -2
- package/dist/owletto/dist/assets/{new-BPW3V0Y1.js → new-D-iMjV74.js} +2 -2
- package/dist/owletto/dist/assets/{organization-DBfgBkzq.js → organization-qaIpEiQg.js} +2 -2
- package/dist/owletto/dist/assets/peek-pane-content-CEsDVScl.js +2 -0
- package/dist/owletto/dist/assets/{pending-seed-CBhx2Ql-.js → pending-seed-BBACroge.js} +2 -2
- package/dist/owletto/dist/assets/{proposal-review-shell-B-jYcKfB.js → proposal-review-shell-C8ZfIAYn.js} +2 -2
- package/dist/owletto/dist/assets/public-shell-ready-K2R8iXSI.js +2 -0
- package/dist/owletto/dist/assets/{record-session-CAmGHMyM.js → record-session-BrM9cdXu.js} +2 -2
- package/dist/owletto/dist/assets/{renderer-olRv_HMI.js → renderer-CTKNMcXP.js} +4 -4
- package/dist/owletto/dist/assets/{reset-password-B9_xi8Pq.js → reset-password-DKBEneyR.js} +2 -2
- package/dist/owletto/dist/assets/{run-initiator-DhE5v4z0.js → run-initiator-BKSgI1o0.js} +2 -2
- package/dist/owletto/dist/assets/{runs-C8sZQr4o.js → runs-k2NpbZm8.js} +2 -2
- package/dist/owletto/dist/assets/runs-list-DUXRMkWN.js +2 -0
- package/dist/owletto/dist/assets/{schema-value-zTJGE4eh.js → schema-value-wjqGxXhv.js} +3 -3
- package/dist/owletto/dist/assets/{scoped-feed-bar-BKyJSa3_.js → scoped-feed-bar-DNFL0sYX.js} +2 -2
- package/dist/owletto/dist/assets/{settings-z02cvVS3.js → settings-V0m5Om5j.js} +2 -2
- package/dist/owletto/dist/assets/{source-record-panels-CGmKIJdN.js → source-record-panels-BMut9YIA.js} +2 -2
- package/dist/owletto/dist/assets/{status-variants-DyRCXBzM.js → status-variants-SzXYYedJ.js} +2 -2
- package/dist/owletto/dist/assets/subDays-9s9OEl5t.js +2 -0
- package/dist/owletto/dist/assets/{table-C637cQxG.js → table-ZuYMOjVR.js} +2 -2
- package/dist/owletto/dist/assets/{use-automations-CgWNoYio.js → use-automations-DfBtVzGa.js} +2 -2
- package/dist/owletto/dist/assets/{use-login-redirect-tDdhXTpt.js → use-login-redirect-BDiS3eyl.js} +2 -2
- package/dist/owletto/dist/assets/{use-mention-search-D-kIKchD.js → use-mention-search-khySpz_V.js} +2 -2
- package/dist/owletto/dist/assets/view-card-DiHWlypr.js +2 -0
- package/dist/owletto/dist/assets/view-param-filters-DGKxSr7r.js +2 -0
- package/dist/owletto/dist/assets/{views-access-required-C35Dyt91.js → views-access-required-HA-PiOwA.js} +2 -2
- package/dist/owletto/dist/index.html +2 -2
- package/dist/server-main.bundle.mjs +1052 -538
- package/npm-shrinkwrap.json +38 -38
- package/package.json +1 -1
- package/vendor/connector-sdk/package.json +1 -1
- package/vendor/core/package.json +1 -1
- package/vendor/views/package.json +1 -1
- package/dist/owletto/dist/assets/_-CYvj1y65.js +0 -3
- package/dist/owletto/dist/assets/_-CeLTSYYY.js +0 -2
- package/dist/owletto/dist/assets/_agentId-BB5E-L6T.js +0 -2
- package/dist/owletto/dist/assets/_automationId-DvUl9CSd.js +0 -2
- package/dist/owletto/dist/assets/_connectorKey.index-Cv6FzK1v.js +0 -2
- package/dist/owletto/dist/assets/_eventId-DZKicuq6.js +0 -2
- package/dist/owletto/dist/assets/_owner-Dauk3YuD.js +0 -3
- package/dist/owletto/dist/assets/_shape-cKrEID3T.js +0 -2
- package/dist/owletto/dist/assets/_viewKey-CPVzVKEf.js +0 -2
- package/dist/owletto/dist/assets/_viewKey-CW8gexOQ.js +0 -2
- package/dist/owletto/dist/assets/activity-route-view-D78Wj0RH.js +0 -2
- package/dist/owletto/dist/assets/app-bridge-C4nPtae3.js +0 -121
- package/dist/owletto/dist/assets/connect-NUCSay8X.js +0 -2
- package/dist/owletto/dist/assets/connect._clientId-Cp-d9Q5b.js +0 -2
- package/dist/owletto/dist/assets/create-CBcodaSO.js +0 -2
- package/dist/owletto/dist/assets/create._connectorKey-s4xkktTC.js +0 -2
- package/dist/owletto/dist/assets/entity-page-DZjzQ2V4.js +0 -2
- package/dist/owletto/dist/assets/event-detail-CkzfakTK.js +0 -2
- package/dist/owletto/dist/assets/index-BE7eb2kE.js +0 -2
- package/dist/owletto/dist/assets/index-BFR0uiKY.js +0 -2
- package/dist/owletto/dist/assets/index-C38OzBpB.js +0 -2
- package/dist/owletto/dist/assets/index-CiKysEhV.js +0 -2
- package/dist/owletto/dist/assets/index-DfdinB7B.js +0 -2
- package/dist/owletto/dist/assets/index-DgMM4Zt5.css +0 -1
- package/dist/owletto/dist/assets/index-Xk711gVC.js +0 -2
- package/dist/owletto/dist/assets/memory-browse-page-DvDtwrEI.js +0 -74
- package/dist/owletto/dist/assets/new-C5HtQdM_.js +0 -2
- package/dist/owletto/dist/assets/peek-pane-content-c2PG3TEX.js +0 -2
- package/dist/owletto/dist/assets/public-shell-ready-D8TijlRY.js +0 -2
- package/dist/owletto/dist/assets/record-activity-DnRVOrG2.js +0 -2
- package/dist/owletto/dist/assets/runs-list-CwtH-wmk.js +0 -2
- package/dist/owletto/dist/assets/subDays-D8nHthaS.js +0 -2
- package/dist/owletto/dist/assets/view-param-filters-CUCj9Df-.js +0 -2
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
function on(e){const t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,o])=>t.indexOf(+r)===-1).map(([r,o])=>o)}function ar(e,t="|"){return e.map(n=>go(n)).join(t)}function sn(e,t){return typeof t=="bigint"?t.toString():t}class vi{constructor(t){this._getter=t,this._value=void 0}get value(){const t=this._getter;return t!==void 0&&(this._value=t(),this._getter=void 0),this._value}}function Mt(e){return new vi(e)}function bi(e){return e==null}function yn(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function yi(e,t){const n=e/t,r=Math.round(n),o=4*Number.EPSILON*Math.max(Math.abs(n),1);return Math.abs(n-r)<o?0:n-r}function $e(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function wn(e){const t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function ye(e){return wn(e._zod.def)??e._zod.def.shape}function po(e,t,n){Object.defineProperty(e,t,{get(){const r=n();return $e(this,t,r),r},enumerable:!0,configurable:!0})}function fo(e,t,n){t in e?$e(e,t,n):e[t]=n}function Ne(e,t,n,r){const o=ye(t);for(const s of n){const i=Object.getOwnPropertyDescriptor(o,s);i.enumerable&&(i.get?po(e,s,()=>{const a=t._zod.def.shape[s];return r?r(a,s):a}):fo(e,s,r?r(i.value,s):i.value))}}function wi(e,t){for(const n of Reflect.ownKeys(t)){const r=Object.getOwnPropertyDescriptor(t,n);r.enumerable&&(r.get?po(e,n,()=>t[n]):fo(e,n,r.value))}}function ae(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function ki(e){return JSON.stringify(e)}function $i(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const ho="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function et(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const zi=Mt(()=>{if(ge.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function De(e){if(et(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(et(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function mo(e){return De(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const Si=new Set(["string","number","symbol"]);function qe(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Re(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function k(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function go(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function Zi(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}const _o={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},Ti={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function Ii(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const s={};return Ne(s,e,Dt(e,t)),Re(e,ae(n,{shape:s,checks:[]}))}function Dt(e,t){const n=ye(e),r=[];for(const o of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,o)?.enumerable)throw new Error(`Unrecognized key: "${String(o)}"`);t[o]&&r.push(o)}return r}function Pi(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const s=new Set(Dt(e,t)),i={};return Ne(i,e,Reflect.ownKeys(ye(e)).filter(a=>!s.has(a))),Re(e,ae(n,{shape:i,checks:[]}))}function Ri(e,t){if(!De(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const o=ye(e);for(const s of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(o,s)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return Re(e,ae(e._zod.def,{shape:vo(e,t)}))}function vo(e,t){const n={};return Ne(n,e,Reflect.ownKeys(ye(e))),wi(n,t),n}function Ei(e,t){if(!De(t))throw new Error("Invalid input to safeExtend: expected a plain object");return Re(e,ae(e._zod.def,{shape:vo(e,t)}))}function Oi(e,t){if(!t?._zod?.def)throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");const n={};Ne(n,e,Reflect.ownKeys(ye(e))),Ne(n,t,Reflect.ownKeys(ye(t)));const r=ae(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return Re(e,r)}function cr(e,t,n,r="partial"){const s=t._zod.def.checks;if(s&&s.length>0)throw new Error(`.${r}() cannot be used on object schemas containing refinements`);const a=n?new Set(Dt(t,n)):void 0,c={};return Ne(c,t,Reflect.ownKeys(ye(t)),e&&((u,l)=>a&&!a.has(l)?u:new e({type:"optional",innerType:u}))),Re(t,ae(t._zod.def,{shape:c,checks:[]}))}function xi(e,t,n){const r=n?new Set(Dt(t,n)):void 0,o={};return Ne(o,t,Reflect.ownKeys(ye(t)),(s,i)=>r&&!r.has(i)?s:new e({type:"nonoptional",innerType:s})),Re(t,ae(t._zod.def,{shape:o}))}function be(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Ci(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function Me(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function Be(e){return typeof e=="string"?e:e?.message}function ur(e){const t=[];for(const n of e??[]){const r=n._zod.def;if(!/_(length|size)$|_equals$/.test(r.check))break;const o=r.maximum??r.length??r.size;o>=0&&t.push([o,n])}return t}function an(e,t,n){var r;for(let o=t;o<e.length;o++)(r=e[o]).schema??(r.schema=n)}function Se(e,t,n){var r;const o=e.inst?._zod?.traits;o?.has("$ZodType")&&(o.has("$ZodCheck")?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);const s=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,i=e.message?e.message:Be(e.inst?._zod.def?.error?.(e))??Be(s?.(e))??Be(t?.error?.(e))??Be(n.customError?.(e))??Be(n.localeError?.(e))??"Invalid input",a={};for(const c of Object.keys(e))c==="inst"||c==="schema"||c==="continue"||c==="input"||c==="__proto__"||(a[c]=e[c]);return a.path??(a.path=[]),a.message=i,t?.reportInput&&(a.input=e.input),a}const Ni=/[\uD800-\uDBFF]/;function kn(e){const t=e.length;if(!Ni.test(e))return t;let n=t;for(let r=0;r<t-1;r++)(e.charCodeAt(r)&64512)===55296&&(e.charCodeAt(r+1)&64512)===56320&&(n--,r++);return n}function $n(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Ai(e){const t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";const n=e;if(n&&Object.getPrototypeOf(n)!==Object.prototype&&"constructor"in n&&n.constructor)return n.constructor.name}}return t}function tt(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}function ji(e,t){for(const n in t){const r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):Mi(e,n,r.value)}}function Ze(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function bo(e,t,n){return Ze(e,t,n,!1)}function yo(e,t){for(const n in e){const r=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return Ze(this,n,r(this))},set(o){Ze(this,n,o)}})}return t}function Mi(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:Ze(this,t,n.bind(this))},set(r){Ze(this,t,r)}})}function Di(e,t){const n=Object.getPrototypeOf(e);return t in n?void 0:n}let Gt,ze=!1;const qi={configurable:!0,get(){ze=!0}};function E(e,t,n){const r=Object.getPrototypeOf(e._zod);if(t in r&&Gt!==e._zod){Gt=void 0;return}Gt=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,qi);const o=ze;ze=!1;try{const s=n(this);return ze?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:s}),ze=ze||o,s}catch(s){throw delete this[t],ze=ze||o,s}},set(o){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:o})}})}function Ui(e,t,n,r){const o=Di(e,t);o&&Object.defineProperty(o,t,{configurable:!0,get(){const s={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,s),s.value=n(this),Object.defineProperty(this,t,s),s.value},set(s){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:s})}})}const Li="~constantCatch";function Fi(e){const t=()=>e;return t[Li]=!0,t}var lr;const Yt={value:void 0,enumerable:!1};let dr="captureStackTrace"in Error?Error:null;function Hi(e){const t=dr;if(t){const n=t.stackTraceLimit;if(typeof n=="number"){try{t.stackTraceLimit=0}catch{return dr=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function m(e,t,n,r){const o={};function s(p){this.def=p,this.constr=d,this.traits=new Set}s.prototype=o;const i=n,a=i&&new WeakSet;function c(p,h){if(p._zod){if(p._zod.traits.has(e))return}else{Yt.value=new s(h);try{Object.defineProperty(p,"_zod",Yt)}finally{Yt.value=void 0}}if(p._zod.traits.add(e),t(p,h),a){const w=Object.getPrototypeOf(p),S=p._zod.constr.prototype;let I=w;for(;I&&I!==S;)I=Object.getPrototypeOf(I);const Z=I??w;a.has(Z)||(a.add(Z),ji(Z,i))}const _=d.prototype;for(const w in _)Object.prototype.hasOwnProperty.call(_,w)&&(w in p||(p[w]=_[w].bind(p)))}const u=r?.Parent??Object;class l extends u{}Object.defineProperty(l,"name",{value:e});function d(p){const h=r?.Parent?Hi(l):this;c(h,p);const _=h._zod.deferred;if(_){for(const S of _)S();h._zod.deferred=void 0}const w=globalThis.__zod_globalConfig?.postProcessor;return w&&w(h),h}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:p=>r?.Parent&&p instanceof r.Parent?!0:p?._zod?.traits?.has(e)}),Object.defineProperty(d,"name",{value:e}),d}let Ce=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}};class wo extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}(lr=globalThis).__zod_globalConfig??(lr.__zod_globalConfig={});const ge=globalThis.__zod_globalConfig;function ve(e){return e&&Object.assign(ge,e),ge}function Ji(){const e=this._zod;return e.message??(e.message=JSON.stringify(e.def,sn,2)),e.message}function Vi(e){this._zod.message=e}const Bi={get:Ji,set:Vi,enumerable:!0,configurable:!0},Qt={value:void 0,enumerable:!1},pr=new WeakSet([Object.prototype,Error.prototype]),ko=(e,t)=>{e.name="$ZodError",Qt.value=t,Object.defineProperty(e,"issues",Qt),Qt.value=void 0,Object.defineProperty(e,"message",Bi);const n=Object.getPrototypeOf(e);pr.has(n)||(pr.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){const r=()=>this.message;return Object.defineProperty(this,"toString",{value:r,configurable:!0,writable:!0}),r},set(r){Object.defineProperty(this,"toString",{value:r,configurable:!0,writable:!0})}}))},Ki=m("$ZodError",ko),Wi=m("$ZodError",ko,void 0,{Parent:Error});function Gi(e,t,n){return Object.prototype.hasOwnProperty.call(e,t)||(t==="__proto__"?Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0}):e[t]=n()),e[t]}function Yi(e,t=n=>n.message){const n={},r=[];for(const o of e.issues)o.path.length>0?Gi(n,o.path[0],()=>[]).push(t(o)):r.push(t(o));return{formErrors:r,fieldErrors:n}}function Qi(e,t=n=>n.message){const n={_errors:[]},r=(o,s=[])=>{for(const i of o.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(a=>r({issues:a},[...s,...i.path]));else if(i.code==="invalid_key")r({issues:i.issues},[...s,...i.path]);else if(i.code==="invalid_element")r({issues:i.issues},[...s,...i.path]);else{const a=[...s,...i.path];if(a.length===0)n._errors.push(t(i));else{let c=n,u=0;for(;u<a.length;){const l=a[u],d=u===a.length-1;if(l==="_errors"){d&&c._errors.push(t(i)),u++;continue}Object.prototype.hasOwnProperty.call(c,l)||Object.defineProperty(c,l,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});const p=c[l];d&&p._errors.push(t(i)),c=p,u++}}}};return r(e),n}function qt(e,t){return{callee:t?.callee??e,Err:t?.Err}}const zn=e=>{const t=(n,r,o,s)=>{const i=o?{...o,async:!1}:{async:!1},a=n._zod.run({value:r,issues:[]},i);if(a instanceof Promise)throw new Ce;if(a.issues.length){const c=new(s?.Err??e)(a.issues.map(u=>Se(u,i,ve())));throw ho(c,s?.callee??t),c}return a.value};return t},Sn=e=>{const t=async(n,r,o,s)=>{const i=o?{...o,async:!0}:{async:!0};let a=n._zod.run({value:r,issues:[]},i);if(a instanceof Promise&&(a=await a),a.issues.length){const c=new(s?.Err??e)(a.issues.map(u=>Se(u,i,ve())));throw ho(c,s?.callee??t),c}return a.value};return t},Ut=e=>(t,n,r)=>{const o=r?{...r,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},o);if(s instanceof Promise)throw new Ce;return s.issues.length?$o(e,s.issues,o):{success:!0,data:s.value}},Xi=Ut(Wi);function $o(e,t,n){let r;return{success:!1,get error(){return r||(r=new e(t.map(o=>Se(o,n,ve()))),t=void 0,n=void 0),r},set error(o){r=o,t=void 0,n=void 0}}}const Zn=e=>async(t,n,r)=>{const o=r?{...r,async:!0}:{async:!0};let s=t._zod.run({value:n,issues:[]},o);return s instanceof Promise&&(s=await s),s.issues.length?$o(e,s.issues,o):{success:!0,data:s.value}},ea=Symbol.for("zod.compile.invalid"),ta=Symbol.for("zod.compile.fallback"),na=((e,t,n)=>{const r=e._zod.bag.validator;if(r!==void 0){if(r(t)!==ea)return!0;if(r.definite===!0&&n===void 0)return!1}return ra(e,t,n)});function ra(e,t,n){const r=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},o=e._zod.bag.fallbackRun;let s;if(o?(r[ta]=!0,s=o({value:t,issues:[]},r)):s=e._zod.run({value:t,issues:[]},r),s instanceof Promise)throw new Ce;return s.issues.length===0}const oa=async(e,t,n)=>{const r=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0};let o=e._zod.run({value:t,issues:[]},r);return o instanceof Promise&&(o=await o),o.issues.length===0},sa=e=>{const t=zn(e),n=(r,o,s,i)=>{const a=s?{...s,direction:"backward"}:{direction:"backward"};return t(r,o,a,qt(n,i))};return n},ia=e=>{const t=zn(e),n=(r,o,s,i)=>t(r,o,s,qt(n,i));return n},aa=e=>{const t=Sn(e),n=async(r,o,s,i)=>{const a=s?{...s,direction:"backward"}:{direction:"backward"};return await t(r,o,a,qt(n,i))};return n},ca=e=>{const t=Sn(e),n=async(r,o,s,i)=>await t(r,o,s,qt(n,i));return n},ua=e=>(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return Ut(e)(t,n,o)},la=e=>(t,n,r)=>Ut(e)(t,n,r),da=e=>async(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return Zn(e)(t,n,o)},pa=e=>async(t,n,r)=>Zn(e)(t,n,r),fa=/^[cC][0-9a-z]{6,}$/,ha=/^[0-9a-z]+$/,ma=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,ga=/^[0-9a-vA-V]{20}$/,_a=/^[A-Za-z0-9]{27}$/,va=/^[a-zA-Z0-9_-]{21}$/;function ba(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}const ya=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,wa=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,fr=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,ka=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,$a="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function za(){return new RegExp($a,"u")}const Sa=/^(?:(?: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])$/,Za=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,Ta=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Ia=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Pa=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Ra=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,Ea=/^https?$/,Oa=/^\+[1-9]\d{6,14}$/,zo="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))";function xa(e){return new RegExp(`^${e}$`)}const Ca=xa(zo);function cn(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Na(e){return new RegExp(`^${cn(e)}$`)}function Aa(e){const t=["Z"];e.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const n=`${cn({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,r=e.local?`${n}|${cn({precision:e.precision})}`:n;return new RegExp(`^${zo}T(?:${r})$`)}const ja=/^[\s\S]{0,}$/,Ma=/^-?\d+$/,Tn=/^-?\d+(?:\.\d+)?$/,Da=/^(?:true|false)$/i,qa=/^null$/i,Ua=/^[^A-Z]*$/,La=/^[^a-z]*$/,oe=m("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),In=e=>{const t=e.value;return!bi(t)&&t.length!==void 0},It={number:"number",bigint:"bigint",object:"date"},So=m("$ZodCheckLessThan",(e,t)=>{oe.init(e,t);const n=It[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:It[typeof r.value]??n,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Zo=m("$ZodCheckGreaterThan",(e,t)=>{oe.init(e,t);const n=It[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:It[typeof r.value]??n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Fa=m("$ZodCheckMultipleOf",(e,t)=>{oe.init(e,t),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):yi(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Ha=m("$ZodCheckNumberFormat",(e,t)=>{oe.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),r=n?"int":"number",[o,s]=_o[t.format];e._zod.check=i=>{const a=i.value;if(n){if(!Number.isInteger(a)){i.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){a>0?i.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort}):i.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}a<o&&i.issues.push({origin:"number",input:a,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),a>s&&i.issues.push({origin:"number",input:a,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}}),Ja=m("$ZodCheckMaxLength",(e,t)=>{var n;oe.init(e,t),(n=e._zod.def).when??(n.when=In),e._zod.check=r=>{const o=r.value,s=o.length;if((typeof o=="string"&&s>t.maximum?kn(o):s)<=t.maximum)return;const a=$n(o);r.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Va=m("$ZodCheckMinLength",(e,t)=>{var n;oe.init(e,t),(n=e._zod.def).when??(n.when=In),e._zod.check=r=>{const o=r.value,s=o.length;if((typeof o=="string"&&s>=t.minimum&&s<t.minimum*2?kn(o):s)>=t.minimum)return;const a=$n(o);r.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Ba=m("$ZodCheckLengthEquals",(e,t)=>{var n;oe.init(e,t),(n=e._zod.def).when??(n.when=In),e._zod.check=r=>{const o=r.value,s=o.length,i=typeof o=="string"&&s>=t.length&&s<=t.length*2?kn(o):s;if(i===t.length)return;const a=$n(o),c=i>t.length;r.issues.push({origin:a,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),Lt=m("$ZodCheckStringFormat",(e,t)=>{var n,r;oe.init(e,t),t.pattern?(n=e._zod).check??(n.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),Ka=m("$ZodCheckRegex",(e,t)=>{Lt.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Wa=m("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Ua),Lt.init(e,t)}),Ga=m("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=La),Lt.init(e,t)}),Ya=m("$ZodCheckIncludes",(e,t)=>{oe.init(e,t);const n=qe(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position},}${n}`:n);t.pattern=r,e._zod.check=o=>{o.value.includes(t.includes,t.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),Qa=m("$ZodCheckStartsWith",(e,t)=>{oe.init(e,t);const n=new RegExp(`^${qe(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),Xa=m("$ZodCheckEndsWith",(e,t)=>{oe.init(e,t);const n=new RegExp(`.*${qe(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}}),ec=m("$ZodCheckOverwrite",(e,t)=>{oe.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});let tc=class{constructor(t=[],n={}){this.content=[],this.indent=0,this.args=t,this.closed=n}indented(t){this.indent+=1;try{t(this)}finally{this.indent-=1}}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const r=t.split(`
|
|
2
|
+
`).filter(i=>i),o=Math.min(...r.map(i=>i.length-i.trimStart().length)),s=r.map(i=>i.slice(o)).map(i=>" ".repeat(this.indent*2)+i);for(const i of s)this.content.push(i)}compile(){const t=Function,n=this?.content??[""];return new t(...Object.keys(this.closed),`return function (${this.args.join(", ")}) {
|
|
3
|
+
${n.join(`
|
|
4
|
+
`)}
|
|
5
|
+
};`)(...Object.values(this.closed))}};const nc={major:4,minor:6,patch:7},U=m("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=nc;const r=e._zod.def.checks,o=e._zod.traits.has("$ZodCheck")?[e,...r??[]]:r?.length?[...r]:[];for(const s of o)for(const i of s._zod.onattach)i(e);if(o.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const s=(a,c,u)=>{if(a.memo)return a;let l=be(a),d;for(const p of c){if(p._zod.def.when){if(Ci(a)||!p._zod.def.when(a))continue}else if(l)continue;const h=a.issues.length,_=p._zod.check(a);if(_ instanceof Promise&&u?.async===!1)throw new Ce;if(d||_ instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await _,a.issues.length!==h&&(an(a.issues,h,e),l||(l=be(a,h)))});else{if(a.issues.length===h)continue;an(a.issues,h,e),l||(l=be(a,h))}}return d?d.then(()=>a):a},i=(a,c,u)=>{if(be(a))return a.aborted=!0,a;const l=s(c,o,u);if(l instanceof Promise){if(u.async===!1)throw new Ce;return l.then(d=>e._zod.parse(d,u))}return e._zod.parse(l,u)};e._zod.run=(a,c)=>{if(c.skipChecks)return e._zod.parse(a,c);if(c.direction==="backward"){const l=e._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});return l instanceof Promise?l.then(d=>i(d,a,c)):i(l,a,c)}const u=e._zod.parse(a,c);if(u instanceof Promise){if(c.async===!1)throw new Ce;return u.then(l=>s(l,o,c))}return s(u,o,c)}}},{get"~standard"(){return bo(this,"~standard",Io(this))},set"~standard"(e){Ze(this,"~standard",e)}}),To=(e,t)=>e.issues.length?{issues:e.issues.map(n=>Se(n,t,ve()))}:{value:e.value};async function rc(e,t){const n={async:!0};return To(await e._zod.run({value:t,issues:[]},n),n)}function Io(e){return{validate:t=>{const n={async:!1};try{const r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return To(r,n)}catch{}return rc(e,t)},vendor:"zod",version:1}}const Pn=m("$ZodString",(e,t)=>{U.init(e,t),e._zod.pattern=t.pattern??ja,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),L=m("$ZodStringFormat",(e,t)=>{Lt.init(e,t),Pn.init(e,t)}),oc=m("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=wa),L.init(e,t)}),sc=m("$ZodUUID",(e,t)=>{if(t.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=fr(r))}else t.pattern??(t.pattern=fr());L.init(e,t)}),ic=m("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=ka),L.init(e,t)}),Po=1,Pt=2;function Ro(e){try{return typeof URL<"u"&&typeof URL.canParse=="function"?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function ac(e,t){return!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t)?Ro(e)||Pt:cc(e,t)}function cc(e,t){if(!t.normalize&&t.protocol?.source===Ea.source&&!/^https?:\/\//i.test(e))return Po;try{if(typeof URL<"u"){const n=URL;if(typeof n.parse=="function")return n.parse(e)??Pt}return new URL(e)}catch{return Pt}}const uc=/[\t\n\r]/g;function hr(e){return e.replace(uc,"")}function lc(e,t){return t.lastIndex=0,t.test(e.hostname)}function dc(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}const pc=m("$ZodURL",(e,t)=>{L.init(e,t),e._zod.check=n=>{try{const r=n.value.trim(),o=ac(r,t);if(o===Po){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}if(o===Pt){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort});return}if(o===!0){n.value=hr(r);return}t.hostname&&!lc(o,t.hostname)&&n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort}),t.protocol&&!dc(o,t.protocol)&&n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort}),n.value=t.normalize?o.href:hr(r);return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),fc=m("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=za()),L.init(e,t)}),hc=m("$ZodNanoID",(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw new Error(`Invalid nanoid length: ${t.length}`);t.pattern??(t.pattern=t.length===void 0?va:ba(t.length)),L.init(e,t)}),mc=m("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=fa),L.init(e,t)}),gc=m("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=ha),L.init(e,t)}),_c=m("$ZodULID",(e,t)=>{t.pattern??(t.pattern=ma),L.init(e,t)}),vc=m("$ZodXID",(e,t)=>{t.pattern??(t.pattern=ga),L.init(e,t)}),bc=m("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=_a),L.init(e,t)}),yc=m("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Aa(t)),L.init(e,t)}),wc=m("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Ca),L.init(e,t)}),kc=m("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Na(t)),L.init(e,t)}),$c=m("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=ya),L.init(e,t)}),zc=m("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Sa),L.init(e,t)}),Sc=/^[0-9a-fA-F:.]+$/;function Eo(e){return Sc.test(e)?Ro(`http://[${e}]`):!1}const Zc=m("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Za),L.init(e,t),e._zod.check=n=>{Eo(n.value)||n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}),Tc=m("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Ta),L.init(e,t)});function Ic(e){const t=e.split("/");if(t.length!==2)return!1;const[n,r]=t;if(!r)return!1;const o=Number(r);return`${o}`!==r||o<0||o>128?!1:Eo(n)}const Pc=m("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Ia),L.init(e,t),e._zod.check=n=>{Ic(n.value)||n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}});function Oo(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const xo=/^[0-9a-zA-Z+/]*={0,2}$/,Rc=m("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=xo),L.init(e,t),e._zod.check=n=>{Oo(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}}),Rn=/^[A-Za-z0-9_-]*$/;function Ec(e){if(!Rn.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return Oo(n)}const Oc=m("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Rn),L.init(e,t),e._zod.check=n=>{Ec(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),xc=m("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Oa),L.init(e,t)});function Cc(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[r]=n;if(!r)return!1;const o=JSON.parse(atob(r));return!("typ"in o&&o?.typ!=="JWT"||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}}const Nc=m("$ZodJWT",(e,t)=>{L.init(e,t),e._zod.check=n=>{Cc(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),Co=m("$ZodNumber",(e,t)=>{U.init(e,t),e._zod.pattern=Tn,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const o=n.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return n;const s=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:String(o):void 0;return n.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...s?{received:s}:{}}),n}}),Ac=m("$ZodNumberFormat",(e,t)=>{Ha.init(e,t),Co.init(e,t)}),jc=m("$ZodBoolean",(e,t)=>{U.init(e,t),e._zod.pattern=Da,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}const o=n.value;return typeof o=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),n}}),Mc=m("$ZodNull",(e,t)=>{U.init(e,t),e._zod.pattern=qa,e._zod.values=new Set([null]),e._zod.parse=(n,r)=>{const o=n.value;return o===null||n.issues.push({expected:"null",code:"invalid_type",input:o,inst:e}),n}}),Dc=m("$ZodUnknown",(e,t)=>{U.init(e,t),e._zod.parse=n=>n}),qc=m("$ZodNever",(e,t)=>{U.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function Uc(e,t){const n=ur(e._zod.def.checks);if(!n.length)return;const r=Math.min(...n.map(s=>s[0])),o=e._zod.parse;e._zod.parse=(s,i)=>{const a=t(s.value);if(a>r&&!i?.skipChecks&&i?.direction!=="backward"){for(const[c,u]of ur(e._zod.def.checks))if(a>c&&u._zod.def.when(s)){const l=s.issues.length;return u._zod.check(s),s.issues[l].continue=!1,an(s.issues,l,e),s}}return o(s,i)}}const Lc=e=>Array.isArray(e)?e.length:-1;function mr(e,t,n){e.issues.length&&t.issues.push(...Me(n,e.issues)),t.value[n]=e.value}const Fc=m("$ZodArray",(e,t)=>{U.init(e,t);const n=ge.memoizer;n?.attach(e),e._zod.parse=(r,o)=>{const s=r.value;if(!Array.isArray(s))return r.issues.push({expected:"array",code:"invalid_type",input:s,inst:e}),r;r.value=n?n.alloc(e,r,Array(s.length),o):Array(s.length);const i=[],a=o?.abortEarly;for(let c=0;c<s.length;c++){const u=s[c],l=t.element._zod.run({value:u,issues:[]},o);if(l instanceof Promise)i.push(l.then(d=>mr(d,r,c)));else if(mr(l,r,c),a&&l.issues.length!==0&&be(l))break}return i.length?Promise.all(i).then(()=>r):r},Uc(e,Lc)});function Rt(e,t,n,r,o,s){const i=n in r,a=s==="optional";if(!(!i&&a&&o==="optional")){if(e.issues.length){if(o!==void 0&&a&&!i)return;t.issues.push(...Me(n,e.issues))}if(!i&&o===void 0){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}e.value===void 0?(i||o==="defaulted"&&!a)&&(t.value[n]=void 0):t.value[n]=e.value}}const Hc=[];function No(e){const t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:Hc,o=r.length?[...t,...r]:t;for(const i of o)if(!e.shape?.[i]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${String(i)}": expected a Zod schema`);const s=Zi(e.shape);return{...e,allKeys:o,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(s)}}function Ao(e,t,n,r,o,s,i){const a=[],c=o.keySet,u=o.catchall._zod,l=u.def.type,d=u.optin,p=u.optout;let h=0;for(const _ in t){if(i&&n.issues.length!==h){if(be(n,h))break;h=n.issues.length}if(c.has(_))continue;if(_==="__proto__"){l==="never"&&a.push(_);continue}if(l==="never"){a.push(_);continue}const w=u.run({value:t[_],issues:[]},r);w instanceof Promise?e.push(w.then(S=>Rt(S,n,_,t,d,p))):Rt(w,n,_,t,d,p)}return a.length&&n.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:s,continue:!0}),e.length?Promise.all(e).then(()=>n):n}const Jc=m("$ZodObject",(e,t)=>{U.init(e,t);const n=Object.getOwnPropertyDescriptor(t,"shape"),r=n?.get?n.get.raw:t.shape??{};if(r){const u=()=>{const l={...r};return Object.defineProperty(t,"shape",{value:l}),u.raw=l,l};u.raw=r,Object.defineProperty(t,"shape",{get:u})}const o=Mt(()=>No(t));E(e,"propValues",u=>{const l=u.def.shape,d={};for(const p in l){const h=l[p]._zod;if(h.values){Object.prototype.hasOwnProperty.call(d,p)||$e(d,p,new Set);for(const _ of h.values)d[p].add(_);h.optin!==void 0&&d[p].add(void 0)}}return d});const s=et,i=t.catchall;let a;const c=ge.memoizer;c?.attach(e),e._zod.parse=(u,l)=>{a??(a=o.value);const d=u.value;if(!s(d))return u.issues.push({expected:"object",code:"invalid_type",input:d,inst:e}),u;u.value=c?c.alloc(e,u,{},l):{};const p=[],h=a.shape,_=l?.abortEarly;let w=u.issues.length;for(const S of a.allKeys){if(_&&u.issues.length!==w){if(be(u,w))break;w=u.issues.length}if(S==="__proto__")continue;const I=h[S],Z=I._zod.optin,T=I._zod.optout,O=I._zod.run({value:d[S],issues:[]},l);O instanceof Promise?p.push(O.then(M=>Rt(M,u,S,d,Z,T))):Rt(O,u,S,d,Z,T)}return i?Ao(p,d,u,l,o.value,e,_===!0):p.length?Promise.all(p).then(()=>u):u}}),Vc=m("$ZodObjectJIT",(e,t)=>{Jc.init(e,t);const n=e._zod.parse,r=Mt(()=>No(t)),o=ge.memoizer,s=h=>{const _=r.value,w=_.symbolKeys,S=new tc(["payload","ctx"],{shape:h,inst:e,memo:o,syms:w}),I=M=>`shape[${M}]._zod.run({ value: input[${M}], issues: [] }, ctx)`,Z=(M,x)=>`
|
|
6
|
+
let ${M}_ab = false;
|
|
7
|
+
for (let i = 0; i < ${M}.issues.length; i++) {
|
|
8
|
+
const iss = ${M}.issues[i];
|
|
9
|
+
iss.path = iss.path ? [${x}, ...iss.path] : [${x}];
|
|
10
|
+
payload.issues.push(iss);
|
|
11
|
+
if (iss.continue !== true) ${M}_ab = true;
|
|
12
|
+
}
|
|
13
|
+
if (${M}_ab && ctx && ctx.abortEarly) {
|
|
14
|
+
payload.value = newResult;
|
|
15
|
+
return payload;
|
|
16
|
+
}`;S.write("const input = payload.value;");const T=Object.create(null);let O=0;for(const M of _.allKeys)T[M]=`key_${O++}`;S.write(o?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(const M of _.allKeys){if(M==="__proto__")continue;const x=T[M],ie=typeof M=="symbol"?`syms[${w.indexOf(M)}]`:ki(M),je=`${ie} in input`,sr=h[M],Wt=sr?._zod?.optin,ir=Wt!==void 0,gi=sr?._zod?.optout==="optional";if(S.write(`const ${x} = ${I(ie)};`),ir&&gi){const _i=Wt==="optional"?`${x}_present`:`${x}.value !== undefined || ${x}_present`;S.write(`
|
|
17
|
+
const ${x}_present = ${je};
|
|
18
|
+
if (!${x}.issues.length || ${x}_present) {
|
|
19
|
+
if (${x}.issues.length) {${Z(x,ie)}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (${_i}) {
|
|
23
|
+
newResult[${ie}] = ${x}.value;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
`)}else ir?(S.write(`
|
|
28
|
+
if (${x}.issues.length) {${Z(x,ie)}
|
|
29
|
+
}
|
|
30
|
+
`),Wt==="defaulted"?S.write(`newResult[${ie}] = ${x}.value;`):S.write(`
|
|
31
|
+
if (${x}.value !== undefined || ${je}) {
|
|
32
|
+
newResult[${ie}] = ${x}.value;
|
|
33
|
+
}
|
|
34
|
+
`)):S.write(`
|
|
35
|
+
const ${x}_present = ${je};
|
|
36
|
+
if (${x}.issues.length) {${Z(x,ie)}
|
|
37
|
+
}
|
|
38
|
+
if (!${x}_present && !${x}.issues.length) {
|
|
39
|
+
payload.issues.push({
|
|
40
|
+
code: "invalid_type",
|
|
41
|
+
expected: "nonoptional",
|
|
42
|
+
input: undefined,
|
|
43
|
+
path: [${ie}]
|
|
44
|
+
});
|
|
45
|
+
if (ctx && ctx.abortEarly) {
|
|
46
|
+
payload.value = newResult;
|
|
47
|
+
return payload;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (${x}_present) {
|
|
52
|
+
newResult[${ie}] = ${x}.value;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
`)}return S.write("payload.value = newResult;"),S.write("return payload;"),S.compile()};let i;const a=et,c=!ge.jitless,l=c&&zi.value,d=t.catchall;let p;e._zod.parse=(h,_)=>{p??(p=r.value);const w=h.value;return a(w)?c&&l&&_?.async===!1&&_.jitless!==!0?(i||(i=s(t.shape)),h=i(h,_),d?Ao([],w,h,_,p,e,_?.abortEarly===!0):h):n(h,_):(h.issues.push({expected:"object",code:"invalid_type",input:w,inst:e}),h)}});function gr(e,t,n,r){for(const s of e)if(s.issues.length===0)return t.value=s.value,t;const o=e.filter(s=>!be(s));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(s=>s.issues.map(i=>Se(i,r,ve())))}),t)}const jo=m("$ZodUnion",(e,t)=>{U.init(e,t),E(e,"optin",r=>r.def.options.some(o=>o._zod.optin==="defaulted")?"defaulted":r.def.options.some(o=>o._zod.optin!==void 0)?"optional":void 0),E(e,"optout",r=>r.def.options.some(o=>o._zod.optout==="optional")?"optional":void 0),E(e,"values",r=>{if(r.def.options.every(o=>o._zod.values))return new Set(r.def.options.flatMap(o=>Array.from(o._zod.values)))}),E(e,"pattern",r=>{if(r.def.options.every(o=>o._zod.pattern)){const o=r.def.options.map(s=>s._zod.pattern);return new RegExp(`^(${o.map(s=>yn(s.source)).join("|")})$`)}});const n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,o)=>{if(n)return n(r,o);let s=!1;const i=[];for(const a of t.options){const c=a._zod.run({value:r.value,issues:[]},o);if(c instanceof Promise)i.push(c),s=!0;else{if(c.issues.length===0)return c;i.push(c)}}return s?Promise.all(i).then(a=>gr(a,r,e,o)):gr(i,r,e,o)}});function Bc(e){const t=new Map;for(const n of e.options){const r=n._zod.propValues?.[e.discriminator];if(!r||r.size===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(n)}"`);for(const o of r)if(t.has(o)){if(o!==void 0)throw new Error(`Duplicate discriminator value "${String(o)}"`);t.set(o,null)}else t.set(o,n)}return t}const Kc=m("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,jo.init(e,t);const n=e._zod.parse;E(e,"propValues",o=>{const s={};let i=0;for(const a of o.def.options){const c=a._zod.propValues;if(!c||Object.keys(c).length===0)throw new Error(`Invalid discriminated union option at index "${o.def.options.indexOf(a)}"`);c[o.def.discriminator]?.has(void 0)&&i++;for(const[u,l]of Object.entries(c)){Object.prototype.hasOwnProperty.call(s,u)||$e(s,u,new Set);for(const d of l)s[u].add(d)}}return!o.def.unionFallback&&i>1&&s[o.def.discriminator]?.delete(void 0),s}),t.options.forEach((o,s)=>{const i=wn(o._zod.def);if(i&&!Object.prototype.hasOwnProperty.call(i,t.discriminator))throw new Error(`Invalid discriminated union option at index "${s}"`)});const r=Mt(()=>Bc(t));e._zod.parse=(o,s)=>{const i=o.value;if(!et(i))return o.issues.push({code:"invalid_type",expected:"object",input:i,inst:e}),o;const a=i?.[t.discriminator],c=r.value.get(a);return c&&(a!==void 0||s.direction!=="backward")?c._zod.run(o,s):t.unionFallback||s.direction==="backward"?n(o,s):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(r.value.keys()).filter(u=>r.value.get(u)!==null),input:i,path:[t.discriminator],inst:e}),o)}}),Wc=m("$ZodIntersection",(e,t)=>{U.init(e,t),e._zod.parse=(n,r)=>{const o=n.value,s=t.left._zod.run({value:o,issues:[]},r),i=t.right._zod.run({value:o,issues:[]},r);return s instanceof Promise||i instanceof Promise?Promise.all([s,i]).then(([c,u])=>_r(n,c,u)):_r(n,s,i)}});function un(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(De(e)&&De(t)){const n=Object.keys(t),r=Object.keys(e).filter(s=>n.indexOf(s)!==-1),o={...e,...t};Object.prototype.hasOwnProperty.call(o,"__proto__")&&delete o.__proto__;for(const s of r){if(s==="__proto__")continue;const i=un(e[s],t[s]);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};o[s]=i.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<e.length;r++){const o=e[r],s=t[r],i=un(o,s);if(!i.valid)return{valid:!1,mergeErrorPath:[r,...i.mergeErrorPath]};n.push(i.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function _r(e,t,n){const r=new Map;let o;const s=new Map,i=(u,l)=>{let d;if(u.code==="unrecognized_keys"&&!u.path?.length)o??(o=u),d=u.keys;else if(u.code==="invalid_key"&&u.origin==="record"&&u.path?.length===1){const p=String(u.path[0]);s.has(p)||s.set(p,u),d=[p]}else return!1;for(const p of d)r.has(p)||r.set(p,{}),r.get(p)[l]=!0;return!0};for(const u of t.issues)i(u,"l")||e.issues.push(u);for(const u of n.issues)i(u,"r")||e.issues.push(u);const a=[...r].filter(([,u])=>u.l&&u.r).map(([u])=>u);if(a.length){const u=o?a.filter(l=>o.keys.includes(l)):[];u.length&&e.issues.push({...o,keys:u});for(const l of a)!u.includes(l)&&s.has(l)&&e.issues.push(s.get(l))}const c=un(t.value,n.value);if(!c.valid){if(be(e))return e;throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}const Gc=m("$ZodRecord",(e,t)=>{U.init(e,t);const n=ge.memoizer;n?.attach(e),e._zod.parse=(r,o)=>{const s=r.value;if(!De(s))return r.issues.push({expected:"record",code:"invalid_type",input:s,inst:e}),r;const i=[],a=t.keyType._zod.values;if(a&&!t.partial){r.value=n?n.alloc(e,r,{},o):{};const c=new Set;for(const l of a)if(typeof l=="string"||typeof l=="number"||typeof l=="symbol"){if(c.add(typeof l=="number"?l.toString():l),l==="__proto__")continue;const d=t.keyType._zod.run({value:l,issues:[]},o);if(d instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(d.issues.length){r.issues.push({code:"invalid_key",origin:"record",issues:d.issues.map(_=>Se(_,o,ve())),input:l,path:[l],inst:e});continue}const p=d.value;if(p==="__proto__")continue;const h=t.valueType._zod.run({value:s[l],issues:[]},o);h instanceof Promise?i.push(h.then(_=>{_.issues.length&&r.issues.push(...Me(l,_.issues)),r.value[p]=_.value})):(h.issues.length&&r.issues.push(...Me(l,h.issues)),r.value[p]=h.value)}let u;for(const l in s)if(!c.has(l))if(t.mode==="loose"){if(l==="__proto__")continue;r.value[l]=s[l]}else u=u??[],u.push(l);u&&u.length>0&&r.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:u,continue:!0})}else{r.value=n?n.alloc(e,r,{},o):{};let c;for(const u of Reflect.ownKeys(s)){if(u==="__proto__"||!Object.prototype.propertyIsEnumerable.call(s,u))continue;let l=t.keyType._zod.run({value:u,issues:[]},o);if(l instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof u=="string"&&Tn.test(u)&&l.issues.length){const _=t.keyType._zod.run({value:Number(u),issues:[]},o);if(_ instanceof Promise)throw new Error("Async schemas not supported in object keys currently");_.issues.length===0&&(l=_)}if(l.issues.length){t.mode==="loose"?r.value[u]=s[u]:a?(c=c??[],c.push(u)):r.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map(_=>Se(_,o,ve())),input:u,path:[u],inst:e});continue}const p=l.value;if(p==="__proto__")continue;const h=t.valueType._zod.run({value:s[u],issues:[]},o);h instanceof Promise?i.push(h.then(_=>{_.issues.length&&r.issues.push(...Me(u,_.issues)),r.value[p]=_.value})):(h.issues.length&&r.issues.push(...Me(u,h.issues)),r.value[p]=h.value)}c&&c.length>0&&r.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:c,continue:!0})}return i.length?Promise.all(i).then(()=>r):r}}),Yc=m("$ZodEnum",(e,t)=>{U.init(e,t);const n=on(t.entries),r=new Set(n);e._zod.values=r,E(e,"pattern",o=>{const s=on(o.def.entries).filter(i=>Si.has(typeof i));return new RegExp(s.length?`^(${s.map(i=>qe(i.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(o,s)=>{const i=o.value;return r.has(i)||o.issues.push({code:"invalid_value",values:n,input:i,inst:e}),o}}),Qc=m("$ZodLiteral",(e,t)=>{U.init(e,t);const n=new Set(t.values);e._zod.values=n,E(e,"pattern",r=>{const o=r.def.values;return new RegExp(o.length?`^(${o.map(s=>typeof s=="string"?qe(s):s?qe(s.toString()):String(s)).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(r,o)=>{const s=r.value;return n.has(s)||r.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),r}}),Xc=m("$ZodTransform",(e,t)=>{U.init(e,t),e._zod.optin="optional",ge.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new wo(e.constructor.name);const o=t.transform(n.value,n);if(r.async)return(o instanceof Promise?o:Promise.resolve(o)).then(i=>(n.value=i,n));if(o instanceof Promise)throw new Ce;return n.value=o,n}});function vr(e,t){return e.value=t.issues.length?void 0:t.value,e}const Mo=m("$ZodOptional",(e,t)=>{U.init(e,t),E(e,"optin",n=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",E(e,"values",n=>{const r=n.def.innerType._zod.values;return r?new Set([...r,void 0]):void 0}),E(e,"pattern",n=>{const r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${yn(r.source)})?$`):void 0}),e._zod.parse=(n,r)=>{if(n.value===void 0){if(t.innerType._zod.optin!=="defaulted")return n;const o=t.innerType._zod.run({value:n.value,issues:[]},r);return o instanceof Promise?o.then(s=>vr(n,s)):vr(n,o)}return t.innerType._zod.run(n,r)}}),eu=m("$ZodExactOptional",(e,t)=>{Mo.init(e,t),E(e,"values",n=>n.def.innerType._zod.values),E(e,"pattern",n=>n.def.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),tu=m("$ZodNullable",(e,t)=>{U.init(e,t),E(e,"optin",n=>n.def.innerType._zod.optin),E(e,"optout",n=>n.def.innerType._zod.optout),E(e,"pattern",n=>{const r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${yn(r.source)}|null)$`):void 0}),E(e,"values",n=>n.def.innerType._zod.values?new Set([...n.def.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>n.value===null?n:t.innerType._zod.run(n,r)}),nu=m("$ZodDefault",(e,t)=>{U.init(e,t),e._zod.optin="defaulted",E(e,"values",n=>n.def.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);if(n.value===void 0)return n.value=t.defaultValue,n;const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(s=>br(s,t)):br(o,t)}});function br(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const ru=m("$ZodPrefault",(e,t)=>{U.init(e,t),e._zod.optin="defaulted",E(e,"values",n=>n.def.innerType._zod.values),e._zod.parse=(n,r)=>(r.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,r))}),ou=m("$ZodNonOptional",(e,t)=>{U.init(e,t),E(e,"values",n=>{const r=n.def.innerType._zod.values;return r?new Set([...r].filter(o=>o!==void 0)):void 0}),e._zod.parse=(n,r)=>{const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(s=>yr(s,e)):yr(o,e)}});function yr(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}function wr(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(o=>Se(o,r,ve()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}const su=m("$ZodCatch",(e,t)=>{U.init(e,t),E(e,"optin",n=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),E(e,"optout",n=>n.def.innerType._zod.optout),E(e,"values",n=>n.def.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const o=t.innerType._zod.run({value:n.value,issues:[]},r);return o instanceof Promise?o.then(s=>wr(n,s,t,r)):wr(n,o,t,r)}}),Do=m("$ZodPipe",(e,t)=>{U.init(e,t),E(e,"values",n=>n.def.in._zod.values),E(e,"optin",n=>n.def.in._zod.optin),E(e,"optout",n=>n.def.out._zod.optout),E(e,"propValues",n=>n.def.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction==="backward"){const s=t.out._zod.run(n,r);return s instanceof Promise?s.then(i=>gt(i,t.in,r)):gt(s,t.in,r)}const o=t.in._zod.run(n,r);return o instanceof Promise?o.then(s=>gt(s,t.out,r)):gt(o,t.out,r)}});function gt(e,t,n){return e.issues.some(r=>r.code!=="unrecognized_keys")?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const iu=m("$ZodPreprocess",(e,t)=>{Do.init(e,t)}),au=m("$ZodReadonly",(e,t)=>{U.init(e,t),E(e,"propValues",n=>n.def.innerType._zod.propValues),E(e,"values",n=>n.def.innerType._zod.values),E(e,"optin",n=>n.def.innerType?._zod?.optin),E(e,"optout",n=>n.def.innerType?._zod?.optout),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(kr):kr(o)}});function kr(e){return e.memo||(e.value=Object.freeze(e.value)),e}const cu=m("$ZodCustom",(e,t)=>{oe.init(e,t),U.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=n=>{const r=n.value,o=t.fn(r);if(o instanceof Promise)return o.then(s=>$r(s,n,r,e));$r(o,n,r,e)}});function $r(e,t,n,r){if(!e){const o={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(o.params=r._zod.def.params),t.issues.push(tt(o))}}class uu extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform"),this.name="ZodCyclicError"}}const ln="~memo",zr=[];function qo(e){return e!==null&&typeof e=="object"}function Xt(e){return e.map(t=>t.path?{...t,path:t.path.slice()}:{...t})}const Uo=new WeakMap,We=0,Zt=1,Ye=2;function Tt(e,t,n){const r=Uo.get(e);if(r!==void 0)return r?Ye:We;if(t.has(e))return Ye;t.add(e);let o=We;const s=l=>{if(o!==Ye&&l?._zod){const d=Tt(l,t);d>o&&(o=d)}},i=(l,d)=>{let p=We;for(const h of Reflect.ownKeys(l)){const _=Object.getOwnPropertyDescriptor(l,h);if(!_.enumerable)continue;const w=_.get?Zt:_.value?._zod?Tt(_.value,t):We;w>p&&(p=w)}return p},a=l=>{l>o&&(o=l)},c=e._zod.def;switch(c.type){case"object":{const l=wn(c);a(l?i(l):Zt),s(c.catchall);break}case"array":s(c.element);break;case"tuple":for(const l of c.items)s(l);s(c.rest);break;case"record":case"map":s(c.keyType),s(c.valueType);break;case"set":s(c.valueType);break;case"union":for(const l of c.options)s(l);break;case"intersection":s(c.left),s(c.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":s(c.innerType);break;case"pipe":s(c.in),s(c.out);break;case"function":s(c.input),s(c.output);break;case"lazy":{const l=c._cachedInner??void 0;a(l?Tt(l,t):Zt);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(const l in c){const d=Object.getOwnPropertyDescriptor(c,l);if(!d||d.get)continue;const p=d.value;if(!(!p||typeof p!="object")){if(p._zod)s(p);else if(Array.isArray(p))for(const h of p)s(h)}}}return t.delete(e),lu(e,o)}function lu(e,t){return t!==Zt&&Uo.set(e,t===Ye),t}function du(e,t){let n=e.buckets.get(t);return n||(n=new WeakMap,e.buckets.set(t,n)),n}let _t;const vt=[],pu={alloc(e,t,n){const r=_t;if(!r)return n;_t=void 0;const o={value:n,issues:null};return r.set(t.value,o),vt.push(o),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{const n=e._zod.parse,r=(o,s)=>{if(s.direction!=="backward"&&hu(s,o.value))throw new uu;return n(o,s)};e._zod.parse=r,e._zod.run===n&&(e._zod.run=r)})},attach(e){var t;let n,r=!1,o,s;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{const i=e._zod.parse,a=(c,u)=>{if(n===void 0){const I=Tt(e,new Set);if(I===We)return e._zod.parse=i,e._zod.run===a&&(e._zod.run=i),i(c,u);I===Ye||r?n=!0:r=!0}const l=c.value;if(!qo(l))return i(c,u);let d=u[ln];d||(d={buckets:new WeakMap,backEdges:void 0},u[ln]=d);let p;o===u?p=s:(p=du(d,e),o=u,s=p);const h=p.get(l);if(h)return c.value=h.value,h.issues?h.issues.length&&c.issues.push(...Xt(h.issues)):(c.memo=!0,d.backEdges??(d.backEdges=new WeakSet),d.backEdges.add(h.value)),c;_t=p;const _=vt.length,w=i(c,u);_t=void 0;const S=vt.length>_?vt.pop():void 0;return w instanceof Promise?w.then(I=>(S&&(S.issues=I.issues.length?Xt(I.issues):zr),I)):(S&&(S.issues=w.issues.length?Xt(w.issues):zr),w)};e._zod.parse=a,e._zod.run===i&&(e._zod.run=a)})}};function fu(){return pu}function hu(e,t){const n=e[ln]?.backEdges;return n!==void 0&&qo(t)&&n.has(t)}const mu=()=>{const e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function t(s){return e[s]??null}const n={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},r={nan:"NaN"};function o(s,i){return s==="number"&&typeof i=="number"&&!Number.isFinite(i)?String(i):r[s]??s}return s=>{switch(s.code){case"invalid_type":{const i=o(s.expected),a=Ai(s.input),c=o(a,s.input);return`Invalid input: expected ${i}, received ${c}`}case"invalid_value":return s.values.length===1?`Invalid input: expected ${go(s.values[0])}`:`Invalid option: expected one of ${ar(s.values,"|")}`;case"too_big":{const i=s.exact?"exactly ":s.inclusive?"<=":"<",a=t(s.origin);return a?`Too big: expected ${s.origin??"value"} to have ${i}${s.maximum.toString()} ${a.unit??"elements"}`:`Too big: expected ${s.origin??"value"} to be ${i}${s.maximum.toString()}`}case"too_small":{const i=s.exact?"exactly ":s.inclusive?">=":">",a=t(s.origin);return a?`Too small: expected ${s.origin} to have ${i}${s.minimum.toString()} ${a.unit}`:`Too small: expected ${s.origin} to be ${i}${s.minimum.toString()}`}case"invalid_format":{const i=s;return i.format==="starts_with"?`Invalid string: must start with "${i.prefix}"`:i.format==="ends_with"?`Invalid string: must end with "${i.suffix}"`:i.format==="includes"?`Invalid string: must include "${i.includes}"`:i.format==="regex"?`Invalid string: must match pattern ${i.pattern}`:`Invalid ${n[i.format]??s.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${s.divisor}`;case"unrecognized_keys":return`Unrecognized key${s.keys.length>1?"s":""}: ${ar(s.keys,", ")}`;case"invalid_key":return`Invalid key in ${s.origin}`;case"invalid_union":return s.options&&Array.isArray(s.options)&&s.options.length>0?`Invalid discriminator value. Expected ${s.options.map(a=>`'${a}'`).join(" | ")}`:s.inclusive===!1?"Invalid input: more than one option matched":"Invalid input";case"invalid_element":return`Invalid value in ${s.origin}`;default:return"Invalid input"}}};function gu(){return{localeError:mu()}}var Sr;let _u=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const r=n[0];return this._map.set(t,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const r={...this.get(n)??{}};delete r.id;const o={...r,...this._map.get(t)};return Object.keys(o).length?o:void 0}return this._map.get(t)}has(t){return this._map.has(t)}};function vu(){return new _u}(Sr=globalThis).__zod_globalRegistry??(Sr.__zod_globalRegistry=vu());const Ge=globalThis.__zod_globalRegistry;function Lo(e){return e.checks&&(e.checks=[...e.checks]),e}function bu(e,t){return new e(Lo({type:"string",...k(t)}))}function yu(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...k(t)})}function wu(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...k(t)})}function ku(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...k(t)})}function $u(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...k(t)})}function zu(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...k(t)})}function Su(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...k(t)})}function Zu(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...k(t)})}function Tu(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...k(t)})}function Iu(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...k(t)})}function Pu(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...k(t)})}function Ru(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...k(t)})}function Eu(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...k(t)})}function Ou(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...k(t)})}function xu(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...k(t)})}function Cu(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...k(t)})}function Nu(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...k(t)})}function Au(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...k(t)})}function ju(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...k(t)})}function Mu(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...k(t)})}function Du(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...k(t)})}function qu(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...k(t)})}function Uu(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...k(t)})}function Fo(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...k(t)})}function Lu(e,t){return new e({type:"string",format:"date",check:"string_format",...k(t)})}function Fu(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...k(t)})}function Hu(e,t){return new e({type:"string",format:"duration",check:"string_format",...k(t)})}function Ju(e,t){return new e(Lo({type:"number",checks:[],...k(t)}))}function Vu(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...k(t)})}function Bu(e,t){return new e({type:"boolean",...k(t)})}function Ku(e,t){return new e({type:"null",...k(t)})}function Wu(e){return new e({type:"unknown"})}function Gu(e,t){return new e({type:"never",...k(t)})}function Zr(e,t){return new So({check:"less_than",...k(t),value:e,inclusive:!1})}function en(e,t){return new So({check:"less_than",...k(t),value:e,inclusive:!0})}function Tr(e,t){return new Zo({check:"greater_than",...k(t),value:e,inclusive:!1})}function tn(e,t){return new Zo({check:"greater_than",...k(t),value:e,inclusive:!0})}function Ir(e,t){return new Fa({check:"multiple_of",...k(t),value:e})}function Ho(e,t){return new Ja({check:"max_length",...k(t),maximum:e})}function Et(e,t){return new Va({check:"min_length",...k(t),minimum:e})}function Jo(e,t){return new Ba({check:"length_equals",...k(t),length:e})}function Yu(e,t){return new Ka({check:"string_format",format:"regex",...k(t),pattern:e})}function Qu(e){return new Wa({check:"string_format",format:"lowercase",...k(e)})}function Xu(e){return new Ga({check:"string_format",format:"uppercase",...k(e)})}function el(e,t){return new Ya({check:"string_format",format:"includes",...k(t),includes:e})}function tl(e,t){return new Qa({check:"string_format",format:"starts_with",...k(t),prefix:e})}function nl(e,t){return new Xa({check:"string_format",format:"ends_with",...k(t),suffix:e})}function Je(e){return new ec({check:"overwrite",tx:e})}function rl(e){return Je(t=>t.normalize(e))}function ol(){return Je(e=>e.trim())}function sl(){return Je(e=>e.toLowerCase())}function il(){return Je(e=>e.toUpperCase())}function al(){return Je(e=>$i(e))}function cl(e,t,n){return new e({type:"array",element:t,...k(n)})}function ul(e,t,n){const r=k(n);return r.abort??(r.abort=!0),new e({type:"custom",check:"custom",fn:t,...r})}function ll(e,t,n){return new e({type:"custom",check:"custom",fn:t,...k(n)})}function dl(e,t){const n=pl(r=>(r.addIssue=o=>{if(typeof o=="string")r.issues.push(tt(o,r.value,n._zod.def));else{const s=o;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),"input"in s||(s.input=r.value),s.inst??(s.inst=n),s.continue??(s.continue=!n._zod.def.abort),r.issues.push(tt(s))}},e(r.value,r)),t);return n}function pl(e,t){const n=new oe({check:"custom",...k(t)});return n._zod.check=e,n}function Qe(e,...t){for(const n of t)for(const r of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,r)&&$e(e,r,n[r]);return e}function Vo(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??Ge,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??"ref",reused:e?.reused??"inline",intersections:[],deferred:[],external:e?.external??void 0}}function Te(e,t,n,r,o){const s=typeof t.unrepresentable=="function"?t.unrepresentable({zodSchema:e,path:r.path,message:o}):t.unrepresentable;if(s==="any")return!1;if(s===void 0||s==="throw")throw new Error(o);return Object.assign(n,s),!0}function Y(e,t,n={path:[],schemaPath:[]}){var r;const o=e._zod.def,s=t.seen.get(e);if(s)return s.count++,n.schemaPath.includes(e)&&(s.cycle=n.path),s.schema;const i={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,i),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;const a=e._zod.toJSONSchema?.();if(a)i.schema=a;else{const l={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,i.schema,l);else{const p=i.schema,h=t.processors[o.type];if(!h)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);h(e,t,p,l)}const d=e._zod.parent;d&&(i.ref||(i.ref=d),Y(d,t,l),t.seen.get(d).isParent=!0)}const c=t.metadataRegistry.get(e);return c&&Qe(i.schema,c),t.io==="input"&&ne(e)&&(delete i.schema.examples,delete i.schema.default),t.io==="input"&&"_prefault"in i.schema&&((r=i.schema).default??(r.default=i.schema._prefault)),delete i.schema._prefault,t.seen.get(e).schema}function Pr(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function Bo(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;const r=new Map;for(const i of e.seen.entries()){const a=e.metadataRegistry.get(i[0])?.id;if(a){const c=r.get(a);if(c&&c!==i[0])throw new Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(a,i[0])}}const o=i=>{const a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const d=e.external.registry.get(i[0])?.id,p=e.external.uri??(_=>_);if(d)return{ref:p(d)};const h=i[1].defId??i[1].schema.id??`schema${e.counter++}`;return i[1].defId=h,{defId:h,ref:`${p("__shared")}#/${a}/${Pr(h)}`}}const c="#",u=`${c}/${a}/`;if(i[1]===n&&!i[1].schema.id)return{ref:c};const l=i[1].schema.id??`__schema${e.counter++}`;return{defId:l,ref:u+Pr(l)}},s=i=>{if(i[1].schema.$ref)return;const a=i[1],{ref:c,defId:u}=o(i);a.def={...a.schema},u&&(a.defId=u);const l=a.schema;for(const d in l)delete l[d];l.$ref=c};if(e.cycles==="throw")for(const i of e.seen.entries()){const a=i[1];if(a.cycle)throw new Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
|
|
56
|
+
|
|
57
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const i of e.seen.entries()){const a=i[1];if(t===i[0]){s(i);continue}if(e.external){const u=e.external.registry.get(i[0])?.id;if(t!==i[0]&&u){s(i);continue}}if(e.metadataRegistry.get(i[0])?.id){s(i);continue}if(a.cycle){s(i);continue}a.count>1&&e.reused==="ref"&&s(i)}e.external&&(e.sharedDefsExtractedFor=e.external)}function Ko(e){const t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;const n=[];for(const r of t){if(!r||typeof r!="object")return;Ko(r);const o=Object.keys(r);if(o.length!==1||o[0]!=="type")return;const s=r.type;for(const i of Array.isArray(s)?s:[s]){if(typeof i!="string")return;n.includes(i)||n.push(i)}}delete e.anyOf,e.type=n.length===1?n[0]:n}const Wo=new Set(["type","properties","required","additionalProperties"]),Rr=["oneOf","anyOf"];function Er(e){const t=e.additionalProperties;return t===void 0||t===!1||typeof t!="object"||t===null?null:Object.keys(t).length?t:null}function dn(e){const t=[];for(const s of e){if(typeof s!="object"||s.type!=="object")return null;for(const i in s)if(!Wo.has(i))return null;t.push(s)}const n={},r=new Set;for(const s of t){for(const i in s.properties){if(Object.prototype.hasOwnProperty.call(n,i))continue;const a=[];for(const u of t){const l=u.properties?.[i]??Er(u);l!=null&&(a.some(d=>JSON.stringify(d)===JSON.stringify(l))||a.push(l))}const c=a.length===1?a[0]:dn(a)??{allOf:a};$e(n,i,c)}for(const i of s.required??[])r.add(i)}const o={type:"object",properties:n};if(r.size&&(o.required=[...r]),t.every(s=>s.additionalProperties===!1))o.additionalProperties=!1;else{const s=[];for(const i of t){const a=Er(i);a&&!s.some(c=>JSON.stringify(c)===JSON.stringify(a))&&s.push(a)}s.length===1?o.additionalProperties=s[0]:s.length>1&&(o.additionalProperties={allOf:s})}return o}function fl(e){const t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(const o of Wo)if(o in e)return;const n=t.filter(o=>Rr.some(s=>Array.isArray(o[s])));let r=null;if(!n.length)r=dn(t);else{const o=n[0],s=Rr.find(c=>Array.isArray(o[c]));if(Object.keys(o).length!==1)return;const i=t.filter(c=>c!==o),a=o[s].map(c=>dn([...i,c]));if(a.some(c=>!c))return;r={[s]:a}}r&&(delete e.allOf,Qe(e,r))}function Go(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=a=>{const c=e.seen.get(a);if(c.ref===null)return;const u=c.def??c.schema,l={...u},d=c.ref;if(c.ref=null,d){r(d);const h=e.seen.get(d),_=h.schema;if(_.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(u.allOf=u.allOf??[],u.allOf.push(_)):Qe(u,_),Qe(u,l),a._zod.parent===d)for(const S in u)S==="$ref"||S==="allOf"||S in l||delete u[S];if(_.$ref&&h.def)for(const S in u)S==="$ref"||S==="allOf"||S in h.def&&JSON.stringify(u[S])===JSON.stringify(h.def[S])&&delete u[S]}const p=a._zod.parent;if(p&&p!==d){r(p);const h=e.seen.get(p);if(h?.schema.$ref&&(u.$ref=h.schema.$ref,h.def))for(const _ in u)_==="$ref"||_==="allOf"||_ in h.def&&JSON.stringify(u[_])===JSON.stringify(h.def[_])&&delete u[_]}e.override({zodSchema:a,jsonSchema:u,path:c.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(const a of[...e.seen.entries()].reverse())r(a[0]);if(e.target!=="openapi-3.0")for(const a of e.seen.entries())Ko(a[1].def??a[1].schema);for(const a of e.deferred)a();if(e.intersections.length){const a=new Map;for(const c of e.seen.values())for(const u of[c.schema,c.def]){const l=u?.allOf;if(!Array.isArray(l))continue;const d=a.get(l);d?d.push(u):a.set(l,[u])}for(const c of e.intersections)for(const u of a.get(c)??[])fl(u)}}const o={};if(e.target==="draft-2020-12"?o.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?o.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?o.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const a=e.external.registry.get(t)?.id;if(!a)throw new Error("Schema is missing an `id` property");o.$id=e.external.uri(a)}Qe(o,n.defId?n.schema:n.def??n.schema);const s=e.metadataRegistry.get(t)?.id;s!==void 0&&o.id===s&&delete o.id;const i=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(const a of e.seen.entries()){const c=a[1];c.def&&c.defId&&(c.def.id===c.defId&&delete c.def.id,$e(i,c.defId,c.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(i).length>0&&(e.target==="draft-2020-12"?o.$defs=i:o.definitions=i);try{const a=JSON.parse(JSON.stringify(o));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:Ot(t,"input",e.processors),output:Ot(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function ne(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const r=e._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return ne(r.element,n);if(r.type==="set")return ne(r.valueType,n);if(r.type==="lazy")return ne(r.getter(),n);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault"||r.type==="catch")return ne(r.innerType,n);if(r.type==="intersection")return ne(r.left,n)||ne(r.right,n);if(r.type==="record"||r.type==="map")return ne(r.keyType,n)||ne(r.valueType,n);if(r.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:ne(r.in,n)||ne(r.out,n);if(r.type==="object"){for(const o in r.shape)if(ne(r.shape[o],n))return!0;return!1}if(r.type==="union"){for(const o of r.options)if(ne(o,n))return!0;return!1}if(r.type==="tuple"){for(const o of r.items)if(ne(o,n))return!0;return!!(r.rest&&ne(r.rest,n))}return!1}const hl=(e,t={})=>n=>{const r=Vo({...n,processors:t});return Y(e,r),Bo(r,e),Go(r,e)},Ot=(e,t,n={})=>r=>{const{libraryOptions:o,target:s}=r??{},i=Vo({...o??{},target:s,io:t,processors:n});return Y(e,i),Bo(i,e),Go(i,e)},Ue=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},Le=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},Or=(e,t)=>{Ue(e,"minimum",t),Le(e,"maximum",t)},Yo=(e,t)=>{e.multipleOf??(e.multipleOf=[]),e.multipleOf.includes(t)||e.multipleOf.push(t)},Qo=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},Xo=(e,t)=>{e.mime=e.mime?e.mime.filter(n=>t.includes(n)):[...t]},es=(e,t)=>{e.format=t,t.includes("int")&&(e.isInt=!0)},xr=(e,t)=>Ue(e,"minimum",t.minimum),Cr=(e,t)=>Le(e,"maximum",t.maximum),Nr=e=>(t,n)=>{es(t,n.format);const[r,o]=e[n.format];Ue(t,"minimum",r),Le(t,"maximum",o)},ml={greater_than:(e,t)=>Ue(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>Le(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>Yo(e,t.value),number_format:Nr(_o),bigint_format:Nr(Ti),min_length:xr,max_length:Cr,length_equals:(e,t)=>Or(e,t.length),min_size:xr,max_size:Cr,size_equals:(e,t)=>Or(e,t.size),string_format:(e,t)=>{es(e,t.format),t.pattern&&Qo(e,t.pattern),(t.format==="base64"||t.format==="base64url")&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>Xo(e,t.mime)};function me(e){const t={},n=e._zod.def,r=e._zod.traits.has("$ZodCheck")?[e,...n.checks??[]]:n.checks??[];for(const s of r)ml[s._zod.def.check]?.(t,s._zod.def);const o=e._zod.bag;o.minimum!==void 0&&Ue(t,"minimum",o.minimum),o.exclusiveMinimum!==void 0&&Ue(t,"exclusiveMinimum",o.exclusiveMinimum),o.maximum!==void 0&&Le(t,"maximum",o.maximum),o.exclusiveMaximum!==void 0&&Le(t,"exclusiveMaximum",o.exclusiveMaximum),o.multipleOf!==void 0&&Yo(t,o.multipleOf),o.format!==void 0&&(t.format??(t.format=o.format),o.format.includes("int")&&(t.isInt=!0)),o.mime&&Xo(t,o.mime);for(const s of o.patterns??[])Qo(t,s);return t}const gl={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},_l=new Map([[xo,Pa],[Rn,Ra]]),ts=e=>_l.get(e)??e,vl=(e,t,n,r)=>{const o=n;o.type="string";const{minimum:s,maximum:i,format:a,patterns:c,contentEncoding:u,laxFormat:l}=me(e);if(typeof s=="number"&&(o.minLength=s),typeof i=="number"&&(o.maxLength=i),a&&(o.format=gl[a]??a,o.format===""&&delete o.format,(a==="time"||l)&&delete o.format),u&&(o.contentEncoding=u),c&&c.size>0){const d=[...c].map(ts);d.length===1?o.pattern=d[0].source:d.length>1&&(o.allOf=[...d.map(p=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:p.source}))])}},bl=(e,t,n,r)=>{const o=n,{minimum:s,maximum:i,multipleOf:a,exclusiveMaximum:c,exclusiveMinimum:u,isInt:l}=me(e);o.type=l?"integer":"number";const d=typeof u=="number"&&u>=(s??Number.NEGATIVE_INFINITY),p=typeof c=="number"&&c<=(i??Number.POSITIVE_INFINITY),h=t.target==="draft-04"||t.target==="openapi-3.0";if(d?h?(o.minimum=u,o.exclusiveMinimum=!0):o.exclusiveMinimum=u:typeof s=="number"&&(o.minimum=s),p?h?(o.maximum=c,o.exclusiveMaximum=!0):o.exclusiveMaximum=c:typeof i=="number"&&(o.maximum=i),a){const _=new Set;for(const I of a)Number.isFinite(I)&&I!==0?_.add(Math.abs(I)):Te(e,t,o,r,`A multipleOf divisor of ${I} cannot be represented in JSON Schema`);const[w,...S]=_;w!==void 0&&(o.multipleOf=w),S.length&&(o.allOf=[...o.allOf??[],...S.map(I=>({multipleOf:I}))])}},yl=(e,t,n,r)=>{n.type="boolean"},wl=(e,t,n,r)=>{t.target==="openapi-3.0"?(n.type="string",n.nullable=!0,n.enum=[null]):n.type="null"},kl=(e,t,n,r)=>{n.not={}},$l=(e,t,n,r)=>{},zl=(e,t,n,r)=>{const o=e._zod.def,s=on(o.entries);if(s.length===0){n.not={};return}s.every(i=>typeof i=="number")&&(n.type="number"),s.every(i=>typeof i=="string")&&(n.type="string"),n.enum=s},Sl=(e,t,n,r)=>{const o=e._zod.def;if(o.values.length===0){n.not={};return}const s=[];for(const i of o.values)if(i===void 0){if(Te(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof i=="bigint"){if(Te(e,t,n,r,"BigInt literals cannot be represented in JSON Schema"))return;s.push(Number(i))}else s.push(i);if(s.length!==0)if(s.length===1){const i=s[0];n.type=i===null?"null":typeof i,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[i]:n.const=i}else s.every(i=>typeof i=="number")&&(n.type="number"),s.every(i=>typeof i=="string")&&(n.type="string"),s.every(i=>typeof i=="boolean")&&(n.type="boolean"),s.every(i=>i===null)&&(n.type="null"),n.enum=s},Zl=(e,t,n,r)=>{Te(e,t,n,r,"Custom types cannot be represented in JSON Schema")},Tl=(e,t,n,r)=>{Te(e,t,n,r,"Transforms cannot be represented in JSON Schema")},Il=(e,t,n,r)=>{const o=n,s=e._zod.def,{minimum:i,maximum:a}=me(e);typeof i=="number"&&(o.minItems=i),typeof a=="number"&&(o.maxItems=a),o.type="array",o.items=Y(s.element,t,{...r,path:[...r.path,"items"]})};function xt(e){const t=e._zod.def;return t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform")?xt(t.out):t.type==="catch"?xt(t.innerType):e._zod.optin}const Pl=(e,t,n,r)=>{const o=n,s=e._zod.def,i=s.shape;if(Object.getOwnPropertySymbols(i).length&&Te(e,t,o,r,"Symbol keys cannot be represented in JSON Schema"))return;o.type="object",o.properties={};for(const u in i)$e(o.properties,u,Y(i[u],t,{...r,path:[...r.path,"properties",u]}));const c=[];for(const u of Object.keys(i)){const l=s.shape[u];(t.io==="input"?xt(l)===void 0:l._zod.optout===void 0)&&c.push(u)}c.length>0&&(o.required=c),s.catchall?._zod.def.type==="never"?o.additionalProperties=!1:s.catchall?s.catchall&&(o.additionalProperties=Y(s.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},Rl=(e,t,n,r)=>{const o=e._zod.def,s=o.inclusive===!1,i=o.options.map((a,c)=>Y(a,t,{...r,path:[...r.path,s?"oneOf":"anyOf",c]}));s?n.oneOf=i:n.anyOf=i},El=(e,t,n,r)=>{const o=e._zod.def,s=Y(o.left,t,{...r,path:[...r.path,"allOf",0]}),i=Y(o.right,t,{...r,path:[...r.path,"allOf",1]}),a=u=>"allOf"in u&&Object.keys(u).length===1,c=[...a(s)?s.allOf:[s],...a(i)?i.allOf:[i]];n.allOf=c,t.intersections.push(c)};function pn(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);const _=e.get(t)?.def;if(!_)return t;const w=pn(e,_,n);return w===_?t:w}for(const _ of["anyOf","oneOf"]){const w=t[_];if(!Array.isArray(w))continue;const S=w.map(I=>pn(e,I,n));S.some((I,Z)=>I!==w[Z])&&(t={...t,[_]:S})}const r=Array.isArray(t.type)?t.type:[t.type],o=!r.includes("string")&&r.some(_=>_==="number"||_==="integer"),s=t.enum??(t.const!==void 0?[t.const]:void 0);if(!o&&!s?.some(_=>typeof _=="number"))return t;const{minimum:i,maximum:a,exclusiveMinimum:c,exclusiveMaximum:u,multipleOf:l,format:d,id:p,...h}=t;return h.enum?h.enum=h.enum.map(_=>typeof _=="number"?String(_):_):typeof h.const=="number"&&(h.const=String(h.const)),o&&(h.type="string",s||(h.pattern=(r.includes("number")?Tn:Ma).source)),h}const fn=new WeakMap;function Ol(e){const t=new Map;for(const r of e.seen.values())r.def&&!t.has(r.schema)&&t.set(r.schema,r);const n=new Map;for(const r of fn.get(e)??[]){const o=e.seen.get(r),s=(o?.def??o?.schema)?.propertyNames;if(!s||s===!0||n.has(s))continue;const i=pn(t,s,new Set);i!==s&&n.set(s,i)}if(n.size)for(const r of e.seen.values())for(const o of[r.schema,r.def]){const s=o&&n.get(o.propertyNames);s&&(o.propertyNames=s)}}const xl=(e,t,n,r)=>{const o=n,s=e._zod.def;o.type="object";const i=s.keyType,a=me(i).patterns;if(s.mode==="loose"&&a&&a.size>0){const l=Y(s.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});o.patternProperties={};for(const d of a)$e(o.patternProperties,ts(d).source,l)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){o.propertyNames=Y(s.keyType,t,{...r,path:[...r.path,"propertyNames"]});let l=fn.get(t);l||(l=[],fn.set(t,l),t.deferred.push(()=>Ol(t))),l.push(e)}o.additionalProperties=Y(s.valueType,t,{...r,path:[...r.path,"additionalProperties"]})}const c=i._zod.values,u=t.io==="input"&&xt(s.valueType)!==void 0;if(c&&!s.partial&&!u){const l=[...c].filter(d=>typeof d=="string"||typeof d=="number");l.length>0&&(o.required=l.map(String))}},Cl=(e,t,n,r)=>{const o=e._zod.def,s=Y(o.innerType,t,r),i=t.seen.get(e);t.target==="openapi-3.0"?(i.ref=o.innerType,n.nullable=!0):n.anyOf=[s,{type:"null"}]},Nl=(e,t,n,r)=>{const o=e._zod.def;Y(o.innerType,t,r);const s=t.seen.get(e);s.ref=o.innerType},En=Symbol();function ns(e,t,n,r,o){let s=!1;const i=JSON.stringify(e,(a,c)=>typeof c!="bigint"?c:(s=!0,null));return s?(Te(t,n,r,o,"BigInt defaults cannot be represented in JSON Schema"),En):JSON.parse(i)}const Al=(e,t,n,r)=>{const o=e._zod.def;Y(o.innerType,t,r);const s=t.seen.get(e);s.ref=o.innerType;const i=ns(o.defaultValue,e,t,n,r);i!==En&&(n.default=i)},jl=(e,t,n,r)=>{const o=e._zod.def;Y(o.innerType,t,r);const s=t.seen.get(e);if(s.ref=o.innerType,t.io!=="input")return;const i=ns(o.defaultValue,e,t,n,r);i!==En&&(n._prefault=i)},Ml=(e,t,n,r)=>{const o=e._zod.def;Y(o.innerType,t,r);const s=t.seen.get(e);s.ref=o.innerType;let i;try{i=o.catchValue(void 0)}catch{Te(e,t,n,r,"Dynamic catch values are not supported in JSON Schema");return}n.default=i},Dl=(e,t,n,r)=>{const o=e._zod.def,s=o.in._zod.traits.has("$ZodTransform"),i=t.io==="input"?s?o.out:o.in:o.out;Y(i,t,r);const a=t.seen.get(e);a.ref=i},ql=(e,t,n,r)=>{const o=e._zod.def;Y(o.innerType,t,r);const s=t.seen.get(e);s.ref=o.innerType,n.readOnly=!0},rs=(e,t,n,r)=>{const o=e._zod.def;Y(o.innerType,t,r);const s=t.seen.get(e);s.ref=o.innerType},Ar=new WeakSet([Object.prototype,Error.prototype]);function bt(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){const r=n(this);return Object.defineProperty(this,t,{value:r,configurable:!0,writable:!0}),r},set(r){Object.defineProperty(this,t,{value:r,configurable:!0,writable:!0})}})}const Ul=(e,t)=>{Ki.init(e,t),e.name="ZodError";const n=Object.getPrototypeOf(e);Ar.has(n)||(Ar.add(n),bt(n,"format",r=>o=>Qi(r,o)),bt(n,"flatten",r=>o=>Yi(r,o)),bt(n,"addIssue",r=>o=>{r.issues.push(o),r.message=JSON.stringify(r.issues,sn,2)}),bt(n,"addIssues",r=>o=>{r.issues.push(...o),r.message=JSON.stringify(r.issues,sn,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},pe=m("ZodError",Ul,void 0,{Parent:Error}),Ll=zn(pe),Fl=Sn(pe),Hl=Ut(pe),Jl=Zn(pe),Vl=sa(pe),Bl=ia(pe),Kl=aa(pe),Wl=ca(pe),Gl=ua(pe),Yl=la(pe),Ql=da(pe),Xl=pa(pe);function ed(){ge.localeError||ve(gu())}function Ft(){ge.memoizer||ve({memoizer:fu()})}const F=m("ZodType",(e,t)=>(ed(),U.init(e,t),e.def=t,e.type=t.type,e),{check(...e){const t=this.def;return this.clone(ae(t,{checks:[...t.checks??[],...e.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return Re(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Kd(e,t))},superRefine(e,t){return this.check(Wd(e,t))},overwrite(e){return this.check(Je(e))},optional(){return B(this)},exactOptional(){return Nd(this)},nullable(){return Dr(this)},nullish(){return B(Dr(this))},nonoptional(e){return Ud(this,e)},array(){return P(this)},or(e){return H([this,e])},and(e){return On(this,e)},transform(e){return qr(this,ls(e))},default(e){return Md(this,e)},prefault(e){return qd(this,e)},catch(e){return Fd(this,e)},pipe(e){return qr(this,e)},readonly(){return Vd(this)},describe(e){const t=this.clone();return Ge.add(t,{description:e}),t},meta(...e){if(e.length===0)return Ge.get(this);const t=this.clone();return Ge.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return bo(this,"~standard",{...Io(this),jsonSchema:{input:Ot(this,"input"),output:Ot(this,"output")}})},set"~standard"(e){Ze(this,"~standard",e)},parse:function e(t,n){return Ll(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await Fl(this,t,n,{callee:e})},safeParse(e,t){return Hl(this,e,t)},async safeParseAsync(e,t){return Jl(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){Ze(this,"spa",e)},validate(e,t){return na(this,e,t)},validateAsync(e,t){return oa(this,e,t)},encode:function e(t,n){return Vl(this,t,n,{callee:e})},decode:function e(t,n){return Bl(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await Kl(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await Wl(this,t,n,{callee:e})},safeEncode(e,t){return Gl(this,e,t)},safeDecode(e,t){return Yl(this,e,t)},async safeEncodeAsync(e,t){return Ql(this,e,t)},async safeDecodeAsync(e,t){return Xl(this,e,t)},toJSONSchema(e){return hl(this,{})(e)},get description(){return Ge.get(this)?.description},get _def(){return this._zod.def}}),os=m("_ZodString",(e,t)=>{Pn.init(e,t),F.init(e,t),e._zod.processJSONSchema=(n,r,o)=>vl(e,n,r)},yo({format:e=>me(e).format??null,minLength:e=>me(e).minimum??null,maxLength:e=>me(e).maximum??null},{regex(...e){return this.check(Yu(...e))},includes(...e){return this.check(el(...e))},startsWith(...e){return this.check(tl(...e))},endsWith(...e){return this.check(nl(...e))},min(...e){return this.check(Et(...e))},max(...e){return this.check(Ho(...e))},length(...e){return this.check(Jo(...e))},nonempty(...e){return this.check(Et(1,...e))},lowercase(e){return this.check(Qu(e))},uppercase(e){return this.check(Xu(e))},trim(){return this.check(ol())},normalize(...e){return this.check(rl(...e))},toLowerCase(){return this.check(sl())},toUpperCase(){return this.check(il())},slugify(){return this.check(al())}})),td=m("ZodString",(e,t)=>{Pn.init(e,t),os.init(e,t)},{email(e){return this.check(yu(sd,e))},url(e){return this.check(Zu(ad,e))},jwt(e){return this.check(Uu(kd,e))},emoji(e){return this.check(Tu(cd,e))},guid(e){return this.check(wu(id,e))},uuid(e){return this.check(ku(yt,e))},uuidv4(e){return this.check($u(yt,e))},uuidv6(e){return this.check(zu(yt,e))},uuidv7(e){return this.check(Su(yt,e))},nanoid(e){return this.check(Iu(ud,e))},cuid(e){return this.check(Pu(ld,e))},cuid2(e){return this.check(Ru(dd,e))},ulid(e){return this.check(Eu(pd,e))},base64(e){return this.check(Mu(bd,e))},base64url(e){return this.check(Du(yd,e))},xid(e){return this.check(Ou(fd,e))},ksuid(e){return this.check(xu(hd,e))},ipv4(e){return this.check(Cu(md,e))},ipv6(e){return this.check(Nu(gd,e))},cidrv4(e){return this.check(Au(_d,e))},cidrv6(e){return this.check(ju(vd,e))},e164(e){return this.check(qu(wd,e))},datetime(e){return this.check(Fo(ss,e))},date(e){return this.check(Lu(nd,e))},time(e){return this.check(Fu(rd,e))},duration(e){return this.check(Hu(od,e))}});function f(e){return bu(td,e)}const W=m("ZodStringFormat",(e,t)=>{L.init(e,t),os.init(e,t)}),ss=m("ZodISODateTime",(e,t)=>{yc.init(e,t),W.init(e,t)}),nd=m("ZodISODate",(e,t)=>{wc.init(e,t),W.init(e,t)}),rd=m("ZodISOTime",(e,t)=>{kc.init(e,t),W.init(e,t)}),od=m("ZodISODuration",(e,t)=>{$c.init(e,t),W.init(e,t)}),sd=m("ZodEmail",(e,t)=>{ic.init(e,t),W.init(e,t)}),id=m("ZodGUID",(e,t)=>{oc.init(e,t),W.init(e,t)}),yt=m("ZodUUID",(e,t)=>{sc.init(e,t),W.init(e,t)}),ad=m("ZodURL",(e,t)=>{pc.init(e,t),W.init(e,t)}),cd=m("ZodEmoji",(e,t)=>{fc.init(e,t),W.init(e,t)}),ud=m("ZodNanoID",(e,t)=>{hc.init(e,t),W.init(e,t)}),ld=m("ZodCUID",(e,t)=>{mc.init(e,t),W.init(e,t)}),dd=m("ZodCUID2",(e,t)=>{gc.init(e,t),W.init(e,t)}),pd=m("ZodULID",(e,t)=>{_c.init(e,t),W.init(e,t)}),fd=m("ZodXID",(e,t)=>{vc.init(e,t),W.init(e,t)}),hd=m("ZodKSUID",(e,t)=>{bc.init(e,t),W.init(e,t)}),md=m("ZodIPv4",(e,t)=>{zc.init(e,t),W.init(e,t)}),gd=m("ZodIPv6",(e,t)=>{Zc.init(e,t),W.init(e,t)}),_d=m("ZodCIDRv4",(e,t)=>{Tc.init(e,t),W.init(e,t)}),vd=m("ZodCIDRv6",(e,t)=>{Pc.init(e,t),W.init(e,t)}),bd=m("ZodBase64",(e,t)=>{Rc.init(e,t),W.init(e,t)}),yd=m("ZodBase64URL",(e,t)=>{Oc.init(e,t),W.init(e,t)}),wd=m("ZodE164",(e,t)=>{xc.init(e,t),W.init(e,t)}),kd=m("ZodJWT",(e,t)=>{Nc.init(e,t),W.init(e,t)}),is=m("ZodNumber",(e,t)=>{Co.init(e,t),F.init(e,t),e._zod.processJSONSchema=(n,r,o)=>bl(e,n,r,o),e.isFinite=!0},yo({minValue:e=>{const{minimum:t,exclusiveMinimum:n}=me(e);return Math.max(t??Number.NEGATIVE_INFINITY,n??Number.NEGATIVE_INFINITY)},maxValue:e=>{const{maximum:t,exclusiveMaximum:n}=me(e);return Math.min(t??Number.POSITIVE_INFINITY,n??Number.POSITIVE_INFINITY)},isInt:e=>{const{isInt:t,multipleOf:n}=me(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>me(e).format??null},{gt(e,t){return this.check(Tr(e,t))},gte(e,t){return this.check(tn(e,t))},min(e,t){return this.check(tn(e,t))},lt(e,t){return this.check(Zr(e,t))},lte(e,t){return this.check(en(e,t))},max(e,t){return this.check(en(e,t))},int(e){return this.check(jr(e))},safe(e){return this.check(jr(e))},positive(e){return this.check(Tr(0,e))},nonnegative(e){return this.check(tn(0,e))},negative(e){return this.check(Zr(0,e))},nonpositive(e){return this.check(en(0,e))},multipleOf(e,t){return this.check(Ir(e,t))},step(e,t){return this.check(Ir(e,t))},finite(){return this}}));function N(e){return Ju(is,e)}const $d=m("ZodNumberFormat",(e,t)=>{Ac.init(e,t),is.init(e,t)});function jr(e){return Vu($d,e)}const zd=m("ZodBoolean",(e,t)=>{jc.init(e,t),F.init(e,t),e._zod.processJSONSchema=(n,r,o)=>yl(e,n,r)});function X(e){return Bu(zd,e)}const Sd=m("ZodNull",(e,t)=>{Mc.init(e,t),F.init(e,t),e._zod.processJSONSchema=(n,r,o)=>wl(e,n,r)});function Zd(e){return Ku(Sd,e)}const Td=m("ZodUnknown",(e,t)=>{Dc.init(e,t),F.init(e,t),e._zod.processJSONSchema=(n,r,o)=>$l()});function K(){return Wu(Td)}const Id=m("ZodNever",(e,t)=>{qc.init(e,t),F.init(e,t),e._zod.processJSONSchema=(n,r,o)=>kl(e,n,r)});function Pd(e){return Gu(Id,e)}const Rd=m("ZodArray",(e,t)=>{Ft(),Fc.init(e,t),F.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Il(e,n,r,o),e.element=t.element},{min(e,t){return this.check(Et(e,t))},nonempty(e){return this.check(Et(1,e))},max(e,t){return this.check(Ho(e,t))},length(e,t){return this.check(Jo(e,t))},unwrap(){return this.element}});function P(e,t){return cl(Rd,e,t)}const as=m("ZodObject",(e,t)=>{Ft(),Vc.init(e,t),F.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Pl(e,n,r,o),Ui(e,"shape",n=>n._zod.def.shape,!1)},{keyof(){return ce(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(ae(this._zod.def,{catchall:e}))},passthrough(){return this.clone(ae(this._zod.def,{catchall:K()}))},loose(){return this.clone(ae(this._zod.def,{catchall:K()}))},strict(){return this.clone(ae(this._zod.def,{catchall:Pd()}))},strip(){return this.clone(ae(this._zod.def,{catchall:void 0}))},extend(e){return Ri(this,e)},safeExtend(e){return Ei(this,e)},merge(e){return Oi(this,e)},pick(e){return Ii(this,e)},omit(e){return Pi(this,e)},partial(...e){return cr(ds,this,e[0])},exactPartial(...e){return cr(ps,this,e[0],"exactPartial")},required(...e){return xi(fs,this,e[0])}});function y(e,t){const n={type:"object",shape:e??{},...k(t)};return new as(n)}function re(e,t){return new as({type:"object",shape:e,catchall:K(),...k(t)})}const cs=m("ZodUnion",(e,t)=>{jo.init(e,t),F.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Rl(e,n,r,o),e.options=t.options});function H(e,t){return new cs({type:"union",options:e,...k(t)})}const Ed=m("ZodDiscriminatedUnion",(e,t)=>{cs.init(e,t),Kc.init(e,t)});function us(e,t,n){return new Ed({type:"union",options:t,discriminator:e,...k(n)})}const Od=m("ZodIntersection",(e,t)=>{Wc.init(e,t),F.init(e,t),e._zod.processJSONSchema=(n,r,o)=>El(e,n,r,o)});function On(e,t){return new Od({type:"intersection",left:e,right:t})}const Mr=m("ZodRecord",(e,t)=>{Ft(),Gc.init(e,t),F.init(e,t),e._zod.processJSONSchema=(n,r,o)=>xl(e,n,r,o),e.keyType=t.keyType,e.valueType=t.valueType});function D(e,t,n){return!t||!t._zod?new Mr({type:"record",keyType:f(),valueType:e,...k(t)}):new Mr({type:"record",keyType:e,valueType:t,...k(n)})}const hn=m("ZodEnum",(e,t)=>{Yc.init(e,t),F.init(e,t),e._zod.processJSONSchema=(r,o,s)=>zl(e,r,o),e.enum=t.entries,e.options=[...e._zod.values];const n=new Set(Object.keys(t.entries));e.extract=(r,o)=>{const s={};for(const i of r)if(n.has(i))s[i]=t.entries[i];else throw new Error(`Key ${i} not found in enum`);return new hn({...t,checks:[],...k(o),entries:s})},e.exclude=(r,o)=>{const s={...t.entries};for(const i of r)if(n.has(i))delete s[i];else throw new Error(`Key ${i} not found in enum`);return new hn({...t,checks:[],...k(o),entries:s})}});function ce(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new hn({type:"enum",entries:n,...k(t)})}const xd=m("ZodLiteral",(e,t)=>{Qc.init(e,t),F.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Sl(e,n,r,o),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function $(e,t){return new xd({type:"literal",values:Array.isArray(e)?e:[e],...k(t)})}const Cd=m("ZodTransform",(e,t)=>{Ft(),Xc.init(e,t),F.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Tl(e,n,r,o),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new wo(e.constructor.name);n.addIssue=s=>{if(typeof s=="string")n.issues.push(tt(s,n.value,t));else{const i=s;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),"input"in i||(i.input=n.value),i.inst??(i.inst=e),n.issues.push(tt(i))}};const o=t.transform(n.value,n);return o instanceof Promise?o.then(s=>(n.value=s,n)):(n.value=o,n)}});function ls(e){return new Cd({type:"transform",transform:e})}const ds=m("ZodOptional",(e,t)=>{Mo.init(e,t),F.init(e,t),e._zod.processJSONSchema=(n,r,o)=>rs(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function B(e){return new ds({type:"optional",innerType:e})}const ps=m("ZodExactOptional",(e,t)=>{eu.init(e,t),F.init(e,t),e._zod.processJSONSchema=(n,r,o)=>rs(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Nd(e){return new ps({type:"optional",innerType:e})}const Ad=m("ZodNullable",(e,t)=>{tu.init(e,t),F.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Cl(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Dr(e){return new Ad({type:"nullable",innerType:e})}const jd=m("ZodDefault",(e,t)=>{nu.init(e,t),F.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Al(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Md(e,t){return new jd({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():mo(t)}})}const Dd=m("ZodPrefault",(e,t)=>{ru.init(e,t),F.init(e,t),e._zod.processJSONSchema=(n,r,o)=>jl(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function qd(e,t){return new Dd({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():mo(t)}})}const fs=m("ZodNonOptional",(e,t)=>{ou.init(e,t),F.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Nl(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Ud(e,t){return new fs({type:"nonoptional",innerType:e,...k(t)})}const Ld=m("ZodCatch",(e,t)=>{su.init(e,t),F.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ml(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Fd(e,t){return new Ld({type:"catch",innerType:e,catchValue:typeof t=="function"?t:Fi(t)})}const hs=m("ZodPipe",(e,t)=>{Do.init(e,t),F.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Dl(e,n,r,o),e.in=t.in,e.out=t.out});function qr(e,t){return new hs({type:"pipe",in:e,out:t})}const Hd=m("ZodPreprocess",(e,t)=>{hs.init(e,t),iu.init(e,t)}),Jd=m("ZodReadonly",(e,t)=>{au.init(e,t),F.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ql(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Vd(e){return new Jd({type:"readonly",innerType:e})}const ms=m("ZodCustom",(e,t)=>{cu.init(e,t),F.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Zl(e,n,r,o)});function Bd(e,t){return ul(ms,e??(()=>!0),t)}function Kd(e,t={}){return ll(ms,e,t)}function Wd(e,t){return dl(e,t)}function gs(e,t){return new Hd({type:"pipe",in:ls(e),out:t})}function Gd(e){return Fo(ss,e)}const Oe="io.modelcontextprotocol/related-task",Ht="2.0",Q=Bd(e=>e!==null&&(typeof e=="object"||typeof e=="function")),_s=H([f(),N().int()]),vs=f();re({ttl:N().optional(),pollInterval:N().optional()});const Yd=y({ttl:N().optional()}),Qd=y({taskId:f()}),xn=re({progressToken:_s.optional(),[Oe]:Qd.optional()}),ue=y({_meta:xn.optional()}),it=ue.extend({task:Yd.optional()}),Xd=e=>it.safeParse(e).success,ee=y({method:f(),params:ue.loose().optional()}),fe=y({_meta:xn.optional()}),he=y({method:f(),params:fe.loose().optional()}),te=re({_meta:xn.optional()}),at=H([f(),N().int()]),bs=y({jsonrpc:$(Ht),id:at,...ee.shape}).strict(),Ur=e=>bs.safeParse(e).success,ys=y({jsonrpc:$(Ht),...he.shape}).strict(),ep=e=>ys.safeParse(e).success,Cn=y({jsonrpc:$(Ht),id:at,result:te}).strict(),wt=e=>Cn.safeParse(e).success;var C;(function(e){e[e.ConnectionClosed=-32e3]="ConnectionClosed",e[e.RequestTimeout=-32001]="RequestTimeout",e[e.ParseError=-32700]="ParseError",e[e.InvalidRequest=-32600]="InvalidRequest",e[e.MethodNotFound=-32601]="MethodNotFound",e[e.InvalidParams=-32602]="InvalidParams",e[e.InternalError=-32603]="InternalError",e[e.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(C||(C={}));const Nn=y({jsonrpc:$(Ht),id:at.optional(),error:y({code:N().int(),message:f(),data:K().optional()})}).strict(),tp=e=>Nn.safeParse(e).success,np=H([bs,ys,Cn,Nn]);H([Cn,Nn]);const ws=te.strict(),rp=fe.extend({requestId:at.optional(),reason:f().optional()}),An=he.extend({method:$("notifications/cancelled"),params:rp}),op=y({src:f(),mimeType:f().optional(),sizes:P(f()).optional(),theme:ce(["light","dark"]).optional()}),ct=y({icons:P(op).optional()}),Fe=y({name:f(),title:f().optional()}),Jt=Fe.extend({...Fe.shape,...ct.shape,version:f(),websiteUrl:f().optional(),description:f().optional()}),sp=On(y({applyDefaults:X().optional()}),D(f(),K())),ip=gs(e=>e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,On(y({form:sp.optional(),url:Q.optional()}),D(f(),K()).optional())),ap=re({list:Q.optional(),cancel:Q.optional(),requests:re({sampling:re({createMessage:Q.optional()}).optional(),elicitation:re({create:Q.optional()}).optional()}).optional()}),cp=re({list:Q.optional(),cancel:Q.optional(),requests:re({tools:re({call:Q.optional()}).optional()}).optional()}),up=y({experimental:D(f(),Q).optional(),sampling:y({context:Q.optional(),tools:Q.optional()}).optional(),elicitation:ip.optional(),roots:y({listChanged:X().optional()}).optional(),tasks:ap.optional(),extensions:D(f(),Q).optional()}),lp=ue.extend({protocolVersion:f(),capabilities:up,clientInfo:Jt}),dp=ee.extend({method:$("initialize"),params:lp}),pp=y({experimental:D(f(),Q).optional(),logging:Q.optional(),completions:Q.optional(),prompts:y({listChanged:X().optional()}).optional(),resources:y({subscribe:X().optional(),listChanged:X().optional()}).optional(),tools:y({listChanged:X().optional()}).optional(),tasks:cp.optional(),extensions:D(f(),Q).optional()}),fp=te.extend({protocolVersion:f(),capabilities:pp,serverInfo:Jt,instructions:f().optional()}),hp=he.extend({method:$("notifications/initialized"),params:fe.optional()}),Vt=ee.extend({method:$("ping"),params:ue.optional()}),mp=y({progress:N(),total:B(N()),message:B(f())}),gp=y({...fe.shape,...mp.shape,progressToken:_s}),jn=he.extend({method:$("notifications/progress"),params:gp}),_p=ue.extend({cursor:vs.optional()}),ut=ee.extend({params:_p.optional()}),lt=te.extend({nextCursor:vs.optional()}),vp=ce(["working","input_required","completed","failed","cancelled"]),dt=y({taskId:f(),status:vp,ttl:H([N(),Zd()]),createdAt:f(),lastUpdatedAt:f(),pollInterval:B(N()),statusMessage:B(f())}),Mn=te.extend({task:dt}),bp=fe.merge(dt),Ct=he.extend({method:$("notifications/tasks/status"),params:bp}),Dn=ee.extend({method:$("tasks/get"),params:ue.extend({taskId:f()})}),qn=te.merge(dt),Un=ee.extend({method:$("tasks/result"),params:ue.extend({taskId:f()})});te.loose();const Ln=ut.extend({method:$("tasks/list")}),Fn=lt.extend({tasks:P(dt)}),Hn=ee.extend({method:$("tasks/cancel"),params:ue.extend({taskId:f()})}),yp=te.merge(dt),ks=y({uri:f(),mimeType:B(f()),_meta:D(f(),K()).optional()}),$s=ks.extend({text:f()}),Jn=f().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),zs=ks.extend({blob:Jn}),pt=ce(["user","assistant"]),Ve=y({audience:P(pt).optional(),priority:N().min(0).max(1).optional(),lastModified:Gd({offset:!0}).optional()}),Ss=y({...Fe.shape,...ct.shape,uri:f(),description:B(f()),mimeType:B(f()),size:B(N()),annotations:Ve.optional(),_meta:B(re({}))}),wp=y({...Fe.shape,...ct.shape,uriTemplate:f(),description:B(f()),mimeType:B(f()),annotations:Ve.optional(),_meta:B(re({}))}),Zs=ut.extend({method:$("resources/list")}),Ts=lt.extend({resources:P(Ss)}),Is=ut.extend({method:$("resources/templates/list")}),Ps=lt.extend({resourceTemplates:P(wp)}),Vn=ue.extend({uri:f()}),kp=Vn,Rs=ee.extend({method:$("resources/read"),params:kp}),Es=te.extend({contents:P(H([$s,zs]))}),Os=he.extend({method:$("notifications/resources/list_changed"),params:fe.optional()}),$p=Vn,zp=ee.extend({method:$("resources/subscribe"),params:$p}),Sp=Vn,Zp=ee.extend({method:$("resources/unsubscribe"),params:Sp}),Tp=fe.extend({uri:f()}),Ip=he.extend({method:$("notifications/resources/updated"),params:Tp}),Pp=y({name:f(),description:B(f()),required:B(X())}),Rp=y({...Fe.shape,...ct.shape,description:B(f()),arguments:B(P(Pp)),_meta:B(re({}))}),xs=ut.extend({method:$("prompts/list")}),Cs=lt.extend({prompts:P(Rp)}),Ep=ue.extend({name:f(),arguments:D(f(),f()).optional()}),Op=ee.extend({method:$("prompts/get"),params:Ep}),Bn=y({type:$("text"),text:f(),annotations:Ve.optional(),_meta:D(f(),K()).optional()}),Kn=y({type:$("image"),data:Jn,mimeType:f(),annotations:Ve.optional(),_meta:D(f(),K()).optional()}),Wn=y({type:$("audio"),data:Jn,mimeType:f(),annotations:Ve.optional(),_meta:D(f(),K()).optional()}),xp=y({type:$("tool_use"),name:f(),id:f(),input:D(f(),K()),_meta:D(f(),K()).optional()}),Ns=y({type:$("resource"),resource:H([$s,zs]),annotations:Ve.optional(),_meta:D(f(),K()).optional()}),As=Ss.extend({type:$("resource_link")}),ft=H([Bn,Kn,Wn,As,Ns]),Cp=y({role:pt,content:ft}),Np=te.extend({description:f().optional(),messages:P(Cp)}),js=he.extend({method:$("notifications/prompts/list_changed"),params:fe.optional()}),Ap=y({title:f().optional(),readOnlyHint:X().optional(),destructiveHint:X().optional(),idempotentHint:X().optional(),openWorldHint:X().optional()}),jp=y({taskSupport:ce(["required","optional","forbidden"]).optional()}),Gn=y({...Fe.shape,...ct.shape,description:f().optional(),inputSchema:y({type:$("object"),properties:D(f(),Q).optional(),required:P(f()).optional()}).catchall(K()),outputSchema:y({type:$("object"),properties:D(f(),Q).optional(),required:P(f()).optional()}).catchall(K()).optional(),annotations:Ap.optional(),execution:jp.optional(),_meta:D(f(),K()).optional()}),Mp=ut.extend({method:$("tools/list")}),Ms=lt.extend({tools:P(Gn)}),nt=te.extend({content:P(ft).default([]),structuredContent:D(f(),K()).optional(),isError:X().optional()});nt.or(te.extend({toolResult:K()}));const Dp=it.extend({name:f(),arguments:D(f(),K()).optional()}),Ds=ee.extend({method:$("tools/call"),params:Dp}),qs=he.extend({method:$("notifications/tools/list_changed"),params:fe.optional()});y({autoRefresh:X().default(!0),debounceMs:N().int().nonnegative().default(300)});const Us=ce(["debug","info","notice","warning","error","critical","alert","emergency"]),qp=ue.extend({level:Us}),Up=ee.extend({method:$("logging/setLevel"),params:qp}),Lp=fe.extend({level:Us,logger:f().optional(),data:K()}),Ls=he.extend({method:$("notifications/message"),params:Lp}),Fp=y({name:f().optional()}),Hp=y({hints:P(Fp).optional(),costPriority:N().min(0).max(1).optional(),speedPriority:N().min(0).max(1).optional(),intelligencePriority:N().min(0).max(1).optional()}),Jp=y({mode:ce(["auto","required","none"]).optional()}),Vp=y({type:$("tool_result"),toolUseId:f().describe("The unique identifier for the corresponding tool call."),content:P(ft).default([]),structuredContent:y({}).loose().optional(),isError:X().optional(),_meta:D(f(),K()).optional()}),Bp=us("type",[Bn,Kn,Wn]),Nt=us("type",[Bn,Kn,Wn,xp,Vp]),Kp=y({role:pt,content:H([Nt,P(Nt)]),_meta:D(f(),K()).optional()}),Wp=it.extend({messages:P(Kp),modelPreferences:Hp.optional(),systemPrompt:f().optional(),includeContext:ce(["none","thisServer","allServers"]).optional(),temperature:N().optional(),maxTokens:N().int(),stopSequences:P(f()).optional(),metadata:Q.optional(),tools:P(Gn).optional(),toolChoice:Jp.optional()}),Fs=ee.extend({method:$("sampling/createMessage"),params:Wp}),Gp=te.extend({model:f(),stopReason:B(ce(["endTurn","stopSequence","maxTokens"]).or(f())),role:pt,content:Bp}),Yp=te.extend({model:f(),stopReason:B(ce(["endTurn","stopSequence","maxTokens","toolUse"]).or(f())),role:pt,content:H([Nt,P(Nt)])}),Qp=y({type:$("boolean"),title:f().optional(),description:f().optional(),default:X().optional()}),Xp=y({type:$("string"),title:f().optional(),description:f().optional(),minLength:N().optional(),maxLength:N().optional(),format:ce(["email","uri","date","date-time"]).optional(),default:f().optional()}),ef=y({type:ce(["number","integer"]),title:f().optional(),description:f().optional(),minimum:N().optional(),maximum:N().optional(),default:N().optional()}),tf=y({type:$("string"),title:f().optional(),description:f().optional(),enum:P(f()),default:f().optional()}),nf=y({type:$("string"),title:f().optional(),description:f().optional(),oneOf:P(y({const:f(),title:f()})),default:f().optional()}),rf=y({type:$("string"),title:f().optional(),description:f().optional(),enum:P(f()),enumNames:P(f()).optional(),default:f().optional()}),of=H([tf,nf]),sf=y({type:$("array"),title:f().optional(),description:f().optional(),minItems:N().optional(),maxItems:N().optional(),items:y({type:$("string"),enum:P(f())}),default:P(f()).optional()}),af=y({type:$("array"),title:f().optional(),description:f().optional(),minItems:N().optional(),maxItems:N().optional(),items:y({anyOf:P(y({const:f(),title:f()}))}),default:P(f()).optional()}),cf=H([sf,af]),uf=H([rf,of,cf]),lf=H([uf,Qp,Xp,ef]),df=it.extend({mode:$("form").optional(),message:f(),requestedSchema:y({type:$("object"),properties:D(f(),lf),required:P(f()).optional()})}),pf=it.extend({mode:$("url"),message:f(),elicitationId:f(),url:f().url()}),ff=H([df,pf]),hf=ee.extend({method:$("elicitation/create"),params:ff}),mf=fe.extend({elicitationId:f()}),gf=he.extend({method:$("notifications/elicitation/complete"),params:mf}),_f=te.extend({action:ce(["accept","decline","cancel"]),content:gs(e=>e===null?void 0:e,D(f(),H([f(),N(),X(),P(f())])).optional())}),vf=y({type:$("ref/resource"),uri:f()}),bf=y({type:$("ref/prompt"),name:f()}),yf=ue.extend({ref:H([bf,vf]),argument:y({name:f(),value:f()}),context:y({arguments:D(f(),f()).optional()}).optional()}),wf=ee.extend({method:$("completion/complete"),params:yf}),kf=te.extend({completion:re({values:P(f()).max(100),total:B(N().int()),hasMore:B(X())})}),$f=y({uri:f().startsWith("file://"),name:f().optional(),_meta:D(f(),K()).optional()}),zf=ee.extend({method:$("roots/list"),params:ue.optional()}),Sf=te.extend({roots:P($f)}),Zf=he.extend({method:$("notifications/roots/list_changed"),params:fe.optional()});H([Vt,dp,wf,Up,Op,xs,Zs,Is,Rs,zp,Zp,Ds,Mp,Dn,Un,Ln,Hn]);H([An,jn,hp,Zf,Ct]);H([ws,Gp,Yp,_f,Sf,qn,Fn,Mn]);H([Vt,Fs,hf,zf,Dn,Un,Ln,Hn]);H([An,jn,Ls,Ip,Os,qs,js,Ct,gf]);H([ws,fp,kf,Np,Cs,Ts,Ps,Es,nt,Ms,qn,Fn,Mn]);class R extends Error{constructor(t,n,r){super(`MCP error ${t}: ${n}`),this.code=t,this.data=r,this.name="McpError"}static fromError(t,n,r){if(t===C.UrlElicitationRequired&&r){const o=r;if(o.elicitations)return new Tf(o.elicitations,n)}return new R(t,n,r)}}class Tf extends R{constructor(t,n=`URL elicitation${t.length>1?"s":""} required`){super(C.UrlElicitationRequired,n,{elicitations:t})}get elicitations(){return this.data?.elicitations??[]}}function Yn(e){return!!e._zod}function Hs(e,t){return Yn(e)?Xi(e,t):e.safeParse(t)}function If(e){if(!e)return;let t;if(Yn(e)?t=e._zod?.def?.shape:t=e.shape,!!t){if(typeof t=="function")try{return t()}catch{return}return t}}function Pf(e){if(Yn(e)){const s=e._zod?.def;if(s){if(s.value!==void 0)return s.value;if(Array.isArray(s.values)&&s.values.length>0)return s.values[0]}}const n=e._def;if(n){if(n.value!==void 0)return n.value;if(Array.isArray(n.values)&&n.values.length>0)return n.values[0]}const r=e.value;if(r!==void 0)return r}function Ee(e){return e==="completed"||e==="failed"||e==="cancelled"}new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function Lr(e){const n=If(e)?.method;if(!n)throw new Error("Schema is missing a method literal");const r=Pf(n);if(typeof r!="string")throw new Error("Schema method literal must be a string");return r}function Fr(e,t){const n=Hs(e,t);if(!n.success)throw n.error;return n.data}const Rf=6e4;class Ef{constructor(t){this._options=t,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(An,n=>{this._oncancel(n)}),this.setNotificationHandler(jn,n=>{this._onprogress(n)}),this.setRequestHandler(Vt,n=>({})),this._taskStore=t?.taskStore,this._taskMessageQueue=t?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(Dn,async(n,r)=>{const o=await this._taskStore.getTask(n.params.taskId,r.sessionId);if(!o)throw new R(C.InvalidParams,"Failed to retrieve task: Task not found");return{...o}}),this.setRequestHandler(Un,async(n,r)=>{const o=async()=>{const s=n.params.taskId;if(this._taskMessageQueue){let a;for(;a=await this._taskMessageQueue.dequeue(s,r.sessionId);){if(a.type==="response"||a.type==="error"){const c=a.message,u=c.id,l=this._requestResolvers.get(u);if(l)if(this._requestResolvers.delete(u),a.type==="response")l(c);else{const d=c,p=new R(d.error.code,d.error.message,d.error.data);l(p)}else{const d=a.type==="response"?"Response":"Error";this._onerror(new Error(`${d} handler missing for request ${u}`))}continue}await this._transport?.send(a.message,{relatedRequestId:r.requestId})}}const i=await this._taskStore.getTask(s,r.sessionId);if(!i)throw new R(C.InvalidParams,`Task not found: ${s}`);if(!Ee(i.status))return await this._waitForTaskUpdate(s,r.signal),await o();if(Ee(i.status)){const a=await this._taskStore.getTaskResult(s,r.sessionId);return this._clearTaskQueue(s),{...a,_meta:{...a._meta,[Oe]:{taskId:s}}}}return await o()};return await o()}),this.setRequestHandler(Ln,async(n,r)=>{try{const{tasks:o,nextCursor:s}=await this._taskStore.listTasks(n.params?.cursor,r.sessionId);return{tasks:o,nextCursor:s,_meta:{}}}catch(o){throw new R(C.InvalidParams,`Failed to list tasks: ${o instanceof Error?o.message:String(o)}`)}}),this.setRequestHandler(Hn,async(n,r)=>{try{const o=await this._taskStore.getTask(n.params.taskId,r.sessionId);if(!o)throw new R(C.InvalidParams,`Task not found: ${n.params.taskId}`);if(Ee(o.status))throw new R(C.InvalidParams,`Cannot cancel task in terminal status: ${o.status}`);await this._taskStore.updateTaskStatus(n.params.taskId,"cancelled","Client cancelled task execution.",r.sessionId),this._clearTaskQueue(n.params.taskId);const s=await this._taskStore.getTask(n.params.taskId,r.sessionId);if(!s)throw new R(C.InvalidParams,`Task not found after cancellation: ${n.params.taskId}`);return{_meta:{},...s}}catch(o){throw o instanceof R?o:new R(C.InvalidRequest,`Failed to cancel task: ${o instanceof Error?o.message:String(o)}`)}}))}async _oncancel(t){if(!t.params.requestId)return;this._requestHandlerAbortControllers.get(t.params.requestId)?.abort(t.params.reason)}_setupTimeout(t,n,r,o,s=!1){this._timeoutInfo.set(t,{timeoutId:setTimeout(o,n),startTime:Date.now(),timeout:n,maxTotalTimeout:r,resetTimeoutOnProgress:s,onTimeout:o})}_resetTimeout(t){const n=this._timeoutInfo.get(t);if(!n)return!1;const r=Date.now()-n.startTime;if(n.maxTotalTimeout&&r>=n.maxTotalTimeout)throw this._timeoutInfo.delete(t),R.fromError(C.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:n.maxTotalTimeout,totalElapsed:r});return clearTimeout(n.timeoutId),n.timeoutId=setTimeout(n.onTimeout,n.timeout),!0}_cleanupTimeout(t){const n=this._timeoutInfo.get(t);n&&(clearTimeout(n.timeoutId),this._timeoutInfo.delete(t))}async connect(t){if(this._transport)throw new Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");this._transport=t;const n=this.transport?.onclose;this._transport.onclose=()=>{n?.(),this._onclose()};const r=this.transport?.onerror;this._transport.onerror=s=>{r?.(s),this._onerror(s)};const o=this._transport?.onmessage;this._transport.onmessage=(s,i)=>{o?.(s,i),wt(s)||tp(s)?this._onresponse(s):Ur(s)?this._onrequest(s,i):ep(s)?this._onnotification(s):this._onerror(new Error(`Unknown message type: ${JSON.stringify(s)}`))},await this._transport.start()}_onclose(){const t=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(const r of this._timeoutInfo.values())clearTimeout(r.timeoutId);this._timeoutInfo.clear();for(const r of this._requestHandlerAbortControllers.values())r.abort();this._requestHandlerAbortControllers.clear();const n=R.fromError(C.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(const r of t.values())r(n)}_onerror(t){this.onerror?.(t)}_onnotification(t){const n=this._notificationHandlers.get(t.method)??this.fallbackNotificationHandler;n!==void 0&&Promise.resolve().then(()=>n(t)).catch(r=>this._onerror(new Error(`Uncaught error in notification handler: ${r}`)))}_onrequest(t,n){const r=this._requestHandlers.get(t.method)??this.fallbackRequestHandler,o=this._transport,s=t.params?._meta?.[Oe]?.taskId;if(r===void 0){const l={jsonrpc:"2.0",id:t.id,error:{code:C.MethodNotFound,message:"Method not found"}};s&&this._taskMessageQueue?this._enqueueTaskMessage(s,{type:"error",message:l,timestamp:Date.now()},o?.sessionId).catch(d=>this._onerror(new Error(`Failed to enqueue error response: ${d}`))):o?.send(l).catch(d=>this._onerror(new Error(`Failed to send an error response: ${d}`)));return}const i=new AbortController;this._requestHandlerAbortControllers.set(t.id,i);const a=Xd(t.params)?t.params.task:void 0,c=this._taskStore?this.requestTaskStore(t,o?.sessionId):void 0,u={signal:i.signal,sessionId:o?.sessionId,_meta:t.params?._meta,sendNotification:async l=>{if(i.signal.aborted)return;const d={relatedRequestId:t.id};s&&(d.relatedTask={taskId:s}),await this.notification(l,d)},sendRequest:async(l,d,p)=>{if(i.signal.aborted)throw new R(C.ConnectionClosed,"Request was cancelled");const h={...p,relatedRequestId:t.id};s&&!h.relatedTask&&(h.relatedTask={taskId:s});const _=h.relatedTask?.taskId??s;return _&&c&&await c.updateTaskStatus(_,"input_required"),await this.request(l,d,h)},authInfo:n?.authInfo,requestId:t.id,requestInfo:n?.requestInfo,taskId:s,taskStore:c,taskRequestedTtl:a?.ttl,closeSSEStream:n?.closeSSEStream,closeStandaloneSSEStream:n?.closeStandaloneSSEStream};Promise.resolve().then(()=>{a&&this.assertTaskHandlerCapability(t.method)}).then(()=>r(t,u)).then(async l=>{if(i.signal.aborted)return;const d={result:l,jsonrpc:"2.0",id:t.id};s&&this._taskMessageQueue?await this._enqueueTaskMessage(s,{type:"response",message:d,timestamp:Date.now()},o?.sessionId):await o?.send(d)},async l=>{if(i.signal.aborted)return;const d={jsonrpc:"2.0",id:t.id,error:{code:Number.isSafeInteger(l.code)?l.code:C.InternalError,message:l.message??"Internal error",...l.data!==void 0&&{data:l.data}}};s&&this._taskMessageQueue?await this._enqueueTaskMessage(s,{type:"error",message:d,timestamp:Date.now()},o?.sessionId):await o?.send(d)}).catch(l=>this._onerror(new Error(`Failed to send response: ${l}`))).finally(()=>{this._requestHandlerAbortControllers.get(t.id)===i&&this._requestHandlerAbortControllers.delete(t.id)})}_onprogress(t){const{progressToken:n,...r}=t.params,o=Number(n),s=this._progressHandlers.get(o);if(!s){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(t)}`));return}const i=this._responseHandlers.get(o),a=this._timeoutInfo.get(o);if(a&&i&&a.resetTimeoutOnProgress)try{this._resetTimeout(o)}catch(c){this._responseHandlers.delete(o),this._progressHandlers.delete(o),this._cleanupTimeout(o),i(c);return}s(r)}_onresponse(t){const n=Number(t.id),r=this._requestResolvers.get(n);if(r){if(this._requestResolvers.delete(n),wt(t))r(t);else{const i=new R(t.error.code,t.error.message,t.error.data);r(i)}return}const o=this._responseHandlers.get(n);if(o===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(t)}`));return}this._responseHandlers.delete(n),this._cleanupTimeout(n);let s=!1;if(wt(t)&&t.result&&typeof t.result=="object"){const i=t.result;if(i.task&&typeof i.task=="object"){const a=i.task;typeof a.taskId=="string"&&(s=!0,this._taskProgressTokens.set(a.taskId,n))}}if(s||this._progressHandlers.delete(n),wt(t))o(t);else{const i=R.fromError(t.error.code,t.error.message,t.error.data);o(i)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(t,n,r){const{task:o}=r??{};if(!o){try{yield{type:"result",result:await this.request(t,n,r)}}catch(i){yield{type:"error",error:i instanceof R?i:new R(C.InternalError,String(i))}}return}let s;try{const i=await this.request(t,Mn,r);if(i.task)s=i.task.taskId,yield{type:"taskCreated",task:i.task};else throw new R(C.InternalError,"Task creation did not return a task");for(;;){const a=await this.getTask({taskId:s},r);if(yield{type:"taskStatus",task:a},Ee(a.status)){a.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:s},n,r)}:a.status==="failed"?yield{type:"error",error:new R(C.InternalError,`Task ${s} failed`)}:a.status==="cancelled"&&(yield{type:"error",error:new R(C.InternalError,`Task ${s} was cancelled`)});return}if(a.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:s},n,r)};return}const c=a.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(u=>setTimeout(u,c)),r?.signal?.throwIfAborted()}}catch(i){yield{type:"error",error:i instanceof R?i:new R(C.InternalError,String(i))}}}request(t,n,r){const{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i,task:a,relatedTask:c}=r??{};return new Promise((u,l)=>{const d=Z=>{l(Z)};if(!this._transport){d(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(t.method),a&&this.assertTaskCapability(t.method)}catch(Z){d(Z);return}r?.signal?.throwIfAborted();const p=this._requestMessageId++,h={...t,jsonrpc:"2.0",id:p};r?.onprogress&&(this._progressHandlers.set(p,r.onprogress),h.params={...t.params,_meta:{...t.params?._meta||{},progressToken:p}}),a&&(h.params={...h.params,task:a}),c&&(h.params={...h.params,_meta:{...h.params?._meta||{},[Oe]:c}});const _=Z=>{this._responseHandlers.delete(p),this._progressHandlers.delete(p),this._cleanupTimeout(p),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:p,reason:String(Z)}},{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i}).catch(O=>this._onerror(new Error(`Failed to send cancellation: ${O}`)));const T=Z instanceof R?Z:new R(C.RequestTimeout,String(Z));l(T)};this._responseHandlers.set(p,Z=>{if(!r?.signal?.aborted){if(Z instanceof Error)return l(Z);try{const T=Hs(n,Z.result);T.success?u(T.data):l(T.error)}catch(T){l(T)}}}),r?.signal?.addEventListener("abort",()=>{_(r?.signal?.reason)});const w=r?.timeout??Rf,S=()=>_(R.fromError(C.RequestTimeout,"Request timed out",{timeout:w}));this._setupTimeout(p,w,r?.maxTotalTimeout,S,r?.resetTimeoutOnProgress??!1);const I=c?.taskId;if(I){const Z=T=>{const O=this._responseHandlers.get(p);O?O(T):this._onerror(new Error(`Response handler missing for side-channeled request ${p}`))};this._requestResolvers.set(p,Z),this._enqueueTaskMessage(I,{type:"request",message:h,timestamp:Date.now()}).catch(T=>{this._cleanupTimeout(p),l(T)})}else this._transport.send(h,{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i}).catch(Z=>{this._cleanupTimeout(p),l(Z)})})}async getTask(t,n){return this.request({method:"tasks/get",params:t},qn,n)}async getTaskResult(t,n,r){return this.request({method:"tasks/result",params:t},n,r)}async listTasks(t,n){return this.request({method:"tasks/list",params:t},Fn,n)}async cancelTask(t,n){return this.request({method:"tasks/cancel",params:t},yp,n)}async notification(t,n){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(t.method);const r=n?.relatedTask?.taskId;if(r){const a={...t,jsonrpc:"2.0",params:{...t.params,_meta:{...t.params?._meta||{},[Oe]:n.relatedTask}}};await this._enqueueTaskMessage(r,{type:"notification",message:a,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(t.method)&&!t.params&&!n?.relatedRequestId&&!n?.relatedTask){if(this._pendingDebouncedNotifications.has(t.method))return;this._pendingDebouncedNotifications.add(t.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(t.method),!this._transport)return;let a={...t,jsonrpc:"2.0"};n?.relatedTask&&(a={...a,params:{...a.params,_meta:{...a.params?._meta||{},[Oe]:n.relatedTask}}}),this._transport?.send(a,n).catch(c=>this._onerror(c))});return}let i={...t,jsonrpc:"2.0"};n?.relatedTask&&(i={...i,params:{...i.params,_meta:{...i.params?._meta||{},[Oe]:n.relatedTask}}}),await this._transport.send(i,n)}setRequestHandler(t,n){const r=Lr(t);this.assertRequestHandlerCapability(r),this._requestHandlers.set(r,(o,s)=>{const i=Fr(t,o);return Promise.resolve(n(i,s))})}removeRequestHandler(t){this._requestHandlers.delete(t)}assertCanSetRequestHandler(t){if(this._requestHandlers.has(t))throw new Error(`A request handler for ${t} already exists, which would be overridden`)}setNotificationHandler(t,n){const r=Lr(t);this._notificationHandlers.set(r,o=>{const s=Fr(t,o);return Promise.resolve(n(s))})}removeNotificationHandler(t){this._notificationHandlers.delete(t)}_cleanupTaskProgressHandler(t){const n=this._taskProgressTokens.get(t);n!==void 0&&(this._progressHandlers.delete(n),this._taskProgressTokens.delete(t))}async _enqueueTaskMessage(t,n,r){if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");const o=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(t,n,r,o)}async _clearTaskQueue(t,n){if(this._taskMessageQueue){const r=await this._taskMessageQueue.dequeueAll(t,n);for(const o of r)if(o.type==="request"&&Ur(o.message)){const s=o.message.id,i=this._requestResolvers.get(s);i?(i(new R(C.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(s)):this._onerror(new Error(`Resolver missing for request ${s} during task ${t} cleanup`))}}}async _waitForTaskUpdate(t,n){let r=this._options?.defaultTaskPollInterval??1e3;try{const o=await this._taskStore?.getTask(t);o?.pollInterval&&(r=o.pollInterval)}catch{}return new Promise((o,s)=>{if(n.aborted){s(new R(C.InvalidRequest,"Request cancelled"));return}const i=setTimeout(o,r);n.addEventListener("abort",()=>{clearTimeout(i),s(new R(C.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(t,n){const r=this._taskStore;if(!r)throw new Error("No task store configured");return{createTask:async o=>{if(!t)throw new Error("No request provided");return await r.createTask(o,t.id,{method:t.method,params:t.params},n)},getTask:async o=>{const s=await r.getTask(o,n);if(!s)throw new R(C.InvalidParams,"Failed to retrieve task: Task not found");return s},storeTaskResult:async(o,s,i)=>{await r.storeTaskResult(o,s,i,n);const a=await r.getTask(o,n);if(a){const c=Ct.parse({method:"notifications/tasks/status",params:a});await this.notification(c),Ee(a.status)&&this._cleanupTaskProgressHandler(o)}},getTaskResult:o=>r.getTaskResult(o,n),updateTaskStatus:async(o,s,i)=>{const a=await r.getTask(o,n);if(!a)throw new R(C.InvalidParams,`Task "${o}" not found - it may have been cleaned up`);if(Ee(a.status))throw new R(C.InvalidParams,`Cannot update task "${o}" from terminal status "${a.status}" to "${s}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await r.updateTaskStatus(o,s,i,n);const c=await r.getTask(o,n);if(c){const u=Ct.parse({method:"notifications/tasks/status",params:c});await this.notification(u),Ee(c.status)&&this._cleanupTaskProgressHandler(o)}},listTasks:o=>r.listTasks(o,n)}}}function g(e,t,n){function r(a,c){var u;Object.defineProperty(a,"_zod",{value:a._zod??{},enumerable:!1}),(u=a._zod).traits??(u.traits=new Set),a._zod.traits.add(e),t(a,c);for(const l in i.prototype)l in a||Object.defineProperty(a,l,{value:i.prototype[l].bind(a)});a._zod.constr=i,a._zod.def=c}const o=n?.Parent??Object;class s extends o{}Object.defineProperty(s,"name",{value:e});function i(a){var c;const u=n?.Parent?new s:this;r(u,a),(c=u._zod).deferred??(c.deferred=[]);for(const l of u._zod.deferred)l();return u}return Object.defineProperty(i,"init",{value:r}),Object.defineProperty(i,Symbol.hasInstance,{value:a=>n?.Parent&&a instanceof n.Parent?!0:a?._zod?.traits?.has(e)}),Object.defineProperty(i,"name",{value:e}),i}class rt extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}const Js={};function Ie(e){return Js}function Of(e){const t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,o])=>t.indexOf(+r)===-1).map(([r,o])=>o)}function xf(e,t){return typeof t=="bigint"?t.toString():t}function Vs(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Qn(e){return e==null}function Xn(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function Cf(e,t){const n=(e.toString().split(".")[1]||"").length,r=(t.toString().split(".")[1]||"").length,o=n>r?n:r,s=Number.parseInt(e.toFixed(o).replace(".","")),i=Number.parseInt(t.toFixed(o).replace(".",""));return s%i/10**o}function q(e,t,n){Object.defineProperty(e,t,{get(){{const r=n();return e[t]=r,r}},set(r){Object.defineProperty(e,t,{value:r})},configurable:!0})}function er(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Ke(e){return JSON.stringify(e)}const Bs=Error.captureStackTrace?Error.captureStackTrace:(...e)=>{};function mn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const Nf=Vs(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function At(e){if(mn(e)===!1)return!1;const t=e.constructor;if(t===void 0)return!0;const n=t.prototype;return!(mn(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}const Af=new Set(["string","number","symbol"]);function ht(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ae(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function z(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function jf(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const Mf={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Df(e,t){const n={},r=e._zod.def;for(const o in t){if(!(o in r.shape))throw new Error(`Unrecognized key: "${o}"`);t[o]&&(n[o]=r.shape[o])}return Ae(e,{...e._zod.def,shape:n,checks:[]})}function qf(e,t){const n={...e._zod.def.shape},r=e._zod.def;for(const o in t){if(!(o in r.shape))throw new Error(`Unrecognized key: "${o}"`);t[o]&&delete n[o]}return Ae(e,{...e._zod.def,shape:n,checks:[]})}function Uf(e,t){if(!At(t))throw new Error("Invalid input to extend: expected a plain object");const n={...e._zod.def,get shape(){const r={...e._zod.def.shape,...t};return er(this,"shape",r),r},checks:[]};return Ae(e,n)}function Lf(e,t){return Ae(e,{...e._zod.def,get shape(){const n={...e._zod.def.shape,...t._zod.def.shape};return er(this,"shape",n),n},catchall:t._zod.def.catchall,checks:[]})}function Ff(e,t,n){const r=t._zod.def.shape,o={...r};if(n)for(const s in n){if(!(s in r))throw new Error(`Unrecognized key: "${s}"`);n[s]&&(o[s]=e?new e({type:"optional",innerType:r[s]}):r[s])}else for(const s in r)o[s]=e?new e({type:"optional",innerType:r[s]}):r[s];return Ae(t,{...t._zod.def,shape:o,checks:[]})}function Hf(e,t,n){const r=t._zod.def.shape,o={...r};if(n)for(const s in n){if(!(s in o))throw new Error(`Unrecognized key: "${s}"`);n[s]&&(o[s]=new e({type:"nonoptional",innerType:r[s]}))}else for(const s in r)o[s]=new e({type:"nonoptional",innerType:r[s]});return Ae(t,{...t._zod.def,shape:o,checks:[]})}function Xe(e,t=0){for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function xe(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function kt(e){return typeof e=="string"?e:e?.message}function Pe(e,t,n){const r={...e,path:e.path??[]};if(!e.message){const o=kt(e.inst?._zod.def?.error?.(e))??kt(t?.error?.(e))??kt(n.customError?.(e))??kt(n.localeError?.(e))??"Invalid input";r.message=o}return delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function tr(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function ot(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}const Ks=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),Object.defineProperty(e,"message",{get(){return JSON.stringify(t,xf,2)},enumerable:!0}),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Ws=g("$ZodError",Ks),Gs=g("$ZodError",Ks,{Parent:Error});function Jf(e,t=n=>n.message){const n={},r=[];for(const o of e.issues)o.path.length>0?(n[o.path[0]]=n[o.path[0]]||[],n[o.path[0]].push(t(o))):r.push(t(o));return{formErrors:r,fieldErrors:n}}function Vf(e,t){const n=t||function(s){return s.message},r={_errors:[]},o=s=>{for(const i of s.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(a=>o({issues:a}));else if(i.code==="invalid_key")o({issues:i.issues});else if(i.code==="invalid_element")o({issues:i.issues});else if(i.path.length===0)r._errors.push(n(i));else{let a=r,c=0;for(;c<i.path.length;){const u=i.path[c];c===i.path.length-1?(a[u]=a[u]||{_errors:[]},a[u]._errors.push(n(i))):a[u]=a[u]||{_errors:[]},a=a[u],c++}}};return o(e),r}const Bf=e=>(t,n,r,o)=>{const s=r?Object.assign(r,{async:!1}):{async:!1},i=t._zod.run({value:n,issues:[]},s);if(i instanceof Promise)throw new rt;if(i.issues.length){const a=new(o?.Err??e)(i.issues.map(c=>Pe(c,s,Ie())));throw Bs(a,o?.callee),a}return i.value},Kf=e=>async(t,n,r,o)=>{const s=r?Object.assign(r,{async:!0}):{async:!0};let i=t._zod.run({value:n,issues:[]},s);if(i instanceof Promise&&(i=await i),i.issues.length){const a=new(o?.Err??e)(i.issues.map(c=>Pe(c,s,Ie())));throw Bs(a,o?.callee),a}return i.value},Ys=e=>(t,n,r)=>{const o=r?{...r,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},o);if(s instanceof Promise)throw new rt;return s.issues.length?{success:!1,error:new(e??Ws)(s.issues.map(i=>Pe(i,o,Ie())))}:{success:!0,data:s.value}},Wf=Ys(Gs),Qs=e=>async(t,n,r)=>{const o=r?Object.assign(r,{async:!0}):{async:!0};let s=t._zod.run({value:n,issues:[]},o);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new e(s.issues.map(i=>Pe(i,o,Ie())))}:{success:!0,data:s.value}},Gf=Qs(Gs),Yf=/^[cC][^\s-]{8,}$/,Qf=/^[0-9a-z]+$/,Xf=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,eh=/^[0-9a-vA-V]{20}$/,th=/^[A-Za-z0-9]{27}$/,nh=/^[a-zA-Z0-9_-]{21}$/,rh=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,oh=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Hr=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000)$/,sh=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,ih="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function ah(){return new RegExp(ih,"u")}const ch=/^(?:(?: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])$/,uh=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})$/,lh=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,dh=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,ph=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Xs=/^[A-Za-z0-9_-]*$/,fh=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/,hh=/^\+(?:[0-9]){6,14}[0-9]$/,ei="(?:(?:\\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])))",mh=new RegExp(`^${ei}$`);function ti(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function gh(e){return new RegExp(`^${ti(e)}$`)}function _h(e){const t=ti({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-]\\d{2}:\\d{2})");const r=`${t}(?:${n.join("|")})`;return new RegExp(`^${ei}T(?:${r})$`)}const vh=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},bh=/^\d+$/,yh=/^-?\d+(?:\.\d+)?/i,wh=/true|false/i,kh=/undefined/i,$h=/^[^A-Z]*$/,zh=/^[^a-z]*$/,se=g("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),ni={number:"number",bigint:"bigint",object:"date"},ri=g("$ZodCheckLessThan",(e,t)=>{se.init(e,t);const n=ni[typeof t.value];e._zod.onattach.push(r=>{const o=r._zod.bag,s=(t.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<s&&(t.inclusive?o.maximum=t.value:o.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:"too_big",maximum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),oi=g("$ZodCheckGreaterThan",(e,t)=>{se.init(e,t);const n=ni[typeof t.value];e._zod.onattach.push(r=>{const o=r._zod.bag,s=(t.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>s&&(t.inclusive?o.minimum=t.value:o.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:"too_small",minimum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Sh=g("$ZodCheckMultipleOf",(e,t)=>{se.init(e,t),e._zod.onattach.push(n=>{var r;(r=n._zod.bag).multipleOf??(r.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%t.value===BigInt(0):Cf(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Zh=g("$ZodCheckNumberFormat",(e,t)=>{se.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),r=n?"int":"number",[o,s]=Mf[t.format];e._zod.onattach.push(i=>{const a=i._zod.bag;a.format=t.format,a.minimum=o,a.maximum=s,n&&(a.pattern=bh)}),e._zod.check=i=>{const a=i.value;if(n){if(!Number.isInteger(a)){i.issues.push({expected:r,format:t.format,code:"invalid_type",input:a,inst:e});return}if(!Number.isSafeInteger(a)){a>0?i.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,continue:!t.abort}):i.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,continue:!t.abort});return}}a<o&&i.issues.push({origin:"number",input:a,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),a>s&&i.issues.push({origin:"number",input:a,code:"too_big",maximum:s,inst:e})}}),Th=g("$ZodCheckMaxLength",(e,t)=>{var n;se.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!Qn(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<o&&(r._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{const o=r.value;if(o.length<=t.maximum)return;const i=tr(o);r.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Ih=g("$ZodCheckMinLength",(e,t)=>{var n;se.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!Qn(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(r._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{const o=r.value;if(o.length>=t.minimum)return;const i=tr(o);r.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Ph=g("$ZodCheckLengthEquals",(e,t)=>{var n;se.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!Qn(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag;o.minimum=t.length,o.maximum=t.length,o.length=t.length}),e._zod.check=r=>{const o=r.value,s=o.length;if(s===t.length)return;const i=tr(o),a=s>t.length;r.issues.push({origin:i,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),Bt=g("$ZodCheckStringFormat",(e,t)=>{var n,r;se.init(e,t),e._zod.onattach.push(o=>{const s=o._zod.bag;s.format=t.format,t.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),Rh=g("$ZodCheckRegex",(e,t)=>{Bt.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Eh=g("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=$h),Bt.init(e,t)}),Oh=g("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=zh),Bt.init(e,t)}),xh=g("$ZodCheckIncludes",(e,t)=>{se.init(e,t);const n=ht(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(o=>{const s=o._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(r)}),e._zod.check=o=>{o.value.includes(t.includes,t.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),Ch=g("$ZodCheckStartsWith",(e,t)=>{se.init(e,t);const n=new RegExp(`^${ht(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),Nh=g("$ZodCheckEndsWith",(e,t)=>{se.init(e,t);const n=new RegExp(`.*${ht(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}}),Ah=g("$ZodCheckOverwrite",(e,t)=>{se.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class jh{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const r=t.split(`
|
|
58
|
+
`).filter(i=>i),o=Math.min(...r.map(i=>i.length-i.trimStart().length)),s=r.map(i=>i.slice(o)).map(i=>" ".repeat(this.indent*2)+i);for(const i of s)this.content.push(i)}compile(){const t=Function,n=this?.args,o=[...(this?.content??[""]).map(s=>` ${s}`)];return new t(...n,o.join(`
|
|
59
|
+
`))}}const Mh={major:4,minor:0,patch:0},j=g("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Mh;const r=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&r.unshift(e);for(const o of r)for(const s of o._zod.onattach)s(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const o=(s,i,a)=>{let c=Xe(s),u;for(const l of i){if(l._zod.def.when){if(!l._zod.def.when(s))continue}else if(c)continue;const d=s.issues.length,p=l._zod.check(s);if(p instanceof Promise&&a?.async===!1)throw new rt;if(u||p instanceof Promise)u=(u??Promise.resolve()).then(async()=>{await p,s.issues.length!==d&&(c||(c=Xe(s,d)))});else{if(s.issues.length===d)continue;c||(c=Xe(s,d))}}return u?u.then(()=>s):s};e._zod.run=(s,i)=>{const a=e._zod.parse(s,i);if(a instanceof Promise){if(i.async===!1)throw new rt;return a.then(c=>o(c,r,i))}return o(a,r,i)}}e["~standard"]={validate:o=>{try{const s=Wf(e,o);return s.success?{value:s.data}:{issues:s.error?.issues}}catch{return Gf(e,o).then(i=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:"zod",version:1}}),nr=g("$ZodString",(e,t)=>{j.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??vh(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),J=g("$ZodStringFormat",(e,t)=>{Bt.init(e,t),nr.init(e,t)}),Dh=g("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=oh),J.init(e,t)}),qh=g("$ZodUUID",(e,t)=>{if(t.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Hr(r))}else t.pattern??(t.pattern=Hr());J.init(e,t)}),Uh=g("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=sh),J.init(e,t)}),Lh=g("$ZodURL",(e,t)=>{J.init(e,t),e._zod.check=n=>{try{const r=n.value,o=new URL(r),s=o.href;t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(o.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:fh.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),!r.endsWith("/")&&s.endsWith("/")?n.value=s.slice(0,-1):n.value=s;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),Fh=g("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=ah()),J.init(e,t)}),Hh=g("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=nh),J.init(e,t)}),Jh=g("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Yf),J.init(e,t)}),Vh=g("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Qf),J.init(e,t)}),Bh=g("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Xf),J.init(e,t)}),Kh=g("$ZodXID",(e,t)=>{t.pattern??(t.pattern=eh),J.init(e,t)}),Wh=g("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=th),J.init(e,t)}),Gh=g("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=_h(t)),J.init(e,t)}),Yh=g("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=mh),J.init(e,t)}),Qh=g("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=gh(t)),J.init(e,t)}),Xh=g("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=rh),J.init(e,t)}),em=g("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=ch),J.init(e,t),e._zod.onattach.push(n=>{const r=n._zod.bag;r.format="ipv4"})}),tm=g("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=uh),J.init(e,t),e._zod.onattach.push(n=>{const r=n._zod.bag;r.format="ipv6"}),e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),nm=g("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=lh),J.init(e,t)}),rm=g("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=dh),J.init(e,t),e._zod.check=n=>{const[r,o]=n.value.split("/");try{if(!o)throw new Error;const s=Number(o);if(`${s}`!==o)throw new Error;if(s<0||s>128)throw new Error;new URL(`http://[${r}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function si(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const om=g("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=ph),J.init(e,t),e._zod.onattach.push(n=>{n._zod.bag.contentEncoding="base64"}),e._zod.check=n=>{si(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function sm(e){if(!Xs.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return si(n)}const im=g("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Xs),J.init(e,t),e._zod.onattach.push(n=>{n._zod.bag.contentEncoding="base64url"}),e._zod.check=n=>{sm(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),am=g("$ZodE164",(e,t)=>{t.pattern??(t.pattern=hh),J.init(e,t)});function cm(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[r]=n;if(!r)return!1;const o=JSON.parse(atob(r));return!("typ"in o&&o?.typ!=="JWT"||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}}const um=g("$ZodJWT",(e,t)=>{J.init(e,t),e._zod.check=n=>{cm(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),ii=g("$ZodNumber",(e,t)=>{j.init(e,t),e._zod.pattern=e._zod.bag.pattern??yh,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const o=n.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return n;const s=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...s?{received:s}:{}}),n}}),lm=g("$ZodNumber",(e,t)=>{Zh.init(e,t),ii.init(e,t)}),dm=g("$ZodBoolean",(e,t)=>{j.init(e,t),e._zod.pattern=wh,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}const o=n.value;return typeof o=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),n}}),pm=g("$ZodUndefined",(e,t)=>{j.init(e,t),e._zod.pattern=kh,e._zod.values=new Set([void 0]),e._zod.optin="optional",e._zod.optout="optional",e._zod.parse=(n,r)=>{const o=n.value;return typeof o>"u"||n.issues.push({expected:"undefined",code:"invalid_type",input:o,inst:e}),n}}),fm=g("$ZodAny",(e,t)=>{j.init(e,t),e._zod.parse=n=>n}),hm=g("$ZodUnknown",(e,t)=>{j.init(e,t),e._zod.parse=n=>n}),mm=g("$ZodNever",(e,t)=>{j.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function Jr(e,t,n){e.issues.length&&t.issues.push(...xe(n,e.issues)),t.value[n]=e.value}const gm=g("$ZodArray",(e,t)=>{j.init(e,t),e._zod.parse=(n,r)=>{const o=n.value;if(!Array.isArray(o))return n.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),n;n.value=Array(o.length);const s=[];for(let i=0;i<o.length;i++){const a=o[i],c=t.element._zod.run({value:a,issues:[]},r);c instanceof Promise?s.push(c.then(u=>Jr(u,n,i))):Jr(c,n,i)}return s.length?Promise.all(s).then(()=>n):n}});function $t(e,t,n){e.issues.length&&t.issues.push(...xe(n,e.issues)),t.value[n]=e.value}function Vr(e,t,n,r){e.issues.length?r[n]===void 0?n in r?t.value[n]=void 0:t.value[n]=e.value:t.issues.push(...xe(n,e.issues)):e.value===void 0?n in r&&(t.value[n]=void 0):t.value[n]=e.value}const _m=g("$ZodObject",(e,t)=>{j.init(e,t);const n=Vs(()=>{const d=Object.keys(t.shape);for(const h of d)if(!(t.shape[h]instanceof j))throw new Error(`Invalid element at key "${h}": expected a Zod schema`);const p=jf(t.shape);return{shape:t.shape,keys:d,keySet:new Set(d),numKeys:d.length,optionalKeys:new Set(p)}});q(e._zod,"propValues",()=>{const d=t.shape,p={};for(const h in d){const _=d[h]._zod;if(_.values){p[h]??(p[h]=new Set);for(const w of _.values)p[h].add(w)}}return p});const r=d=>{const p=new jh(["shape","payload","ctx"]),h=n.value,_=Z=>{const T=Ke(Z);return`shape[${T}]._zod.run({ value: input[${T}], issues: [] }, ctx)`};p.write("const input = payload.value;");const w=Object.create(null);let S=0;for(const Z of h.keys)w[Z]=`key_${S++}`;p.write("const newResult = {}");for(const Z of h.keys)if(h.optionalKeys.has(Z)){const T=w[Z];p.write(`const ${T} = ${_(Z)};`);const O=Ke(Z);p.write(`
|
|
60
|
+
if (${T}.issues.length) {
|
|
61
|
+
if (input[${O}] === undefined) {
|
|
62
|
+
if (${O} in input) {
|
|
63
|
+
newResult[${O}] = undefined;
|
|
64
|
+
}
|
|
65
|
+
} else {
|
|
66
|
+
payload.issues = payload.issues.concat(
|
|
67
|
+
${T}.issues.map((iss) => ({
|
|
68
|
+
...iss,
|
|
69
|
+
path: iss.path ? [${O}, ...iss.path] : [${O}],
|
|
70
|
+
}))
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
} else if (${T}.value === undefined) {
|
|
74
|
+
if (${O} in input) newResult[${O}] = undefined;
|
|
75
|
+
} else {
|
|
76
|
+
newResult[${O}] = ${T}.value;
|
|
77
|
+
}
|
|
78
|
+
`)}else{const T=w[Z];p.write(`const ${T} = ${_(Z)};`),p.write(`
|
|
79
|
+
if (${T}.issues.length) payload.issues = payload.issues.concat(${T}.issues.map(iss => ({
|
|
80
|
+
...iss,
|
|
81
|
+
path: iss.path ? [${Ke(Z)}, ...iss.path] : [${Ke(Z)}]
|
|
82
|
+
})));`),p.write(`newResult[${Ke(Z)}] = ${T}.value`)}p.write("payload.value = newResult;"),p.write("return payload;");const I=p.compile();return(Z,T)=>I(d,Z,T)};let o;const s=mn,i=!Js.jitless,c=i&&Nf.value,u=t.catchall;let l;e._zod.parse=(d,p)=>{l??(l=n.value);const h=d.value;if(!s(h))return d.issues.push({expected:"object",code:"invalid_type",input:h,inst:e}),d;const _=[];if(i&&c&&p?.async===!1&&p.jitless!==!0)o||(o=r(t.shape)),d=o(d,p);else{d.value={};const T=l.shape;for(const O of l.keys){const M=T[O],x=M._zod.run({value:h[O],issues:[]},p),ie=M._zod.optin==="optional"&&M._zod.optout==="optional";x instanceof Promise?_.push(x.then(je=>ie?Vr(je,d,O,h):$t(je,d,O))):ie?Vr(x,d,O,h):$t(x,d,O)}}if(!u)return _.length?Promise.all(_).then(()=>d):d;const w=[],S=l.keySet,I=u._zod,Z=I.def.type;for(const T of Object.keys(h)){if(S.has(T))continue;if(Z==="never"){w.push(T);continue}const O=I.run({value:h[T],issues:[]},p);O instanceof Promise?_.push(O.then(M=>$t(M,d,T))):$t(O,d,T)}return w.length&&d.issues.push({code:"unrecognized_keys",keys:w,input:h,inst:e}),_.length?Promise.all(_).then(()=>d):d}});function Br(e,t,n,r){for(const o of e)if(o.issues.length===0)return t.value=o.value,t;return t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(o=>o.issues.map(s=>Pe(s,r,Ie())))}),t}const vm=g("$ZodUnion",(e,t)=>{j.init(e,t),q(e._zod,"optin",()=>t.options.some(n=>n._zod.optin==="optional")?"optional":void 0),q(e._zod,"optout",()=>t.options.some(n=>n._zod.optout==="optional")?"optional":void 0),q(e._zod,"values",()=>{if(t.options.every(n=>n._zod.values))return new Set(t.options.flatMap(n=>Array.from(n._zod.values)))}),q(e._zod,"pattern",()=>{if(t.options.every(n=>n._zod.pattern)){const n=t.options.map(r=>r._zod.pattern);return new RegExp(`^(${n.map(r=>Xn(r.source)).join("|")})$`)}}),e._zod.parse=(n,r)=>{let o=!1;const s=[];for(const i of t.options){const a=i._zod.run({value:n.value,issues:[]},r);if(a instanceof Promise)s.push(a),o=!0;else{if(a.issues.length===0)return a;s.push(a)}}return o?Promise.all(s).then(i=>Br(i,n,e,r)):Br(s,n,e,r)}}),bm=g("$ZodIntersection",(e,t)=>{j.init(e,t),e._zod.parse=(n,r)=>{const o=n.value,s=t.left._zod.run({value:o,issues:[]},r),i=t.right._zod.run({value:o,issues:[]},r);return s instanceof Promise||i instanceof Promise?Promise.all([s,i]).then(([c,u])=>Kr(n,c,u)):Kr(n,s,i)}});function gn(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(At(e)&&At(t)){const n=Object.keys(t),r=Object.keys(e).filter(s=>n.indexOf(s)!==-1),o={...e,...t};for(const s of r){const i=gn(e[s],t[s]);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};o[s]=i.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<e.length;r++){const o=e[r],s=t[r],i=gn(o,s);if(!i.valid)return{valid:!1,mergeErrorPath:[r,...i.mergeErrorPath]};n.push(i.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Kr(e,t,n){if(t.issues.length&&e.issues.push(...t.issues),n.issues.length&&e.issues.push(...n.issues),Xe(e))return e;const r=gn(t.value,n.value);if(!r.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(r.mergeErrorPath)}`);return e.value=r.data,e}const ym=g("$ZodRecord",(e,t)=>{j.init(e,t),e._zod.parse=(n,r)=>{const o=n.value;if(!At(o))return n.issues.push({expected:"record",code:"invalid_type",input:o,inst:e}),n;const s=[];if(t.keyType._zod.values){const i=t.keyType._zod.values;n.value={};for(const c of i)if(typeof c=="string"||typeof c=="number"||typeof c=="symbol"){const u=t.valueType._zod.run({value:o[c],issues:[]},r);u instanceof Promise?s.push(u.then(l=>{l.issues.length&&n.issues.push(...xe(c,l.issues)),n.value[c]=l.value})):(u.issues.length&&n.issues.push(...xe(c,u.issues)),n.value[c]=u.value)}let a;for(const c in o)i.has(c)||(a=a??[],a.push(c));a&&a.length>0&&n.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:a})}else{n.value={};for(const i of Reflect.ownKeys(o)){if(i==="__proto__")continue;const a=t.keyType._zod.run({value:i,issues:[]},r);if(a instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(a.issues.length){n.issues.push({origin:"record",code:"invalid_key",issues:a.issues.map(u=>Pe(u,r,Ie())),input:i,path:[i],inst:e}),n.value[a.value]=a.value;continue}const c=t.valueType._zod.run({value:o[i],issues:[]},r);c instanceof Promise?s.push(c.then(u=>{u.issues.length&&n.issues.push(...xe(i,u.issues)),n.value[a.value]=u.value})):(c.issues.length&&n.issues.push(...xe(i,c.issues)),n.value[a.value]=c.value)}}return s.length?Promise.all(s).then(()=>n):n}}),wm=g("$ZodEnum",(e,t)=>{j.init(e,t);const n=Of(t.entries);e._zod.values=new Set(n),e._zod.pattern=new RegExp(`^(${n.filter(r=>Af.has(typeof r)).map(r=>typeof r=="string"?ht(r):r.toString()).join("|")})$`),e._zod.parse=(r,o)=>{const s=r.value;return e._zod.values.has(s)||r.issues.push({code:"invalid_value",values:n,input:s,inst:e}),r}}),km=g("$ZodLiteral",(e,t)=>{j.init(e,t),e._zod.values=new Set(t.values),e._zod.pattern=new RegExp(`^(${t.values.map(n=>typeof n=="string"?ht(n):n?n.toString():String(n)).join("|")})$`),e._zod.parse=(n,r)=>{const o=n.value;return e._zod.values.has(o)||n.issues.push({code:"invalid_value",values:t.values,input:o,inst:e}),n}}),$m=g("$ZodTransform",(e,t)=>{j.init(e,t),e._zod.parse=(n,r)=>{const o=t.transform(n.value,n);if(r.async)return(o instanceof Promise?o:Promise.resolve(o)).then(i=>(n.value=i,n));if(o instanceof Promise)throw new rt;return n.value=o,n}}),zm=g("$ZodOptional",(e,t)=>{j.init(e,t),e._zod.optin="optional",e._zod.optout="optional",q(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),q(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Xn(n.source)})?$`):void 0}),e._zod.parse=(n,r)=>t.innerType._zod.optin==="optional"?t.innerType._zod.run(n,r):n.value===void 0?n:t.innerType._zod.run(n,r)}),Sm=g("$ZodNullable",(e,t)=>{j.init(e,t),q(e._zod,"optin",()=>t.innerType._zod.optin),q(e._zod,"optout",()=>t.innerType._zod.optout),q(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Xn(n.source)}|null)$`):void 0}),q(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>n.value===null?n:t.innerType._zod.run(n,r)}),Zm=g("$ZodDefault",(e,t)=>{j.init(e,t),e._zod.optin="optional",q(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(n.value===void 0)return n.value=t.defaultValue,n;const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(s=>Wr(s,t)):Wr(o,t)}});function Wr(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const Tm=g("$ZodPrefault",(e,t)=>{j.init(e,t),e._zod.optin="optional",q(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>(n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,r))}),Im=g("$ZodNonOptional",(e,t)=>{j.init(e,t),q(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(r=>r!==void 0)):void 0}),e._zod.parse=(n,r)=>{const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(s=>Gr(s,e)):Gr(o,e)}});function Gr(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const Pm=g("$ZodCatch",(e,t)=>{j.init(e,t),e._zod.optin="optional",q(e._zod,"optout",()=>t.innerType._zod.optout),q(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(s=>(n.value=s.value,s.issues.length&&(n.value=t.catchValue({...n,error:{issues:s.issues.map(i=>Pe(i,r,Ie()))},input:n.value}),n.issues=[]),n)):(n.value=o.value,o.issues.length&&(n.value=t.catchValue({...n,error:{issues:o.issues.map(s=>Pe(s,r,Ie()))},input:n.value}),n.issues=[]),n)}}),Rm=g("$ZodPipe",(e,t)=>{j.init(e,t),q(e._zod,"values",()=>t.in._zod.values),q(e._zod,"optin",()=>t.in._zod.optin),q(e._zod,"optout",()=>t.out._zod.optout),e._zod.parse=(n,r)=>{const o=t.in._zod.run(n,r);return o instanceof Promise?o.then(s=>Yr(s,t,r)):Yr(o,t,r)}});function Yr(e,t,n){return Xe(e)?e:t.out._zod.run({value:e.value,issues:e.issues},n)}const Em=g("$ZodReadonly",(e,t)=>{j.init(e,t),q(e._zod,"propValues",()=>t.innerType._zod.propValues),q(e._zod,"values",()=>t.innerType._zod.values),q(e._zod,"optin",()=>t.innerType._zod.optin),q(e._zod,"optout",()=>t.innerType._zod.optout),e._zod.parse=(n,r)=>{const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(Qr):Qr(o)}});function Qr(e){return e.value=Object.freeze(e.value),e}const Om=g("$ZodCustom",(e,t)=>{se.init(e,t),j.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=n=>{const r=n.value,o=t.fn(r);if(o instanceof Promise)return o.then(s=>Xr(s,n,r,e));Xr(o,n,r,e)}});function Xr(e,t,n,r){if(!e){const o={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(o.params=r._zod.def.params),t.issues.push(ot(o))}}class xm{constructor(){this._map=new Map,this._idmap=new Map}add(t,...n){const r=n[0];if(this._map.set(t,r),r&&typeof r=="object"&&"id"in r){if(this._idmap.has(r.id))throw new Error(`ID ${r.id} already exists in the registry`);this._idmap.set(r.id,t)}return this}clear(){return this._map=new Map,this._idmap=new Map,this}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const r={...this.get(n)??{}};return delete r.id,{...r,...this._map.get(t)}}return this._map.get(t)}has(t){return this._map.has(t)}}function Cm(){return new xm}const zt=Cm();function Nm(e,t){return new e({type:"string",...z(t)})}function Am(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...z(t)})}function eo(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...z(t)})}function jm(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...z(t)})}function Mm(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...z(t)})}function Dm(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...z(t)})}function qm(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...z(t)})}function Um(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...z(t)})}function Lm(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...z(t)})}function Fm(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...z(t)})}function Hm(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...z(t)})}function Jm(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...z(t)})}function Vm(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...z(t)})}function Bm(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...z(t)})}function Km(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...z(t)})}function Wm(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...z(t)})}function Gm(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...z(t)})}function Ym(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...z(t)})}function Qm(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...z(t)})}function Xm(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...z(t)})}function eg(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...z(t)})}function tg(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...z(t)})}function ng(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...z(t)})}function rg(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...z(t)})}function og(e,t){return new e({type:"string",format:"date",check:"string_format",...z(t)})}function sg(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...z(t)})}function ig(e,t){return new e({type:"string",format:"duration",check:"string_format",...z(t)})}function ag(e,t){return new e({type:"number",checks:[],...z(t)})}function cg(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...z(t)})}function ug(e,t){return new e({type:"boolean",...z(t)})}function lg(e,t){return new e({type:"undefined",...z(t)})}function dg(e){return new e({type:"any"})}function pg(e){return new e({type:"unknown"})}function fg(e,t){return new e({type:"never",...z(t)})}function to(e,t){return new ri({check:"less_than",...z(t),value:e,inclusive:!1})}function nn(e,t){return new ri({check:"less_than",...z(t),value:e,inclusive:!0})}function no(e,t){return new oi({check:"greater_than",...z(t),value:e,inclusive:!1})}function rn(e,t){return new oi({check:"greater_than",...z(t),value:e,inclusive:!0})}function ro(e,t){return new Sh({check:"multiple_of",...z(t),value:e})}function ai(e,t){return new Th({check:"max_length",...z(t),maximum:e})}function jt(e,t){return new Ih({check:"min_length",...z(t),minimum:e})}function ci(e,t){return new Ph({check:"length_equals",...z(t),length:e})}function hg(e,t){return new Rh({check:"string_format",format:"regex",...z(t),pattern:e})}function mg(e){return new Eh({check:"string_format",format:"lowercase",...z(e)})}function gg(e){return new Oh({check:"string_format",format:"uppercase",...z(e)})}function _g(e,t){return new xh({check:"string_format",format:"includes",...z(t),includes:e})}function vg(e,t){return new Ch({check:"string_format",format:"starts_with",...z(t),prefix:e})}function bg(e,t){return new Nh({check:"string_format",format:"ends_with",...z(t),suffix:e})}function mt(e){return new Ah({check:"overwrite",tx:e})}function yg(e){return mt(t=>t.normalize(e))}function wg(){return mt(e=>e.trim())}function kg(){return mt(e=>e.toLowerCase())}function $g(){return mt(e=>e.toUpperCase())}function zg(e,t,n){return new e({type:"array",element:t,...z(n)})}function Sg(e,t,n){return new e({type:"custom",check:"custom",fn:t,...z(n)})}const Zg=g("ZodISODateTime",(e,t)=>{Gh.init(e,t),G.init(e,t)});function Tg(e){return rg(Zg,e)}const Ig=g("ZodISODate",(e,t)=>{Yh.init(e,t),G.init(e,t)});function Pg(e){return og(Ig,e)}const Rg=g("ZodISOTime",(e,t)=>{Qh.init(e,t),G.init(e,t)});function Eg(e){return sg(Rg,e)}const Og=g("ZodISODuration",(e,t)=>{Xh.init(e,t),G.init(e,t)});function xg(e){return ig(Og,e)}const Cg=(e,t)=>{Ws.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>Vf(e,n)},flatten:{value:n=>Jf(e,n)},addIssue:{value:n=>e.issues.push(n)},addIssues:{value:n=>e.issues.push(...n)},isEmpty:{get(){return e.issues.length===0}}})},Kt=g("ZodError",Cg,{Parent:Error}),Ng=Bf(Kt),Ag=Kf(Kt),jg=Ys(Kt),Mg=Qs(Kt),V=g("ZodType",(e,t)=>(j.init(e,t),e.def=t,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone({...t,checks:[...t.checks??[],...n.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),e.clone=(n,r)=>Ae(e,n,r),e.brand=()=>e,e.register=((n,r)=>(n.add(e,r),e)),e.parse=(n,r)=>Ng(e,n,r,{callee:e.parse}),e.safeParse=(n,r)=>jg(e,n,r),e.parseAsync=async(n,r)=>Ag(e,n,r,{callee:e.parseAsync}),e.safeParseAsync=async(n,r)=>Mg(e,n,r),e.spa=e.safeParseAsync,e.refine=(n,r)=>e.check(O_(n,r)),e.superRefine=n=>e.check(x_(n)),e.overwrite=n=>e.check(mt(n)),e.optional=()=>io(e),e.nullable=()=>ao(e),e.nullish=()=>io(ao(e)),e.nonoptional=n=>z_(e,n),e.array=()=>de(e),e.or=n=>le([e,n]),e.and=n=>f_(e,n),e.transform=n=>co(e,v_(n)),e.default=n=>w_(e,n),e.prefault=n=>$_(e,n),e.catch=n=>Z_(e,n),e.pipe=n=>co(e,n),e.readonly=()=>P_(e),e.describe=n=>{const r=e.clone();return zt.add(r,{description:n}),r},Object.defineProperty(e,"description",{get(){return zt.get(e)?.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return zt.get(e);const r=e.clone();return zt.add(r,n[0]),r},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),ui=g("_ZodString",(e,t)=>{nr.init(e,t),V.init(e,t);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...r)=>e.check(hg(...r)),e.includes=(...r)=>e.check(_g(...r)),e.startsWith=(...r)=>e.check(vg(...r)),e.endsWith=(...r)=>e.check(bg(...r)),e.min=(...r)=>e.check(jt(...r)),e.max=(...r)=>e.check(ai(...r)),e.length=(...r)=>e.check(ci(...r)),e.nonempty=(...r)=>e.check(jt(1,...r)),e.lowercase=r=>e.check(mg(r)),e.uppercase=r=>e.check(gg(r)),e.trim=()=>e.check(wg()),e.normalize=(...r)=>e.check(yg(...r)),e.toLowerCase=()=>e.check(kg()),e.toUpperCase=()=>e.check($g())}),Dg=g("ZodString",(e,t)=>{nr.init(e,t),ui.init(e,t),e.email=n=>e.check(Am(qg,n)),e.url=n=>e.check(Um(Ug,n)),e.jwt=n=>e.check(ng(n_,n)),e.emoji=n=>e.check(Lm(Lg,n)),e.guid=n=>e.check(eo(oo,n)),e.uuid=n=>e.check(jm(St,n)),e.uuidv4=n=>e.check(Mm(St,n)),e.uuidv6=n=>e.check(Dm(St,n)),e.uuidv7=n=>e.check(qm(St,n)),e.nanoid=n=>e.check(Fm(Fg,n)),e.guid=n=>e.check(eo(oo,n)),e.cuid=n=>e.check(Hm(Hg,n)),e.cuid2=n=>e.check(Jm(Jg,n)),e.ulid=n=>e.check(Vm(Vg,n)),e.base64=n=>e.check(Xm(Xg,n)),e.base64url=n=>e.check(eg(e_,n)),e.xid=n=>e.check(Bm(Bg,n)),e.ksuid=n=>e.check(Km(Kg,n)),e.ipv4=n=>e.check(Wm(Wg,n)),e.ipv6=n=>e.check(Gm(Gg,n)),e.cidrv4=n=>e.check(Ym(Yg,n)),e.cidrv6=n=>e.check(Qm(Qg,n)),e.e164=n=>e.check(tg(t_,n)),e.datetime=n=>e.check(Tg(n)),e.date=n=>e.check(Pg(n)),e.time=n=>e.check(Eg(n)),e.duration=n=>e.check(xg(n))});function A(e){return Nm(Dg,e)}const G=g("ZodStringFormat",(e,t)=>{J.init(e,t),ui.init(e,t)}),qg=g("ZodEmail",(e,t)=>{Uh.init(e,t),G.init(e,t)}),oo=g("ZodGUID",(e,t)=>{Dh.init(e,t),G.init(e,t)}),St=g("ZodUUID",(e,t)=>{qh.init(e,t),G.init(e,t)}),Ug=g("ZodURL",(e,t)=>{Lh.init(e,t),G.init(e,t)}),Lg=g("ZodEmoji",(e,t)=>{Fh.init(e,t),G.init(e,t)}),Fg=g("ZodNanoID",(e,t)=>{Hh.init(e,t),G.init(e,t)}),Hg=g("ZodCUID",(e,t)=>{Jh.init(e,t),G.init(e,t)}),Jg=g("ZodCUID2",(e,t)=>{Vh.init(e,t),G.init(e,t)}),Vg=g("ZodULID",(e,t)=>{Bh.init(e,t),G.init(e,t)}),Bg=g("ZodXID",(e,t)=>{Kh.init(e,t),G.init(e,t)}),Kg=g("ZodKSUID",(e,t)=>{Wh.init(e,t),G.init(e,t)}),Wg=g("ZodIPv4",(e,t)=>{em.init(e,t),G.init(e,t)}),Gg=g("ZodIPv6",(e,t)=>{tm.init(e,t),G.init(e,t)}),Yg=g("ZodCIDRv4",(e,t)=>{nm.init(e,t),G.init(e,t)}),Qg=g("ZodCIDRv6",(e,t)=>{rm.init(e,t),G.init(e,t)}),Xg=g("ZodBase64",(e,t)=>{om.init(e,t),G.init(e,t)}),e_=g("ZodBase64URL",(e,t)=>{im.init(e,t),G.init(e,t)}),t_=g("ZodE164",(e,t)=>{am.init(e,t),G.init(e,t)}),n_=g("ZodJWT",(e,t)=>{um.init(e,t),G.init(e,t)}),li=g("ZodNumber",(e,t)=>{ii.init(e,t),V.init(e,t),e.gt=(r,o)=>e.check(no(r,o)),e.gte=(r,o)=>e.check(rn(r,o)),e.min=(r,o)=>e.check(rn(r,o)),e.lt=(r,o)=>e.check(to(r,o)),e.lte=(r,o)=>e.check(nn(r,o)),e.max=(r,o)=>e.check(nn(r,o)),e.int=r=>e.check(so(r)),e.safe=r=>e.check(so(r)),e.positive=r=>e.check(no(0,r)),e.nonnegative=r=>e.check(rn(0,r)),e.negative=r=>e.check(to(0,r)),e.nonpositive=r=>e.check(nn(0,r)),e.multipleOf=(r,o)=>e.check(ro(r,o)),e.step=(r,o)=>e.check(ro(r,o)),e.finite=()=>e;const n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function _e(e){return ag(li,e)}const r_=g("ZodNumberFormat",(e,t)=>{lm.init(e,t),li.init(e,t)});function so(e){return cg(r_,e)}const o_=g("ZodBoolean",(e,t)=>{dm.init(e,t),V.init(e,t)});function we(e){return ug(o_,e)}const s_=g("ZodUndefined",(e,t)=>{pm.init(e,t),V.init(e,t)});function _n(e){return lg(s_,e)}const i_=g("ZodAny",(e,t)=>{fm.init(e,t),V.init(e,t)});function di(){return dg(i_)}const a_=g("ZodUnknown",(e,t)=>{hm.init(e,t),V.init(e,t)});function He(){return pg(a_)}const c_=g("ZodNever",(e,t)=>{mm.init(e,t),V.init(e,t)});function vn(e){return fg(c_,e)}const u_=g("ZodArray",(e,t)=>{gm.init(e,t),V.init(e,t),e.element=t.element,e.min=(n,r)=>e.check(jt(n,r)),e.nonempty=n=>e.check(jt(1,n)),e.max=(n,r)=>e.check(ai(n,r)),e.length=(n,r)=>e.check(ci(n,r)),e.unwrap=()=>e.element});function de(e,t){return zg(u_,e,t)}const l_=g("ZodObject",(e,t)=>{_m.init(e,t),V.init(e,t),q(e,"shape",()=>t.shape),e.keyof=()=>m_(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:He()}),e.loose=()=>e.clone({...e._zod.def,catchall:He()}),e.strict=()=>e.clone({...e._zod.def,catchall:vn()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>Uf(e,n),e.merge=n=>Lf(e,n),e.pick=n=>Df(e,n),e.omit=n=>qf(e,n),e.partial=(...n)=>Ff(pi,e,n[0]),e.required=(...n)=>Hf(fi,e,n[0])});function b(e,t){const n={type:"object",get shape(){return er(this,"shape",{...e}),this.shape},...z(t)};return new l_(n)}const d_=g("ZodUnion",(e,t)=>{vm.init(e,t),V.init(e,t),e.options=t.options});function le(e,t){return new d_({type:"union",options:e,...z(t)})}const p_=g("ZodIntersection",(e,t)=>{bm.init(e,t),V.init(e,t)});function f_(e,t){return new p_({type:"intersection",left:e,right:t})}const h_=g("ZodRecord",(e,t)=>{ym.init(e,t),V.init(e,t),e.keyType=t.keyType,e.valueType=t.valueType});function ke(e,t,n){return new h_({type:"record",keyType:e,valueType:t,...z(n)})}const bn=g("ZodEnum",(e,t)=>{wm.init(e,t),V.init(e,t),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(r,o)=>{const s={};for(const i of r)if(n.has(i))s[i]=t.entries[i];else throw new Error(`Key ${i} not found in enum`);return new bn({...t,checks:[],...z(o),entries:s})},e.exclude=(r,o)=>{const s={...t.entries};for(const i of r)if(n.has(i))delete s[i];else throw new Error(`Key ${i} not found in enum`);return new bn({...t,checks:[],...z(o),entries:s})}});function m_(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new bn({type:"enum",entries:n,...z(t)})}const g_=g("ZodLiteral",(e,t)=>{km.init(e,t),V.init(e,t),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function v(e,t){return new g_({type:"literal",values:Array.isArray(e)?e:[e],...z(t)})}const __=g("ZodTransform",(e,t)=>{$m.init(e,t),V.init(e,t),e._zod.parse=(n,r)=>{n.addIssue=s=>{if(typeof s=="string")n.issues.push(ot(s,n.value,t));else{const i=s;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=n.value),i.inst??(i.inst=e),i.continue??(i.continue=!0),n.issues.push(ot(i))}};const o=t.transform(n.value,n);return o instanceof Promise?o.then(s=>(n.value=s,n)):(n.value=o,n)}});function v_(e){return new __({type:"transform",transform:e})}const pi=g("ZodOptional",(e,t)=>{zm.init(e,t),V.init(e,t),e.unwrap=()=>e._zod.def.innerType});function io(e){return new pi({type:"optional",innerType:e})}const b_=g("ZodNullable",(e,t)=>{Sm.init(e,t),V.init(e,t),e.unwrap=()=>e._zod.def.innerType});function ao(e){return new b_({type:"nullable",innerType:e})}const y_=g("ZodDefault",(e,t)=>{Zm.init(e,t),V.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function w_(e,t){return new y_({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():t}})}const k_=g("ZodPrefault",(e,t)=>{Tm.init(e,t),V.init(e,t),e.unwrap=()=>e._zod.def.innerType});function $_(e,t){return new k_({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():t}})}const fi=g("ZodNonOptional",(e,t)=>{Im.init(e,t),V.init(e,t),e.unwrap=()=>e._zod.def.innerType});function z_(e,t){return new fi({type:"nonoptional",innerType:e,...z(t)})}const S_=g("ZodCatch",(e,t)=>{Pm.init(e,t),V.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Z_(e,t){return new S_({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const T_=g("ZodPipe",(e,t)=>{Rm.init(e,t),V.init(e,t),e.in=t.in,e.out=t.out});function co(e,t){return new T_({type:"pipe",in:e,out:t})}const I_=g("ZodReadonly",(e,t)=>{Em.init(e,t),V.init(e,t)});function P_(e){return new I_({type:"readonly",innerType:e})}const R_=g("ZodCustom",(e,t)=>{Om.init(e,t),V.init(e,t)});function E_(e){const t=new se({check:"custom"});return t._zod.check=e,t}function O_(e,t={}){return Sg(R_,e,t)}function x_(e){const t=E_(n=>(n.addIssue=r=>{if(typeof r=="string")n.issues.push(ot(r,n.value,t._zod.def));else{const o=r;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=n.value),o.inst??(o.inst=t),o.continue??(o.continue=!t._zod.def.abort),n.issues.push(ot(o))}},e(n.value,n)));return t}(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,n)=>(typeof require<"u"?require:t)[n]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});class C_ extends Ef{_registeredMethods=new Set;_eventSlots=new Map;onEventDispatch(t,n){}_ensureEventSlot(t){let n=this._eventSlots.get(t);if(!n){let r=this.eventSchemas[t];if(!r)throw Error(`Unknown event: ${String(t)}`);n={listeners:[]},this._eventSlots.set(t,n);let o=r.shape.method.value;this._registeredMethods.add(o);let s=n;super.setNotificationHandler(r,i=>{let a=i.params;this.onEventDispatch(t,a),s.onHandler?.(a);for(let c of[...s.listeners])c(a)})}return n}setEventHandler(t,n){let r=this._ensureEventSlot(t);r.onHandler&&n&&console.warn(`[MCP Apps] on${String(t)} handler replaced. Use addEventListener("${String(t)}", …) to add multiple listeners without replacing.`),r.onHandler=n}getEventHandler(t){return this._eventSlots.get(t)?.onHandler}addEventListener(t,n){this._ensureEventSlot(t).listeners.push(n)}removeEventListener(t,n){let r=this._eventSlots.get(t);if(!r)return;let o=r.listeners.indexOf(n);o!==-1&&r.listeners.splice(o,1)}setRequestHandler=(t,n)=>{this._assertMethodNotRegistered(t,"setRequestHandler"),super.setRequestHandler(t,n)};setNotificationHandler=(t,n)=>{this._assertMethodNotRegistered(t,"setNotificationHandler"),super.setNotificationHandler(t,n)};warnIfRequestHandlerReplaced(t,n,r){n&&r&&console.warn(`[MCP Apps] ${t} handler replaced. Previous handler will no longer be called.`)}replaceRequestHandler=(t,n)=>{let r=t.shape.method.value;this._registeredMethods.add(r),super.setRequestHandler(t,n)};_assertMethodNotRegistered(t,n){let r=t.shape.method.value;if(this._registeredMethods.has(r))throw Error(`Handler for "${r}" already registered (via ${n}). Use addEventListener() to attach multiple listeners, or the on* setter for replace semantics.`);this._registeredMethods.add(r)}}var hi="2026-01-26",N_="ui/notifications/tool-input-partial",A_=le([v("light"),v("dark")]).describe("Color theme preference for the host environment."),st=le([v("inline"),v("fullscreen"),v("pip")]).describe("Display mode for UI presentation."),j_=le([v("--color-background-primary"),v("--color-background-secondary"),v("--color-background-tertiary"),v("--color-background-inverse"),v("--color-background-ghost"),v("--color-background-info"),v("--color-background-danger"),v("--color-background-success"),v("--color-background-warning"),v("--color-background-disabled"),v("--color-text-primary"),v("--color-text-secondary"),v("--color-text-tertiary"),v("--color-text-inverse"),v("--color-text-ghost"),v("--color-text-info"),v("--color-text-danger"),v("--color-text-success"),v("--color-text-warning"),v("--color-text-disabled"),v("--color-border-primary"),v("--color-border-secondary"),v("--color-border-tertiary"),v("--color-border-inverse"),v("--color-border-ghost"),v("--color-border-info"),v("--color-border-danger"),v("--color-border-success"),v("--color-border-warning"),v("--color-border-disabled"),v("--color-ring-primary"),v("--color-ring-secondary"),v("--color-ring-inverse"),v("--color-ring-info"),v("--color-ring-danger"),v("--color-ring-success"),v("--color-ring-warning"),v("--font-sans"),v("--font-mono"),v("--font-weight-normal"),v("--font-weight-medium"),v("--font-weight-semibold"),v("--font-weight-bold"),v("--font-text-xs-size"),v("--font-text-sm-size"),v("--font-text-md-size"),v("--font-text-lg-size"),v("--font-heading-xs-size"),v("--font-heading-sm-size"),v("--font-heading-md-size"),v("--font-heading-lg-size"),v("--font-heading-xl-size"),v("--font-heading-2xl-size"),v("--font-heading-3xl-size"),v("--font-text-xs-line-height"),v("--font-text-sm-line-height"),v("--font-text-md-line-height"),v("--font-text-lg-line-height"),v("--font-heading-xs-line-height"),v("--font-heading-sm-line-height"),v("--font-heading-md-line-height"),v("--font-heading-lg-line-height"),v("--font-heading-xl-line-height"),v("--font-heading-2xl-line-height"),v("--font-heading-3xl-line-height"),v("--border-radius-xs"),v("--border-radius-sm"),v("--border-radius-md"),v("--border-radius-lg"),v("--border-radius-xl"),v("--border-radius-full"),v("--border-width-regular"),v("--shadow-hairline"),v("--shadow-sm"),v("--shadow-md"),v("--shadow-lg")]).describe("CSS variable keys available to MCP apps for theming."),M_=ke(j_.describe(`Style variables for theming MCP apps.
|
|
83
|
+
|
|
84
|
+
Individual style keys are optional - hosts may provide any subset of these values.
|
|
85
|
+
Values are strings containing CSS values (colors, sizes, font stacks, etc.).
|
|
86
|
+
|
|
87
|
+
Note: This type uses \`Record<K, string | undefined>\` rather than \`Partial<Record<K, string>>\`
|
|
88
|
+
for compatibility with Zod schema generation. Both are functionally equivalent for validation.`),le([A(),_n()]).describe(`Style variables for theming MCP apps.
|
|
89
|
+
|
|
90
|
+
Individual style keys are optional - hosts may provide any subset of these values.
|
|
91
|
+
Values are strings containing CSS values (colors, sizes, font stacks, etc.).
|
|
92
|
+
|
|
93
|
+
Note: This type uses \`Record<K, string | undefined>\` rather than \`Partial<Record<K, string>>\`
|
|
94
|
+
for compatibility with Zod schema generation. Both are functionally equivalent for validation.`)).describe(`Style variables for theming MCP apps.
|
|
95
|
+
|
|
96
|
+
Individual style keys are optional - hosts may provide any subset of these values.
|
|
97
|
+
Values are strings containing CSS values (colors, sizes, font stacks, etc.).
|
|
98
|
+
|
|
99
|
+
Note: This type uses \`Record<K, string | undefined>\` rather than \`Partial<Record<K, string>>\`
|
|
100
|
+
for compatibility with Zod schema generation. Both are functionally equivalent for validation.`),D_=b({method:v("ui/open-link"),params:b({url:A().describe("URL to open in the host's browser")})});b({isError:we().optional().describe("True if the host failed to open the URL (e.g., due to security policy).")}).passthrough();b({isError:we().optional().describe("True if the download failed (e.g., user cancelled or host denied).")}).passthrough();b({isError:we().optional().describe("True if the host rejected or failed to deliver the message.")}).passthrough();var q_=b({method:v("ui/notifications/sandbox-proxy-ready"),params:b({})}),rr=b({connectDomains:de(A()).optional().describe(`Origins for network requests (fetch/XHR/WebSocket).
|
|
101
|
+
|
|
102
|
+
- Maps to CSP \`connect-src\` directive
|
|
103
|
+
- Empty or omitted → no network connections (secure default)`),resourceDomains:de(A()).optional().describe("Origins for static resources (images, scripts, stylesheets, fonts, media).\n\n- Maps to CSP `img-src`, `script-src`, `style-src`, `font-src`, `media-src` directives\n- Wildcard subdomains supported: `https://*.example.com`\n- Empty or omitted → no network resources (secure default)"),frameDomains:de(A()).optional().describe("Origins for nested iframes.\n\n- Maps to CSP `frame-src` directive\n- Empty or omitted → no nested iframes allowed (`frame-src 'none'`)"),baseUriDomains:de(A()).optional().describe("Allowed base URIs for the document.\n\n- Maps to CSP `base-uri` directive\n- Empty or omitted → only same origin allowed (`base-uri 'self'`)")}),or=b({camera:b({}).optional().describe("Request camera access.\n\nMaps to Permission Policy `camera` feature."),microphone:b({}).optional().describe("Request microphone access.\n\nMaps to Permission Policy `microphone` feature."),geolocation:b({}).optional().describe("Request geolocation access.\n\nMaps to Permission Policy `geolocation` feature."),clipboardWrite:b({}).optional().describe("Request clipboard write access.\n\nMaps to Permission Policy `clipboard-write` feature.")}),U_=b({method:v("ui/notifications/size-changed"),params:b({width:_e().optional().describe("New width in pixels."),height:_e().optional().describe("New height in pixels.")})});b({method:v("ui/notifications/tool-input"),params:b({arguments:ke(A(),He().describe("Complete tool call arguments as key-value pairs.")).optional().describe("Complete tool call arguments as key-value pairs.")})});b({method:v("ui/notifications/tool-input-partial"),params:b({arguments:ke(A(),He().describe("Partial tool call arguments (incomplete, may change).")).optional().describe("Partial tool call arguments (incomplete, may change).")})});b({method:v("ui/notifications/tool-cancelled"),params:b({reason:A().optional().describe('Optional reason for the cancellation (e.g., "user action", "timeout").')})});var L_=b({fonts:A().optional()}),F_=b({variables:M_.optional().describe("CSS variables for theming the app."),css:L_.optional().describe("CSS blocks that apps can inject.")});b({method:v("ui/resource-teardown"),params:b({})});var H_=ke(A(),He()),uo=b({text:b({}).optional().describe("Host supports text content blocks."),image:b({}).optional().describe("Host supports image content blocks."),audio:b({}).optional().describe("Host supports audio content blocks."),resource:b({}).optional().describe("Host supports resource content blocks."),resourceLink:b({}).optional().describe("Host supports resource link content blocks."),structuredContent:b({}).optional().describe("Host supports structured content.")}),J_=b({method:v("ui/notifications/request-teardown"),params:b({}).optional()}),V_=b({experimental:ke(A(),ke(A(),di()).describe("Experimental features keyed by identifier.")).optional().describe("Experimental features keyed by identifier."),openLinks:b({}).optional().describe("Host supports opening external URLs."),downloadFile:b({}).optional().describe("Host supports file downloads via ui/download-file."),serverTools:b({listChanged:we().optional().describe("Host supports tools/list_changed notifications.")}).optional().describe("Host can proxy tool calls to the MCP server."),serverResources:b({listChanged:we().optional().describe("Host supports resources/list_changed notifications.")}).optional().describe("Host can proxy resource reads to the MCP server."),logging:b({}).optional().describe("Host accepts log messages."),sandbox:b({permissions:or.optional().describe("Permissions granted by the host (camera, microphone, geolocation)."),csp:rr.optional().describe("CSP domains approved by the host.")}).optional().describe("Sandbox configuration applied by the host."),updateModelContext:uo.optional().describe("Host accepts context updates (ui/update-model-context) to be included in the model's context for future turns."),message:uo.optional().describe("Host supports receiving content messages (ui/message) from the view."),sampling:b({tools:b({}).optional().describe("Host supports tool use via `tools` and `toolChoice` parameters.")}).optional().describe("Host supports LLM sampling (sampling/createMessage) from the view.\nMirrors the MCP `ClientCapabilities.sampling` shape so hosts can pass it through.")}),B_=b({experimental:ke(A(),ke(A(),di()).describe("Experimental features keyed by identifier.")).optional().describe("Experimental features keyed by identifier."),tools:b({listChanged:we().optional().describe("App supports tools/list_changed notifications.")}).optional().describe("App exposes MCP-style tools that the host can call."),availableDisplayModes:de(st).optional().describe("Display modes the app supports.")}),K_=b({method:v("ui/notifications/initialized"),params:b({}).optional()});b({csp:rr.optional().describe("Content Security Policy configuration for UI resources."),permissions:or.optional().describe("Sandbox permissions requested by the UI resource."),domain:A().optional().describe(`Dedicated origin for view sandbox.
|
|
104
|
+
|
|
105
|
+
Useful when views need stable, dedicated origins for OAuth callbacks, CORS policies, or API key allowlists.
|
|
106
|
+
|
|
107
|
+
**Host-dependent:** The format and validation rules for this field are determined by each host. Servers MUST consult host-specific documentation for the expected domain format. Common patterns include:
|
|
108
|
+
- Hash-based subdomains (e.g., \`{hash}.claudemcpcontent.com\`)
|
|
109
|
+
- URL-derived subdomains (e.g., \`www-example-com.oaiusercontent.com\`)
|
|
110
|
+
|
|
111
|
+
If omitted, host uses default sandbox origin (typically per-conversation).`),prefersBorder:we().optional().describe(`Visual boundary preference - true if view prefers a visible border.
|
|
112
|
+
|
|
113
|
+
Boolean requesting whether a visible border and background is provided by the host. Specifying an explicit value for this is recommended because hosts' defaults may vary.
|
|
114
|
+
|
|
115
|
+
- \`true\`: request visible border + background
|
|
116
|
+
- \`false\`: request no visible border + background
|
|
117
|
+
- omitted: host decides border`)});var lo=b({method:v("ui/request-display-mode"),params:b({mode:st.describe("The display mode being requested.")})});b({mode:st.describe("The display mode that was actually set. May differ from requested if not supported.")}).passthrough();var W_=le([v("model"),v("app")]).describe("Tool visibility scope - who can access the tool.");b({resourceUri:A().optional(),visibility:de(W_).optional().describe(`Who can access this tool. Default: ["model", "app"]
|
|
118
|
+
- "model": Tool visible to and callable by the agent
|
|
119
|
+
- "app": Tool callable by the app from this server only`),csp:vn().optional(),permissions:vn().optional()});b({mimeTypes:de(A()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')});var G_=b({method:v("ui/download-file"),params:b({contents:de(le([Ns,As])).describe("Resource contents to download — embedded (inline data) or linked (host fetches). Uses standard MCP resource types.")})}),Y_=b({method:v("ui/message"),params:b({role:v("user").describe('Message role, currently only "user" is supported.'),content:de(ft).describe("Message content blocks (text, image, etc.).")})});b({method:v("ui/notifications/sandbox-resource-ready"),params:b({html:A().describe("HTML content to load into the inner iframe."),sandbox:A().optional().describe("Optional override for the inner iframe's sandbox attribute."),csp:rr.optional().describe("CSP configuration from resource metadata."),permissions:or.optional().describe("Sandbox permissions from resource metadata.")})});b({method:v("ui/notifications/tool-result"),params:nt.describe("Standard MCP tool execution result.")});var mi=b({toolInfo:b({id:at.optional().describe("JSON-RPC id of the tools/call request."),tool:Gn.describe("Tool definition including name, inputSchema, etc.")}).optional().describe("Metadata of the tool call that instantiated this App."),theme:A_.optional().describe("Current color theme preference."),styles:F_.optional().describe("Style configuration for theming the app."),displayMode:st.optional().describe("How the UI is currently displayed."),availableDisplayModes:de(st).optional().describe("Display modes the host supports."),containerDimensions:le([b({height:_e().describe("Fixed container height in pixels.")}),b({maxHeight:le([_e(),_n()]).optional().describe("Maximum container height in pixels.")})]).and(le([b({width:_e().describe("Fixed container width in pixels.")}),b({maxWidth:le([_e(),_n()]).optional().describe("Maximum container width in pixels.")})])).optional().describe(`Container dimensions. Represents the dimensions of the iframe or other
|
|
120
|
+
container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:A().optional().describe("User's language and region preference in BCP 47 format."),timeZone:A().optional().describe("User's timezone in IANA format."),userAgent:A().optional().describe("Host application identifier."),platform:le([v("web"),v("desktop"),v("mobile")]).optional().describe("Platform type for responsive design decisions."),deviceCapabilities:b({touch:we().optional().describe("Whether the device supports touch input."),hover:we().optional().describe("Whether the device supports hover interactions.")}).optional().describe("Device input capabilities."),safeAreaInsets:b({top:_e().describe("Top safe area inset in pixels."),right:_e().describe("Right safe area inset in pixels."),bottom:_e().describe("Bottom safe area inset in pixels."),left:_e().describe("Left safe area inset in pixels.")}).optional().describe("Mobile safe area boundaries in pixels.")}).passthrough();b({method:v("ui/notifications/host-context-changed"),params:mi.describe("Partial context update containing only changed fields.")});var Q_=b({method:v("ui/update-model-context"),params:b({content:de(ft).optional().describe("Context content blocks (text, image, etc.)."),structuredContent:ke(A(),He().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.")})}),X_=b({method:v("ui/initialize"),params:b({appInfo:Jt.describe("App identification (name and version)."),appCapabilities:B_.describe("Features and capabilities this app provides."),protocolVersion:A().describe("Protocol version this app supports.")})});b({protocolVersion:A().describe('Negotiated protocol version string (e.g., "2025-11-21").'),hostInfo:Jt.describe("Host application identification and version."),hostCapabilities:V_.describe("Features and capabilities provided by the host."),hostContext:mi.describe("Rich context about the host environment.")}).passthrough();class sv{eventTarget;eventSource;messageListener;constructor(t=window.parent,n){this.eventTarget=t,this.eventSource=n,this.messageListener=r=>{if(n&&r.source!==this.eventSource){console.debug("Ignoring message from unknown source",r);return}let o=np.safeParse(r.data);o.success?(console.debug("Parsed message",o.data),this.onmessage?.(o.data)):r.data?.jsonrpc!=="2.0"?console.debug("Ignoring non-JSON-RPC message",o.error.message,r):(console.error("Failed to parse message",o.error.message,r),this.onerror?.(Error("Invalid JSON-RPC message received: "+o.error.message)))}}async start(){window.addEventListener("message",this.messageListener)}async send(t,n){t.method!==N_&&console.debug("Sending message",t),this.eventTarget.postMessage(t,"*")}async close(){window.removeEventListener("message",this.messageListener),this.onclose?.()}onclose;onerror;onmessage;sessionId;setProtocolVersion}var ev=[hi];class iv extends C_{_client;_hostInfo;_capabilities;_appCapabilities;_hostContext={};_appInfo;_initializedReceived=!1;_baseReplaceRequestHandler=this.replaceRequestHandler;replaceRequestHandler=(t,n)=>{this._baseReplaceRequestHandler(t,(r,o)=>(this._initializedReceived||console.warn(`[ext-apps] AppBridge received '${r.method}' before ui/notifications/initialized. The View is calling host methods before completing the handshake; it should await app.connect() first.`),n(r,o)))};eventSchemas={sizechange:U_,sandboxready:q_,initialized:K_,requestteardown:J_,loggingmessage:Ls};constructor(t,n,r,o){super(o),this._client=t,this._hostInfo=n,this._capabilities=r,this.addEventListener("initialized",()=>{this._initializedReceived=!0}),this._hostContext=o?.hostContext||{},this.setRequestHandler(X_,s=>this._oninitialize(s)),this.setRequestHandler(Vt,(s,i)=>(this.onping?.(s.params,i),{})),this.replaceRequestHandler(lo,s=>({mode:this._hostContext.displayMode??"inline"}))}getAppCapabilities(){return this._appCapabilities}getAppVersion(){return this._appInfo}onping;get onsizechange(){return this.getEventHandler("sizechange")}set onsizechange(t){this.setEventHandler("sizechange",t)}get onsandboxready(){return this.getEventHandler("sandboxready")}set onsandboxready(t){this.setEventHandler("sandboxready",t)}get oninitialized(){return this.getEventHandler("initialized")}set oninitialized(t){this.setEventHandler("initialized",t)}_onmessage;get onmessage(){return this._onmessage}set onmessage(t){this.warnIfRequestHandlerReplaced("onmessage",this._onmessage,t),this._onmessage=t,this.replaceRequestHandler(Y_,async(n,r)=>{if(!this._onmessage)throw Error("No onmessage handler set");return this._onmessage(n.params,r)})}_onopenlink;get onopenlink(){return this._onopenlink}set onopenlink(t){this.warnIfRequestHandlerReplaced("onopenlink",this._onopenlink,t),this._onopenlink=t,this.replaceRequestHandler(D_,async(n,r)=>{if(!this._onopenlink)throw Error("No onopenlink handler set");return this._onopenlink(n.params,r)})}_ondownloadfile;get ondownloadfile(){return this._ondownloadfile}set ondownloadfile(t){this.warnIfRequestHandlerReplaced("ondownloadfile",this._ondownloadfile,t),this._ondownloadfile=t,this.replaceRequestHandler(G_,async(n,r)=>{if(!this._ondownloadfile)throw Error("No ondownloadfile handler set");return this._ondownloadfile(n.params,r)})}get onrequestteardown(){return this.getEventHandler("requestteardown")}set onrequestteardown(t){this.setEventHandler("requestteardown",t)}_onrequestdisplaymode;get onrequestdisplaymode(){return this._onrequestdisplaymode}set onrequestdisplaymode(t){this.warnIfRequestHandlerReplaced("onrequestdisplaymode",this._onrequestdisplaymode,t),this._onrequestdisplaymode=t,this.replaceRequestHandler(lo,async(n,r)=>{if(!this._onrequestdisplaymode)throw Error("No onrequestdisplaymode handler set");return this._onrequestdisplaymode(n.params,r)})}get onloggingmessage(){return this.getEventHandler("loggingmessage")}set onloggingmessage(t){this.setEventHandler("loggingmessage",t)}_onupdatemodelcontext;get onupdatemodelcontext(){return this._onupdatemodelcontext}set onupdatemodelcontext(t){this.warnIfRequestHandlerReplaced("onupdatemodelcontext",this._onupdatemodelcontext,t),this._onupdatemodelcontext=t,this.replaceRequestHandler(Q_,async(n,r)=>{if(!this._onupdatemodelcontext)throw Error("No onupdatemodelcontext handler set");return this._onupdatemodelcontext(n.params,r)})}_oncalltool;get oncalltool(){return this._oncalltool}set oncalltool(t){this.warnIfRequestHandlerReplaced("oncalltool",this._oncalltool,t),this._oncalltool=t,this.replaceRequestHandler(Ds,async(n,r)=>{if(!this._oncalltool)throw Error("No oncalltool handler set");return this._oncalltool(n.params,r)})}set oncreatesamplingmessage(t){this.setRequestHandler(Fs,async(n,r)=>t(n.params,r))}sendToolListChanged(t={}){return this.notification({method:"notifications/tools/list_changed",params:t})}_onlistresources;get onlistresources(){return this._onlistresources}set onlistresources(t){this.warnIfRequestHandlerReplaced("onlistresources",this._onlistresources,t),this._onlistresources=t,this.replaceRequestHandler(Zs,async(n,r)=>{if(!this._onlistresources)throw Error("No onlistresources handler set");return this._onlistresources(n.params,r)})}_onlistresourcetemplates;get onlistresourcetemplates(){return this._onlistresourcetemplates}set onlistresourcetemplates(t){this.warnIfRequestHandlerReplaced("onlistresourcetemplates",this._onlistresourcetemplates,t),this._onlistresourcetemplates=t,this.replaceRequestHandler(Is,async(n,r)=>{if(!this._onlistresourcetemplates)throw Error("No onlistresourcetemplates handler set");return this._onlistresourcetemplates(n.params,r)})}_onreadresource;get onreadresource(){return this._onreadresource}set onreadresource(t){this.warnIfRequestHandlerReplaced("onreadresource",this._onreadresource,t),this._onreadresource=t,this.replaceRequestHandler(Rs,async(n,r)=>{if(!this._onreadresource)throw Error("No onreadresource handler set");return this._onreadresource(n.params,r)})}sendResourceListChanged(t={}){return this.notification({method:"notifications/resources/list_changed",params:t})}_onlistprompts;get onlistprompts(){return this._onlistprompts}set onlistprompts(t){this.warnIfRequestHandlerReplaced("onlistprompts",this._onlistprompts,t),this._onlistprompts=t,this.replaceRequestHandler(xs,async(n,r)=>{if(!this._onlistprompts)throw Error("No onlistprompts handler set");return this._onlistprompts(n.params,r)})}sendPromptListChanged(t={}){return this.notification({method:"notifications/prompts/list_changed",params:t})}assertCapabilityForMethod(t){}assertRequestHandlerCapability(t){}assertNotificationCapability(t){}assertTaskCapability(t){throw Error("Tasks are not supported in MCP Apps")}assertTaskHandlerCapability(t){throw Error("Task handlers are not supported in MCP Apps")}getCapabilities(){return this._capabilities}async _oninitialize(t){let n=t.params.protocolVersion;return this._appInfo!==void 0&&console.warn("[ext-apps] AppBridge received a second ui/initialize. The View may be double-mounting (e.g. React StrictMode in dev) without closing the previous App instance. Responding normally; the latest appInfo/appCapabilities replace the previous values."),this._appCapabilities=t.params.appCapabilities,this._appInfo=t.params.appInfo,{protocolVersion:ev.includes(n)?n:hi,hostCapabilities:this.getCapabilities(),hostInfo:this._hostInfo,hostContext:this._hostContext}}setHostContext(t){let n={},r=!1;for(let o of Object.keys(t)){let s=this._hostContext[o],i=t[o];tv(s,i)||(n[o]=i,r=!0)}r&&(this._hostContext=t,this.sendHostContextChange(n))}sendHostContextChange(t){return this.notification({method:"ui/notifications/host-context-changed",params:t})}sendToolInput(t){return this.notification({method:"ui/notifications/tool-input",params:t})}sendToolInputPartial(t){return this.notification({method:"ui/notifications/tool-input-partial",params:t})}sendToolResult(t){return this.notification({method:"ui/notifications/tool-result",params:t})}sendToolCancelled(t){return this.notification({method:"ui/notifications/tool-cancelled",params:t})}sendSandboxResourceReady(t){return this.notification({method:"ui/notifications/sandbox-resource-ready",params:t})}teardownResource(t,n){return this.request({method:"ui/resource-teardown",params:t},H_,n)}sendResourceTeardown=this.teardownResource;callTool(t,n){return this.request({method:"tools/call",params:t},nt,n)}listTools(t,n){return this.request({method:"tools/list",params:t},Ms,n)}async connect(t){if(this.transport)throw Error("AppBridge is already connected. Call close() before connecting again.");if(this._initializedReceived=!1,this._client){let n=this._client.getServerCapabilities();if(!n)throw Error("Client server capabilities not available");n.tools&&(this.oncalltool=async(r,o)=>this._client.request({method:"tools/call",params:r},nt,{signal:o.signal}),n.tools.listChanged&&this._client.setNotificationHandler(qs,r=>this.sendToolListChanged(r.params))),n.resources&&(this.onlistresources=async(r,o)=>this._client.request({method:"resources/list",params:r},Ts,{signal:o.signal}),this.onlistresourcetemplates=async(r,o)=>this._client.request({method:"resources/templates/list",params:r},Ps,{signal:o.signal}),this.onreadresource=async(r,o)=>this._client.request({method:"resources/read",params:r},Es,{signal:o.signal}),n.resources.listChanged&&this._client.setNotificationHandler(Os,r=>this.sendResourceListChanged(r.params))),n.prompts&&(this.onlistprompts=async(r,o)=>this._client.request({method:"prompts/list",params:r},Cs,{signal:o.signal}),n.prompts.listChanged&&this._client.setNotificationHandler(js,r=>this.sendPromptListChanged(r.params)))}return super.connect(t)}}function tv(e,t){return JSON.stringify(e)===JSON.stringify(t)}export{iv as D,sv as E};
|
|
121
|
+
//# sourceMappingURL=app-bridge-B-L0rGz9.js.map
|